SALES PD AMEND 2
This commit is contained in:
parent
ff0bafd0a6
commit
a296135fc2
@ -401,8 +401,12 @@ class Sales_PD_Controller extends REST_Controller {
|
|||||||
public function saveSalesPD_post()
|
public function saveSalesPD_post()
|
||||||
{
|
{
|
||||||
$records = $this->post('records');
|
$records = $this->post('records');
|
||||||
if($records['sales_pd_id'])
|
$is_entry_done = null;
|
||||||
|
$id = null;
|
||||||
|
//print_r($records);die();
|
||||||
|
if($records['sales_pd_id'] == '' || $records['sales_pd_id'] == null)
|
||||||
{
|
{
|
||||||
|
|
||||||
$count = $this->Sales_PD_Model->selectCustomRecords(array('count(*) as count'),array('lender_id' => $records['lender_id'],'product_id' => $records['product_id']),SALES_PD_DATA);
|
$count = $this->Sales_PD_Model->selectCustomRecords(array('count(*) as count'),array('lender_id' => $records['lender_id'],'product_id' => $records['product_id']),SALES_PD_DATA);
|
||||||
|
|
||||||
$lender_short_name = $this->Sales_PD_Model->selectCustomRecords(array('short_name'),array('entity_id' => $records['lender_id']),ENTITY);
|
$lender_short_name = $this->Sales_PD_Model->selectCustomRecords(array('short_name'),array('entity_id' => $records['lender_id']),ENTITY);
|
||||||
@ -414,12 +418,47 @@ class Sales_PD_Controller extends REST_Controller {
|
|||||||
$salepd_serial_no .= '-'.(++$count[0]['count']);
|
$salepd_serial_no .= '-'.(++$count[0]['count']);
|
||||||
|
|
||||||
$records['sales_pd_sno'] = $salepd_serial_no;
|
$records['sales_pd_sno'] = $salepd_serial_no;
|
||||||
$this->Sales_PD_Model->saveRecords($records,SALES_PD_DATA);
|
$id = $this->Sales_PD_Model->saveRecords($records,SALES_PD_DATA);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->Sales_PD_Model->updateRecords($records,SALES_PD_DATA,array('sales_pd_id' => $records['sales_pd_id']));
|
|
||||||
|
$drafted_sections = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('status' => 0,'sales_pd_id' => $records['sales_pd_id'],'isactive' => 1),SALESPD_SECTION_DATA);
|
||||||
|
//print_r($drafted_sections);die();
|
||||||
|
if(count($drafted_sections))
|
||||||
|
{
|
||||||
|
$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';
|
||||||
|
$id = $this->Sales_PD_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;
|
||||||
|
$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 saveSalesPDsection_post()
|
public function saveSalesPDsection_post()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user