diff --git a/api/application/config/calendar.php b/api/application/config/calendar.php
new file mode 100644
index 00000000..977d88dd
--- /dev/null
+++ b/api/application/config/calendar.php
@@ -0,0 +1,6 @@
+load->model('GC_Event_Model');
+ }
+
+ public function addEvent_post()
+ {
+ log_message('ERROR','#/# G-Calender-Event Fns Entered');
+ $post = $this->post();
+ $data = array();
+ $valErr = "";
+
+ if(!empty($post)){
+ if(empty($post['title'])){
+ $valErr .= 'event title is Empty.
';
+ }
+ if(empty($post['date'])){
+ $valErr .= 'event date is Empty.
';
+ }
+ $event = array(
+ // 'title' =>$title,
+ 'title' => !empty($post['title'])?trim($post['title']):'Con Call - 1',
+ 'location' => !empty($post['location'])?trim($post['location']):'Perambalur',
+ 'summary' => !empty($post['summary'])?trim($post['summary']):'Google meet link',
+ 'start' => !empty($post['time_from'])?trim($post['time_from']):'10:30',
+ 'end' => !empty($post['time_to'])?trim($post['time_to']):'17:00',
+ 'description' => !empty($post['description'])?trim($post['description']):'Generated By Sanjeev',
+ 'date' => !empty($post['date'])?date_format($date,"Y-m-d"):date('Y-m-d')
+
+ );
+ log_message('ERROR',"GC-Event data : ".json_encode($event));
+ if(empty($valErr)){
+ $event = $this->GC_Event_Model->addEvent($event);
+ if(!empty($event['id'])){
+ log_message('ERROR','GC-Event Created - ID :'.$event);
+ $statusMsg = 'Events created';
+ }else{
+ log_message('ERROR','GC-Event Not Created issues on Insert');
+ $statusMsg = 'Something went wrong, please try again after some time.';
+ }
+ }else{
+ log_message('ERROR','GC-Event Not Created because of mandatory fields - '.trim($valErr, '
'));
+ $statusMsg = '
Please fill all the mandatory fields:
'.trim($valErr, '
');
+ }
+ }else{
+ log_message('ERROR','GC-Event Data Not Available');
+ $statusMsg = 'Data Not Available.';
+ }
+
+ $data['dataStatus'] = true;
+ $data['status'] = REST_Controller::HTTP_OK;
+ $data['msg'] = $statusMsg;
+ $this->response($data,REST_Controller::HTTP_OK);
+ }
+
+ public function eventList_get()
+ {
+ log_message('ERROR','#/# G-Calender-Event List');
+ $get = $this->get();
+
+ if($get){
+
+ $start = $get['start'].' 00:00:00';
+
+ $end = $get['end'].' 23:59:59';
+
+ $data['msg'] = 'Events of between '.$get['start']." and ".$get['end'];
+
+ } else {
+
+ $start = false;
+
+ $end = false;
+
+ $data['msg'] = 'Events of today';
+
+ }
+
+ $data['events'] = $this->GC_Event_Model->getEvents('primary', $start, $end, 40);
+ $data['dataStatus'] = true;
+ $data['status'] = REST_Controller::HTTP_OK;
+ $this->response($data,REST_Controller::HTTP_OK);
+
+ }
+
+}
\ No newline at end of file
diff --git a/api/application/controllers/SMC_Credit_PD_Controller.php b/api/application/controllers/SMC_Credit_PD_Controller.php
index b6e4c24d..5b444ce5 100644
--- a/api/application/controllers/SMC_Credit_PD_Controller.php
+++ b/api/application/controllers/SMC_Credit_PD_Controller.php
@@ -1546,6 +1546,7 @@ public function filterSalesPDList_post() {
// if($value['fk_form_id'] == 2){print_r($value['json']);die();}
$view_data['pd_section_data'][$value['fk_form_id']] = $value['json'];
+ // $CETAPP_creditPD_data[$value['form_name']] = $value['json'];
}
else
{
@@ -1555,6 +1556,7 @@ public function filterSalesPDList_post() {
$data_from_excel = $this->loadDataFromExcelBusiProcess($view_data['pd_master_details'],$value['fk_form_id']);
//print_r($data_from_excel);die();
$view_data['pd_section_data'][$value['fk_form_id']] = $data_from_excel;
+ // $CETAPP_creditPD_data[$value['form_name']] = $data_from_excel;
}
}
@@ -1635,7 +1637,9 @@ public function filterSalesPDList_post() {
}
}
$view_data['pd_section_data'][5]['key_stakeholders'] = $temp_arr;
+ // $CETAPP_creditPD_data['Key Stakeholders in Business']['key_stakeholders'] = $temp_arr;
}// ### LFMP key_stakeholders ends
+ // log_message('ERROR',"SUSEEN".json_encode($CETAPP_creditPD_data));die();
if($view_data['pd_master_details'][0]['product_abbr'] == "NBFC/MFI"){
$html_content = $this->load->view('smc_creditpd_reports/NBFC',$view_data,true);
diff --git a/api/application/controllers/Sales_PD_Controller.php b/api/application/controllers/Sales_PD_Controller.php
index 104b8c6d..11e7195f 100644
--- a/api/application/controllers/Sales_PD_Controller.php
+++ b/api/application/controllers/Sales_PD_Controller.php
@@ -219,11 +219,12 @@ class Sales_PD_Controller extends REST_Controller {
$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(count($view_data['section9'])>0){
for ($i = 0; $i < count($view_data['section9']); $i++){
- $img_fields[0]['img_name'] = $view_data['section9'][$i]['img_name'];
+ $img_fields = $common_fields;
+ $img_fields['img_name'] = $view_data['section9'][$i]['img_name'];
$img_split = explode( ',', $view_data['section9'][$i]['img']);
- $img_fields[0]['img'] = $img_split[1];
+ $img_fields['img'] = $img_split[1];
// $img_fields[0]['img'] = $view_data['section9'][$i]['img'];
- salespd_cetapp::pushwithcetsalespdapi($common_fields,$img_fields,2);
+ salespd_cetapp::pushwithcetphotographapi($img_fields);
}
// "section9":{"selfie_with_person_met":"SAVED","approach_to_pd_location":["SAVED",""],"name_board_seen":["SAVED",""],"stock_image":["SAVED","SAVED","SAVED","SAVED",""],"workplace_interior_image":["SAVED","SAVED",""]}}
// $arr1 =array();$arr2 =array();
@@ -242,13 +243,14 @@ class Sales_PD_Controller extends REST_Controller {
salespd_cetapp::pushwithcetsalespdapi($common_fields,$section_fields,1);
$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);
if(!empty($view_data['satellite_image'])){
- $stt_fields[0]['img_name'] = $view_data['satellite_image'][0]['img_name'];
- $stt_fields[0]['img'] = $view_data['satellite_image'][0]['img'];
- salespd_cetapp::pushwithcetsalespdapi($common_fields,$stt_fields,2);
+ $stt_fields = $common_fields;
+ $stt_fields['img_name'] = $view_data['satellite_image'][0]['img_name'];
+ $stt_fields['img'] = $view_data['satellite_image'][0]['img'];
+ salespd_cetapp::pushwithcetphotographapi($stt_fields);
}
$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();
+ // die();
//$view_name = $sales_pd_data[0]['short_name'].'_'.$sales_pd_data[0]['abbr'];
$view_name = $sales_pd_data[0]['short_name'];if( $sales_pd_data[0]['abbr'] == 'MEQ'){ $view_name = $sales_pd_data[0]['abbr']; }
$html_content = $this->load->view('sale_pd_templates/'.$view_name,$view_data,true);
diff --git a/api/application/helpers/salespd_cetapp_helper.php b/api/application/helpers/salespd_cetapp_helper.php
index c5dd659a..f2ab5720 100644
--- a/api/application/helpers/salespd_cetapp_helper.php
+++ b/api/application/helpers/salespd_cetapp_helper.php
@@ -2,32 +2,37 @@
class SALESPD_CETAPP
{
-
public static function pushwithcetsalespdapi($fields,$data,$flag)
{
log_message('ERROR','#### pushwithcetsalespdapi Helper FNS');
$fields['data'] = $data;
$pdid = $fields['pdid'];
$headers = array('Content-Type: application/json');
- //log_message('ERROR',"Response Format : ".json_encode($fields));
$ch = curl_init();
if($flag == 1){ //sectionurl
$log_msg = "PullSalesPDData api ";
- log_message('ERROR',"Flag 1 ".$log_msg);
$url = 'https://demo.devopsmcfinance.com/cet_salespd/api/PullSalesPdData';
+ $output_data = json_encode( $fields );
}else if($flag == 2){ // imgurl
- $log_msg = "PullSalesPdPhotographsData api ";
- log_message('ERROR',"Flag 2 ".$log_msg);
+ $merged_headers = array_merge($headers,array('Content-Encoding : gzip','Vary: Accept-Encoding'));
$url = 'https://demo.devopsmcfinance.com/cet_salespd/api/PullSalesPdPhotographsData';
- $log_msg = $log_msg."(".$data[0]['img_name'].")";
+ $log_msg = " PullSalesPdPhotographsData api (".$data[0]['img_name'].")";
+ // (gzencode(json_encode($data), 9))
+ $output_data = gzencode(json_encode($fields), 9);
+ }
+ else if($flag == 3){ // imgurl
+ $url = 'https://demo.devopsmcfinance.com/cet_salespd/api/PullSalesPdPhotographsData';
+ $log_msg = " PullSalesPdPhotographsData api (".$data[0]['img_name'].")";
+ $output_data = json_encode( $fields );
}
// print_r($fields);die;
+ log_message('ERROR',"Flag ".$flag.$log_msg." Request Format : ".$output_data);
curl_setopt( $ch,CURLOPT_URL, $url);
curl_setopt( $ch,CURLOPT_POST, true );
- curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
+ curl_setopt( $ch,CURLOPT_HTTPHEADER, $flag == 2 ? $merged_headers : $headers );
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, true );
- curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ));
+ curl_setopt( $ch,CURLOPT_POSTFIELDS, $output_data);
$result = curl_exec($ch );
$response = json_decode($result);
log_message('ERROR',"CET APP PDID (".$pdid.") ".$log_msg." curl result : ".json_encode($result)." response :".json_encode($response));
@@ -40,6 +45,52 @@ class SALESPD_CETAPP
curl_close( $ch );
$CI =&get_instance();
}
+
+ // multipart/form-data;
+ public static function pushwithcetphotographapi($fields)
+ {
+ log_message('ERROR','#### pushwithcetphotographapi Helper FNS');
+ $img = $fields['img'];
+ $pdid = $fields['pdid'];
+ $img = str_replace('data:image/png;base64,', '', $img);
+ $img = str_replace(' ', '+', $img);
+ $data = base64_decode($img);
+ // $file = $CI->external_path.'/tmp/' . uniqid() .'png';
+ // $file = $CI->external_path.'/tmp/' . date('Y-m-d_h:i:s') .'png';
+ // $file = $CI->external_path.'/tmp/temp.png';
+ $file = '/opt/lampp/htdocs/ssa_external_data/testing/tmp/temp.png';
+ // $success = file_put_contents($file, base64_decode($data));
+ $success = file_put_contents($file, $data);
+ if($success){
+ log_message('ERROR',"CET APP PDID (".$pdid.") ".$fields['img_name']." = Successfully Uploaded");
+ }else{
+ log_message('ERROR',"CET APP PDID (".$pdid.") ".$fields['img_name']." = Upload failed");
+ }
+ // unlink($file_name_with_full_path);
+
+ $headers = array('Content-Type: multipart/form-data');
+ // $headers = array('Content-Type: application/json');
+ $ch = curl_init();
+ $url = 'https://demo.devopsmcfinance.com/cet_salespd/api/PullSalesPdPhotographsData';
+ $log_msg = " PullSalesPdPhotographsData api (".$fields['img_name'].")";
+ $fields['img'] = $file;
+ curl_setopt( $ch,CURLOPT_URL, $url);
+ curl_setopt( $ch,CURLOPT_POST, true );
+ curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
+ // curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
+ // curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, true );
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
+ $result=curl_exec ($ch);
+ $response = json_decode($result);
+ log_message('ERROR',"CET APP PDID (".$pdid.") ".$log_msg." curl result : ".json_encode($result)." response :".json_encode($response));
+ // print_r($result);
+ // $file_name_with_full_path = $CI->external_path.'/tmp/'. temp .'.png';
+ curl_close( $ch );
+ unlink($file);
+ $CI =&get_instance();
+ // unlink($file_name_with_full_path);
+
+ }
}
?>
\ No newline at end of file
diff --git a/api/application/libraries/Googleapi.php b/api/application/libraries/Googleapi.php
new file mode 100644
index 00000000..b6bcd9e3
--- /dev/null
+++ b/api/application/libraries/Googleapi.php
@@ -0,0 +1,67 @@
+client = new Google_Client();
+ $this->client->setApplicationName('Learning Gmeet Event in Php');
+ $this->ci =& get_instance();
+ $this->ci->config->load('calendar');
+ $this->client->setClientId($this->ci->config->item('client_id'));
+ $this->client->setClientSecret($this->ci->config->item('client_secret'));
+ // $this->client->setRedirectUri($this->ci->config->base_url().'gc/auth/oauth');
+ $this->client->addScope(Google_Service_Calendar::CALENDAR);
+ $this->client->addScope('profile');
+ }
+
+ public function loginUrl() {
+ return $this->client->createAuthUrl();
+ }
+
+ public function getAuthenticate() {
+ return $this->client->authenticate();
+ }
+
+ public function getAccessToken() {
+ return $this->client->getAccessToken();
+ }
+
+ public function setAccessToken() {
+ return $this->client->setAccessToken();
+ }
+
+ public function revokeToken() {
+ return $this->client->revokeToken();
+ }
+
+ public function client() {
+ return $this->client;
+ }
+
+ public function getUser() {
+ $google_ouath = new Google_Service_Oauth2($this->client);
+ return (object)$google_ouath->userinfo->get();
+ }
+
+ public function isAccessTokenExpired() {
+ return $this->client->isAccessTokenExpired();
+ }
+}
+?>
\ No newline at end of file
diff --git a/api/application/models/GC_Event_Model.php b/api/application/models/GC_Event_Model.php
new file mode 100644
index 00000000..8926ce38
--- /dev/null
+++ b/api/application/models/GC_Event_Model.php
@@ -0,0 +1,122 @@
+load->library('session');
+ $this->load->library('googleplus');
+ $this->calendar = new Google_Service_Calendar($this->googleplus->client());
+
+ }
+
+
+ public function getEvents($calendarId = 'primary', $timeMin = false, $timeMax = false, $maxResults = 10)
+ {
+
+
+ if ( ! $timeMin) {
+
+ $timeMin = date("c", strtotime(date('Y-m-d ').' 00:00:00'));
+
+ } else {
+
+ $timeMin = date("c", strtotime($timeMin));
+
+ }
+
+
+ if ( ! $timeMax) {
+
+ $timeMax = date("c", strtotime(date('Y-m-d ').' 23:59:59'));
+
+ } else {
+
+ $timeMax = date("c", strtotime($timeMax));
+
+ }
+
+
+ $optParams = array(
+ 'maxResults' => $maxResults,
+ 'orderBy' => 'startTime',
+ 'singleEvents' => true,
+ 'timeMin' => $timeMin,
+ 'timeMax' => $timeMax,
+ 'timeZone' => 'Asia/Kolkata',
+
+ );
+
+ $results = $this->googlecalendar->calendar->events->listEvents($calendarId, $optParams);
+
+
+ $data = array();
+
+ foreach ($results->getItems() as $item) {
+
+ $start = date('d-m-Y H:i', strtotime($item->getStart()->dateTime));
+
+ array_push(
+
+ $data,
+ array(
+
+ 'id' => $item->getId(),
+ 'summary' => $item->getSummary(),
+ 'description' => $item->getDescription(),
+ 'creator' => $item->getCreator(),
+ 'start' => $item->getStart()->dateTime,
+ 'end' => $item->getEnd()->dateTime,
+
+
+ )
+
+ );
+
+ }
+
+ return $data;
+
+ }
+
+
+ public function addEvent($calendarId = 'primary', $data)
+ {
+
+
+ //date format is => 2016-06-18T17:00:00+03:00
+
+ $event = new Google_Service_Calendar_Event(
+ array(
+ 'summary' => $data['summary'],
+ 'description' => $data['description'],
+ 'start' => array(
+ 'dateTime' => $data['date'].'T'.$data['start'].':00+05:30',
+ 'timeZone' => 'Asia/Kolkata',
+ ),
+ 'end' => array(
+ 'dateTime' => $data['date'].'T'.$data['end'].':00+05:30',
+ 'timeZone' => 'Asia/Kolkata',
+ ),
+ 'attendees' => array(
+ array('email' => 'venbalap08@gmail.com'),
+ ),
+ )
+ );
+
+ $this->db->insert('t_se_team_vc_events',$data);
+ return array(
+ 'id' => $this->db->insert_id(),
+ 'event_id' => $this->calendar->events->insert($calendarId, $event)
+ );
+
+
+
+
+ }
+
+
+}
\ No newline at end of file