From 1249f11e5cf851d0f37f19e51704deb3fe165b15 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Sat, 25 Jun 2022 18:53:19 +0530 Subject: [PATCH] code moved : ps --- .../controllers/Flyhi_Controller.php | 187 +++++++++++++++++- 1 file changed, 183 insertions(+), 4 deletions(-) diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index 8ac18465..230ce979 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -704,7 +704,7 @@ class Flyhi_Controller extends REST_Controller { //$view_name = $flyhipd_data[0]['short_name'].'_'.$flyhipd_data[0]['abbr']; $view_name = $flyhipd_data[0]['short_name']; $html_content = $this->load->view('sale_pd_templates/'.$view_name,$view_data,true); - // echo $html_content;die(); + echo $html_content;die(); $pdf_doc = $this->pdfgenerator->generate($html_content, $filename='version', $stream=false, $paper = 'A4', $orientation = "portrait"); //End of PDF Gen using DOM PDF $output_file = $this->external_path ."/sales_pd/" .$pd_id. "/temp.pdf"; @@ -766,9 +766,188 @@ class Flyhi_Controller extends REST_Controller { if($section_array['section_id']) { $questions = json_decode($section_array['section_data'],true); - return $this->processFlyhiPDQuestions($questions['questions'],$section_array['section_id']); + return $this->processFlyhiPDData($questions['json'],$section_array['section_id']); + // return $this->processFlyhiPDQuestions($questions['questions'],$section_array['section_id']); } } + function processFlyhiPDData($questions,$section_id){ + $temp_array = array(); + foreach ($questions as $ques_key => $ques_value) { + if($ques_key == 'permanent_state' && !empty($ques_value)){ + + $table = STATE; + $fields = array('name'); + $where_condition_array = array('isactive' => 1,'state_id'=>$ques_value); + $result_data = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,$table); + if(count($result_data)) + { + $new_key = $ques_key . '_master'; + $questions[$new_key] = $result_data[0]['name']; + } + + }if($ques_key == 'business_state' && !empty($ques_value)){ + $table = STATE; + $fields = array('name'); + $where_condition_array = array('isactive' => 1,'state_id'=>$ques_value); + $result_data = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,$table); + if(count($result_data)) + { + $new_key = $ques_key . '_master'; + $questions[$new_key] = $result_data[0]['name']; + } + + }if($ques_key == 'officer_state' && !empty($ques_value)){ + $table = STATE; + $fields = array('name'); + $where_condition_array = array('isactive' => 1,'state_id'=>$ques_value); + $result_data = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,$table); + if(count($result_data)) + { + $new_key = $ques_key . '_master'; + $questions[$new_key] = $result_data[0]['name']; + } + } + if($ques_key == 'permanent_city'){ + $table = CITY; + $fields = array('name'); + $where_condition_array = array('isactive' => 1,'city_id'=>$ques_value); + $result_data = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,$table); + if(count($result_data)) + { + $new_key = $ques_key . '_master'; + $questions[$new_key] = $result_data[0]['name']; + } + }if($ques_key == 'business_city'){ + $table = CITY; + $fields = array('name'); + $where_condition_array = array('isactive' => 1,'city_id'=>$ques_value); + $result_data = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,$table); + if(count($result_data)) + { + $new_key = $ques_key . '_master'; + $questions[$new_key] = $result_data[0]['name']; + } + }if($ques_key == 'officer_city'){ + $table = CITY; + $fields = array('name'); + $where_condition_array = array('isactive' => 1,'city_id'=>$ques_value); + $result_data = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,$table); + if(count($result_data)) + { + $new_key = $ques_key . '_master'; + $questions[$new_key] = $result_data[0]['name']; + } + } + if($ques_key == 'business_pincode' && $ques_value != "1"){ + $table = PINCODE; + $fields = array('pincode'); + $where_condition_array = array('pincode_id'=>$ques_value); + $result_data = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,$table); + if(count($result_data)) + { + $new_key = $ques_key . '_master'; + $questions[$new_key] = $result_data[0]['pincode']; + } + + }if($ques_key == 'business_pincode_others' && $ques_value == "1"){ + $new_key = 'business_pincode_master'; + $questions[$new_key] = $result_data[0]['pincode']; + } + if($ques_key == 'permanent_pincode' && $ques_value != "1"){ + $table = PINCODE; + $fields = array('pincode'); + $where_condition_array = array('pincode_id'=>$ques_value); + $result_data = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,$table); + if(count($result_data)) + { + $new_key = $ques_key . '_master'; + $questions[$new_key] = $result_data[0]['pincode']; + } + }if($ques_key == 'permanent_pincode_others' && $ques_value == "1"){ + $new_key = $ques_key . 'permanent_pincode_master'; + $questions[$new_key] = $result_data[0]['pincode']; + } + if($ques_key == 'officer_pincode' && $ques_value != "1"){ + // residence_pincode: "1" + // residence_pincode_others: "600016" + $table = PINCODE; + $fields = array('pincode'); + $where_condition_array = array('pincode_id'=>$ques_value); + $result_data = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,$table); + if(count($result_data)) + { + $new_key = $ques_key . '_master'; + $questions[$new_key] = $result_data[0]['pincode']; + } + }if($ques_key == 'officer_pincode_others'){ + $new_key = 'officer_pincode_master'; + $questions[$new_key] = $result_data[0]['pincode']; + } + if($ques_key == 'lender_name'){ + $table = ENTITY; + $fields = array('full_name','short_name'); + $where_condition_array = array('entity_id'=>$ques_value); + $result_data = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,$table); + if(count($result_data)) + { + $new_key = $ques_key . '_master'; + $questions[$new_key] = $result_data[0]['full_name']; + $questions["lender_abbr"] = $result_data[0]['short_name']; + } + } + if($ques_key == 'branch'){ + + $table = ENTITYLENDERBRANCH; + $fields = array('branch_name as name'); + $where_condition_array = array('entity_lender_branch_id'=>$ques_value); + $result_data = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,$table); + if(count($result_data)) + { + $new_key = $ques_key . '_master'; + $questions[$new_key] = $result_data[0]['name']; + } + } + if($ques_key == 'lender_sales_person'){ + $table = USERPROFILE; + $fields = array('concat(first_name," ",last_name) as name'); + $where_condition_array = array('userid'=>$ques_value); + $result_data = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,$table); + if(count($result_data)) + { + $new_key = $ques_key . '_master'; + $questions[$new_key] = $result_data[0]['name']; + } + + } + if($ques_key == 'lender_credit_person'){ + $table = USERPROFILE; + $fields = array('concat(first_name," ",last_name) as name'); + $where_condition_array = array('userid'=>$ques_value); + $result_data = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,$table); + if(count($result_data)) + { + $new_key = $ques_key . '_master'; + $questions[$new_key] = $result_data[0]['name']; + } + } + if($ques_key == 'product_name'){ + $table = PRODUCTS; + $fields = array('name'); + $where_condition_array = array('product_id'=>$ques_value); + $result_data = $this->Flyhi_Model->selectCustomRecords($fields,$where_condition_array,$table); + if(count($result_data)) + { + $new_key = $ques_key . '_master'; + $questions[$new_key] = $result_data[0]['name']; + } + } + if($ques_key == 'residence_details'){ + + } + + } + print_r($questions);die(); + } function processFlyhiPDQuestions($questions,$section_id) { @@ -1053,8 +1232,8 @@ class Flyhi_Controller extends REST_Controller { $records = $this->post('records'); $FHFSL_product = (ENVIRONMENT == 'production' ? 27 : 26); $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 49); - $lender = $records['lender_id'] ? $records['lender_id'] : $FHFSL_lender; - $product = $records['product_id'] ? $records['product_id'] : $FHFSL_product; + $lender = isset($records['lender_id']) ? $records['lender_id'] : $FHFSL_lender; + $product = isset($records['product_id']) ? $records['product_id'] : $FHFSL_product; $id = null; // print_r($records);//die(); log_message('ERROR','####FLYHIPD SAVE CALLED');