CETapp photograph api : ps
This commit is contained in:
parent
c7ce200411
commit
dcb08ae7cc
6
api/application/config/calendar.php
Normal file
6
api/application/config/calendar.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
$config['GOOGLE_CLIENT_ID'] = '286363508265-0d7308vsvbosi26qnoj0ka2odj0e2h7j.apps.googleusercontent.com';
|
||||
$config['GOOGLE_CLIENT_SECRET'] = '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';
|
||||
$config['GOOGLE_OAUTH_SCOPE'] = 'https://www.googleapis.com/auth/calendar';
|
||||
100
api/application/controllers/GC_Event_Controller.php
Normal file
100
api/application/controllers/GC_Event_Controller.php
Normal file
@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/**
|
||||
* User: VE10
|
||||
* This Controller deals with GC_Event Related CRUD Operations
|
||||
*/
|
||||
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
require_once APPPATH . '/libraries/REST_Controller.php';
|
||||
require APPPATH . 'vendor/autoload.php';
|
||||
|
||||
class GC_Event_Controller extends REST_Controller {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->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.<br/>';
|
||||
}
|
||||
if(empty($post['date'])){
|
||||
$valErr .= 'event date is Empty.<br/>';
|
||||
}
|
||||
$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, '<br/>'));
|
||||
$statusMsg = '<p>Please fill all the mandatory fields:</p>'.trim($valErr, '<br/>');
|
||||
}
|
||||
}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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
67
api/application/libraries/Googleapi.php
Normal file
67
api/application/libraries/Googleapi.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Google API : Google Client API
|
||||
*
|
||||
* @author TechArise Team
|
||||
*
|
||||
* @email info@techarise.com
|
||||
*
|
||||
* Description of Contact Controller
|
||||
*/
|
||||
|
||||
if (!defined('BASEPATH'))
|
||||
exit('No direct script access allowed');
|
||||
|
||||
class Googleapi
|
||||
{
|
||||
/**
|
||||
* Googleapi constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
// load google client api
|
||||
require_once BASH_PATH.'vendor/autoload.php';
|
||||
$this->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();
|
||||
}
|
||||
}
|
||||
?>
|
||||
122
api/application/models/GC_Event_Model.php
Normal file
122
api/application/models/GC_Event_Model.php
Normal file
@ -0,0 +1,122 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
require_once APPPATH . '/libraries/SPARQ_Model.php';
|
||||
class GC_Event_Model extends SPARQ_Model {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
parent::__construct();
|
||||
$this->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)
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user