Quotes: a line can have a picture beside its name on the quote, guest link, portal and PDF, uploaded or pulled from a link to a picture or a product page's main picture, fetched only from public addresses and kept as ITFlow's own resized copy in uploads/quote_images; products keep a picture that a quote line added from them copies, Copy Quote copies them, and deleting a line, quote, client or product removes the files; Admin Settings Quotes can switch pictures off; database 3.8.8 adds quote_items.item_image, products.product_image and config_quote_show_images; 26.11.9 changelog entries

This commit is contained in:
johnnyq
2026-11-17 21:25:57 -05:00
parent bd62f4af22
commit 475f27fc7f
27 changed files with 619 additions and 15 deletions

View File

@@ -58,7 +58,7 @@ ob_start();
<h5 class="modal-title"><i class="fas fa-fw fa-edit me-2"></i>Edit Line <span class="fw-normal text-white-50 ms-1"><?= escapeHtml(billingNumber($type, $doc)) ?></span></h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
</div>
<form action="post.php" method="post" autocomplete="off" data-billing-line-form>
<form action="post.php" method="post" enctype="multipart/form-data" autocomplete="off" data-billing-line-form>
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
<input type="hidden" name="billing_item_save" value="1">
<input type="hidden" name="type" value="<?= escapeHtml($type) ?>">
@@ -259,6 +259,9 @@ ob_start();
<?php if ($type === 'quote') { // what it costs you and how its price comes from that (functions/quote_pricing.php) ?>
<?= quotePricingFields($item, $currency) ?>
<?php } ?>
<?php if ($type === 'quote' && quoteImagesShown()) { // its picture (functions/quote_images.php) ?>
<?= quoteImageField('item_image', $item['item_image'] ?? '', 'Shown beside the line, on the quote and its PDF.') ?>
<?php } ?>
<div class="col-sm-4">
<label class="form-label">Quantity <strong class="text-danger">*</strong></label>
<div class="input-group">

View File

@@ -19,7 +19,7 @@ ob_start();
<h5 class="modal-title"><i class="fas fa-fw fa-box-open me-2"></i>New Product or Service</h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
</div>
<form action="post.php" method="post" autocomplete="off">
<form action="post.php" method="post" enctype="multipart/form-data" autocomplete="off">
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
<div class="modal-body">

View File

@@ -22,7 +22,7 @@ ob_start();
<h5 class="modal-title"><i class="fas fa-fw fa-edit me-2"></i>Edit <span class="fw-normal text-white-50 ms-1"><?= escapeHtml($form_product['product_name']) ?></span></h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
</div>
<form action="post.php" method="post" autocomplete="off">
<form action="post.php" method="post" enctype="multipart/form-data" autocomplete="off">
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
<input type="hidden" name="product_id" value="<?= $product_id ?>">

View File

