From 0a65cdab3453a50008803d3bbb3b69860787fca1 Mon Sep 17 00:00:00 2001 From: arf20 Date: Thu, 6 Nov 2025 23:37:25 +0100 Subject: Don't send invoices for 0€ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- makeinvoices.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'makeinvoices.php') diff --git a/makeinvoices.php b/makeinvoices.php index f4f02e8..f9ef030 100644 --- a/makeinvoices.php +++ b/makeinvoices.php @@ -145,14 +145,19 @@ if ($_SERVER["REQUEST_METHOD"] == "GET") { foreach ($clients as $client) { $ret = generate_pdf($client, array_filter($dueorders, function($e) { global $client; return $e["client"] == $client["id"]; })); + $param_amount = $ret[1]; + + if ($param_amount == 0.0) + continue; + $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 { -- cgit v1.2.3