Created
December 30, 2022 09:15
-
-
Save finalwebsites/26f0ec7d66df6209e583df6c217f326b to your computer and use it in GitHub Desktop.
EFD getinvoicelist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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