by kev1n » Tue Apr 15, 2025 6:51 pm
Hi,
If we assume that an order must be saved before an invoice can be created, then a PHP procedure could be implemented to first insert a record into the factuur table and then add the corresponding items into the factuuritem table.
The "Create Invoice (factuur)" button would trigger a PHP procedure (e.g. with code create_invoice):
Here's an example of what the
create_invoice procedure might look like
Code: Select all
// Create record in factuur:
$insertSql = "
INSERT INTO `factuur` (
`factuur_id`,
`factuur_order_id`,
`factuur_nummer`,
`factuur_opmerking`,
`factuur_datum`
) VALUES (
:factuur_id,
:factuur_order_id,
:factuur_nummer,
:factuur_opmerking,
:factuur_datum
)
";
$orderId = nuID();
$data = [
"factuur_id" => $orderId,
"factuur_order_id" => 12345, // or some incrementing number etc.
"factuur_nummer" => 'INV-2025-001',
"factuur_opmerking" => '....',
"factuur_datum" => date("Y-m-d")
];
nuRunQuery($insertSql, $data, true);
// More code here ....
// Loop through orders_items and add create the order items in factuuritem....
// Finally open the form "COMPANY_Tabel_Factuur"
$js = "nuForm('67f53db73d013a8', '$orderId', '', '', '2');";
nuJavaScriptCallback($js);
Hi,
If we assume that an order must be saved before an invoice can be created, then a PHP procedure could be implemented to first insert a record into the factuur table and then add the corresponding items into the factuuritem table.
The "Create Invoice (factuur)" button would trigger a PHP procedure (e.g. with code create_invoice):
[code]nuRunPHPHidden('create_invoice');
[/code]
Here's an example of what the [i]create_invoice[/i] procedure might look like
[code]// Create record in factuur:
$insertSql = "
INSERT INTO `factuur` (
`factuur_id`,
`factuur_order_id`,
`factuur_nummer`,
`factuur_opmerking`,
`factuur_datum`
) VALUES (
:factuur_id,
:factuur_order_id,
:factuur_nummer,
:factuur_opmerking,
:factuur_datum
)
";
$orderId = nuID();
$data = [
"factuur_id" => $orderId,
"factuur_order_id" => 12345, // or some incrementing number etc.
"factuur_nummer" => 'INV-2025-001',
"factuur_opmerking" => '....',
"factuur_datum" => date("Y-m-d")
];
nuRunQuery($insertSql, $data, true);
// More code here ....
// Loop through orders_items and add create the order items in factuuritem....
// Finally open the form "COMPANY_Tabel_Factuur"
$js = "nuForm('67f53db73d013a8', '$orderId', '', '', '2');";
nuJavaScriptCallback($js);[/code]