diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index 7d7b8fd0..f72404cf 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -3883,30 +3883,57 @@ class PD_Controller extends REST_Controller { { $records = $this->post('records'); $pd_id = $records['pd_id']; - // $pd_form_id = $records['pd_form_id']; + $company_list = array(); $fields = array('json'); $where_condition_array = array('isactive' => 1,'fk_form_id'=>18,'fk_pd_id'=>$pd_id); - $rec = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); - - //print_r($rec); - // $pd_applicant_details = $this->PD_Model->getApplicantsDetails($pd_id); - - // foreach($pd_applicant_details as $applicant) - // { - // $company_list = array_merge($company_list,array($applicant['company_name'])); - // } - + $rec = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); if(count($rec)) { $temp_data = json_decode($rec[0]['json'],true); foreach($temp_data['companies'] as $company) { - //print_r($company); + $company_list[] = array('company_order_id' => $company['company_order_id'],'company_name' => $company['company_name'],'is_active' => $company['is_active']); } + + foreach($company_list as $list_key => $company) + { + $form_array = array( + array('form_id' => 1,'form_name' => 'Supplier Details'), + array('form_id' => 2,'form_name' => 'Client Details'), + array('form_id' => 11,'form_name' => 'Stock Details'), + array('form_id' => 13,'form_name' => 'Business Informations'), + array('form_id' => 14,'form_name' => 'Financial Information') + + ); + $temp = array(); + foreach($form_array as $form) + { + $this->db->SELECT('count(*) as count'); + $this->db->FROM(PDFORMDETAILSJSON.' as PDFORMDETAILSJSON'); + $this->db->WHERE('PDFORMDETAILSJSON.fk_pd_id',$pd_id); + $this->db->WHERE('PDFORMDETAILSJSON.fk_form_id',$form['form_id']); + $this->db->WHERE('PDFORMDETAILSJSON.company_id',$company['company_order_id']); + $this->db->WHERE('PDFORMDETAILSJSON.isactive',1); + $template_forms_count = $this->db->GET()->result_array(); + + if($template_forms_count[0]['count'] != 0) { + $temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => true); + } + else + { + $temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => false); + } + + } + + $company_list[$list_key]['form_status'] = $temp; + + + } } if(count($company_list))