<commit_before>'use strict';

// Projects controller
angular.module('projects').controller('ProjectsController', ['$scope', '$stateParams', '$location', 'Authentication', 'Projects', '$upload', 'ngAudio', '$http',
	function($scope, $stateParams, $location, Authentication, Projects, $upload, ngAudio, $http ) {
		$scope.authentication = Authentication;

		// rating
		$scope.max = 5;
		$scope.isReadonly = false;
		$scope.ratings = [];
		$scope.ratingsAvg = [];
		// static project options
		$scope.projProgress = [];
		$scope.selCheckVal = 0;
		$scope.client = [];
		$scope.talent = [];
		$scope.showRename = 0;
		$scope.statusOpts = ['In Progress', 'On Hold', 'Booked', 'Canceled', 'ReAuditioned', 'Dead', 'Closed - Pending Client Decision', 'Complete'];
		$scope.priorityOpts = ['None', 'Very low', 'Low', 'Medium', 'High', 'Very high'];
		$scope.phaseStatusOpts = ['in progress','open','complete','suspended'];
		$scope.soundersOpts = ['Sounders', 'No Sounders - Approved By William'];
		$scope.talentStatus = ['Cast', 'Emailed', 'Scheduled', 'Message left', 'Out', 'Received needs to be posted', 'Posted', 'Not Posted (Bad Read)'];
		$scope.loadAudio = 0;
		$scope.audio = [];
		$scope.lastAudioID = 0;
		$scope.newLead = {};
		$scope.referenceFiles = [];
		$scope.scripts = [];
		$scope.newProject = {notifyClient: true};
		$scope.parts = [];
		$scope.toggleRefs = false;
		$scope.selectedMainClients = [];

		$scope.hoveringOver = function(value,key,object) {
	        $scope.overStar = value;
	        $scope.percent = 100 * (value / $scope.max);
	        $scope.selCheckVal = value;
      	};

      	// compare dates check for within hour
      	$scope.compareDates = function(projDate){
      		var now = new Date();
      		projDate = new Date(projDate);

      		var hours = Math.abs(projDate - now) / 36e5;

      		if(hours < 1){
      			return true
      		}
      	};
      	$scope.checkPassed = function(projDate){
      		var now = new Date();
      		projDate = new Date(projDate);

      		if(now > projDate){
      			return true
      		}
      	};

      	// show part field if talent value is not already checked
      	$scope.showPartFld = function(id){
      		for(var i = 0; i < $scope.project.talent.length; ++i){
      			if($scope.project.talent[i].talentId === String(id)){
      				if($scope.project.talent[i].requested === true || $scope.project.talent[i].regular === true){
      					return false
      				}
      			}
      		}
   			return true
     	};
     	$scope.showCreatePartFld = function(id){
      		for(var i = 0; i < $scope.talent.length; ++i){
      			if($scope.talent[i].talentId === String(id)){
      				if($scope.talent[i].requested === true || $scope.talent[i].regular === true){
      					return false
      				}
      			}
      		}
   			return true
     	};

		// verify users
		$scope.permitAdminDirector = function(){
			var allowRoles = ['admin', 'producer/auditions director'];

			for(var i = 0; i < Authentication.user.roles.length; ++i){
				for(var j = 0; j < allowRoles.length; ++j){
					if(Authentication.user.roles[i] === allowRoles[j]) {
						return true;
					}
				}
			}
		};
		$scope.permitAdminTalentDirectorProdCoord = function(){
			var allowRoles = ['admin', 'talent director', 'production coordinator'];

			for(var i = 0; i < Authentication.user.roles.length; ++i){
				for(var j = 0; j < allowRoles.length; ++j){
					if(Authentication.user.roles[i] === allowRoles[j]) {
						return true;
					}
				}
			}
		};
		$scope.permitEveryOneButClients = function(){
			var allowRoles = ['admin', 'producer/auditions director', 'production coordinator', 'talent director'];

			for(var i = 0; i < Authentication.user.roles.length; ++i){
				for(var j = 0; j < allowRoles.length; ++j){
					if(Authentication.user.roles[i] === allowRoles[j]) {
						return true;
					}
				}
			}
		};
		$scope.permitClient = function(){
			var allowRoles = ['client'];

			for(var i = 0; i < Authentication.user.roles.length; ++i){
				for(var j = 0; j < allowRoles.length; ++j){
					if(Authentication.user.roles[i] === allowRoles[j]) {
						return true;
					}
				}
			}
		};
		$scope.permitClientClient = function(){
			var allowRoles = ['client-client'];

			for(var i = 0; i < Authentication.user.roles.length; ++i){
				for(var j = 0; j < allowRoles.length; ++j){
					if(Authentication.user.roles[i] === allowRoles[j]) {
						return true;
					}
				}
			}
		};

		// verify create access
		$scope.userCheck = function(){
			if(Authentication.user.roles[0] !== 'admin' && Authentication.user.roles[0] !== 'producer/auditions director'){
				$location.path('/projects');
			}
		};

		// send various client emails
		$scope.sendClientEmail = function(type){

			$http.post('/projects/sendclientemail', {
		        type: type,
		        project: $scope.project,
		        clients: $scope.selectedMainClients
		    }).
			success(function(data, status, headers, config) {
        		alert('Clients Emailed ' + type + ' Email ');
        		$scope.selectedMainClients = [];
        	}).<commit_msg>client update email project note addition<commit_after>'use strict';

// Projects controller
angular.module('projects').controller('ProjectsController', ['$scope', '$stateParams', '$location', 'Authentication', 'Projects', '$upload', 'ngAudio', '$http',
	function($scope, $stateParams, $location, Authentication, Projects, $upload, ngAudio, $http ) {
		$scope.authentication = Authentication;

		// rating
		$scope.max = 5;
		$scope.isReadonly = false;
		$scope.ratings = [];
		$scope.ratingsAvg = [];
		// static project options
		$scope.projProgress = [];
		$scope.selCheckVal = 0;
		$scope.client = [];
		$scope.talent = [];
		$scope.showRename = 0;
		$scope.statusOpts = ['In Progress', 'On Hold', 'Booked', 'Canceled', 'ReAuditioned', 'Dead', 'Closed - Pending Client Decision', 'Complete'];
		$scope.priorityOpts = ['None', 'Very low', 'Low', 'Medium', 'High', 'Very high'];
		$scope.phaseStatusOpts = ['in progress','open','complete','suspended'];
		$scope.soundersOpts = ['Sounders', 'No Sounders - Approved By William'];
		$scope.talentStatus = ['Cast', 'Emailed', 'Scheduled', 'Message left', 'Out', 'Received needs to be posted', 'Posted', 'Not Posted (Bad Read)'];
		$scope.loadAudio = 0;
		$scope.audio = [];
		$scope.lastAudioID = 0;
		$scope.newLead = {};
		$scope.referenceFiles = [];
		$scope.scripts = [];
		$scope.newProject = {notifyClient: true};
		$scope.parts = [];
		$scope.toggleRefs = false;
		$scope.selectedMainClients = [];

		$scope.hoveringOver = function(value,key,object) {
	        $scope.overStar = value;
	        $scope.percent = 100 * (value / $scope.max);
	        $scope.selCheckVal = value;
      	};

      	// compare dates check for within hour
      	$scope.compareDates = function(projDate){
      		var now = new Date();
      		projDate = new Date(projDate);

      		var hours = Math.abs(projDate - now) / 36e5;

      		if(hours < 1){
      			return true
      		}
      	};
      	$scope.checkPassed = function(projDate){
      		var now = new Date();
      		projDate = new Date(projDate);

      		if(now > projDate){
      			return true
      		}
      	};

      	// show part field if talent value is not already checked
      	$scope.showPartFld = function(id){
      		for(var i = 0; i < $scope.project.talent.length; ++i){
      			if($scope.project.talent[i].talentId === String(id)){
      				if($scope.project.talent[i].requested === true || $scope.project.talent[i].regular === true){
      					return false
      				}
      			}
      		}
   			return true
     	};
     	$scope.showCreatePartFld = function(id){
      		for(var i = 0; i < $scope.talent.length; ++i){
      			if($scope.talent[i].talentId === String(id)){
      				if($scope.talent[i].requested === true || $scope.talent[i].regular === true){
      					return false
      				}
      			}
      		}
   			return true
     	};

		// verify users
		$scope.permitAdminDirector = function(){
			var allowRoles = ['admin', 'producer/auditions director'];

			for(var i = 0; i < Authentication.user.roles.length; ++i){
				for(var j = 0; j < allowRoles.length; ++j){
					if(Authentication.user.roles[i] === allowRoles[j]) {
						return true;
					}
				}
			}
		};
		$scope.permitAdminTalentDirectorProdCoord = function(){
			var allowRoles = ['admin', 'talent director', 'production coordinator'];

			for(var i = 0; i < Authentication.user.roles.length; ++i){
				for(var j = 0; j < allowRoles.length; ++j){
					if(Authentication.user.roles[i] === allowRoles[j]) {
						return true;
					}
				}
			}
		};
		$scope.permitEveryOneButClients = function(){
			var allowRoles = ['admin', 'producer/auditions director', 'production coordinator', 'talent director'];

			for(var i = 0; i < Authentication.user.roles.length; ++i){
				for(var j = 0; j < allowRoles.length; ++j){
					if(Authentication.user.roles[i] === allowRoles[j]) {
						return true;
					}
				}
			}
		};
		$scope.permitClient = function(){
			var allowRoles = ['client'];

			for(var i = 0; i < Authentication.user.roles.length; ++i){
				for(var j = 0; j < allowRoles.length; ++j){
					if(Authentication.user.roles[i] === allowRoles[j]) {
						return true;
					}
				}
			}
		};
		$scope.permitClientClient = function(){
			var allowRoles = ['client-client'];

			for(var i = 0; i < Authentication.user.roles.length; ++i){
				for(var j = 0; j < allowRoles.length; ++j){
					if(Authentication.user.roles[i] === allowRoles[j]) {
						return true;
					}
				}
			}
		};

		// verify create access
		$scope.userCheck = function(){
			if(Authentication.user.roles[0] !== 'admin' && Authentication.user.roles[0] !== 'producer/auditions director'){
				$location.path('/projects');
			}
		};

		// send various client emails
		$scope.sendClientEmail = function(type){

			$http.post('/projects/sendclientemail', {
		        type: type,
		        project: $scope.project,
		        clients: $scope.selectedMainClients
		    }).
			success(function(data, status, headers, config) {
        		alert('Clients Emailed ' + type + ' Email ');
        		$scope.selectedMainClients = [];

				var now = new Date();
				var item = {
							date: now.toJSON(), 
							userid: Authentication.user._id, 
							username: Authentication.user.displayName, 
							item: '', 
							deleted: false
						};

        		// add note
        		switch(type){
        			case 'opening':
						var note = 'Client Notified of Project Start by ' + Authentication.user.displayName;
					break;
					case 'carryover':
						var note = 'Client sent Carryover by ' + Authentication.user.displayName;
					break;
					case 'closing':
						var note = 'Client Notified of Project Completion by ' + Authentication.user.displayName;
					break;
        		}

        		// add note to note object
        		item.item = note;

        		// add to project discussion
        		$scope.project.discussion.push(item);

        		// update project store
				$scope.update();
        	}).
{'fraction_non_alphanumeric': 0.1645500725689405, 'fraction_numerical': 0.0047169811320754715, 'mean_word_length': 2.6872909698996654, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4264076', 'n_tokens_mistral': 4258, 'n_tokens_neox': 3638, 'n_words': 773}