/**
 * widgetCustomerNotificationsCtrl Controller
 * Extracted from bookings module
 */

Bookings.controller('widgetCustomerNotificationsCtrl', ['$scope', 'ErrorsHandler', '$timeout', 'CustomerNotificationsService', '$uibModal', function ($scope, ErrorsHandler, $timeout, CustomerNotificationsService, $uibModal) {

	/**
	 * Notifications sent to the client related to a task
	 *
	 * @array
	 */

	$scope.notifications = CustomerNotificationsService.notifications;


	$scope.sendNotification = function () {

		var modalInstance = $uibModal.open({
			templateUrl: 'bookings/modals/new-customer-notification.html',
			controller: 'CustomerNotificationCtrl',
			resolve: {
				taskId: function () {
					return $scope.task.id;
				},
				notification: null,
			}

		});
	};

	$scope.showNotification = function (notification) {

		var modalInstance = $uibModal.open({
			templateUrl: 'bookings/modals/customer-notification.html',
			controller: 'CustomerNotificationCtrl',
			resolve: {
				notification: function () {
					return notification;
				},
				taskId: function () {
					return $scope.task.id;
				}
			}

		});

	};

}])
