From c44f65d5fb624e5b0cad5210ec8898972d4438b7 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Wed, 8 Feb 2023 16:34:25 +0530 Subject: [PATCH] reverted : ps --- .../controllers/Sales_PD_Controller.php | 47 ++++++++++--------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/api/application/controllers/Sales_PD_Controller.php b/api/application/controllers/Sales_PD_Controller.php index 1f8ff460..6d3540ec 100644 --- a/api/application/controllers/Sales_PD_Controller.php +++ b/api/application/controllers/Sales_PD_Controller.php @@ -967,27 +967,7 @@ class Sales_PD_Controller extends REST_Controller { public function saveSalesPDsection_post() { - $records = $this->post('records'); - $is_entry_created = $this->salesPDsection($records); - if($is_entry_created) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $is_entry_created; - $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); - - } - } - public function salesPDsection($records) - { - + $records = $this->post('records'); $sales_pd_id = $records['sales_pd_id']; $section_id = $records['section_id']; $fk_createdby = $records['fk_createdby']; @@ -1098,7 +1078,21 @@ class Sales_PD_Controller extends REST_Controller { //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($fields,SALESPD_SECTION_DATA); - return $is_entry_created; + if($is_entry_created) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $is_entry_created; + $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); + + } } public function getSalesPDSectionData_post() @@ -1703,7 +1697,14 @@ public function filterSalesPDList_post() { } if(!empty($section_data)){ foreach ($section_data as $key => $data_value){ - $reponse = $this->salesPDsection($data_value); + $check=$this->Sales_PD_Model->selectCustomRecords(array('*'),array('sales_pd_id' =>$id,'section_id' => $data_value['section_id'],'isactive' => 1 ),SALESPD_SECTION_DATA); + if(count($check)>0){ + $this->Sales_PD_Model->updateRecords(array('isactive' => 0),SALESPD_SECTION_DATA,array('sales_pd_id' =>$id,'section_id' => $data_value['section_id'] )); + } + //insert new record + $section_data_arr = json_encode($data_value); + $fields = array('sales_pd_id' => $id, 'section_id' => $data_value['section_id'], 'status' =>1,'section_data' => $section_data_arr,'createdby' => $createdby); + $reponse = $this->Sales_PD_Model->saveRecords($fields,SALESPD_SECTION_DATA); $msg = $msg." ( ".$data_value['section_name']." ID : ".$reponse. " )"; } }