Sales PD S3 Image : ps
This commit is contained in:
parent
5894dca19e
commit
0af3e6eac4
@ -214,12 +214,17 @@ class Sales_PD_Controller extends REST_Controller {
|
||||
// print_r($view_data['section3']);die();
|
||||
$view_data['section9'] = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('fk_sales_pd_id' => $sales_pd_id,'img_name !=' => 'satellite','isactive' => 1),SALEPD_DOCS);
|
||||
if($view_data['section9']){
|
||||
$gcpBucketName = 'sales-pd-demo';
|
||||
// $gcpBucketName = GCP_BUCKET_NAME;
|
||||
foreach ($view_data['section9'] as $key => $value){
|
||||
if($value['img'] == '' ){
|
||||
$objectName = "pd".$sales_pd_id."/images/".$value['img_name'].".png";
|
||||
$img_gcp_url = $this->googlecloud->getSingleObjectInaBucketAsSignedURI($gcpBucketName,$objectName);
|
||||
$view_data['section9'][$key]['img'] = $img_gcp_url ? $img_gcp_url : "";
|
||||
if($value['img_name'] == '' ){
|
||||
$bucket_name = LENDER_BUCKET_NAME_PREFIX.$sales_pd_data[0]['lender_id'];
|
||||
$bucket_key = "sales_pd/".$sales_pd_data[0]['sales_pd_id']."/images/".$value['img_name'].".png";
|
||||
$singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name, $bucket_key,'30 minutes');
|
||||
$img_url = $value['img'] ? $value['img'] : ($singed_uri ? $singed_uri : "");
|
||||
$view_data['section9'][$key]['img_name'] = $img_url;
|
||||
// $objectName = "pd".$sales_pd_id."/images/".$value['img_name'].".png";
|
||||
// $img_gcp_url = $this->googlecloud->getSingleObjectInaBucketAsSignedURI($gcpBucketName,$objectName);
|
||||
// $view_data['section9'][$key]['img'] = $img_gcp_url ? $img_gcp_url : "";
|
||||
// echo "img". $img_gcp_url;
|
||||
}
|
||||
|
||||
@ -228,7 +233,13 @@ class Sales_PD_Controller extends REST_Controller {
|
||||
}
|
||||
|
||||
// print_r($view_data['section9']);die();
|
||||
$view_data['satellite_image'] = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('fk_sales_pd_id' => $sales_pd_id,'img_name' => 'satellite','isactive' => 1),SALEPD_DOCS);
|
||||
$satellite_image = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('fk_sales_pd_id' => $sales_pd_id,'img_name' => 'satellite','isactive' => 1),SALEPD_DOCS);
|
||||
$bucket_name = LENDER_BUCKET_NAME_PREFIX.$sales_pd_data[0]['lender_id'];
|
||||
$bucket_key = "sales_pd/".$sales_pd_data[0]['sales_pd_id']."/images/satellite.png";
|
||||
$singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name, $bucket_key,'30 minutes');
|
||||
$img_url = $value['img'] ? 'data:image/gif;base64,'.$satellite_image[0]['img'] : ($singed_uri ? $singed_uri : "");
|
||||
$view_data['satellite_image'] = $img_url;
|
||||
// $view_data['satellite_image'] = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('fk_sales_pd_id' => $sales_pd_id,'img_name' => 'satellite','isactive' => 1),SALEPD_DOCS);
|
||||
$view_data['product_id'] = $sales_pd_data[0]['product_id'];
|
||||
$view_data['geo_location'] = $sales_pd_data[0]['geo_location'];
|
||||
//print_r($this->db->last_query());die();
|
||||
@ -246,7 +257,7 @@ class Sales_PD_Controller extends REST_Controller {
|
||||
log_message('ERROR','####SALES PD REPORT UPLOAD TO S3'.$sales_pd_id);
|
||||
$s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data);
|
||||
/*** GCP Report Upload here */
|
||||
$gcpBucketName = 'sales-pd-demo';
|
||||
$gcpBucketName = GCP_BUCKET_NAME;
|
||||
$gcpObjectName = "pd".$sales_pd_id."/report/".$pdf_name.".pdf";
|
||||
$source=$output_file;
|
||||
$gcpResult = $this->googlecloud->uploadFileToGCPBucket($gcpBucketName,$gcpObjectName,$source);
|
||||
@ -261,13 +272,13 @@ class Sales_PD_Controller extends REST_Controller {
|
||||
$this->Sales_PD_Model->updateRecords(array('is_pdf' => 1, 'is_edited' => 0),SALES_PD_DATA,array('sales_pd_id' => $sales_pd_id));
|
||||
sleep(10);
|
||||
$result = $this->dataSynchronization($sales_pd_id);
|
||||
log_message('ERROR', '#### Automation CET Data Push Sales PD ('.$sales_pd_id.') status '.$result->status." Data Transfered");
|
||||
if($result->status == 200){
|
||||
log_message('ERROR', '#### Sales PD ('.$sales_pd_id.') status '.$result->status." Data Transfered");
|
||||
log_message('ERROR', '#### Automation CET Data Push Sales PD ('.$sales_pd_id.') status : '.$result->status);
|
||||
if(isset($result->status) && $result->status == 200){
|
||||
log_message('ERROR', '#### Sales PD ('.$sales_pd_id.') status : '.$result->status." Data Transfered");
|
||||
$update_fields2 = array('is_the_data_transfer_cet' => 1);
|
||||
$this->Sales_PD_Model->updateRecords($update_fields2,SALES_PD_DATA,array('sales_pd_id' => $sales_pd_id));
|
||||
}else{
|
||||
log_message('ERROR', '#### Sales PD ('.$sales_pd_id.') status '.$result->status);
|
||||
log_message('ERROR', '#### Sales PD ('.$sales_pd_id.') status : '.$result->status." Data Not Transfered");
|
||||
}
|
||||
if($api)
|
||||
{
|
||||
@ -299,7 +310,7 @@ class Sales_PD_Controller extends REST_Controller {
|
||||
}else {
|
||||
$singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$old_key,'30 minutes');
|
||||
}
|
||||
$gcpBucketName = 'sales-pd-demo';
|
||||
$gcpBucketName = GCP_BUCKET_NAME;
|
||||
// $gcpObjectName = "pd".$sales_pd_id."/report/new.pdf";
|
||||
$gcpObjectName = "pd".$sales_pd_id."/report/".$pdf_name.".pdf";
|
||||
$report_gcp_url = $this->googlecloud->getSingleObjectInaBucketAsSignedURI($gcpBucketName,$gcpObjectName);
|
||||
@ -325,7 +336,7 @@ class Sales_PD_Controller extends REST_Controller {
|
||||
$details = $this->Sales_PD_Model->selectCustomRecords($columns, $where_arr, $table);
|
||||
if(!empty($details)){
|
||||
$response = $this->dataSynchronization($sales_pd_id);
|
||||
if($response){
|
||||
if(isset($response->status) && ($response->status == 200)){
|
||||
log_message('ERROR', '#### Sales PD ('.$sales_pd_id.') status '.$response->status." Data Transfered");
|
||||
$update_fields2 = array('is_the_data_transfer_cet' => 1);
|
||||
$this->Sales_PD_Model->updateRecords($update_fields2,SALES_PD_DATA,array('sales_pd_id' => $sales_pd_id));
|
||||
@ -334,6 +345,7 @@ class Sales_PD_Controller extends REST_Controller {
|
||||
$data['msg'] = 'Data Shared Successfully';
|
||||
$this->response($data,REST_Controller::HTTP_OK);
|
||||
}else{
|
||||
log_message('ERROR', '#### Sales PD ('.$sales_pd_id.') status '.$response->status." Data Not Transfered");
|
||||
$data['dataStatus'] = false;
|
||||
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
||||
$data['msg'] = 'Something went wrong! Try Later';
|
||||
@ -381,7 +393,7 @@ class Sales_PD_Controller extends REST_Controller {
|
||||
$sales_pd_id = $details[$i]['sales_pd_id'];
|
||||
// echo $sales_pd_id;
|
||||
$result = $this->dataSynchronization($sales_pd_id);
|
||||
if($result->status == 200){
|
||||
if(isset($result->status) && $result->status == 200){
|
||||
$flag = $flag+1;
|
||||
//update here.
|
||||
log_message('ERROR', '#### Sales PD ('.$sales_pd_id.') status '.$result->status." Data Transfered");
|
||||
@ -389,7 +401,7 @@ class Sales_PD_Controller extends REST_Controller {
|
||||
$this->Sales_PD_Model->updateRecords($update_fields2,SALES_PD_DATA,array('sales_pd_id' => $sales_pd_id));
|
||||
array_push($ids, $sales_pd_id);
|
||||
}else{
|
||||
log_message('ERROR', '#### Sales PD ('.$sales_pd_id.') status '.$result->status);
|
||||
log_message('ERROR', '#### Sales PD ('.$sales_pd_id.') status '.$result->status." Data Not Transfered");
|
||||
}
|
||||
// $flag = ($result == true) ? $flag+1 : $flag;
|
||||
}
|
||||
@ -464,7 +476,7 @@ class Sales_PD_Controller extends REST_Controller {
|
||||
}
|
||||
}
|
||||
$result = cet_salespd::pushwithcetsalespdapi($common_fields,$CETAPP_salesPD_data,1);
|
||||
if($result->status == 200){
|
||||
if(isset($result->status) && $result->status == 200){
|
||||
$photograph_data = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('fk_sales_pd_id' => $sales_pd_id,'img_name !=' => 'satellite','isactive' => 1),SALEPD_DOCS);
|
||||
$satellite_image = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('fk_sales_pd_id' => $sales_pd_id,'img_name' => 'satellite','isactive' => 1),SALEPD_DOCS);
|
||||
log_message('ERROR', '#### Sales PD ('.$sales_pd_id.') There are ' . count($photograph_data).' Images');
|
||||
@ -488,7 +500,7 @@ class Sales_PD_Controller extends REST_Controller {
|
||||
}
|
||||
return $result;
|
||||
}else{
|
||||
log_message('ERROR',"###CET APP SALES PDID (".$sales_pd_id.") PullSalesPDData response :".json_encode($result));
|
||||
log_message('ERROR',"### CET APP SALES PDID (".$sales_pd_id.") PullSalesPDData response :".json_encode($result));
|
||||
$data['dataStatus'] = false;
|
||||
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
||||
$data['msg'] = 'Sales pd details Not Pushed ! Try Later';
|
||||
@ -761,6 +773,7 @@ class Sales_PD_Controller extends REST_Controller {
|
||||
if($is_customer_app)
|
||||
{
|
||||
$this->Sales_PD_Model->updateRecords(array('isactive' => 0),SALESPD_SECTION_DATA,array('section_id' => 9,'sales_pd_id' => $records['fk_sales_pd_id']));
|
||||
log_message('ERROR', '### SATELLITE IMAGE STORED IN S3 DONE - ');
|
||||
}
|
||||
|
||||
}
|
||||
@ -769,15 +782,36 @@ class Sales_PD_Controller extends REST_Controller {
|
||||
$this->Flyhi_Model->updateRecords($update_fields2,SALEPD_DOCS,array('doc_id'=>$records['img_id']));
|
||||
}
|
||||
unset($records['img_id']);
|
||||
|
||||
$this->load->library('Googlecloud');
|
||||
$gcpBucketName = 'sales-pd-demo';
|
||||
$objectName = "pd".$records['fk_sales_pd_id']."/images/".$records['img_name'].".png";
|
||||
$sales_pd_id = $records['fk_sales_pd_id'];
|
||||
$image_inserted = 0;
|
||||
$source=$records['img'];
|
||||
//Google Library - GCP
|
||||
$this->load->library('Googlecloud');
|
||||
$gcpBucketName = GCP_BUCKET_NAME;
|
||||
$objectName = "pd".$sales_pd_id."/images/".$records['img_name'].".png";
|
||||
$result = $this->googlecloud->uploadFileToGCPBucket($gcpBucketName,$objectName,$source);
|
||||
if($result == true){
|
||||
$image_inserted++;
|
||||
log_message('ERROR', '### Sales-PD ('.$sales_pd_id.') '.$records['img_name'].' Image Stored In GCP');
|
||||
}else{ log_message('ERROR', '### Sales-PD ('.$sales_pd_id.') '.$records['img_name'].' Image Not Stored In GCP'); }
|
||||
//Amazon Library - S3
|
||||
$columns = array('SALES_PD_DATA.lender_id');
|
||||
$table = SALES_PD_DATA.' as SALES_PD_DATA';
|
||||
$where_condition_array = array('SALES_PD_DATA.sales_pd_id' => $sales_pd_id);
|
||||
$sales_pd_data = $this->Sales_PD_Model->selectCustomRecords($columns,$where_condition_array,$table);
|
||||
|
||||
$bucket_name = LENDER_BUCKET_NAME_PREFIX.$sales_pd_data[0]['lender_id'];
|
||||
$bucket_key = "sales_pd/".$sales_pd_id."/images/".$records['img_name'].".png";
|
||||
$bucket_data = array('bucket_name' => $bucket_name, 'key' => $bucket_key, 'sourcefile' => $source);
|
||||
$s3result = $this->aws_s3->uploadFileToS3Bucket($bucket_data);
|
||||
if (is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) {
|
||||
$image_inserted++;
|
||||
log_message('ERROR', '### Sales-PD ('.$sales_pd_id.') '.$records['img_name'].' Image Stored In S3');
|
||||
}else{ log_message('ERROR', '### Sales-PD ('.$sales_pd_id.') '.$records['img_name'].' Image Not Stored In S3'); }
|
||||
if($image_inserted>=1){
|
||||
unset($records['img']);
|
||||
$id = $this->Sales_PD_Model->saveRecords($records,SALEPD_DOCS);
|
||||
log_message('ERROR', '### Sales-PD ('.$sales_pd_id.') Image Saved in DB - id : '.$id);
|
||||
}
|
||||
if($id)
|
||||
{
|
||||
@ -1141,6 +1175,11 @@ class Sales_PD_Controller extends REST_Controller {
|
||||
{
|
||||
$records = $this->post('records');
|
||||
$section_data = array();
|
||||
$columns = array('SALES_PD_DATA.lender_id');
|
||||
$table = SALES_PD_DATA.' as SALES_PD_DATA';
|
||||
$where_condition_array = array('SALES_PD_DATA.sales_pd_id' => $records['sales_pd_id']);
|
||||
$sales_pd_data = $this->Sales_PD_Model->selectCustomRecords($columns,$where_condition_array,$table);
|
||||
|
||||
if(!is_numeric($records['section_id'])){ // Sales PD Section ListPage.
|
||||
$fields=array('id','sales_pd_id','section_id','status','createdby','createdon');
|
||||
if($records['section_id'] == 'data'){ $fields[] = 'section_data'; }
|
||||
@ -1175,7 +1214,11 @@ class Sales_PD_Controller extends REST_Controller {
|
||||
$selfie = $this->Sales_PD_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'];
|
||||
$bucket_name = LENDER_BUCKET_NAME_PREFIX.$sales_pd_data[0]['lender_id'];
|
||||
$bucket_key = "sales_pd/".$records['sales_pd_id']."/images/".$selfie[0]['img'].".png";
|
||||
$singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name, $bucket_key, '30 minutes');
|
||||
$photo_questions['questions'][$key]['answer_value'] = $singed_uri;
|
||||
// $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'];
|
||||
}
|
||||
@ -1196,7 +1239,11 @@ class Sales_PD_Controller extends REST_Controller {
|
||||
{
|
||||
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'];
|
||||
$bucket_name = LENDER_BUCKET_NAME_PREFIX.$sales_pd_data[0]['lender_id'];
|
||||
$bucket_key = "sales_pd/".$records['sales_pd_id']."/images/".$img_value['img'].".png";
|
||||
$singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name, $bucket_key,'30 minutes');
|
||||
$photo_questions['questions'][$key]['questions_group'][$v_key]['questions'][0]['answer_value'] = $singed_uri;
|
||||
// $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'];
|
||||
unset($all_sales_pd_images[$img_key]);
|
||||
@ -1368,9 +1415,9 @@ public function filterSalesPDList_post() {
|
||||
}
|
||||
|
||||
$img_data = array();
|
||||
$this->load->library('Googlecloud');
|
||||
$gcpBucketName = 'sales-pd-demo';
|
||||
$objectName = "pd".$sales_pd_master_data[0]['sales_pd_id']."/images/";
|
||||
// $this->load->library('Googlecloud');
|
||||
// $gcpBucketName = GCP_BUCKET_NAME;
|
||||
// $objectName = "pd".$sales_pd_master_data[0]['sales_pd_id']."/images/";
|
||||
if(count($sales_pd_img_data))
|
||||
{
|
||||
|
||||
@ -1387,26 +1434,34 @@ public function filterSalesPDList_post() {
|
||||
if($value['is_multiple'])
|
||||
{
|
||||
if(!array_key_exists($key,$img_data))
|
||||
{
|
||||
$img_gcp_url = $this->googlecloud->getSingleObjectInaBucketAsSignedURI($gcpBucketName,$objectName.$value['img_name'].".png");
|
||||
$img_url = $sales_pd_img_data_value['img'] ? $sales_pd_img_data_value['img'] : ($img_gcp_url ? $img_gcp_url : "");
|
||||
{
|
||||
$bucket_name = LENDER_BUCKET_NAME_PREFIX.$sales_pd_master_data[0]['lender_id'];
|
||||
$bucket_key = "sales_pd/".$sales_pd_master_data[0]['sales_pd_id']."/images/".$value['img_name'].".png";
|
||||
$singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name, $bucket_key,'30 minutes');
|
||||
$img_url = $value['img'] ? $value['img'] : ($singed_uri ? $singed_uri : "");
|
||||
$img_data[$key] = array('img_key' => $key,'img_name' => $value['img_name'],'img_data' => [array('img_url' => $img_url,'img_id'=>($sales_pd_img_data_value['doc_id']) ? $sales_pd_img_data_value['doc_id'] : '','location'=>($sales_pd_img_data_value['location']) ? $sales_pd_img_data_value['location'] : '')],'is_multiple' => 1,'section_heading' => $value['img_name']);
|
||||
// $img_data[$key] = array('img_key' => $key,'img_name' => $value['img_name'],'img_data' => [array('img_url' => $sales_pd_img_data_value['img'] ? $sales_pd_img_data_value['img'] : '','img_id'=>($sales_pd_img_data_value['doc_id']) ? $sales_pd_img_data_value['doc_id'] : '','location'=>($sales_pd_img_data_value['location']) ? $sales_pd_img_data_value['location'] : '')],'is_multiple' => 1,'section_heading' => $value['img_name']);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$img_gcp_url = $this->googlecloud->getSingleObjectInaBucketAsSignedURI($gcpBucketName,$objectName.$value['img_name'].".png");
|
||||
$img_url = $sales_pd_img_data_value['img'] ? $sales_pd_img_data_value['img'] : ($img_gcp_url ? $img_gcp_url : "");
|
||||
$bucket_name = LENDER_BUCKET_NAME_PREFIX.$sales_pd_master_data[0]['lender_id'];
|
||||
$bucket_key = "sales_pd/".$sales_pd_master_data[0]['sales_pd_id']."/images/".$value['img_name'].".png";
|
||||
$singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name, $bucket_key,'30 minutes');
|
||||
$img_url = $value['img'] ? $value['img'] : ($singed_uri ? $singed_uri : "");
|
||||
$img_data[$key]['img_data'][] = array('img_url' => $img_url,'img_id'=>($sales_pd_img_data_value['doc_id']) ? $sales_pd_img_data_value['doc_id'] : '','location'=>($sales_pd_img_data_value['location']) ? $sales_pd_img_data_value['location'] : '');
|
||||
// $img_gcp_url = $this->googlecloud->getSingleObjectInaBucketAsSignedURI($gcpBucketName,$objectName.$value['img_name'].".png");
|
||||
// $img_url = $sales_pd_img_data_value['img'] ? $sales_pd_img_data_value['img'] : ($img_gcp_url ? $img_gcp_url : "");
|
||||
// $img_data[$key]['img_data'][] = array('img_url' => $img_url,'img_id'=>($sales_pd_img_data_value['doc_id']) ? $sales_pd_img_data_value['doc_id'] : '','location'=>($sales_pd_img_data_value['location']) ? $sales_pd_img_data_value['location'] : '');
|
||||
// $img_data[$key]['img_data'][] = array('img_url' => $sales_pd_img_data_value['img'] ? $sales_pd_img_data_value['img'] : '','img_id'=>($sales_pd_img_data_value['doc_id']) ? $sales_pd_img_data_value['doc_id'] : '','location'=>($sales_pd_img_data_value['location']) ? $sales_pd_img_data_value['location'] : '');
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$img_gcp_url = $this->googlecloud->getSingleObjectInaBucketAsSignedURI($gcpBucketName,$objectName.$value['img_name'].".png");
|
||||
$img_url = $sales_pd_img_data_value['img'] ? $sales_pd_img_data_value['img'] : ($img_gcp_url ? $img_gcp_url : "");
|
||||
$bucket_name = LENDER_BUCKET_NAME_PREFIX.$sales_pd_master_data[0]['lender_id'];
|
||||
$bucket_key = "sales_pd/".$sales_pd_master_data[0]['sales_pd_id']."/images/".$value['img_name'].".png";
|
||||
$singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name, $bucket_key,'30 minutes');
|
||||
$img_url = $value['img'] ? $value['img'] : ($singed_uri ? $singed_uri : "");
|
||||
$img_data[$key] = array('img_key' => $key,'img_name' => $value['img_name'],'img_url' => $img_url,'is_multiple' => 0,'section_heading' => $value['img_name'],'img_id'=>($sales_pd_img_data_value['doc_id']) ? $sales_pd_img_data_value['doc_id'] : '','location'=>($sales_pd_img_data_value['location']) ? $sales_pd_img_data_value['location'] : '');//$sales_pd_img_data_value['img']
|
||||
|
||||
}
|
||||
@ -1674,9 +1729,12 @@ public function filterSalesPDList_post() {
|
||||
$applicantname = $this->get('applicantname');
|
||||
$applicantid = $this->get('applicantid');
|
||||
$userid = $this->get('uid');
|
||||
$loanamount = $this->get('loan_amount');
|
||||
$createdby = null;
|
||||
// $reponse_arr = json_decode(,true);
|
||||
// print_r(APPPATH."controller/newSalesPD.json");die();
|
||||
$lenderid = (ENVIRONMENT == 'production' ? 7 : 35);
|
||||
if ((!empty($sales_pd_type)) && (!empty($productname)) && (!empty($applicantname)) && (!empty($applicantid)) && (!empty($userid))) {
|
||||
if ((!empty($sales_pd_type)) && (!empty($productname)) && (!empty($applicantname)) && (!empty($applicantid)) && (!empty($userid)) && (!empty($loanamount))) {
|
||||
|
||||
/************lender id,shortname******************/
|
||||
$lender_short_name = $this->Sales_PD_Model->selectCustomRecords(array('short_name'),array('entity_id' => $lenderid),ENTITY);
|
||||
@ -1724,7 +1782,7 @@ public function filterSalesPDList_post() {
|
||||
/*************Inserting Here ******************/
|
||||
$records = array("sales_pd_sno"=> $salepd_serial_no,"rand_string"=>$randomString,"lender_id"=>$lenderid, "product_id"=>$product_id, "sales_pd_type"=>$sales_pd_type, "applicant_id"=>$applicantid, "applicant_name"=>$applicantname, "createdby"=>$createdby, "isactive"=>1);
|
||||
$id = $this->Sales_PD_Model->saveRecords($records,SALES_PD_DATA);
|
||||
// $id = 775; // 772,773,777,778
|
||||
// $id = 775; // 772,773,777,778
|
||||
log_message('ERROR','## 2) available sales pdid : '.$id);
|
||||
if (!empty($id)) {
|
||||
$msg = "Inserted, Sales PD : ".$salepd_serial_no."/".$id;
|
||||
@ -1774,10 +1832,26 @@ public function filterSalesPDList_post() {
|
||||
|
||||
}
|
||||
$general = array("section_id"=>$section_id,"section_name"=>$section_name,"onsubmit"=>null,"questions"=>$value['questions'],"order_id"=>1,"is_complete"=>1,"fk_createdby"=>$createdby,"sales_pd_id"=>$id);
|
||||
// print_r($general);
|
||||
array_push($section_data, $general);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if($value['questions'] && $loanamount)
|
||||
{
|
||||
foreach($value['questions'] as $form_key => $form_value)
|
||||
{
|
||||
$fieldtype = isset($form_value['type']) ? $form_value['type'] : "";
|
||||
if($form_value['question_key'] == 'loan_amount_applied'){
|
||||
$value['questions'][$form_key]['answer_value'] = $loanamount;
|
||||
}
|
||||
else if(!empty($form_value['question_key'])){
|
||||
$value['questions'][$form_key]['answer_value'] = ($fieldtype == 8 || $fieldtype == 4 || $fieldtype == 3 || $fieldtype == 2) ? 0 : null;
|
||||
}
|
||||
|
||||
}
|
||||
$fund = array("section_id"=>$section_id,"section_name"=>$section_name,"onsubmit"=>null,"questions"=>$value['questions'],"order_id"=>1,"is_complete"=>1,"fk_createdby"=>$createdby,"sales_pd_id"=>$id);
|
||||
array_push($section_data, $fund);
|
||||
}
|
||||
break;
|
||||
default: "No Sections";
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ class satellite_image
|
||||
|
||||
public static function getSatelliteImage($pd_id,$pd_type = 1,$api = null)//1 - credit PD,2 - sales pd, 3- smc credit pd
|
||||
{
|
||||
// echo 'satellite'.$pd_type;
|
||||
// echo 'satellite'.$pd_type;
|
||||
log_message('ERROR','####Satellite IMG HELPER '.$pd_id);
|
||||
$pdid = $pd_id;
|
||||
|
||||
@ -96,9 +96,49 @@ class satellite_image
|
||||
else if($pd_type == 2) //save satellite img as base64 in sale pd doc table
|
||||
{
|
||||
|
||||
$satellite_base64 = base64_encode(file_get_contents($satellite_image_png_path));
|
||||
$CI->Sales_PD_Model->updateRecords(array('isactive' => 0),SALEPD_DOCS,array('img_name' => 'satellite','fk_sales_pd_id' => $pd_id));
|
||||
$CI->Sales_PD_Model->saveRecords(array('img' => $satellite_base64,'img_name' => 'satellite','fk_sales_pd_id' => $pdid),SALEPD_DOCS);
|
||||
// Images As blob
|
||||
// $satellite_base64 = base64_encode(file_get_contents($satellite_image_png_path));
|
||||
// $CI->Sales_PD_Model->updateRecords(array('isactive' => 0),SALEPD_DOCS,array('img_name' => 'satellite','fk_sales_pd_id' => $pd_id));
|
||||
// $CI->Sales_PD_Model->saveRecords(array('img' => $satellite_base64,'img_name' => 'satellite','fk_sales_pd_id' => $pdid),SALEPD_DOCS);
|
||||
|
||||
$image_inserted = 0;
|
||||
$source=$satellite_image_png_path;
|
||||
// Google Library - GCP
|
||||
$CI->load->library('Googlecloud');
|
||||
$gcpBucketName = GCP_BUCKET_NAME;
|
||||
$objectName = "pd".$pdid."/images/satellite.png";
|
||||
$result = $CI->googlecloud->uploadFileToGCPBucket($gcpBucketName,$objectName,$source);
|
||||
if($result == true){
|
||||
$image_inserted++;
|
||||
log_message('ERROR', '### Sales-PD ('.$pdid.') Satellite Image Stored In GCP ');
|
||||
}else{
|
||||
log_message('ERROR', '### Sales-PD ('.$pdid.') Satellite Image Not Stored In GCP');
|
||||
}
|
||||
|
||||
// Amazon Library - S3
|
||||
$columns = array('SALES_PD_DATA.lender_id');
|
||||
$table = SALES_PD_DATA.' as SALES_PD_DATA';
|
||||
$where_condition_array = array('SALES_PD_DATA.sales_pd_id' => $pdid);
|
||||
$sales_pd_data = $CI->Sales_PD_Model->selectCustomRecords($columns,$where_condition_array,$table);
|
||||
$bucket_name = LENDER_BUCKET_NAME_PREFIX.$sales_pd_data[0]['lender_id'];
|
||||
$bucket_key = "sales_pd/".$pdid."/images/satellite.png";
|
||||
$bucket_data = array('bucket_name'=>$bucket_name,'key'=>$bucket_key,'sourcefile'=>$source);
|
||||
$s3result= $CI->aws_s3->uploadFileToS3Bucket($bucket_data);
|
||||
|
||||
if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200)
|
||||
{
|
||||
$image_inserted++;
|
||||
log_message('ERROR', '### Sales-PD ('.$pdid.') Satellite Image Stored In S3 ');
|
||||
}else{
|
||||
log_message('ERROR', '### Sales-PD ('.$pdid.') Satellite Image Not Stored In S3 ');
|
||||
}
|
||||
|
||||
if($image_inserted>=1){
|
||||
$CI->Sales_PD_Model->updateRecords(array('isactive' => 0),SALEPD_DOCS,array('img_name' => 'satellite','fk_sales_pd_id' => $pdid));
|
||||
$CI->Sales_PD_Model->saveRecords(array('img' => null,'img_name' => 'satellite','fk_sales_pd_id' => $pdid),SALEPD_DOCS);
|
||||
log_message('ERROR', '### Sales-PD ('.$pdid.') Satellite Images Saved in DB');
|
||||
}
|
||||
|
||||
}
|
||||
else if($pd_type == 3)
|
||||
{
|
||||
|
||||
@ -558,7 +558,8 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
<br><table class="scorecard_table"><tr><th class="thlargefont" colspan="10">Satellite Image of PD Location</th></tr></table><br>
|
||||
<p><b>GPS Coordinates of location where PD Visit was done : <?php echo $geo_location ? $geo_location : '-'; ?></b></p>
|
||||
<?php if($geo_location) { ?>
|
||||
<img style="border:3px solid #0191ed;" src = "<?php echo 'data:image/gif;base64,'.$satellite_image[0]['img']; ?>" alt = "PD Visted Location Satellite Image " height="300px" width="630px">
|
||||
<!-- <img style="border:3px solid #0191ed;" src = "<?php echo 'data:image/gif;base64,'.$satellite_image[0]['img']; ?>" alt = "PD Visted Location Satellite Image " height="300px" width="630px"> -->
|
||||
<img style="border:3px solid #0191ed;" src = "<?php echo $satellite_image; ?>" alt = "PD Visted Location Satellite Image " height="300px" width="630px">
|
||||
<?php
|
||||
}else{ echo '<p>Due to location access not provided by loan applicant Geo coordinates on photographs and Satellite image of PD location is not shown</p>';}
|
||||
?>
|
||||
|
||||
@ -540,7 +540,8 @@ if(isset($section6))
|
||||
<br><table class="scorecard_table"><tr><th class="thlargefont" colspan="10">Satellite Image of PD Location</th></tr></table><br>
|
||||
<p><b>GPS Coordinates of location where PD Visit was done : <?php echo $geo_location ? $geo_location : '-'; ?></b></p>
|
||||
<?php if($geo_location) { ?>
|
||||
<img style="border:3px solid #0191ed;" src = "<?php echo 'data:image/gif;base64,'.$satellite_image[0]['img']; ?>" alt = "PD Visted Location Satellite Image " height="300px" width="630px">
|
||||
<!-- <img style="border:3px solid #0191ed;" src = "<?php echo 'data:image/gif;base64,'.$satellite_image[0]['img']; ?>" alt = "PD Visted Location Satellite Image " height="300px" width="630px"> -->
|
||||
<img style="border:3px solid #0191ed;" src = "<?php echo $satellite_image; ?>" alt = "PD Visted Location Satellite Image " height="300px" width="630px">
|
||||
<?php
|
||||
}else{ echo '<p>Due to location access not provided by loan applicant Geo coordinates on photographs and Satellite image of PD location is not shown</p>';}
|
||||
?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user