mirror of
https://github.com/itflow-org/itflow
synced 2026-11-12 07:27:22 +00:00
Agents restricted from a client could still edit, archive, restore or delete it, run bulk actions on it (edits, tags, archive, email, tickets) and add credits. Every selected client is now checked before anything is written. Expense, trip and recurring expense edits now check the client the record already belongs to, not just the submitted one. Recurring expense delete, revenue edit/delete and task approval handlers gained the same check. Per-client reports and the dashboard payment/ticket lists now hide clients the agent is denied. Company-wide totals are unchanged.
69 lines
2.5 KiB
PHP
69 lines
2.5 KiB
PHP
<?php
|
|
|
|
require_once "includes/inc_all_reports.php";
|
|
|
|
enforceUserPermission('module_financial');
|
|
|
|
$sql = mysqli_query($mysqli, "
|
|
SELECT client_id, client_name,
|
|
SUM(CASE WHEN recurring_invoice_frequency = 'month' THEN recurring_invoice_amount
|
|
WHEN recurring_invoice_frequency = 'year' THEN recurring_invoice_amount / 12 END) AS recurring_monthly_total
|
|
FROM clients
|
|
LEFT JOIN recurring_invoices ON client_id = recurring_invoice_client_id
|
|
WHERE recurring_invoice_status = 1
|
|
" . clientScopeSql('clients.client_id') . "
|
|
GROUP BY clients.client_id
|
|
HAVING recurring_monthly_total > 0
|
|
ORDER BY recurring_monthly_total DESC
|
|
");
|
|
|
|
?>
|
|
|
|
<div class="card card-dark">
|
|
<div class="card-header py-2">
|
|
<h3 class="card-title mt-2"><i class="fas fa-fw fa-sync me-2"></i>Recurring Income By Client</h3>
|
|
<div class="card-tools">
|
|
<button type="button" class="btn btn-primary d-print-none" onclick="window.print();"><i class="fas fa-fw fa-print me-2"></i>Print</button>
|
|
</div>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="table-responsive-sm">
|
|
<table class="table table-striped table-sm">
|
|
<thead>
|
|
<tr>
|
|
<th>Client</th>
|
|
<th class="text-end">Monthly Recurring</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
|
|
while ($row = mysqli_fetch_assoc($sql)) {
|
|
$client_id = intval($row['client_id']);
|
|
$client_name = escapeHtml($row['client_name']);
|
|
$recurring_monthly_total = floatval($row['recurring_monthly_total']);
|
|
$recurring_total = $recurring_total + $recurring_monthly_total;
|
|
?>
|
|
|
|
|
|
<tr>
|
|
<td><a href="../../agent/client_overview.php?client_id=<?= $client_id ?>"><?= $client_name ?></a></td>
|
|
<td class="text-end"><?= numfmt_format_currency($currency_format, $recurring_monthly_total, $session_company_currency) ?></td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
|
|
?>
|
|
<tr>
|
|
<th>Total Monthly Income</th>
|
|
<th class="text-end"><?= numfmt_format_currency($currency_format, $recurring_total, $session_company_currency) ?></th>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php require_once "../../includes/footer.php";
|
|
?>
|