SALES PD & SATELLITE SCRIPT CHANGED

This commit is contained in:
Velz2020 2020-01-14 17:42:57 +05:30
parent 051a034175
commit 014d3776d4
6 changed files with 63 additions and 31 deletions

View File

@ -4436,9 +4436,24 @@ public function getPDFormDetailsJSON_post()
//if(isset($overall_summary_report['sales_calculated_by_monthwise']['netprofit'])){ $temp_netmargin_array = array_merge($temp_netmargin_array,array($overall_summary_report['sales_calculated_by_monthwise']['netprofit'])); }
if(isset($overall_summary_report['sales_calculated_by_itemwise']['netprofit'])){ $temp_netmargin_array = array_merge($temp_netmargin_array,array($overall_summary_report['sales_calculated_by_itemwise']['netprofit'])); }
$overall_summary_report['consolidated_report']['consolidated_sales_revenue'] = round(array_sum($temp_sales_array) / count($temp_sales_array));
if(count($temp_sales_array))
{
$overall_summary_report['consolidated_report']['consolidated_sales_revenue'] = round(array_sum($temp_sales_array) / count($temp_sales_array));
}
else
{
$overall_summary_report['consolidated_report']['consolidated_sales_revenue'] = 0.0;
}
$overall_summary_report['consolidated_report']['consolidated_nerprofit'] = round(array_sum($temp_netmargin_array) / count($temp_netmargin_array));
if(count($temp_netmargin_array))
{
$overall_summary_report['consolidated_report']['consolidated_nerprofit'] = round(array_sum($temp_netmargin_array) / count($temp_netmargin_array));
}
else
{
$overall_summary_report['consolidated_report']['consolidated_nerprofit'] = 0.0;
}
if($overall_summary_report['consolidated_report']['consolidated_nerprofit'] != 0 && $overall_summary_report['consolidated_report']['consolidated_sales_revenue'] != 0)
{

View File

@ -188,8 +188,7 @@ class Sales_PD_Controller extends REST_Controller {
{
//$json_data = (json_decode($sales_pd_data[0]['pd_json'],true));
satellite_image::getSatelliteImage($sales_pd_id,2);
$all_section_data = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $sales_pd_id,'isactive' => 1),SALESPD_SECTION_DATA);
// print_r($this->db->last_query());die();
$view_data['master'] = $sales_pd_data;
@ -451,9 +450,12 @@ class Sales_PD_Controller extends REST_Controller {
$update_fields = array('geo_location' => $records['location']);
$this->Sales_PD_Model->updateRecords($update_fields,SALES_PD_DATA,array('sales_pd_id' => $records['fk_sales_pd_id']));
satellite_image::getSatelliteImage($records['fk_sales_pd_id'],2);
//disable previous selfie img
$update_fields2 = array('isactive' => 0);
$this->Sales_PD_Model->updateRecords($update_fields2,SALEPD_DOCS,array('img_name' => 'selfie_with_person_met','fk_sales_pd_id' => $records['fk_sales_pd_id']));
}
$id = $this->Sales_PD_Model->saveRecords($records,SALEPD_DOCS);
@ -561,9 +563,11 @@ class Sales_PD_Controller extends REST_Controller {
{
$records['status'] = 'COMPLETED';
$records['completed_date'] = date('Y-m-d h:i:s');
$id = $this->Sales_PD_Model->updateRecords($records,SALES_PD_DATA,array('sales_pd_id' => $records['sales_pd_id']));
satellite_image::getSatelliteImage($records['sales_pd_id'],2);
$this->prepareSalesPDReport($records['sales_pd_id'],false);
sleep(5);
//trigger mail function
PDALERTS::sendSalesPDMail($this,$records['sales_pd_id']);
}
@ -797,7 +801,10 @@ class Sales_PD_Controller extends REST_Controller {
public function testAPISalesPD_post()
{
PDALERTS::sendSalesPDMail($this,14);die();
//PDALERTS::sendSalesPDMail($this,32);die();
satellite_image::getSatelliteImage(32,2);//die();
// $url = "https://maps.googleapis.com/maps/api/staticmap?center=12.9788141,80.1871334&zoom=14&markers=color:red|12.9788141,80.1871334&size=800x300&maptype=roadmap&key=AIzaSyA3lYDYxwtn5vLSl45SOKbtK7G6cEyXGr0";
// file_put_contents('test.jpg', file_get_contents($url));
}
public function salesPDMisReport_post()

View File

@ -206,7 +206,10 @@ class PDALERTS
self::sendMail($CI,'komalmittal@sinemanagement.com',$msg,$core_details);
self::sendMail($CI,'sinepd@sinemanagement.com',$msg,$core_details);
if($core_details[0]['pd_status'] != 'TRIGGERED')
{
self::sendMail($CI,'sinepd@sinemanagement.com',$msg,$core_details);
}
}

View File

@ -18,41 +18,48 @@ class satellite_image
{
mkdir($path_to_check,0777);
}
$google_map_static_api_key = GOOGLE_STATIC_MAP_API_KEY;
if($pd_type == 1)
{
$pdmas = $CI->PD_Model->getPDMasterDetails($pdid);
$geo_location = $pdmas[0]['start_location'];
// $satellite_script_from_db = $CI->$model_to_load->selectCustomRecords(array('*'),array('script_name' => SATELLITE_IMAGE_LOCATION),SCRIPTS);
// $satellite_script = $satellite_script_from_db[0]['script_content'];
//Replacing Place holders
// $satellite_script = str_replace('{{APPPATH}}',$path_to_check,$satellite_script);
// $satellite_script = str_replace('{{ADDRESS}}',$geo_location,$satellite_script);
// $satellite_script = str_replace('{{GEOLOCATION}}',$geo_location,$satellite_script);
// $satellite_script = str_replace('{{API_KEY}}',$google_map_static_api_key,$satellite_script);
// //echo $satellite_script;die();
// file_put_contents(APPPATH.'/views/js/phantomsatellite.js',$satellite_script);
// //call& execute phantom script
// $str = 'phantomjs '.APPPATH.'/views/js/phantomsatellite.js';
// exec($str,$ou);
// exec('phantom.exit();');
}
else if($pd_type == 2)
{
$pdmas = $CI->Sales_PD_Model->selectCustomRecords(array('geo_location'),array('sales_pd_id' => $pdid),SALES_PD_DATA);
$geo_location = $pdmas[0]['geo_location'];
}
$url = "https://maps.googleapis.com/maps/api/staticmap?center=".$geo_location."&zoom=14&markers=color:red|".$geo_location."&size=800x300&maptype=roadmap&key=".$google_map_static_api_key;
//echo $url;
$ou = file_put_contents($path_to_check.'/satellite.png', file_get_contents($url));
$satellite_script = $url;
$satellite_script_from_db = $CI->$model_to_load->selectCustomRecords(array('*'),array('script_name' => SATELLITE_IMAGE_LOCATION),SCRIPTS);
$satellite_script = $satellite_script_from_db[0]['script_content'];
$google_map_static_api_key = GOOGLE_STATIC_MAP_API_KEY;
//Replacing Place holders
$satellite_script = str_replace('{{APPPATH}}',$path_to_check,$satellite_script);
$satellite_script = str_replace('{{ADDRESS}}',$geo_location,$satellite_script);
$satellite_script = str_replace('{{GEOLOCATION}}',$geo_location,$satellite_script);
$satellite_script = str_replace('{{API_KEY}}',$google_map_static_api_key,$satellite_script);
//echo $satellite_script;die();
file_put_contents(APPPATH.'/views/js/phantomsatellite.js',$satellite_script);
//call& execute phantom script
$str = 'phantomjs '.APPPATH.'/views/js/phantomsatellite.js';
exec($str,$ou);
exec('phantom.exit();');
// //convert as base 64 image.

View File

@ -1122,7 +1122,7 @@ if ( isset($pdf) ) {
echo '<p style="text-align:justify;">';
echo '<span contenteditable="true">The PD visit was done at </span><span class="tooltip">'. $address_type. '<span class="tooltiptext">Address Form - Type of Address </span></span><span contenteditable="true"> of the loan applicants. </span>';
echo '<span contenteditable="true">The </span><span class="tooltip">'.$address_type.'<span class="tooltiptext">Address Form - Type of Address </span></span><span contenteditable="true"> is </span><span class="tooltip">'.$property_owner_type.'<span class="tooltiptext">Business Assest Form - Owner of the Property </span></span><span contenteditable="true"> and the business has been in operation from here for the last</span> <span class="tooltip">'.$yrs_being_run.'<span class="tooltiptext">Business Assest Form - Business running Yrs in this premise </span></span><span contenteditable="true">.</span>';
echo '<br><br><span contenteditable="true">The</span> <span class="tooltip">'.$address_type.'<span class="tooltiptext">Address Form - Type of Address </span></span> <span contenteditable="true">is located in </span><span class="tooltip">'.$locality.'<span class="tooltiptext">Address Form - Locality of Address </span></span> <span contenteditable="true">and the estimated area of the</span> <span class="tooltip">'.$address_type.'<span class="tooltiptext">Address Form - Type of Address </span></span> <span contenteditable="true">is</span> <span class="tooltip">'.$estimated_area.'<span class="tooltiptext">Address Form - Estimated Area </span></span> <span contenteditable="true">.</span>';
echo '<br><br><span contenteditable="true">The</span> <span class="tooltip">'.$address_type.'<span class="tooltiptext">Address Form - Type of Address </span></span> <span contenteditable="true">is located in </span><span class="tooltip">'.$locality.'<span class="tooltiptext">Address Form - Locality of Address </span></span> <span contenteditable="true">'.($estimated_area != 0? 'and the estimated area of the</span> <span class="tooltip">'.$address_type.'<span class="tooltiptext">Address Form - Type of Address </span></span> <span contenteditable="true">is</span> <span class="tooltip">'.$estimated_area.'<span class="tooltiptext">Address Form - Estimated Area </span></span> <span contenteditable="true">.</span>' : '');
echo '<br><br><span contenteditable="true">The PD location was </span><span class="tooltip">'. $pd_address['pd_location_master'].'<span class="tooltiptext">Address Form - Approach to PD location </span></span>. ' . '<span contenteditable="true">As Per PD Officer, the</span> <span class="tooltip">'.$address_type .'<span class="tooltiptext">Address Form - Type of Address </span></span> <span contenteditable="true">is situated in</span><span class="tooltip"> '.$comment_locality_master .'<span class="tooltiptext">Address Form - Comment on locality </span></span> <span contenteditable="true">Locality.</span>';
echo '<br><br><span contenteditable="true">The PD officer also made the following observations:</span>' ;
echo '<br><ul>';

View File

@ -99,7 +99,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
<footer>
<hr>
<img style="width:50px;height:50px;opacity: 0.5;padding-top: 5px;" src='https://pdgenie.com/logo/sineedge_red.png'/> Powered By PDGenie
<img style="width:50px;height:50px;opacity: 0.5;padding-top: 5px;" src='https://pdgenie.com/logo/sineedge_red.png'/> Powered By PD Genie
</footer>
<header>