diff --git a/credits.php b/credits.php index 1da307d0c..49e3ea4e4 100644 --- a/credits.php +++ b/credits.php @@ -142,7 +142,7 @@ ?> - + "> @@ -151,9 +151,9 @@ - - diff --git a/inc_all_client.php b/inc_all_client.php index e5d693be4..b4b0d3b44 100644 --- a/inc_all_client.php +++ b/inc_all_client.php @@ -89,6 +89,11 @@ // Get Balance $balance = getClientBalance($mysqli, $client_id, $credits = true); + // Get Amount Paid + $sql_amount_paid = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS amount_paid FROM payments, invoices WHERE payment_invoice_id = invoice_id AND invoice_client_id = $client_id"); + $row = mysqli_fetch_array($sql_amount_paid); + $amount_paid = floatval($row['amount_paid']); + //Get Monthly Recurring Total $sql_recurring_monthly_total = mysqli_query($mysqli, "SELECT SUM(recurring_amount) AS recurring_monthly_total FROM recurring WHERE recurring_status = 1 AND recurring_frequency = 'month' AND recurring_client_id = $client_id"); $row = mysqli_fetch_array($sql_recurring_monthly_total); diff --git a/post/invoice.php b/post/invoice.php index 69647197d..e2dfa7f17 100644 --- a/post/invoice.php +++ b/post/invoice.php @@ -91,7 +91,7 @@ //Generate a unique URL key for clients to access $url_key = randomString(156); - mysqli_query($mysqli,"INSERT INTO invoices SET invoice_prefix = '$config_invoice_prefix', invoice_number = $invoice_number, invoice_scope = '$invoice_scope', invoice_date = '$date', invoice_due = DATE_ADD('$date', INTERVAL $client_net_terms day), invoice_category_id = $category_id, invoice_status = 'Draft', invoice_amount = $invoice_amount, invoice_currency_code = '$invoice_currency_code', invoice_note = '$invoice_note', invoice_url_key = '$url_key', invoice_client_id = $client_id") or die(mysql_error()); + mysqli_query($mysqli,"INSERT INTO invoices SET invoice_prefix = '$config_invoice_prefix', invoice_number = $invoice_number, invoice_scope = '$invoice_scope', invoice_date = '$date', invoice_due = DATE_ADD('$date', INTERVAL $client_net_terms day), invoice_category_id = $category_id, invoice_status = 'Draft', invoice_amount = $invoice_amount, invoice_currency_code = '$invoice_currency_code', invoice_note = '$invoice_note', invoice_url_key = '$url_key', invoice_client_id = $client_id"); $new_invoice_id = mysqli_insert_id($mysqli); @@ -1439,9 +1439,8 @@ header("Location: post.php?add_ticket_to_invoice=$invoice_id"); } -if (isset($_POST['apply_credit_id'])) { - - $credit_id = intval($_POST['apply_credit_id']); +if (isset($_GET['apply_credit_id'])) { + $credit_id = intval($_GET['apply_credit_id']); $credit_sql = mysqli_query($mysqli,"SELECT * FROM credits WHERE credit_id = $credit_id"); $credit_row = mysqli_fetch_array($credit_sql); @@ -1570,9 +1569,9 @@ header("Location: " . $_SERVER["HTTP_REFERER"]); } -if (isset($_POST['delete_credit_id'])) { - $credit_id = intval($_POST['delete_credit_id']); - +if (isset($_GET['delete_credit'])) { + $credit_id = intval($_GET['delete_credit']); + mysqli_query($mysqli,"DELETE FROM credits WHERE credit_id = $credit_id"); $_SESSION['alert_message'] = "Credit deleted";