diff options
author | arf20 <aruizfernandez05@gmail.com> | 2024-03-24 01:41:55 +0100 |
---|---|---|
committer | arf20 <aruizfernandez05@gmail.com> | 2024-03-24 01:41:55 +0100 |
commit | 8a1f665f1ff9c5084b9c6372d21b49e8a36713b3 (patch) | |
tree | c21fa06a72ee9fb7147e4fb16d02a77b6f29000d /makeinvoices.php | |
parent | 0c86e53fb5d51ae1c853226ebc6673dbca17deca (diff) | |
download | arfnet2-cstims-8a1f665f1ff9c5084b9c6372d21b49e8a36713b3.tar.gz arfnet2-cstims-8a1f665f1ff9c5084b9c6372d21b49e8a36713b3.zip |
Invoice management
Diffstat (limited to 'makeinvoices.php')
-rw-r--r-- | makeinvoices.php | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/makeinvoices.php b/makeinvoices.php index 2060b13..a12ef5c 100644 --- a/makeinvoices.php +++ b/makeinvoices.php @@ -88,10 +88,20 @@ $fdom = new DateTime('first day of this month'); $ldom = new DateTime('last day of this month'); foreach ($clients as $client) { - generate_pdf($client, array_filter($dueorders, function($e) { global $client; return $e["client"] == $client["id"]; })); -} - + $ret = generate_pdf($client, array_filter($dueorders, function($e) { global $client; return $e["client"] == $client["id"]; })); + $sql = "INSERT INTO invoices (client, `desc`, amount, pdf) VALUES (?, ?, ?, ?)"; + $stmt = mysqli_prepare($link, $sql); + mysqli_stmt_bind_param($stmt, "ssss", $param_client, $param_desc, $param_amount, $param_pdf); + $param_client = $client["id"]; + $param_desc = "Monthly invoice"; + $param_amount = $ret[1]; + $param_pdf = $ret[0]; + + if (!mysqli_stmt_execute($stmt) || (mysqli_stmt_affected_rows($stmt) != 1)) { + echo "SQL error."; + } else echo $client["id"]." ok ".$ret[1]."\n"; +} function getservicebyid($id) { @@ -197,7 +207,7 @@ function generate_pdf($client, $dueorders) { $pdf->ColoredTable($theader, $columnsw, $columnsal, $tdata, true); - $pdf->Output('invoice.pdf', 'I'); + return array($pdf->Output('invoice.pdf', 'S'), $subtotal); } ?>
\ No newline at end of file |