FIX_Zoho Route post into get : ps
This commit is contained in:
parent
f293a63fce
commit
c59f336326
@ -135,7 +135,7 @@ $routes->get('purchaseorder/Savencrlist', 'Purchaseorder::Savencrlist');
|
||||
$routes->get('purchaseorder/Nonconfirmativelist','Purchaseorder::Nonconfirmativelist');
|
||||
|
||||
//Zohobooks sync
|
||||
$routes->post('user/zohobooks_api_fetch_all','User::zohobooks_api_fetch_all');
|
||||
$routes->get('user/zohobooks_api_fetch_all','User::zohobooks_api_fetch_all');
|
||||
|
||||
// Application Payslip Routes
|
||||
$routes->match(['get', 'post', 'put', 'delete'],'monthlyListings', 'Monthlypay::monthlyListing');
|
||||
|
||||
@ -1301,9 +1301,8 @@ class User extends BaseController
|
||||
$tokendata['token'] = $token;
|
||||
$Zohobook_model->customUpdate($tokendata, 1, 'zohobook_accesstoken');
|
||||
}
|
||||
|
||||
$result = getheringInvoiceDetails($date_today, $date_yesterday, $token);//refer zohobook helper
|
||||
|
||||
// print_r($result);die;
|
||||
$headers_new = $result['headers_new'];
|
||||
$res = json_decode($result['data'], true);
|
||||
if(isset($res['invoices']) && !empty($res['invoices'])){
|
||||
@ -1311,12 +1310,11 @@ class User extends BaseController
|
||||
// echo json_encode($inv_array);die;
|
||||
}else{
|
||||
$inv_array = array();
|
||||
log_message('ERROR', $res['message']);
|
||||
log_message('error', $res['message']);
|
||||
echo "An Error Occur ==> " .$res['message']." \n <br> ";
|
||||
throw new \Exception($res['message']);
|
||||
}
|
||||
|
||||
|
||||
if(!empty($inv_array)){
|
||||
foreach ($inv_array as $inv) {
|
||||
$invoice_id = $inv['invoice_id'];
|
||||
@ -1575,7 +1573,7 @@ class User extends BaseController
|
||||
echo 'new invoice inserted count- ' . $insert_count . '/' . 'status updated count - ' . $update_count;
|
||||
}else{
|
||||
$err = 'invoice details not founded ( from '.$date_yesterday.' into '.$date_today.' )';
|
||||
log_message('ERROR', $err);
|
||||
log_message('error', $err);
|
||||
echo $err;
|
||||
throw new \Exception($err);
|
||||
}
|
||||
@ -1583,9 +1581,9 @@ class User extends BaseController
|
||||
// }
|
||||
} catch (\Exception $e) {
|
||||
$data['err'] = $e->getMessage();
|
||||
$data['last_query'] = $this->db->getLastQuery();
|
||||
// $data['last_query'] = $this->db->getLastQuery();
|
||||
$Zohobook_model->customInsert($data, 'zohobook_api_err');
|
||||
log_message('ERROR', "Data insertion failed : " . $e->getMessage());
|
||||
log_message('error', "Data insertion failed : " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
// END zoho API
|
||||
|
||||
@ -1,11 +1,5 @@
|
||||
<?php
|
||||
|
||||
// Define namespace
|
||||
namespace App\Helpers;
|
||||
|
||||
// Import required libraries
|
||||
use Config\Services;
|
||||
|
||||
if (! function_exists('generateNewToken')) {
|
||||
function generateNewToken()
|
||||
{
|
||||
@ -48,8 +42,8 @@ if (! function_exists('getheringInvoiceDetails')) {
|
||||
|
||||
// Zoho API credentials
|
||||
$organization_id = '776847408';
|
||||
// $url_org = "https://books.zoho.com/api/v3/invoices?";
|
||||
$url_org = "https://zohoapis.com/api/v3/invoices?";
|
||||
$url_org = "https://books.zoho.com/api/v3/invoices?";
|
||||
// $url_org = "https://zohoapis.com/api/v3/invoices?";
|
||||
|
||||
// Construct query parameters
|
||||
$fields = array(
|
||||
@ -94,8 +88,8 @@ if (! function_exists('getheringInvoiceSubDetails')) {
|
||||
$ch = curl_init();
|
||||
|
||||
// Construct URL for invoice sub-details
|
||||
// $url2 = 'https://books.zoho.com/api/v3/invoices/'.$invoice_id.'?organization_id='.$organization_id;
|
||||
$url2 = 'https://zohoapis.com/api/v3/invoices/'.$invoice_id.'?organization_id='.$organization_id;
|
||||
$url2 = 'https://books.zoho.com/api/v3/invoices/'.$invoice_id.'?organization_id='.$organization_id;
|
||||
// $url2 = 'https://zohoapis.com/api/v3/invoices/'.$invoice_id.'?organization_id='.$organization_id;
|
||||
// Set cURL options
|
||||
curl_setopt($ch, CURLOPT_URL, $url2);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
@ -107,5 +101,11 @@ if (! function_exists('getheringInvoiceSubDetails')) {
|
||||
return curl_exec($ch);
|
||||
}
|
||||
}
|
||||
if (! function_exists('test_helper')) {
|
||||
function test_helper()
|
||||
{
|
||||
return "Helper function called!";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user