4th commited :ps
This commit is contained in:
parent
a243f0e913
commit
29efb88454
@ -307,7 +307,111 @@ class Flyhi_Controller extends REST_Controller {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public function getFlyhiPD_post()
|
||||||
|
{
|
||||||
|
$records = $this->post('records');
|
||||||
|
$section_data = array();
|
||||||
|
if(!is_numeric($records['section_id'])){
|
||||||
|
$fields=array('id','sales_pd_id','section_id','status','createdby','createdon');
|
||||||
|
if($records['section_id'] == 'data'){ $fields[] = 'section_data'; }
|
||||||
|
$section_data=$this->Flyhi_Model->selectCustomRecords($fields,array('sales_pd_id' => $records['sales_pd_id'],'isactive' => 1),SALESPD_SECTION_DATA);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$section_data = $this->Flyhi_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $records['sales_pd_id'],'isactive' => 1,'section_id' => $records['section_id']),SALESPD_SECTION_DATA);
|
||||||
|
//print_r( json_decode($section_data[0]['section_data'],true));die();
|
||||||
|
if($records['section_id'] == 9 && count($section_data))
|
||||||
|
{
|
||||||
|
$all_sales_pd_images = $this->Flyhi_Model->selectCustomRecords(array('*'),array('fk_sales_pd_id' => $records['sales_pd_id'],'img_name !=' => 'satellite','isactive' => 1),SALEPD_DOCS);
|
||||||
|
// print_r($all_sales_pd_images);die();
|
||||||
|
$photo_questions = (json_decode(($section_data[0]['section_data']),true));
|
||||||
|
$array1 = array_map(function($element){
|
||||||
|
return $element['img_name'];
|
||||||
|
}, $all_sales_pd_images);
|
||||||
|
$array2 = (array_count_values($array1));
|
||||||
|
$array3 = array();
|
||||||
|
foreach ($photo_questions['questions'] as $key => $value)
|
||||||
|
{
|
||||||
|
$array3[$value['question_key']] = (isset($value['questions_group']) && $value['is_repeatable']) ? count($value['questions_group']) : ($value['answer_value'] ? 1 : 0 );
|
||||||
|
}
|
||||||
|
// $subtracted = array_map(function ($x, $y) { return $x-$y; } , $array2, $array3);
|
||||||
|
// $result = array_combine(array_keys($array2), $subtracted);
|
||||||
|
$result = array();
|
||||||
|
foreach ($array2 as $key => $value) {
|
||||||
|
$var = $array2[$key] - $array3[$key];
|
||||||
|
$result[$key] = ($var < 0 ? 0 : $var);
|
||||||
|
}
|
||||||
|
// echo "all image \n";print_r($array2);echo "section image \n";
|
||||||
|
// print_r($array3);echo "all - section = result \n";print_r($result);die();
|
||||||
|
|
||||||
|
foreach ($photo_questions['questions'] as $key => $value)
|
||||||
|
{
|
||||||
|
if(isset($value['answer_value']) && $value['answer_value'] && !$value['is_repeatable'])
|
||||||
|
{
|
||||||
|
$selfie = $this->Flyhi_Model->selectCustomRecords(array('*'),array('fk_sales_pd_id' => $records['sales_pd_id'],'img_name' => 'selfie_with_person_met','isactive' => 1),SALEPD_DOCS);
|
||||||
|
if(count($selfie))
|
||||||
|
{
|
||||||
|
$photo_questions['questions'][$key]['answer_value'] = $selfie[0]['img'];
|
||||||
|
$photo_questions['questions'][$key]['image_location'] = $selfie[0]['location'];
|
||||||
|
$photo_questions['questions'][$key]['image_id'] = $selfie[0]['doc_id'];
|
||||||
|
//$photo_questions['questions'][$key]['answer_value'] = "CHNAGED";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach ($value['questions_group'] as $v_key => $individual_value)
|
||||||
|
{
|
||||||
|
//print_r($individual_value);die();
|
||||||
|
//if($individual_value['questions'][0]['answer_value'])
|
||||||
|
// echo $individual_value['questions'][0]['question_key'];
|
||||||
|
// echo $result[$individual_value['questions'][0]['question_key']];
|
||||||
|
// if($individual_value['questions'][0]['question_key'] == 'stock_image'){
|
||||||
|
if (array_key_exists($individual_value['questions'][0]['question_key'],$result)){
|
||||||
|
for($i=1;$i<=$result[$individual_value['questions'][0]['question_key']];$i++){
|
||||||
|
$photo_questions['questions'][$key]['questions_group'][$v_key+($i)] = $photo_questions['questions'][$key]['questions_group'][0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// }
|
||||||
|
if(isset($individual_value['questions'][0]['answer_value']))
|
||||||
|
{
|
||||||
|
//iterate all_sales_pd_images to get one
|
||||||
|
foreach ($all_sales_pd_images as $img_key => $img_value)
|
||||||
|
{
|
||||||
|
if($individual_value['questions'][0]['question_key'] == $img_value['img_name'])
|
||||||
|
{
|
||||||
|
$photo_questions['questions'][$key]['questions_group'][$v_key]['questions'][0]['answer_value'] = $img_value['img'];
|
||||||
|
$photo_questions['questions'][$key]['questions_group'][$v_key]['questions'][0]['image_location'] = $img_value['location'];
|
||||||
|
$photo_questions['questions'][$key]['questions_group'][$v_key]['questions'][0]['image_id'] = $img_value['doc_id'];
|
||||||
|
//$photo_questions['questions'][$key]['questions_group'][$v_key]['questions'][0]['answer_value'] = "CHANGED";
|
||||||
|
unset($all_sales_pd_images[$img_key]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//print_r($photo_questions);die;
|
||||||
|
$photo_questions = json_encode($photo_questions);
|
||||||
|
$section_data[0]['section_data'] = $photo_questions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($section_data)
|
||||||
|
{
|
||||||
|
$data['dataStatus'] = true;
|
||||||
|
$data['status'] = REST_Controller::HTTP_OK;
|
||||||
|
$data['records'] = $section_data;
|
||||||
|
$this->response($data,REST_Controller::HTTP_OK);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$data['dataStatus'] = false;
|
||||||
|
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
||||||
|
$data['msg'] = 'No Data Found';
|
||||||
|
$this->response($data,REST_Controller::HTTP_OK);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function getFlyhiPDReport_get()
|
public function getFlyhiPDReport_get()
|
||||||
{
|
{
|
||||||
$pd_id = $this->uri->segment(2);
|
$pd_id = $this->uri->segment(2);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user