actual PD

This commit is contained in:
velz 2018-10-22 10:28:29 +05:30
parent 1680e63dc3
commit 6cdc290295
5 changed files with 183 additions and 10 deletions

View File

@ -87,7 +87,7 @@ defined('EXIT__AUTO_MAX') OR define('EXIT__AUTO_MAX', 125); // highest auto
// define login route name for token verification
//defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', '(listLessPDDetails/:any)'); // no errors
//defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', '(listAllTemplates/:any)'); // no errors
defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', 'getQuestionsForTemplateCreation'); // no errors
defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', 'savePDQuestions'); // no errors
/*********************AWS resources Constants*************************************************/
defined('PROFILE_PICTURE_BUCKET_NAME') OR define('PROFILE_PICTURE_BUCKET_NAME','sineedgedevprofilepic');
@ -312,5 +312,8 @@ defined('VENDORCITYMAPID') OR define('VENDORCITYMAPID','vendor_city_map_id');
defined('PDCATEGORYWEIGHTAGE') OR define('PDCATEGORYWEIGHTAGE','t_pd_category_weightage');
defined('PDCATEGORYWEIGHTAGEID') OR define('PDCATEGORYWEIGHTAGEID','pd_category_weightage_id');
defined('PDDETAIL') OR define('PDDETAIL','t_pd_details');
defined('PDDETAILID') OR define('PDDETAILID','pd_detail_id');

View File

@ -134,4 +134,5 @@ $route['schdulePD'] = 'PD_Controller/schdulePD';
$route['getListPDOfficers'] = 'PD_Controller/getListPDOfficers';
$route['loadFullTemplate'] = 'PD_Controller/loadFullTemplate';
$route['allbase'] = 'PD_Controller/base';
$route['savePDQuestions'] = 'PD_Controller/saveActualPDQuestions';

View File

