mirror of
https://github.com/itflow-org/itflow
synced 2026-03-19 04:04:51 +00:00
replace all instances of mysqli_fetch_array with mysqli_fetch_assoc for better performance and memory usage
This commit is contained in:
@@ -29,7 +29,7 @@ $monthlyTotals = array_fill(1, 12, 0); // Initialize monthly totals for each mo
|
||||
<select onchange="this.form.submit()" class="form-control" name="year">
|
||||
<?php
|
||||
|
||||
while ($row = mysqli_fetch_array($sql_expense_years)) {
|
||||
while ($row = mysqli_fetch_assoc($sql_expense_years)) {
|
||||
$expense_year = $row['expense_year'];
|
||||
?>
|
||||
<option <?php if ($year == $expense_year) { ?> selected <?php } ?> > <?php echo $expense_year; ?></option>
|
||||
@@ -85,7 +85,7 @@ $monthlyTotals = array_fill(1, 12, 0); // Initialize monthly totals for each mo
|
||||
echo "<td class='text-right'>" . $categoryTotal . "</td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
|
||||
|
||||
// Displaying the monthly totals row
|
||||
echo "<tr><td><strong>Total</strong></td>";
|
||||
$grandTotal = 0;
|
||||
@@ -104,4 +104,4 @@ $monthlyTotals = array_fill(1, 12, 0); // Initialize monthly totals for each mo
|
||||
</div>
|
||||
|
||||
<?php require_once "../../includes/footer.php";
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -17,38 +17,38 @@ enforceUserPermission('module_financial');
|
||||
|
||||
<?php
|
||||
$sql_clients = mysqli_query($mysqli, "
|
||||
SELECT
|
||||
SELECT
|
||||
clients.client_id,
|
||||
clients.client_name,
|
||||
IFNULL(SUM(invoices.invoice_amount), 0) - IFNULL(SUM(payments.payment_amount), 0) AS balance
|
||||
FROM
|
||||
FROM
|
||||
clients
|
||||
LEFT JOIN
|
||||
invoices
|
||||
ON
|
||||
clients.client_id = invoices.invoice_client_id
|
||||
AND invoices.invoice_status != 'Draft'
|
||||
ON
|
||||
clients.client_id = invoices.invoice_client_id
|
||||
AND invoices.invoice_status != 'Draft'
|
||||
AND invoices.invoice_status != 'Cancelled'
|
||||
AND invoice_status != 'Non-Billable'
|
||||
LEFT JOIN
|
||||
(SELECT
|
||||
payment_invoice_id,
|
||||
SUM(payment_amount) as payment_amount
|
||||
FROM payments
|
||||
(SELECT
|
||||
payment_invoice_id,
|
||||
SUM(payment_amount) as payment_amount
|
||||
FROM payments
|
||||
GROUP BY payment_invoice_id) as payments
|
||||
ON
|
||||
invoices.invoice_id = payments.payment_invoice_id
|
||||
GROUP BY
|
||||
clients.client_id,
|
||||
clients.client_name
|
||||
HAVING
|
||||
HAVING
|
||||
balance > 0
|
||||
ORDER BY
|
||||
balance DESC
|
||||
");
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<div class="table-responsive-sm">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
@@ -59,7 +59,7 @@ enforceUserPermission('module_financial');
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
while ($row = mysqli_fetch_array($sql_clients)) {
|
||||
while ($row = mysqli_fetch_assoc($sql_clients)) {
|
||||
$client_id = intval($row['client_id']);
|
||||
$client_name = nullable_htmlentities($row['client_name']);
|
||||
$balance = floatval($row['balance']);
|
||||
@@ -72,7 +72,7 @@ enforceUserPermission('module_financial');
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -82,4 +82,3 @@ enforceUserPermission('module_financial');
|
||||
|
||||
<?php
|
||||
require_once "../../includes/footer.php";
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ $passwords_not_rotated_sql = mysqli_query($mysqli,
|
||||
|
||||
<?php
|
||||
|
||||
while ($row = mysqli_fetch_array($passwords_not_rotated_sql)) {
|
||||
while ($row = mysqli_fetch_assoc($passwords_not_rotated_sql)) {
|
||||
|
||||
$credential_id = intval($row['credential_id']);
|
||||
$credential_name = nullable_htmlentities($row['credential_name']);
|
||||
@@ -72,4 +72,3 @@ $passwords_not_rotated_sql = mysqli_query($mysqli,
|
||||
|
||||
<?php
|
||||
require_once "../../includes/footer.php";
|
||||
|
||||
|
||||
@@ -22,18 +22,18 @@ $sql_payment_years = mysqli_query($mysqli, "SELECT DISTINCT YEAR(payment_date) A
|
||||
$year_condition = ($year == 'all') ? "" : "AND YEAR(expense_date) = $year";
|
||||
|
||||
$sql_vendor_expenses = mysqli_query($mysqli, "
|
||||
SELECT
|
||||
vendors.*,
|
||||
SUM(expenses.expense_amount) AS amount_paid
|
||||
FROM
|
||||
vendors
|
||||
LEFT JOIN
|
||||
SELECT
|
||||
vendors.*,
|
||||
SUM(expenses.expense_amount) AS amount_paid
|
||||
FROM
|
||||
vendors
|
||||
LEFT JOIN
|
||||
expenses ON vendors.vendor_id = expenses.expense_vendor_id $year_condition
|
||||
GROUP BY
|
||||
GROUP BY
|
||||
vendors.vendor_id
|
||||
HAVING
|
||||
amount_paid > 599
|
||||
ORDER BY
|
||||
ORDER BY
|
||||
amount_paid DESC
|
||||
");
|
||||
|
||||
@@ -52,7 +52,7 @@ $sql_vendor_expenses = mysqli_query($mysqli, "
|
||||
<option value="all" <?php if ($year == 'all') { ?> selected <?php } ?> >All Years</option>
|
||||
<?php
|
||||
|
||||
while ($row = mysqli_fetch_array($sql_payment_years)) {
|
||||
while ($row = mysqli_fetch_assoc($sql_payment_years)) {
|
||||
$payment_year = intval($row['payment_year']);
|
||||
?>
|
||||
<option <?php if ($year == $payment_year) { ?> selected <?php } ?> > <?php echo $payment_year; ?></option>
|
||||
@@ -74,7 +74,7 @@ $sql_vendor_expenses = mysqli_query($mysqli, "
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
while ($row = mysqli_fetch_array($sql_vendor_expenses)) {
|
||||
while ($row = mysqli_fetch_assoc($sql_vendor_expenses)) {
|
||||
$vendor_id = intval($row['vendor_id']);
|
||||
$vendor_name = nullable_htmlentities($row['vendor_name']);
|
||||
$amount_paid = floatval($row['amount_paid']); ?>
|
||||
@@ -85,7 +85,7 @@ $sql_vendor_expenses = mysqli_query($mysqli, "
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -35,7 +35,7 @@ $largest_expense_month = 0;
|
||||
<div class="card-body">
|
||||
<form class="mb-3">
|
||||
<select onchange="this.form.submit()" class="form-control" name="year">
|
||||
<?php while ($row = mysqli_fetch_array($sql_expense_years)) {
|
||||
<?php while ($row = mysqli_fetch_assoc($sql_expense_years)) {
|
||||
$expense_year = intval($row['expense_year']); ?>
|
||||
<option <?php if ($year == $expense_year) { ?> selected <?php } ?>><?php echo $expense_year; ?></option>
|
||||
<?php } ?>
|
||||
@@ -67,7 +67,7 @@ $largest_expense_month = 0;
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php while ($row = mysqli_fetch_array($sql_categories)) {
|
||||
<?php while ($row = mysqli_fetch_assoc($sql_categories)) {
|
||||
$category_id = intval($row['category_id']);
|
||||
$category_name = nullable_htmlentities($row['category_name']); ?>
|
||||
<tr>
|
||||
@@ -76,7 +76,7 @@ $largest_expense_month = 0;
|
||||
$total_expense_for_all_months = 0;
|
||||
for ($month = 1; $month <= 12; $month++) {
|
||||
$sql_expenses = mysqli_query($mysqli, "SELECT SUM(expense_amount) AS expense_amount_for_month FROM expenses WHERE expense_category_id = $category_id AND YEAR(expense_date) = $year AND MONTH(expense_date) = $month");
|
||||
$rowm = mysqli_fetch_array($sql_expenses);
|
||||
$rowm = mysqli_fetch_assoc($sql_expenses);
|
||||
$expense_amount_for_month = floatval($rowm['expense_amount_for_month']);
|
||||
$total_expense_for_all_months += $expense_amount_for_month;
|
||||
?>
|
||||
@@ -100,7 +100,7 @@ $largest_expense_month = 0;
|
||||
$grand_total_all_months = 0;
|
||||
for ($month = 1; $month <= 12; $month++) {
|
||||
$sql_expenses = mysqli_query($mysqli, "SELECT SUM(expense_amount) AS expense_total_amount_for_month FROM expenses WHERE YEAR(expense_date) = $year AND MONTH(expense_date) = $month AND expense_vendor_id > 0");
|
||||
$rowt = mysqli_fetch_array($sql_expenses);
|
||||
$rowt = mysqli_fetch_assoc($sql_expenses);
|
||||
$expense_total_amount_for_month = floatval($rowt['expense_total_amount_for_month']);
|
||||
$grand_total_all_months += $expense_total_amount_for_month;
|
||||
?>
|
||||
@@ -139,7 +139,7 @@ $largest_expense_month = 0;
|
||||
// Build series and track the largest month for axis max
|
||||
for ($month = 1; $month <= 12; $month++) {
|
||||
$sql_expenses = mysqli_query($mysqli, "SELECT SUM(expense_amount) AS expense_amount_for_month FROM expenses WHERE YEAR(expense_date) = $year AND MONTH(expense_date) = $month AND expense_vendor_id > 0");
|
||||
$rowm = mysqli_fetch_array($sql_expenses);
|
||||
$rowm = mysqli_fetch_assoc($sql_expenses);
|
||||
$expenses_for_month = floatval($rowm['expense_amount_for_month']);
|
||||
|
||||
if ($expenses_for_month > 0 && $expenses_for_month > $largest_expense_month) {
|
||||
|
||||
@@ -108,12 +108,12 @@
|
||||
<?php } ?>
|
||||
|
||||
<?php
|
||||
$sql_custom_links = mysqli_query($mysqli, "SELECT * FROM custom_links
|
||||
$sql_custom_links = mysqli_query($mysqli, "SELECT * FROM custom_links
|
||||
WHERE custom_link_location = 5 AND custom_link_archived_at IS NULL
|
||||
ORDER BY custom_link_order ASC, custom_link_name ASC"
|
||||
);
|
||||
|
||||
while ($row = mysqli_fetch_array($sql_custom_links)) {
|
||||
while ($row = mysqli_fetch_assoc($sql_custom_links)) {
|
||||
$custom_link_name = nullable_htmlentities($row['custom_link_name']);
|
||||
$custom_link_uri = sanitize_url($row['custom_link_uri']);
|
||||
$custom_link_icon = nullable_htmlentities($row['custom_link_icon']);
|
||||
|
||||
@@ -14,7 +14,7 @@ if (isset($_GET['year'])) {
|
||||
$year = date('Y');
|
||||
}
|
||||
|
||||
$sql_payment_years = mysqli_query($mysqli, "SELECT DISTINCT YEAR(payment_date) AS payment_year FROM payments
|
||||
$sql_payment_years = mysqli_query($mysqli, "SELECT DISTINCT YEAR(payment_date) AS payment_year FROM payments
|
||||
UNION SELECT DISTINCT YEAR(revenue_date) AS payment_year FROM revenues
|
||||
ORDER BY payment_year DESC"
|
||||
);
|
||||
@@ -34,7 +34,7 @@ $sql_payment_years = mysqli_query($mysqli, "SELECT DISTINCT YEAR(payment_date) A
|
||||
<option value="all" <?php if ($year == 'all') { ?> selected <?php } ?> >All Years</option>
|
||||
<?php
|
||||
|
||||
while ($row = mysqli_fetch_array($sql_payment_years)) {
|
||||
while ($row = mysqli_fetch_assoc($sql_payment_years)) {
|
||||
$payment_year = intval($row['payment_year']);
|
||||
?>
|
||||
<option <?php if ($year == $payment_year) { ?> selected <?php } ?> > <?php echo $payment_year; ?></option>
|
||||
@@ -58,7 +58,7 @@ $sql_payment_years = mysqli_query($mysqli, "SELECT DISTINCT YEAR(payment_date) A
|
||||
|
||||
$sql_clients = mysqli_query($mysqli, $sql_clients);
|
||||
?>
|
||||
|
||||
|
||||
<div class="table-responsive-sm">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
@@ -69,7 +69,7 @@ $sql_payment_years = mysqli_query($mysqli, "SELECT DISTINCT YEAR(payment_date) A
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
while ($row = mysqli_fetch_array($sql_clients)) {
|
||||
while ($row = mysqli_fetch_assoc($sql_clients)) {
|
||||
$client_id = intval($row['client_id']);
|
||||
$client_name = nullable_htmlentities($row['client_name']);
|
||||
$amount_paid = floatval($row['amount_paid']);
|
||||
@@ -82,7 +82,7 @@ $sql_payment_years = mysqli_query($mysqli, "SELECT DISTINCT YEAR(payment_date) A
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -92,4 +92,3 @@ $sql_payment_years = mysqli_query($mysqli, "SELECT DISTINCT YEAR(payment_date) A
|
||||
|
||||
<?php
|
||||
require_once "../../includes/footer.php";
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ if (isset($_GET['year'])) {
|
||||
}
|
||||
|
||||
$sql_payment_years = mysqli_query($mysqli, "SELECT DISTINCT YEAR(payment_date) AS payment_year FROM payments
|
||||
UNION SELECT DISTINCT YEAR(revenue_date) AS payment_year FROM revenues
|
||||
UNION SELECT DISTINCT YEAR(revenue_date) AS payment_year FROM revenues
|
||||
ORDER BY payment_year DESC");
|
||||
|
||||
$sql_categories = mysqli_query($mysqli, "SELECT * FROM categories WHERE category_type = 'Income' ORDER BY category_name ASC");
|
||||
@@ -37,7 +37,7 @@ $largest_income_month = 0;
|
||||
<div class="card-body p-0">
|
||||
<form class="p-3">
|
||||
<select onchange="this.form.submit()" class="form-control" name="year">
|
||||
<?php while ($row = mysqli_fetch_array($sql_payment_years)) {
|
||||
<?php while ($row = mysqli_fetch_assoc($sql_payment_years)) {
|
||||
$payment_year = intval($row['payment_year']); ?>
|
||||
<option <?php if ($year == $payment_year) { ?> selected <?php } ?>><?php echo $payment_year; ?></option>
|
||||
<?php } ?>
|
||||
@@ -71,7 +71,7 @@ $largest_income_month = 0;
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php while ($row = mysqli_fetch_array($sql_categories)) {
|
||||
<?php while ($row = mysqli_fetch_assoc($sql_categories)) {
|
||||
$category_id = intval($row['category_id']);
|
||||
$category_name = nullable_htmlentities($row['category_name']); ?>
|
||||
<tr>
|
||||
@@ -81,12 +81,12 @@ $largest_income_month = 0;
|
||||
for ($month = 1; $month <= 12; $month++) {
|
||||
// Payments to Invoices
|
||||
$sql_payments = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS payment_amount_for_month FROM payments, invoices WHERE payment_invoice_id = invoice_id AND invoice_category_id = $category_id AND YEAR(payment_date) = $year AND MONTH(payment_date) = $month");
|
||||
$row2 = mysqli_fetch_array($sql_payments);
|
||||
$row2 = mysqli_fetch_assoc($sql_payments);
|
||||
$payment_amount_for_month = floatval($row2['payment_amount_for_month']);
|
||||
|
||||
// Revenues
|
||||
$sql_revenues = mysqli_query($mysqli, "SELECT SUM(revenue_amount) AS revenue_amount_for_month FROM revenues WHERE revenue_category_id = $category_id AND YEAR(revenue_date) = $year AND MONTH(revenue_date) = $month");
|
||||
$row3 = mysqli_fetch_array($sql_revenues);
|
||||
$row3 = mysqli_fetch_assoc($sql_revenues);
|
||||
$revenues_amount_for_month = floatval($row3['revenue_amount_for_month']);
|
||||
|
||||
$payment_amount_for_month = $payment_amount_for_month + $revenues_amount_for_month;
|
||||
@@ -104,11 +104,11 @@ $largest_income_month = 0;
|
||||
$grand_total_all_months = 0;
|
||||
for ($month = 1; $month <= 12; $month++) {
|
||||
$sql_payments = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS payment_total_amount_for_month FROM payments, invoices WHERE payment_invoice_id = invoice_id AND YEAR(payment_date) = $year AND MONTH(payment_date) = $month");
|
||||
$row4 = mysqli_fetch_array($sql_payments);
|
||||
$row4 = mysqli_fetch_assoc($sql_payments);
|
||||
$payment_total_amount_for_month = floatval($row4['payment_total_amount_for_month']);
|
||||
|
||||
$sql_revenues = mysqli_query($mysqli, "SELECT SUM(revenue_amount) AS revenue_amount_for_month FROM revenues WHERE revenue_category_id > 0 AND YEAR(revenue_date) = $year AND MONTH(revenue_date) = $month");
|
||||
$row5 = mysqli_fetch_array($sql_revenues);
|
||||
$row5 = mysqli_fetch_assoc($sql_revenues);
|
||||
$revenues_total_amount_for_month = floatval($row5['revenue_amount_for_month']);
|
||||
|
||||
$payment_total_amount_for_month += $revenues_total_amount_for_month;
|
||||
@@ -154,11 +154,11 @@ $largest_income_month = 0;
|
||||
// Build series and track the largest month for axis max
|
||||
for ($month = 1; $month <= 12; $month++) {
|
||||
$sql_payments = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS payment_amount_for_month FROM payments, invoices WHERE payment_invoice_id = invoice_id AND YEAR(payment_date) = $year AND MONTH(payment_date) = $month");
|
||||
$r1 = mysqli_fetch_array($sql_payments);
|
||||
$r1 = mysqli_fetch_assoc($sql_payments);
|
||||
$payments_for_month = floatval($r1['payment_amount_for_month']);
|
||||
|
||||
$sql_revenues = mysqli_query($mysqli, "SELECT SUM(revenue_amount) AS revenue_amount_for_month FROM revenues WHERE revenue_category_id > 0 AND YEAR(revenue_date) = $year AND MONTH(revenue_date) = $month");
|
||||
$r2 = mysqli_fetch_array($sql_revenues);
|
||||
$r2 = mysqli_fetch_assoc($sql_revenues);
|
||||
$revenues_for_month = floatval($r2['revenue_amount_for_month']);
|
||||
|
||||
$income_for_month = $payments_for_month + $revenues_for_month;
|
||||
|
||||
@@ -36,7 +36,7 @@ $sql_categories_expense = mysqli_query($mysqli, "SELECT * FROM categories WHERE
|
||||
<select onchange="this.form.submit()" class="form-control" name="year">
|
||||
<?php
|
||||
|
||||
while ($row = mysqli_fetch_array($sql_all_years)) {
|
||||
while ($row = mysqli_fetch_assoc($sql_all_years)) {
|
||||
$all_years = intval($row['all_years']);
|
||||
?>
|
||||
<option <?php if ($year == $all_years) { ?> selected <?php } ?> > <?php echo $all_years; ?></option>
|
||||
@@ -65,7 +65,7 @@ $sql_categories_expense = mysqli_query($mysqli, "SELECT * FROM categories WHERE
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
while ($row = mysqli_fetch_array($sql_categories_income)) {
|
||||
while ($row = mysqli_fetch_assoc($sql_categories_income)) {
|
||||
$category_id = intval($row['category_id']);
|
||||
$category_name = nullable_htmlentities($row['category_name']);
|
||||
?>
|
||||
@@ -79,11 +79,11 @@ $sql_categories_expense = mysqli_query($mysqli, "SELECT * FROM categories WHERE
|
||||
|
||||
for($month = 1; $month<=3; $month++) {
|
||||
$sql_payments = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS payment_amount_for_month FROM payments, invoices WHERE payment_invoice_id = invoice_id AND invoice_category_id = $category_id AND YEAR(payment_date) = $year AND MONTH(payment_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_payments);
|
||||
$row = mysqli_fetch_assoc($sql_payments);
|
||||
$payment_amount_for_month = floatval($row['payment_amount_for_month']);
|
||||
|
||||
$sql_revenues = mysqli_query($mysqli, "SELECT SUM(revenue_amount) AS revenue_amount_for_month FROM revenues WHERE revenue_category_id = $category_id AND YEAR(revenue_date) = $year AND MONTH(revenue_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_revenues);
|
||||
$row = mysqli_fetch_assoc($sql_revenues);
|
||||
$revenue_amount_for_month = floatval($row['revenue_amount_for_month']);
|
||||
|
||||
$payment_amount_for_month = $payment_amount_for_month + $revenue_amount_for_month;
|
||||
@@ -101,11 +101,11 @@ $sql_categories_expense = mysqli_query($mysqli, "SELECT * FROM categories WHERE
|
||||
|
||||
for($month = 4; $month<=6; $month++) {
|
||||
$sql_payments = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS payment_amount_for_month FROM payments, invoices WHERE payment_invoice_id = invoice_id AND invoice_category_id = $category_id AND YEAR(payment_date) = $year AND MONTH(payment_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_payments);
|
||||
$row = mysqli_fetch_assoc($sql_payments);
|
||||
$payment_amount_for_month = floatval($row['payment_amount_for_month']);
|
||||
|
||||
$sql_revenues = mysqli_query($mysqli, "SELECT SUM(revenue_amount) AS revenue_amount_for_month FROM revenues WHERE revenue_category_id = $category_id AND YEAR(revenue_date) = $year AND MONTH(revenue_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_revenues);
|
||||
$row = mysqli_fetch_assoc($sql_revenues);
|
||||
$revenue_amount_for_month = floatval($row['revenue_amount_for_month']);
|
||||
|
||||
$payment_amount_for_month = $payment_amount_for_month + $revenue_amount_for_month;
|
||||
@@ -123,11 +123,11 @@ $sql_categories_expense = mysqli_query($mysqli, "SELECT * FROM categories WHERE
|
||||
|
||||
for($month = 7; $month<=9; $month++) {
|
||||
$sql_payments = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS payment_amount_for_month FROM payments, invoices WHERE payment_invoice_id = invoice_id AND invoice_category_id = $category_id AND YEAR(payment_date) = $year AND MONTH(payment_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_payments);
|
||||
$row = mysqli_fetch_assoc($sql_payments);
|
||||
$payment_amount_for_month = floatval($row['payment_amount_for_month']);
|
||||
|
||||
$sql_revenues = mysqli_query($mysqli, "SELECT SUM(revenue_amount) AS revenue_amount_for_month FROM revenues WHERE revenue_category_id = $category_id AND YEAR(revenue_date) = $year AND MONTH(revenue_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_revenues);
|
||||
$row = mysqli_fetch_assoc($sql_revenues);
|
||||
$revenue_amount_for_month = floatval($row['revenue_amount_for_month']);
|
||||
|
||||
$payment_amount_for_month = $payment_amount_for_month + $revenue_amount_for_month;
|
||||
@@ -144,11 +144,11 @@ $sql_categories_expense = mysqli_query($mysqli, "SELECT * FROM categories WHERE
|
||||
|
||||
for($month = 10; $month<=12; $month++) {
|
||||
$sql_payments = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS payment_amount_for_month FROM payments, invoices WHERE payment_invoice_id = invoice_id AND invoice_category_id = $category_id AND YEAR(payment_date) = $year AND MONTH(payment_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_payments);
|
||||
$row = mysqli_fetch_assoc($sql_payments);
|
||||
$payment_amount_for_month = floatval($row['payment_amount_for_month']);
|
||||
|
||||
$sql_revenues = mysqli_query($mysqli, "SELECT SUM(revenue_amount) AS revenue_amount_for_month FROM revenues WHERE revenue_category_id = $category_id AND YEAR(revenue_date) = $year AND MONTH(revenue_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_revenues);
|
||||
$row = mysqli_fetch_assoc($sql_revenues);
|
||||
$revenue_amount_for_month = floatval($row['revenue_amount_for_month']);
|
||||
|
||||
$payment_amount_for_month = $payment_amount_for_month + $revenue_amount_for_month;
|
||||
@@ -180,11 +180,11 @@ $sql_categories_expense = mysqli_query($mysqli, "SELECT * FROM categories WHERE
|
||||
|
||||
for($month = 1; $month<=3; $month++) {
|
||||
$sql_payments = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS payment_total_amount_for_month FROM payments, invoices WHERE payment_invoice_id = invoice_id AND YEAR(payment_date) = $year AND MONTH(payment_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_payments);
|
||||
$row = mysqli_fetch_assoc($sql_payments);
|
||||
$payment_total_amount_for_month = floatval($row['payment_total_amount_for_month']);
|
||||
|
||||
$sql_revenues = mysqli_query($mysqli, "SELECT SUM(revenue_amount) AS revenue_total_amount_for_month FROM revenues WHERE revenue_category_id > 0 AND YEAR(revenue_date) = $year AND MONTH(revenue_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_revenues);
|
||||
$row = mysqli_fetch_assoc($sql_revenues);
|
||||
$revenue_total_amount_for_month = floatval($row['revenue_total_amount_for_month']);
|
||||
|
||||
$payment_total_amount_for_month = $payment_total_amount_for_month + $revenue_total_amount_for_month;
|
||||
@@ -202,11 +202,11 @@ $sql_categories_expense = mysqli_query($mysqli, "SELECT * FROM categories WHERE
|
||||
|
||||
for($month = 4; $month<=6; $month++) {
|
||||
$sql_payments = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS payment_total_amount_for_month FROM payments, invoices WHERE payment_invoice_id = invoice_id AND YEAR(payment_date) = $year AND MONTH(payment_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_payments);
|
||||
$row = mysqli_fetch_assoc($sql_payments);
|
||||
$payment_total_amount_for_month = floatval($row['payment_total_amount_for_month']);
|
||||
|
||||
$sql_revenues = mysqli_query($mysqli, "SELECT SUM(revenue_amount) AS revenue_total_amount_for_month FROM revenues WHERE revenue_category_id > 0 AND YEAR(revenue_date) = $year AND MONTH(revenue_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_revenues);
|
||||
$row = mysqli_fetch_assoc($sql_revenues);
|
||||
$revenue_total_amount_for_month = floatval($row['revenue_total_amount_for_month']);
|
||||
|
||||
$payment_total_amount_for_month = $payment_total_amount_for_month + $revenue_total_amount_for_month;
|
||||
@@ -224,11 +224,11 @@ $sql_categories_expense = mysqli_query($mysqli, "SELECT * FROM categories WHERE
|
||||
|
||||
for($month = 7; $month<=9; $month++) {
|
||||
$sql_payments = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS payment_total_amount_for_month FROM payments, invoices WHERE payment_invoice_id = invoice_id AND YEAR(payment_date) = $year AND MONTH(payment_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_payments);
|
||||
$row = mysqli_fetch_assoc($sql_payments);
|
||||
$payment_total_amount_for_month = floatval($row['payment_total_amount_for_month']);
|
||||
|
||||
$sql_revenues = mysqli_query($mysqli, "SELECT SUM(revenue_amount) AS revenue_total_amount_for_month FROM revenues WHERE revenue_category_id > 0 AND YEAR(revenue_date) = $year AND MONTH(revenue_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_revenues);
|
||||
$row = mysqli_fetch_assoc($sql_revenues);
|
||||
$revenue_total_amount_for_month = floatval($row['revenue_total_amount_for_month']);
|
||||
|
||||
$payment_total_amount_for_month = $payment_total_amount_for_month + $revenue_total_amount_for_month;
|
||||
@@ -246,11 +246,11 @@ $sql_categories_expense = mysqli_query($mysqli, "SELECT * FROM categories WHERE
|
||||
|
||||
for($month = 10; $month<=12; $month++) {
|
||||
$sql_payments = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS payment_total_amount_for_month FROM payments, invoices WHERE payment_invoice_id = invoice_id AND YEAR(payment_date) = $year AND MONTH(payment_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_payments);
|
||||
$row = mysqli_fetch_assoc($sql_payments);
|
||||
$payment_total_amount_for_month = floatval($row['payment_total_amount_for_month']);
|
||||
|
||||
$sql_revenues = mysqli_query($mysqli, "SELECT SUM(revenue_amount) AS revenue_total_amount_for_month FROM revenues WHERE revenue_category_id > 0 AND YEAR(revenue_date) = $year AND MONTH(revenue_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_revenues);
|
||||
$row = mysqli_fetch_assoc($sql_revenues);
|
||||
$revenue_total_amount_for_month = floatval($row['revenue_total_amount_for_month']);
|
||||
|
||||
$payment_total_amount_for_month = $payment_total_amount_for_month + $revenue_total_amount_for_month;
|
||||
@@ -272,7 +272,7 @@ $sql_categories_expense = mysqli_query($mysqli, "SELECT * FROM categories WHERE
|
||||
<th colspan="5"></th>
|
||||
</tr>
|
||||
<?php
|
||||
while ($row = mysqli_fetch_array($sql_categories_expense)) {
|
||||
while ($row = mysqli_fetch_assoc($sql_categories_expense)) {
|
||||
$category_id = intval($row['category_id']);
|
||||
$category_name = nullable_htmlentities($row['category_name']);
|
||||
?>
|
||||
@@ -286,7 +286,7 @@ $sql_categories_expense = mysqli_query($mysqli, "SELECT * FROM categories WHERE
|
||||
|
||||
for($month = 1; $month<=3; $month++) {
|
||||
$sql_expenses = mysqli_query($mysqli, "SELECT SUM(expense_amount) AS expense_amount_for_month FROM expenses WHERE expense_category_id = $category_id AND YEAR(expense_date) = $year AND MONTH(expense_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_expenses);
|
||||
$row = mysqli_fetch_assoc($sql_expenses);
|
||||
$expense_amount_for_quarter_one = $expense_amount_for_quarter_one + floatval($row['expense_amount_for_month']);
|
||||
}
|
||||
|
||||
@@ -300,7 +300,7 @@ $sql_categories_expense = mysqli_query($mysqli, "SELECT * FROM categories WHERE
|
||||
|
||||
for($month = 4; $month<=6; $month++) {
|
||||
$sql_expenses = mysqli_query($mysqli, "SELECT SUM(expense_amount) AS expense_amount_for_month FROM expenses WHERE expense_category_id = $category_id AND YEAR(expense_date) = $year AND MONTH(expense_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_expenses);
|
||||
$row = mysqli_fetch_assoc($sql_expenses);
|
||||
$expense_amount_for_quarter_two = $expense_amount_for_quarter_two + floatval($row['expense_amount_for_month']);
|
||||
}
|
||||
|
||||
@@ -314,7 +314,7 @@ $sql_categories_expense = mysqli_query($mysqli, "SELECT * FROM categories WHERE
|
||||
|
||||
for($month = 7; $month<=9; $month++) {
|
||||
$sql_expenses = mysqli_query($mysqli, "SELECT SUM(expense_amount) AS expense_amount_for_month FROM expenses WHERE expense_category_id = $category_id AND YEAR(expense_date) = $year AND MONTH(expense_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_expenses);
|
||||
$row = mysqli_fetch_assoc($sql_expenses);
|
||||
$expense_amount_for_quarter_three = $expense_amount_for_quarter_three + floatval($row['expense_amount_for_month']);
|
||||
}
|
||||
|
||||
@@ -328,7 +328,7 @@ $sql_categories_expense = mysqli_query($mysqli, "SELECT * FROM categories WHERE
|
||||
|
||||
for($month = 10; $month<=12; $month++) {
|
||||
$sql_expenses = mysqli_query($mysqli, "SELECT SUM(expense_amount) AS expense_amount_for_month FROM expenses WHERE expense_category_id = $category_id AND YEAR(expense_date) = $year AND MONTH(expense_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_expenses);
|
||||
$row = mysqli_fetch_assoc($sql_expenses);
|
||||
$expense_amount_for_quarter_four = $expense_amount_for_quarter_four + floatval($row['expense_amount_for_month']);
|
||||
}
|
||||
|
||||
@@ -357,7 +357,7 @@ $sql_categories_expense = mysqli_query($mysqli, "SELECT * FROM categories WHERE
|
||||
|
||||
for($month = 1; $month<=3; $month++) {
|
||||
$sql_expenses = mysqli_query($mysqli, "SELECT SUM(expense_amount) AS expense_total_amount_for_month FROM expenses WHERE expense_category_id > 0 AND YEAR(expense_date) = $year AND MONTH(expense_date) = $month AND expense_vendor_id > 0");
|
||||
$row = mysqli_fetch_array($sql_expenses);
|
||||
$row = mysqli_fetch_assoc($sql_expenses);
|
||||
$expense_total_amount_for_quarter_one = $expense_total_amount_for_quarter_one + floatval($row['expense_total_amount_for_month']);
|
||||
}
|
||||
|
||||
@@ -371,7 +371,7 @@ $sql_categories_expense = mysqli_query($mysqli, "SELECT * FROM categories WHERE
|
||||
|
||||
for($month = 4; $month<=6; $month++) {
|
||||
$sql_expenses = mysqli_query($mysqli, "SELECT SUM(expense_amount) AS expense_total_amount_for_month FROM expenses WHERE expense_category_id > 0 AND YEAR(expense_date) = $year AND MONTH(expense_date) = $month AND expense_vendor_id > 0");
|
||||
$row = mysqli_fetch_array($sql_expenses);
|
||||
$row = mysqli_fetch_assoc($sql_expenses);
|
||||
$expense_total_amount_for_quarter_two = $expense_total_amount_for_quarter_two + floatval($row['expense_total_amount_for_month']);
|
||||
}
|
||||
|
||||
@@ -385,7 +385,7 @@ $sql_categories_expense = mysqli_query($mysqli, "SELECT * FROM categories WHERE
|
||||
|
||||
for($month = 7; $month<=9; $month++) {
|
||||
$sql_expenses = mysqli_query($mysqli, "SELECT SUM(expense_amount) AS expense_total_amount_for_month FROM expenses WHERE expense_category_id > 0 AND YEAR(expense_date) = $year AND MONTH(expense_date) = $month AND expense_vendor_id > 0");
|
||||
$row = mysqli_fetch_array($sql_expenses);
|
||||
$row = mysqli_fetch_assoc($sql_expenses);
|
||||
$expense_total_amount_for_quarter_three = $expense_total_amount_for_quarter_three + floatval($row['expense_total_amount_for_month']);
|
||||
}
|
||||
|
||||
@@ -399,7 +399,7 @@ $sql_categories_expense = mysqli_query($mysqli, "SELECT * FROM categories WHERE
|
||||
|
||||
for($month = 10; $month<=12; $month++) {
|
||||
$sql_expenses = mysqli_query($mysqli, "SELECT SUM(expense_amount) AS expense_total_amount_for_month FROM expenses WHERE expense_category_id > 0 AND YEAR(expense_date) = $year AND MONTH(expense_date) = $month AND expense_vendor_id > 0");
|
||||
$row = mysqli_fetch_array($sql_expenses);
|
||||
$row = mysqli_fetch_assoc($sql_expenses);
|
||||
$expense_total_amount_for_quarter_four = $expense_total_amount_for_quarter_four + floatval($row['expense_total_amount_for_month']);
|
||||
}
|
||||
|
||||
@@ -434,4 +434,3 @@ $sql_categories_expense = mysqli_query($mysqli, "SELECT * FROM categories WHERE
|
||||
</div>
|
||||
|
||||
<?php require_once "../../includes/footer.php";
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ $sql = mysqli_query($mysqli, "
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
while ($row = mysqli_fetch_array($sql)) {
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$client_id = intval($row['client_id']);
|
||||
$client_name = nullable_htmlentities($row['client_name']);
|
||||
$recurring_monthly_total = floatval($row['recurring_monthly_total']);
|
||||
|
||||
@@ -8,7 +8,7 @@ $year = isset($_GET['year']) ? intval($_GET['year']) : date('Y');
|
||||
|
||||
$view = isset($_GET['view']) ? $_GET['view'] : 'quarterly';
|
||||
|
||||
$currency_row = mysqli_fetch_array(mysqli_query($mysqli,"SELECT company_currency FROM companies WHERE company_id = 1"));
|
||||
$currency_row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT company_currency FROM companies WHERE company_id = 1"));
|
||||
$company_currency = nullable_htmlentities($currency_row['company_currency']);
|
||||
|
||||
// GET unique years from expenses, payments and revenues
|
||||
@@ -30,7 +30,7 @@ $sql_tax = mysqli_query($mysqli, "SELECT `tax_name` FROM `taxes`");
|
||||
<select onchange="this.form.submit()" class="form-control" name="year">
|
||||
<?php
|
||||
|
||||
while ($row = mysqli_fetch_array($sql_all_years)) {
|
||||
while ($row = mysqli_fetch_assoc($sql_all_years)) {
|
||||
$all_years = intval($row['all_years']);
|
||||
?>
|
||||
<option <?php if ($year == $all_years) { echo "selected"; } ?> > <?php echo $all_years; ?></option>
|
||||
@@ -70,7 +70,7 @@ $sql_tax = mysqli_query($mysqli, "SELECT `tax_name` FROM `taxes`");
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
while ($row = mysqli_fetch_array($sql_tax)) {
|
||||
while ($row = mysqli_fetch_assoc($sql_tax)) {
|
||||
$tax_name = sanitizeInput($row['tax_name']);
|
||||
echo "<tr>";
|
||||
echo "<td>" . $row['tax_name'] . "</td>";
|
||||
@@ -118,4 +118,3 @@ $sql_tax = mysqli_query($mysqli, "SELECT `tax_name` FROM `taxes`");
|
||||
</div>
|
||||
|
||||
<?php require_once "../../includes/footer.php";
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ $sql_clients = mysqli_query($mysqli, "SELECT client_id, client_name FROM clients
|
||||
<form class="mb-3">
|
||||
<select onchange="this.form.submit()" class="form-control" name="year">
|
||||
<?php
|
||||
while ($row = mysqli_fetch_array($sql_ticket_years)) {
|
||||
while ($row = mysqli_fetch_assoc($sql_ticket_years)) {
|
||||
$ticket_year = intval($row['ticket_year']); ?>
|
||||
<option <?php if ($year == $ticket_year) { ?> selected <?php } ?> > <?php echo $ticket_year; ?></option>
|
||||
<?php } ?>
|
||||
@@ -116,33 +116,33 @@ $sql_clients = mysqli_query($mysqli, "SELECT client_id, client_name FROM clients
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
while ($row = mysqli_fetch_array($sql_clients)) {
|
||||
while ($row = mysqli_fetch_assoc($sql_clients)) {
|
||||
$client_id = intval($row['client_id']);
|
||||
$client_name = nullable_htmlentities($row['client_name']);
|
||||
|
||||
// Calculate total tickets raised in period
|
||||
$sql_ticket_raised_count = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS ticket_raised_count FROM tickets WHERE YEAR(ticket_created_at) = $year AND ticket_client_id = $client_id");
|
||||
$row = mysqli_fetch_array($sql_ticket_raised_count);
|
||||
$row = mysqli_fetch_assoc($sql_ticket_raised_count);
|
||||
$ticket_raised_count = intval($row['ticket_raised_count']);
|
||||
|
||||
// Calculate total tickets raised in period that are resolved
|
||||
$sql_ticket_resolved_count = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS ticket_resolved_count FROM tickets WHERE YEAR(ticket_created_at) = $year AND ticket_client_id = $client_id AND ticket_resolved_at IS NOT NULL");
|
||||
$row = mysqli_fetch_array($sql_ticket_resolved_count);
|
||||
$row = mysqli_fetch_assoc($sql_ticket_resolved_count);
|
||||
$ticket_resolved_count = intval($row['ticket_resolved_count']);
|
||||
|
||||
// Breakdown tickets for each priority - Low
|
||||
$sql_low_ticket_count = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS low_ticket_count FROM tickets WHERE YEAR(ticket_created_at) = $year AND ticket_client_id = $client_id AND ticket_priority = 'Low'");
|
||||
$row = mysqli_fetch_array($sql_low_ticket_count);
|
||||
$row = mysqli_fetch_assoc($sql_low_ticket_count);
|
||||
$low_ticket_count = intval($row['low_ticket_count']);
|
||||
|
||||
// Breakdown tickets for each priority - Low
|
||||
$sql_med_ticket_count = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS med_ticket_count FROM tickets WHERE YEAR(ticket_created_at) = $year AND ticket_client_id = $client_id AND ticket_priority = 'Medium'");
|
||||
$row = mysqli_fetch_array($sql_med_ticket_count);
|
||||
$row = mysqli_fetch_assoc($sql_med_ticket_count);
|
||||
$med_ticket_count = intval($row['med_ticket_count']);
|
||||
|
||||
// Breakdown tickets for each priority - Low
|
||||
$sql_high_ticket_count = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS high_ticket_count FROM tickets WHERE YEAR(ticket_created_at) = $year AND ticket_client_id = $client_id AND ticket_priority = 'High'");
|
||||
$row = mysqli_fetch_array($sql_high_ticket_count);
|
||||
$row = mysqli_fetch_assoc($sql_high_ticket_count);
|
||||
$high_ticket_count = intval($row['high_ticket_count']);
|
||||
|
||||
// Used to calculate average time to respond to tickets that were raised in period specified
|
||||
@@ -153,7 +153,7 @@ $sql_clients = mysqli_query($mysqli, "SELECT client_id, client_name FROM clients
|
||||
|
||||
// Calculate total time tracked towards tickets in the period
|
||||
$sql_time = mysqli_query($mysqli, "SELECT SEC_TO_TIME(SUM(TIME_TO_SEC(ticket_reply_time_worked))) as total_time FROM ticket_replies LEFT JOIN tickets ON tickets.ticket_id = ticket_replies.ticket_reply_ticket_id WHERE YEAR(ticket_created_at) = $year AND ticket_client_id = $client_id AND ticket_reply_time_worked IS NOT NULL");
|
||||
$row = mysqli_fetch_array($sql_time);
|
||||
$row = mysqli_fetch_assoc($sql_time);
|
||||
$ticket_total_time_worked = nullable_htmlentities($row['total_time']);
|
||||
|
||||
if ($ticket_raised_count > 0 || $ticket_resolved_count > 0) {
|
||||
@@ -162,7 +162,7 @@ $sql_clients = mysqli_query($mysqli, "SELECT client_id, client_name FROM clients
|
||||
$avg_time_to_respond = '-';
|
||||
$count = 0;
|
||||
$total = 0;
|
||||
while ($row = mysqli_fetch_array($sql_tickets_respond)) {
|
||||
while ($row = mysqli_fetch_assoc($sql_tickets_respond)) {
|
||||
if (!empty($row['ticket_first_response_at'])) {
|
||||
$openedTime = new DateTime($row['ticket_created_at']);
|
||||
$respondTime = new DateTime($row['ticket_first_response_at']);
|
||||
@@ -179,7 +179,7 @@ $sql_clients = mysqli_query($mysqli, "SELECT client_id, client_name FROM clients
|
||||
if ($ticket_resolved_count > 0) {
|
||||
$count = 0;
|
||||
$total = 0;
|
||||
while ($row = mysqli_fetch_array($sql_tickets_resolved)) {
|
||||
while ($row = mysqli_fetch_assoc($sql_tickets_resolved)) {
|
||||
$openedTime = new DateTime($row['ticket_created_at']);
|
||||
$resolvedTime = new DateTime($row['ticket_resolved_at']);
|
||||
|
||||
@@ -238,33 +238,33 @@ $sql_clients = mysqli_query($mysqli, "SELECT client_id, client_name FROM clients
|
||||
<tbody>
|
||||
<?php
|
||||
mysqli_data_seek($sql_clients, 0); // Reset
|
||||
while ($row = mysqli_fetch_array($sql_clients)) {
|
||||
while ($row = mysqli_fetch_assoc($sql_clients)) {
|
||||
$client_id = intval($row['client_id']);
|
||||
$client_name = nullable_htmlentities($row['client_name']);
|
||||
|
||||
// Calculate total tickets raised in period
|
||||
$sql_ticket_raised_count = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS ticket_raised_count FROM tickets WHERE YEAR(ticket_created_at) = $year AND MONTH(ticket_created_at) = $month AND ticket_client_id = $client_id");
|
||||
$row = mysqli_fetch_array($sql_ticket_raised_count);
|
||||
$row = mysqli_fetch_assoc($sql_ticket_raised_count);
|
||||
$ticket_raised_count = intval($row['ticket_raised_count']);
|
||||
|
||||
// Calculate total tickets raised in period that are resolved
|
||||
$sql_ticket_resolved_count = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS ticket_resolved_count FROM tickets WHERE YEAR(ticket_created_at) = $year AND MONTH(ticket_created_at) = $month AND ticket_client_id = $client_id AND ticket_resolved_at IS NOT NULL");
|
||||
$row = mysqli_fetch_array($sql_ticket_resolved_count);
|
||||
$row = mysqli_fetch_assoc($sql_ticket_resolved_count);
|
||||
$ticket_resolved_count = intval($row['ticket_resolved_count']);
|
||||
|
||||
// Breakdown tickets for each priority - Low
|
||||
$sql_low_ticket_count = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS low_ticket_count FROM tickets WHERE YEAR(ticket_created_at) = $year AND MONTH(ticket_created_at) = $month AND ticket_client_id = $client_id AND ticket_priority = 'Low'");
|
||||
$row = mysqli_fetch_array($sql_low_ticket_count);
|
||||
$row = mysqli_fetch_assoc($sql_low_ticket_count);
|
||||
$low_ticket_count = intval($row['low_ticket_count']);
|
||||
|
||||
// Breakdown tickets for each priority - Low
|
||||
$sql_med_ticket_count = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS med_ticket_count FROM tickets WHERE YEAR(ticket_created_at) = $year AND MONTH(ticket_created_at) = $month AND ticket_client_id = $client_id AND ticket_priority = 'Medium'");
|
||||
$row = mysqli_fetch_array($sql_med_ticket_count);
|
||||
$row = mysqli_fetch_assoc($sql_med_ticket_count);
|
||||
$med_ticket_count = intval($row['med_ticket_count']);
|
||||
|
||||
// Breakdown tickets for each priority - Low
|
||||
$sql_high_ticket_count = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS high_ticket_count FROM tickets WHERE YEAR(ticket_created_at) = $year AND MONTH(ticket_created_at) = $month AND ticket_client_id = $client_id AND ticket_priority = 'High'");
|
||||
$row = mysqli_fetch_array($sql_high_ticket_count);
|
||||
$row = mysqli_fetch_assoc($sql_high_ticket_count);
|
||||
$high_ticket_count = intval($row['high_ticket_count']);
|
||||
|
||||
// Used to calculate average time to respond to tickets that were raised in period specified
|
||||
@@ -275,7 +275,7 @@ $sql_clients = mysqli_query($mysqli, "SELECT client_id, client_name FROM clients
|
||||
|
||||
// Calculate total time tracked towards tickets in the period
|
||||
$sql_time = mysqli_query($mysqli, "SELECT SEC_TO_TIME(SUM(TIME_TO_SEC(ticket_reply_time_worked))) as total_time FROM ticket_replies LEFT JOIN tickets ON tickets.ticket_id = ticket_replies.ticket_reply_ticket_id WHERE YEAR(ticket_created_at) = $year AND MONTH(ticket_created_at) = $month AND ticket_client_id = $client_id AND ticket_reply_time_worked IS NOT NULL");
|
||||
$row = mysqli_fetch_array($sql_time);
|
||||
$row = mysqli_fetch_assoc($sql_time);
|
||||
$ticket_total_time_worked = nullable_htmlentities($row['total_time']);
|
||||
|
||||
if ($ticket_raised_count > 0 || $ticket_resolved_count > 0) {
|
||||
@@ -284,7 +284,7 @@ $sql_clients = mysqli_query($mysqli, "SELECT client_id, client_name FROM clients
|
||||
$avg_time_to_respond = '-';
|
||||
$count = 0;
|
||||
$total = 0;
|
||||
while ($row = mysqli_fetch_array($sql_tickets_respond)) {
|
||||
while ($row = mysqli_fetch_assoc($sql_tickets_respond)) {
|
||||
if (!empty($row['ticket_first_response_at'])) {
|
||||
$openedTime = new DateTime($row['ticket_created_at']);
|
||||
$respondTime = new DateTime($row['ticket_first_response_at']);
|
||||
@@ -301,7 +301,7 @@ $sql_clients = mysqli_query($mysqli, "SELECT client_id, client_name FROM clients
|
||||
if ($ticket_resolved_count > 0) {
|
||||
$count = 0;
|
||||
$total = 0;
|
||||
while ($row = mysqli_fetch_array($sql_tickets_resolved)) {
|
||||
while ($row = mysqli_fetch_assoc($sql_tickets_resolved)) {
|
||||
$openedTime = new DateTime($row['ticket_created_at']);
|
||||
$resolvedTime = new DateTime($row['ticket_resolved_at']);
|
||||
|
||||
@@ -340,4 +340,3 @@ $sql_clients = mysqli_query($mysqli, "SELECT client_id, client_name FROM clients
|
||||
|
||||
<?php
|
||||
require_once "../../includes/footer.php";
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ $largest_ticket_month = 0;
|
||||
<form class="p-3">
|
||||
<select onchange="this.form.submit()" class="form-control" name="year">
|
||||
<?php
|
||||
while ($row = mysqli_fetch_array($sql_ticket_years)) {
|
||||
while ($row = mysqli_fetch_assoc($sql_ticket_years)) {
|
||||
$ticket_year = intval($row['ticket_year']); ?>
|
||||
<option <?php if ($year == $ticket_year) { ?> selected <?php } ?>><?php echo $ticket_year; ?></option>
|
||||
<?php } ?>
|
||||
@@ -76,7 +76,7 @@ $largest_ticket_month = 0;
|
||||
for ($month = 1; $month <= 12; $month++) {
|
||||
|
||||
$sql_tickets = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS tickets_for_month FROM tickets WHERE YEAR(ticket_created_at) = $year AND MONTH(ticket_created_at) = $month");
|
||||
$row = mysqli_fetch_array($sql_tickets);
|
||||
$row = mysqli_fetch_assoc($sql_tickets);
|
||||
$tickets_for_month = intval($row['tickets_for_month']);
|
||||
|
||||
if ($tickets_for_month > 0 && $tickets_for_month > $largest_ticket_month) {
|
||||
@@ -111,7 +111,7 @@ $largest_ticket_month = 0;
|
||||
// Recompute for the chart dataset (values already gathered above, but we echo directly again)
|
||||
for ($month = 1; $month <= 12; $month++) {
|
||||
$sql_tickets = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS tickets_for_month FROM tickets WHERE YEAR(ticket_created_at) = $year AND MONTH(ticket_created_at) = $month");
|
||||
$row = mysqli_fetch_array($sql_tickets);
|
||||
$row = mysqli_fetch_assoc($sql_tickets);
|
||||
$tickets_for_month = intval($row['tickets_for_month']);
|
||||
echo "$tickets_for_month,";
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ $rows = 0;
|
||||
<form class="mb-3">
|
||||
<select onchange="this.form.submit()" class="form-control" name="year">
|
||||
<?php
|
||||
while ($row = mysqli_fetch_array($sql_ticket_years)) {
|
||||
while ($row = mysqli_fetch_assoc($sql_ticket_years)) {
|
||||
$ticket_year = intval($row['ticket_year']); ?>
|
||||
<option <?php if ($year == $ticket_year) { ?> selected <?php } ?> > <?php echo $ticket_year; ?></option>
|
||||
<?php } ?>
|
||||
@@ -87,7 +87,7 @@ $rows = 0;
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
while ($row = mysqli_fetch_array($sql_clients)) {
|
||||
while ($row = mysqli_fetch_assoc($sql_clients)) {
|
||||
$client_id = intval($row['client_id']);
|
||||
$client_name = nullable_htmlentities($row['client_name']);
|
||||
|
||||
@@ -103,7 +103,7 @@ $rows = 0;
|
||||
AND
|
||||
ticket_client_id = $client_id"
|
||||
);
|
||||
$row = mysqli_fetch_array($sql_ticket_raised_count);
|
||||
$row = mysqli_fetch_assoc($sql_ticket_raised_count);
|
||||
$ticket_raised_count = intval($row['ticket_raised_count']);
|
||||
|
||||
// Calculate total tickets raised in period that are closed and billable
|
||||
@@ -122,7 +122,7 @@ $rows = 0;
|
||||
AND
|
||||
ticket_billable = 1
|
||||
");
|
||||
$row = mysqli_fetch_array($sql_ticket_closed_count);
|
||||
$row = mysqli_fetch_assoc($sql_ticket_closed_count);
|
||||
$ticket_closed_count = intval($row['ticket_closed_count']);
|
||||
|
||||
// Calculate total tickets raised in period that are closed and billable, but not invoiced
|
||||
@@ -142,7 +142,7 @@ $rows = 0;
|
||||
ticket_billable = 1
|
||||
AND
|
||||
ticket_invoice_id = 0");
|
||||
$row = mysqli_fetch_array($sql_ticket_unbilled_count);
|
||||
$row = mysqli_fetch_assoc($sql_ticket_unbilled_count);
|
||||
$ticket_unbilled_count = intval($row['ticket_unbilled_count']);
|
||||
|
||||
if ($ticket_unbilled_count > 0) {
|
||||
@@ -179,4 +179,3 @@ $rows = 0;
|
||||
|
||||
<?php
|
||||
require_once "../../includes/footer.php";
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ $sql_users = mysqli_query($mysqli, "
|
||||
LEFT JOIN user_settings on users.user_id = user_settings.user_id
|
||||
WHERE user_type = 1
|
||||
AND user_status = 1
|
||||
AND user_archived_at IS NULL
|
||||
AND user_archived_at IS NULL
|
||||
ORDER BY user_name DESC"
|
||||
);
|
||||
// TODO: Maybe try and filter this to just users with the support module perm
|
||||
@@ -83,7 +83,7 @@ $sql_users = mysqli_query($mysqli, "
|
||||
<form class="mb-3">
|
||||
<select onchange="this.form.submit()" class="form-control" name="year">
|
||||
<?php
|
||||
while ($row = mysqli_fetch_array($sql_ticket_years)) {
|
||||
while ($row = mysqli_fetch_assoc($sql_ticket_years)) {
|
||||
$ticket_year = intval($row['ticket_year']); ?>
|
||||
<option <?php if ($year == $ticket_year) { ?> selected <?php } ?> > <?php echo $ticket_year; ?></option>
|
||||
<?php } ?>
|
||||
@@ -108,13 +108,13 @@ $sql_users = mysqli_query($mysqli, "
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
while ($agent_row = mysqli_fetch_array($sql_users)) {
|
||||
while ($agent_row = mysqli_fetch_assoc($sql_users)) {
|
||||
$user_id = intval($agent_row['user_id']);
|
||||
$user_name = nullable_htmlentities($agent_row['user_name']);
|
||||
|
||||
// Get tickets in period that are still assigned to the technician/agent
|
||||
$sql_ticket_count = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS ticket_count FROM tickets WHERE YEAR(ticket_created_at) = $year AND ticket_assigned_to = $user_id");
|
||||
$row = mysqli_fetch_array($sql_ticket_count);
|
||||
$row = mysqli_fetch_assoc($sql_ticket_count);
|
||||
$ticket_raised_count = intval($row['ticket_count']);
|
||||
|
||||
// Get unique tickets in period that the agent replied to/touched
|
||||
@@ -122,34 +122,34 @@ $sql_users = mysqli_query($mysqli, "
|
||||
SELECT COUNT(DISTINCT ticket_id) AS tickets_touched
|
||||
FROM (
|
||||
-- Tickets the agent replied to
|
||||
SELECT ticket_reply_ticket_id AS ticket_id
|
||||
FROM ticket_replies
|
||||
SELECT ticket_reply_ticket_id AS ticket_id
|
||||
FROM ticket_replies
|
||||
WHERE YEAR(ticket_reply_created_at) = $year AND ticket_reply_by = $user_id
|
||||
|
||||
|
||||
UNION
|
||||
|
||||
|
||||
-- Tickets the agent opened
|
||||
SELECT ticket_id
|
||||
FROM tickets
|
||||
SELECT ticket_id
|
||||
FROM tickets
|
||||
WHERE YEAR(ticket_created_at) = $year AND ticket_created_by = $user_id
|
||||
|
||||
|
||||
UNION
|
||||
|
||||
|
||||
-- Tickets the agent closed
|
||||
SELECT ticket_id
|
||||
FROM tickets
|
||||
SELECT ticket_id
|
||||
FROM tickets
|
||||
WHERE YEAR(ticket_created_at) = $year AND ticket_closed_by = $user_id
|
||||
)
|
||||
AS tickets_touched
|
||||
");
|
||||
|
||||
$row = mysqli_fetch_array($sql_tickets_touched);
|
||||
$row = mysqli_fetch_assoc($sql_tickets_touched);
|
||||
$tickets_touched = intval($row['tickets_touched']);
|
||||
|
||||
|
||||
// Calculate total time tracked towards tickets in the period (for this agent)
|
||||
$sql_time = mysqli_query($mysqli, "SELECT SEC_TO_TIME(SUM(TIME_TO_SEC(ticket_reply_time_worked))) as total_time FROM ticket_replies LEFT JOIN tickets ON tickets.ticket_id = ticket_replies.ticket_reply_ticket_id WHERE YEAR(ticket_created_at) = $year AND ticket_reply_by = $user_id AND ticket_reply_time_worked IS NOT NULL");
|
||||
$row = mysqli_fetch_array($sql_time);
|
||||
$row = mysqli_fetch_assoc($sql_time);
|
||||
$ticket_total_time_worked = nullable_htmlentities($row['total_time']);
|
||||
|
||||
?>
|
||||
@@ -178,4 +178,3 @@ $sql_users = mysqli_query($mysqli, "
|
||||
|
||||
<?php
|
||||
require_once "../../includes/footer.php";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user