susee:zohobook fetch api
This commit is contained in:
parent
871ae4e202
commit
6074d6496c
@ -16,6 +16,8 @@ class Login extends CI_Controller
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('login_model');
|
||||
$this->load->model('Zohobook_api_model','Zohobook_model');
|
||||
$this->load->helper('zohobooks_fetch_api_helper');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -249,6 +251,304 @@ class Login extends CI_Controller
|
||||
*
|
||||
* }
|
||||
*/
|
||||
|
||||
// start zoho API
|
||||
|
||||
function zohobooks_api_fetch_all(){
|
||||
try{
|
||||
if (isset($_POST['sync']) || $_GET['from'] != null && $_GET['to'] != null)
|
||||
{
|
||||
// $ch=curl_init();
|
||||
$this->load->helper('zohobooks_fetch_api_helper');
|
||||
if($_GET['from'] != null && $_GET['to'] != null)
|
||||
{
|
||||
$date_today = $_GET['to'];
|
||||
$date_yesterday = $_GET['from'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$date_today = date('Y-m-d');
|
||||
$date_yesterday = date('Y-m-d',strtotime('-1 day',strtotime($date_today)));
|
||||
}
|
||||
$chk_acc_token_val = $this->Zohobook_model->get_data('zohobook_accesstoken','id' , 1);
|
||||
$date = new DateTime($chk_acc_token_val[0]['created_at']); $date->add(new DateInterval('PT1H'));
|
||||
$token = 0;
|
||||
if ($date->format('Y-m-d h:i:s') > date('Y-m-d h:i:s')) { $token = $chk_acc_token_val[0]['token']; }
|
||||
else { $token = generateNewToken(); $tokendata['token'] = $token; $this->Zohobook_model->update($tokendata , 1,'zohobook_accesstoken'); }
|
||||
$result = getheringInvoiceDetails($date_today , $date_yesterday , $token);
|
||||
// echo json_encode($result);
|
||||
$headers_new = $result['headers_new'];
|
||||
$res = json_decode($result['data'],true);
|
||||
$inv_array = $res['invoices'];
|
||||
foreach($inv_array as $inv){
|
||||
$invoice_id = $inv['invoice_id'];
|
||||
if($invoice_id!==""){
|
||||
$organization_id = '655654572';
|
||||
$result2=getheringInvoiceSubDetails($invoice_id,$organization_id,$headers_new);
|
||||
$resall = json_decode($result2,true);
|
||||
$res2[] = $resall['invoice'];
|
||||
}
|
||||
}
|
||||
$insert_count = 0;
|
||||
$update_count = 0;
|
||||
foreach($res2 as $rs)
|
||||
{
|
||||
$gst_no = $rs['gst_no'];
|
||||
$sku = $rs['line_items'][0]['sku'];
|
||||
$invoice_number = $rs['invoice_number'];
|
||||
$invoice_date = $rs['date'];
|
||||
|
||||
$sql_invoice_chk = $this->Zohobook_model->ip_invoices($invoice_number , $invoice_date);
|
||||
if($sql_invoice_chk <= 0)
|
||||
{
|
||||
$gst_no = $rs['gst_no'];
|
||||
$sku = $rs['line_items'][0]['sku'];
|
||||
$invoice_number = $rs['invoice_number'];
|
||||
$invoice_date = $rs['date'];
|
||||
$due_date = $rs['due_date'];
|
||||
$item_price = $rs['line_items'][0]['rate'];
|
||||
$item_order = $rs['line_items'][0]['item_order'];
|
||||
$item_product_unit = $rs['line_items'][0]['unit'];
|
||||
$item_name = $rs['line_items'][0]['name'];
|
||||
$item_description = $rs['line_items'][0]['description'];
|
||||
$item_quantity = $rs['line_items'][0]['quantity'];
|
||||
// $batch_no = $rs['custom_fields'][5]['value'];
|
||||
$batch_no = "";
|
||||
$invoice_time=$rs['created_time'];
|
||||
$time_array = explode("T", $invoice_time);
|
||||
$time_array = explode("+",$time_array[1]);
|
||||
$invoice_time = $time_array[0];
|
||||
$status = $rs['status'];
|
||||
|
||||
$vehicle_number = $rs['custom_field_hash']['cf_vehicle_number'];
|
||||
$transport_mode =$rs['custom_field_hash']['cf_transport_mode'];
|
||||
$purchase_order_date = $rs['custom_field_hash']['cf_purchase_order_date'];
|
||||
$driver = $rs['custom_field_hash']['cf_driver'];
|
||||
$place_of_supply = $rs['custom_field_hash']['cf_place_of_supply'];
|
||||
|
||||
$cgst = $rs['taxes'][0]['tax_name'];
|
||||
$sgst = $rs['taxes'][1]['tax_name'];
|
||||
$cgst = $cgst[4];
|
||||
$sgst = $sgst[4];
|
||||
$cgst = $cgst.'.000';
|
||||
$getcgsttax = $this->Zohobook_model->ip_tax_rates($cgst);
|
||||
if($getcgsttax)
|
||||
{
|
||||
$cgsttaxid = $getcgsttax[0]['tax_rate_id'];
|
||||
log_message('error', 'Data fetch success DB : ip_tax_rates cgst'. $cgst);
|
||||
}
|
||||
else
|
||||
{
|
||||
log_message('error', 'No data => Data fetch failed DB : ip_tax_rates '. $cgst);
|
||||
$cgst_data['tax_rate_percent'] = $cgst;
|
||||
$getcgsttax = $this->Zohobook_model->insert($cgst_data,'ip_tax_rates');
|
||||
$cgsttaxid = $getcgsttax[0]['tax_rate_id'];
|
||||
log_message('error', 'New Data Created : DB : ip_tax_rates , tax_rate_id : '.$cgsttaxid);
|
||||
}
|
||||
|
||||
$sgst = $sgst.'.000';
|
||||
$getsgsttax = $this->Zohobook_model->ip_tax_rates($sgst);
|
||||
if($getsgsttax)
|
||||
{
|
||||
$sgsttaxid = $getsgsttax[0]['tax_rate_id'];
|
||||
log_message('error', 'Data fetch success DB : ip_tax_rates sgst'. $sgst);
|
||||
}
|
||||
else
|
||||
{
|
||||
log_message('error', 'No data => Data fetch failed DB : ip_tax_rates '. $sgst);
|
||||
$sgst_data['tax_rate_percent'] = $sgst;
|
||||
$getsgsttax = $this->Zohobook_model->insert($sgst_data,'ip_tax_rates');
|
||||
$sgsttaxid = $getsgsttax[0]['tax_rate_id'];
|
||||
log_message('error', 'New Data Created : DB : ip_tax_rates , tax_rate_id : '.$sgsttaxid);
|
||||
}
|
||||
|
||||
$item_subtotal = $rs['line_items'][0]['item_total'];
|
||||
$item_tax_total = $rs['tax_total'];
|
||||
$item_total = $rs['total'];
|
||||
$item_sgst_amt = $rs['taxes'][1]['tax_amount'];
|
||||
$item_cgst_amt = $rs['taxes'][0]['tax_amount'];
|
||||
|
||||
$item_discount = 0.00;
|
||||
$item_igst_amt = 0.00;
|
||||
if($batch_no==""){ $batch_no = "";}
|
||||
$gst_sql = $this->Zohobook_model->ip_clients($gst_no);
|
||||
if($gst_sql)
|
||||
{
|
||||
$client_id = $gst_sql[0]['client_id'];
|
||||
log_message('error', 'Data fetch success DB : ip_clients , client_id : '.$client_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
log_message('error', 'No data => Data fetch failed DB : ip_clients '.$gst_no);
|
||||
$gst_no_data['client_tax_code'] = $gst_no;
|
||||
$gst_sql = $this->Zohobook_model->insert($gst_no_data,'ip_clients');
|
||||
$client_id = $gst_sql[0]['tax_rate_id'];
|
||||
log_message('error', 'New Data Created : DB : ip_clients , client_id : '.$client_id);
|
||||
}
|
||||
|
||||
$sku_sql = $this->Zohobook_model->ip_products($sku);
|
||||
if($sku_sql)
|
||||
{
|
||||
$product_id = $sku_sql[0]['product_id'];
|
||||
log_message('error', 'Data fetch success DB : ip_products , product_id : '.$product_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
log_message('error', 'No data => Data fetch failed DB : ip_products '. $sku);
|
||||
$sku_data['product_name'] = $item_name;
|
||||
$sku_data['product_description'] = $item_description;
|
||||
$sku_data['sku'] = $sku;
|
||||
$sku_sql = $this->Zohobook_model->insert($sku_data,'ip_products');
|
||||
$product_id = $sku_sql[0]['sku'];
|
||||
log_message('error', 'sku'.$sku);
|
||||
log_message('error', 'New Data Created : DB : product_id , product_id : '.$product_id);
|
||||
}
|
||||
|
||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$charactersLength = strlen($characters);
|
||||
$randomString = '';
|
||||
for ($i = 0; $i < 16; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; }
|
||||
$url_key = $randomString;
|
||||
|
||||
$ip_invoices['user_id'] = 1;
|
||||
$ip_invoices['client_id'] = $client_id;
|
||||
$ip_invoices['invoice_group_id'] = 6;
|
||||
$ip_invoices['invoice_status_id'] = 2;
|
||||
$ip_invoices['invoice_date_created'] = $invoice_date;
|
||||
$ip_invoices['invoice_time_created'] = $invoice_time;
|
||||
$ip_invoices['invoice_date_due'] = $due_date;
|
||||
$ip_invoices['invoice_number'] = $invoice_number;
|
||||
$ip_invoices['invoice_url_key'] = $url_key;
|
||||
$ip_invoices['receivedstatus'] = 'ST066';
|
||||
$ip_invoices['credit_status'] = 0;
|
||||
$invoice_insert_id = $this->Zohobook_model->insert($ip_invoices,'ip_invoices');
|
||||
if($invoice_insert_id)
|
||||
log_message('error', 'Data insert success DB : ip_invoices client id :'. $client_id);
|
||||
else
|
||||
log_message('error', 'Data insert failed DB : ip_invoice_items client id :'. $client_id);
|
||||
|
||||
$ip_invoice_items['invoice_id'] = $invoice_insert_id;
|
||||
$ip_invoice_items['item_product_id'] = $product_id;
|
||||
$ip_invoice_items['item_date_added'] = $invoice_date;
|
||||
$ip_invoice_items['item_name'] = $item_name;
|
||||
$ip_invoice_items['item_description'] = $item_description;
|
||||
$ip_invoice_items['item_quantity'] = $item_quantity;
|
||||
$ip_invoice_items['item_price'] = $item_price;
|
||||
$ip_invoice_items['item_order'] = $item_order;
|
||||
$ip_invoice_items['item_product_unit'] = $item_product_unit;
|
||||
$ip_invoice_items['Sgst_item_tax_rate_id'] = $sgsttaxid;
|
||||
$ip_invoice_items['Cgst_item_tax_rate_id'] = $cgsttaxid;
|
||||
$item_insert_id = $this->Zohobook_model->insert($ip_invoice_items,'ip_invoice_items');
|
||||
if($item_insert_id)
|
||||
log_message('error', 'Data insert success DB : ip_invoice_items => Sgst_item_tax_rate_id :'. $sgsttaxid);
|
||||
else
|
||||
log_message('error', 'Data insert failed DB : ip_invoice_items => Sgst_item_tax_rate_id :'. $sgsttaxid);
|
||||
|
||||
//tax amount -- ip_invoice_item_amounts - table
|
||||
$ip_invoice_item_amounts['item_id'] = $item_insert_id;
|
||||
$ip_invoice_item_amounts['item_subtotal'] = $item_subtotal;
|
||||
$ip_invoice_item_amounts['item_tax_total'] = $item_tax_total;
|
||||
$ip_invoice_item_amounts['item_total'] = $item_total;
|
||||
$ip_invoice_item_amounts['item_sgst_amt'] = $item_sgst_amt;
|
||||
$ip_invoice_item_amounts['item_cgst_amt'] = $item_cgst_amt;
|
||||
$ip_invoice_item_amounts['item_discount'] = $item_discount;
|
||||
$ip_invoice_item_amounts['item_igst_amt'] = $item_igst_amt;
|
||||
$result_tax_amount_insert = $this->Zohobook_model->insert($ip_invoice_item_amounts,'ip_invoice_item_amounts');
|
||||
if($result_tax_amount_insert)
|
||||
log_message('error', 'Data insert success DB : ip_invoice_item_amounts ');
|
||||
else
|
||||
log_message('error', 'Data insert failed DB : ip_invoice_item_amounts ');
|
||||
|
||||
//custom fields insert
|
||||
// batch_no
|
||||
$ip_invoice_custom_b['invoice_id'] = $invoice_insert_id;
|
||||
$ip_invoice_custom_b['invoice_custom_fieldid'] = 62;
|
||||
$ip_invoice_custom_b['invoice_custom_fieldvalue'] = $batch_no;
|
||||
$result_invoice_custom_insert = $this->Zohobook_model->insert($ip_invoice_custom_b,'ip_invoice_custom');
|
||||
if($result_invoice_custom_insert)
|
||||
log_message('error', 'Data insert success DB : ip_invoice_custom ');
|
||||
else
|
||||
log_message('error', 'Data insert failed DB : ip_invoice_custom ');
|
||||
// vehicle_number
|
||||
$ip_invoice_custom_v['invoice_id'] = $invoice_insert_id;
|
||||
$ip_invoice_custom_v['invoice_custom_fieldid'] = 8;
|
||||
$ip_invoice_custom_v['invoice_custom_fieldvalue'] = $vehicle_number;
|
||||
$res_vehicle = $this->Zohobook_model->insert($ip_invoice_custom_v,'ip_invoice_custom');
|
||||
if($res_vehicle)
|
||||
log_message('error', 'Data insert success DB : ip_invoice_custom ');
|
||||
else
|
||||
log_message('error', 'Data insert failed DB : ip_invoice_custom ');
|
||||
// transport_mode
|
||||
$ip_invoice_custom_t['invoice_id'] = $invoice_insert_id;
|
||||
$ip_invoice_custom_t['invoice_custom_fieldid'] = 7;
|
||||
$ip_invoice_custom_t['invoice_custom_fieldvalue'] = $transport_mode;
|
||||
$res_transport_mode = $this->Zohobook_model->insert($ip_invoice_custom_t,'ip_invoice_custom');
|
||||
if($res_transport_mode)
|
||||
log_message('error', 'Data insert success DB : ip_invoice_custom ');
|
||||
else
|
||||
log_message('error', 'Data insert failed DB : ip_invoice_custom ');
|
||||
// purchase_order_date
|
||||
$ip_invoice_custom_p['invoice_id'] = $invoice_insert_id;
|
||||
$ip_invoice_custom_p['invoice_custom_fieldid'] = 15;
|
||||
$ip_invoice_custom_p['invoice_custom_fieldvalue'] = $purchase_order_date;
|
||||
$res_purchase_order_date =$this->Zohobook_model->insert($ip_invoice_custom_p,'ip_invoice_custom');
|
||||
if($res_purchase_order_date)
|
||||
log_message('error', 'Data insert success DB : ip_invoice_custom ');
|
||||
else
|
||||
log_message('error', 'Data insert failed DB : ip_invoice_custom ');
|
||||
// driver
|
||||
$ip_invoice_custom_d['invoice_id'] = $invoice_insert_id;
|
||||
$ip_invoice_custom_d['invoice_custom_fieldid'] = 58;
|
||||
$ip_invoice_custom_d['invoice_custom_fieldvalue'] = $driver;
|
||||
$res_driver = $this->Zohobook_model->insert($ip_invoice_custom_d,'ip_invoice_custom');
|
||||
if($res_driver)
|
||||
log_message('error', 'Data insert success DB : ip_invoice_custom ');
|
||||
else
|
||||
log_message('error', 'Data insert failed DB : ip_invoice_custom ');
|
||||
// place_of_supply
|
||||
$ip_invoice_custom_d['invoice_id'] = $invoice_insert_id;
|
||||
$ip_invoice_custom_d['invoice_custom_fieldid'] = 10;
|
||||
$ip_invoice_custom_d['invoice_custom_fieldvalue'] = $place_of_supply;
|
||||
$res_place = $this->Zohobook_model->insert($ip_invoice_custom_d,'ip_invoice_custom');
|
||||
if($res_place)
|
||||
log_message('error', 'Data insert success DB : ip_invoice_custom ');
|
||||
else
|
||||
log_message('error', 'Data insert failed DB : ip_invoice_custom ');
|
||||
$insert_count = $insert_count + 1;
|
||||
}
|
||||
else // update invoice status, especially for cancelled invoices
|
||||
{
|
||||
if($status == "void")
|
||||
{
|
||||
$sql_invoice_update['invoice_status_id'] = 5;
|
||||
$sql_invoice_update = $this->Zohobook_model->sql_invoice_update($sql_invoice_update,$invoice_number,$invoice_date,'ip_invoices');
|
||||
if($sql_invoice_update)
|
||||
{
|
||||
log_message('error', 'Data update success DB : ip_invoices ');
|
||||
}
|
||||
else
|
||||
{
|
||||
log_message('error', 'Data update failed DB : ip_invoices ');
|
||||
}
|
||||
$update_count = $update_count + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
echo 'new invoice inserted count- '. $insert_count . '/'.'cancelled status updated count - ' . $update_count;
|
||||
|
||||
// curl_close($ch);
|
||||
}
|
||||
}
|
||||
catch (Exception $e) {
|
||||
$data['err'] = $e->getMessage();
|
||||
$data['last_query'] = $this->db->last_query();
|
||||
$this->Zohobook_model->insert($data,'zohobook_api_err');
|
||||
log_message('ERROR', "Data insertion failed : " . $e->getMessage());
|
||||
|
||||
}
|
||||
}
|
||||
//end
|
||||
// END zoho API
|
||||
|
||||
|
||||
|
||||
|
||||
@ -20,6 +20,8 @@ class quality extends BaseController
|
||||
parent::__construct();
|
||||
$this->load->model('quality_model');
|
||||
$this->load->library('form_validation');
|
||||
$this->load->model('Zohobook_api_model','Zohobook_model');
|
||||
$this->load->helper('zohobooks_fetch_api_helper');
|
||||
//$this->load->library('dompdf_gen');
|
||||
$this->isLoggedIn();
|
||||
}
|
||||
@ -539,345 +541,296 @@ class quality extends BaseController
|
||||
// start zoho API
|
||||
|
||||
function zohobooks_api_fetch_all(){
|
||||
|
||||
//echo 'scuess';die();
|
||||
log_message('error'," ***Syncing with zoho books...***");
|
||||
if (isset($_POST['sync']))
|
||||
{
|
||||
|
||||
$con = new mysqli($this->db->hostname,$this->db->username,$this->db->password,$this->db->database);
|
||||
|
||||
|
||||
$ch=curl_init();
|
||||
|
||||
$organization_id = '655654572';
|
||||
$client_id = '1000.T9H4WV9XTGUJRB6HRDMQANB6VT04NH';
|
||||
$refresh_token = '1000.6608673cee76166874b326b8183a38ab.5fa4b2fa427fe64c5a8700f7170e3a58';
|
||||
$client_secret = '91ec3fc047493706ae9c15c086741d90ef1de3cd6c';
|
||||
$redirect_uri = 'https://sia.sidharthindustries.com/SIA/';
|
||||
|
||||
$date_today = date('Y-m-d');
|
||||
$date_yesterday = date('Y-m-d',strtotime('-7 day',strtotime($date_today)));
|
||||
log_message('error'," ***ZOHO***".$date_today."**".$date_yesterday);
|
||||
// $date_yesterday = '2022-09-01';
|
||||
|
||||
// echo $date_yesterday.'-'.$date_today;//die();
|
||||
|
||||
|
||||
$url_org ="https://books.zoho.com/api/v3/invoices?";
|
||||
|
||||
$fields=array(
|
||||
|
||||
"usestate" => "true",
|
||||
"organization_id" =>"655654572",
|
||||
"date_start" => $date_yesterday,
|
||||
"date_end" => $date_today
|
||||
|
||||
);
|
||||
|
||||
$data_all = http_build_query($fields);
|
||||
|
||||
$accesstoken = '1000.095b66fc95fc81874c1cfc7d15b0904e.10bc9956d9b9ec14cce1350ee0cf8254';
|
||||
|
||||
//code => 57 -->expired
|
||||
//code => 0 -->not expired
|
||||
$headers=array(
|
||||
'Authorization:Zoho-oauthtoken '.$accesstoken,
|
||||
'Content-Type:application/json'
|
||||
);
|
||||
|
||||
$data_access = $url_org.$data_all;
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, $data_access);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
|
||||
$body = '{}';
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS,$body);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
$result=curl_exec($ch);
|
||||
log_message('error'," Response ".$result);
|
||||
$res = json_decode($result);
|
||||
|
||||
|
||||
|
||||
if($res->code=="57")
|
||||
{
|
||||
log_message('error'," IF condition ");
|
||||
$url_getauthtoken = 'https://accounts.zoho.com/oauth/v2/token?refresh_token='.$refresh_token.'&client_id='.$client_id.'&client_secret='.$client_secret.'&redirect_uri='.$redirect_uri.'&grant_type=refresh_token';
|
||||
curl_setopt($ch, CURLOPT_URL, $url_getauthtoken);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
|
||||
$body = '{}';
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS,$body);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
$res_token=curl_exec($ch);
|
||||
|
||||
$ress = json_decode($res_token);
|
||||
|
||||
$newaccesstoken = $ress->access_token;
|
||||
|
||||
|
||||
$headers_new=array(
|
||||
'Authorization:Zoho-oauthtoken '.$newaccesstoken,
|
||||
'Content-Type:application/json'
|
||||
);
|
||||
|
||||
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, $url_org.$data_access);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers_new);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
|
||||
$body = '{}';
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS,$body);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
$result=curl_exec($ch);
|
||||
|
||||
$res = json_decode($result,true);
|
||||
|
||||
|
||||
// print_r($res);
|
||||
$inv_array = $res['invoices'];
|
||||
|
||||
foreach($inv_array[0] as $inv){
|
||||
|
||||
$invoice_id = $inv['invoice_id'];
|
||||
log_message('error', " # Invoice ID : " . $invoice_id);
|
||||
|
||||
if($invoice_id!==""){
|
||||
|
||||
$url2 = 'https://books.zoho.com/api/v3/invoices/'.$invoice_id.'?organization_id='.$organization_id;
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, $url2);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers_new);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
|
||||
$body2 = '{}';
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS,$body2);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
$result2=curl_exec($ch);
|
||||
|
||||
$resall = json_decode($result2,true);
|
||||
$res2[] = $resall['invoice'];
|
||||
log_message('error', "Zoho URL Invoice ( " . $invoice_id . " )");
|
||||
log_message('error', "Response : ".$result2);
|
||||
// print_r($result2);
|
||||
// exit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//echo count($res2);
|
||||
log_message('error', "Zoho URL Invoice ( " . $invoice_id . " ) count ".count($res2));
|
||||
|
||||
$insert_count = 0;
|
||||
$update_count = 0;
|
||||
|
||||
foreach($res2 as $rs)
|
||||
try{
|
||||
if (isset($_POST['sync']) || $_GET['from'] != null && $_GET['to'] != null)
|
||||
{
|
||||
// $ch=curl_init();
|
||||
$this->load->helper('zohobooks_fetch_api_helper');
|
||||
if($_GET['from'] != null && $_GET['to'] != null)
|
||||
{
|
||||
|
||||
|
||||
$gst_no = $rs['gst_no'];
|
||||
$sku = $rs['line_items'][0]['sku'];
|
||||
$invoice_number = $rs['invoice_number'];
|
||||
$invoice_date = $rs['date'];
|
||||
$due_date = $rs['due_date'];
|
||||
$item_price = $rs['line_items'][0]['rate'];
|
||||
$item_order = $rs['line_items'][0]['item_order'];
|
||||
$item_product_unit = $rs['line_items'][0]['unit'];
|
||||
$item_name = $rs['line_items'][0]['name'];
|
||||
$item_description = $rs['line_items'][0]['description'];
|
||||
$item_quantity = $rs['line_items'][0]['quantity'];
|
||||
$batch_no = $rs['custom_fields'][5]['value'];
|
||||
$invoice_time=$rs['created_time'];
|
||||
$time_array = explode("T", $invoice_time);
|
||||
$time_array = explode("+",$time_array[1]);
|
||||
$invoice_time = $time_array[0];
|
||||
$status = $rs['status'];
|
||||
|
||||
$vehicle_number = $rs['custom_field_hash']['cf_vehicle_number'];
|
||||
$transport_mode =$rs['custom_field_hash']['cf_transport_mode'];
|
||||
$purchase_order_date = $rs['custom_field_hash']['cf_purchase_order_date'];
|
||||
$driver = $rs['custom_field_hash']['cf_driver'];
|
||||
$place_of_supply = $rs['custom_field_hash']['cf_place_of_supply'];
|
||||
|
||||
|
||||
$cgst = $rs['taxes'][0]['tax_name'];
|
||||
$sgst = $rs['taxes'][1]['tax_name'];
|
||||
$cgst = $cgst[4];
|
||||
$sgst = $sgst[4];
|
||||
$cgst = $cgst.'.000';
|
||||
$getcgsttax = "SELECT * FROM ip_tax_rates WHERE tax_rate_percent='$cgst'";
|
||||
$res_cgsttax = $con->query($getcgsttax);
|
||||
$rw_cgsttax = $res_cgsttax->fetch_assoc();
|
||||
$cgsttaxid = $rw_cgsttax['tax_rate_id'];
|
||||
|
||||
$sgst = $sgst.'.000';
|
||||
$getsgsttax = "SELECT * FROM ip_tax_rates WHERE tax_rate_percent='$sgst'";
|
||||
$res_sgsttax = $con->query($getsgsttax);
|
||||
$rw_sgsttax = $res_sgsttax->fetch_assoc();
|
||||
$sgsttaxid = $rw_sgsttax['tax_rate_id'];
|
||||
|
||||
|
||||
|
||||
$item_subtotal = $rs['line_items'][0]['item_total'];
|
||||
$item_tax_total = $rs['tax_total'];
|
||||
$item_total = $rs['total'];
|
||||
$item_sgst_amt = $rs['taxes'][1]['tax_amount'];
|
||||
$item_cgst_amt = $rs['taxes'][0]['tax_amount'];
|
||||
|
||||
$item_discount = 0.00;
|
||||
$item_isgt_amt = 0.00;
|
||||
|
||||
|
||||
if($batch_no=="")
|
||||
{
|
||||
|
||||
$batch_no = "";
|
||||
}
|
||||
|
||||
$gst_sql = "SELECT * FROM ip_clients WHERE client_tax_code='$gst_no'";
|
||||
$res_gst = $con->query($gst_sql);
|
||||
|
||||
// $r_gst[] = $res_gst->fetch_assoc()['client_id'];
|
||||
$client_id = $res_gst->fetch_assoc()['client_id'];
|
||||
|
||||
|
||||
$sku_sql = "SELECT * FROM ip_products WHERE sku='$sku'";
|
||||
$res_sku = $con->query($sku_sql);
|
||||
// $r_sku[] = $res_sku->fetch_assoc()['product_id'];
|
||||
$product_id = $res_sku->fetch_assoc()['product_id'];
|
||||
log_message('error invoice_number',$invoice_number);
|
||||
$sql_invoice_chk = "SELECT * FROM ip_invoices WHERE invoice_number='$invoice_number' AND invoice_date_created='$invoice_date'";
|
||||
$res_invoice = $con->query($sql_invoice_chk);
|
||||
log_message('error invoice chk ',$sql_invoice_chk);
|
||||
log_message('error return rows ',$res_invoice->num_rows);
|
||||
if($res_invoice->num_rows<=0)
|
||||
{
|
||||
log_message('error ',$res_invoice->num_rows);
|
||||
|
||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$charactersLength = strlen($characters);
|
||||
$randomString = '';
|
||||
for ($i = 0; $i < 16; $i++)
|
||||
{
|
||||
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
||||
}
|
||||
|
||||
|
||||
|
||||
$url_key = $randomString;
|
||||
|
||||
$sql_invoice_insert = "INSERT INTO ip_invoices(user_id,client_id,invoice_group_id,invoice_status_id,invoice_date_created,invoice_time_created,invoice_date_due,invoice_number,invoice_url_key,receivedstatus,credit_status)VALUES(1,'$client_id',6,2,'$invoice_date','$invoice_time','$due_date','$invoice_number','$url_key','ST066',0)";
|
||||
$result_invoice_insert = $con->query($sql_invoice_insert);
|
||||
log_message('error'," Invoice Inserted ".$result_invoice_insert);
|
||||
log_message('error'," Invoice Inserted id ".$con->insert_id);
|
||||
log_message('error',"query invoice => ",$sql_invoice_insert);
|
||||
//exit();
|
||||
$invoice_insert_id=$con->insert_id;
|
||||
|
||||
$sql_invoiceitem_insert = "INSERT INTO ip_invoice_items(invoice_id,item_product_id,item_date_added,item_name,item_description,item_quantity,item_price,item_order,item_product_unit,Sgst_item_tax_rate_id,Cgst_item_tax_rate_id)
|
||||
VALUES('$invoice_insert_id','$product_id','$invoice_date','$item_name','$item_description','$item_quantity','$item_price','$item_order','$item_product_unit','$sgsttaxid','$cgsttaxid')";
|
||||
$result_invoiceitem_insert = $con->query($sql_invoiceitem_insert);
|
||||
|
||||
$item_insert_id = $con->insert_id;
|
||||
|
||||
|
||||
//tax amount -- ip_invoice_item_amounts - table
|
||||
|
||||
|
||||
$sql_tax_amount_insert = "INSERT INTO ip_invoice_item_amounts(item_id,item_subtotal,item_tax_total,item_total,item_sgst_amt,item_cgst_amt,item_discount,item_igst_amt)VALUES('$item_insert_id','$item_subtotal','$item_tax_total','$item_total','$item_sgst_amt','$item_cgst_amt','$item_discount','$item_igst_amt')";
|
||||
$result_tax_amount_insert = $con->query($sql_tax_amount_insert);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//custom fields insert
|
||||
$sql_invoice_custom_insert = "INSERT INTO ip_invoice_custom(invoice_id,invoice_custom_fieldid,invoice_custom_fieldvalue)VALUES('$invoice_insert_id',62,'$batch_no')";
|
||||
$result_invoice_custom_insert = $con->query($sql_invoice_custom_insert);
|
||||
|
||||
$custom_vehicle = "INSERT INTO ip_invoice_custom(invoice_id,invoice_custom_fieldid,invoice_custom_fieldvalue)VALUES('$invoice_insert_id',8,'$vehicle_number')";
|
||||
$res_vehicle = $con->query($custom_vehicle);
|
||||
|
||||
$custom_transport_mode = "INSERT INTO ip_invoice_custom(invoice_id,invoice_custom_fieldid,invoice_custom_fieldvalue)VALUES('$invoice_insert_id',7,'$transport_mode')";
|
||||
$res_transport_mode= $con->query($custom_transport_mode);
|
||||
|
||||
$custom_purchase_order_date= "INSERT INTO ip_invoice_custom(invoice_id,invoice_custom_fieldid,invoice_custom_fieldvalue)VALUES('$invoice_insert_id',15,'$purchase_order_date')";
|
||||
$res_purchase_order_date = $con->query($custom_purchase_order_date);
|
||||
|
||||
$custom_driver = "INSERT INTO ip_invoice_custom(invoice_id,invoice_custom_fieldid,invoice_custom_fieldvalue)VALUES('$invoice_insert_id',58,'$driver')";
|
||||
$res_driver = $con->query($custom_driver);
|
||||
|
||||
$custom_place = "INSERT INTO ip_invoice_custom(invoice_id,invoice_custom_fieldid,invoice_custom_fieldvalue)VALUES('$invoice_insert_id',10,'$place_of_supply')";
|
||||
$res_place = $con->query($custom_place);
|
||||
$insert_count = $insert_count + 1;
|
||||
echo "success";
|
||||
|
||||
}
|
||||
else// update invoice status, especially for cancelled invoices
|
||||
{
|
||||
|
||||
if($status == "void")
|
||||
{
|
||||
$sql_invoice_update = "UPDATE ip_invoices SET invoice_status_id = 5 WHERE invoice_number='$invoice_number' AND invoice_date_created='$invoice_date'";
|
||||
$sql_invoice_update = $con->query($sql_invoice_update);
|
||||
echo "update-".$sql_invoice_update;
|
||||
$update_count = $update_count + 1;
|
||||
$date_today = $_GET['to'];
|
||||
$date_yesterday = $_GET['from'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$date_today = date('Y-m-d');
|
||||
$date_yesterday = date('Y-m-d',strtotime('-1 day',strtotime($date_today)));
|
||||
}
|
||||
$chk_acc_token_val = $this->Zohobook_model->get_data('zohobook_accesstoken','id' , 1);
|
||||
$date = new DateTime($chk_acc_token_val[0]['created_at']); $date->add(new DateInterval('PT1H'));
|
||||
$token = 0;
|
||||
if ($date->format('Y-m-d h:i:s') > date('Y-m-d h:i:s')) { $token = $chk_acc_token_val[0]['token']; }
|
||||
else { $token = generateNewToken(); $tokendata['token'] = $token; $this->Zohobook_model->update($tokendata , 1,'zohobook_accesstoken'); }
|
||||
$result = getheringInvoiceDetails($date_today , $date_yesterday , $token);
|
||||
// echo json_encode($result);
|
||||
$headers_new = $result['headers_new'];
|
||||
$res = json_decode($result['data'],true);
|
||||
$inv_array = $res['invoices'];
|
||||
foreach($inv_array as $inv){
|
||||
$invoice_id = $inv['invoice_id'];
|
||||
if($invoice_id!==""){
|
||||
$organization_id = '655654572';
|
||||
$result2=getheringInvoiceSubDetails($invoice_id,$organization_id,$headers_new);
|
||||
$resall = json_decode($result2,true);
|
||||
$res2[] = $resall['invoice'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$insert_count = 0;
|
||||
$update_count = 0;
|
||||
foreach($res2 as $rs)
|
||||
{
|
||||
$gst_no = $rs['gst_no'];
|
||||
$sku = $rs['line_items'][0]['sku'];
|
||||
$invoice_number = $rs['invoice_number'];
|
||||
$invoice_date = $rs['date'];
|
||||
|
||||
$sql_invoice_chk = $this->Zohobook_model->ip_invoices($invoice_number , $invoice_date);
|
||||
if($sql_invoice_chk <= 0)
|
||||
{
|
||||
$gst_no = $rs['gst_no'];
|
||||
$sku = $rs['line_items'][0]['sku'];
|
||||
$invoice_number = $rs['invoice_number'];
|
||||
$invoice_date = $rs['date'];
|
||||
$due_date = $rs['due_date'];
|
||||
$item_price = $rs['line_items'][0]['rate'];
|
||||
$item_order = $rs['line_items'][0]['item_order'];
|
||||
$item_product_unit = $rs['line_items'][0]['unit'];
|
||||
$item_name = $rs['line_items'][0]['name'];
|
||||
$item_description = $rs['line_items'][0]['description'];
|
||||
$item_quantity = $rs['line_items'][0]['quantity'];
|
||||
// $batch_no = $rs['custom_fields'][5]['value'];
|
||||
$batch_no = "";
|
||||
$invoice_time=$rs['created_time'];
|
||||
$time_array = explode("T", $invoice_time);
|
||||
$time_array = explode("+",$time_array[1]);
|
||||
$invoice_time = $time_array[0];
|
||||
$status = $rs['status'];
|
||||
|
||||
$vehicle_number = $rs['custom_field_hash']['cf_vehicle_number'];
|
||||
$transport_mode =$rs['custom_field_hash']['cf_transport_mode'];
|
||||
$purchase_order_date = $rs['custom_field_hash']['cf_purchase_order_date'];
|
||||
$driver = $rs['custom_field_hash']['cf_driver'];
|
||||
$place_of_supply = $rs['custom_field_hash']['cf_place_of_supply'];
|
||||
|
||||
$cgst = $rs['taxes'][0]['tax_name'];
|
||||
$sgst = $rs['taxes'][1]['tax_name'];
|
||||
$cgst = $cgst[4];
|
||||
$sgst = $sgst[4];
|
||||
$cgst = $cgst.'.000';
|
||||
$getcgsttax = $this->Zohobook_model->ip_tax_rates($cgst);
|
||||
if($getcgsttax)
|
||||
{
|
||||
$cgsttaxid = $getcgsttax[0]['tax_rate_id'];
|
||||
log_message('error', 'Data fetch success DB : ip_tax_rates cgst'. $cgst);
|
||||
}
|
||||
else
|
||||
{
|
||||
log_message('error', 'No data => Data fetch failed DB : ip_tax_rates '. $cgst);
|
||||
$cgst_data['tax_rate_percent'] = $cgst;
|
||||
$getcgsttax = $this->Zohobook_model->insert($cgst_data,'ip_tax_rates');
|
||||
$cgsttaxid = $getcgsttax[0]['tax_rate_id'];
|
||||
log_message('error', 'New Data Created : DB : ip_tax_rates , tax_rate_id : '.$cgsttaxid);
|
||||
}
|
||||
|
||||
$sgst = $sgst.'.000';
|
||||
$getsgsttax = $this->Zohobook_model->ip_tax_rates($sgst);
|
||||
if($getsgsttax)
|
||||
{
|
||||
$sgsttaxid = $getsgsttax[0]['tax_rate_id'];
|
||||
log_message('error', 'Data fetch success DB : ip_tax_rates sgst'. $sgst);
|
||||
}
|
||||
else
|
||||
{
|
||||
log_message('error', 'No data => Data fetch failed DB : ip_tax_rates '. $sgst);
|
||||
$sgst_data['tax_rate_percent'] = $sgst;
|
||||
$getsgsttax = $this->Zohobook_model->insert($sgst_data,'ip_tax_rates');
|
||||
$sgsttaxid = $getsgsttax[0]['tax_rate_id'];
|
||||
log_message('error', 'New Data Created : DB : ip_tax_rates , tax_rate_id : '.$sgsttaxid);
|
||||
}
|
||||
|
||||
$item_subtotal = $rs['line_items'][0]['item_total'];
|
||||
$item_tax_total = $rs['tax_total'];
|
||||
$item_total = $rs['total'];
|
||||
$item_sgst_amt = $rs['taxes'][1]['tax_amount'];
|
||||
$item_cgst_amt = $rs['taxes'][0]['tax_amount'];
|
||||
|
||||
$item_discount = 0.00;
|
||||
$item_igst_amt = 0.00;
|
||||
if($batch_no==""){ $batch_no = "";}
|
||||
$gst_sql = $this->Zohobook_model->ip_clients($gst_no);
|
||||
if($gst_sql)
|
||||
{
|
||||
$client_id = $gst_sql[0]['client_id'];
|
||||
log_message('error', 'Data fetch success DB : ip_clients , client_id : '.$client_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
log_message('error', 'No data => Data fetch failed DB : ip_clients '.$gst_no);
|
||||
$gst_no_data['client_tax_code'] = $gst_no;
|
||||
$gst_sql = $this->Zohobook_model->insert($gst_no_data,'ip_clients');
|
||||
$client_id = $gst_sql[0]['tax_rate_id'];
|
||||
log_message('error', 'New Data Created : DB : ip_clients , client_id : '.$client_id);
|
||||
}
|
||||
|
||||
$sku_sql = $this->Zohobook_model->ip_products($sku);
|
||||
if($sku_sql)
|
||||
{
|
||||
$product_id = $sku_sql[0]['product_id'];
|
||||
log_message('error', 'Data fetch success DB : ip_products , product_id : '.$product_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
log_message('error', 'No data => Data fetch failed DB : ip_products '. $sku);
|
||||
$sku_data['product_name'] = $item_name;
|
||||
$sku_data['product_description'] = $item_description;
|
||||
$sku_data['sku'] = $sku;
|
||||
$sku_sql = $this->Zohobook_model->insert($sku_data,'ip_products');
|
||||
$product_id = $sku_sql[0]['sku'];
|
||||
log_message('error', 'sku'.$sku);
|
||||
log_message('error', 'New Data Created : DB : product_id , product_id : '.$product_id);
|
||||
}
|
||||
|
||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
$charactersLength = strlen($characters);
|
||||
$randomString = '';
|
||||
for ($i = 0; $i < 16; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; }
|
||||
$url_key = $randomString;
|
||||
|
||||
$ip_invoices['user_id'] = 1;
|
||||
$ip_invoices['client_id'] = $client_id;
|
||||
$ip_invoices['invoice_group_id'] = 6;
|
||||
$ip_invoices['invoice_status_id'] = 2;
|
||||
$ip_invoices['invoice_date_created'] = $invoice_date;
|
||||
$ip_invoices['invoice_time_created'] = $invoice_time;
|
||||
$ip_invoices['invoice_date_due'] = $due_date;
|
||||
$ip_invoices['invoice_number'] = $invoice_number;
|
||||
$ip_invoices['invoice_url_key'] = $url_key;
|
||||
$ip_invoices['receivedstatus'] = 'ST066';
|
||||
$ip_invoices['credit_status'] = 0;
|
||||
$invoice_insert_id = $this->Zohobook_model->insert($ip_invoices,'ip_invoices');
|
||||
if($invoice_insert_id)
|
||||
log_message('error', 'Data insert success DB : ip_invoices client id :'. $client_id);
|
||||
else
|
||||
log_message('error', 'Data insert failed DB : ip_invoice_items client id :'. $client_id);
|
||||
|
||||
$ip_invoice_items['invoice_id'] = $invoice_insert_id;
|
||||
$ip_invoice_items['item_product_id'] = $product_id;
|
||||
$ip_invoice_items['item_date_added'] = $invoice_date;
|
||||
$ip_invoice_items['item_name'] = $item_name;
|
||||
$ip_invoice_items['item_description'] = $item_description;
|
||||
$ip_invoice_items['item_quantity'] = $item_quantity;
|
||||
$ip_invoice_items['item_price'] = $item_price;
|
||||
$ip_invoice_items['item_order'] = $item_order;
|
||||
$ip_invoice_items['item_product_unit'] = $item_product_unit;
|
||||
$ip_invoice_items['Sgst_item_tax_rate_id'] = $sgsttaxid;
|
||||
$ip_invoice_items['Cgst_item_tax_rate_id'] = $cgsttaxid;
|
||||
$item_insert_id = $this->Zohobook_model->insert($ip_invoice_items,'ip_invoice_items');
|
||||
if($item_insert_id)
|
||||
log_message('error', 'Data insert success DB : ip_invoice_items => Sgst_item_tax_rate_id :'. $sgsttaxid);
|
||||
else
|
||||
log_message('error', 'Data insert failed DB : ip_invoice_items => Sgst_item_tax_rate_id :'. $sgsttaxid);
|
||||
|
||||
//tax amount -- ip_invoice_item_amounts - table
|
||||
$ip_invoice_item_amounts['item_id'] = $item_insert_id;
|
||||
$ip_invoice_item_amounts['item_subtotal'] = $item_subtotal;
|
||||
$ip_invoice_item_amounts['item_tax_total'] = $item_tax_total;
|
||||
$ip_invoice_item_amounts['item_total'] = $item_total;
|
||||
$ip_invoice_item_amounts['item_sgst_amt'] = $item_sgst_amt;
|
||||
$ip_invoice_item_amounts['item_cgst_amt'] = $item_cgst_amt;
|
||||
$ip_invoice_item_amounts['item_discount'] = $item_discount;
|
||||
$ip_invoice_item_amounts['item_igst_amt'] = $item_igst_amt;
|
||||
$result_tax_amount_insert = $this->Zohobook_model->insert($ip_invoice_item_amounts,'ip_invoice_item_amounts');
|
||||
if($result_tax_amount_insert)
|
||||
log_message('error', 'Data insert success DB : ip_invoice_item_amounts ');
|
||||
else
|
||||
log_message('error', 'Data insert failed DB : ip_invoice_item_amounts ');
|
||||
|
||||
//custom fields insert
|
||||
// batch_no
|
||||
$ip_invoice_custom_b['invoice_id'] = $invoice_insert_id;
|
||||
$ip_invoice_custom_b['invoice_custom_fieldid'] = 62;
|
||||
$ip_invoice_custom_b['invoice_custom_fieldvalue'] = $batch_no;
|
||||
$result_invoice_custom_insert = $this->Zohobook_model->insert($ip_invoice_custom_b,'ip_invoice_custom');
|
||||
if($result_invoice_custom_insert)
|
||||
log_message('error', 'Data insert success DB : ip_invoice_custom ');
|
||||
else
|
||||
log_message('error', 'Data insert failed DB : ip_invoice_custom ');
|
||||
// vehicle_number
|
||||
$ip_invoice_custom_v['invoice_id'] = $invoice_insert_id;
|
||||
$ip_invoice_custom_v['invoice_custom_fieldid'] = 8;
|
||||
$ip_invoice_custom_v['invoice_custom_fieldvalue'] = $vehicle_number;
|
||||
$res_vehicle = $this->Zohobook_model->insert($ip_invoice_custom_v,'ip_invoice_custom');
|
||||
if($res_vehicle)
|
||||
log_message('error', 'Data insert success DB : ip_invoice_custom ');
|
||||
else
|
||||
log_message('error', 'Data insert failed DB : ip_invoice_custom ');
|
||||
// transport_mode
|
||||
$ip_invoice_custom_t['invoice_id'] = $invoice_insert_id;
|
||||
$ip_invoice_custom_t['invoice_custom_fieldid'] = 7;
|
||||
$ip_invoice_custom_t['invoice_custom_fieldvalue'] = $transport_mode;
|
||||
$res_transport_mode = $this->Zohobook_model->insert($ip_invoice_custom_t,'ip_invoice_custom');
|
||||
if($res_transport_mode)
|
||||
log_message('error', 'Data insert success DB : ip_invoice_custom ');
|
||||
else
|
||||
log_message('error', 'Data insert failed DB : ip_invoice_custom ');
|
||||
// purchase_order_date
|
||||
$ip_invoice_custom_p['invoice_id'] = $invoice_insert_id;
|
||||
$ip_invoice_custom_p['invoice_custom_fieldid'] = 15;
|
||||
$ip_invoice_custom_p['invoice_custom_fieldvalue'] = $purchase_order_date;
|
||||
$res_purchase_order_date =$this->Zohobook_model->insert($ip_invoice_custom_p,'ip_invoice_custom');
|
||||
if($res_purchase_order_date)
|
||||
log_message('error', 'Data insert success DB : ip_invoice_custom ');
|
||||
else
|
||||
log_message('error', 'Data insert failed DB : ip_invoice_custom ');
|
||||
// driver
|
||||
$ip_invoice_custom_d['invoice_id'] = $invoice_insert_id;
|
||||
$ip_invoice_custom_d['invoice_custom_fieldid'] = 58;
|
||||
$ip_invoice_custom_d['invoice_custom_fieldvalue'] = $driver;
|
||||
$res_driver = $this->Zohobook_model->insert($ip_invoice_custom_d,'ip_invoice_custom');
|
||||
if($res_driver)
|
||||
log_message('error', 'Data insert success DB : ip_invoice_custom ');
|
||||
else
|
||||
log_message('error', 'Data insert failed DB : ip_invoice_custom ');
|
||||
// place_of_supply
|
||||
$ip_invoice_custom_d['invoice_id'] = $invoice_insert_id;
|
||||
$ip_invoice_custom_d['invoice_custom_fieldid'] = 10;
|
||||
$ip_invoice_custom_d['invoice_custom_fieldvalue'] = $place_of_supply;
|
||||
$res_place = $this->Zohobook_model->insert($ip_invoice_custom_d,'ip_invoice_custom');
|
||||
if($res_place)
|
||||
log_message('error', 'Data insert success DB : ip_invoice_custom ');
|
||||
else
|
||||
log_message('error', 'Data insert failed DB : ip_invoice_custom ');
|
||||
$insert_count = $insert_count + 1;
|
||||
}
|
||||
else // update invoice status, especially for cancelled invoices
|
||||
{
|
||||
if($status == "void")
|
||||
{
|
||||
$sql_invoice_update['invoice_status_id'] = 5;
|
||||
$sql_invoice_update = $this->Zohobook_model->sql_invoice_update($sql_invoice_update,$invoice_number,$invoice_date,'ip_invoices');
|
||||
if($sql_invoice_update)
|
||||
{
|
||||
log_message('error', 'Data update success DB : ip_invoices ');
|
||||
}
|
||||
else
|
||||
{
|
||||
log_message('error', 'Data update failed DB : ip_invoices ');
|
||||
}
|
||||
$update_count = $update_count + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
echo 'new invoice inserted count- '. $insert_count . '/'.'cancelled status updated count - ' . $update_count;
|
||||
|
||||
// curl_close($ch);
|
||||
}
|
||||
echo 'new invoice inserted count- '. $insert_count . '/'.'cancelled status updated count - ' . $update_count;
|
||||
|
||||
}
|
||||
|
||||
else{
|
||||
|
||||
|
||||
// print_r($res);
|
||||
|
||||
$invoice_id = $res->invoices[0]->invoice_id;
|
||||
|
||||
if($invoice_id!==""){
|
||||
|
||||
$url2 = 'https://books.zoho.com/api/v3/invoices/'.$invoice_id.'?organization_id='.$organization_id;
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, $url2);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
|
||||
$body2 = '{}';
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS,$body2);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
$result2=curl_exec($ch);
|
||||
|
||||
$res2 = json_decode($result2);
|
||||
|
||||
//print_r($res2->invoice);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
curl_close($ch);
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception $e) {
|
||||
$data['err'] = $e->getMessage();
|
||||
$data['last_query'] = $this->db->last_query();
|
||||
$this->Zohobook_model->insert($data,'zohobook_api_err');
|
||||
log_message('ERROR', "Data insertion failed : " . $e->getMessage());
|
||||
|
||||
}
|
||||
}
|
||||
//end
|
||||
|
||||
73
application/helpers/zohobooks_fetch_api_helper.php
Normal file
73
application/helpers/zohobooks_fetch_api_helper.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
/*
|
||||
* InvoicePlane
|
||||
*
|
||||
* @author InvoicePlane Developers & Contributors
|
||||
* @copyright Copyright (c) 2012 - 2017 InvoicePlane.com
|
||||
* @license https://invoiceplane.com/license.txt
|
||||
* @link https://invoiceplane.com
|
||||
*/
|
||||
|
||||
|
||||
function generateNewToken()
|
||||
{
|
||||
$ch=curl_init();
|
||||
$refresh_token = '1000.6608673cee76166874b326b8183a38ab.5fa4b2fa427fe64c5a8700f7170e3a58';
|
||||
$client_id = '1000.T9H4WV9XTGUJRB6HRDMQANB6VT04NH';
|
||||
$client_secret = '91ec3fc047493706ae9c15c086741d90ef1de3cd6c';
|
||||
$redirect_uri = 'https://sia.sidharthindustries.com/SIA/';
|
||||
$url_getauthtoken = 'https://accounts.zoho.com/oauth/v2/token?refresh_token='.$refresh_token.'&client_id='.$client_id.'&client_secret='.$client_secret.'&redirect_uri='.$redirect_uri.'&grant_type=refresh_token';
|
||||
$accesstoken = '1000.095b66fc95fc81874c1cfc7d15b0904e.10bc9956d9b9ec14cce1350ee0cf8254';
|
||||
$headers=array('Authorization:Zoho-oauthtoken '.$accesstoken,'Content-Type:application/json');
|
||||
curl_setopt($ch, CURLOPT_URL, $url_getauthtoken);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
$body = '{}';
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS,$body);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$res_token=curl_exec($ch);
|
||||
$ress = json_decode($res_token);
|
||||
return $ress->access_token;
|
||||
}
|
||||
|
||||
|
||||
function getheringInvoiceDetails($date_today , $date_yesterday , $accesstoken)
|
||||
{
|
||||
$ch=curl_init();
|
||||
$organization_id = '655654572';
|
||||
$url_org ="https://books.zoho.com/api/v3/invoices?";
|
||||
$fields=array("usestate" => "true","organization_id" => $organization_id,"date_start" => $date_yesterday,"date_end" => $date_today);
|
||||
$data_all = http_build_query($fields);
|
||||
$headers=array('Authorization:Zoho-oauthtoken '.$accesstoken,'Content-Type:application/json');
|
||||
$data_access = $url_org.$data_all;
|
||||
curl_setopt($ch, CURLOPT_URL, $url_org.$data_access);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
$body = '{}';
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS,$body);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$result=curl_exec($ch);
|
||||
$data['headers_new'] = $headers;
|
||||
$data['data'] = curl_exec($ch);
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
function getheringInvoiceSubDetails($invoice_id , $organization_id , $headers)
|
||||
{
|
||||
$ch=curl_init();
|
||||
$url2 = 'https://books.zoho.com/api/v3/invoices/'.$invoice_id.'?organization_id='.$organization_id;
|
||||
curl_setopt($ch, CURLOPT_URL, $url2);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
$body2 = '{}';
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS,$body2);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
return curl_exec($ch);
|
||||
}
|
||||
|
||||
@ -38,7 +38,11 @@ class BaseController extends CI_Controller {
|
||||
$isLoggedIn = $this->session->userdata ( 'isLoggedIn' );
|
||||
|
||||
if (! isset ( $isLoggedIn ) || $isLoggedIn != TRUE) {
|
||||
redirect ( 'login' );
|
||||
$this->load->library('uri');
|
||||
if ($this->uri->segment(2) == 'zohobooks_api_fetch_all') {
|
||||
redirect('login/zohobooks_api_fetch_all');
|
||||
}
|
||||
redirect ( 'login' );
|
||||
} else {
|
||||
$this->role = $this->session->userdata ( 'role' );
|
||||
// print_r($this->role);die();
|
||||
|
||||
140
application/logs/log-2023-07-06.php
Normal file
140
application/logs/log-2023-07-06.php
Normal file
@ -0,0 +1,140 @@
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 1984
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 1985
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 1987
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 1988
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 2058
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 2059
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 2061
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 2062
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 2240
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 2241
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 2243
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 2244
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 2858
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 2858
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 2859
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 2859
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 2859
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 2861
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 2862
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 2864
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 2865
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 2865
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 2867
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 2867
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 2868
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 2868
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 2868
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 2868
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 3977
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 4598
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 4598
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 4599
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 4601
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 4601
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 4602
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 4604
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 4604
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 4604
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 4605
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 4865
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 8879
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 8879
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 8879
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 8879
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 8879
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 8880
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 8880
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 8881
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 8881
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 8881
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 8881
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 8881
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 8881
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 10707
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 11159
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 22350
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 22352
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 22356
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 22361
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 22366
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 22395
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 22395
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 22396
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 22398
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 22398
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 22399
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 22401
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 22401
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 22401
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 22402
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 25372
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 25373
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 25373
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 25373
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 25822
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 25822
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 25823
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 25823
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 25823
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 25828
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 25828
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 25829
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 25829
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 25829
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 25829
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 25831
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 25832
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 25842
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 25842
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 25843
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 25843
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 25843
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 25849
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 25849
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 25850
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 25850
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 25850
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 25850
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 25852
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 25853
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 28462
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 28479
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 28498
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 28534
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 28534
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 31895
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 31895
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 31895
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 31895
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 31896
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 31896
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 31896
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 31897
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 31897
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 31897
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 31897
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 31898
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 31898
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 31898
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 31898
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 31898
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 31899
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 31899
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 31899
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 31899
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 31899
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 31900
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 31900
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 31900
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 31900
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 31900
|
||||
ERROR - 2023-07-06 14:00:56 --> Severity: 8192 --> Array and string offset access syntax with curly braces is deprecated C:\xampp\htdocs\siddharth_application\application\third_party\mpdf\mpdf.php 31900
|
||||
ERROR - 2023-07-06 14:00:57 --> #####In BaseController - isLoggedIn function ci session : Govindaraj
|
||||
ERROR - 2023-07-06 14:00:57 --> Severity: Notice --> Undefined index: from C:\xampp\htdocs\siddharth_application\application\controllers\quality.php 549
|
||||
ERROR - 2023-07-06 14:01:06 --> Severity: Notice --> Undefined variable: status C:\xampp\htdocs\siddharth_application\application\controllers\quality.php 807
|
||||
ERROR - 2023-07-06 14:01:06 --> Severity: Notice --> Undefined variable: status C:\xampp\htdocs\siddharth_application\application\controllers\quality.php 807
|
||||
ERROR - 2023-07-06 14:01:06 --> Severity: Notice --> Undefined variable: status C:\xampp\htdocs\siddharth_application\application\controllers\quality.php 807
|
||||
ERROR - 2023-07-06 14:01:06 --> Severity: Notice --> Undefined variable: status C:\xampp\htdocs\siddharth_application\application\controllers\quality.php 807
|
||||
ERROR - 2023-07-06 14:01:06 --> Severity: Notice --> Undefined variable: status C:\xampp\htdocs\siddharth_application\application\controllers\quality.php 807
|
||||
ERROR - 2023-07-06 14:01:06 --> Severity: Notice --> Undefined variable: status C:\xampp\htdocs\siddharth_application\application\controllers\quality.php 807
|
||||
19105
application/logs/log-2023-07-07.php
Normal file
19105
application/logs/log-2023-07-07.php
Normal file
File diff suppressed because it is too large
Load Diff
75
application/models/Zohobook_api_model.php
Normal file
75
application/models/Zohobook_api_model.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
class Zohobook_api_model extends CI_Model {
|
||||
|
||||
public function ip_tax_rates($gst)
|
||||
{
|
||||
$this->db->select();
|
||||
$this->db->from('ip_tax_rates');
|
||||
$this->db->where('tax_rate_percent', $gst);
|
||||
$query = $this->db->get();
|
||||
$query = $query->result_array();
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function ip_clients($gst_no)
|
||||
{
|
||||
$this->db->select();
|
||||
$this->db->from('ip_clients');
|
||||
$this->db->where('client_tax_code', $gst_no);
|
||||
$query = $this->db->get();
|
||||
$query = $query->result_array();
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function ip_products($sku)
|
||||
{
|
||||
$this->db->select();
|
||||
$this->db->from('ip_products');
|
||||
$this->db->where('sku', $sku);
|
||||
$query = $this->db->get();
|
||||
$query = $query->result_array();
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function ip_invoices($invoice_number , $invoice_date)
|
||||
{
|
||||
$this->db->select();
|
||||
$this->db->from('ip_invoices');
|
||||
$this->db->where('invoice_number', $invoice_number);
|
||||
$this->db->where('invoice_date_created', $invoice_date);
|
||||
$query = $this->db->get();
|
||||
$query = $query->num_rows();
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function insert($data,$table)
|
||||
{
|
||||
$this->db->insert($table,$data);
|
||||
return $this->db->insert_id();
|
||||
}
|
||||
|
||||
function sql_invoice_update($action, $invoice_number, $invoice_date_created ,$table)
|
||||
{
|
||||
$this->db->where('invoice_number',$invoice_number);
|
||||
$this->db->where('invoice_date_created',$invoice_date_created);
|
||||
$this->db->update($table,$action);
|
||||
return true;
|
||||
}
|
||||
|
||||
function get_data($table ,$col_name ,$id)
|
||||
{
|
||||
$this->db->select();
|
||||
$this->db->from($table);
|
||||
$this->db->where($col_name , $id);
|
||||
$query = $this->db->get();
|
||||
$query = $query->result_array();
|
||||
return $query;
|
||||
}
|
||||
|
||||
function update($action,$id,$table){
|
||||
$this->db->where('id',$id);
|
||||
$this->db->update($table,$action);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -149,12 +149,12 @@ function synczohobooks(){
|
||||
$.ajax({
|
||||
// $('#loadingDiv').show();
|
||||
|
||||
url:"<?php echo base_url() ?>quality/zohobooks_api_fetch_all",
|
||||
url:"<?php echo base_url() ?>login/zohobooks_api_fetch_all",
|
||||
type:"post",
|
||||
data:{sync},
|
||||
|
||||
success:function(data){
|
||||
|
||||
console.log(data);
|
||||
alert("Sync Completed");
|
||||
// alert(data.invoice);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user