upload Sales PD Data To CET App api : ps

This commit is contained in:
VE10-Sanjeev 2022-08-23 22:28:03 +05:30
parent 54687cf5a8
commit 9e301beae3
2 changed files with 96 additions and 47 deletions

View File

@ -370,6 +370,7 @@ $route['getEvent'] = 'GC_Event_Controller/getEventFromGoogleCalender';//dummy ch
$route['createGmeetLink'] = 'PD_Controller/createGmeetLink'; //only developer testing, not for APP use
$route['deleteCalenderEvent'] = 'PD_Controller/deleteCalenderEvent'; //only developer testing, not for APP use
$route['uploadSalesPDDataToCETApp'] = 'Sales_PD_Controller/uploadSalesPDDataToCETApp';
$route['getSalesPDReportforCETApp'] = 'Sales_PD_Controller/getSalesPDReportforCETApp';
$route['getCreditPDReportforCETApp'] = 'SMC_Credit_PD_Controller/getCreditPDReportforCETApp';

View File

@ -205,63 +205,17 @@ class Sales_PD_Controller extends REST_Controller {
$all_section_data = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $sales_pd_id,'isactive' => 1),SALESPD_SECTION_DATA,array(),'','section_id','ASC');
// print_r(json_decode($all_section_data[0]['section_data'],true));die();
$view_data['master'] = $sales_pd_data;
$common_fields = array('pdid'=>$sales_pd_data[0]['sales_pd_id'],
'product'=>$sales_pd_data[0]['abbr'],
'caseno'=>$sales_pd_data[0]['sales_pd_sno']);
foreach ($all_section_data as $sec_key => $section)
{
// print_r($section['section_id']);die();
// log_message('ERROR','####PREPARE SALESPD REPORT CALLED'.$sales_pd_id);
$view_data['section'.$section['section_id'] ] = $this->processSalesPDJSON($section);//die();
$section_fields['section'.$section['section_id'] ] = $this->processSalesPDJSON($section);
}
// print_r($view_data['section3']);die();
$view_data['section9'] = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('fk_sales_pd_id' => $sales_pd_id,'img_name !=' => 'satellite','isactive' => 1),SALEPD_DOCS);
if(count($view_data['section9'])>0){
for ($i = 0; $i < count($view_data['section9']); $i++){
$img_fields = $common_fields;
$img_fields['img_name'] = $view_data['section9'][$i]['img_name'];
$img_split = explode( ',', $view_data['section9'][$i]['img']);
$img_fields['img'] = $img_split[1];
// $img_fields[0]['img'] = $view_data['section9'][$i]['img'];
cet_salespd::pushwithcetphotographapi($img_fields,$i);
}
// "section9":{"selfie_with_person_met":"SAVED","approach_to_pd_location":["SAVED",""],"name_board_seen":["SAVED",""],"stock_image":["SAVED","SAVED","SAVED","SAVED",""],"workplace_interior_image":["SAVED","SAVED",""]}}
// $arr1 =array();$arr2 =array();
//for ($i = 0; $i < count($view_data['section9']); $i++){
// $img_name = $view_data['section9'][$i]['img_name'];
// if(!in_array($img_name, $arr1)){
// array_push($arr1,$img_name);
// }
// $k = array_search($img_name, $arr1); //$k = 1;
// $arr2[$k][] = $view_data['section9'][$i]['img'];
// for ($j = 0; $j < count($arr1); $j++) {
// $section_fields['section9'][$arr1[$j]] = $arr2[$j];
// }
//}
}
// cet_salespd::pushwithcetsalespdapi($common_fields,$section_fields,1);
$CETAPP_salesPD_data = $section_fields;
$officer_name = isset($CETAPP_salesPD_data['section8']['name_of_sales_team_member']) ? $CETAPP_salesPD_data['section8']['name_of_sales_team_member'] : '';
if(!empty($officer_name)){
$officer_details = $this->Sales_PD_Model->selectCustomRecords(array('userid as officer_id', 'email','mobile_no','concat(first_name," ",last_name) as officer_full_name'),array('first_name' => $officer_name),USERPROFILE);
if(!empty($officer_details)){
foreach($officer_details as $key=>$value) {
$CETAPP_salesPD_data['section8'] = array_merge($section_fields['section8'],$value);
}
}
}
cet_salespd::pushwithcetsalespdapi($common_fields,$CETAPP_salesPD_data,1);
$view_data['satellite_image'] = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('fk_sales_pd_id' => $sales_pd_id,'img_name' => 'satellite','isactive' => 1),SALEPD_DOCS);
if(!empty($view_data['satellite_image'])){
$stt_fields = $common_fields;
$stt_fields['img_name'] = $view_data['satellite_image'][0]['img_name'];
$stt_fields['img'] = $view_data['satellite_image'][0]['img'];
cet_salespd::pushwithcetphotographapi($stt_fields,0);
}
$view_data['product_id'] = $sales_pd_data[0]['product_id'];
$view_data['geo_location'] = $sales_pd_data[0]['geo_location'];
// die();
//print_r($this->db->last_query());die();
//$view_name = $sales_pd_data[0]['short_name'].'_'.$sales_pd_data[0]['abbr'];
$view_name = $sales_pd_data[0]['short_name'];if( $sales_pd_data[0]['abbr'] == 'MEQ'){ $view_name = $sales_pd_data[0]['abbr']; }
$html_content = $this->load->view('sale_pd_templates/'.$view_name,$view_data,true);
@ -316,6 +270,100 @@ class Sales_PD_Controller extends REST_Controller {
}
}
}
function uploadSalesPDDataToCETApp_get()
{
log_message('ERROR','#### upload SalesPDData To CETApp Called');
$sales_pd_id = $this->uri->segment(2);
if(!empty($sales_pd_id)){
log_message('ERROR','#### Sales PD = '.$sales_pd_id);
$columns = array('SALES_PD_DATA.*','ENTITY.short_name','PRODUCT.abbr','USERPROFILE.smc_emp_code');
$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' => USERPROFILE. ' as USERPROFILE',
'condition' =>'SALES_PD_DATA.createdby = USERPROFILE.userid',
'jointype' => 'LEFT')
);
$where_condition_array = array('SALES_PD_DATA.sales_pd_id' => $sales_pd_id);
$sales_pd_data = $this->Sales_PD_Model->getJoinRecords($columns,$table,$joins,$where_condition_array);
log_message('ERROR','#### Total Sales PD is '.count($sales_pd_data));
if(count($sales_pd_data)>0)
{
$all_section_data = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $sales_pd_id,'isactive' => 1),SALESPD_SECTION_DATA,array(),'','section_id','ASC');
$common_fields = array('pdid'=>$sales_pd_data[0]['sales_pd_id'],
'product'=>$sales_pd_data[0]['abbr'],
'caseno'=>$sales_pd_data[0]['sales_pd_sno']);
foreach ($all_section_data as $sec_key => $section)
{
$section_fields['section'.$section['section_id'] ] = $this->processSalesPDJSON($section);
}
$photograph_data = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('fk_sales_pd_id' => $sales_pd_id,'img_name !=' => 'satellite','isactive' => 1),SALEPD_DOCS);
if(count($photograph_data)>0){
for ($i = 0; $i < count($photograph_data); $i++){
$img_fields = $common_fields;
$img_fields['img_name'] = $photograph_data[$i]['img_name'];
$img_split = explode( ',', $photograph_data[$i]['img']);
$img_fields['img'] = $img_split[1];
// $img_fields[0]['img'] = $photograph_data[$i]['img'];
cet_salespd::pushwithcetphotographapi($img_fields,$i);
}
}
// cet_salespd::pushwithcetsalespdapi($common_fields,$section_fields,1);
$CETAPP_salesPD_data = $section_fields;
$officer_name = isset($CETAPP_salesPD_data['section8']['name_of_sales_team_member']) ? $CETAPP_salesPD_data['section8']['name_of_sales_team_member'] : '';
if(!empty($officer_name)){
$officer_details = $this->Sales_PD_Model->selectCustomRecords(array('userid as officer_id', 'email','mobile_no','concat(first_name," ",last_name) as officer_full_name'),array('first_name' => $officer_name),USERPROFILE);
if(!empty($officer_details)){
foreach($officer_details as $key=>$value) {
$CETAPP_salesPD_data['section8'] = array_merge($section_fields['section8'],$value);
}
}
}
cet_salespd::pushwithcetsalespdapi($common_fields,$CETAPP_salesPD_data,1);
$satellite_image = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('fk_sales_pd_id' => $sales_pd_id,'img_name' => 'satellite','isactive' => 1),SALEPD_DOCS);
if(!empty($satellite_image)){
$stt_fields = $common_fields;
$stt_fields['img_name'] = $satellite_image[0]['img_name'];
$stt_fields['img'] = $satellite_image[0]['img'];
cet_salespd::pushwithcetphotographapi($stt_fields,0);
}
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['msg'] = 'Data Shared Successfully';
$this->response($data,REST_Controller::HTTP_OK);
}
else
{
log_message('ERROR','#### There is No Data Found relevant Sales PDID ');
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
$data['msg'] = 'There is No Data Found relevant Sales PDID ! Try Later';
$this->response($data,REST_Controller::HTTP_OK);
}
}else{
log_message('ERROR','#### Can`t able Found the Sales PDID ');
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
$data['msg'] = 'Can`t able Found the Sales PDID ! Try Later';
$this->response($data,REST_Controller::HTTP_OK);
}
}
public function getSalesPDReport_get()
{
$sales_pd_id = $this->uri->segment(2);