flyhi 2 : ps
This commit is contained in:
parent
453924b969
commit
a9dc7b6e4c
@ -375,7 +375,7 @@ $route['getCreditPDReportforCETApp'] = 'SMC_Credit_PD_Controller/getCreditPDRep
|
|||||||
|
|
||||||
$route['faceMarkImage'] = 'PD_Controller/toMakeFaceBoundingBox';
|
$route['faceMarkImage'] = 'PD_Controller/toMakeFaceBoundingBox';
|
||||||
|
|
||||||
$route['saveFlyHiSalesPD'] = 'Flyhi_Controller/saveFlyHiSalesPD';
|
$route['saveFlyhiPD'] = 'Flyhi_Controller/saveFlyhiPD';
|
||||||
$route['listFlyhiSalesPD'] = 'Flyhi_Controller/listFlyhiSalesPD';
|
$route['listFlyhiPD'] = 'Flyhi_Controller/listFlyhiPD';
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -13,13 +13,11 @@ class Flyhi_Controller extends REST_Controller {
|
|||||||
$this->load->model('Sales_PD_Model','Sales_PD_Model');
|
$this->load->model('Sales_PD_Model','Sales_PD_Model');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function listFlyhiSalesPD_get(){
|
public function listFlyhiPD_get(){
|
||||||
|
|
||||||
$lender_id = $this->uri->segment(2);
|
|
||||||
$user_id = $this->uri->segment(3);
|
$user_id = $this->uri->segment(3);
|
||||||
$role = $this->uri->segment(4);
|
|
||||||
|
|
||||||
$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.product_id','SALES_PD_DATA.is_pdf','SALES_PD_DATA.is_edited','ENTITY.short_name','PRODUCT.abbr','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',
|
$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',
|
||||||
'(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');
|
'(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';
|
$table = SALES_PD_DATA.' as SALES_PD_DATA';
|
||||||
|
|
||||||
@ -27,9 +25,6 @@ class Flyhi_Controller extends REST_Controller {
|
|||||||
array('table' => ENTITY. ' as ENTITY',
|
array('table' => ENTITY. ' as ENTITY',
|
||||||
'condition' =>'SALES_PD_DATA.lender_id = ENTITY.entity_id',
|
'condition' =>'SALES_PD_DATA.lender_id = ENTITY.entity_id',
|
||||||
'jointype' => 'INNER'),
|
'jointype' => 'INNER'),
|
||||||
array('table' => PRODUCTS. ' as PRODUCT',
|
|
||||||
'condition' =>'SALES_PD_DATA.product_id = PRODUCT.product_id',
|
|
||||||
'jointype' => 'INNER'),
|
|
||||||
array('table' => CITY. ' as CITY',
|
array('table' => CITY. ' as CITY',
|
||||||
'condition' =>'SALES_PD_DATA.city_id = CITY.city_id',
|
'condition' =>'SALES_PD_DATA.city_id = CITY.city_id',
|
||||||
'jointype' => 'LEFT'),
|
'jointype' => 'LEFT'),
|
||||||
@ -40,53 +35,180 @@ class Flyhi_Controller extends REST_Controller {
|
|||||||
|
|
||||||
$or_where = array();
|
$or_where = array();
|
||||||
$where_condition_array['SALES_PD_DATA.isactive'] = 1;
|
$where_condition_array['SALES_PD_DATA.isactive'] = 1;
|
||||||
if(is_numeric($lender_id))
|
|
||||||
{
|
|
||||||
$where_condition_array['SALES_PD_DATA.lender_id'] = $lender_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FILTERING THE LAST 10 DAYS RECORDS
|
// FILTERING THE LAST 10 DAYS RECORDS
|
||||||
$key_date='SALES_PD_DATA.createdon BETWEEN DATE_SUB(NOW(), INTERVAL 60 DAY) AND NOW()';
|
$key_date='SALES_PD_DATA.createdon BETWEEN DATE_SUB(NOW(), INTERVAL 60 DAY) AND NOW()';
|
||||||
$condition_value=null;
|
$condition_value=null;
|
||||||
$where_condition_array[$key_date] = $condition_value;
|
$where_condition_array[$key_date] = $condition_value;
|
||||||
// print_r ($where_condition_array);
|
|
||||||
// ----END OF FILTERING THE LAST 10 DAYS RECORDS---
|
// ----END OF FILTERING THE LAST 10 DAYS RECORDS---
|
||||||
|
|
||||||
$MWISELender = (ENVIRONMENT == 'production' ? 7 : 35);
|
$FHFSL_lender = (ENVIRONMENT == 'production' ? 0 : 49);
|
||||||
if($role && is_numeric($role) && $role == 11 && $MWISELender == $lender_id){
|
if($user_id && is_numeric($user_id))
|
||||||
// $where_condition_array['SALES_PD_DATA.product_id'] = (ENVIRONMENT == 'production' ? 23 : 22);
|
{ $where_condition_array['SALES_PD_DATA.createdby'] = $user_id; }
|
||||||
}else{
|
|
||||||
if($role && is_numeric($role) && $role == 15) //if role area sales head the pull all meq cases
|
|
||||||
{
|
|
||||||
$where_condition_array['SALES_PD_DATA.product_id'] = (ENVIRONMENT == 'production' ? 23 : 22);
|
|
||||||
$or_where['SALES_PD_DATA.createdby'] = $user_id;
|
|
||||||
}
|
|
||||||
else 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;
|
$where_condition_array['SALES_PD_DATA.sales_pd_type in (3,4)'] = null;
|
||||||
$order_by = 'SALES_PD_DATA.sales_pd_id';
|
$order_by = 'SALES_PD_DATA.sales_pd_id';
|
||||||
$sales_pd_data = $this->Sales_PD_Model->getJoinRecords($columns,$table,$joins,$where_condition_array,$order_by,'DESC','',$or_where);
|
|
||||||
|
$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();
|
//print_r($this->db->last_query());die();
|
||||||
|
|
||||||
if(count($sales_pd_data))
|
if(count($Flyhi_pd_data))
|
||||||
{
|
{
|
||||||
$data['dataStatus'] = true;
|
$data['dataStatus'] = true;
|
||||||
$data['status'] = REST_Controller::HTTP_OK;
|
$data['status'] = REST_Controller::HTTP_OK;
|
||||||
$data['records'] = $sales_pd_data;
|
$data['records'] = $Flyhi_pd_data;
|
||||||
$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'] = 'FlyHI PD Data Not Found! Try Later';
|
||||||
$this->response($data,REST_Controller::HTTP_OK);
|
$this->response($data,REST_Controller::HTTP_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function saveFlyhiPD_post()
|
||||||
|
{
|
||||||
|
$records = $this->post('records');
|
||||||
|
$is_entry_done = null;
|
||||||
|
$id = null;
|
||||||
|
|
||||||
|
log_message('ERROR','####FLYHI-PD SAVE CALLED');
|
||||||
|
$lender_short_name = $this->Flyhi_Model->selectCustomRecords(array('short_name'),array('entity_id' => $records['lender_id']),ENTITY);
|
||||||
|
|
||||||
|
// $section_names = array('1' => 'General Section','2' => 'Photography');
|
||||||
|
$section_names = array('1' => 'General Section');
|
||||||
|
|
||||||
|
// here i get the counts.
|
||||||
|
$count = $this->Flyhi_Model->selectCustomRecords(array('count(*) as count'),array('lender_id' => $records['lender_id'],'isactive' => 1),SALES_PD_DATA);
|
||||||
|
|
||||||
|
// If Condition inserting Data in Master Table
|
||||||
|
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');
|
||||||
|
$salepd_serial_no .= 'FHFSL-'.(++$count[0]['count']);
|
||||||
|
|
||||||
|
$records['sales_pd_sno'] = $salepd_serial_no;
|
||||||
|
// print_r($records);die();
|
||||||
|
$id = $this->Flyhi_Model->saveRecords($records,SALES_PD_DATA);
|
||||||
|
|
||||||
|
//start camunda process
|
||||||
|
//CAMUNDA::startSalesPDInstance($id);
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
// print_r($completed_sections);die();
|
||||||
|
|
||||||
|
$dup_of_section_names = $section_names;
|
||||||
|
// print_r($dup_of_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
|
||||||
|
|
||||||
|
if(count($dup_of_section_names))
|
||||||
|
{
|
||||||
|
$res_data = array();
|
||||||
|
foreach ($dup_of_section_names as $key => $value)
|
||||||
|
{
|
||||||
|
$res_data[] = array('section_id' => $key,'sectin_name' => $section_names[$key]);
|
||||||
|
}
|
||||||
|
$data['dataStatus'] = true;
|
||||||
|
$data['records'] = $res_data;
|
||||||
|
$data['pd_status'] = 'DRAFT';
|
||||||
|
$data['status'] = REST_Controller::HTTP_OK;
|
||||||
|
$this->response($data,REST_Controller::HTTP_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
{
|
||||||
|
$records['status'] = 'COMPLETED';
|
||||||
|
$records['is_cus_link_disabled'] = 1;
|
||||||
|
$records['completed_date'] = date('Y-m-d H:i:s');
|
||||||
|
$id = $this->Flyhi_Model->updateRecords($records,SALES_PD_DATA,array('sales_pd_id' => $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);
|
||||||
|
$gen_form = json_decode($form[0]['section_data'],true);
|
||||||
|
if(!empty($gen_form)){
|
||||||
|
foreach ($gen_form['questions'] as $g_key => $g_value)
|
||||||
|
{
|
||||||
|
|
||||||
|
if($g_value['question_key'] == 'city')
|
||||||
|
{
|
||||||
|
$city = $g_value['answer_value'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}//gen_form closed here.
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
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']));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if($id)
|
||||||
|
{
|
||||||
|
$data['dataStatus'] = true;
|
||||||
|
$data['records'] = $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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}// Class Ends
|
}// Class Ends
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user