mirror of
https://github.com/itflow-org/itflow
synced 2026-11-20 03:17:24 +00:00
License templates stage 2: templates carry the seats a license starts with, a renewal term, a vendor from the vendor templates and the product they are sold as (database 3.2.9); a license made from one starts with its seats, gets a renewal date worked out from the purchase date and uses the client's vendor from that vendor template, or one with the same name, or has one made from the template by someone who can add vendors; New License fills in the seats, vendor and renewal date from the template and keeps the renewal date in step with the purchase date until one is typed in; Renew starts on the template's term; new licenses can be made for several clients at once with an option to skip clients that already have one; the template page and list show the new fields and the list search covers vendor and product; the license quick look shows the product and price to Sales users; deleting a vendor template or product removes it from the templates that used it
This commit is contained in:
@@ -3,7 +3,9 @@
|
||||
* A license template's fields - shared by its New and Edit windows
|
||||
* (software_template_add.php, software_template_edit.php), which set
|
||||
* $template (softwareTemplateRow(), or [] for a new one) before including it.
|
||||
* Posts what softwareTemplateFields() reads (functions/software_template.php).
|
||||
* Posts what softwareTemplateFields() reads (functions/software_template.php):
|
||||
* with the seats a license starts with, how often it renews, the vendor
|
||||
* template its vendor comes from and the product it is sold as.
|
||||
*
|
||||
* Should not be accessed directly.
|
||||
*/
|
||||
@@ -20,6 +22,25 @@ if ($license_type !== '' && !in_array($license_type, $license_types, true)) {
|
||||
$license_types[] = $license_type;
|
||||
}
|
||||
|
||||
$seats = $t['software_template_seats'] ?? null;
|
||||
$term = (string) ($t['software_template_term'] ?? '');
|
||||
$vendor_template_id = intval($t['software_template_vendor_template_id'] ?? 0);
|
||||
$product_id = intval($t['software_template_product_id'] ?? 0);
|
||||
|
||||
// Current vendor templates and products - and the one it has, even when archived since
|
||||
$vendor_templates = [];
|
||||
$sql = mysqli_query($mysqli, "SELECT vendor_template_id, vendor_template_name, vendor_template_description, vendor_template_archived_at FROM vendor_templates
|
||||
WHERE vendor_template_archived_at IS NULL OR vendor_template_id = $vendor_template_id ORDER BY vendor_template_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$vendor_templates[] = $row;
|
||||
}
|
||||
$products = [];
|
||||
$sql = mysqli_query($mysqli, "SELECT product_id, product_name, product_type, product_price, product_currency_code, product_frequency, product_seat_source, product_archived_at FROM products
|
||||
WHERE product_archived_at IS NULL OR product_id = $product_id ORDER BY product_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$products[] = $row;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<div class="row g-3">
|
||||
@@ -67,6 +88,55 @@ if ($license_type !== '' && !in_array($license_type, $license_types, true)) {
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Seats</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-users"></i></span>
|
||||
<input type="number" class="form-control" name="seats" min="0" max="1000000" step="1" placeholder="No limit" value="<?= $seats === null ? '' : intval($seats) ?>">
|
||||
</div>
|
||||
<div class="form-text">What a license starts with - change it for each client.</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Renews every</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-redo-alt"></i></span>
|
||||
<select class="form-select" name="term">
|
||||
<option value="">- Doesn't renew -</option>
|
||||
<?php foreach (SOFTWARE_RENEWAL_TERMS as $value => $label) { ?>
|
||||
<option value="<?= escapeHtml($value) ?>" <?= $value === $term ? 'selected' : '' ?>><?= escapeHtml($label) ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-text">Its renewal date is worked out from when it was bought.</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Vendor</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-building"></i></span>
|
||||
<select class="form-select select2" name="vendor_template_id">
|
||||
<option value="0">- None -</option>
|
||||
<?php foreach ($vendor_templates as $row) { ?>
|
||||
<option value="<?= intval($row['vendor_template_id']) ?>" <?= intval($row['vendor_template_id']) === $vendor_template_id ? 'selected' : '' ?><?= selectOptionVendor($row['vendor_template_name'], $row['vendor_template_archived_at'] ? 'Archived' : (string) $row['vendor_template_description']) ?>><?= escapeHtml($row['vendor_template_name']) ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-text">From the vendor templates - the client's own vendor made from it, or one made for them.</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Sold as</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-box-open"></i></span>
|
||||
<select class="form-select select2" name="product_id">
|
||||
<option value="0">- None -</option>
|
||||
<?php foreach ($products as $row) {
|
||||
$type_icon = productTypes()[$row['product_type']]['icon'] ?? 'fa-wrench';
|
||||
$line = $row['product_archived_at'] ? 'Archived' : billingMoney($row['product_price'], $row['product_currency_code']) . ' · ' . productBilledText($row['product_frequency'], $row['product_seat_source']); ?>
|
||||
<option value="<?= intval($row['product_id']) ?>" <?= intval($row['product_id']) === $product_id ? 'selected' : '' ?><?= selectOptionData(['icon' => "fas $type_icon", 'description' => $line]) ?>><?= escapeHtml($row['product_name']) ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-text">From Products & Services - what you charge for it.</div>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<label class="form-label">Notes</label>
|
||||
<div class="input-group">
|
||||
|
||||
Reference in New Issue
Block a user