From 50464559aa522ce04222cebcee3cc6a115aa2902 Mon Sep 17 00:00:00 2001 From: arf20 Date: Tue, 9 Apr 2024 16:20:32 +0200 Subject: Add proof of payment and fix HTML issues --- manageinvoices.php | 52 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 10 deletions(-) (limited to 'manageinvoices.php') diff --git a/manageinvoices.php b/manageinvoices.php index 56f2490..04983b3 100644 --- a/manageinvoices.php +++ b/manageinvoices.php @@ -61,6 +61,20 @@ if (isset($_GET["pdf"])) { echo $pdf; } +if (isset($_GET["proof"])) { + // Get invoice + $sql = "SELECT proof FROM invoices WHERE id = ?"; + $stmt = mysqli_prepare($link, $sql); + mysqli_stmt_bind_param($stmt, "s", $param_id); + $param_id = $_GET["proof"]; + mysqli_stmt_execute($stmt); + $result = mysqli_stmt_get_result($stmt); + $proof = $result->fetch_all(MYSQLI_ASSOC)[0]["proof"]; + header("Content-type: application/pdf"); + header("Content-Disposition: inline;filename=\"proof.pdf\""); + echo $proof; +} + // POST actions if ($_SERVER["REQUEST_METHOD"] == "POST") { // edit entry @@ -71,9 +85,25 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { $param_status = $_POST["status"]; $param_id = $_POST["id"]; - if (!mysqli_stmt_execute($stmt) || (mysqli_stmt_affected_rows($stmt) != 1)) { - echo "SQL error."; - } else header("location: ".$_SERVER['SCRIPT_NAME']); + if (!mysqli_stmt_execute($stmt)) { + die("SQL error 1."); + } + + if (isset($_FILES["proof"])) { + $proof = file_get_contents($_FILES["proof"]["tmp_name"]); + + $sql = "UPDATE invoices SET proof = ? WHERE id = ?"; + $stmt = mysqli_prepare($link, $sql); + mysqli_stmt_bind_param($stmt, "ss", $param_proof, $param_id); + $param_proof = $proof; + $param_id = $_POST["id"]; + + if (!mysqli_stmt_execute($stmt) || (mysqli_stmt_affected_rows($stmt) != 1)) { + die("SQL error 2."); + } + } + + header("location: ".$_SERVER['SCRIPT_NAME']); } } @@ -132,7 +162,7 @@ function getinvoicebyid($id) {

ARFNET Client Service Ticket and Invoice Management System

panel

-

Orders

+

Invoices

Edit invoice ".$invoice["id"]."

\n" + echo "

Edit invoice ".$invoice["id"]."

\n" ."

\n" ."

\n" ."

\n" ."

\n" ."

\n" - ."" - ."
cancel" + ."

\n" + ."\n" + ."
cancel\n" ."
"; } ?> manual invoice - + " @@ -180,6 +211,7 @@ function getinvoicebyid($id) { ."" ."" ."" + ."" ."\n"; } ?> @@ -188,8 +220,8 @@ function getinvoicebyid($id) { -- cgit v1.2.3
idclientdescriptionamountdatepdfstatusaction
idclientdescriptionamountdatepdfstatusproofaction
".$invoice["id"]."".$invoice["date"]."pdf".$invoice["status"]."pdfdel edit