@@ -252,6 +252,9 @@ if ($form_vendor_id && !isset($form_vendors[$form_vendor_id]) && $form_value('ve
<textarea class="form-control" name="description" rows="3" placeholder="What the client sees under the line - what it covers, per user per month, what is included"><?= escapeHtml($form_value('product_description')) ?></textarea>
</div>
</div>
<?php if (quoteImagesReady()) { // a quote line added from it takes a copy (functions/quote_images.php) ?>
<?= quoteImageField('product_image', $form_edit ? ($form_product['product_image'] ?? '') : '', 'A quote line added from it takes a copy.') ?>
<?php } ?>
<div class="col-12">
<label class="form-label">Notes <span class="text-body-secondary fw-normal small">for agents only</span></label>
<div class="input-group">

View File

@@ -129,6 +129,13 @@ if (isset($_POST['billing_item_save'])) {
$name = trim((string) $_POST['name']);
logAudit(billingAuditType($type), 'Edit', escapeSql("$session_name " . ($item_id ? 'edited' : 'added') . " line $name " . ($item_id ? 'on' : 'to') . " $number"), $client_id, $doc_id);
// A quote line's picture - a new one, or taken off (functions/quote_images.php)
$image_error = $type === 'quote' ? quoteImageSave('quote_items', $saved, $_POST, $_FILES) : '';
if ($image_error !== '') {
flashAlert('<strong>' . escapeHtml($name) . '</strong> ' . ($item_id ? 'updated' : 'added') . ', but its picture couldn\'t be added: ' . escapeHtml($image_error), 'warning');
billingPostBack($type, $doc_id, "line-$saved");
}
flashAlert('<strong>' . escapeHtml($name) . '</strong> ' . ($item_id ? 'updated' : 'added'));
billingPostBack($type, $doc_id, $item_id ? "line-$saved" : 'add-line');

View File

@@ -304,8 +304,9 @@ if (isset($_GET['delete_client'])) {
//Delete Quote and related items
$sql = mysqli_query($mysqli, "SELECT quote_id FROM quotes WHERE quote_client_id = $client_id");
while($row = mysqli_fetch_assoc($sql)) {
$quote_id = $row['quote_id'];
$quote_id = intval($row['quote_id']);
quoteImagesDeleteFor("item_quote_id = $quote_id");
mysqli_query($mysqli, "DELETE FROM quote_items WHERE item_quote_id = $quote_id");
}
mysqli_query($mysqli, "DELETE FROM quotes WHERE quote_client_id = $client_id");

View File

@@ -42,6 +42,13 @@ if (isset($_POST['add_product'])) {
logAudit("Product", "Create", "$session_name created " . strtolower($type_label) . " $name", 0, $product_id);
// Its picture (functions/quote_images.php)
$image_error = quoteImageSave('products', $product_id, $_POST, $_FILES);
if ($image_error !== '') {
flashAlert("$type_label <strong>" . escapeHtml($product['product_name']) . "</strong> added, but its picture couldn't be added: " . escapeHtml($image_error), 'warning');
redirect();
}
flashAlert("$type_label <strong>" . escapeHtml($product['product_name']) . "</strong> added");
redirect();
@@ -76,6 +83,13 @@ if (isset($_POST['edit_product'])) {
}
}
// Its picture (functions/quote_images.php)
$image_error = quoteImageSave('products', $product_id, $_POST, $_FILES);
if ($image_error !== '') {
flashAlert("<strong>" . escapeHtml($product['product_name']) . "</strong> saved$price_note - but its picture couldn't be added: " . escapeHtml($image_error), 'warning');
redirect();
}
flashAlert("<strong>" . escapeHtml($product['product_name']) . "</strong> saved$price_note");
redirect();

View File

@@ -105,7 +105,7 @@ if (isset($_POST['add_quote_copy'])) {
mysqli_query($mysqli,"INSERT INTO history SET history_status = 'Draft', history_description = 'Quote copied!', history_quote_id = $new_quote_id");
$sql_items = mysqli_query($mysqli,"SELECT item_description, item_id, item_name, item_order, item_price, item_quantity, item_subtotal,
item_tax, item_tax_id, item_total, item_frequency, item_product_id" . (quotePricingReady() ? ', item_cost, item_price_method, item_price_percent' : '') . " FROM quote_items WHERE item_quote_id = $quote_id");
item_tax, item_tax_id, item_total, item_frequency, item_product_id" . (quotePricingReady() ? ', item_cost, item_price_method, item_price_percent' : '') . (quoteImagesReady() ? ', item_image' : '') . " FROM quote_items WHERE item_quote_id = $quote_id");
while($row = mysqli_fetch_assoc($sql_items)) {
$item_id = intval($row['item_id']);
$item_name = escapeSql($row['item_name']);
@@ -124,7 +124,7 @@ if (isset($_POST['add_quote_copy'])) {
if ($item_product_id && !getFieldById('products', $item_product_id, 'product_id')) {
$item_product_id = 0;
}
$item_pricing = quotePricingCopySql($row);
$item_pricing = quotePricingCopySql($row) . quoteImageCopySql($row);
mysqli_query($mysqli,"INSERT INTO quote_items SET item_name = '$item_name', item_description = '$item_description', item_quantity = $item_quantity, item_price = $item_price, item_subtotal = $item_subtotal, item_tax = $item_tax, item_total = $item_total, item_order = $item_order, item_tax_id = $tax_id, item_frequency = $item_frequency, item_product_id = $item_product_id$item_pricing, item_quote_id = $new_quote_id");
}
@@ -247,7 +247,8 @@ if (isset($_GET['delete_quote'])) {
mysqli_query($mysqli,"DELETE FROM quotes WHERE quote_id = $quote_id");
//Delete Items Associated with the Quote
//Delete Items Associated with the Quote - and their pictures (functions/quote_images.php)
quoteImagesDeleteFor("item_quote_id = $quote_id");
$sql = mysqli_query($mysqli,"SELECT item_id FROM quote_items WHERE item_quote_id = $quote_id");
while($row = mysqli_fetch_assoc($sql)) {;
$item_id = intval($row['item_id']);