diff --git a/api/application/config/routes.php b/api/application/config/routes.php index a03d485a..dad969b6 100644 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -262,4 +262,5 @@ $route['listSalesPD/(:any)'] = 'Sales_PD_Controller/listSalesPD'; $route['listSalesPD/(:any)/(:any)'] = 'Sales_PD_Controller/listSalesPD'; $route['saveSalesPDImage'] = 'Sales_PD_Controller/saveSalesPDImage'; $route['saveSalesPDsection'] = 'Sales_PD_Controller/saveSalesPDsection'; +$route['getSalesPDSectionData'] = 'Sales_PD_Controller/getSalesPDSectionData'; diff --git a/api/application/controllers/Entity_Management_Controller.php b/api/application/controllers/Entity_Management_Controller.php index 00895eb0..1b83c35c 100644 --- a/api/application/controllers/Entity_Management_Controller.php +++ b/api/application/controllers/Entity_Management_Controller.php @@ -1104,6 +1104,7 @@ class Entity_Management_Controller extends REST_Controller { { $entity_id = $this->uri->segment(2); $products = array(); + $salespd_products = array(); $customer_segments = array(); $pd_types = array(); $financial_institutions = array(); @@ -1134,6 +1135,10 @@ class Entity_Management_Controller extends REST_Controller { { $pd_types = explode(",",$preference_value['values']); } + if($preference_value['preference_type'] == 4) + { + $salespd_products = explode(",",$preference_value['values']); + } } @@ -1156,6 +1161,24 @@ class Entity_Management_Controller extends REST_Controller { $products[$key]['subproducts'] = $subproducts; } + //GET SALESPS PRODUCT AND SUB PRODUCT + $this->db->SELECT('product_id,name as product_name,abbr as product_abbr')->FROM(PRODUCTS); + if(count($salespd_products)) + { + $this->db->WHERE_IN('product_id ',$salespd_products); + } + $this->db->WHERE('isactive',1); + $salespd_products = $this->db->GET()->result_array(); + //print_r($products);die(); + foreach($salespd_products as $key => $value) + { + $fields = array('subproduct_id','name as subproduct_name','abbr as subproduct_abbr','is_others'); + $where_condition_array = array('isactive' => 1,'fk_product_id' => $value['product_id']); + $subproducts = $this->Entity_Management_Model->selectCustomRecords($fields,$where_condition_array,SUBPRODUCTS); + //array_push($result_data[$key],$subproducts); + $salespd_products[$key]['subproducts'] = $subproducts; + } + //GET CUSTOMER SEGMENTS $this->db->SELECT('customer_segment_id,name as customer_segment,abbr')->FROM(CUSTOMERSEGMENT); if(count($customer_segments)) @@ -1177,7 +1200,7 @@ class Entity_Management_Controller extends REST_Controller { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = array('products' =>$products,'customer_segments' => $customer_segments, 'pd_types' => $pd_types,'financial_institutions' => $financial_institutions); + $data['records'] = array('products' =>$products,'customer_segments' => $customer_segments, 'pd_types' => $pd_types,'financial_institutions' => $financial_institutions,'salespd_products' => $salespd_products); $this->response($data,REST_Controller::HTTP_OK); diff --git a/api/application/controllers/Sales_PD_Controller.php b/api/application/controllers/Sales_PD_Controller.php index 0341d2bc..7c1bddc4 100644 --- a/api/application/controllers/Sales_PD_Controller.php +++ b/api/application/controllers/Sales_PD_Controller.php @@ -51,104 +51,104 @@ class Sales_PD_Controller extends REST_Controller { } - public function saveSalesPDOld_post() - { - $records = $this->post('records'); - $applicant_name = ''; - $applicant_id = ''; - $officer = ''; - //satellite_image::getSatelliteImage(22,2);//die(); - foreach (json_decode($records['pd_json'],true) as $key => $value) - { - //print_r($value);die(); - if($value['section_id'] == 1) - { - foreach ($value['questions'] as $g_key => $g_value) - { - if($g_value['question_key'] == 'application_id') - { - $applicant_id = $g_value['answer_value'] ? $g_value['answer_value'] : 'Not Provided'; - } + // public function saveSalesPDOld_post() + // { + // $records = $this->post('records'); + // $applicant_name = ''; + // $applicant_id = ''; + // $officer = ''; + // //satellite_image::getSatelliteImage(22,2);//die(); + // foreach (json_decode($records['pd_json'],true) as $key => $value) + // { + // //print_r($value);die(); + // if($value['section_id'] == 1) + // { + // foreach ($value['questions'] as $g_key => $g_value) + // { + // if($g_value['question_key'] == 'application_id') + // { + // $applicant_id = $g_value['answer_value'] ? $g_value['answer_value'] : 'Not Provided'; + // } - if($records['product_id'] == 4) - { - if($g_value['question_key'] == 'company_name') - { - $applicant_name = $g_value['answer_value']; - } - } - else - { - if($g_value['question_key'] == 'person_met_during_visit') - { - $applicant_name = $g_value['answer_value']; + // if($records['product_id'] == 4) + // { + // if($g_value['question_key'] == 'company_name') + // { + // $applicant_name = $g_value['answer_value']; + // } + // } + // else + // { + // if($g_value['question_key'] == 'person_met_during_visit') + // { + // $applicant_name = $g_value['answer_value']; - } - } + // } + // } - } - } - if($value['section_id'] == 8) - { - foreach ($value['questions'] as $g_key => $g_value) - { - if($g_value['question_key'] == 'name_of_sales_team_member') - { - $officer = $g_value['answer_value']; - } + // } + // } + // if($value['section_id'] == 8) + // { + // foreach ($value['questions'] as $g_key => $g_value) + // { + // if($g_value['question_key'] == 'name_of_sales_team_member') + // { + // $officer = $g_value['answer_value']; + // } - } - } - } + // } + // } + // } - $records['applicant_id'] = $applicant_id; - $records['applicant_name'] = $applicant_name; - $records['officer_name'] = $officer; + // $records['applicant_id'] = $applicant_id; + // $records['applicant_name'] = $applicant_name; + // $records['officer_name'] = $officer; - $id = null; - if(!$records['sales_pd_id']) - { - //generate sales pd serial no + // $id = null; + // if(!$records['sales_pd_id']) + // { + // //generate sales pd serial no - $count = $this->Sales_PD_Model->selectCustomRecords(array('count(*) as count'),array('lender_id' => $records['lender_id'],'product_id' => $records['product_id']),SALES_PD_DATA); + // $count = $this->Sales_PD_Model->selectCustomRecords(array('count(*) as count'),array('lender_id' => $records['lender_id'],'product_id' => $records['product_id']),SALES_PD_DATA); - $lender_short_name = $this->Sales_PD_Model->selectCustomRecords(array('short_name'),array('entity_id' => $records['lender_id']),ENTITY); + // $lender_short_name = $this->Sales_PD_Model->selectCustomRecords(array('short_name'),array('entity_id' => $records['lender_id']),ENTITY); - $product_short_name = $this->Sales_PD_Model->selectCustomRecords(array('abbr'),array('product_id' => $records['product_id']),PRODUCTS); - //print_r($product_short_name); + // $product_short_name = $this->Sales_PD_Model->selectCustomRecords(array('abbr'),array('product_id' => $records['product_id']),PRODUCTS); + // //print_r($product_short_name); - $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']); - //echo $salepd_serial_no; - //end generate sales pd serial no - // echo $salepd_serial_no; - // die(); - $records['sales_pd_sno'] = $salepd_serial_no; - $id = $this->Sales_PD_Model->saveRecords($records,SALES_PD_DATA); - satellite_image::getSatelliteImage($id,2); - } - else - { - $id = $this->Sales_PD_Model->updateRecords($records,SALES_PD_DATA,array('sales_pd_id' => $records['sales_pd_id'])); - } + // $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']); + // //echo $salepd_serial_no; + // //end generate sales pd serial no + // // echo $salepd_serial_no; + // // die(); + // $records['sales_pd_sno'] = $salepd_serial_no; + // $id = $this->Sales_PD_Model->saveRecords($records,SALES_PD_DATA); + // satellite_image::getSatelliteImage($id,2); + // } + // else + // { + // $id = $this->Sales_PD_Model->updateRecords($records,SALES_PD_DATA,array('sales_pd_id' => $records['sales_pd_id'])); + // } - if($id) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $id; - $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); - } + // if($id) + // { + // $data['dataStatus'] = true; + // $data['status'] = REST_Controller::HTTP_OK; + // $data['records'] = $id; + // $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 getSalesPDReport_get() { @@ -188,10 +188,13 @@ class Sales_PD_Controller extends REST_Controller { { - $json_data = (json_decode($sales_pd_data[0]['pd_json'],true)); - $view_data = array(); - foreach ($json_data as $sec_key => $section) + //$json_data = (json_decode($sales_pd_data[0]['pd_json'],true)); + $all_section_data = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $sales_pd_id,'isactive' => 1),SALESPD_SECTION_DATA); + // print_r($this->db->last_query());die(); + $view_data['master'] = $sales_pd_data; + foreach ($all_section_data as $sec_key => $section) { + //print_r($section);die(); $view_data['section'.$section['section_id'] ] = $this->processSalesPDJSON($section); } @@ -241,7 +244,7 @@ class Sales_PD_Controller extends REST_Controller { { $lender_id = $this->uri->segment(2); $user_id = $this->uri->segment(3); - $columns = array('SALES_PD_DATA.sales_pd_id','SALES_PD_DATA.sales_pd_sno','SALES_PD_DATA.applicant_name','SALES_PD_DATA.officer_name','SALES_PD_DATA.applicant_id','SALES_PD_DATA.lender_id','SALES_PD_DATA.product_id','SALES_PD_DATA.is_pdf','SALES_PD_DATA.is_edited','ENTITY.short_name','PRODUCT.abbr','SALES_PD_DATA.createdon'); + $columns = array('SALES_PD_DATA.sales_pd_id','SALES_PD_DATA.sales_pd_sno','SALES_PD_DATA.applicant_name','SALES_PD_DATA.officer_name','SALES_PD_DATA.applicant_id','SALES_PD_DATA.lender_id','SALES_PD_DATA.product_id','SALES_PD_DATA.is_pdf','SALES_PD_DATA.is_edited','ENTITY.short_name','PRODUCT.abbr','SALES_PD_DATA.createdon,SALES_PD_DATA.status'); $table = SALES_PD_DATA.' as SALES_PD_DATA'; $joins = array( array('table' => ENTITY. ' as ENTITY', @@ -285,6 +288,7 @@ class Sales_PD_Controller extends REST_Controller { function processSalesPDJSON($section_array) { // + //print_r($section_array);die(); //echo '###'.$section_array['section_id'].'####'; if($section_array['section_id'] == 9) { @@ -293,7 +297,8 @@ class Sales_PD_Controller extends REST_Controller { if($section_array['section_id']) { //print_r($section_array);//die(); - return $this->processSalesPDQuestions($section_array['questions'],$section_array['section_id']); + $questions = json_decode($section_array['section_data'],true); + return $this->processSalesPDQuestions($questions['questions'],$section_array['section_id']); } // die(); @@ -306,6 +311,7 @@ class Sales_PD_Controller extends REST_Controller { function processSalesPDQuestions($questions,$section_id) { + //print_r($questions);die(); $temp_array = array(); foreach ($questions as $ques_key => $question) { @@ -380,6 +386,13 @@ class Sales_PD_Controller extends REST_Controller { public function saveSalesPDImage_post() { $records = $this->post('records'); + + if($records['img_name'] == 'selfie_with_person_met') + { + //$location = $records['location']; + $update_fields = array('location' => $records['location']); + $this->Sales_PD_Model->updateRecords($update_fields,SALES_PD_DATA,array('sales_pd_id' => $records['fk_sales_pd_id'])); + } $id = $this->Sales_PD_Model->saveRecords($records,SALEPD_DOCS); if($id) @@ -423,20 +436,28 @@ class Sales_PD_Controller extends REST_Controller { else { - $drafted_sections = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('status' => 0,'sales_pd_id' => $records['sales_pd_id'],'isactive' => 1),SALESPD_SECTION_DATA); - //print_r($drafted_sections);die(); - if(count($drafted_sections)) + if(isset($records['status']) && $records['status'] == 'COMPLETED') { - $data['dataStatus'] = true; - $data['records'] = $drafted_sections; - $data['pd_status'] = 'DRAFT'; - $data['status'] = REST_Controller::HTTP_OK; - $this->response($data,REST_Controller::HTTP_OK); + $drafted_sections = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('status' => 0,'sales_pd_id' => $records['sales_pd_id'],'isactive' => 1),SALESPD_SECTION_DATA); + //print_r($drafted_sections);die(); + if(count($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 + { + $records['status'] = 'COMPLETED'; + $id = $this->Sales_PD_Model->updateRecords($records,SALES_PD_DATA,array('sales_pd_id' => $records['sales_pd_id'])); + } } else { - $records['status'] = 'COMPLETED'; - $id = $this->Sales_PD_Model->updateRecords($records,SALES_PD_DATA,array('sales_pd_id' => $records['sales_pd_id'])); + $id = $this->Sales_PD_Model->updateRecords($records,SALES_PD_DATA,array('sales_pd_id' => $records['sales_pd_id'])); } } @@ -468,20 +489,118 @@ class Sales_PD_Controller extends REST_Controller { $section_id = $records['section_id']; $fk_createdby = $records['fk_createdby']; $status = $records['is_complete']; - $section_data = $records; + $section_data = json_encode($records); + //Get Sales PD master Data + + $columns = array('SALES_PD_DATA.*','ENTITY.short_name','PRODUCT.abbr'); + $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') + ); + + $where_condition_array = array('SALES_PD_DATA.sales_pd_id' => $sales_pd_id); + $sales_pd_master_data = $this->Sales_PD_Model->getJoinRecords($columns,$table,$joins,$where_condition_array); + + //pre process works + switch($section_id) + { + case 1: //General section + //update Applicant ID and applicant Name to sales pD master Table + $applicant_id = ''; + $applicant_name = ''; + if($records['section_data']) + { + foreach ($records['section_data']['questions'] as $g_key => $g_value) + { + if($g_value['question_key'] == 'application_id') + { + $applicant_id = $g_value['answer_value'] ? $g_value['answer_value'] : 'Not Provided'; + } + + if($sales_pd_master_data[0]['abbr'] == 'BL') // leter WTCL + { + if($g_value['question_key'] == 'company_name') + { + $applicant_name = $g_value['answer_value']; + } + } + else + { + if($g_value['question_key'] == 'person_met_during_visit') + { + $applicant_name = $g_value['answer_value']; + + } + } + + } + } + + $update_fields = array('applicant_name' => $applicant_name,'applicant_id' => $applicant_id); + $this->Sales_PD_Model->updateRecords($update_fields,SALES_PD_DATA,array('sales_pd_id' => $sales_pd_id)); + + + break; + + case 2: //Fund Requirement + break; + + case 3: //stakeholders + break; + + case 4: //brief of business + + case 5: //Financial + break; + + case 6: //property + break; + + case 7: //Officer self details + break; + + case 8: //final remarks of PD officer + //update PD officer Name to sales pD master Table + $officer = ''; + if($records['section_data']) + { + foreach($records['section_data']['questions'] as $g_key => $g_value) + { + if($g_value['question_key'] == 'name_of_sales_team_member') + { + $officer = $g_value['answer_value']; + break; + } + + } + } + $update_fields = array('officer_name' => $officer); + $this->Sales_PD_Model->updateRecords($update_fields,SALES_PD_DATA,array('sales_pd_id' => $sales_pd_id)); + break; + + case 9: //photosection + break; + + default: + } //make inactive previous records $this->Sales_PD_Model->updateRecords(array('isactive' => 0),SALESPD_SECTION_DATA,array('sales_pd_id' =>$sales_pd_id,'section_id' => $section_id )); //insert new record - $fields = array('sales_pd_id' => $sales_pd_id, 'section_id' => $section_id, 'status' =>$status ,'section_data' => $section_data, 'createdby' => $fk_createdby); - $is_entry_created = $this->Sales_PD_Model->saveRecords(array('isactive' => 0),SALESPD_SECTION_DATA); + $fields = array('sales_pd_id' => $sales_pd_id, 'section_id' => $section_id, 'status' =>$status ,'section_data' => $section_data,'createdby' => $fk_createdby); + $is_entry_created = $this->Sales_PD_Model->saveRecords($fields,SALESPD_SECTION_DATA); if($is_entry_created) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $id; + $data['records'] = $is_entry_created; $this->response($data,REST_Controller::HTTP_OK); } else @@ -495,6 +614,30 @@ class Sales_PD_Controller extends REST_Controller { } + + public function getSalesPDSectionData_post() + { + $records = $this->post('records'); + + $section_data = $this->Sales_PD_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($section_data) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $section_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); + + } + + } } diff --git a/api/application/views/report_templates/JSONTOREPORT_DI_AI.php b/api/application/views/report_templates/JSONTOREPORT_DI_AI.php index ad888783..f02804c6 100644 --- a/api/application/views/report_templates/JSONTOREPORT_DI_AI.php +++ b/api/application/views/report_templates/JSONTOREPORT_DI_AI.php @@ -2293,6 +2293,7 @@ if($total_no_of_business > 0) { +

As per Loan Applicant(s) met, the Financials are as below:

diff --git a/api/application/views/sale_pd_templates/MWISE.php b/api/application/views/sale_pd_templates/MWISE.php index 585d377d..7a204c77 100644 --- a/api/application/views/sale_pd_templates/MWISE.php +++ b/api/application/views/sale_pd_templates/MWISE.php @@ -4,9 +4,9 @@ defined('BASEPATH') OR exit('No direct script access allowed'); $uparrow = ''; $downarrow = ''; $dash = ' '; - $product_name = $product_id == 8 ? 'LFMP' : 'BL'; + $product_name = $master[0]['abbr'] $rupee_symbol = ""; - //print_r($section1);die(); + //print_r($master[0]['abbr']);die(); ?>