%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
<?php class Program extends MY_Controller { function __construct() { parent::__construct(); not_logged_res(); $this->checkAccess('manage_programs'); $this->load->model("program_model", "prog"); $this->load->model("master_model", "master"); } function init(){ $data=$this->prog->lists(); $data['programTypes']=$this->master->programTypes(); $data['academicCareers']=$this->master->academicCareers(); $data['disciplines']=$this->master->disciplines(); $data['schools']=$this->master->schools(); $data['coupans']=$this->common->allCoupans(TRUE); $data['campuses']=$this->common->all_campus(); $this->json_data($data); } function lists(){ $data=$this->prog->lists(); $this->json_data($data); } function save(){ $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_programs.title.id!='$id']", $this->req); //|is_unique[master_programs.title.id!='$id'] $this->form_validation->set_rules('type_id', 'Type', "required", $this->req); $this->form_validation->set_rules('ac_id', 'Academic career', "required", $this->req); $this->form_validation->set_rules('discipline_id', 'Discipline', "required", $this->req); $this->form_validation->set_rules('school_id', 'School', "required", $this->req); $this->form_validation->set_rules('fee', 'Application fee', "numeric", $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', 'type_id', 'ac_id', 'discipline_id', 'school_id', 'fee', 'adm_through', 'is_medical', 'is_phd', 'status', 'highlights', 'eligibility', 'scholarship', 'career_path', 'program_fee_dtl', 'financial_assistance')); /** Image */ if($_FILES['image']['name'] && check_image_ext($_FILES['image']['name'])){ $this->load->library('Image'); $oldimg=''; if($id){ $oldimg=$this->db->select("image")->get_where("master_programs", array('id'=>$id))->row()->image; } $filename=append_to_filename($_FILES['image']['name'], time()); if($this->image->resize($_FILES['image']['tmp_name'], UP_PATHF.'programs_images/'.$filename, 600)){ $data['image']=$filename; if($oldimg){ del_file(UP_PATHF.'programs_images/'.$oldimg); } } } /** \ */ /** Brochure */ if($_FILES['brochure']['name'] && strtolower(get_ext($_FILES['brochure']['name'])) == 'pdf'){ $oldpdf=''; if($id){ $oldpdf=$this->db->select("brochure")->get_where("master_programs", 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($program_id=$this->common->save($data, "master_programs")){ /** Coupans */ $this->db->delete("coupans_in_use", array('program_id'=>$program_id)); if($post['coupans']){ foreach($post['coupans'] as $coupan_id){ $d=array('coupan_id'=>$coupan_id, 'program_id'=>$program_id, 'created'=>currentDT(), 'updated'=>currentDT()); $this->db->insert("coupans_in_use", $d); } } /** \ */ $inf['success']='T'; $inf['msg']='Program '.($id?'updated':'added').' successfully'; } } $this->json_data($inf); } } function detail($id=0){ $dtl=$this->prog->detail($id); $this->json_data($dtl); } function delete(){ $inf=array('success'=>'F', 'msg'=>'Can not deleted!'); $id=intval($this->input->post('id')); $img=$this->db->select("image")->get_where("master_programs", array('id'=>$id))->row()->image; $brochure=$this->db->select("brochure")->get_where("master_programs", array('id'=>$id))->row()->brochure; if($this->prog->delete($id)){ if($img){ del_file(UP_PATHF.'programs_images/'.$img); } if($brochure){ del_file(UP_PATHF.'brochure/'.$brochure); } $inf['success']='T'; $inf['msg']="Program deleted successfully"; } $this->json_data($inf); } function removeImage(){ $inf=array('success'=>'F', 'msg'=>'Can not removed!'); $id=intval($this->input->post('id')); $img=$this->db->select("image")->get_where("master_programs", array('id'=>$id))->row()->image; if($this->common->save(array('id'=>$id, 'image'=>''), "master_programs")){ if($img){ del_file(UP_PATHF.'programs_images/'.$img); } $inf['success']='T'; $inf['msg']="Image removed successfully"; } $this->json_data($inf); } function removeBrochure(){ $inf=array('success'=>'F', 'msg'=>'Can not removed!'); $id=intval($this->input->post('id')); $img=$this->db->select("brochure")->get_where("master_programs", array('id'=>$id))->row()->brochure; if($this->common->save(array('id'=>$id, 'brochure'=>''), "master_programs")){ if($img){ del_file(UP_PATHF.'brochure/'.$img); } $inf['success']='T'; $inf['msg']="Brochure removed successfully"; } $this->json_data($inf); } /** Plans */ function initPlans(){ $data['allPrograms']=$this->common->allPrograms(); $this->json_data($data); } function getPlans($programId=0){ $data['plans']=$this->prog->plans($programId); $this->json_data($data); } function savePlan(){ $inf=array('success'=>'F', 'msg'=>'Error!'); $post=trim_array($this->input->post()); $id=$post['id']=intval($post['id']); $this->form_validation->set_rules('program_id', 'Program', "required", $this->req); $this->form_validation->set_rules('campus_ids[]', 'Campus', "required", $this->req); $this->form_validation->set_rules('title', 'Name', "required", $this->req); /* $this->form_validation->set_rules('code', 'Plan code', "required|is_unique[master_program_plans.code.id!='$id']", $this->req); */ $this->form_validation->set_rules('code', 'Plan code', "required", $this->req); $this->form_validation->set_rules('fee', 'Application fee', "numeric", $this->req); $this->form_validation->set_rules('program_code', 'Program code', "required", $this->req); $this->form_validation->set_rules('ac_code', 'Career code', "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', 'program_id', 'title', 'code', 'program_code', 'ac_code', 'fee', 'program_fee', 'program_duration', 'status')); $data['campus_ids']=implode(",", $post['campus_ids']); if($post['fee_year']){ $fee_year=array_values($post['fee_year']); $data['fee_year_wise']=trim(implode(",", $fee_year), ","); } if($post['fee_semester']){ $fee_semester=array_values($post['fee_semester']); $data['fee_semester_wise']=trim(implode(",", $fee_semester), ","); } if($plan_id=$this->common->save($data, "master_program_plans")){ /** Coupans */ $this->db->delete("coupans_in_use", array('plan_id'=>$plan_id)); if($post['coupans']){ foreach($post['coupans'] as $coupan_id){ $d=array('coupan_id'=>$coupan_id, 'plan_id'=>$plan_id, 'created'=>currentDT(), 'updated'=>currentDT()); $this->db->insert("coupans_in_use", $d); } } /** \ */ $inf['success']='T'; $inf['msg']='Plan '.($id?'updated':'added').' successfully'; } } $this->json_data($inf); } function planDetail($id=0){ $dtl=$this->prog->planDetail($id); $this->json_data($dtl); } function deletePlan(){ $inf=array('success'=>'F', 'msg'=>'Can not deleted!'); $id=intval($this->input->post('id')); if($this->prog->deletePlan($id)){ $inf['success']='T'; $inf['msg']="Plan deleted successfully"; } $this->json_data($inf); } function uploadPlanExcel(){ $post=trim_array($this->input->post()); $inf=array('success'=>'F', 'msg'=>'Error!'); if(!$post['program_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; $r=trim_array($r); if($r[0]){ $d=array( 'program_id'=>$post['program_id'], 'title'=>$r[0], 'code'=>$r[1], 'ac_code'=>$r[2], 'program_code'=>$r[3], 'fee'=>$r[4], 'program_fee'=>$r[5], 'program_duration'=>$r[6], 'status'=>1, 'created_by'=>USER_ID, 'updated_by'=>USER_ID, 'created'=>currentDT(), 'updated'=>currentDT() ); if($id=$this->db->select("id")->get_where("master_program_plans", array('title'=>$r[0], 'program_id'=>$post['program_id']))->row()->id){ $this->db->update("master_program_plans", $d, array('id'=>$id)); }else{ $this->db->insert("master_program_plans", $d); $c++; } } } $inf['success']='T'; $inf['msg']="$c records added"; $this->json_data($inf); } /** Suggested Programs/Plans */ function initSuggestedPrograms($programId=0){ $data['allPrograms']=$this->common->allPrograms(); $data['suggestedPrograms']=$this->prog->suggestedPrograms($programId); $this->json_data($data); } function addSuggestedProgram(){ $inf=array('success'=>'F', 'msg'=>'Error!'); $post=trim_array($this->input->post()); if($this->db->get_where("suggested_programs", array('program_id'=>$post['program_id'], 'sug_program_id'=>$post['sug_program_id']))->row()->id){ $inf['msg']="Already added"; $this->json_data($inf); } $data=array('program_id'=>$post['program_id'], 'sug_program_id'=>$post['sug_program_id']); if($this->common->save($data, "suggested_programs")){ $inf['suggestedPrograms']=$this->prog->suggestedPrograms($post['program_id']); $inf['success']='T'; $inf['msg']="Program added"; } $this->json_data($inf); } function deleteSuggestedProgram(){ $inf=array('success'=>'F', 'msg'=>'Error!'); $post=trim_array($this->input->post()); $program_id=$this->db->get_where("suggested_programs", array('id'=>$post['id']))->row()->program_id; if($this->db->delete("suggested_programs", array('id'=>$post['id']))){ $inf['suggestedPrograms']=$this->prog->suggestedPrograms($program_id); $inf['success']='T'; $inf['msg']="Removed"; } $this->json_data($inf); } function addSuggestedPlans(){ $inf=array('success'=>'F', 'msg'=>'Error!'); $post=trim_array($this->input->post()); if(!$post['sug_program_id']){ $inf['msg']="Invalid Data!"; $this->json_data($inf); } if(!$post['splans']){ //$inf['msg']="Select plans!"; $this->json_data($inf); $post['splans']=[]; } $this->db->delete("suggested_plans", array('sug_program_id'=>$post['sug_program_id'])); $splans=[]; foreach($post['splans'] as $plan_id){ $splans[]=array('sug_program_id'=>$post['sug_program_id'], 'plan_id'=>$plan_id, 'created_by'=>USER_ID, 'updated_by'=>USER_ID, 'created'=>currentDT(), 'updated'=>currentDT()); } if($splans){ $this->db->insert_batch("suggested_plans", $splans); } $inf['success']='T'; $inf['msg']="Plans assigned"; $this->json_data($inf); } } //EOF