Skip to content

Instantly share code, notes, and snippets.

@finalwebsites
Created December 30, 2022 09:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save finalwebsites/26f0ec7d66df6209e583df6c217f326b to your computer and use it in GitHub Desktop.
Save finalwebsites/26f0ec7d66df6209e583df6c217f326b to your computer and use it in GitHub Desktop.
EFD getinvoicelist
<?php
function getInvoices($contact, $page = 0) {
global $link, $api, $today, $year_ago;
$filters = array(
'contact_id' => $contact,
'is_sent' => 1,
'invoice_date' => array($year_ago, $today)
);
//print_r($filters);
$resp = $api->getInvoicesList(
$filters,
$page,
10
);
//die(print_r($resp));
if (empty($resp['results'])) return;
foreach ($resp['results'] as $row) {
$sql = sprintf("INSERT INTO invoices SET ID = %d, cust_id = %d, invoice_date = '%s', invoice_number = '%s', total = %f", $row['id'], $row['contact_id'], date('Y-m-d', strtotime($row['invoice_date'])), mysqli_real_escape_string($link, $row['invoice_number']), $row['invoice_total']);
mysqli_query($link, $sql);
}
if ($page == 0) return $resp['total_count_in_db'];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment