diff --git a/api/application/controllers/Sales_PD_Controller.php b/api/application/controllers/Sales_PD_Controller.php index 66751347..bbc4d122 100644 --- a/api/application/controllers/Sales_PD_Controller.php +++ b/api/application/controllers/Sales_PD_Controller.php @@ -479,14 +479,19 @@ class Sales_PD_Controller extends REST_Controller { $is_entry_done = null; $id = null; //print_r($records);die(); - if($records['sales_pd_id'] == '' || $records['sales_pd_id'] == null) - { + + $section_names = array('1' => 'General Section','2' => 'Fund Requirement','3' => 'stakeholders','4' => 'Brief of business','5' => 'Financial','6' => 'Property Details','7' => 'Officer Details','8' => 'Final Remraks','9' => 'Photography'); $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); $product_short_name = $this->Sales_PD_Model->selectCustomRecords(array('abbr'),array('product_id' => $records['product_id']),PRODUCTS); + if($records['sales_pd_id'] == '' || $records['sales_pd_id'] == null) + { + + + $salepd_serial_no = count($lender_short_name)? $lender_short_name[0]['short_name']:'UNKNOWN'; $salepd_serial_no .= count($product_short_name)? '-'.$product_short_name[0]['abbr']:'-UNKNOWN'; @@ -497,16 +502,37 @@ class Sales_PD_Controller extends REST_Controller { } else { - + //echo $product_short_name[0]['abbr']; if(isset($records['status']) && $records['status'] == 'COMPLETED') { $drafted_sections = $this->Sales_PD_Model->selectCustomRecords(array('section_id'),array('status' => 0,'sales_pd_id' => $records['sales_pd_id'],'isactive' => 1),SALESPD_SECTION_DATA); - //print_r($drafted_sections); + + $completed_sections = $this->Sales_PD_Model->selectCustomRecords(array('section_id'),array('status' => 1,'sales_pd_id' => $records['sales_pd_id'],'isactive' => 1),SALESPD_SECTION_DATA); + //print_r($completed_sections); + + $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($product_short_name[0]['abbr'] == "WCTL"){ unset($dup_of_section_names[6]);} + // print_r($dup_of_section_names); + $data['dataStatus'] = true; + $data['records'] = array_values($dup_of_section_names); + $data['pd_status'] = 'DRAFT'; + $data['status'] = REST_Controller::HTTP_OK; + $this->response($data,REST_Controller::HTTP_OK); + if(count($drafted_sections)) { - //merge section name - $section_names = array('General Section','Fund Requirement','stakeholders','Brief of business','Financial','Property Details','Officer Details','Final Remraks','Photography'); + $drafted_sections = array_map(function($single) use ($section_names) {