Files
itflow/agent/modals/client/client_terms_note.php
johnnyq 1e5bffff3c Rates, net terms and SLAs come from the client's contract, else the instance defaults: database 3.5.0 adds a default after-hours rate (Settings > Defaults, now Rates and terms), gives each client whose own rate, net terms or SLAs differ from the defaults an active Standard terms contract setting just those (12-month term renewing itself, starting the day the client was added or the day before its earliest contract, archived with an archived client), deletes per-client SLA assignments and drops clients.client_rate and client_net_terms; time bills at the contract's rate, its after-hours rate or the default after-hours rate, else the default rate, new invoices are due on the contract's net terms else the default, and new tickets get the contract's SLA else the default; a client's own terms still apply until the update runs; the client add and edit windows lose the rate, terms and SLA fields for a note saying what the client is billed on and where it comes from, the Clients list loses Set Hourly Rate and Set Net Terms and shows the contract's rate, the overview's Terms shows the after-hours rate and whether terms are a contract's or the defaults, a contract's page and document show what it leaves empty from another contract in force or the default so signed documents stay unchanged, contract windows show the defaults as placeholders, contract names take a proper possessive; the client import and API create make a Standard terms contract for a rate or terms that aren't the defaults (returning contract_id), API update reports them in not_kept; the client export gives the rates, terms and SLAs as billed; demo data puts each demo client's terms on a contract; changelog updated
2026-10-27 22:22:34 -04:00

46 lines
2.9 KiB
PHP

<?php
/*
* The client form's Billing tab: where a client's rates, net terms and SLAs
* come from - its contract in force, else the defaults - since a client has
* none of its own (functions/contract_billing.php). $terms_note_client_id:
* the client being edited, or 0 for a new one.
*/
$terms_note_client_id = intval($terms_note_client_id ?? 0);
$terms_note = $terms_note_client_id ? contractClientTerms($terms_note_client_id) : null;
$terms_note_defaults = billingDefaults();
$terms_note_money = function ($amount) use ($session_company_currency) {
return escapeHtml(billingMoney($amount, $session_company_currency));
};
$terms_note_net = function ($days) {
return $days > 0 ? "Net $days" : 'due on receipt';
};
// The contracts in force they come from, by name - "Gold", "Gold and Standard terms"
$terms_note_names = [];
if ($terms_note) {
$terms_note_names = array_merge([$terms_note['rate']['contract_name'], $terms_note['after_hours'][1], $terms_note['net_terms'][1]], array_column($terms_note['slas'], 1));
$terms_note_names = array_values(array_unique(array_filter(array_map('strval', $terms_note_names), 'strlen')));
}
$terms_note_from = count($terms_note_names) > 1 ? implode(', ', array_slice($terms_note_names, 0, -1)) . ' and ' . end($terms_note_names) : ($terms_note_names[0] ?? '');
?>
<div class="alert alert-light border small mb-3" data-client-terms-note>
<div class="fw-semibold mb-1"><i class="fas fa-fw fa-file-contract me-1"></i>Rates, net terms and SLAs</div>
<?php if ($terms_note) { ?>
<div>
<?= $terms_note_money($terms_note['rate']['rate']) ?>/hr<?= $terms_note['after_hours'][0] > 0 ? ', ' . $terms_note_money($terms_note['after_hours'][0]) . '/hr after hours' : '' ?>,
<?= $terms_note_net($terms_note['net_terms'][0]) ?> -
<?= $terms_note_from !== '' ? 'from ' . escapeHtml($terms_note_from) . (count($terms_note_names) > 1 ? ', the contracts in force, with the defaults for anything they leave empty.' : ', the contract in force, with the defaults for anything it leaves empty.') : 'the defaults, as no contract in force sets them.' ?>
</div>
<div class="text-body-secondary mt-1">
They come from the client's contract, not the client.
<a href="/agent/contracts.php?client_id=<?= $terms_note_client_id ?>">Contracts</a> - or change the defaults in Admin &gt; Settings &gt; Defaults and Admin &gt; SLAs.
</div>
<?php } else { ?>
<div>
They come from the client's contract, not the client - add one from its Contracts once it is added. Until then the defaults apply:
<?= $terms_note_money($terms_note_defaults['rate']) ?>/hr<?= $terms_note_defaults['after_hours'] > 0 ? ', ' . $terms_note_money($terms_note_defaults['after_hours']) . '/hr after hours' : '' ?>,
<?= $terms_note_net($terms_note_defaults['net_terms']) ?>, and the SLAs in Admin &gt; SLAs.
</div>
<?php } ?>
</div>