|
@@ -12,28 +12,27 @@ function get_grace() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
add_hook('InvoiceCreation', 1, function($vars) {
|
|
add_hook('InvoiceCreation', 1, function($vars) {
|
|
|
- $grace = get_grace();
|
|
|
|
|
$invoice = localAPI('GetInvoice', ['invoiceid' => $vars['invoiceid']]);
|
|
$invoice = localAPI('GetInvoice', ['invoiceid' => $vars['invoiceid']]);
|
|
|
if($invoice['duedate'] == $invoice['date']) {
|
|
if($invoice['duedate'] == $invoice['date']) {
|
|
|
|
|
+ $grace = get_grace();
|
|
|
array_shift($invoice);
|
|
array_shift($invoice);
|
|
|
$dateTime = date_create($invoice['duedate']);
|
|
$dateTime = date_create($invoice['duedate']);
|
|
|
date_add($dateTime,date_interval_create_from_date_string("$grace days"));
|
|
date_add($dateTime,date_interval_create_from_date_string("$grace days"));
|
|
|
$invoice['duedate'] = date_format($dateTime, 'Y-m-d');
|
|
$invoice['duedate'] = date_format($dateTime, 'Y-m-d');
|
|
|
$result = localAPI('UpdateInvoice', $invoice);
|
|
$result = localAPI('UpdateInvoice', $invoice);
|
|
|
|
|
+ if($result['result'] == 'success') {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ logModuleCall(
|
|
|
|
|
+ 'InvoiceCreation',
|
|
|
|
|
+ __FUNCTION__,
|
|
|
|
|
+ $result,
|
|
|
|
|
+ "Hook Error",
|
|
|
|
|
+ $invoice
|
|
|
|
|
+ );
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
- if($result['result'] == 'success') {
|
|
|
|
|
- return true;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- logModuleCall(
|
|
|
|
|
- 'InvoiceCreation',
|
|
|
|
|
- __FUNCTION__,
|
|
|
|
|
- $result,
|
|
|
|
|
- "Hook Error",
|
|
|
|
|
- $invoice
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- return false;
|
|
|
|
|
|
|
+ return true;
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
?>
|
|
?>
|