Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
o-psi committed Feb 27, 2024
1 parent 129fbd3 commit 02ebe84
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
6 changes: 3 additions & 3 deletions credits.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
?>

<tr>
<td><?php echo $client_name; ?></td>
<td><a href="client_overview.php?client_id=<?php echo $credit_client_id; ?>"><?php echo $client_name; ?></a>
<td><?php echo $account_name; ?></td>
<td class="text-right
<?php if ($sort == "credit_amount") { echo "sorting-$order"; } ?>">
Expand All @@ -151,9 +151,9 @@
<td><?php echo $credit_date; ?></td>
<td><?php echo $credit_reference; ?></td>
<td>
<a href="post.php?apply_credit_id=<?php echo $credit_id; ?>" class="btn btn-sm btn-primary"
<a href="post.php?apply_credit=<?php echo $credit_id; ?>" class="btn btn-sm btn-primary"
title="Apply"><i class="fas fa-credit-card"></i></a>
<a href="post.php?delete_credit_id=<?php echo $credit_id; ?>" class="btn btn-sm btn-danger"
<a href="post.php?delete_credit=<?php echo $credit_id; ?>" class="btn btn-sm btn-danger"
title="Delete"><i class="fas fa-trash"></i></a>
</td>
</tr>
Expand Down
5 changes: 5 additions & 0 deletions inc_all_client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 6 additions & 7 deletions post/invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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";
Expand Down

0 comments on commit 02ebe84

Please sign in to comment.