@ -937,11 +937,12 @@ class PD_Controller extends REST_Controller {
/******** for Load Whole PD Template for PD Screen @param template_id***************/
public function loadFullTemplate_get()
{
$template_id = "";
if($this->get('template_id')) { $template_id = $this->get('template_id'); }
if($template_id != "" || $template_id != null)
$pd_id = "";
if($this->get('pd_id')) { $pd_id = $this->get('pd_id'); }
if($pd_id != "" || $pd_id != null)
{
$template_details = $this->PD_Model->getTemplateForPD($template_id);
$template_details = $this->PD_Model->getTemplateForPD($pd_id);
if(count($template_details))
{
$data['dataStatus'] = true;
@ -953,15 +954,171 @@ class PD_Controller extends REST_Controller {
{
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
$data['msg'] = 'Template Not for PD ID'.$pd_id;
$this->response($data,REST_Controller::HTTP_OK);
}
}
else
{
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_BAD_REQUEST;
$data['msg'] = 'No Param Available';
$this->response($data,REST_Controller::HTTP_OK);
}
}
/******** Save Single PD qustions ********/
/******** Save Multiple/Single PD qustions ********/
public function saveActualPDQuestions_post()
{
//$records = json_decode($this->post('records'),true);
$records = $this->post('records');
$pd_detail_id = "";
//print_r($records);
foreach($records as $record_key => $record)
{
if($record['pd_detail_id'] != "" || $record['pd_detail_id'] != null)
{
if(isset($record['pd_answer_image']))
{
//Get Lender ID
$sql = 'SELECT fk_lender_id FROM '. PDTRIGGER .' WHERE pd_id ='.$record["fk_pd_id"];
$lender_id = $this->db->query($sql)->result_array();
//Get Old File name Delete Old FIle From S3
$sql = 'SELECT pd_answer_image FROM '. PDDETAIL .' WHERE pd_detail_id ='.$record["pd_detail_id"];
$old_image = $this->db->query($sql)->result_array();
if(count($old_image))
{
$bucketname = LENDER_BUCKET_NAME_PREFIX.$lender_id[0]['fk_lender_id'];
$key = 'pd'.$record['fk_pd_id'].'/'.$old_image[0]['pd_answer_image'];
$this->aws_s3->deleteSingleObjFromBucket($bucketname,$key);
}
$temp_base64_string = $record['pd_answer_image'];
$title = $record['pd_anwer_image_title'];
$output_file = APPPATH."/docs/temp_base64_image.png";
//Generate Random File Name
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < 5; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
$temp_file_name = $randomString.date('Y-m-d-H:m:s').'.png';
$ifp = fopen( $output_file, 'wb' );
$temp_data = explode( ',', $temp_base64_string );
fwrite( $ifp, base64_decode( $temp_data[ 1 ] ) );
fclose( $ifp );
$tempdoc = $output_file;
$tempdocname = $temp_file_name;
$bucketname = LENDER_BUCKET_NAME_PREFIX.$lender_id[0]['fk_lender_id'];
$key = 'pd'.$record['fk_pd_id'].'/'.$tempdocname ;
$sourcefile = $tempdoc;
$bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile);
$s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data);
if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200)
{
$record['pd_answer_image'] = $tempdocname;
}
}
$where_condition_array = array('pd_detail_id' => $record['pd_detail_id']);
$pd_detail_id = $this->PD_Model->updateRecords($record,PDDETAIL,$where_condition_array);
if($pd_detail_id != "" || $pd_detail_id != null)
{
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = true;
$this->response($data,REST_Controller::HTTP_OK);
}
else
{
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
$data['msg'] = "Something Went Wrong..!Try Later";
$this->response($data,REST_Controller::HTTP_OK);
}
}
else
{
if(isset($record['pd_answer_image']))
{
//Get Lender ID
$sql = 'SELECT fk_lender_id FROM '. PDTRIGGER .' WHERE pd_id ='.$record["fk_pd_id"];
$lender_id = $this->db->query($sql)->result_array();
$temp_base64_string = $record['pd_answer_image'];
$title = $record['pd_anwer_image_title'];
$output_file = APPPATH."/docs/temp_base64_image.png";
//Generate Random File Name
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < 5; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
$temp_file_name = $randomString.date('Y-m-d-H:m:s').'.png';
$ifp = fopen( $output_file, 'wb' );
$temp_data = explode( ',', $temp_base64_string );
fwrite( $ifp, base64_decode( $temp_data[ 1 ] ) );
fclose( $ifp );
$tempdoc = $output_file;
$tempdocname = $temp_file_name;
$bucketname = LENDER_BUCKET_NAME_PREFIX.$lender_id[0]['fk_lender_id'];
$key = 'pd'.$record['fk_pd_id'].'/'.$tempdocname ;
$sourcefile = $tempdoc;
$bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile);
$s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data);
if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200)
{
$record['pd_answer_image'] = $tempdocname;
}
}
$pd_detail_id = $this->PD_Model->saveRecords($record,PDDETAIL);
if($pd_detail_id != "" || $pd_detail_id != null)
{
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = $pd_detail_id;
$this->response($data,REST_Controller::HTTP_OK);
}
else
{
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
$data['msg'] = "Something Went Wrong..!Try Later";
$this->response($data,REST_Controller::HTTP_OK);
}
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 126 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -264,10 +264,20 @@ class PD_Model extends SPARQ_Model {
public function getTemplateForPD($template_id)
public function getTemplateForPD($pdid)
{
$template_id = "";
$categories = "";
//Get PD Master Details including Template id @param $pd_id
$pd_master_detials = $this->getPDMasterDetails($pdid);
// print_r($pd_master_detials);
$template_id = $pd_master_detials[0]['fk_pd_template_id'];
if($template_id != "" || $template_id != null)
{
//Get Category, QUestions and Answers @param $template_id
$this->db->SELECT('QUESTIONCATEGORY.category_name,TEMPLATECATEGORYWEIGHTAGE.template_category_weightage_id, TEMPLATECATEGORYWEIGHTAGE.fk_question_category_id, TEMPLATECATEGORYWEIGHTAGE.fk_template_id, TEMPLATECATEGORYWEIGHTAGE.weightage, DATE_FORMAT(TEMPLATECATEGORYWEIGHTAGE.createdon,"%d/%m/%Y") as createdon, TEMPLATECATEGORYWEIGHTAGE.fk_createdby, DATE_FORMAT(TEMPLATECATEGORYWEIGHTAGE.updatedon, "%d/%m/%Y") as updatedon, TEMPLATECATEGORYWEIGHTAGE.isactive, TEMPLATECATEGORYWEIGHTAGE.fk_updatedby');
$this->db->FROM(TEMPLATECATEGORYWEIGHTAGE .' as TEMPLATECATEGORYWEIGHTAGE');
$this->db->JOIN(QUESTIONCATEGORY.' as QUESTIONCATEGORY','TEMPLATECATEGORYWEIGHTAGE.fk_question_category_id = QUESTIONCATEGORY.question_category_id');
@ -275,7 +285,7 @@ class PD_Model extends SPARQ_Model {
// $this->db->JOIN(USERPROFILE.' as USERPROFILE1','TEMPLATECATEGORYWEIGHTAGE.fk_updatedby = USERPROFILE1.userid','LEFT');
$this->db->WHERE('TEMPLATECATEGORYWEIGHTAGE.fk_template_id',$template_id);
$categories = $this->db->GET()->result_array();
//print_r( $categories);
if(count($categories))
{
/*
@ -299,12 +309,13 @@ class PD_Model extends SPARQ_Model {
if(count($questions))
{
//image S3 url attach is pending
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, TEMPLATEANSWERWEIGHTAGE.isactive');
$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,PDDETAIL.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(PDDETAIL.' as PDDETAIL',"QUESTIONANSWERS.question_answer_id = PDDETAIL.pd_answer_id AND PDDETAIL.fk_pd_id = $pdid",'LEFT');
// $this->db->WHERE('QUESTIONANSWERS.fk_question_id',$question['question_id']);
$this->db->WHERE('TEMPLATEANSWERWEIGHTAGE.fk_template_question_id',$question['template_question_id']);
$answers = $this->db->GET()->result_array();
@ -315,6 +326,7 @@ class PD_Model extends SPARQ_Model {
}
}
}
return $categories;
}