From 68d242f512365d24572d852c1d5126712238c384 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Thu, 8 Jun 2023 13:48:25 +0530 Subject: [PATCH] Dynamic CHnages api : ps --- .../controllers/Flyhi_Controller.php | 421 ++++-------------- 1 file changed, 89 insertions(+), 332 deletions(-) diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index 74002b90..4aba0268 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 : 49); + $pd_lender = (ENVIRONMENT == 'production' ? 19 : 31); $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,10 +49,11 @@ class Flyhi_Controller extends REST_Controller { } public function getMasterForFlyhiPD_get(){ - $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 49); - $FHFSL_product = (ENVIRONMENT == 'production' ? 27 : 26); - $default_product = $FHFSL_product; - $default_lender = $FHFSL_lender; + + // $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 31); + // $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); @@ -96,18 +97,28 @@ class Flyhi_Controller extends REST_Controller { } public function lenderMasterForFlyhiPD_get(){ - $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'; + // $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 31); + // $default_lender = $FHFSL_lender; + $user_id = $this->get('user_id'); - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $result_data; - $this->response($data,REST_Controller::HTTP_OK); + 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); + } } public function productMasterForFlyhiPD_get(){ @@ -125,10 +136,14 @@ class Flyhi_Controller extends REST_Controller { } public function branchMasterForFlyhiPD_get(){ - $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 49); + //$FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 31); + $lender_id = $this->get('lender_id'); + + if(!empty($lender_id)) + { $branches = array(); $lender_fields = array('entity_id','full_name','short_name'); - $lender_where_condition_array = array('isactive' => 1,'entity_id' => $FHFSL_lender); + $lender_where_condition_array = array('isactive' => 1,'entity_id' => $lender_id); $result_data = $this->Flyhi_Model->selectCustomRecords($lender_fields,$lender_where_condition_array,ENTITY,array(),'','full_name'); if(count($result_data)) { @@ -147,12 +162,20 @@ 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(){ - $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 49); - $FHFSL_product = (ENVIRONMENT == 'production' ? 27 : 26); + $lender_id = $this->get('lender_id'); + 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', @@ -162,7 +185,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'] = $FHFSL_lender; + $where_condition_array['USERPROFILE.fk_entity_id'] = $lender_id; $key_date="ROLES.role_name LIKE '%credit%'"; $condition_value=null; $where_condition_array[$key_date] = $condition_value; @@ -174,11 +197,19 @@ 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(){ - $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 49); - $FHFSL_product = (ENVIRONMENT == 'production' ? 27 : 26); - + $lender_id = $this->get('lender_id'); + + 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', @@ -189,7 +220,7 @@ class Flyhi_Controller extends REST_Controller { 'jointype' => 'INNER')); $order_by = 'USERPROFILE.userid'; $or_where = array(); - $where_condition_array['USERPROFILE.fk_entity_id'] = $FHFSL_lender; + $where_condition_array['USERPROFILE.fk_entity_id'] = $lender_id; $key_date="ROLES.role_name LIKE '%sale%'"; $condition_value=null; $where_condition_array[$key_date] = $condition_value; @@ -201,16 +232,28 @@ 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(1); + + $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 = 5 THEN "-" END IF) 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', - '(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', + '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'; @@ -247,11 +290,12 @@ class Flyhi_Controller extends REST_Controller { $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; + 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); @@ -273,290 +317,6 @@ class Flyhi_Controller extends REST_Controller { } } - public function saveFlyhiPDOLD_post() - { - $records = $this->post('records'); - $is_entry_done = null; - $flyhi_pd_id = null; - $section_data = json_encode($records); - $fk_createdby = isset($records['fk_createdby']) ? $records['fk_createdby'] : ""; - $applicant_id = null; - $applicant_name = null; - $city = null; - $lender_id = null; - $loan_amount = null; - $pd_branch_id = null; - $lender_sales_person = null; - $lender_credit_person = null; - $product_id = null; - // $product_short_name = $this->Flyhi_Model->selectCustomRecords(array('abbr'),array('product_id' => $records['product_id']),PRODUCTS); - - log_message('ERROR','####FLYHI-PD SAVE CALLED'); - - $section_names = array('1' => 'General Section','9' => 'Photography'); - // $section_names = array('1' => 'General Section'); - - if($records['sales_pd_id'] == '' || $records['sales_pd_id'] == null) - { - - /************ASSIGN Random URL******************/ - $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-'; - $charactersLength = strlen($characters); - $randomString = ''; - for ($i = 0; $i < 16; $i++) - { - $randomString .= $characters[rand(0, $charactersLength - 1)]; - } - - $records['rand_string'] = $randomString; - log_message('ERROR','####INSERT NEW FLYHIPD'); - if($records['questions']) - { - foreach ($records['questions'] as $g_key => $g_value) - { - if(isset($g_value['question_key']) && $g_value['question_key'] === 'loan_application_id') - { - $applicant_id = $g_value['answer_value'] ? $g_value['answer_value'] : 'Not Provided'; - } - if(isset($g_value['question_key']) && $g_value['question_key'] == 'lender_name') - { - $lender_id = $g_value['answer_value']; - } - if(isset($g_value['question_key']) && $g_value['question_key'] == 'loan_amount') - { - $loan_amount = $g_value['answer_value']; - } - if(isset($g_value['question_key']) && $g_value['question_key'] == 'branch') - { - $pd_branch_id = $g_value['answer_value']; - } - if(isset($g_value['question_key']) && $g_value['question_key'] == 'lender_sales_person') - { - $lender_sales_person = $g_value['answer_value']; - } - if(isset($g_value['question_key']) && $g_value['question_key'] == 'lender_credit_person') - { - $lender_credit_person = $g_value['answer_value']; - } - if(isset($g_value['question_key']) && $g_value['question_key'] == 'product_name') - { - $product_id = $g_value['answer_value']; - } - - if(isset($g_value['question_key']) && $g_value['question_key'] == 'verification_type') - { - if(isset($g_value['onchange_properties'])) - { - foreach ($g_value['onchange_properties'] as $h_key => $h_value) - { - foreach ($h_value['form_controls'] as $i_key => $i_value) - { - foreach ($i_value['questions'] as $j_key => $j_value) - { - if($g_value['answer_value'] == 'Residence verification' && $j_value['question_key'] == 'residence_city'){ - $city = $j_value['answer_value']; - $flyhi_pd_type = 4; - } - if($g_value['answer_value'] == 'Office verification' && $j_value['question_key'] == 'officer_city'){ - $city = $j_value['answer_value']; - $flyhi_pd_type = 3; - } - - } - } - } - } - } - - } - - } - $count = $this->Flyhi_Model->selectCustomRecords(array('count(*) as count'),array('lender_id' => $lender_id,'isactive' => 1),SALES_PD_DATA); - $lender_short_name = $this->Flyhi_Model->selectCustomRecords(array('short_name'),array('entity_id' => $lender_id),ENTITY); - $FLYHI_PD['applicant_name'] = $applicant_name; - $FLYHI_PD['applicant_id'] = $applicant_id; - $FLYHI_PD['city_id']=$city; - $FLYHI_PD['loan_amount'] = $loan_amount; - $FLYHI_PD['lender_sales_person'] = $lender_sales_person ; - $FLYHI_PD['lender_credit_person'] = $lender_credit_person ; - $FLYHI_PD['pd_branch_id'] = $pd_branch_id; - $FLYHI_PD['lender_id'] = $lender_id; - $FLYHI_PD['createdby'] = $fk_createdby; - $FLYHI_PD['rand_string'] = $randomString; - $FLYHI_PD['sales_pd_type'] = $flyhi_pd_type; - $FLYHI_PD['product_id'] = $product_id ? $product_id : (ENVIRONMENT == 'production' ? 27 : 26); - $flyhi_pd_id = $this->Flyhi_Model->saveRecords($FLYHI_PD,SALES_PD_DATA); - $section_data = json_encode($records); - $this->Flyhi_Model->updateRecords(array('isactive' => 0),SALESPD_SECTION_DATA,array('sales_pd_id' =>$flyhi_pd_id,'section_id' => 1 )); - $status = $records['is_complete']; - $fields = array('sales_pd_id' => $flyhi_pd_id, 'section_id' => 1, 'status' =>$status ,'section_data' => $section_data,'createdby' => $fk_createdby); - $is_entry_done = $this->Flyhi_Model->saveRecords($fields,SALESPD_SECTION_DATA); - } - - else - { - if(isset($records['status']) && $records['status'] == 'COMPLETED') - { - log_message('ERROR','####COMPLETE FLYHI-PD'.$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); - $dup_of_section_names = $section_names; - foreach ($completed_sections as $completed_section_key => $completed_section_value) - { - if($dup_of_section_names [ $completed_section_value['section_id'] ] ) - { - unset($dup_of_section_names [ $completed_section_value['section_id'] ]); - } - } - unset($dup_of_section_names[9]);//unset photograph always - $img_satellite_check = $this->Flyhi_Model->selectCustomRecords(array('count(*) as count'),array('img_name' => 'satellite','fk_sales_pd_id' => $records['sales_pd_id'],'isactive' => 1),SALEPD_DOCS); - $img_selfile_check = $this->Flyhi_Model->selectCustomRecords(array('count(*) as count'),array('img_name' => 'selfie_with_person_met','fk_sales_pd_id' => $records['sales_pd_id'],'isactive' => 1),SALEPD_DOCS); - - if(count($drafted_sections) ) - { - - $drafted_sections = array_map(function($single) use ($section_names) - { - return array('section_id' => $single['section_id'],'sectin_name' => $section_names [ $single['section_id'] ]); - },$drafted_sections); - - unset($records['status']); - $data['dataStatus'] = true; - $data['records'] = $drafted_sections; - $data['pd_status'] = 'DRAFT'; - $data['status'] = REST_Controller::HTTP_OK; - $this->response($data,REST_Controller::HTTP_OK); - } - else if($img_satellite_check[0]['count'] == 0 || $img_selfile_check[0]['count'] == 0) - { - unset($records['status']); - $data['dataStatus'] = true; - $data['records'][] = ($img_selfile_check[0]['count'] == 0) ? array('section_id' => 9,'section_name' => 'selfie image') : ( $img_satellite_check[0]['count'] == 0 ? array('section_id' => 9,'section_name' => 'satellite image') :('selfie image and satellite image ar not available')); - $data['pd_status'] = 'DRAFT'; - $data['status'] = REST_Controller::HTTP_OK; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $records['status'] = 'COMPLETED'; - $records['is_cus_link_disabled'] = 1; - $records['completed_date'] = date('Y-m-d H:i:s'); - $flyhi_pd_id = $this->Flyhi_Model->updateRecords($records,SALES_PD_DATA,array('sales_pd_id' => $records['sales_pd_id'])); - $this->prepareFlyhiPDReport($records['sales_pd_id'],false); - sleep(10); - log_message('ERROR','####FLYHI-PD AFTER 10 PREPARED REPORT'.$records['sales_pd_id']); - } - } - else - { - - log_message('ERROR','####UPDATE FLYHIPD'.$records['sales_pd_id']); - // $gen_form = json_decode($form[0]['section_data'],true); - $flyhi_pd_id = (int)$records['sales_pd_id']; - - if($records['questions']){ - foreach ($records['questions'] as $g_key => $g_value) - { - if(isset($g_value['question_key']) && $g_value['question_key'] === 'loan_application_id') - { - $applicant_id = $g_value['answer_value'] ? $g_value['answer_value'] : 'Not Provided'; - } - - - if(isset($g_value['question_key']) && $g_value['question_key'] == 'lender_name') - { - $lender_id = $g_value['answer_value']; - } - - - if(isset($g_value['question_key']) && $g_value['question_key'] == 'loan_amount') - { - $loan_amount = $g_value['answer_value']; - } - if(isset($g_value['question_key']) && $g_value['question_key'] == 'branch') - { - $pd_branch_id = $g_value['answer_value']; - } - if(isset($g_value['question_key']) && $g_value['question_key'] == 'lender_sales_person') - { - $lender_sales_person = $g_value['answer_value']; - } - if(isset($g_value['question_key']) && $g_value['question_key'] == 'lender_credit_person') - { - $lender_credit_person = $g_value['answer_value']; - } - - if(isset($g_value['question_key']) && $g_value['question_key'] == 'product_name') - { - $product_id = $g_value['answer_value']; - } - - if(isset($g_value['question_key']) && $g_value['question_key'] == 'verification_type') - { - if(isset($g_value['onchange_properties'])) - { - foreach ($g_value['onchange_properties'] as $h_key => $h_value) - { - foreach ($h_value['form_controls'] as $i_key => $i_value) - { - foreach ($i_value['questions'] as $j_key => $j_value) - { - if($g_value['answer_value'] == 'Residence verification' && $j_value['question_key'] == 'residence_city'){ - $city = $j_value['answer_value']; - $flyhi_pd_type = 4; - } - if($g_value['answer_value'] == 'Office verification' && $j_value['question_key'] == 'officer_city'){ - $city = $j_value['answer_value']; - $flyhi_pd_type = 3; - } - if($g_value['answer_value'] == 'Office verification' && $j_value['question_key'] == 'employer_business_name') - { - $applicant_name = $j_value['answer_value']; - } - } - } - } - } - } - - } - - } - $FLYHI_PD['applicant_name'] = $applicant_name; - $FLYHI_PD['applicant_id'] = $applicant_id; - $FLYHI_PD['city_id']=$city; - $FLYHI_PD['loan_amount'] = $loan_amount; - $FLYHI_PD['lender_sales_person'] = $lender_sales_person ; - $FLYHI_PD['lender_credit_person'] = $lender_credit_person ; - $FLYHI_PD['pd_branch_id'] = $pd_branch_id; - $FLYHI_PD['lender_id'] = $lender_id; - $FLYHI_PD['product_id'] = $product_id ? $product_id : (ENVIRONMENT == 'production' ? 27 : 26); - $status = $records['is_complete']; - $section_data = json_encode($records); - $this->Flyhi_Model->updateRecords($FLYHI_PD,SALES_PD_DATA,array('sales_pd_id' => $flyhi_pd_id)); - $this->Flyhi_Model->updateRecords(array('isactive' => 0),SALESPD_SECTION_DATA,array('sales_pd_id' =>$flyhi_pd_id,'section_id' => 1)); - $fields = array('sales_pd_id' => $flyhi_pd_id, 'section_id' => 1, 'status' =>$status ,'section_data' => $section_data,'createdby' => $fk_createdby); - $is_entry_done = $this->Flyhi_Model->saveRecords($fields,SALESPD_SECTION_DATA); - } // else 179 - } // else 167 - if($flyhi_pd_id) - { - $data['dataStatus'] = true; - $data['records'] = $flyhi_pd_id; - $data['status'] = REST_Controller::HTTP_OK; - if(isset($records['rand_string'])){ $data['rand_string'] = $records['rand_string']; } - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = 'Something went wrong! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); - } - } - - public function getFlyhiPD_post() { $records = $this->post('records'); @@ -698,7 +458,7 @@ class Flyhi_Controller extends REST_Controller { function prepareFlyhiPDReport($pd_id,$api = true) { - log_message('ERROR','####PREPARE Flyhi PD REPORT CALLED'.$pd_id); + log_message('ERROR','#### PREPARE REPORT CALLED'.$pd_id); $columns = array('SALES_PD_DATA.*','ENTITY.short_name','PRODUCT.name','PRODUCT.abbr','USERPROFILE.smc_emp_code'); // $columns = array('SALES_PD_DATA.*','ENTITY.short_name','USERPROFILE.smc_emp_code'); $table = SALES_PD_DATA.' as SALES_PD_DATA'; @@ -719,7 +479,10 @@ class Flyhi_Controller extends REST_Controller { $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-";} + 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-";} + else $pd_type = "Demo PD-"; + // print_r($flyhipd_data);die(); if($flyhipd_data) // if(1) @@ -754,7 +517,7 @@ class Flyhi_Controller extends REST_Controller { foreach ($all_section_data as $sec_key => $section) { // print_r($section['section_id']);die(); - // log_message('ERROR','####PREPARE SALESPD REPORT CALLED'.$pd_id); + $view_data['section'.$section['section_id'] ] = $this->processFlyhiPDJSON($section);//die(); // print_r($view_data['section'.$section['section_id'] ]);die; $section_fields['section'.$section['section_id'] ] = $this->processFlyhiPDJSON($section); @@ -794,7 +557,7 @@ class Flyhi_Controller extends REST_Controller { //echo $bytes; //die(); $bucket_data = array('bucket_name'=>$bucket_name,'key'=>$key,'sourcefile'=>$this->external_path.'/sales_pd/'.$pd_id.'/temp.pdf'); - log_message('ERROR','####FLYHIPD REPORT UPLOAD TO S3'.$pd_id); + log_message('ERROR','#### '.$pd_type.' REPORT UPLOAD TO S3'.$pd_id); $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) @@ -1372,17 +1135,11 @@ 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); + // print_r($records);//die(); + $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'); @@ -1400,7 +1157,7 @@ class Flyhi_Controller extends REST_Controller { $randomString .= $characters[rand(0, $charactersLength - 1)]; } $records['rand_string'] = $randomString; - log_message('ERROR','####INSERT NEW FLYHIPD'); + log_message('ERROR','####INSERT NEW '.$lender_short_name.' PD'); $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']); @@ -1415,7 +1172,7 @@ class Flyhi_Controller extends REST_Controller { //echo $product_short_name[0]['abbr']; if(isset($records['status']) && $records['status'] == 'COMPLETED') { - log_message('ERROR','####COMPLETE FLYHIPD'.$records['sales_pd_id']); + log_message('ERROR','####COMPLETE '.$lender_short_name.' PD'.$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); @@ -1499,7 +1256,7 @@ class Flyhi_Controller extends REST_Controller { $this->prepareFlyhiPDReport($records['sales_pd_id'],false); // die(); sleep(10); - log_message('ERROR','####FlyHiPD AFTER 10 PREPARED REPORT'.$records['sales_pd_id']); + log_message('ERROR','#### '.$lender_short_name.' PD 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); @@ -1523,7 +1280,7 @@ class Flyhi_Controller extends REST_Controller { } else { - log_message('ERROR','####UPDATE FLYHIPD'.$records['sales_pd_id']); + log_message('ERROR','#### UPDATE '.$lender_short_name.' PD => '.$records['sales_pd_id']); $id = $this->Flyhi_Model->updateRecords($records,SALES_PD_DATA,array('sales_pd_id' => $records['sales_pd_id'])); } @@ -2261,12 +2018,12 @@ class Flyhi_Controller extends REST_Controller { $sales_pd_id = $this->get('sales_pd_id'); if(!empty($sales_pd_id)){ $this->Flyhi_Model->updateRecords(array('is_pdf' => 0),SALES_PD_DATA,array('sales_pd_id' => $sales_pd_id)); - log_message('ERROR','####Manually Called - Report Generated Flyhi pd = '.$sales_pd_id); + log_message('ERROR','#### Manually Called - Report Generated PD => '.$sales_pd_id); $this->prepareFlyhiPDReport($sales_pd_id);} else{ $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_FOUND; - $data['msg'] = 'Sales PDID Not Found !'; + $data['msg'] = 'PDID Not Found !'; $this->response($data,REST_Controller::HTTP_OK); } }