SALESPD SECTION SAVE API

This commit is contained in:
Velz2020 2019-12-18 17:56:00 +05:30
parent ff3d0eb2f7
commit ff0bafd0a6
3 changed files with 30 additions and 4 deletions

View File

@ -608,6 +608,7 @@ defined('D_BUSINESS_PARTNERS') OR define('D_BUSINESS_PARTNERS','d_business_partn
defined('SALESPDTEMPLATE') OR define('SALESPDTEMPLATE','m_sales_pd_template');
defined('SALES_PD_DATA') OR define('SALES_PD_DATA','t_sales_pd_data');
defined('SALEPD_DOCS') OR define('SALEPD_DOCS','t_salepd_docs');
defined('SALESPD_SECTION_DATA') OR define('SALESPD_SECTION_DATA','t_salespd_section_data');

View File

@ -261,4 +261,5 @@ $route['(downloadSalesPDReport/:any)'] = 'Sales_PD_Controller/getSalesPDReport';
$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';

View File

@ -425,10 +425,34 @@ class Sales_PD_Controller extends REST_Controller {
public function saveSalesPDsection_post()
{
$records = $this->post('records');
//sales+pd_id
//section_id
//status
//createdby
$sales_pd_id = $records['sales_pd_id'];
$section_id = $records['section_id'];
$fk_createdby = $records['fk_createdby'];
$status = $records['is_complete'];
$section_data = $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 ));
//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);
if($is_entry_created)
{
$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);
}
}