mirror of
https://github.com/itflow-org/itflow
synced 2026-03-27 07:45:37 +00:00
Merge branch 'master' into ticket_notifications
This commit is contained in:
@@ -104,14 +104,15 @@ $document_parent = intval($row['document_parent']);
|
|||||||
|
|
||||||
while ($row = mysqli_fetch_array($sql_files)) {
|
while ($row = mysqli_fetch_array($sql_files)) {
|
||||||
$file_id = intval($row['file_id']);
|
$file_id = intval($row['file_id']);
|
||||||
|
$folder_id = intval($row['file_folder_id']);
|
||||||
$file_name = nullable_htmlentities($row['file_name']);
|
$file_name = nullable_htmlentities($row['file_name']);
|
||||||
|
|
||||||
$linked_files[] = $file_id;
|
$linked_files[] = $file_id;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<li>
|
<li>
|
||||||
<?php echo $file_name; ?>
|
<a href="client_files.php?client_id=<?php echo $client_id; ?>&folder_id=<?php echo $folder_id; ?>&q=<?php echo $file_name; ?>" target="_blank"><?php echo $file_name; ?><i class="fas fa-external-link-alt ml-1"></i></a>
|
||||||
<a href="post.php?unlink_file_from_document&file_id=<?php echo $file_id; ?>&document_id=<?php echo $document_id; ?>">
|
<a class="confirm-link" href="post.php?unlink_file_from_document&file_id=<?php echo $file_id; ?>&document_id=<?php echo $document_id; ?>">
|
||||||
<i class="fas fa-fw fa-times text-secondary ml-2"></i>
|
<i class="fas fa-fw fa-times text-secondary ml-2"></i>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@@ -143,8 +144,8 @@ $document_parent = intval($row['document_parent']);
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
<li>
|
<li>
|
||||||
<?php echo $contact_name; ?>
|
<a href="client_contact_details.php?client_id=<?php echo $client_id; ?>&contact_id=<?php echo $contact_id; ?>" target="_blank"><?php echo $contact_name; ?><i class="fas fa-external-link-alt ml-1"></i></a>
|
||||||
<a href="post.php?unlink_contact_from_document&contact_id=<?php echo $contact_id; ?>&document_id=<?php echo $document_id; ?>">
|
<a class="confirm-link" href="post.php?unlink_contact_from_document&contact_id=<?php echo $contact_id; ?>&document_id=<?php echo $document_id; ?>">
|
||||||
<i class="fas fa-fw fa-times text-secondary ml-2"></i>
|
<i class="fas fa-fw fa-times text-secondary ml-2"></i>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@@ -161,7 +162,7 @@ $document_parent = intval($row['document_parent']);
|
|||||||
<ul>
|
<ul>
|
||||||
<?php
|
<?php
|
||||||
$sql_assets = mysqli_query($mysqli, "SELECT * FROM assets, asset_documents
|
$sql_assets = mysqli_query($mysqli, "SELECT * FROM assets, asset_documents
|
||||||
WHERE assets.asset_id = asset_documents.asset_id
|
WHERE assets.asset_id = asset_documents.asset_id
|
||||||
AND asset_documents.document_id = $document_id
|
AND asset_documents.document_id = $document_id
|
||||||
ORDER BY asset_name ASC"
|
ORDER BY asset_name ASC"
|
||||||
);
|
);
|
||||||
@@ -176,8 +177,8 @@ $document_parent = intval($row['document_parent']);
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
<li>
|
<li>
|
||||||
<?php echo $asset_name; ?>
|
<a href="client_asset_details.php?client_id=<?php echo $client_id; ?>&asset_id=<?php echo $asset_id; ?>" target="_blank"><?php echo $asset_name; ?><i class="fas fa-external-link-alt ml-1"></i></a>
|
||||||
<a href="post.php?unlink_asset_from_document&asset_id=<?php echo $asset_id; ?>&document_id=<?php echo $document_id; ?>">
|
<a class="confirm-link" href="post.php?unlink_asset_from_document&asset_id=<?php echo $asset_id; ?>&document_id=<?php echo $document_id; ?>">
|
||||||
<i class="fas fa-fw fa-times text-secondary ml-2"></i>
|
<i class="fas fa-fw fa-times text-secondary ml-2"></i>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@@ -209,8 +210,8 @@ $document_parent = intval($row['document_parent']);
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
<li>
|
<li>
|
||||||
<?php echo $software_name; ?>
|
<a href="client_software.php?client_id=<?php echo $client_id; ?>&q=<?php echo $software_name; ?>" target="_blank"><?php echo $software_name; ?><i class="fas fa-external-link-alt ml-1"></i></a>
|
||||||
<a href="post.php?unlink_software_from_document&software_id=<?php echo $software_id; ?>&document_id=<?php echo $document_id; ?>">
|
<a class="confirm-link" href="post.php?unlink_software_from_document&software_id=<?php echo $software_id; ?>&document_id=<?php echo $document_id; ?>">
|
||||||
<i class="fas fa-fw fa-times text-secondary ml-2"></i>
|
<i class="fas fa-fw fa-times text-secondary ml-2"></i>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@@ -242,8 +243,8 @@ $document_parent = intval($row['document_parent']);
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
<li>
|
<li>
|
||||||
<?php echo $vendor_name; ?>
|
<a href="client_vendors.php?client_id=<?php echo $client_id; ?>&q=<?php echo $vendor_name; ?>" target="_blank"><?php echo $vendor_name; ?><i class="fas fa-external-link-alt ml-1"></i></a>
|
||||||
<a href="post.php?unlink_vendor_from_document&vendor_id=<?php echo $vendor_id; ?>&document_id=<?php echo $document_id; ?>">
|
<a class="confirm-link" href="post.php?unlink_vendor_from_document&vendor_id=<?php echo $vendor_id; ?>&document_id=<?php echo $document_id; ?>">
|
||||||
<i class="fas fa-fw fa-times text-secondary ml-2"></i>
|
<i class="fas fa-fw fa-times text-secondary ml-2"></i>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -288,6 +288,15 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
<li class="nav-item">
|
||||||
|
<a href="client_statement.php?client_id=<?php echo $client_id; ?>" class="nav-link <?php if (basename($_SERVER["PHP_SELF"]) == "client_statement.php") { echo "active"; } ?>">
|
||||||
|
<i class="nav-icon fas fa-file-invoice-dollar"></i>
|
||||||
|
<p>
|
||||||
|
Statement
|
||||||
|
</p>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a href="client_trips.php?client_id=<?php echo $client_id; ?>" class="nav-link <?php if (basename($_SERVER["PHP_SELF"]) == "client_trips.php") { echo "active"; } ?>">
|
<a href="client_trips.php?client_id=<?php echo $client_id; ?>" class="nav-link <?php if (basename($_SERVER["PHP_SELF"]) == "client_trips.php") { echo "active"; } ?>">
|
||||||
<i class="nav-icon fas fa-route"></i>
|
<i class="nav-icon fas fa-route"></i>
|
||||||
|
|||||||
188
client_statement.php
Normal file
188
client_statement.php
Normal file
@@ -0,0 +1,188 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
require_once "inc_all.php";
|
||||||
|
|
||||||
|
|
||||||
|
if (isset($_GET['client_id'])) {
|
||||||
|
|
||||||
|
$client_id = intval($_GET['client_id']);
|
||||||
|
|
||||||
|
$sql_client_details = "
|
||||||
|
SELECT
|
||||||
|
client_name,
|
||||||
|
client_type,
|
||||||
|
client_website,
|
||||||
|
client_net_terms
|
||||||
|
FROM
|
||||||
|
clients
|
||||||
|
WHERE
|
||||||
|
client_id = $client_id";
|
||||||
|
|
||||||
|
$result_client_details = mysqli_query($mysqli, $sql_client_details);
|
||||||
|
$row_client_details = mysqli_fetch_assoc($result_client_details);
|
||||||
|
|
||||||
|
$client_name = nullable_htmlentities($row_client_details['client_name']);
|
||||||
|
$client_type = nullable_htmlentities($row_client_details['client_type']);
|
||||||
|
$client_website = nullable_htmlentities($row_client_details['client_website']);
|
||||||
|
$client_net_terms = intval($row_client_details['client_net_terms']);
|
||||||
|
|
||||||
|
$sql_client_unpaid_invoices = "
|
||||||
|
SELECT
|
||||||
|
invoice_id,
|
||||||
|
invoice_number,
|
||||||
|
invoice_prefix,
|
||||||
|
invoice_date,
|
||||||
|
invoice_due,
|
||||||
|
invoice_amount
|
||||||
|
FROM
|
||||||
|
invoices
|
||||||
|
WHERE
|
||||||
|
invoice_client_id = $client_id
|
||||||
|
AND invoice_status NOT LIKE 'Draft'
|
||||||
|
AND invoice_status NOT LIKE 'Cancelled'
|
||||||
|
AND invoice_status NOT LIKE 'Paid'";
|
||||||
|
|
||||||
|
$result_client_unpaid_invoices = mysqli_query($mysqli, $sql_client_unpaid_invoices);
|
||||||
|
|
||||||
|
$currency_code = getSettingValue($mysqli, "company_currency");
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<ol class="breadcrumb d-print-none">
|
||||||
|
<li class="breadcrumb-item">
|
||||||
|
<a href="clients.php">Clients</a>
|
||||||
|
</li>
|
||||||
|
<li class="breadcrumb-item">
|
||||||
|
<a href="client_invoices.php?client_id=<?php echo $client_id; ?>"><?php echo $client_name; ?></a>
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
<div class="card card-dark">
|
||||||
|
<div class="card-header py-2">
|
||||||
|
<h3 class="card-title mt-2"><i class="fas fa-fw fa-balance-scale mr-2"></i>Statement for <?php echo $client_name ?></h3>
|
||||||
|
<div class="card-tools">
|
||||||
|
<button type="button" class="btn btn-primary d-print-none" onclick="window.print();"><i class="fas fa-fw fa-print mr-2"></i>Print</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card-body p-0">
|
||||||
|
<div>
|
||||||
|
<div class="table-responsive-sm">
|
||||||
|
<table class="table table-sm">
|
||||||
|
<!-- Past Due Payments -->
|
||||||
|
<thead class="text-dark">
|
||||||
|
<tr>
|
||||||
|
<th>Invoice Number</th>
|
||||||
|
<th>Date</th>
|
||||||
|
<th>Due Date</th>
|
||||||
|
<th>Amount</th>
|
||||||
|
<th>Balance</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
while ($row = mysqli_fetch_assoc($result_client_unpaid_invoices)) {
|
||||||
|
$invoice_number = intval($row['invoice_number']);
|
||||||
|
$invoice_id = intval($row['invoice_id']);
|
||||||
|
$invoice_prefix = nullable_htmlentities($row['invoice_prefix']);
|
||||||
|
$invoice_date = nullable_htmlentities($row['invoice_date']);
|
||||||
|
$invoice_amount = floatval($row['invoice_amount']);
|
||||||
|
$invoice_amount_formatted = numfmt_format_currency($currency_format, $invoice_amount, $currency_code);
|
||||||
|
$invoice_url = "invoice.php?invoice_id=$invoice_id";
|
||||||
|
$invoice_due = nullable_htmlentities($row['invoice_due']);
|
||||||
|
|
||||||
|
$invoice_balance = floatval(calculateInvoiceBalance($mysqli, $invoice_id));
|
||||||
|
$invoice_balance_formatted = numfmt_format_currency($currency_format, $invoice_balance, $currency_code);
|
||||||
|
|
||||||
|
?>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a href="<?php echo $invoice_url; ?>" target="_blank"><?php echo $invoice_prefix . $invoice_number; ?></a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?php echo $invoice_date; ?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?php echo $invoice_due; ?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?php echo $invoice_amount_formatted; ?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?php echo $invoice_balance_formatted; ?>
|
||||||
|
</td>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="table-responsive-sm">
|
||||||
|
<!-- Previous Payments -->
|
||||||
|
<table class="table table-sm">
|
||||||
|
<thead class="text-dark">
|
||||||
|
<tr>
|
||||||
|
<th>Payment Reference</th>
|
||||||
|
<th>Payment Date</th>
|
||||||
|
<th>Payment Amount</th>
|
||||||
|
<th>Invoice Number</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
$sql_client_payments = "
|
||||||
|
SELECT
|
||||||
|
payments.payment_date,
|
||||||
|
payments.payment_amount,
|
||||||
|
payments.payment_reference,
|
||||||
|
invoices.invoice_number,
|
||||||
|
invoices.invoice_prefix
|
||||||
|
FROM
|
||||||
|
payments
|
||||||
|
LEFT JOIN
|
||||||
|
invoices ON payments.payment_invoice_id = invoices.invoice_id
|
||||||
|
WHERE
|
||||||
|
payment_account_id = $client_id
|
||||||
|
AND payment_archived_at IS NULL
|
||||||
|
ORDER BY
|
||||||
|
payment_date DESC";
|
||||||
|
|
||||||
|
$result_client_payments = mysqli_query($mysqli, $sql_client_payments);
|
||||||
|
|
||||||
|
while ($row = mysqli_fetch_assoc($result_client_payments)) {
|
||||||
|
$payment_date = nullable_htmlentities($row['payment_date']);
|
||||||
|
$payment_amount = floatval($row['payment_amount']);
|
||||||
|
$payment_reference = nullable_htmlentities($row['payment_reference']);
|
||||||
|
$invoice_number = nullable_htmlentities($row['invoice_prefix'].$row['invoice_number']);
|
||||||
|
$payment_amount_formatted = numfmt_format_currency($currency_format, $payment_amount, $currency_code);
|
||||||
|
|
||||||
|
?>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<?php echo $payment_reference; ?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?php echo $payment_date; ?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?php echo $payment_amount_formatted; ?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?php echo $invoice_number; ?>
|
||||||
|
</td>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php require_once "footer.php";
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
||||||
5
debug.php
Normal file
5
debug.php
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
ini_set('display_startup_errors', 1);
|
||||||
|
error_reporting(E_ALL);
|
||||||
@@ -850,7 +850,7 @@ function calculateAccountBalance($mysqli, $account_id) {
|
|||||||
$sql_account = mysqli_query($mysqli, "SELECT * FROM accounts LEFT JOIN account_types ON accounts.account_type = account_types.account_type_id WHERE account_archived_at IS NULL AND account_id = $account_id ORDER BY account_name ASC; ");
|
$sql_account = mysqli_query($mysqli, "SELECT * FROM accounts LEFT JOIN account_types ON accounts.account_type = account_types.account_type_id WHERE account_archived_at IS NULL AND account_id = $account_id ORDER BY account_name ASC; ");
|
||||||
$row = mysqli_fetch_array($sql_account);
|
$row = mysqli_fetch_array($sql_account);
|
||||||
$opening_balance = floatval($row['opening_balance']);
|
$opening_balance = floatval($row['opening_balance']);
|
||||||
$account_id = $row['account_id'];
|
$account_id = intval($row['account_id']);
|
||||||
|
|
||||||
$sql_payments = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS total_payments FROM payments WHERE payment_account_id = $account_id");
|
$sql_payments = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS total_payments FROM payments WHERE payment_account_id = $account_id");
|
||||||
$row = mysqli_fetch_array($sql_payments);
|
$row = mysqli_fetch_array($sql_payments);
|
||||||
@@ -873,6 +873,7 @@ function calculateAccountBalance($mysqli, $account_id) {
|
|||||||
return $balance;
|
return $balance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function addToMailQueue($mysqli, $data) {
|
function addToMailQueue($mysqli, $data) {
|
||||||
$config_invoice_from_email = strval(getSettingValue($mysqli, 'config_invoice_from_email'));
|
$config_invoice_from_email = strval(getSettingValue($mysqli, 'config_invoice_from_email'));
|
||||||
$config_invoice_from_name = strval(getSettingValue($mysqli, 'config_invoice_from_name'));
|
$config_invoice_from_name = strval(getSettingValue($mysqli, 'config_invoice_from_name'));
|
||||||
@@ -887,4 +888,23 @@ function addToMailQueue($mysqli, $data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
function calculateInvoiceBalance($mysqli, $invoice_id) {
|
||||||
|
$sql_invoice = mysqli_query($mysqli, "SELECT * FROM invoices WHERE invoice_id = $invoice_id");
|
||||||
|
$row = mysqli_fetch_array($sql_invoice);
|
||||||
|
$invoice_amount = floatval($row['invoice_amount']);
|
||||||
|
$invoice_id = intval($row['invoice_id']);
|
||||||
|
|
||||||
|
$sql_payments = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS total_payments FROM payments WHERE payment_invoice_id = $invoice_id");
|
||||||
|
$row = mysqli_fetch_array($sql_payments);
|
||||||
|
$total_payments = floatval($row['total_payments']);
|
||||||
|
|
||||||
|
$balance = $invoice_amount - $total_payments;
|
||||||
|
|
||||||
|
if ($balance == '') {
|
||||||
|
$balance = '0.00';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $balance;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -170,8 +170,6 @@ if (isset($_POST['edit_software'])) {
|
|||||||
$expire = "'" . $expire . "'";
|
$expire = "'" . $expire . "'";
|
||||||
}
|
}
|
||||||
$notes = sanitizeInput($_POST['notes']);
|
$notes = sanitizeInput($_POST['notes']);
|
||||||
$username = trim(mysqli_real_escape_string($mysqli, encryptLoginEntry($_POST['username'])));
|
|
||||||
$password = trim(mysqli_real_escape_string($mysqli, encryptLoginEntry($_POST['password'])));
|
|
||||||
|
|
||||||
mysqli_query($mysqli,"UPDATE software SET software_name = '$name', software_version = '$version', software_type = '$type', software_key = '$key', software_license_type = '$license_type', software_seats = $seats, software_purchase = $purchase, software_expire = $expire, software_notes = '$notes' WHERE software_id = $software_id");
|
mysqli_query($mysqli,"UPDATE software SET software_name = '$name', software_version = '$version', software_type = '$type', software_key = '$key', software_license_type = '$license_type', software_seats = $seats, software_purchase = $purchase, software_expire = $expire, software_notes = '$notes' WHERE software_id = $software_id");
|
||||||
|
|
||||||
@@ -196,10 +194,15 @@ if (isset($_POST['edit_software'])) {
|
|||||||
|
|
||||||
//If login exists then update the login
|
//If login exists then update the login
|
||||||
if ($login_id > 0) {
|
if ($login_id > 0) {
|
||||||
|
$username = encryptLoginEntry($_POST['username']);
|
||||||
|
$password = encryptLoginEntry($_POST['password']);
|
||||||
|
|
||||||
mysqli_query($mysqli,"UPDATE logins SET login_name = '$name', login_username = '$username', login_password = '$password' WHERE login_id = $login_id");
|
mysqli_query($mysqli,"UPDATE logins SET login_name = '$name', login_username = '$username', login_password = '$password' WHERE login_id = $login_id");
|
||||||
}else{
|
}else{
|
||||||
//If Username is filled in then add a login
|
//If Username is filled in then add a login
|
||||||
if (!empty($username)) {
|
if (!empty($_POST['username'])) {
|
||||||
|
$username = encryptLoginEntry($_POST['username']);
|
||||||
|
$password = encryptLoginEntry($_POST['password']);
|
||||||
|
|
||||||
mysqli_query($mysqli,"INSERT INTO logins SET login_name = '$name', login_username = '$username', login_password = '$password', login_software_id = $software_id, login_client_id = $client_id");
|
mysqli_query($mysqli,"INSERT INTO logins SET login_name = '$name', login_username = '$username', login_password = '$password', login_software_id = $software_id, login_client_id = $client_id");
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@
|
|||||||
$formatted_behind_amount = numfmt_format_currency($currency_format, $behind_amount, $config_currency_code);
|
$formatted_behind_amount = numfmt_format_currency($currency_format, $behind_amount, $config_currency_code);
|
||||||
|
|
||||||
echo "<tr>";
|
echo "<tr>";
|
||||||
echo "<td><a href='client_overview.php?client_id=$client_id'>$client_name</a></td>";
|
echo "<td><a href='client_statement.php?client_id=$client_id'>$client_name</a></td>";
|
||||||
echo "<td>$formatted_balance</td>";
|
echo "<td>$formatted_balance</td>";
|
||||||
echo "<td>$billing_contact_phone</td>";
|
echo "<td>$billing_contact_phone</td>";
|
||||||
echo "<td>$formatted_recurring_monthly_total</td>";
|
echo "<td>$formatted_recurring_monthly_total</td>";
|
||||||
|
|||||||
Reference in New Issue
Block a user