From 1b4bece74ed19b01ccb1fa154d9a0ac82ba86e9d Mon Sep 17 00:00:00 2001 From: Velz2020 Date: Sat, 21 Dec 2019 16:12:21 +0530 Subject: [PATCH] SALES PD MUL IMGS RETRIVE AND REPORT --- .../controllers/Sales_PD_Controller.php | 169 +++++++++++++++--- .../views/sale_pd_templates/MWISE.php | 12 +- 2 files changed, 146 insertions(+), 35 deletions(-) diff --git a/api/application/controllers/Sales_PD_Controller.php b/api/application/controllers/Sales_PD_Controller.php index eda19e16..44c2350d 100644 --- a/api/application/controllers/Sales_PD_Controller.php +++ b/api/application/controllers/Sales_PD_Controller.php @@ -340,7 +340,10 @@ class Sales_PD_Controller extends REST_Controller { } - $temp_array[ $question['question_key'] ] = substr_replace($temp_array[ $question['question_key'] ],'', strrpos($temp_array[ $question['question_key'] ],','),1); + if(substr_count($temp_array[ $question['question_key'] ], ',')) + { + $temp_array[ $question['question_key'] ] = substr_replace($temp_array[ $question['question_key'] ],'', strrpos($temp_array[ $question['question_key'] ],','),1); + } if(substr_count($temp_array[ $question['question_key'] ], ',')) { @@ -488,10 +491,22 @@ class Sales_PD_Controller extends REST_Controller { if(isset($records['status']) && $records['status'] == 'COMPLETED') { - $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(); + $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); 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) + { + return array('section_id' => $single['section_id'],'sectin_name' => $section_names [ $single['section_id'] ]); + }, + $drafted_sections); + + //print_r($drafted_sections);die(); + unset($records['status']); $data['dataStatus'] = true; $data['records'] = $drafted_sections; @@ -680,46 +695,142 @@ class Sales_PD_Controller extends REST_Controller { } else { - + $image_order = array('selfie_with_person_met','approach_to_pd_location','name_board_seen','stock_image','workplace_interior_image'); $images = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('fk_sales_pd_id' => $records['sales_pd_id'],'img_name !=' => 'satellite','isactive' => 1),SALEPD_DOCS); //print_r($images);die(); - $photo_names = array('selfie_with_person_met' => 'Selfie with person met','approach_to_pd_location' => 'Approach to pd location','name_board_seen' => 'Name board seen', 'stock_image' => 'Stock image','workplace_interior_image' => 'Workplace interior image','satellite1' => 'satellite'); - if(count($images)) - { + $photo_names = array('selfie_with_person_met' => 'Selfie with person met','approach_to_pd_location' => 'Approach to pd location','name_board_seen' => 'Name board seen', 'stock_image' => 'Stock image','workplace_interior_image' => 'Workplace interior image'); + $questions = array(); $questions_group = array(); - foreach ($images as $key => $value) + foreach ($photo_names as $photo_key => $photo_value) { - - $question['is_repeatable'] = ""; - $question['group_title'] = null; - $question['answer_value'] = $value['img']; - //$question['answer_value'] = "IMG"; - $question['question'] = $photo_names [ $value['img_name'] ]; - $question['question_key'] = $value['img_name']; - $question['type'] = 6; - $question['validations'] = []; - $question['raw_validations'] = []; - $question['api_properties'] = null; - $question['answers'] = null; - $question['onchange_properties'] = null; - if($value['img_name'] == 'selfie_with_person_met') + if(count($images)) { - $questions[] = $question; + // foreach ($images as $key => $value) + // { + + //check current photo is exist in images array + //print_r($photo_key); + $is_exist = false; + $exist_data = array(); + + //$question = []; + foreach ($images as $key => $value) + { + if($photo_key == $value['img_name']) + { + $is_exist = true; + $exist_data[] = array('img_name' => $value['img_name'],'img' => $value['img']); + // unset($images[$key]); + // break; + } + } + // echo $is_exist; + // echo '
'; + if($is_exist) + { + // echo "YESPART"; + // echo '
'; + foreach ($exist_data as $exist_data_key => $exist_data_value) + { + + + $question['is_repeatable'] = ""; + $question['group_title'] = null; + $question['answer_value'] = $value['img']; + //$question['answer_value'] = "IMG"; + $question['question'] = $photo_names [ $exist_data_value['img_name'] ]; + $question['question_key'] = $exist_data_value['img_name']; + $question['type'] = 6; + $question['validations'] = []; + $question['raw_validations'] = []; + $question['api_properties'] = null; + $question['answers'] = null; + $question['onchange_properties'] = null; + if($exist_data_value['img_name'] == 'selfie_with_person_met') + { + $questions[] = $question; + } + else + { + $questions[ $photo_names [ $exist_data_value['img_name'] ] ] ['is_repeatable'] = 1; + $questions[ $photo_names [ $exist_data_value['img_name'] ] ] ['group_title'] = $photo_names [ $exist_data_value['img_name'] ]; + $questions[ $photo_names [ $exist_data_value['img_name'] ] ] ['group_type'] = 6; + $questions[ $photo_names [ $exist_data_value['img_name'] ] ] ['questions_group'][0]['questions'][] = $question; + } + } + $exist_data = array(); + + } + else + { + // echo "NOPART"; + // echo '
'; + // print_r($questions); + $question['is_repeatable'] = ""; + $question['group_title'] = null; + $question['answer_value'] = ''; + //$question['answer_value'] = "IMG"; + $question['question'] = $photo_value; + $question['question_key'] =$photo_key; + $question['type'] = 6; + $question['validations'] = []; + $question['raw_validations'] = []; + $question['api_properties'] = null; + $question['answers'] = null; + $question['onchange_properties'] = null; + if($photo_key == 'selfie_with_person_met') + { + //echo 'SELFIE'; + $questions[] = $question; + } + else + { + $questions[ $photo_names [ $value['img_name'] ] ] ['is_repeatable'] = 1; + $questions[ $photo_names [ $value['img_name'] ] ] ['group_title'] = $photo_value; + $questions[ $photo_names [ $value['img_name'] ] ] ['group_type'] = 6; + $questions[ $photo_names [ $value['img_name'] ] ] ['questions_group'][0]['questions'][] = $question; + } + //break; + // print_r($questions); + // die(); + } + + //} } else { - $questions[ $photo_names [ $value['img_name'] ] ] ['is_repeatable'] = 1; - $questions[ $photo_names [ $value['img_name'] ] ] ['group_title'] = $photo_names [ $value['img_name'] ]; - $questions[ $photo_names [ $value['img_name'] ] ] ['group_type'] = 6; - $questions[ $photo_names [ $value['img_name'] ] ] ['questions_group'][]['questions'][] = $question; + $question['is_repeatable'] = ""; + $question['group_title'] = null; + $question['answer_value'] = ''; + //$question['answer_value'] = "IMG"; + $question['question'] = $photo_value; + $question['question_key'] =$photo_key; + $question['type'] = 6; + $question['validations'] = []; + $question['raw_validations'] = []; + $question['api_properties'] = null; + $question['answers'] = null; + $question['onchange_properties'] = null; + if($value['img_name'] == 'selfie_with_person_met') + { + $questions[] = []; + } + else + { + $questions[ $photo_names [ $value['img_name'] ] ] ['is_repeatable'] = 1; + $questions[ $photo_names [ $value['img_name'] ] ] ['group_title'] = $photo_value; + $questions[ $photo_names [ $value['img_name'] ] ] ['group_type'] = 6; + $questions[ $photo_names [ $value['img_name'] ] ] ['questions_group'][0]['questions'][] = []; + } } - } + $temp['questions'] = array_values($questions); + print_r($questions);die(); $temp['section_id'] = 9; $temp['section_name'] = 'Photography'; @@ -734,7 +845,7 @@ class Sales_PD_Controller extends REST_Controller { $temp2['section_id'] = $records['section_id']; $temp2['status'] = '1'; $section_data[] = $temp2; - } + } if($section_data) diff --git a/api/application/views/sale_pd_templates/MWISE.php b/api/application/views/sale_pd_templates/MWISE.php index e351bac5..297e330c 100644 --- a/api/application/views/sale_pd_templates/MWISE.php +++ b/api/application/views/sale_pd_templates/MWISE.php @@ -117,7 +117,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); - + Main Applicat Name @@ -187,7 +187,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); ''.$section3_value['share_holding'].'%'. ''.$section3_value['vintage_in_current_biz'].''. ''.$section3_value['total_work_exp'].''. - ''.($section3_value['previous_experience_details'] ? $section3_value['previous_experience_details'] : 'NA' ).''. + ''.( isset ($section3_value['previous_experience_details']) && $section3_value['previous_experience_details'] ? $section3_value['previous_experience_details'] : 'NA' ).''. ''.$section3_value['started_biz'].''. ''; } @@ -384,7 +384,7 @@ if(isset($section6)) $property_value) { - echo '

Property '.($property_key + 1).''; + echo ' Property '.($property_key + 1).''; //echo 'Property '. ($property_key + 1).'
'; ?> @@ -477,10 +477,10 @@ if(isset($section6)) for($i = $from ; $i <= $to; $i++) { - // if(isset($section9[$i])) - // { + if(isset($section9[$i])) + { echo ' '.$section9[$i]['img_name'].'
'.$photo_names [ $section9[$i]['img_name'] ].''; - //} + } //unset($p_key); }