PD PROCESS 5

This commit is contained in:
velz 2018-10-25 15:33:10 +05:30
parent 3fb147b12a
commit 65f7212dcc
2 changed files with 68 additions and 21 deletions

View File

@ -245,7 +245,7 @@ class PD_Controller extends REST_Controller {
{
$fields = array('fk_template_id');
$where_condition_array = array('fk_lender_id'=>1 ,'fk_product_id'=> 1,'fk_customer_segment'=> 1,'isactive' => 1);
$where_condition_array = array('fk_lender_id'=>$pd_details['fk_lender_id'] ,'fk_product_id'=> $pd_details['fk_product_id'],'fk_customer_segment'=> $pd_details['fk_customer_segment'],'isactive' => 1);
$table = LENDERTEMPLATE;
@ -465,15 +465,39 @@ class PD_Controller extends REST_Controller {
$this->aws_sns->sendSMS($msg,$no);
}
$where_condition_array = array('pd_id' => $pd_details['pd_id']);
$pd_id_modified = $this->PD_Model->updateRecords($pd_details,PDTRIGGER,$where_condition_array);
if($pd_details['pd_status'] == TRIGGERED)
{
// Create entries on `t_pd_category_weightage` table from Template Category weightage
// Template Re assign Functionality
$fields = array('fk_lender_id','fk_product_id','fk_customer_segment');
$where_condition_array = array('pd_id'=>$pdid);
$res_array = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDTRIGGER);
/***********************CHOOSE PD TEMPALATE*********************/
if(count($res_array))
{
$fields = array('fk_template_id');
$where_condition_array = array('fk_lender_id'=>$res_array['fk_lender_id'] ,'fk_product_id'=> $res_array['fk_product_id'],'fk_customer_segment'=> $res_array['fk_customer_segment'],'isactive' => 1);
$table = LENDERTEMPLATE;
$choosed_template_id = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,$table);
if(count($choosed_template_id))
{
$pd_details['fk_pd_template_id'] = $choosed_template_id[0]['fk_template_id'];
}
}
}
$where_condition_array = array('pd_id' => $pd_details['pd_id']);
$pd_id_modified = $this->PD_Model->updateRecords($pd_details,PDTRIGGER,$where_condition_array);
if($pd_id_modified != null || $pd_id_modified != '' && $count != 0)
{
PDALERTS::pdnotification($pd_details['pd_id']);
@ -712,6 +736,11 @@ class PD_Controller extends REST_Controller {
}
$where_condition_array = array('pd_id' => $records['pd_id']);
$pd_id_modified = $this->PD_Model->updateRecords($records,PDTRIGGER,$where_condition_array);
// $where_condition_array = array('fk_user_id' => $records['fk_pd_allocated_to']);
// $temp_array = array('');
// $pd_id_modified = $this->PD_Model->updateRecords($records,PDTRIGGER,$where_condition_array);
if($pd_id_modified != "" || $pd_id_modified != null)
{
PDALERTS::pdnotification($records['pd_id']);

View File

@ -433,7 +433,7 @@ class PD_Model extends SPARQ_Model {
foreach($questions as $answer_key => $question)
{
$this->db->SELECT('QUESTIONANSWERS.question_answer_id,QUESTIONANSWERS.answer,TEMPLATEANSWERWEIGHTAGE.template_answer_weightage_id, TEMPLATEANSWERWEIGHTAGE.fk_template_question_id, TEMPLATEANSWERWEIGHTAGE.fk_question_answer_id, TEMPLATEANSWERWEIGHTAGE.template_answer_weightage,PDANSWER.pd_detail_answer_id');
$this->db->SELECT('QUESTIONANSWERS.question_answer_id,QUESTIONANSWERS.answer,TEMPLATEANSWERWEIGHTAGE.template_answer_weightage_id, TEMPLATEANSWERWEIGHTAGE.fk_template_question_id, TEMPLATEANSWERWEIGHTAGE.fk_question_answer_id, TEMPLATEANSWERWEIGHTAGE.template_answer_weightage,PDANSWER.pd_detail_answer_id,PDANSWER.fk_pd_detail_id');
$this->db->FROM(TEMPLATEANSWERWEIGHTAGE.' as TEMPLATEANSWERWEIGHTAGE');
$this->db->JOIN(QUESTIONANSWERS.' as QUESTIONANSWERS','TEMPLATEANSWERWEIGHTAGE.fk_question_answer_id = QUESTIONANSWERS.question_answer_id','LEFT');
$this->db->JOIN(PDANSWER." as PDANSWER","QUESTIONANSWERS.question_answer_id = PDANSWER.pd_answer_id AND TEMPLATEANSWERWEIGHTAGE.fk_question_answer_id = PDANSWER.pd_answer_id AND PDANSWER.isactive = 1 AND PDANSWER.fk_pd_id = $pdid",'LEFT');
@ -460,8 +460,9 @@ class PD_Model extends SPARQ_Model {
public function getAnswersForPD($question_id,$pd_id,$template_id,$category_id)
{
$overalldata ="";
$pd_master_detials = $this->getPDMasterDetails($pd_id);
$this->db->SELECT('QUESTIONANSWERS.question_answer_id,QUESTIONANSWERS.answer,TEMPLATEANSWERWEIGHTAGE.template_answer_weightage,PDANSWER.pd_detail_answer_id,PDANSWER.isactive');
$this->db->SELECT('QUESTIONANSWERS.question_answer_id,QUESTIONANSWERS.answer,TEMPLATEANSWERWEIGHTAGE.template_answer_weightage,PDANSWER.pd_detail_answer_id,PDANSWER.isactive,PDANSWER.fk_pd_detail_id');
$this->db->FROM(TEMPLATEANSWERWEIGHTAGE.' as TEMPLATEANSWERWEIGHTAGE');
$this->db->JOIN(TEMPLATEQUESTION." as TEMPLATEQUESTION","TEMPLATEANSWERWEIGHTAGE.fk_template_question_id = TEMPLATEQUESTION.template_question_id AND TEMPLATEQUESTION.fk_template_question_category_id = $category_id AND TEMPLATEQUESTION.fk_template_id = $template_id AND TEMPLATEQUESTION.fk_question_id = $question_id");
$this->db->JOIN(QUESTIONANSWERS.' as QUESTIONANSWERS','TEMPLATEANSWERWEIGHTAGE.fk_question_answer_id = QUESTIONANSWERS.question_answer_id');
@ -475,22 +476,39 @@ class PD_Model extends SPARQ_Model {
//$this->db->WHERE('TEMPLATEANSWERWEIGHTAGE.fk_template_id',$template_id);
// $this->db->WHERE('PDDETAIL.fk_pd_id',$pdid);
$answers = $this->db->GET()->result_array();
$overalldata['answers'] = $answers;
// if(count($answers))
// {
// $bucket_name = LENDER_BUCKET_NAME_PREFIX.$pd_master_detials[0]['fk_lender_id'];
// foreach($answers as $answer_key => $answer)
// {
// if($answer['pd_answer_image'] != "" || $answer['pd_answer_image'] != null)
// {
// $profilepics3path = 'pd'.$pd_master_detials[0]['pd_id'].'/'.$answer['pd_answer_image'];
// $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$profilepics3path,'+30 minutes');
// $answers[$answer_key]['doc_url'] = $singed_uri;
// }
// }
//Get PD Detail ID From PD DETAILS table using pd_id and question_id
$fields = array('pd_detail_id','question_remark','fk_question_id as question_id','pd_question');
$where_condition_array = array('fk_pd_id'=>$pd_id,'fk_question_id'=>$question_id);
$pd_detail = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDDETAIL);
// print_r($pd_detail);die();
if(count($pd_detail))
{
$overalldata['question_remark'] = $pd_detail[0]['question_remark'];
$overalldata['pd_detail_id'] = array('pd_detail_id'=>$pd_detail[0]['pd_detail_id'],'question_id' => $pd_detail[0]['question_id'],'question' => $pd_detail[0]['pd_question']);
$fields = array('pd_document_id', 'fk_pd_id', 'fk_pd_detail_id', 'pd_document_title', 'pd_document_name');
$where_condition_array = array('fk_pd_id'=>$pd_id,'fk_pd_detail_id'=> $pd_detail[0]['pd_detail_id']);
// }
return $answers;
$pd_docs = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDDOCUMENTS);
if(count($pd_docs))
{
$bucket_name = LENDER_BUCKET_NAME_PREFIX.$pd_master_detials[0]['fk_lender_id'];
foreach($pd_docs as $doc_key => $doc)
{
if($doc['pd_document_name'] != "" || $doc['pd_document_name'] != null)
{
$profilepics3path = 'pd'.$pd_master_detials[0]['pd_id'].'/'.$doc['pd_document_name'];
$singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$profilepics3path,'+30 minutes');
$pd_docs[$doc_key]['doc_url'] = $singed_uri;
}
}
$overalldata['images'] = $pd_docs;
}
}
return $overalldata;
}