diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 2df58091..4eb4f863 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -389,7 +389,7 @@ $route['getCreditPDReportforCETApp'] = 'SMC_Credit_PD_Controller/getCreditPDRep $route['faceMarkImage'] = 'PD_Controller/toMakeFaceBoundingBox'; $route['saveFlyhiPD'] = 'Flyhi_Controller/saveFlyhiPD'; -$route['(listFlyhiPD/:any)'] = 'Flyhi_Controller/listFlyhiPD'; +$route['listFlyhiPD'] = 'Flyhi_Controller/listFlyhiPD'; $route['getFlyhiPDSectionData'] = 'Flyhi_Controller/getFlyhiPD'; $route['loadFlyhiPDTemplate'] = 'Flyhi_Controller/loadFlyhiPDTemplate'; $route['(downloadFlyhiPDReport/:any)'] = 'Flyhi_Controller/getFlyhiPDReport'; diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index a0953ec0..4aeb47c1 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -27,7 +27,7 @@ class Flyhi_Controller extends REST_Controller { $pd_status= $records['pd_status']; $pd_from_date = $records['pd_from_date']; $pd_to_date = $records['pd_to_date']; - $pd_lender = (ENVIRONMENT == 'production' ? 19 : 31); + $pd_lender = (ENVIRONMENT == 'production' ? 19 : 49); $pd_products = isset($records['pd_products']) ? $records['pd_products'] : (ENVIRONMENT == 'production' ? 27 : 26) ; $pd_applicant_name = strtolower($records['pd_applicant_name']); $sales_pd_officer_id = isset($records['sales_pd_officer_id']) ? $records['sales_pd_officer_id'] : null ; @@ -49,11 +49,10 @@ class Flyhi_Controller extends REST_Controller { } public function getMasterForFlyhiPD_get(){ - - // $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 31); - // $FHFSL_product = (ENVIRONMENT == 'production' ? 27 : 26); - // $default_product = $FHFSL_product; - // $default_lender = $FHFSL_lender; + $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 49); + $FHFSL_product = (ENVIRONMENT == 'production' ? 27 : 26); + $default_product = $FHFSL_product; + $default_lender = $FHFSL_lender; $lender_fields = array('entity_id','full_name','short_name'); $lender_where_condition_array = array('isactive' => 1,'entity_id' => $FHFSL_lender); @@ -97,28 +96,18 @@ class Flyhi_Controller extends REST_Controller { } public function lenderMasterForFlyhiPD_get(){ - // $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 31); - // $default_lender = $FHFSL_lender; - $user_id = $this->get('user_id'); + $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 49); + $default_lender = $FHFSL_lender; + + $lender_fields = array('entity_id','full_name','short_name'); + $lender_where_condition_array = array('isactive' => 1,'entity_id' => $FHFSL_lender); + $result_data = $this->Flyhi_Model->selectCustomRecords($lender_fields,$lender_where_condition_array,ENTITY,array(),'','full_name'); + $result_data = count($result_data)>0 ? $result_data : 'Lender was not found'; - if(!empty($user_id)) - { - $default_lender = $this->Flyhi_Model->getEntityFromUserdetails($user_id); - $lender_fields = array('entity_id','full_name','short_name'); - $lender_where_condition_array = array('isactive' => 1,'entity_id' => $default_lender); - $result_data = $this->Flyhi_Model->selectCustomRecords($lender_fields,$lender_where_condition_array,ENTITY,array(),'','full_name'); - $result_data = count($result_data)>0 ? $result_data : 'Lender was not found'; - - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $result_data; - $this->response($data,REST_Controller::HTTP_OK); - }else{ - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = 'No Record Found'; - $this->response($data,REST_Controller::HTTP_OK); - } + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result_data; + $this->response($data,REST_Controller::HTTP_OK); } public function productMasterForFlyhiPD_get(){ @@ -136,14 +125,10 @@ class Flyhi_Controller extends REST_Controller { } public function branchMasterForFlyhiPD_get(){ - //$FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 31); - $lender_id = $this->get('lender_id'); - - if(!empty($lender_id)) - { + $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 49); $branches = array(); $lender_fields = array('entity_id','full_name','short_name'); - $lender_where_condition_array = array('isactive' => 1,'entity_id' => $lender_id); + $lender_where_condition_array = array('isactive' => 1,'entity_id' => $FHFSL_lender); $result_data = $this->Flyhi_Model->selectCustomRecords($lender_fields,$lender_where_condition_array,ENTITY,array(),'','full_name'); if(count($result_data)) { @@ -162,20 +147,12 @@ class Flyhi_Controller extends REST_Controller { $data['status'] = REST_Controller::HTTP_OK; $data['records'] = count($branches)>0?$branches:"Branches Not Found"; $this->response($data,REST_Controller::HTTP_OK); - } - else{ - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = 'No Branches Record Found'; - $this->response($data,REST_Controller::HTTP_OK); - } } - + public function lenderCreditPersonForFlyhiPD_get(){ - $lender_id = $this->get('lender_id'); + $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 49); + $FHFSL_product = (ENVIRONMENT == 'production' ? 27 : 26); - if(!empty($lender_id)) - { $columns = array('USERPROFILE.userid','concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as user_name','USERPROFILE.fk_entity_id','USERPROFILE.fk_city','USERPROFILEROLES.user_role','USERPROFILE.fk_entity_type_id','ROLES.role_name','if( POSITION("credit" IN ROLES.role_name),"CREDIT","SALES") as role_type'); $table = USERPROFILE.' as USERPROFILE'; $joins = array(array('table' => USERPROFILEROLES. ' as USERPROFILEROLES', @@ -185,7 +162,7 @@ class Flyhi_Controller extends REST_Controller { 'condition' =>'ROLES.role_id = USERPROFILEROLES.user_role', 'jointype' => 'INNER')); $order_by = 'USERPROFILE.userid'; - $where_condition_array['USERPROFILE.fk_entity_id'] = $lender_id; + $where_condition_array['USERPROFILE.fk_entity_id'] = $FHFSL_lender; $key_date="ROLES.role_name LIKE '%credit%'"; $condition_value=null; $where_condition_array[$key_date] = $condition_value; @@ -197,19 +174,12 @@ class Flyhi_Controller extends REST_Controller { $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $lender_contact_persons; $this->response($data,REST_Controller::HTTP_OK); - } - else{ - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = 'No Records Found'; - $this->response($data,REST_Controller::HTTP_OK); - } } + public function lenderSalesPersonForFlyhiPD_get(){ - $lender_id = $this->get('lender_id'); - - if(!empty($lender_id)) - { + $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 49); + $FHFSL_product = (ENVIRONMENT == 'production' ? 27 : 26); + $columns = array('USERPROFILE.userid','concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as user_name','USERPROFILE.fk_entity_id','USERPROFILE.fk_city','USERPROFILEROLES.user_role','USERPROFILE.fk_entity_type_id','ROLES.role_name','if( POSITION("credit" IN ROLES.role_name),"CREDIT","SALES") as role_type'); $table = USERPROFILE.' as USERPROFILE'; $joins = array(array('table' => USERPROFILEROLES. ' as USERPROFILEROLES', @@ -220,7 +190,7 @@ class Flyhi_Controller extends REST_Controller { 'jointype' => 'INNER')); $order_by = 'USERPROFILE.userid'; $or_where = array(); - $where_condition_array['USERPROFILE.fk_entity_id'] = $lender_id; + $where_condition_array['USERPROFILE.fk_entity_id'] = $FHFSL_lender; $key_date="ROLES.role_name LIKE '%sale%'"; $condition_value=null; $where_condition_array[$key_date] = $condition_value; @@ -232,195 +202,77 @@ class Flyhi_Controller extends REST_Controller { $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $lender_contact_persons; $this->response($data,REST_Controller::HTTP_OK); - } - else{ - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = 'No Records Found'; - $this->response($data,REST_Controller::HTTP_OK); - } - } - - public function listFlyhiPD_get(){ - - $user_id = $this->uri->segment(2); - - $lender_id = $this->Flyhi_Model->getEntityFromUserdetails($user_id); - $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 31); - if($lender_id == $FHFSL_lender) $sales_pd_type_master_query = '(CASE WHEN SALES_PD_DATA.sales_pd_type = 3 THEN "Workplace verification" WHEN SALES_PD_DATA.sales_pd_type = 4 THEN "Residence verification" ELSE "-" END) AS sales_pd_type_master'; - else $sales_pd_type_master_query = 'if(SALES_PD_DATA.sales_pd_type IS NULL ," ", SALES_PD_DATA.sales_pd_type ) AS sales_pd_type_master'; - - $columns = array('SALES_PD_DATA.sales_pd_id','SALES_PD_DATA.sales_pd_sno','SALES_PD_DATA.applicant_name','concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as officer_name','SALES_PD_DATA.applicant_id','SALES_PD_DATA.lender_id','SALES_PD_DATA.is_pdf','SALES_PD_DATA.is_edited','ENTITY.full_name','ENTITY.short_name','SALES_PD_DATA.status','SALES_PD_DATA.sales_pd_type','SALES_PD_DATA.rand_string','SALES_PD_DATA.isactive','SALES_PD_DATA.city_id','CITY.name as city_name', - 'SALES_PD_DATA.lender_sales_person','concat(LENDERSALESPERSON.first_name," ",LENDERSALESPERSON.last_name) as lender_sales_person_name','LENDERSALESPERSON.mobile_no as lender_sales_contact_mobileno','LENDERSALESPERSON.email as lender_sales_person_email', - 'SALES_PD_DATA.lender_credit_person','concat(LENDERCREDITPERSON.first_name," ",LENDERCREDITPERSON.last_name) as lender_credit_person_name','LENDERCREDITPERSON.mobile_no as lender_credit_person_contact_mobileno','LENDERCREDITPERSON.email as lender_credit_person_email', - 'SALES_PD_DATA.pd_branch_id','ENTITYLENDERBRANCH.branch_name','SALES_PD_DATA.loan_amount',$sales_pd_type_master_query, - '(CASE WHEN SALES_PD_DATA.status = "STARTED" THEN SALES_PD_DATA.createdon WHEN SALES_PD_DATA.status = "COMPLETED" THEN SALES_PD_DATA.completed_date ELSE NULL END) AS createdon'); - $table = SALES_PD_DATA.' as SALES_PD_DATA'; - - $joins = array( - array('table' => ENTITY. ' as ENTITY', - 'condition' =>'SALES_PD_DATA.lender_id = ENTITY.entity_id', - 'jointype' => 'INNER'), - // array('table' => PRODUCTS. ' as PRODUCT', - // 'condition' =>'SALES_PD_DATA.product_id = PRODUCT.product_id', - // 'jointype' => 'INNER'), - array('table' => CITY. ' as CITY', - 'condition' =>'SALES_PD_DATA.city_id = CITY.city_id', - 'jointype' => 'LEFT'), - array('table' => USERPROFILE. ' as USERPROFILE', - 'condition' =>'SALES_PD_DATA.createdby = USERPROFILE.userid', - 'jointype' => 'LEFT'), - array('table' => USERPROFILE. ' as LENDERSALESPERSON', - 'condition' =>'SALES_PD_DATA.lender_sales_person = LENDERSALESPERSON.userid', - 'jointype' => 'LEFT'), - array('table' => USERPROFILE. ' as LENDERCREDITPERSON', - 'condition' =>'SALES_PD_DATA.lender_credit_person = LENDERCREDITPERSON.userid', - 'jointype' => 'LEFT'), - array('table' => ENTITYLENDERBRANCH. ' as ENTITYLENDERBRANCH', - 'condition' =>'SALES_PD_DATA.pd_branch_id = ENTITYLENDERBRANCH.entity_lender_branch_id', - 'jointype' => 'LEFT') - ); - - $or_where = array(); - $where_condition_array['SALES_PD_DATA.isactive'] = 1; - - // FILTERING THE LAST 10 DAYS RECORDS - $key_date='SALES_PD_DATA.createdon BETWEEN DATE_SUB(NOW(), INTERVAL 60 DAY) AND NOW()'; - $condition_value=null; - $where_condition_array[$key_date] = $condition_value; - // ----END OF FILTERING THE LAST 10 DAYS RECORDS--- - - - if($user_id && is_numeric($user_id)) - { $where_condition_array['SALES_PD_DATA.createdby'] = $user_id; } - - if($lender_id == $FHFSL_lender) $where_condition_array['SALES_PD_DATA.sales_pd_type in (3,4)'] = null; - - $order_by = 'SALES_PD_DATA.sales_pd_id'; - - $Flyhi_pd_data = $this->Flyhi_Model->getJoinRecords($columns,$table,$joins,$where_condition_array,$order_by,'DESC','',$or_where); - //print_r($this->db->last_query());die(); - - if(count($Flyhi_pd_data)) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $Flyhi_pd_data; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = 'FlyHI PD Data Not Found! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); - } } - public function getFlyhiPD_post() - { - $records = $this->post('records'); - $section_data = array(); - if(!is_numeric($records['section_id'])){ - $fields=array('id','sales_pd_id','section_id','status','createdby','createdon'); - if($records['section_id'] == 'data'){ $fields[] = 'section_data'; } - $section_data=$this->Flyhi_Model->selectCustomRecords($fields,array('sales_pd_id' => $records['sales_pd_id'],'isactive' => 1),SALESPD_SECTION_DATA); - } - else{ - $section_data = $this->Flyhi_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $records['sales_pd_id'],'isactive' => 1,'section_id' => $records['section_id']),SALESPD_SECTION_DATA); - //print_r( json_decode($section_data[0]['section_data'],true));die(); - if($records['section_id'] == 9 && count($section_data)) - { - $all_sales_pd_images = $this->Flyhi_Model->selectCustomRecords(array('*'),array('fk_sales_pd_id' => $records['sales_pd_id'],'img_name !=' => 'satellite','isactive' => 1),SALEPD_DOCS); - // print_r($all_sales_pd_images);die(); - $photo_questions = (json_decode(($section_data[0]['section_data']),true)); - $array1 = array_map(function($element){ - return $element['img_name']; - }, $all_sales_pd_images); - $array2 = (array_count_values($array1)); - $array3 = array(); - foreach ($photo_questions['questions'] as $key => $value) - { - $array3[$value['question_key']] = (isset($value['questions_group']) && $value['is_repeatable']) ? count($value['questions_group']) : ($value['answer_value'] ? 1 : 0 ); - } - // $subtracted = array_map(function ($x, $y) { return $x-$y; } , $array2, $array3); - // $result = array_combine(array_keys($array2), $subtracted); - $result = array(); - foreach ($array2 as $key => $value) { - $var = $array2[$key] - $array3[$key]; - $result[$key] = ($var < 0 ? 0 : $var); - } -// echo "all image \n";print_r($array2);echo "section image \n"; -// print_r($array3);echo "all - section = result \n";print_r($result);die(); - - foreach ($photo_questions['questions'] as $key => $value) - { - if(isset($value['answer_value']) && $value['answer_value'] && !$value['is_repeatable']) - { - $selfie = $this->Flyhi_Model->selectCustomRecords(array('*'),array('fk_sales_pd_id' => $records['sales_pd_id'],'img_name' => 'selfie_with_person_met','isactive' => 1),SALEPD_DOCS); - if(count($selfie)) - { - $photo_questions['questions'][$key]['answer_value'] = $selfie[0]['img']; - $photo_questions['questions'][$key]['image_location'] = $selfie[0]['location']; - $photo_questions['questions'][$key]['image_id'] = $selfie[0]['doc_id']; - //$photo_questions['questions'][$key]['answer_value'] = "CHNAGED"; - } - } - else - { - foreach ($value['questions_group'] as $v_key => $individual_value) - { - //print_r($individual_value);die(); - //if($individual_value['questions'][0]['answer_value']) - // echo $individual_value['questions'][0]['question_key']; - // echo $result[$individual_value['questions'][0]['question_key']]; - // if($individual_value['questions'][0]['question_key'] == 'stock_image'){ - if (array_key_exists($individual_value['questions'][0]['question_key'],$result)){ - for($i=1;$i<=$result[$individual_value['questions'][0]['question_key']];$i++){ - $photo_questions['questions'][$key]['questions_group'][$v_key+($i)] = $photo_questions['questions'][$key]['questions_group'][0]; - } - } - // } - if(isset($individual_value['questions'][0]['answer_value'])) - { - //iterate all_sales_pd_images to get one - foreach ($all_sales_pd_images as $img_key => $img_value) - { - if($individual_value['questions'][0]['question_key'] == $img_value['img_name']) - { - $photo_questions['questions'][$key]['questions_group'][$v_key]['questions'][0]['answer_value'] = $img_value['img']; - $photo_questions['questions'][$key]['questions_group'][$v_key]['questions'][0]['image_location'] = $img_value['location']; - $photo_questions['questions'][$key]['questions_group'][$v_key]['questions'][0]['image_id'] = $img_value['doc_id']; - //$photo_questions['questions'][$key]['questions_group'][$v_key]['questions'][0]['answer_value'] = "CHANGED"; - unset($all_sales_pd_images[$img_key]); - break; - } - } - } - } - } - } - //print_r($photo_questions);die; - $photo_questions = json_encode($photo_questions); - $section_data[0]['section_data'] = $photo_questions; - } - } - if($section_data) + public function listFlyhiPD_get(){ + + $user_id = $this->uri->segment(1); + $columns = array('SALES_PD_DATA.sales_pd_id','SALES_PD_DATA.sales_pd_sno','SALES_PD_DATA.applicant_name','concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as officer_name','SALES_PD_DATA.applicant_id','SALES_PD_DATA.lender_id','SALES_PD_DATA.is_pdf','SALES_PD_DATA.is_edited','ENTITY.full_name','ENTITY.short_name','SALES_PD_DATA.status','SALES_PD_DATA.sales_pd_type','SALES_PD_DATA.rand_string','SALES_PD_DATA.isactive','SALES_PD_DATA.city_id','CITY.name as city_name', + 'SALES_PD_DATA.lender_sales_person','concat(LENDERSALESPERSON.first_name," ",LENDERSALESPERSON.last_name) as lender_sales_person_name','LENDERSALESPERSON.mobile_no as lender_sales_contact_mobileno','LENDERSALESPERSON.email as lender_sales_person_email', + 'SALES_PD_DATA.lender_credit_person','concat(LENDERCREDITPERSON.first_name," ",LENDERCREDITPERSON.last_name) as lender_credit_person_name','LENDERCREDITPERSON.mobile_no as lender_credit_person_contact_mobileno','LENDERCREDITPERSON.email as lender_credit_person_email', + 'SALES_PD_DATA.pd_branch_id','ENTITYLENDERBRANCH.branch_name','SALES_PD_DATA.loan_amount', + '(CASE WHEN SALES_PD_DATA.sales_pd_type = 3 THEN "Workplace verification" WHEN SALES_PD_DATA.sales_pd_type = 4 THEN "Residence verification" ELSE "-" END) AS sales_pd_type_master', + '(CASE WHEN SALES_PD_DATA.status = "STARTED" THEN SALES_PD_DATA.createdon WHEN SALES_PD_DATA.status = "COMPLETED" THEN SALES_PD_DATA.completed_date ELSE NULL END) AS createdon'); + $table = SALES_PD_DATA.' as SALES_PD_DATA'; + + $joins = array( + array('table' => ENTITY. ' as ENTITY', + 'condition' =>'SALES_PD_DATA.lender_id = ENTITY.entity_id', + 'jointype' => 'INNER'), + // array('table' => PRODUCTS. ' as PRODUCT', + // 'condition' =>'SALES_PD_DATA.product_id = PRODUCT.product_id', + // 'jointype' => 'INNER'), + array('table' => CITY. ' as CITY', + 'condition' =>'SALES_PD_DATA.city_id = CITY.city_id', + 'jointype' => 'LEFT'), + array('table' => USERPROFILE. ' as USERPROFILE', + 'condition' =>'SALES_PD_DATA.createdby = USERPROFILE.userid', + 'jointype' => 'LEFT'), + array('table' => USERPROFILE. ' as LENDERSALESPERSON', + 'condition' =>'SALES_PD_DATA.lender_sales_person = LENDERSALESPERSON.userid', + 'jointype' => 'LEFT'), + array('table' => USERPROFILE. ' as LENDERCREDITPERSON', + 'condition' =>'SALES_PD_DATA.lender_credit_person = LENDERCREDITPERSON.userid', + 'jointype' => 'LEFT'), + array('table' => ENTITYLENDERBRANCH. ' as ENTITYLENDERBRANCH', + 'condition' =>'SALES_PD_DATA.pd_branch_id = ENTITYLENDERBRANCH.entity_lender_branch_id', + 'jointype' => 'LEFT') + ); + + $or_where = array(); + $where_condition_array['SALES_PD_DATA.isactive'] = 1; + + // FILTERING THE LAST 10 DAYS RECORDS + $key_date='SALES_PD_DATA.createdon BETWEEN DATE_SUB(NOW(), INTERVAL 60 DAY) AND NOW()'; + $condition_value=null; + $where_condition_array[$key_date] = $condition_value; + // ----END OF FILTERING THE LAST 10 DAYS RECORDS--- + + $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 49); + if($user_id && is_numeric($user_id)) + { $where_condition_array['SALES_PD_DATA.createdby'] = $user_id; } + + $where_condition_array['SALES_PD_DATA.sales_pd_type in (3,4)'] = null; + $order_by = 'SALES_PD_DATA.sales_pd_id'; + + $Flyhi_pd_data = $this->Flyhi_Model->getJoinRecords($columns,$table,$joins,$where_condition_array,$order_by,'DESC','',$or_where); + // print_r($this->db->last_query());die(); + + if(count($Flyhi_pd_data)) { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $section_data; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $Flyhi_pd_data; + $this->response($data,REST_Controller::HTTP_OK); } else { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = 'No Data Found'; - $this->response($data,REST_Controller::HTTP_OK); - + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'FlyHI PD Data Not Found! Try Later'; + $this->response($data,REST_Controller::HTTP_OK); } - } + } public function loadFlyhiPDTemplate_post() { @@ -477,7 +329,6 @@ class Flyhi_Controller extends REST_Controller { $where_condition_array = array('SALES_PD_DATA.sales_pd_id' => $pd_id); // $where_condition_array = array('SALES_PD_DATA.sales_pd_id' => $flyhipd_id); $flyhipd_data = $this->Flyhi_Model->getJoinRecords($columns,$table,$joins,$where_condition_array); - // print_r($flyhipd_data);die(); $pd_type = ""; if($flyhipd_data[0]['sales_pd_type'] == 3){$pd_type = "Workplace FI PD-"; } else if($flyhipd_data[0]['sales_pd_type'] == 4){$pd_type = "Residence FI PD-";} @@ -505,6 +356,7 @@ class Flyhi_Controller extends REST_Controller { $all_section_data = $this->Flyhi_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $pd_id,'isactive' => 1),SALESPD_SECTION_DATA,array(),'','section_id','ASC'); // print_r($all_section_data);die(); if(!$flyhipd_data[0]['is_pdf'] || $flyhipd_data[0]['is_edited']) + // if(1) { $all_section_data = $this->Flyhi_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $pd_id,'isactive' => 1),SALESPD_SECTION_DATA,array(),'','section_id','ASC'); @@ -605,7 +457,7 @@ class Flyhi_Controller extends REST_Controller { } } } - + function processFlyhiPDJSON($section_array) { if($section_array['section_id']) @@ -847,7 +699,7 @@ class Flyhi_Controller extends REST_Controller { } return $questions;} - } + } function processFlyhiPDQuestions($questions,$section_id) { @@ -1135,11 +987,17 @@ class Flyhi_Controller extends REST_Controller { public function saveFlyhiPD_post() { $records = $this->post('records'); + $FHFSL_product = (ENVIRONMENT == 'production' ? 27 : 26); + $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 49); + $lender = isset($records['lender_id']) ? $records['lender_id'] : $FHFSL_lender; + $product = isset($records['product_id']) ? $records['product_id'] : $FHFSL_product; + $records['lender_id'] = $lender; + $records['product_id'] = $product; $id = null; - // print_r($records);//die(); + log_message('ERROR','####FLYHIPD SAVE CALLED'); $lender_short_name = $this->Flyhi_Model->selectCustomRecords(array('short_name'),array('entity_id' => $lender ),ENTITY); - log_message('ERROR','#### '.$lender_short_name.' PD SAVE CALLED'); + $product_short_name = $this->Flyhi_Model->selectCustomRecords(array('abbr'),array('product_id' => $product ),PRODUCTS); $section_names = array('1' => 'General Section','9' => 'Photography'); @@ -1157,7 +1015,7 @@ class Flyhi_Controller extends REST_Controller { $randomString .= $characters[rand(0, $charactersLength - 1)]; } $records['rand_string'] = $randomString; - log_message('ERROR','####INSERT NEW '.$lender_short_name.' PD'); + log_message('ERROR','####INSERT NEW FLYHIPD'); $salepd_serial_no = count($lender_short_name)? $lender_short_name[0]['short_name']:'UNKNOWN'; $salepd_serial_no .= count($product_short_name)? '-'.$product_short_name[0]['abbr']:'-UNKNOWN'; $salepd_serial_no .= '-'.(++$count[0]['count']); @@ -1172,7 +1030,7 @@ class Flyhi_Controller extends REST_Controller { //echo $product_short_name[0]['abbr']; if(isset($records['status']) && $records['status'] == 'COMPLETED') { - log_message('ERROR','####COMPLETE '.$lender_short_name.' PD'.$records['sales_pd_id']); + log_message('ERROR','####COMPLETE FLYHIPD'.$records['sales_pd_id']); $drafted_sections = $this->Flyhi_Model->selectCustomRecords(array('section_id'),array('status' => 0,'sales_pd_id' => $records['sales_pd_id'],'isactive' => 1),SALESPD_SECTION_DATA); $completed_sections = $this->Flyhi_Model->selectCustomRecords(array('section_id'),array('status' => 1,'sales_pd_id' => $records['sales_pd_id'],'isactive' => 1),SALESPD_SECTION_DATA); @@ -1256,7 +1114,7 @@ class Flyhi_Controller extends REST_Controller { $this->prepareFlyhiPDReport($records['sales_pd_id'],false); // die(); sleep(10); - log_message('ERROR','#### '.$lender_short_name.' PD AFTER 10 PREPARED REPORT'.$records['sales_pd_id']); + log_message('ERROR','####FlyHiPD AFTER 10 PREPARED REPORT'.$records['sales_pd_id']); // $city = ''; // $form = $this->Flyhi_Model->selectCustomRecords(array(),array('isactive' => 1,'sales_pd_id' => $records['sales_pd_id'],'section_id' => 1,'status' => 1),SALESPD_SECTION_DATA); @@ -1280,7 +1138,7 @@ class Flyhi_Controller extends REST_Controller { } else { - log_message('ERROR','#### UPDATE '.$lender_short_name.' PD => '.$records['sales_pd_id']); + log_message('ERROR','####UPDATE FLYHIPD'.$records['sales_pd_id']); $id = $this->Flyhi_Model->updateRecords($records,SALES_PD_DATA,array('sales_pd_id' => $records['sales_pd_id'])); } @@ -1305,6 +1163,7 @@ class Flyhi_Controller extends REST_Controller { } + public function saveFlyhiPDsection_Aspersalespdtype_post() { $records = $this->post('records');