From ff0bafd0a60e947fb72f051fdbf093d69e4481f7 Mon Sep 17 00:00:00 2001 From: Velz2020 Date: Wed, 18 Dec 2019 17:56:00 +0530 Subject: [PATCH] SALESPD SECTION SAVE API --- api/application/config/constants.php | 1 + api/application/config/routes.php | 1 + .../controllers/Sales_PD_Controller.php | 32 ++++++++++++++++--- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/api/application/config/constants.php b/api/application/config/constants.php index d1075250..e9db7d83 100644 --- a/api/application/config/constants.php +++ b/api/application/config/constants.php @@ -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'); diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 985b5e29..a03d485a 100644 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -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'; diff --git a/api/application/controllers/Sales_PD_Controller.php b/api/application/controllers/Sales_PD_Controller.php index fcef4159..3af3b88c 100644 --- a/api/application/controllers/Sales_PD_Controller.php +++ b/api/application/controllers/Sales_PD_Controller.php @@ -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); + + } }