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

@@ -0,0 +1,32 @@
<?php
/*
* ITFlow - Database update to version 3.8.8 (from 3.8.7)
* Included by admin/database_updates.php - do not access directly
*
* Pictures on quote lines and products (functions/quote_images.php) - the same
* columns, with the same meanings, as MountaineerIT's build:
* quote_items.item_image - the line's picture, a path under uploads/; NULL for none.
* products.product_image - the product's, which a quote line added from it copies.
* settings.config_quote_show_images - quotes show their lines' pictures (1, the default) or not.
*
* Re-runnable: each column is added only where it isn't there yet.
*/
defined('FROM_DB_UPDATER') || die("Direct file access is not allowed");
$itflow_column = function ($table, $column) use ($mysqli) {
$result = mysqli_query($mysqli, "SELECT 1 FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = '$table' AND COLUMN_NAME = '$column' LIMIT 1");
return $result && mysqli_num_rows($result) > 0;
};
if (!$itflow_column('quote_items', 'item_image')) {
mysqli_query($mysqli, "ALTER TABLE `quote_items` ADD `item_image` varchar(255) DEFAULT NULL AFTER `item_price_percent`");
}
if (!$itflow_column('products', 'product_image')) {
mysqli_query($mysqli, "ALTER TABLE `products` ADD `product_image` varchar(255) DEFAULT NULL AFTER `product_cost`");
}
if (!$itflow_column('settings', 'config_quote_show_images')) {
mysqli_query($mysqli, "ALTER TABLE `settings` ADD `config_quote_show_images` tinyint(1) NOT NULL DEFAULT 1 AFTER `config_quote_price_presets`");
}

View File

@@ -793,6 +793,7 @@ function demoDataRemove($mysqli) {
$sql = mysqli_query($mysqli, "SELECT quote_id FROM quotes WHERE quote_client_id = $client_id");
while ($row = mysqli_fetch_assoc($sql)) {
$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 history WHERE history_quote_id = $quote_id");
}

View File

@@ -3,7 +3,8 @@
/*
* Admin > Settings > Quotes (admin/settings_quote.php):
* edit_quote_settings saves the numbering, the footer, who is emailed a
* client's answer and the pricing a line starts with. A next number already
* client's answer, the pricing a line starts with and whether lines show
* their pictures. A next number already
* in use, an email address that isn't one, or a % that can't be used, comes
* back to the page saying so - nothing is saved.
*/
@@ -15,10 +16,14 @@ if (isset($_POST['edit_quote_settings'])) {
validateCSRFToken();
$pricing_columns = quotePricingReady() ? ['config_quote_price_method', 'config_quote_price_percent', 'config_quote_price_presets'] : [];
$before = settingsCurrent(array_merge(['config_quote_prefix', 'config_quote_next_number', 'config_quote_footer', 'config_quote_notification_email'], $pricing_columns));
$image_columns = quoteImagesReady() ? ['config_quote_show_images'] : [];
$before = settingsCurrent(array_merge(['config_quote_prefix', 'config_quote_next_number', 'config_quote_footer', 'config_quote_notification_email'], $pricing_columns, $image_columns));
// What was sent, and what is saved for anything that wasn't
// What was sent, and what is saved for anything that wasn't - a switch sends nothing when off
$in = $_POST + array_map(function ($value) { return (string) $value; }, $before);
if ($image_columns) {
$in['config_quote_show_images'] = empty($_POST['config_quote_show_images']) ? '0' : '1';
}
[$prefix, $number, $errors] = settingsNumberingCheck('quote', $in, $before);
$after = [
@@ -30,6 +35,9 @@ if (isset($_POST['edit_quote_settings'])) {
if ($problem = settingsEmailProblem($after['config_quote_notification_email'])) {
$errors['config_quote_notification_email'] = $problem;
}
if ($image_columns) {
$after['config_quote_show_images'] = $in['config_quote_show_images'];
}
// How a line's price comes from its cost (functions/quote_pricing.php)
if ($pricing_columns) {
$method = quotePriceMethod($in['config_quote_price_method']);

View File

@@ -44,6 +44,13 @@ echo settingsPageStart('quote');
<?= settingsSectionEnd() ?>
<?php } ?>
<?php if (quoteImagesReady()) { ?>
<?= settingsSectionStart('pictures', 'Pictures', 'A quote line can have a picture - uploaded, pulled from a link, or taken from its product.') ?>
<?= settingsSwitch('config_quote_show_images', quoteImagesShown() ? 1 : 0, ['label' => 'Show pictures on quotes',
'help' => 'Beside each line on the quote, the guest link, the client portal and the PDF - and the Picture field in a line\'s Edit window. Off, they are kept but not shown.']) ?>
<?= settingsSectionEnd() ?>
<?php } ?>
<?= settingsSaveBar('edit_quote_settings') ?>
</div>
</div>