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 --- admin.php | 12 ++++++------ client.php | 8 ++++---- dbinit.sql | 1 + manageinvoices.php | 52 ++++++++++++++++++++++++++++++++++++++++++---------- manageorders.php | 4 ++-- manageservices.php | 4 ++-- managetickets.php | 4 ++-- manageusers.php | 4 ++-- openticket.php | 4 ++-- order.php | 4 ++-- 10 files changed, 65 insertions(+), 32 deletions(-) diff --git a/admin.php b/admin.php index eaa0f62..b0b37c3 100644 --- a/admin.php +++ b/admin.php @@ -155,12 +155,12 @@ function getorderbyid($id) {

Logged as

-

Logout

-

Manage users

-

Manage services

-

Manage orders

-

Manage tickets

-

Manage invoices

+

Logout

+

Manage users

+

Manage services

+

Manage orders

+

Manage tickets

+

Manage invoices

diff --git a/client.php b/client.php index a17084d..c96d8cf 100644 --- a/client.php +++ b/client.php @@ -102,10 +102,10 @@ function getorderbyid($id) {

Logged as

-

Logout

-

Order a new service

-

Open ticket

-

Payment methods

+

Logout

+

Order a new service

+

Open ticket

+

Payment methods

diff --git a/dbinit.sql b/dbinit.sql index f3476d9..0b2930c 100644 --- a/dbinit.sql +++ b/dbinit.sql @@ -52,6 +52,7 @@ CREATE TABLE `arfnet2`.`invoices` ( `amount` DECIMAL(10, 4) NOT NULL , `pdf` MEDIUMBLOB NOT NULL , `date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , + `proof` MEDIUMBLOB DEFAULT NULL , `status` ENUM('paid','unpaid') NOT NULL DEFAULT 'unpaid' , PRIMARY KEY (`id`) ); 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) { diff --git a/manageorders.php b/manageorders.php index 565ef91..a307adf 100644 --- a/manageorders.php +++ b/manageorders.php @@ -183,8 +183,8 @@ function getclientbyid($id) { diff --git a/manageservices.php b/manageservices.php index fe68c81..a69f4e6 100644 --- a/manageservices.php +++ b/manageservices.php @@ -138,8 +138,8 @@ function getservicebyid($id) { diff --git a/managetickets.php b/managetickets.php index 66c5b13..10f90d7 100644 --- a/managetickets.php +++ b/managetickets.php @@ -209,8 +209,8 @@ function getuserbyid($id) { diff --git a/manageusers.php b/manageusers.php index 7d4044d..f93788d 100644 --- a/manageusers.php +++ b/manageusers.php @@ -146,8 +146,8 @@ function getuserbyid($id) { diff --git a/openticket.php b/openticket.php index 6269120..3c3bf7f 100644 --- a/openticket.php +++ b/openticket.php @@ -152,8 +152,8 @@ function getorderbyid($id) { diff --git a/order.php b/order.php index 5e5675a..c51fce2 100644 --- a/order.php +++ b/order.php @@ -178,8 +178,8 @@ function genoption($id, $name) { -- cgit v1.2.3
idclientdescriptionamountdatepdfstatusaction
idclientdescriptionamountdatepdfstatusproofaction
".$invoice["id"]."".$invoice["date"]."pdf".$invoice["status"]."pdfdel edit