From a46450a0e778d512b28fc15c702594f2b3b60496 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Sat, 28 May 2022 18:06:26 +0530 Subject: [PATCH 01/10] fixes 1 : ps --- api/application/controllers/PD_Controller.php | 6 ++-- api/application/helpers/faceapi_helper.php | 35 ++++++++++--------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index 8ee382fe..d10bab63 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -980,7 +980,7 @@ class PD_Controller extends REST_Controller { // SMS_GUPSHUP::sendSMS($msg,$no,array('pd_id' => $exist_pd_details[0]['pd_id'],'status' => 'STARTED','msg' => 'Cus Link from PD controlller')); // } - } + }// started if condition closed here. // die(); if(isset($pd_details['pd_status']) && (($pd_details['pd_status'] == COMPLETED) || ($pd_details['pd_status'] == ADD_ON_PENDING)) ) { @@ -989,6 +989,7 @@ class PD_Controller extends REST_Controller { { $pd_details['complete_override_data'] = json_encode($pd_details['complete_override_data']); $pd_details['completed_on'] = date('Y-m-d H:i:s'); + log_message('ERROR',"PD Controller Completed Status Calling (toMakeFaceBoundingBox)"); $this->toMakeFaceBoundingBox($exist_pd_details); } @@ -11927,10 +11928,11 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() public function toMakeFaceBoundingBox($master_details){ // $pdid = $this->get('pd');//pdid 3184 comment this $pdid = $master_details[0]['pd_id']; + log_message('ERROR',"PD Controller inside to Make FaceBoundingBox PDID : ".$pdid); $bounding_box = array(); if(!empty($pdid)){ // $master_details = $this->PD_Model->getPDMasterDetails($pdid);//comment this - if($master_details[0]['pd_status'] == COMPLETED && $master_details[0]['facemark_image_generated'] == 0){ + if($master_details[0]['facemark_image_generated'] == 0){ $db_result = $this->PD_Model->selectCustomRecords(array('faceapi_result'),array('pd_id' => $pdid),PDTRIGGER); $string = $db_result[0]['faceapi_result']; // echo gettype($string); diff --git a/api/application/helpers/faceapi_helper.php b/api/application/helpers/faceapi_helper.php index ac3734a2..e5e14120 100644 --- a/api/application/helpers/faceapi_helper.php +++ b/api/application/helpers/faceapi_helper.php @@ -4,15 +4,16 @@ class faceapi { public static function toMakeFaceBoundingBox($image_name,$BoundingBox,$destination_path){ $get_image_format = explode(".",$image_name); - // $image_format = $get_image_format[1]; - $img = imagecreatefrompng($destination_path); - // if($image_format == 'png'){ - // $img = imagecreatefrompng($destination_path); - // }else if($image_format == 'jpeg'){ - // $img = imagecreatefromjpeg($destination_path); - // }else if($image_format == 'jpg'){ - // $img = imagecreatefromjpg($destination_path); - // } + $image_format = $get_image_format[1]; + // print_r($get_image_format);die(); + // $img = imagecreatefrompng($destination_path); + if($image_format == 'png'){ + $img = imagecreatefrompng($destination_path); + }else if($image_format == 'jpeg'){ + $img = imagecreatefromjpeg($destination_path); + }else if($image_format == 'jpg'){ + $img = imagecreatefromjpg($destination_path); + } $red = imagecolorallocate($img, 255, 0, 0); @@ -29,7 +30,7 @@ class faceapi $Top_coordinate = ($BoundingBox[$i]['Top'] * $imageheight) ; $Face_width = ($BoundingBox[$i]['Width'] * $imagewidth) ; $Face_height = ($BoundingBox[$i]['Height'] * $imageheight) ; - $Similarity = round($BoundingBox[$i]['Similarity']); + $Similarity = $BoundingBox[$i]['Similarity']; $x1 = $Left_coordinate; $y1 = $Top_coordinate; @@ -42,12 +43,15 @@ class faceapi } public static function DrawLine($x1,$y1,$Face_width,$Face_height,$Similarity,$img,$destination_path){ - if($Similarity >= 70 ){// above 70 green + $Similarity_split = explode(".",$Similarity); + $Similarity_value = $Similarity_split[0]; + list($imagewidth, $imageheight) = getimagesize($destination_path); + if($Similarity_value >= 70 ){// above 70 green $color = imagecolorallocate($img, 0, 153, 0); - }else if($Similarity < 70 ){// below 70 red + }else if($Similarity_value < 70 ){// below 70 red $color = imagecolorallocate($img, 255, 0, 0); } - $Similarity = $Similarity." %"; + $Similarity = $Similarity_value." %"; //TOP LINe $t_x1 = $x1; $t_y1 = $y1; @@ -73,13 +77,12 @@ class faceapi $image_format = $get_image_format[1]; if($image_format == 'png'){ - $destination_path = $get_image_format[0].".jpeg"; imagepng($img, $destination_path); }else if($image_format == 'jpeg'){ imagejpeg($img, $destination_path); }else if($image_format == 'jpg'){ - $destination_path = $get_image_format[0].".jpeg"; - imagepng($img, $destination_path); + // $destination_path = $get_image_format[0].".jpeg"; + imagejpg($img, $destination_path); } } From 4123f9e5e86d9e24a3ebdee301aa26878c5db736 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Sat, 28 May 2022 18:28:32 +0530 Subject: [PATCH 02/10] fixes : ps --- api/application/controllers/PD_Controller.php | 9 ++++++--- api/application/helpers/faceapi_helper.php | 8 ++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index d10bab63..1155dba3 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -989,7 +989,7 @@ class PD_Controller extends REST_Controller { { $pd_details['complete_override_data'] = json_encode($pd_details['complete_override_data']); $pd_details['completed_on'] = date('Y-m-d H:i:s'); - log_message('ERROR',"PD Controller Completed Status Calling (toMakeFaceBoundingBox)"); + log_message('ERROR',"PD Controller line no : 992 When Completed status means called (to Make FaceBoundingBox)"); $this->toMakeFaceBoundingBox($exist_pd_details); } @@ -11940,6 +11940,7 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() // echo gettype($my_array); if(!empty($my_array) && !empty($my_array["FaceMatches"])){ $arr = $my_array["FaceMatches"]; + log_message('ERROR',"to Make FaceBoundingBox FaceMatches array cnt : ".count($arr)); for($i=0;$iaws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes'); + log_message('ERROR',"to Make FaceBoundingBox FaceMatches singed_uri : ".$singed_uri); // $temp_image_name = "sample.png"; $temp_image_name = "face_api_image.jpeg"; @@ -11964,16 +11966,17 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile); $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); + log_message('ERROR',"to Make FaceBoundingBox s3result : ".$s3result['@metadata']['statusCode']); // print_r($s3result);die(); if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { + log_message('ERROR',"to Make FaceBoundingBox updating pdtrigger table facemark_image_generated as 1"); //Update $this->db->WHERE('pd_id',$pdid)->UPDATE(PDTRIGGER,array('facemark_image_generated' => 1)); - + log_message('ERROR',"save document table face_api_result_image after unlink"); $record_data = array('fk_pd_id' => $pdid,'pd_document_title'=>'face_api_result_image','pd_document_name'=>$temp_image_name); $this->PD_Model->saveRecords($record_data,PDDOCUMENTS); - unlink($destination_path); } // $data['dataStatus'] = true; diff --git a/api/application/helpers/faceapi_helper.php b/api/application/helpers/faceapi_helper.php index e5e14120..787fadeb 100644 --- a/api/application/helpers/faceapi_helper.php +++ b/api/application/helpers/faceapi_helper.php @@ -3,8 +3,10 @@ class faceapi { public static function toMakeFaceBoundingBox($image_name,$BoundingBox,$destination_path){ + log_message('ERROR','####faceapi helper to Make FaceBoundingBox fns'); $get_image_format = explode(".",$image_name); $image_format = $get_image_format[1]; + log_message('ERROR','####faceapi helper to Make FaceBoundingBox image_format'.$image_format); // print_r($get_image_format);die(); // $img = imagecreatefrompng($destination_path); if($image_format == 'png'){ @@ -15,15 +17,12 @@ class faceapi $img = imagecreatefromjpg($destination_path); } - $red = imagecolorallocate($img, 255, 0, 0); $black = imagecolorallocate($img, 0, 0, 0); $white = imagecolorallocate($img, 255, 255, 255); - - list($imagewidth, $imageheight) = getimagesize($destination_path); - + log_message('ERROR','####faceapi helper to Make FaceBoundingBox image_width'.$imagewidth.'image_height'.$imageheight); for($i=0;$i Date: Mon, 30 May 2022 10:12:35 +0530 Subject: [PATCH 03/10] fixes : ps --- api/application/config/routes.php | 2 +- api/application/controllers/PD_Controller.php | 39 ++++++++++--------- api/application/helpers/faceapi_helper.php | 25 ++++++------ 3 files changed, 35 insertions(+), 31 deletions(-) diff --git a/api/application/config/routes.php b/api/application/config/routes.php index c2c7e0d1..b4619e10 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -373,5 +373,5 @@ $route['deleteCalenderEvent'] = 'PD_Controller/deleteCalenderEvent'; //only deve $route['getSalesPDReportforCETApp'] = 'Sales_PD_Controller/getSalesPDReportforCETApp'; $route['getCreditPDReportforCETApp'] = 'SMC_Credit_PD_Controller/getCreditPDReportforCETApp'; -// $route['faceMarkImage'] = 'PD_Controller/toMakeFaceBoundingBox'; +$route['faceMarkImage'] = 'PD_Controller/toMakeFaceBoundingBox'; diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index c8fe85c4..224505e1 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -989,7 +989,7 @@ class PD_Controller extends REST_Controller { { $pd_details['complete_override_data'] = json_encode($pd_details['complete_override_data']); $pd_details['completed_on'] = date('Y-m-d H:i:s'); - log_message('ERROR',"PD Controller line no : 992 When Completed status means called (to Make FaceBoundingBox)"); + log_message('ERROR',"In PD Controller @ line no : 992 (When Completed status means calling to Make FaceBoundingBox fns below"); $this->toMakeFaceBoundingBox($exist_pd_details); } @@ -11948,11 +11948,12 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() public function toMakeFaceBoundingBox($master_details){ // $pdid = $this->get('pd');//pdid 3184 comment this $pdid = $master_details[0]['pd_id']; - log_message('ERROR',"PD Controller inside to Make FaceBoundingBox PDID : ".$pdid); + log_message('ERROR',"In PD Controller @ line no : 11951 (to Make FaceBoundingBox called ) PDID : ".$pdid); $bounding_box = array(); if(!empty($pdid)){ // $master_details = $this->PD_Model->getPDMasterDetails($pdid);//comment this if($master_details[0]['facemark_image_generated'] == 0){ + log_message('ERROR',"In PD Controller @ line no : 11956 Facemark Image Generated : ".$master_details[0]['facemark_image_generated']); $db_result = $this->PD_Model->selectCustomRecords(array('faceapi_result'),array('pd_id' => $pdid),PDTRIGGER); $string = $db_result[0]['faceapi_result']; // echo gettype($string); @@ -11960,7 +11961,7 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() // echo gettype($my_array); if(!empty($my_array) && !empty($my_array["FaceMatches"])){ $arr = $my_array["FaceMatches"]; - log_message('ERROR',"to Make FaceBoundingBox FaceMatches array cnt : ".count($arr)); + log_message('ERROR',"In PD Controller @ line no : 11964 to Make FaceBoundingBox FaceMatches array cnt : ".count($arr)); for($i=0;$iaws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes'); - log_message('ERROR',"to Make FaceBoundingBox FaceMatches singed_uri : ".$singed_uri); + log_message('ERROR',"In PD Controller @ line no : 11973 to Make FaceBoundingBox FaceMatches singed_uri : ".$singed_uri); // $temp_image_name = "sample.png"; $temp_image_name = "face_api_image.jpeg"; @@ -11986,35 +11987,37 @@ public function getCompaniesListsFromGeneralFormRawJSONV2_post() $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile); $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); - log_message('ERROR',"to Make FaceBoundingBox s3result : ".$s3result['@metadata']['statusCode']); + log_message('ERROR',"In PD Controller @ line no : 11990 to Make FaceBoundingBox FaceMatches s3result : ".$s3result['@metadata']['statusCode']); // print_r($s3result);die(); if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { - log_message('ERROR',"to Make FaceBoundingBox updating pdtrigger table facemark_image_generated as 1"); + log_message('ERROR',"In PD Controller @ line no : 11996 to Make FaceBoundingBox updating pdtrigger table facemark_image_generated as 1"); //Update $this->db->WHERE('pd_id',$pdid)->UPDATE(PDTRIGGER,array('facemark_image_generated' => 1)); - log_message('ERROR',"save document table face_api_result_image after unlink"); + log_message('ERROR',"In PD Controller @ line no : 11998 to Make FaceBoundingBox save document table face_api_result_image after unlink"); $record_data = array('fk_pd_id' => $pdid,'pd_document_title'=>'face_api_result_image','pd_document_name'=>$temp_image_name); $this->PD_Model->saveRecords($record_data,PDDOCUMENTS); unlink($destination_path); } // $data['dataStatus'] = true; // $data['status'] = REST_Controller::HTTP_OK; - // $data['msg'] = 'Given PDID '; + // $data['msg'] = 'Success '; // $data['details'] = $bounding_box; } - // else{ - // $data['dataStatus'] = false; - // $data['status'] = REST_Controller::HTTP_NO_CONTENT; - // $data['msg'] = 'Given PDID is Not in Completed Status'; - // } + else{ + log_message('ERROR',"In PD Controller @ line no : 12009 to Make FaceBoundingBox Faceapi Image Already Generated"); + // $data['dataStatus'] = false; + // $data['status'] = REST_Controller::HTTP_NO_CONTENT; + // $data['msg'] = 'Faceapi Image Already Generated'; + } + } + else{ + log_message('ERROR',"In PD Controller @ line no : 12016 to Make FaceBoundingBox PDID is Not Available"); + // $data['dataStatus'] = false; + // $data['status'] = REST_Controller::HTTP_NO_CONTENT; + // $data['msg'] = 'PDID is Not Available'; } - // else{ - // $data['dataStatus'] = false; - // $data['status'] = REST_Controller::HTTP_NO_CONTENT; - // $data['msg'] = 'PDID is Not Available'; - // } // $this->response($data,REST_Controller::HTTP_OK); } diff --git a/api/application/helpers/faceapi_helper.php b/api/application/helpers/faceapi_helper.php index 787fadeb..a2c86b62 100644 --- a/api/application/helpers/faceapi_helper.php +++ b/api/application/helpers/faceapi_helper.php @@ -3,26 +3,26 @@ class faceapi { public static function toMakeFaceBoundingBox($image_name,$BoundingBox,$destination_path){ - log_message('ERROR','####faceapi helper to Make FaceBoundingBox fns'); + log_message('ERROR',"In faceapi helper @ line no : 6 to Make FaceBoundingBox"); $get_image_format = explode(".",$image_name); $image_format = $get_image_format[1]; - log_message('ERROR','####faceapi helper to Make FaceBoundingBox image_format'.$image_format); + log_message('ERROR','In faceapi helper @ line no : 9 to Make FaceBoundingBox image_format :'.$image_format); // print_r($get_image_format);die(); - // $img = imagecreatefrompng($destination_path); - if($image_format == 'png'){ - $img = imagecreatefrompng($destination_path); - }else if($image_format == 'jpeg'){ - $img = imagecreatefromjpeg($destination_path); - }else if($image_format == 'jpg'){ - $img = imagecreatefromjpg($destination_path); - } + $img = imagecreatefrompng($destination_path); + // if($image_format == 'png'){ + // $img = imagecreatefrompng($destination_path); + // }else if($image_format == 'jpeg'){ + // $img = imagecreatefromjpeg($destination_path); + // }else if($image_format == 'jpg'){ + // $img = imagecreatefromjpg($destination_path); + // } $red = imagecolorallocate($img, 255, 0, 0); $black = imagecolorallocate($img, 0, 0, 0); $white = imagecolorallocate($img, 255, 255, 255); list($imagewidth, $imageheight) = getimagesize($destination_path); - log_message('ERROR','####faceapi helper to Make FaceBoundingBox image_width'.$imagewidth.'image_height'.$imageheight); + log_message('ERROR','In faceapi helper @ line no : 25 to Make FaceBoundingBox image_width'.$imagewidth.'image_height'.$imageheight); for($i=0;$i Date: Tue, 31 May 2022 16:28:49 +0000 Subject: [PATCH 04/10] faceapi_helper.php edited online with Bitbucket --- api/application/helpers/faceapi_helper.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/api/application/helpers/faceapi_helper.php b/api/application/helpers/faceapi_helper.php index a2c86b62..8b884915 100644 --- a/api/application/helpers/faceapi_helper.php +++ b/api/application/helpers/faceapi_helper.php @@ -51,6 +51,7 @@ class faceapi }else if($Similarity_value < 70 ){// below 70 red $color = imagecolorallocate($img, 255, 0, 0); } + $white = imagecolorallocate($img, 255, 255, 255); log_message('ERROR','In faceapi helper @ line no : 45 Draw Line color : '.$color); $Similarity = $Similarity_value." %"; //TOP LINe @@ -71,9 +72,12 @@ class faceapi $imgl = self::imagelinethick($img,$t_x2,$t_y2,$b_x2,$b_y2,$color,7);//right line // apppath / doc la roboto.tff $font = APPPATH."docs/roboto.ttf"; - imagettftext($img, 20, 0, ($t_x1), ($t_y1-5), $color,$font, $Similarity); + // imagettftext($img, 20, 0, ($t_x1), ($t_y1-5), $color,$font, $Similarity); // imagepng($img, $destination_path); // imagepng($img, "face4.png"); + imagefilledrectangle($img, $t_x1-5, $t_y1-18, $t_x1+28, $t_y1, $white); + imagettftext($img, 10, 10, ($t_x1), ($t_y1-5), $color,$font, $Similarity); + $get_image_format = explode(".",$destination_path); $image_format = $get_image_format[1]; From 2fe8fc5a47fc37f03084b6189c8821cb461641f5 Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Sat, 4 Jun 2022 07:38:38 +0000 Subject: [PATCH 05/10] faceapi_helper size increases --- api/application/helpers/faceapi_helper.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api/application/helpers/faceapi_helper.php b/api/application/helpers/faceapi_helper.php index 8b884915..fc28974a 100644 --- a/api/application/helpers/faceapi_helper.php +++ b/api/application/helpers/faceapi_helper.php @@ -75,8 +75,10 @@ class faceapi // imagettftext($img, 20, 0, ($t_x1), ($t_y1-5), $color,$font, $Similarity); // imagepng($img, $destination_path); // imagepng($img, "face4.png"); - imagefilledrectangle($img, $t_x1-5, $t_y1-18, $t_x1+28, $t_y1, $white); - imagettftext($img, 10, 10, ($t_x1), ($t_y1-5), $color,$font, $Similarity); + // imagefilledrectangle($img, $t_x1-5, $t_y1-18, $t_x1+28, $t_y1, $white); + // imagettftext($img, 10, 10, ($t_x1), ($t_y1-5), $color,$font, $Similarity); + imagefilledrectangle($img, $t_x1-5, $t_y1-30, $t_x1+60, $t_y1, $white); + imagettftext($img, 17, 8, ($t_x1), ($t_y1-5), $color,$font, $Similarity); $get_image_format = explode(".",$destination_path); $image_format = $get_image_format[1]; From 20e0a945d88bf01e57c9be4716b323c8d67035d6 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Wed, 8 Jun 2022 13:50:52 +0530 Subject: [PATCH 06/10] Flyhi api : ps --- api/application/config/routes.php | 4 + .../controllers/Flyhi_Controller.php | 92 +++++++++++++++++++ api/application/models/Flyhi_Model.php | 91 ++++++++++++++++++ 3 files changed, 187 insertions(+) create mode 100644 api/application/controllers/Flyhi_Controller.php create mode 100644 api/application/models/Flyhi_Model.php diff --git a/api/application/config/routes.php b/api/application/config/routes.php index b4619e10..eca918e2 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -375,3 +375,7 @@ $route['getCreditPDReportforCETApp'] = 'SMC_Credit_PD_Controller/getCreditPDRep $route['faceMarkImage'] = 'PD_Controller/toMakeFaceBoundingBox'; +$route['saveFlyHiSalesPD'] = 'Flyhi_Controller/saveFlyHiSalesPD'; +$route['listFlyhiSalesPD'] = 'Flyhi_Controller/listFlyhiSalesPD'; + + diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php new file mode 100644 index 00000000..6284890f --- /dev/null +++ b/api/application/controllers/Flyhi_Controller.php @@ -0,0 +1,92 @@ +load->model('Flyhi_Model','Flyhi_Model'); + $this->load->model('Sales_PD_Model','Sales_PD_Model'); + } + + public function listFlyhiSalesPD_get(){ + + $lender_id = $this->uri->segment(2); + $user_id = $this->uri->segment(3); + $role = $this->uri->segment(4); + + $columns = array('SALES_PD_DATA.sales_pd_id','SALES_PD_DATA.sales_pd_sno','SALES_PD_DATA.applicant_name','concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as officer_name','SALES_PD_DATA.applicant_id','SALES_PD_DATA.lender_id','SALES_PD_DATA.product_id','SALES_PD_DATA.is_pdf','SALES_PD_DATA.is_edited','ENTITY.short_name','PRODUCT.abbr','SALES_PD_DATA.status','SALES_PD_DATA.sales_pd_type','SALES_PD_DATA.rand_string','SALES_PD_DATA.isactive','SALES_PD_DATA.city_id','CITY.name as city_name', + '(CASE WHEN SALES_PD_DATA.status = "STARTED" THEN SALES_PD_DATA.createdon WHEN SALES_PD_DATA.status = "COMPLETED" THEN SALES_PD_DATA.completed_date ELSE NULL END) AS createdon'); + $table = SALES_PD_DATA.' as SALES_PD_DATA'; + + $joins = array( + array('table' => ENTITY. ' as ENTITY', + 'condition' =>'SALES_PD_DATA.lender_id = ENTITY.entity_id', + 'jointype' => 'INNER'), + array('table' => PRODUCTS. ' as PRODUCT', + 'condition' =>'SALES_PD_DATA.product_id = PRODUCT.product_id', + 'jointype' => 'INNER'), + array('table' => CITY. ' as CITY', + 'condition' =>'SALES_PD_DATA.city_id = CITY.city_id', + 'jointype' => 'LEFT'), + array('table' => USERPROFILE. ' as USERPROFILE', + 'condition' =>'SALES_PD_DATA.createdby = USERPROFILE.userid', + 'jointype' => 'LEFT') + ); + + $or_where = array(); + $where_condition_array['SALES_PD_DATA.isactive'] = 1; + if(is_numeric($lender_id)) + { + $where_condition_array['SALES_PD_DATA.lender_id'] = $lender_id; + } + + // FILTERING THE LAST 10 DAYS RECORDS + $key_date='SALES_PD_DATA.createdon BETWEEN DATE_SUB(NOW(), INTERVAL 60 DAY) AND NOW()'; + $condition_value=null; + $where_condition_array[$key_date] = $condition_value; + // print_r ($where_condition_array); + // ----END OF FILTERING THE LAST 10 DAYS RECORDS--- + + $MWISELender = (ENVIRONMENT == 'production' ? 7 : 35); + if($role && is_numeric($role) && $role == 11 && $MWISELender == $lender_id){ + // $where_condition_array['SALES_PD_DATA.product_id'] = (ENVIRONMENT == 'production' ? 23 : 22); + }else{ + if($role && is_numeric($role) && $role == 15) //if role area sales head the pull all meq cases + { + $where_condition_array['SALES_PD_DATA.product_id'] = (ENVIRONMENT == 'production' ? 23 : 22); + $or_where['SALES_PD_DATA.createdby'] = $user_id; + } + else if($user_id && is_numeric($user_id)) + { + $where_condition_array['SALES_PD_DATA.createdby'] = $user_id; + } + } + $where_condition_array['SALES_PD_DATA.sales_pd_type in (3,4)'] = null; + $order_by = 'SALES_PD_DATA.sales_pd_id'; + $sales_pd_data = $this->Sales_PD_Model->getJoinRecords($columns,$table,$joins,$where_condition_array,$order_by,'DESC','',$or_where); + //print_r($this->db->last_query());die(); + + if(count($sales_pd_data)) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $sales_pd_data; + $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); + } + + + } + +}// Class Ends diff --git a/api/application/models/Flyhi_Model.php b/api/application/models/Flyhi_Model.php new file mode 100644 index 00000000..90ba047f --- /dev/null +++ b/api/application/models/Flyhi_Model.php @@ -0,0 +1,91 @@ +db->SELECT(' SALES_PD_DATA.sales_pd_sno, SALES_PD_DATA.sales_pd_id, SALES_PD_DATA.applicant_name,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as officer_name,SALES_PD_DATA.applicant_id,SALES_PD_DATA.lender_id,SALES_PD_DATA.product_id,SALES_PD_DATA.is_pdf,SALES_PD_DATA.is_edited,ENTITY.short_name,PRODUCTS.abbr, + (CASE WHEN SALES_PD_DATA.status = "STARTED" THEN SALES_PD_DATA.createdon WHEN SALES_PD_DATA.status = "COMPLETED" THEN SALES_PD_DATA.completed_date ELSE NULL END) AS createdon, + DATE_FORMAT(SALES_PD_DATA.createdon, "%Y-%m-%d") as pd_createdon, SALES_PD_DATA.status,SALES_PD_DATA.sales_pd_type,SALES_PD_DATA.rand_string'); + $this->db->from(SALES_PD_DATA.' as SALES_PD_DATA'); + $this->db->join(ENTITY.' as ENTITY','ENTITY.entity_id = SALES_PD_DATA.lender_id','INNER'); + $this->db->join(PRODUCTS.' as PRODUCTS', 'PRODUCTS.product_id = SALES_PD_DATA.product_id','INNER'); + $this->db->join(USERPROFILE.' as USERPROFILE', 'USERPROFILE.userid = SALES_PD_DATA.createdby','INNER'); + if(!empty($pd_status)){ + $this->db->where_in('SALES_PD_DATA.status',$pd_status); + } + if(($pd_from_date != "" || $pd_from_date != null) && ($pd_to_date != "" || $pd_to_date != null)) { + // $this->db->where('SALES_PD_DATA.createdon BETWEEN '. "'$pd_from_date'". ' AND '. "'$pd_to_date'" ); + if($pd_status[0] == "STARTED" ){ + $this->db->where("DATE_FORMAT(SALES_PD_DATA.createdon,'%Y-%m-%d') BETWEEN ". "'$pd_from_date'". ' AND '. "'$pd_to_date'" ); + }else if($pd_status[0] == "COMPLETED" ){ + $this->db->where("DATE_FORMAT(SALES_PD_DATA.completed_date,'%Y-%m-%d') BETWEEN ". "'$pd_from_date'". ' AND '. "'$pd_to_date'" ); + }else{ + $this->db->where("DATE_FORMAT(SALES_PD_DATA.completed_date,'%Y-%m-%d') BETWEEN ". "'$pd_from_date'". ' AND '. "'$pd_to_date'" ); + $this->db->or_where("DATE_FORMAT(SALES_PD_DATA.createdon,'%Y-%m-%d') BETWEEN ". "'$pd_from_date'". ' AND '. "'$pd_to_date'" ); + } + } + else if($pd_from_date != "" && $pd_from_date != null) { + // $this->db->where("DATE_FORMAT(SALES_PD_DATA.createdon,'%Y-%m-%d')",$pd_from_date); + if($pd_status[0] == "STARTED" ){ + $this->db->where("DATE_FORMAT(SALES_PD_DATA.createdon,'%Y-%m-%d')",$pd_from_date); + }else if($pd_status[0] == "COMPLETED" ){ + $this->db->where("DATE_FORMAT(SALES_PD_DATA.completed_date,'%Y-%m-%d')",$pd_from_date); + }else{ + $this->db->where("DATE_FORMAT(SALES_PD_DATA.completed_date,'%Y-%m-%d')",$pd_from_date); + $this->db->or_where("DATE_FORMAT(SALES_PD_DATA.createdon,'%Y-%m-%d')",$pd_from_date); + } + } + else if($pd_to_date != "" && $pd_to_date != null) { + // $this->db->where("DATE_FORMAT(SALES_PD_DATA.createdon,'%Y-%m-%d')",$pd_to_date); + if($pd_status[0] == "STARTED" ){ + $this->db->where("DATE_FORMAT(SALES_PD_DATA.createdon,'%Y-%m-%d')",$pd_to_date); + }else if($pd_status[0] == "COMPLETED" ){ + $this->db->where("DATE_FORMAT(SALES_PD_DATA.completed_date,'%Y-%m-%d')",$pd_to_date); + }else{ + $this->db->where("DATE_FORMAT(SALES_PD_DATA.completed_date,'%Y-%m-%d')",$pd_to_date); + $this->db->or_where("DATE_FORMAT(SALES_PD_DATA.createdon,'%Y-%m-%d')",$pd_to_date); + } + } + if(!empty($pd_products)){ + $this->db->where_in('SALES_PD_DATA.product_id',$pd_products); + } + if(!empty($pd_lender)) { + $this->db->where_in('SALES_PD_DATA.lender_id',$pd_lender); + } + if(!empty($pd_applicant_name)) { + $this->db->like('SALES_PD_DATA.applicant_name',$pd_applicant_name); + } + if(!empty($pd_officer_name)) { + $this->db->like('SALES_PD_DATA.officer_name',$pd_officer_name); + } + + if(!empty($sales_pd_officer_id)) { + $this->db->WHERE('SALES_PD_DATA.createdby',$sales_pd_officer_id); + } + if(!empty($sales_pd_type) && count($sales_pd_type)) { + $this->db->WHERE_IN('SALES_PD_DATA.sales_pd_type',$sales_pd_type); + } + $this->db->WHERE('SALES_PD_DATA.isactive',1); + $this->db->order_by('SALES_PD_DATA.sales_pd_id','desc'); + $this->db->limit(1000,0); + $result = $this->db->get()->result_array(); + // if(ENVIRONMENT == 'development'){echo 'LAST QUERY '. $this->db->last_query();} + //echo $this->db->last_query();die(); + return $result; + } + public function testSaleSection($id){ + $this->db->SELECT('*')->FROM("t_salespd_section_data")->WHERE('sales_pd_id',$id)->WHERE('isactive',1); + $query = $this->db->get(); + return $query->result(); + // $sql = 'insert into sineedgeprod.t_salespd_section_data(sales_pd_id, section_id, status, section_data, createdby, isactive) select sales_pd_id, section_id, status, section_data, createdby, isactive from sineedgeprod.t_salespd_section_data WHERE sales_pd_id = 1768 and section_id = 1 and isactive = 1;'; + // $modified = $this->db->query($sql); + } + +} \ No newline at end of file From a9dc7b6e4ca3eb05e02dd525e4ce38d5e0406c60 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Wed, 8 Jun 2022 17:32:56 +0530 Subject: [PATCH 07/10] flyhi 2 : ps --- api/application/config/routes.php | 4 +- .../controllers/Flyhi_Controller.php | 186 +++++++++++++++--- 2 files changed, 156 insertions(+), 34 deletions(-) diff --git a/api/application/config/routes.php b/api/application/config/routes.php index eca918e2..40efadf7 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -375,7 +375,7 @@ $route['getCreditPDReportforCETApp'] = 'SMC_Credit_PD_Controller/getCreditPDRep $route['faceMarkImage'] = 'PD_Controller/toMakeFaceBoundingBox'; -$route['saveFlyHiSalesPD'] = 'Flyhi_Controller/saveFlyHiSalesPD'; -$route['listFlyhiSalesPD'] = 'Flyhi_Controller/listFlyhiSalesPD'; +$route['saveFlyhiPD'] = 'Flyhi_Controller/saveFlyhiPD'; +$route['listFlyhiPD'] = 'Flyhi_Controller/listFlyhiPD'; diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index 6284890f..575ae5f0 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -13,13 +13,11 @@ class Flyhi_Controller extends REST_Controller { $this->load->model('Sales_PD_Model','Sales_PD_Model'); } - public function listFlyhiSalesPD_get(){ + public function listFlyhiPD_get(){ - $lender_id = $this->uri->segment(2); $user_id = $this->uri->segment(3); - $role = $this->uri->segment(4); - $columns = array('SALES_PD_DATA.sales_pd_id','SALES_PD_DATA.sales_pd_sno','SALES_PD_DATA.applicant_name','concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as officer_name','SALES_PD_DATA.applicant_id','SALES_PD_DATA.lender_id','SALES_PD_DATA.product_id','SALES_PD_DATA.is_pdf','SALES_PD_DATA.is_edited','ENTITY.short_name','PRODUCT.abbr','SALES_PD_DATA.status','SALES_PD_DATA.sales_pd_type','SALES_PD_DATA.rand_string','SALES_PD_DATA.isactive','SALES_PD_DATA.city_id','CITY.name as city_name', + $columns = array('SALES_PD_DATA.sales_pd_id','SALES_PD_DATA.sales_pd_sno','SALES_PD_DATA.applicant_name','concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as officer_name','SALES_PD_DATA.applicant_id','SALES_PD_DATA.lender_id','SALES_PD_DATA.is_pdf','SALES_PD_DATA.is_edited','ENTITY.full_name','ENTITY.short_name','SALES_PD_DATA.status','SALES_PD_DATA.sales_pd_type','SALES_PD_DATA.rand_string','SALES_PD_DATA.isactive','SALES_PD_DATA.city_id','CITY.name as city_name', '(CASE WHEN SALES_PD_DATA.status = "STARTED" THEN SALES_PD_DATA.createdon WHEN SALES_PD_DATA.status = "COMPLETED" THEN SALES_PD_DATA.completed_date ELSE NULL END) AS createdon'); $table = SALES_PD_DATA.' as SALES_PD_DATA'; @@ -27,9 +25,6 @@ class Flyhi_Controller extends REST_Controller { array('table' => ENTITY. ' as ENTITY', 'condition' =>'SALES_PD_DATA.lender_id = ENTITY.entity_id', 'jointype' => 'INNER'), - array('table' => PRODUCTS. ' as PRODUCT', - 'condition' =>'SALES_PD_DATA.product_id = PRODUCT.product_id', - 'jointype' => 'INNER'), array('table' => CITY. ' as CITY', 'condition' =>'SALES_PD_DATA.city_id = CITY.city_id', 'jointype' => 'LEFT'), @@ -40,53 +35,180 @@ class Flyhi_Controller extends REST_Controller { $or_where = array(); $where_condition_array['SALES_PD_DATA.isactive'] = 1; - if(is_numeric($lender_id)) - { - $where_condition_array['SALES_PD_DATA.lender_id'] = $lender_id; - } // FILTERING THE LAST 10 DAYS RECORDS $key_date='SALES_PD_DATA.createdon BETWEEN DATE_SUB(NOW(), INTERVAL 60 DAY) AND NOW()'; $condition_value=null; $where_condition_array[$key_date] = $condition_value; - // print_r ($where_condition_array); // ----END OF FILTERING THE LAST 10 DAYS RECORDS--- - $MWISELender = (ENVIRONMENT == 'production' ? 7 : 35); - if($role && is_numeric($role) && $role == 11 && $MWISELender == $lender_id){ - // $where_condition_array['SALES_PD_DATA.product_id'] = (ENVIRONMENT == 'production' ? 23 : 22); - }else{ - if($role && is_numeric($role) && $role == 15) //if role area sales head the pull all meq cases - { - $where_condition_array['SALES_PD_DATA.product_id'] = (ENVIRONMENT == 'production' ? 23 : 22); - $or_where['SALES_PD_DATA.createdby'] = $user_id; - } - else if($user_id && is_numeric($user_id)) - { - $where_condition_array['SALES_PD_DATA.createdby'] = $user_id; - } - } + $FHFSL_lender = (ENVIRONMENT == 'production' ? 0 : 49); + if($user_id && is_numeric($user_id)) + { $where_condition_array['SALES_PD_DATA.createdby'] = $user_id; } + $where_condition_array['SALES_PD_DATA.sales_pd_type in (3,4)'] = null; $order_by = 'SALES_PD_DATA.sales_pd_id'; - $sales_pd_data = $this->Sales_PD_Model->getJoinRecords($columns,$table,$joins,$where_condition_array,$order_by,'DESC','',$or_where); + + $Flyhi_pd_data = $this->Flyhi_Model->getJoinRecords($columns,$table,$joins,$where_condition_array,$order_by,'DESC','',$or_where); //print_r($this->db->last_query());die(); - if(count($sales_pd_data)) + if(count($Flyhi_pd_data)) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $sales_pd_data; + $data['records'] = $Flyhi_pd_data; $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'; + $data['msg'] = 'FlyHI PD Data Not Found! Try Later'; $this->response($data,REST_Controller::HTTP_OK); } - - } + public function saveFlyhiPD_post() + { + $records = $this->post('records'); + $is_entry_done = null; + $id = null; + + log_message('ERROR','####FLYHI-PD SAVE CALLED'); + $lender_short_name = $this->Flyhi_Model->selectCustomRecords(array('short_name'),array('entity_id' => $records['lender_id']),ENTITY); + + // $section_names = array('1' => 'General Section','2' => 'Photography'); + $section_names = array('1' => 'General Section'); + + // here i get the counts. + $count = $this->Flyhi_Model->selectCustomRecords(array('count(*) as count'),array('lender_id' => $records['lender_id'],'isactive' => 1),SALES_PD_DATA); + + // If Condition inserting Data in Master Table + if($records['sales_pd_id'] == '' || $records['sales_pd_id'] == null) + { + + /************ASSIGN Random URL******************/ + $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-'; + $charactersLength = strlen($characters); + $randomString = ''; + for ($i = 0; $i < 16; $i++) + { + $randomString .= $characters[rand(0, $charactersLength - 1)]; + } + $records['rand_string'] = $randomString; + log_message('ERROR','####INSERT NEW FLYHIPD'); + $salepd_serial_no .= 'FHFSL-'.(++$count[0]['count']); + + $records['sales_pd_sno'] = $salepd_serial_no; + // print_r($records);die(); + $id = $this->Flyhi_Model->saveRecords($records,SALES_PD_DATA); + + //start camunda process + //CAMUNDA::startSalesPDInstance($id); + } + else + { + if(isset($records['status']) && $records['status'] == 'COMPLETED') + { + log_message('ERROR','####COMPLETE FLYHI-PD'.$records['sales_pd_id']); + $drafted_sections = $this->Flyhi_Model->selectCustomRecords(array('section_id'),array('status' => 0,'sales_pd_id' => $records['sales_pd_id'],'isactive' => 1),SALESPD_SECTION_DATA); + $completed_sections = $this->Flyhi_Model->selectCustomRecords(array('section_id'),array('status' => 1,'sales_pd_id' => $records['sales_pd_id'],'isactive' => 1),SALESPD_SECTION_DATA); + // print_r($completed_sections);die(); + + $dup_of_section_names = $section_names; + // print_r($dup_of_section_names); + foreach ($completed_sections as $completed_section_key => $completed_section_value) + { + if($dup_of_section_names [ $completed_section_value['section_id'] ] ) + { + unset($dup_of_section_names [ $completed_section_value['section_id'] ]); + } + } + + unset($dup_of_section_names[9]);//unset photograph always + + if(count($dup_of_section_names)) + { + $res_data = array(); + foreach ($dup_of_section_names as $key => $value) + { + $res_data[] = array('section_id' => $key,'sectin_name' => $section_names[$key]); + } + $data['dataStatus'] = true; + $data['records'] = $res_data; + $data['pd_status'] = 'DRAFT'; + $data['status'] = REST_Controller::HTTP_OK; + $this->response($data,REST_Controller::HTTP_OK); + } + + + + if(count($drafted_sections) ) + { + + + + $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); + + unset($records['status']); + $data['dataStatus'] = true; + $data['records'] = $drafted_sections; + $data['pd_status'] = 'DRAFT'; + $data['status'] = REST_Controller::HTTP_OK; + $this->response($data,REST_Controller::HTTP_OK); + } + + + + else + { + $records['status'] = 'COMPLETED'; + $records['is_cus_link_disabled'] = 1; + $records['completed_date'] = date('Y-m-d H:i:s'); + $id = $this->Flyhi_Model->updateRecords($records,SALES_PD_DATA,array('sales_pd_id' => $records['sales_pd_id'])); + $city = ''; + $form = $this->Flyhi_Model->selectCustomRecords(array(),array('isactive' => 1,'sales_pd_id' => $records['sales_pd_id'],'section_id' => 1,'status' => 1),SALESPD_SECTION_DATA); + $gen_form = json_decode($form[0]['section_data'],true); + if(!empty($gen_form)){ + foreach ($gen_form['questions'] as $g_key => $g_value) + { + + if($g_value['question_key'] == 'city') + { + $city = $g_value['answer_value']; + } + } + }//gen_form closed here. + } + + } + else + { + log_message('ERROR','####UPDATE FLYHIPD'.$records['sales_pd_id']); + $id = $this->Flyhi_Model->updateRecords($records,SALES_PD_DATA,array('sales_pd_id' => $records['sales_pd_id'])); + + } + + } + + if($id) + { + $data['dataStatus'] = true; + $data['records'] = $id; + $data['status'] = REST_Controller::HTTP_OK; + if(isset($records['rand_string'])){ $data['rand_string'] = $records['rand_string']; } + $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); + } + } }// Class Ends From efd0eb7e517e00b68541a5553abc12e6d37cc034 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Thu, 9 Jun 2022 18:21:08 +0530 Subject: [PATCH 08/10] Save flyhi : ps --- .../controllers/Flyhi_Controller.php | 262 +++++++++++------- 1 file changed, 155 insertions(+), 107 deletions(-) diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index 575ae5f0..bd1c2d49 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -15,9 +15,12 @@ class Flyhi_Controller extends REST_Controller { public function listFlyhiPD_get(){ - $user_id = $this->uri->segment(3); + $user_id = $this->uri->segment(1); $columns = array('SALES_PD_DATA.sales_pd_id','SALES_PD_DATA.sales_pd_sno','SALES_PD_DATA.applicant_name','concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as officer_name','SALES_PD_DATA.applicant_id','SALES_PD_DATA.lender_id','SALES_PD_DATA.is_pdf','SALES_PD_DATA.is_edited','ENTITY.full_name','ENTITY.short_name','SALES_PD_DATA.status','SALES_PD_DATA.sales_pd_type','SALES_PD_DATA.rand_string','SALES_PD_DATA.isactive','SALES_PD_DATA.city_id','CITY.name as city_name', + 'SALES_PD_DATA.lender_sales_person','concat(LENDERSALESPERSON.first_name," ",LENDERSALESPERSON.last_name) as lender_sales_person_name','LENDERSALESPERSON.mobile_no as lender_sales_contact_mobileno','LENDERSALESPERSON.email as lender_sales_person_email', + 'SALES_PD_DATA.lender_credit_person','concat(LENDERCREDITPERSON.first_name," ",LENDERCREDITPERSON.last_name) as lender_credit_person_name','LENDERCREDITPERSON.mobile_no as lender_credit_person_contact_mobileno','LENDERCREDITPERSON.email as lender_credit_person_email', + 'SALES_PD_DATA.pd_branch_id,ENTITYLENDERBRANCH.branch_name','SALES_PD_DATA.loan_amount', '(CASE WHEN SALES_PD_DATA.status = "STARTED" THEN SALES_PD_DATA.createdon WHEN SALES_PD_DATA.status = "COMPLETED" THEN SALES_PD_DATA.completed_date ELSE NULL END) AS createdon'); $table = SALES_PD_DATA.' as SALES_PD_DATA'; @@ -30,6 +33,15 @@ class Flyhi_Controller extends REST_Controller { 'jointype' => 'LEFT'), array('table' => USERPROFILE. ' as USERPROFILE', 'condition' =>'SALES_PD_DATA.createdby = USERPROFILE.userid', + 'jointype' => 'LEFT'), + array('table' => USERPROFILE. ' as LENDERSALESPERSON', + 'condition' =>'SALES_PD_DATA.lender_sales_person = LENDERSALESPERSON.userid', + 'jointype' => 'LEFT'), + array('table' => USERPROFILE. ' as LENDERCREDITPERSON', + 'condition' =>'SALES_PD_DATA.lender_credit_person = LENDERCREDITPERSON.userid', + 'jointype' => 'LEFT'), + array('table' => ENTITYLENDERBRANCH. ' as ENTITYLENDERBRANCH', + 'condition' =>'SALES_PD_DATA.pd_branch_id = ENTITYLENDERBRANCH.entity_lender_branch_id', 'jointype' => 'LEFT') ); @@ -70,24 +82,29 @@ class Flyhi_Controller extends REST_Controller { public function saveFlyhiPD_post() { - $records = $this->post('records'); - $is_entry_done = null; - $id = null; - - log_message('ERROR','####FLYHI-PD SAVE CALLED'); - $lender_short_name = $this->Flyhi_Model->selectCustomRecords(array('short_name'),array('entity_id' => $records['lender_id']),ENTITY); + $records = $this->post('records'); + $is_entry_done = null; + $flyhi_pd_id = null; + $section_data = json_encode($records); + $fk_createdby = $records['fk_createdby']; + $applicant_id = null; + $applicant_name = null; + $city = null; + $lender_id = null; + $loan_amount = null; + $pd_branch_id = null; + $lender_sales_person = null; + $lender_credit_person = null; - // $section_names = array('1' => 'General Section','2' => 'Photography'); - $section_names = array('1' => 'General Section'); + log_message('ERROR','####FLYHI-PD SAVE CALLED'); + + // $section_names = array('1' => 'General Section','2' => 'Photography'); + $section_names = array('1' => 'General Section'); - // here i get the counts. - $count = $this->Flyhi_Model->selectCustomRecords(array('count(*) as count'),array('lender_id' => $records['lender_id'],'isactive' => 1),SALES_PD_DATA); + if($records['sales_pd_id'] == '' || $records['sales_pd_id'] == null) + { - // If Condition inserting Data in Master Table - if($records['sales_pd_id'] == '' || $records['sales_pd_id'] == null) - { - - /************ASSIGN Random URL******************/ + /************ASSIGN Random URL******************/ $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-'; $charactersLength = strlen($characters); $randomString = ''; @@ -95,110 +112,141 @@ class Flyhi_Controller extends REST_Controller { { $randomString .= $characters[rand(0, $charactersLength - 1)]; } + $records['rand_string'] = $randomString; log_message('ERROR','####INSERT NEW FLYHIPD'); - $salepd_serial_no .= 'FHFSL-'.(++$count[0]['count']); - - $records['sales_pd_sno'] = $salepd_serial_no; - // print_r($records);die(); - $id = $this->Flyhi_Model->saveRecords($records,SALES_PD_DATA); - - //start camunda process - //CAMUNDA::startSalesPDInstance($id); - } - else - { + if($records['questions']) + { + foreach ($records['questions'] as $g_key => $g_value) + { + if($g_value['question_key'] == 'application_id') + { + $applicant_id = $g_value['answer_value'] ? $g_value['answer_value'] : 'Not Provided'; + } + if($g_value['question_key'] == 'company_name') + { + $applicant_name = $g_value['answer_value']; + } + if($g_value['question_key'] == 'city') + { + $city = $g_value['answer_value']; + } + if($g_value['question_key'] == 'lender_id') + { + $lender_id = $g_value['answer_value']; + } + if($g_value['question_key'] == 'loan_amount') + { + $loan_amount = $g_value['answer_value']; + } + if($g_value['question_key'] == 'pd_branch_id') + { + $pd_branch_id = $g_value['answer_value']; + } + if($g_value['question_key'] == 'lender_sales_person') + { + $lender_sales_person = $g_value['answer_value']; + } + if($g_value['question_key'] == 'lender_credit_person') + { + $lender_credit_person = $g_value['answer_value']; + } + + } + } + $count = $this->Flyhi_Model->selectCustomRecords(array('count(*) as count'),array('lender_id' => $lender_id,'isactive' => 1),SALES_PD_DATA); + $lender_short_name = $this->Flyhi_Model->selectCustomRecords(array('short_name'),array('entity_id' => $lender_id),ENTITY); + $salepd_serial_no = 'FHFSL-'.(++$count[0]['count']); + + $FLYHI_PD['applicant_id'] = $applicant_id; + $FLYHI_PD['city_id']=$city; + $FLYHI_PD['sales_pd_sno'] = $salepd_serial_no; + $FLYHI_PD['loan_amount'] = $loan_amount; + $FLYHI_PD['lender_sales_person'] = $lender_sales_person ; + $FLYHI_PD['lender_credit_person'] = $lender_credit_person ; + $FLYHI_PD['pd_branch_id'] = $pd_branch_id; + $FLYHI_PD['lender_id'] = $lender_id; + $flyhi_pd_id = $this->Flyhi_Model->saveRecords($FLYHI_PD,SALES_PD_DATA); + $section_data = json_encode($records); + $this->Sales_PD_Model->updateRecords(array('isactive' => 0),SALESPD_SECTION_DATA,array('sales_pd_id' =>$flyhi_pd_id,'section_id' => 1 )); + $status = $records['is_complete']; + $fields = array('sales_pd_id' => $flyhi_pd_id, 'section_id' => 1, 'status' =>$status ,'section_data' => $section_data,'createdby' => $fk_createdby); + $is_entry_done = $this->Sales_PD_Model->saveRecords($fields,SALESPD_SECTION_DATA); + } + + else + { if(isset($records['status']) && $records['status'] == 'COMPLETED') { log_message('ERROR','####COMPLETE FLYHI-PD'.$records['sales_pd_id']); - $drafted_sections = $this->Flyhi_Model->selectCustomRecords(array('section_id'),array('status' => 0,'sales_pd_id' => $records['sales_pd_id'],'isactive' => 1),SALESPD_SECTION_DATA); + $records['status'] = 'COMPLETED'; + $records['is_cus_link_disabled'] = 1; + $records['completed_date'] = date('Y-m-d H:i:s'); + $flyhi_pd_id = $this->Flyhi_Model->updateRecords($records,SALES_PD_DATA,array('sales_pd_id' => $records['sales_pd_id'])); $completed_sections = $this->Flyhi_Model->selectCustomRecords(array('section_id'),array('status' => 1,'sales_pd_id' => $records['sales_pd_id'],'isactive' => 1),SALESPD_SECTION_DATA); - // print_r($completed_sections);die(); - - $dup_of_section_names = $section_names; - // print_r($dup_of_section_names); - foreach ($completed_sections as $completed_section_key => $completed_section_value) - { - if($dup_of_section_names [ $completed_section_value['section_id'] ] ) - { - unset($dup_of_section_names [ $completed_section_value['section_id'] ]); - } - } - - unset($dup_of_section_names[9]);//unset photograph always - - if(count($dup_of_section_names)) - { - $res_data = array(); - foreach ($dup_of_section_names as $key => $value) - { - $res_data[] = array('section_id' => $key,'sectin_name' => $section_names[$key]); - } - $data['dataStatus'] = true; - $data['records'] = $res_data; - $data['pd_status'] = 'DRAFT'; - $data['status'] = REST_Controller::HTTP_OK; - $this->response($data,REST_Controller::HTTP_OK); - } - - - - if(count($drafted_sections) ) - { - - - - $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); - - unset($records['status']); - $data['dataStatus'] = true; - $data['records'] = $drafted_sections; - $data['pd_status'] = 'DRAFT'; - $data['status'] = REST_Controller::HTTP_OK; - $this->response($data,REST_Controller::HTTP_OK); - } - - - - else - { - $records['status'] = 'COMPLETED'; - $records['is_cus_link_disabled'] = 1; - $records['completed_date'] = date('Y-m-d H:i:s'); - $id = $this->Flyhi_Model->updateRecords($records,SALES_PD_DATA,array('sales_pd_id' => $records['sales_pd_id'])); - $city = ''; - $form = $this->Flyhi_Model->selectCustomRecords(array(),array('isactive' => 1,'sales_pd_id' => $records['sales_pd_id'],'section_id' => 1,'status' => 1),SALESPD_SECTION_DATA); - $gen_form = json_decode($form[0]['section_data'],true); - if(!empty($gen_form)){ - foreach ($gen_form['questions'] as $g_key => $g_value) - { - - if($g_value['question_key'] == 'city') - { - $city = $g_value['answer_value']; - } - } - }//gen_form closed here. - } - } else { + log_message('ERROR','####UPDATE FLYHIPD'.$records['sales_pd_id']); - $id = $this->Flyhi_Model->updateRecords($records,SALES_PD_DATA,array('sales_pd_id' => $records['sales_pd_id'])); + // $gen_form = json_decode($form[0]['section_data'],true); + $flyhi_pd_id = $records['sales_pd_id']; - } - - } - - if($id) + if($records['questions']){ + foreach ($records['questions'] as $g_key => $g_value) + { + if($g_value['question_key'] == 'application_id') + { + $applicant_id = $g_value['answer_value'] ? $g_value['answer_value'] : 'Not Provided'; + } + if($g_value['question_key'] == 'company_name') + { + $applicant_name = $g_value['answer_value']; + } + if($g_value['question_key'] == 'city') + { + $city = $g_value['answer_value']; + } + if($g_value['question_key'] == 'lender_id') + { + $lender_id = $g_value['answer_value']; + } + if($g_value['question_key'] == 'loan_amount') + { + $loan_amount = $g_value['answer_value']; + } + if($g_value['question_key'] == 'pd_branch_id') + { + $pd_branch_id = $g_value['answer_value']; + } + if($g_value['question_key'] == 'lender_sales_person') + { + $lender_sales_person = $g_value['answer_value']; + } + if($g_value['question_key'] == 'lender_credit_person') + { + $lender_credit_person = $g_value['answer_value']; + } + } + } + $FLYHI_PD['applicant_name'] = $applicant_name; + $FLYHI_PD['applicant_id'] = $applicant_id; + $FLYHI_PD['city_id']=$city; + $FLYHI_PD['loan_amount'] = $loan_amount; + $FLYHI_PD['lender_sales_person'] = $lender_sales_person ; + $FLYHI_PD['lender_credit_person'] = $lender_credit_person ; + $FLYHI_PD['pd_branch_id'] = $pd_branch_id; + $FLYHI_PD['lender_id'] = $lender_id; + $flyhi_pd_id = $this->Flyhi_Model->updateRecords($FLYHI_PD,SALES_PD_DATA,array('sales_pd_id' => $records['sales_pd_id'])); + $status = $records['is_complete']; + $fields = array('sales_pd_id' => $flyhi_pd_id, 'section_id' => 1, 'status' =>$status ,'section_data' => $section_data,'createdby' => $fk_createdby); + $is_entry_done = $this->Sales_PD_Model->saveRecords($fields,SALESPD_SECTION_DATA); + } // else 179 + } // else 167 + if($flyhi_pd_id) { $data['dataStatus'] = true; - $data['records'] = $id; + $data['records'] = $flyhi_pd_id; $data['status'] = REST_Controller::HTTP_OK; if(isset($records['rand_string'])){ $data['rand_string'] = $records['rand_string']; } $this->response($data,REST_Controller::HTTP_OK); From 5f33b2653e18cb1d6e44240b93f91dc61ffe113e Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Thu, 9 Jun 2022 18:40:05 +0530 Subject: [PATCH 09/10] get flyhi : ps --- api/application/config/routes.php | 2 ++ .../controllers/Flyhi_Controller.php | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 40efadf7..18e306aa 100755 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -377,5 +377,7 @@ $route['faceMarkImage'] = 'PD_Controller/toMakeFaceBoundingBox'; $route['saveFlyhiPD'] = 'Flyhi_Controller/saveFlyhiPD'; $route['listFlyhiPD'] = 'Flyhi_Controller/listFlyhiPD'; +$route['listFlyhiSalesPD'] = 'Flyhi_Controller/listFlyhiPD'; +$route['getFlyhiPD'] = 'Flyhi_Controller/getFlyhiPD'; diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index bd1c2d49..6ae7ffde 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -259,4 +259,28 @@ class Flyhi_Controller extends REST_Controller { $this->response($data,REST_Controller::HTTP_OK); } } + + public function getFlyhiPD_get() + { + $Flyhi_pdid = $this->get('sales_pd_id'); + $section_data = array(); + if(isset($Flyhi_pdid) || $Flyhi_pdid != "" || $Flyhi_pdid != null) + { + $section_data = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $Flyhi_pdid,'isactive' => 1,'section_id' => 1),SALESPD_SECTION_DATA); + } + 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); + } + } }// Class Ends From d2ba78ecb5cdb7f09a70b1ac9729b609ab604cce Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Thu, 9 Jun 2022 19:29:25 +0530 Subject: [PATCH 10/10] flyhi : ps --- api/application/controllers/Flyhi_Controller.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index 6ae7ffde..a79f6ad7 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -156,16 +156,18 @@ class Flyhi_Controller extends REST_Controller { } $count = $this->Flyhi_Model->selectCustomRecords(array('count(*) as count'),array('lender_id' => $lender_id,'isactive' => 1),SALES_PD_DATA); $lender_short_name = $this->Flyhi_Model->selectCustomRecords(array('short_name'),array('entity_id' => $lender_id),ENTITY); - $salepd_serial_no = 'FHFSL-'.(++$count[0]['count']); - + $flyhipd_serial_no = $lender_short_name.'-'.(++$count[0]['count']); + $FLYHI_PD['applicant_name'] = $applicant_name; $FLYHI_PD['applicant_id'] = $applicant_id; $FLYHI_PD['city_id']=$city; - $FLYHI_PD['sales_pd_sno'] = $salepd_serial_no; + $FLYHI_PD['sales_pd_sno'] = $flyhipd_serial_no; $FLYHI_PD['loan_amount'] = $loan_amount; $FLYHI_PD['lender_sales_person'] = $lender_sales_person ; $FLYHI_PD['lender_credit_person'] = $lender_credit_person ; $FLYHI_PD['pd_branch_id'] = $pd_branch_id; $FLYHI_PD['lender_id'] = $lender_id; + $FLYHI_PD['createdby'] = $fk_createdby; + $FLYHI_PD['rand_string'] = $randomString; $flyhi_pd_id = $this->Flyhi_Model->saveRecords($FLYHI_PD,SALES_PD_DATA); $section_data = json_encode($records); $this->Sales_PD_Model->updateRecords(array('isactive' => 0),SALESPD_SECTION_DATA,array('sales_pd_id' =>$flyhi_pd_id,'section_id' => 1 )); @@ -237,7 +239,7 @@ class Flyhi_Controller extends REST_Controller { $FLYHI_PD['lender_credit_person'] = $lender_credit_person ; $FLYHI_PD['pd_branch_id'] = $pd_branch_id; $FLYHI_PD['lender_id'] = $lender_id; - $flyhi_pd_id = $this->Flyhi_Model->updateRecords($FLYHI_PD,SALES_PD_DATA,array('sales_pd_id' => $records['sales_pd_id'])); + $flyhi_pd_id = $this->Flyhi_Model->updateRecords($FLYHI_PD,SALES_PD_DATA,array('sales_pd_id' => $flyhi_pd_id)); $status = $records['is_complete']; $fields = array('sales_pd_id' => $flyhi_pd_id, 'section_id' => 1, 'status' =>$status ,'section_data' => $section_data,'createdby' => $fk_createdby); $is_entry_done = $this->Sales_PD_Model->saveRecords($fields,SALESPD_SECTION_DATA); @@ -262,7 +264,7 @@ class Flyhi_Controller extends REST_Controller { public function getFlyhiPD_get() { - $Flyhi_pdid = $this->get('sales_pd_id'); + $Flyhi_pdid = $this->get('pd_id'); $section_data = array(); if(isset($Flyhi_pdid) || $Flyhi_pdid != "" || $Flyhi_pdid != null) {