FIX_Zoho Route post into get : ps

This commit is contained in:
VE10-Sanjeev 2024-06-21 07:11:28 +00:00
parent f293a63fce
commit c59f336326
3 changed files with 16 additions and 18 deletions

View File

@ -135,7 +135,7 @@ $routes->get('purchaseorder/Savencrlist', 'Purchaseorder::Savencrlist');
$routes->get('purchaseorder/Nonconfirmativelist','Purchaseorder::Nonconfirmativelist'); $routes->get('purchaseorder/Nonconfirmativelist','Purchaseorder::Nonconfirmativelist');
//Zohobooks sync //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 // Application Payslip Routes
$routes->match(['get', 'post', 'put', 'delete'],'monthlyListings', 'Monthlypay::monthlyListing'); $routes->match(['get', 'post', 'put', 'delete'],'monthlyListings', 'Monthlypay::monthlyListing');

View File

@ -1301,9 +1301,8 @@ class User extends BaseController
$tokendata['token'] = $token; $tokendata['token'] = $token;
$Zohobook_model->customUpdate($tokendata, 1, 'zohobook_accesstoken'); $Zohobook_model->customUpdate($tokendata, 1, 'zohobook_accesstoken');
} }
$result = getheringInvoiceDetails($date_today, $date_yesterday, $token);//refer zohobook helper $result = getheringInvoiceDetails($date_today, $date_yesterday, $token);//refer zohobook helper
// print_r($result);die;
$headers_new = $result['headers_new']; $headers_new = $result['headers_new'];
$res = json_decode($result['data'], true); $res = json_decode($result['data'], true);
if(isset($res['invoices']) && !empty($res['invoices'])){ if(isset($res['invoices']) && !empty($res['invoices'])){
@ -1311,12 +1310,11 @@ class User extends BaseController
// echo json_encode($inv_array);die; // echo json_encode($inv_array);die;
}else{ }else{
$inv_array = array(); $inv_array = array();
log_message('ERROR', $res['message']); log_message('error', $res['message']);
echo "An Error Occur ==> " .$res['message']." \n <br> "; echo "An Error Occur ==> " .$res['message']." \n <br> ";
throw new \Exception($res['message']); throw new \Exception($res['message']);
} }
if(!empty($inv_array)){ if(!empty($inv_array)){
foreach ($inv_array as $inv) { foreach ($inv_array as $inv) {
$invoice_id = $inv['invoice_id']; $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; echo 'new invoice inserted count- ' . $insert_count . '/' . 'status updated count - ' . $update_count;
}else{ }else{
$err = 'invoice details not founded ( from '.$date_yesterday.' into '.$date_today.' )'; $err = 'invoice details not founded ( from '.$date_yesterday.' into '.$date_today.' )';
log_message('ERROR', $err); log_message('error', $err);
echo $err; echo $err;
throw new \Exception($err); throw new \Exception($err);
} }
@ -1583,9 +1581,9 @@ class User extends BaseController
// } // }
} catch (\Exception $e) { } catch (\Exception $e) {
$data['err'] = $e->getMessage(); $data['err'] = $e->getMessage();
$data['last_query'] = $this->db->getLastQuery(); // $data['last_query'] = $this->db->getLastQuery();
$Zohobook_model->customInsert($data, 'zohobook_api_err'); $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 // END zoho API

View File

@ -1,11 +1,5 @@
<?php <?php
// Define namespace
namespace App\Helpers;
// Import required libraries
use Config\Services;
if (! function_exists('generateNewToken')) { if (! function_exists('generateNewToken')) {
function generateNewToken() function generateNewToken()
{ {
@ -48,8 +42,8 @@ if (! function_exists('getheringInvoiceDetails')) {
// Zoho API credentials // Zoho API credentials
$organization_id = '776847408'; $organization_id = '776847408';
// $url_org = "https://books.zoho.com/api/v3/invoices?"; $url_org = "https://books.zoho.com/api/v3/invoices?";
$url_org = "https://zohoapis.com/api/v3/invoices?"; // $url_org = "https://zohoapis.com/api/v3/invoices?";
// Construct query parameters // Construct query parameters
$fields = array( $fields = array(
@ -94,8 +88,8 @@ if (! function_exists('getheringInvoiceSubDetails')) {
$ch = curl_init(); $ch = curl_init();
// Construct URL for invoice sub-details // Construct URL for invoice sub-details
// $url2 = 'https://books.zoho.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; // $url2 = 'https://zohoapis.com/api/v3/invoices/'.$invoice_id.'?organization_id='.$organization_id;
// Set cURL options // Set cURL options
curl_setopt($ch, CURLOPT_URL, $url2); curl_setopt($ch, CURLOPT_URL, $url2);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
@ -107,5 +101,11 @@ if (! function_exists('getheringInvoiceSubDetails')) {
return curl_exec($ch); return curl_exec($ch);
} }
} }
if (! function_exists('test_helper')) {
function test_helper()
{
return "Helper function called!";
}
}
?> ?>