commit 7c71c6506d5ecc1aae0ae22169d19b0cf09a912b Author: Kumi Date: Wed Aug 25 19:27:25 2021 +0200 Development version, definitely unstable and insecure... diff --git a/apply.php b/apply.php new file mode 100644 index 0000000..521c400 --- /dev/null +++ b/apply.php @@ -0,0 +1,44 @@ +description; + $prices[] = $billable->amount; + $taxed[] = true; + } + + print_r($billables); + print_r($prices); + print_r($taxed); + + $result = localAPI("UpdateInvoice", array( + 'invoiceid' => $_POST["invoiceid"], + 'newitemdescription' => $billables, + 'newitemamount' => $prices, + 'newitemtaxed' => $taxed + )); + + if (!$result["result"] == "success") { + die("Could not apply billables to invoice."); + } + + foreach ($_POST["billable"] as $billableid) { + incrementBillableInvoices($billableid); + } + + header("Location: /admin/invoices.php?action=edit&id=" . $_POST["invoiceid"]); + +} else { + die(); +} diff --git a/functions.php b/functions.php new file mode 100644 index 0000000..66a0be0 --- /dev/null +++ b/functions.php @@ -0,0 +1,32 @@ +where("userid", $userid); + + if (!$invoiced) { + $billables = $billables->where("invoicecount", 0); + } + + $billables = $billables->get(); + + return $billables; +} + +function getBillable($billableid) { + $billables = Capsule::table('tblbillableitems') + ->where("id", $billableid) + ->get(); + + foreach ($billables as $billable) { + return $billable; + } +} + +function incrementBillableInvoices($billableid) { + Capsule::table('tblbillableitems') + ->where("id", $billableid) + ->increment("invoicecount"); +} \ No newline at end of file diff --git a/hooks.php b/hooks.php new file mode 100644 index 0000000..2f94ed6 --- /dev/null +++ b/hooks.php @@ -0,0 +1,59 @@ +'); + print(''); +}); diff --git a/whmcs_apply_billables.php b/whmcs_apply_billables.php new file mode 100644 index 0000000..1a443fb --- /dev/null +++ b/whmcs_apply_billables.php @@ -0,0 +1,13 @@ + 'Apply Billables to Invoices', + 'APIVersion' => '1.1' + ); +}