SALES PD CHANGES INCORPORATED

This commit is contained in:
Velz2020 2019-12-19 18:42:48 +05:30
parent a296135fc2
commit d327ba4d14
5 changed files with 276 additions and 108 deletions

View File

@ -262,4 +262,5 @@ $route['listSalesPD/(:any)'] = 'Sales_PD_Controller/listSalesPD';
$route['listSalesPD/(:any)/(:any)'] = 'Sales_PD_Controller/listSalesPD'; $route['listSalesPD/(:any)/(:any)'] = 'Sales_PD_Controller/listSalesPD';
$route['saveSalesPDImage'] = 'Sales_PD_Controller/saveSalesPDImage'; $route['saveSalesPDImage'] = 'Sales_PD_Controller/saveSalesPDImage';
$route['saveSalesPDsection'] = 'Sales_PD_Controller/saveSalesPDsection'; $route['saveSalesPDsection'] = 'Sales_PD_Controller/saveSalesPDsection';
$route['getSalesPDSectionData'] = 'Sales_PD_Controller/getSalesPDSectionData';

View File

@ -1104,6 +1104,7 @@ class Entity_Management_Controller extends REST_Controller {
{ {
$entity_id = $this->uri->segment(2); $entity_id = $this->uri->segment(2);
$products = array(); $products = array();
$salespd_products = array();
$customer_segments = array(); $customer_segments = array();
$pd_types = array(); $pd_types = array();
$financial_institutions = array(); $financial_institutions = array();
@ -1134,6 +1135,10 @@ class Entity_Management_Controller extends REST_Controller {
{ {
$pd_types = explode(",",$preference_value['values']); $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; $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 //GET CUSTOMER SEGMENTS
$this->db->SELECT('customer_segment_id,name as customer_segment,abbr')->FROM(CUSTOMERSEGMENT); $this->db->SELECT('customer_segment_id,name as customer_segment,abbr')->FROM(CUSTOMERSEGMENT);
if(count($customer_segments)) if(count($customer_segments))
@ -1177,7 +1200,7 @@ class Entity_Management_Controller extends REST_Controller {
$data['dataStatus'] = true; $data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK; $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); $this->response($data,REST_Controller::HTTP_OK);

View File

@ -51,104 +51,104 @@ class Sales_PD_Controller extends REST_Controller {
} }
public function saveSalesPDOld_post() // public function saveSalesPDOld_post()
{ // {
$records = $this->post('records'); // $records = $this->post('records');
$applicant_name = ''; // $applicant_name = '';
$applicant_id = ''; // $applicant_id = '';
$officer = ''; // $officer = '';
//satellite_image::getSatelliteImage(22,2);//die(); // //satellite_image::getSatelliteImage(22,2);//die();
foreach (json_decode($records['pd_json'],true) as $key => $value) // foreach (json_decode($records['pd_json'],true) as $key => $value)
{ // {
//print_r($value);die(); // //print_r($value);die();
if($value['section_id'] == 1) // if($value['section_id'] == 1)
{ // {
foreach ($value['questions'] as $g_key => $g_value) // foreach ($value['questions'] as $g_key => $g_value)
{ // {
if($g_value['question_key'] == 'application_id') // if($g_value['question_key'] == 'application_id')
{ // {
$applicant_id = $g_value['answer_value'] ? $g_value['answer_value'] : 'Not Provided'; // $applicant_id = $g_value['answer_value'] ? $g_value['answer_value'] : 'Not Provided';
} // }
if($records['product_id'] == 4) // if($records['product_id'] == 4)
{ // {
if($g_value['question_key'] == 'company_name') // if($g_value['question_key'] == 'company_name')
{ // {
$applicant_name = $g_value['answer_value']; // $applicant_name = $g_value['answer_value'];
} // }
} // }
else // else
{ // {
if($g_value['question_key'] == 'person_met_during_visit') // if($g_value['question_key'] == 'person_met_during_visit')
{ // {
$applicant_name = $g_value['answer_value']; // $applicant_name = $g_value['answer_value'];
} // }
} // }
} // }
} // }
if($value['section_id'] == 8) // if($value['section_id'] == 8)
{ // {
foreach ($value['questions'] as $g_key => $g_value) // foreach ($value['questions'] as $g_key => $g_value)
{ // {
if($g_value['question_key'] == 'name_of_sales_team_member') // if($g_value['question_key'] == 'name_of_sales_team_member')
{ // {
$officer = $g_value['answer_value']; // $officer = $g_value['answer_value'];
} // }
} // }
} // }
} // }
$records['applicant_id'] = $applicant_id; // $records['applicant_id'] = $applicant_id;
$records['applicant_name'] = $applicant_name; // $records['applicant_name'] = $applicant_name;
$records['officer_name'] = $officer; // $records['officer_name'] = $officer;
$id = null; // $id = null;
if(!$records['sales_pd_id']) // if(!$records['sales_pd_id'])
{ // {
//generate sales pd serial no // //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); // $product_short_name = $this->Sales_PD_Model->selectCustomRecords(array('abbr'),array('product_id' => $records['product_id']),PRODUCTS);
//print_r($product_short_name); // //print_r($product_short_name);
$salepd_serial_no = count($lender_short_name)? $lender_short_name[0]['short_name']:'UNKNOWN'; // $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($product_short_name)? '-'.$product_short_name[0]['abbr']:'-UNKNOWN';
$salepd_serial_no .= '-'.(++$count[0]['count']); // $salepd_serial_no .= '-'.(++$count[0]['count']);
//echo $salepd_serial_no; // //echo $salepd_serial_no;
//end generate sales pd serial no // //end generate sales pd serial no
// echo $salepd_serial_no; // // echo $salepd_serial_no;
// die(); // // die();
$records['sales_pd_sno'] = $salepd_serial_no; // $records['sales_pd_sno'] = $salepd_serial_no;
$id = $this->Sales_PD_Model->saveRecords($records,SALES_PD_DATA); // $id = $this->Sales_PD_Model->saveRecords($records,SALES_PD_DATA);
satellite_image::getSatelliteImage($id,2); // satellite_image::getSatelliteImage($id,2);
} // }
else // else
{ // {
$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']));
} // }
if($id) // if($id)
{ // {
$data['dataStatus'] = true; // $data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK; // $data['status'] = REST_Controller::HTTP_OK;
$data['records'] = $id; // $data['records'] = $id;
$this->response($data,REST_Controller::HTTP_OK); // $this->response($data,REST_Controller::HTTP_OK);
} // }
else // else
{ // {
$data['dataStatus'] = false; // $data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NO_CONTENT; // $data['status'] = REST_Controller::HTTP_NO_CONTENT;
$data['msg'] = 'Something went wrong! Try Later'; // $data['msg'] = 'Something went wrong! Try Later';
$this->response($data,REST_Controller::HTTP_OK); // $this->response($data,REST_Controller::HTTP_OK);
} // }
} // }
public function getSalesPDReport_get() 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)); //$json_data = (json_decode($sales_pd_data[0]['pd_json'],true));
$view_data = array(); $all_section_data = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $sales_pd_id,'isactive' => 1),SALESPD_SECTION_DATA);
foreach ($json_data as $sec_key => $section) // 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); $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); $lender_id = $this->uri->segment(2);
$user_id = $this->uri->segment(3); $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'; $table = SALES_PD_DATA.' as SALES_PD_DATA';
$joins = array( $joins = array(
array('table' => ENTITY. ' as ENTITY', array('table' => ENTITY. ' as ENTITY',
@ -285,6 +288,7 @@ class Sales_PD_Controller extends REST_Controller {
function processSalesPDJSON($section_array) function processSalesPDJSON($section_array)
{ {
// //
//print_r($section_array);die();
//echo '###'.$section_array['section_id'].'####'; //echo '###'.$section_array['section_id'].'####';
if($section_array['section_id'] == 9) if($section_array['section_id'] == 9)
{ {
@ -293,7 +297,8 @@ class Sales_PD_Controller extends REST_Controller {
if($section_array['section_id']) if($section_array['section_id'])
{ {
//print_r($section_array);//die(); //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(); // die();
@ -306,6 +311,7 @@ class Sales_PD_Controller extends REST_Controller {
function processSalesPDQuestions($questions,$section_id) function processSalesPDQuestions($questions,$section_id)
{ {
//print_r($questions);die();
$temp_array = array(); $temp_array = array();
foreach ($questions as $ques_key => $question) foreach ($questions as $ques_key => $question)
{ {
@ -381,6 +387,13 @@ class Sales_PD_Controller extends REST_Controller {
{ {
$records = $this->post('records'); $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); $id = $this->Sales_PD_Model->saveRecords($records,SALEPD_DOCS);
if($id) if($id)
{ {
@ -423,10 +436,13 @@ class Sales_PD_Controller extends REST_Controller {
else else
{ {
if(isset($records['status']) && $records['status'] == 'COMPLETED')
{
$drafted_sections = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('status' => 0,'sales_pd_id' => $records['sales_pd_id'],'isactive' => 1),SALESPD_SECTION_DATA); $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(); //print_r($drafted_sections);die();
if(count($drafted_sections)) if(count($drafted_sections))
{ {
unset($records['status']);
$data['dataStatus'] = true; $data['dataStatus'] = true;
$data['records'] = $drafted_sections; $data['records'] = $drafted_sections;
$data['pd_status'] = 'DRAFT'; $data['pd_status'] = 'DRAFT';
@ -438,6 +454,11 @@ class Sales_PD_Controller extends REST_Controller {
$records['status'] = 'COMPLETED'; $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']));
} }
}
else
{
$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']; $section_id = $records['section_id'];
$fk_createdby = $records['fk_createdby']; $fk_createdby = $records['fk_createdby'];
$status = $records['is_complete']; $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 //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 )); $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 //insert new record
$fields = array('sales_pd_id' => $sales_pd_id, 'section_id' => $section_id, 'status' =>$status ,'section_data' => $section_data,'createdby' => $fk_createdby); $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); $is_entry_created = $this->Sales_PD_Model->saveRecords($fields,SALESPD_SECTION_DATA);
if($is_entry_created) if($is_entry_created)
{ {
$data['dataStatus'] = true; $data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK; $data['status'] = REST_Controller::HTTP_OK;
$data['records'] = $id; $data['records'] = $is_entry_created;
$this->response($data,REST_Controller::HTTP_OK); $this->response($data,REST_Controller::HTTP_OK);
} }
else else
@ -496,6 +615,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);
}
}
} }

View File

@ -2293,6 +2293,7 @@ if($total_no_of_business > 0) {
</tbody></table> </tbody></table>
<?php } else{ ?> <?php } else{ ?>
<p> As per Loan Applicant(s) met, the Financials are as below: </p>
<table class="scorecard_table"> <table class="scorecard_table">
<thead> <thead>
<tr> <tr>

View File

@ -4,9 +4,9 @@ defined('BASEPATH') OR exit('No direct script access allowed');
$uparrow = '<span style="color:green;">↑</span>'; $uparrow = '<span style="color:green;">↑</span>';
$downarrow = '<span style="color:red;">↓</span>'; $downarrow = '<span style="color:red;">↓</span>';
$dash = '<span style="color:black;"> </span>'; $dash = '<span style="color:black;"> </span>';
$product_name = $product_id == 8 ? 'LFMP' : 'BL'; $product_name = $master[0]['abbr']
$rupee_symbol = "<span style='font-family: DejaVu Sans; sans-serif;font-size:10px'>₹</span>"; $rupee_symbol = "<span style='font-family: DejaVu Sans; sans-serif;font-size:10px'>₹</span>";
//print_r($section1);die(); //print_r($master[0]['abbr']);die();
?><!DOCTYPE html> ?><!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>