mirror of https://github.com/itflow-org/itflow
Merge branch 'develop' of github.com:itflow-org/itflow into develop
This commit is contained in:
commit
4ffe75683b
|
|
@ -93,6 +93,7 @@ If you want to improve ITFlow, feel free to fork the repo and create a pull requ
|
|||
We’re incredibly grateful to the organizations and individuals who support the project - a big thank you to:
|
||||
- CompuMatter
|
||||
- F1 for HELP
|
||||
- digiBandit
|
||||
- JetBrains (PhpStorm)
|
||||
|
||||
## License
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||
<div class="dropdown-menu">
|
||||
<button class="dropdown-item text-danger text-bold"
|
||||
type="submit" form="bulkActions" name="bulk_delete_api_keys">
|
||||
<i class="fas fa-fw fa-trash mr-2"></i>Revoke
|
||||
<i class="fas fa-fw fa-trash mr-2"></i>Delete
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -139,9 +139,16 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||
<i class="fas fa-ellipsis-h"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu">
|
||||
<a class="dropdown-item text-danger text-bold confirm-link" href="post.php?delete_api_key=<?php echo $api_key_id; ?>&csrf_token=<?php echo $_SESSION['csrf_token'] ?>">
|
||||
<i class="fas fa-fw fa-times mr-2"></i>Revoke
|
||||
</a>
|
||||
<?php if ($api_key_expire > date("Y-m-d H:i:s")) { ?>
|
||||
<a class="dropdown-item text-danger text-bold confirm-link" href="post.php?revoke_api_key=<?php echo $api_key_id; ?>&csrf_token=<?php echo $_SESSION['csrf_token'] ?>">
|
||||
<i class="fas fa-fw fa-times mr-2"></i>Revoke
|
||||
</a>
|
||||
<?php } ?>
|
||||
<?php if ($api_key_expire < date("Y-m-d H:i:s")) { ?>
|
||||
<a class="dropdown-item text-danger text-bold confirm-link" href="post.php?delete_api_key=<?php echo $api_key_id; ?>&csrf_token=<?php echo $_SESSION['csrf_token'] ?>">
|
||||
<i class="fas fa-fw fa-times mr-2"></i>Delete
|
||||
</a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
|
|
|||
|
|
@ -31,6 +31,27 @@ if (isset($_POST['add_api_key'])) {
|
|||
|
||||
}
|
||||
|
||||
if (isset($_GET['revoke_api_key'])) {
|
||||
|
||||
validateCSRFToken($_GET['csrf_token']);
|
||||
|
||||
$api_key_id = intval($_GET['revoke_api_key']);
|
||||
|
||||
// Get API Key Name
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT api_key_name, api_key_client_id FROM api_keys WHERE api_key_id = $api_key_id"));
|
||||
$api_key_name = sanitizeInput($row['api_key_name']);
|
||||
$client_id = intval($row['api_key_client_id']);
|
||||
|
||||
mysqli_query($mysqli,"UPDATE api_keys SET api_key_expire = NOW() WHERE api_key_id = $api_key_id");
|
||||
|
||||
logAction("API Key", "Revoke", "$session_name revoked API key $name", $client_id);
|
||||
|
||||
flash_alert("API Key <strong>$name</strong> revoked", 'error');
|
||||
|
||||
redirect();
|
||||
|
||||
}
|
||||
|
||||
if (isset($_GET['delete_api_key'])) {
|
||||
|
||||
validateCSRFToken($_GET['csrf_token']);
|
||||
|
|
|
|||
|
|
@ -125,49 +125,52 @@
|
|||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
<?php if ($config_module_enable_accounting == 1 && lookupUserPermission("module_financial") >= 1) { ?>
|
||||
|
||||
<?php if ($config_module_enable_accounting == 1) { ?>
|
||||
<li class="nav-header mt-3">FINANCE</li>
|
||||
<li class="nav-item">
|
||||
<a href="/agent/payments.php" class="nav-link <?php if (basename($_SERVER["PHP_SELF"]) == "payments.php") { echo "active"; } ?>">
|
||||
<i class="nav-icon fas fa-credit-card"></i>
|
||||
<p>Payments</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="/agent/vendors.php" class="nav-link <?php if (basename($_SERVER["PHP_SELF"]) == "vendors.php") { echo "active"; } ?>">
|
||||
<i class="nav-icon fas fa-building"></i>
|
||||
<p>Vendors</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="/agent/expenses.php" class="nav-link <?php if (basename($_SERVER["PHP_SELF"]) == "expenses.php") { echo "active"; } ?>">
|
||||
<i class="nav-icon fas fa-shopping-cart"></i>
|
||||
<p>Expenses</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="/agent/recurring_expenses.php" class="nav-link <?php if (basename($_SERVER["PHP_SELF"]) == "recurring_expenses.php") { echo "active"; } ?>">
|
||||
<i class="nav-icon fas fa-redo-alt"></i>
|
||||
<p>
|
||||
Recurring Expenses
|
||||
<?php if ($num_recurring_expenses) { ?>
|
||||
<span class="right badge text-light" data-toggle="tooltip" title="Recurring Expenses"><?php echo $num_recurring_expenses; ?></span>
|
||||
<?php } ?>
|
||||
</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="/agent/accounts.php" class="nav-link <?php if (basename($_SERVER["PHP_SELF"]) == "accounts.php") { echo "active"; } ?>">
|
||||
<i class="nav-icon fas fa-piggy-bank"></i>
|
||||
<p>Accounts</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="/agent/transfers.php" class="nav-link <?php if (basename($_SERVER["PHP_SELF"]) == "transfers.php") { echo "active"; } ?>">
|
||||
<i class="nav-icon fas fa-exchange-alt"></i>
|
||||
<p>Transfers</p>
|
||||
</a>
|
||||
</li>
|
||||
<?php if (lookupUserPermission("module_financial") >= 1) { ?>
|
||||
<li class="nav-item">
|
||||
<a href="/agent/payments.php" class="nav-link <?php if (basename($_SERVER["PHP_SELF"]) == "payments.php") { echo "active"; } ?>">
|
||||
<i class="nav-icon fas fa-credit-card"></i>
|
||||
<p>Payments</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="/agent/vendors.php" class="nav-link <?php if (basename($_SERVER["PHP_SELF"]) == "vendors.php") { echo "active"; } ?>">
|
||||
<i class="nav-icon fas fa-building"></i>
|
||||
<p>Vendors</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="/agent/expenses.php" class="nav-link <?php if (basename($_SERVER["PHP_SELF"]) == "expenses.php") { echo "active"; } ?>">
|
||||
<i class="nav-icon fas fa-shopping-cart"></i>
|
||||
<p>Expenses</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="/agent/recurring_expenses.php" class="nav-link <?php if (basename($_SERVER["PHP_SELF"]) == "recurring_expenses.php") { echo "active"; } ?>">
|
||||
<i class="nav-icon fas fa-redo-alt"></i>
|
||||
<p>
|
||||
Recurring Expenses
|
||||
<?php if ($num_recurring_expenses) { ?>
|
||||
<span class="right badge text-light" data-toggle="tooltip" title="Recurring Expenses"><?php echo $num_recurring_expenses; ?></span>
|
||||
<?php } ?>
|
||||
</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="/agent/accounts.php" class="nav-link <?php if (basename($_SERVER["PHP_SELF"]) == "accounts.php") { echo "active"; } ?>">
|
||||
<i class="nav-icon fas fa-piggy-bank"></i>
|
||||
<p>Accounts</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="/agent/transfers.php" class="nav-link <?php if (basename($_SERVER["PHP_SELF"]) == "transfers.php") { echo "active"; } ?>">
|
||||
<i class="nav-icon fas fa-exchange-alt"></i>
|
||||
<p>Transfers</p>
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
<li class="nav-item">
|
||||
<a href="/agent/trips.php" class="nav-link <?php if (basename($_SERVER["PHP_SELF"]) == "trips.php") { echo "active"; } ?>">
|
||||
<i class="nav-icon fas fa-route"></i>
|
||||
|
|
|
|||
|
|
@ -288,6 +288,9 @@ if (isset($_GET['invoice_id'])) {
|
|||
<a class="dropdown-item" href="post.php?export_invoice_pdf=<?php echo $invoice_id; ?>" target="_blank">
|
||||
<i class="fa fa-fw fa-download text-secondary mr-2"></i>Download PDF
|
||||
</a>
|
||||
<a class="dropdown-item" href="post.php?export_invoice_packing_slip=<?php echo $invoice_id; ?>" target="_blank">
|
||||
<i class="fa fa-fw fa-box-open text-secondary mr-2"></i>Packing Slip
|
||||
</a>
|
||||
<?php if (!empty($config_smtp_host) && !empty($contact_email)) { ?>
|
||||
<a class="dropdown-item" href="post.php?email_invoice=<?php echo $invoice_id; ?>">
|
||||
<i class="fa fa-fw fa-paper-plane text-secondary mr-2"></i>Send Email
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ $asset_mac = nullable_htmlentities($row['interface_mac']);
|
|||
$asset_uri = nullable_htmlentities($row['asset_uri']);
|
||||
$asset_uri_2 = nullable_htmlentities($row['asset_uri_2']);
|
||||
$asset_status = nullable_htmlentities($row['asset_status']);
|
||||
$asset_purchase_reference = nullable_htmlentities($row['asset_purchase_reference']);
|
||||
$asset_purchase_date = nullable_htmlentities($row['asset_purchase_date']);
|
||||
$asset_warranty_expire = nullable_htmlentities($row['asset_warranty_expire']);
|
||||
$asset_install_date = nullable_htmlentities($row['asset_install_date']);
|
||||
|
|
@ -370,7 +371,7 @@ ob_start();
|
|||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-shopping-cart"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="purchase_reference" placeholder="eg. Invoice, PO Number" >
|
||||
<input type="text" class="form-control" name="purchase_reference" placeholder="eg. Invoice, PO Number" value="<?php echo $asset_purchase_reference; ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -508,9 +508,10 @@ ob_start();
|
|||
<ul>
|
||||
<?php
|
||||
while ($row = mysqli_fetch_assoc($sql_asset_history)) {
|
||||
$asset_history_description = nullable_htmlentities(($row['asset_history_description']));
|
||||
$asset_history_created_at = nullable_htmlentities(($row['asset_history_created_at']));
|
||||
echo "<li><small class='text-secondary'>$asset_history_created_at</small><br>$asset_history_description</li>";
|
||||
$asset_history_status = nullable_htmlentities($row['asset_history_status']);
|
||||
$asset_history_description = nullable_htmlentities($row['asset_history_description']);
|
||||
$asset_history_created_at = nullable_htmlentities($row['asset_history_created_at']);
|
||||
echo "<li>$asset_history_created_at - $asset_history_status <br/>$asset_history_description</li><br/>";
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
|
|
|
|||
|
|
@ -128,6 +128,9 @@ if (isset($_POST['edit_asset'])) {
|
|||
}
|
||||
}
|
||||
|
||||
// Add to History
|
||||
mysqli_query($mysqli,"INSERT INTO asset_history SET asset_history_status = '$status', asset_history_description = '$session_name updated $name', asset_history_asset_id = $asset_id");
|
||||
|
||||
logAction("Asset", "Edit", "$session_name edited asset $name", $client_id, $asset_id);
|
||||
|
||||
flash_alert("Asset <strong>$name</strong> edited");
|
||||
|
|
@ -152,6 +155,9 @@ if (isset($_GET['archive_asset'])) {
|
|||
|
||||
mysqli_query($mysqli,"UPDATE assets SET asset_archived_at = NOW() WHERE asset_id = $asset_id");
|
||||
|
||||
// Add to History
|
||||
mysqli_query($mysqli,"INSERT INTO asset_history SET asset_history_status = 'Archived', asset_history_description = '$session_name archived $asset_name', asset_history_asset_id = $asset_id");
|
||||
|
||||
logAction("Asset", "Archive", "$session_name archived asset $asset_name", $client_id, $asset_id);
|
||||
|
||||
flash_alert("Asset <strong>$asset_name</strong> archived", 'error');
|
||||
|
|
@ -176,6 +182,9 @@ if (isset($_GET['unarchive_asset'])) {
|
|||
|
||||
mysqli_query($mysqli,"UPDATE assets SET asset_archived_at = NULL WHERE asset_id = $asset_id");
|
||||
|
||||
// Add to History
|
||||
mysqli_query($mysqli,"INSERT INTO asset_history SET asset_history_status = 'UnArchived', asset_history_description = '$session_name unarchived $asset_name', asset_history_asset_id = $asset_id");
|
||||
|
||||
logAction("Asset", "Unarchive", "$session_name unarchived asset $asset_name", $client_id, $asset_id);
|
||||
|
||||
flash_alert("Asset <strong>$asset_name</strong> Unarchived");
|
||||
|
|
@ -391,6 +400,7 @@ if (isset($_POST['bulk_transfer_client_asset'])) {
|
|||
// Archive/log the current asset
|
||||
$notes = $asset_notes . "\r\n\r\n---\r\n* " . date('Y-m-d H:i:s') . ": Transferred asset $asset_name (old asset ID: $current_asset_id) from $current_client_name to $new_client_name (new asset ID: $new_asset_id)";
|
||||
mysqli_query($mysqli,"UPDATE assets SET asset_archived_at = NOW() WHERE asset_id = $current_asset_id");
|
||||
mysqli_query($mysqli,"INSERT INTO asset_history SET asset_history_status = 'Transferred', asset_history_description = '$session_name transferred $asset_name to $new_client_name', asset_history_asset_id = $current_asset_id");
|
||||
|
||||
// Log Archive
|
||||
logAction("Asset", "Archive", "$session_name archived asset $asset_name (via transfer)", $current_client_id, $current_asset_id);
|
||||
|
|
@ -402,6 +412,7 @@ if (isset($_POST['bulk_transfer_client_asset'])) {
|
|||
// Log the new asset
|
||||
$notes = $asset_notes . "\r\n\r\n---\r\n* " . date('Y-m-d H:i:s') . ": Transferred asset $asset_name (old asset ID: $current_asset_id) from $current_client_name to $new_client_name (new asset ID: $new_asset_id)";
|
||||
logAction("Asset", "Create", "$session_name created asset $name (via transfer)", $new_client_id, $new_asset_id);
|
||||
mysqli_query($mysqli,"INSERT INTO asset_history SET asset_history_status = 'Transferred', asset_history_description = '$session_name created asset via transfer from $current_client_name', asset_history_asset_id = $new_asset_id");
|
||||
|
||||
logAction("Asset", "Transfer", "$session_name Transferred asset $asset_name (old asset ID: $current_asset_id) from $current_client_name to $new_client_name (new asset ID: $new_asset_id)", $new_client_id, $new_asset_id);
|
||||
|
||||
|
|
@ -486,6 +497,9 @@ if (isset($_POST['bulk_edit_asset_status'])) {
|
|||
|
||||
logAction("Asset", "Edit", "$session_name set status to $status on $asset_name", $client_id, $asset_id);
|
||||
|
||||
// Add to History
|
||||
mysqli_query($mysqli,"INSERT INTO asset_history SET asset_history_status = '$status', asset_history_description = '$session_name updated $asset_name', asset_history_asset_id = $asset_id");
|
||||
|
||||
}
|
||||
|
||||
logAction("Asset", "Bulk Edit", "$session_name set status to $status on $asset_count assets", $client_id);
|
||||
|
|
@ -521,6 +535,9 @@ if (isset($_POST['bulk_archive_assets'])) {
|
|||
|
||||
logAction("Asset", "Archive", "$session_name archived asset $asset_name", $client_id, $asset_id);
|
||||
|
||||
// Add to History
|
||||
mysqli_query($mysqli,"INSERT INTO asset_history SET asset_history_status = 'Archived', asset_history_description = '$session_name archived $asset_name', asset_history_asset_id = $asset_id");
|
||||
|
||||
}
|
||||
|
||||
logAction("Asset", "Bulk Archive", "$session_name archived $count assets", $client_id);
|
||||
|
|
@ -558,6 +575,9 @@ if (isset($_POST['bulk_unarchive_assets'])) {
|
|||
// Individual Asset logging
|
||||
logAction("Asset", "Unarchive", "$session_name unarchived asset $asset_name", $client_id, $asset_id);
|
||||
|
||||
// Add to History
|
||||
mysqli_query($mysqli,"INSERT INTO asset_history SET asset_history_status = 'UnArchived', asset_history_description = '$session_name unarchived $asset_name', asset_history_asset_id = $asset_id");
|
||||
|
||||
}
|
||||
|
||||
logAction("Asset", "Bulk Unarchive", "$session_name unarchived $count assets");
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ if (isset($_POST['add_invoice'])) {
|
|||
|
||||
$invoice_id = mysqli_insert_id($mysqli);
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_status = 'Draft', history_description = 'Invoice created', history_invoice_id = $invoice_id");
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_status = 'Draft', history_description = 'Invoice created by $session_name', history_invoice_id = $invoice_id");
|
||||
|
||||
logAction("Invoice", "Create", "$session_name created Invoice $config_invoice_prefix$invoice_number - $scope", $client_id, $invoice_id);
|
||||
|
||||
|
|
@ -159,7 +159,7 @@ if (isset($_GET['mark_invoice_sent'])) {
|
|||
|
||||
mysqli_query($mysqli,"UPDATE invoices SET invoice_status = 'Sent' WHERE invoice_id = $invoice_id");
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_status = 'Sent', history_description = 'Invoice marked sent', history_invoice_id = $invoice_id");
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_status = 'Sent', history_description = 'Invoice marked sent by $session_name', history_invoice_id = $invoice_id");
|
||||
|
||||
logAction("Invoice", "Edit", "$session_name marked invoice $invoice_prefix$invoice_number sent", $client_id, $invoice_id);
|
||||
|
||||
|
|
@ -205,7 +205,7 @@ if (isset($_GET['cancel_invoice'])) {
|
|||
|
||||
mysqli_query($mysqli,"UPDATE invoices SET invoice_status = 'Cancelled' WHERE invoice_id = $invoice_id");
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_status = 'Cancelled', history_description = 'Invoice cancelled', history_invoice_id = $invoice_id");
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_status = 'Cancelled', history_description = 'Invoice cancelled by $session_name', history_invoice_id = $invoice_id");
|
||||
|
||||
logAction("Invoice", "Edit", "$session_name cancelled invoice $invoice_prefix$invoice_number", $client_id, $invoice_id);
|
||||
|
||||
|
|
@ -586,7 +586,7 @@ if (isset($_GET['email_invoice'])) {
|
|||
|
||||
flash_alert("Invoice sent!");
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_status = 'Sent', history_description = 'Invoice sent to the mail queue ID: $email_id', history_invoice_id = $invoice_id");
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_status = 'Sent', history_description = 'Invoice sent by $session_name (mail queue ID: $email_id)', history_invoice_id = $invoice_id");
|
||||
|
||||
// Don't change the status to sent if the status is anything but draft
|
||||
if ($invoice_status == 'Draft') {
|
||||
|
|
@ -944,6 +944,153 @@ if (isset($_GET['export_invoice_pdf'])) {
|
|||
|
||||
}
|
||||
|
||||
if (isset($_GET['export_invoice_packing_slip'])) {
|
||||
|
||||
$invoice_id = intval($_GET['export_invoice_packing_slip']);
|
||||
|
||||
$sql = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM invoices
|
||||
LEFT JOIN clients ON invoice_client_id = client_id
|
||||
LEFT JOIN contacts ON clients.client_id = contacts.contact_client_id AND contact_primary = 1
|
||||
LEFT JOIN locations ON clients.client_id = locations.location_client_id AND location_primary = 1
|
||||
WHERE invoice_id = $invoice_id
|
||||
$access_permission_query
|
||||
LIMIT 1"
|
||||
);
|
||||
|
||||
$row = mysqli_fetch_assoc($sql);
|
||||
$invoice_id = intval($row['invoice_id']);
|
||||
$invoice_prefix = nullable_htmlentities($row['invoice_prefix']);
|
||||
$invoice_number = intval($row['invoice_number']);
|
||||
$invoice_date = nullable_htmlentities($row['invoice_date']);
|
||||
$client_id = intval($row['client_id']);
|
||||
$client_name = nullable_htmlentities($row['client_name']);
|
||||
$location_address = nullable_htmlentities($row['location_address']);
|
||||
$location_city = nullable_htmlentities($row['location_city']);
|
||||
$location_state = nullable_htmlentities($row['location_state']);
|
||||
$location_zip = nullable_htmlentities($row['location_zip']);
|
||||
$location_country = nullable_htmlentities($row['location_country']);
|
||||
$contact_email = nullable_htmlentities($row['contact_email']);
|
||||
$contact_phone_country_code = nullable_htmlentities($row['contact_phone_country_code']);
|
||||
$contact_phone = nullable_htmlentities(formatPhoneNumber($row['contact_phone'], $contact_phone_country_code));
|
||||
$contact_extension = nullable_htmlentities($row['contact_extension']);
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM companies WHERE company_id = 1");
|
||||
$row = mysqli_fetch_assoc($sql);
|
||||
$company_id = intval($row['company_id']);
|
||||
$company_name = nullable_htmlentities($row['company_name']);
|
||||
$company_country = nullable_htmlentities($row['company_country']);
|
||||
$company_address = nullable_htmlentities($row['company_address']);
|
||||
$company_city = nullable_htmlentities($row['company_city']);
|
||||
$company_state = nullable_htmlentities($row['company_state']);
|
||||
$company_zip = nullable_htmlentities($row['company_zip']);
|
||||
$company_phone_country_code = nullable_htmlentities($row['company_phone_country_code']);
|
||||
$company_phone = nullable_htmlentities(formatPhoneNumber($row['company_phone'], $company_phone_country_code));
|
||||
$company_email = nullable_htmlentities($row['company_email']);
|
||||
$company_website = nullable_htmlentities($row['company_website']);
|
||||
$company_tax_id = nullable_htmlentities($row['company_tax_id']);
|
||||
if ($config_invoice_show_tax_id && !empty($company_tax_id)) {
|
||||
$company_tax_id_display = "Tax ID: $company_tax_id";
|
||||
} else {
|
||||
$company_tax_id_display = "";
|
||||
}
|
||||
$company_logo = nullable_htmlentities($row['company_logo']);
|
||||
|
||||
require_once("../plugins/TCPDF/tcpdf.php");
|
||||
|
||||
// Start TCPDF
|
||||
$pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8', false);
|
||||
$pdf->SetMargins(10, 10, 10);
|
||||
$pdf->setPrintHeader(false);
|
||||
$pdf->setPrintFooter(false);
|
||||
$pdf->AddPage();
|
||||
$pdf->SetFont('helvetica', '', 10);
|
||||
|
||||
// Logo + Right Columns
|
||||
$html = '<table width="100%" cellspacing="0" cellpadding="3">
|
||||
<tr>
|
||||
<td width="40%">';
|
||||
if (!empty($company_logo) && file_exists("../uploads/settings/$company_logo")) {
|
||||
$html .= '<img src="/uploads/settings/' . $company_logo . '" width="120">';
|
||||
}
|
||||
$html .= '</td>
|
||||
<td width="60%" align="right">
|
||||
<span style="font-size:18pt; font-weight:bold;">Packing Slip</span><br>
|
||||
<span style="font-size:14pt;">' . $invoice_prefix . $invoice_number . '</span><br>';
|
||||
$html .= '</td>
|
||||
</tr>
|
||||
</table><br>';
|
||||
|
||||
// Billing titles
|
||||
$html .= '<table width="100%" cellspacing="0" cellpadding="2">
|
||||
<tr>
|
||||
<td width="50%" style="font-size:14pt; font-weight:bold;">' . $company_name . '</td>
|
||||
<td width="50%" align="right" style="font-size:14pt; font-weight:bold;">' . $client_name . '</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="font-size:10pt; line-height:1.4;">' . nl2br("$company_address\n$company_city $company_state $company_zip\n$company_country\n$company_phone\n$company_website\n$company_tax_id_display") . '</td>
|
||||
<td style="font-size:10pt; line-height:1.4;" align="right">' . nl2br("$location_address\n$location_city $location_state $location_zip\n$location_country\n$contact_email\n$contact_phone") . '</td>
|
||||
</tr>
|
||||
</table><br>';
|
||||
|
||||
// Items header
|
||||
$html .= '
|
||||
<table border="0" cellpadding="5" cellspacing="0" width="100%">
|
||||
<tr style="background-color:#f0f0f0;">
|
||||
<th align="left" width="50%"><strong>Item</strong></th>
|
||||
<th align="center" width="40%"><strong>Qty</strong></th>
|
||||
<th align="right" width="10%"><strong>Picked?</strong></th>
|
||||
</tr>';
|
||||
|
||||
// Load items
|
||||
$sub_total = 0;
|
||||
$total_tax = 0;
|
||||
|
||||
$sql_items = mysqli_query($mysqli, "SELECT * FROM invoice_items WHERE item_invoice_id = $invoice_id ORDER BY item_order ASC");
|
||||
while ($item = mysqli_fetch_assoc($sql_items)) {
|
||||
$name = $item['item_name'];
|
||||
$qty = $item['item_quantity'];
|
||||
|
||||
$html .= '
|
||||
<tr>
|
||||
<td><strong>' . $name . '</strong></td>
|
||||
<td align="center">' . number_format($qty, 2) . '</td>
|
||||
<td align="right">
|
||||
<table cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td style="border:0.5px solid #000; width:12px; height:5px; margin-top:2px"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
$html .= '</table><br><br><br>';
|
||||
|
||||
|
||||
// Picked/Checked by
|
||||
$html .= '
|
||||
<table width="100%" cellspacing="0" cellpadding="8" style="font-size:10pt; margin-top:20px;">
|
||||
<tr>
|
||||
<td width="50%" style="border:1px solid #000; height:60px;">
|
||||
<strong>Picked By:</strong><br><br>
|
||||
</td>
|
||||
<td width="50%" style="border:1px solid #000; height:60px;">
|
||||
<strong>Checked By:</strong><br><br>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br><br>';
|
||||
|
||||
$pdf->writeHTML($html, true, false, true, false, '');
|
||||
|
||||
$filename = preg_replace('/[^A-Za-z0-9_\-]/', '_', "{$invoice_date}_{$company_name}_{$client_name}_Invoice_{$invoice_prefix}{$invoice_number}");
|
||||
$pdf->Output("$filename.pdf", 'I');
|
||||
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
if (isset($_POST['bulk_edit_invoice_category'])) {
|
||||
|
||||
$category_id = intval($_POST['bulk_category_id']);
|
||||
|
|
|
|||
|
|
@ -150,8 +150,10 @@ function addTicket($contact_id, $contact_name, $contact_email, $client_id, $date
|
|||
mysqli_query($mysqli, "INSERT INTO ticket_watchers SET watcher_email = '$contact_email_esc', watcher_ticket_id = $id");
|
||||
}
|
||||
|
||||
// External email
|
||||
$bad_pattern = "/do[\W_]*not[\W_]*reply|no[\W_]*reply/i";
|
||||
$data = [];
|
||||
if ($config_ticket_client_general_notifications == 1) {
|
||||
if ($config_ticket_client_general_notifications == 1 && !preg_match($bad_pattern, $contact_email)) {
|
||||
$subject_email = "Ticket created - [$config_ticket_prefix$ticket_number] - $subject";
|
||||
$body = "<i style='color: #808080'>##- Please type your reply above this line -##</i><br><br>Hello $contact_name,<br><br>Thank you for your email. A ticket regarding \"$subject\" has been automatically created for you.<br><br>Ticket: $config_ticket_prefix$ticket_number<br>Subject: $subject<br>Status: New<br>Portal: <a href='https://$config_base_url/guest/guest_view_ticket.php?ticket_id=$id&url_key=$url_key'>View ticket</a><br><br>--<br>$company_name - Support<br>$config_ticket_from_email<br>$company_phone";
|
||||
$data[] = [
|
||||
|
|
@ -164,6 +166,7 @@ function addTicket($contact_id, $contact_name, $contact_email, $client_id, $date
|
|||
];
|
||||
}
|
||||
|
||||
// Internal email
|
||||
if ($config_ticket_new_ticket_notification_email) {
|
||||
if ($client_id == 0) {
|
||||
$client_name = "Guest";
|
||||
|
|
@ -611,7 +614,16 @@ foreach ($messages as $message) {
|
|||
// Body (prefer HTML)
|
||||
$message_body_html = $message->getHTMLBody();
|
||||
$message_body_text = $message->getTextBody();
|
||||
$message_body = $message_body_html ?: nl2br(htmlspecialchars((string)$message_body_text));
|
||||
$message_body_raw = $message->getRawBody();
|
||||
|
||||
if (!empty($message_body_html)) {
|
||||
$message_body = $message_body_html;
|
||||
} elseif (!empty($message_body_text)) {
|
||||
$message_body = nl2br(htmlspecialchars($message_body_text));
|
||||
} else {
|
||||
// Final fallback
|
||||
$message_body = nl2br(htmlspecialchars($message_body_raw));
|
||||
}
|
||||
|
||||
// Handle attachments (inline vs regular)
|
||||
$attachments = [];
|
||||
|
|
|
|||
Loading…
Reference in New Issue