mirror of https://github.com/itflow-org/itflow
Reporting
- Add ticket summary & ticket by client report (#514) - General tidy
This commit is contained in:
parent
aad55c6d56
commit
e5a5aebc2c
|
|
@ -9,12 +9,6 @@ if (isset($_GET['year'])) {
|
|||
$year = date('Y');
|
||||
}
|
||||
|
||||
if (isset($_GET['year'])) {
|
||||
$year = intval($_GET['year']);
|
||||
} else {
|
||||
$year = date('Y');
|
||||
}
|
||||
|
||||
$sql_payment_years = mysqli_query($mysqli,"SELECT DISTINCT YEAR(payment_date) AS payment_year FROM payments WHERE company_id = $session_company_id UNION SELECT DISTINCT YEAR(revenue_date) AS payment_year FROM revenues WHERE company_id = $session_company_id ORDER BY payment_year DESC");
|
||||
|
||||
$sql_vendors = mysqli_query($mysqli,"SELECT * FROM vendors WHERE company_id = $session_company_id");
|
||||
|
|
|
|||
|
|
@ -9,12 +9,6 @@ if (isset($_GET['year'])) {
|
|||
$year = date('Y');
|
||||
}
|
||||
|
||||
if (isset($_GET['year'])) {
|
||||
$year = intval($_GET['year']);
|
||||
} else {
|
||||
$year = date('Y');
|
||||
}
|
||||
|
||||
$sql_expense_years = mysqli_query($mysqli,"SELECT DISTINCT YEAR(expense_date) AS expense_year FROM expenses WHERE expense_category_id > 0 AND company_id = $session_company_id ORDER BY expense_year DESC");
|
||||
|
||||
$sql_categories = mysqli_query($mysqli,"SELECT * FROM categories WHERE category_type = 'Expense' AND company_id = $session_company_id ORDER BY category_name ASC");
|
||||
|
|
@ -140,7 +134,6 @@ $sql_categories = mysqli_query($mysqli,"SELECT * FROM categories WHERE category_
|
|||
Chart.defaults.global.defaultFontFamily = '-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif';
|
||||
Chart.defaults.global.defaultFontColor = '#292b2c';
|
||||
|
||||
// Area Chart Example
|
||||
var ctx = document.getElementById("cashFlow");
|
||||
var myLineChart = new Chart(ctx, {
|
||||
type: 'line',
|
||||
|
|
|
|||
|
|
@ -9,12 +9,6 @@ if (isset($_GET['year'])) {
|
|||
$year = date('Y');
|
||||
}
|
||||
|
||||
if (isset($_GET['year'])) {
|
||||
$year = intval($_GET['year']);
|
||||
} else {
|
||||
$year = date('Y');
|
||||
}
|
||||
|
||||
$sql_payment_years = mysqli_query($mysqli,"SELECT DISTINCT YEAR(payment_date) AS payment_year FROM payments WHERE company_id = $session_company_id UNION SELECT DISTINCT YEAR(revenue_date) AS payment_year FROM revenues WHERE company_id = $session_company_id ORDER BY payment_year DESC");
|
||||
|
||||
$sql_clients = mysqli_query($mysqli,"SELECT * FROM clients WHERE company_id = $session_company_id");
|
||||
|
|
@ -59,7 +53,7 @@ $sql_clients = mysqli_query($mysqli,"SELECT * FROM clients WHERE company_id = $s
|
|||
$client_id = $row['client_id'];
|
||||
$client_name = htmlentities($row['client_name']);
|
||||
|
||||
$sql_amount_paid = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS amount_paid FROM payments, invoices WHERE payment_invoice_id = invoice_id AND YEAR(payment_date) = $year AND invoice_client_id = $client_id");
|
||||
$sql_amount_paid = mysqli_query($mysqli, "SELECT SUM(payment_amount) AS amount_paid FROM payments, invoices WHERE payment_invoice_id = invoice_id AND YEAR(payment_date) = $year AND invoice_client_id = $client_id");
|
||||
$row = mysqli_fetch_array($sql_amount_paid);
|
||||
|
||||
$amount_paid = floatval($row['amount_paid']);
|
||||
|
|
|
|||
|
|
@ -9,12 +9,6 @@ if (isset($_GET['year'])) {
|
|||
$year = date('Y');
|
||||
}
|
||||
|
||||
if (isset($_GET['year'])) {
|
||||
$year = intval($_GET['year']);
|
||||
} else {
|
||||
$year = date('Y');
|
||||
}
|
||||
|
||||
$sql_payment_years = mysqli_query($mysqli, "SELECT DISTINCT YEAR(payment_date) AS payment_year FROM payments WHERE company_id = $session_company_id UNION SELECT DISTINCT YEAR(revenue_date) AS payment_year FROM revenues WHERE company_id = $session_company_id ORDER BY payment_year DESC");
|
||||
|
||||
$sql_categories = mysqli_query($mysqli, "SELECT * FROM categories WHERE category_type = 'Income' AND company_id = $session_company_id ORDER BY category_name ASC");
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
require_once("inc_all_reports.php");
|
||||
validateAccountantRole();
|
||||
|
||||
$sql_clients = mysqli_query($mysqli,"SELECT * FROM clients WHERE company_id = $session_company_id");
|
||||
$sql_clients = mysqli_query($mysqli, "SELECT * FROM clients WHERE company_id = $session_company_id");
|
||||
|
||||
?>
|
||||
|
||||
|
|
@ -31,13 +31,13 @@ $sql_clients = mysqli_query($mysqli,"SELECT * FROM clients WHERE company_id = $s
|
|||
$client_name = htmlentities($row['client_name']);
|
||||
|
||||
//Get Monthly Recurring Total
|
||||
$sql_recurring_monthly_total = mysqli_query($mysqli,"SELECT SUM(recurring_amount) AS recurring_monthly_total FROM recurring WHERE recurring_status = 1 AND recurring_frequency = 'month' AND recurring_client_id = $client_id AND company_id = $session_company_id");
|
||||
$sql_recurring_monthly_total = mysqli_query($mysqli, "SELECT SUM(recurring_amount) AS recurring_monthly_total FROM recurring WHERE recurring_status = 1 AND recurring_frequency = 'month' AND recurring_client_id = $client_id AND company_id = $session_company_id");
|
||||
$row = mysqli_fetch_array($sql_recurring_monthly_total);
|
||||
|
||||
$recurring_monthly_total = $row['recurring_monthly_total'];
|
||||
|
||||
//Get Yearly Recurring Total
|
||||
$sql_recurring_yearly_total = mysqli_query($mysqli,"SELECT SUM(recurring_amount) AS recurring_yearly_total FROM recurring WHERE recurring_status = 1 AND recurring_frequency = 'year' AND recurring_client_id = $client_id AND company_id = $session_company_id");
|
||||
$sql_recurring_yearly_total = mysqli_query($mysqli, "SELECT SUM(recurring_amount) AS recurring_yearly_total FROM recurring WHERE recurring_status = 1 AND recurring_frequency = 'year' AND recurring_client_id = $client_id AND company_id = $session_company_id");
|
||||
$row = mysqli_fetch_array($sql_recurring_yearly_total);
|
||||
|
||||
$recurring_yearly_total = $row['recurring_yearly_total'] / 12;
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ if (isset($_GET['year'])) {
|
|||
}
|
||||
|
||||
//GET unique years from expenses, payments and revenues
|
||||
$sql_all_years = mysqli_query($mysqli,"SELECT DISTINCT(YEAR(item_created_at)) AS all_years FROM invoice_items WHERE company_id = $session_company_id ORDER BY all_years DESC");
|
||||
$sql_all_years = mysqli_query($mysqli, "SELECT DISTINCT(YEAR(item_created_at)) AS all_years FROM invoice_items WHERE company_id = $session_company_id ORDER BY all_years DESC");
|
||||
|
||||
$sql_tax = mysqli_query($mysqli,"SELECT * FROM taxes WHERE company_id = $session_company_id ORDER BY tax_name ASC");
|
||||
$sql_tax = mysqli_query($mysqli, "SELECT * FROM taxes WHERE company_id = $session_company_id ORDER BY tax_name ASC");
|
||||
|
||||
?>
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ $sql_tax = mysqli_query($mysqli,"SELECT * FROM taxes WHERE company_id = $session
|
|||
|
||||
for($month = 1; $month<=3; $month++) {
|
||||
|
||||
$sql_tax_collected = mysqli_query($mysqli,"SELECT SUM(item_tax) AS tax_collected_for_month
|
||||
$sql_tax_collected = mysqli_query($mysqli, "SELECT SUM(item_tax) AS tax_collected_for_month
|
||||
FROM invoices, invoice_items
|
||||
WHERE item_invoice_id = invoice_id
|
||||
AND invoice_status LIKE 'Paid'
|
||||
|
|
@ -91,7 +91,7 @@ $sql_tax = mysqli_query($mysqli,"SELECT * FROM taxes WHERE company_id = $session
|
|||
|
||||
for($month = 4; $month <= 6; $month ++) {
|
||||
|
||||
$sql_tax_collected = mysqli_query($mysqli,"SELECT SUM(item_tax) AS tax_collected_for_month
|
||||
$sql_tax_collected = mysqli_query($mysqli, "SELECT SUM(item_tax) AS tax_collected_for_month
|
||||
FROM invoices, invoice_items
|
||||
WHERE item_invoice_id = invoice_id
|
||||
AND invoice_status LIKE 'Paid'
|
||||
|
|
@ -115,7 +115,7 @@ $sql_tax = mysqli_query($mysqli,"SELECT * FROM taxes WHERE company_id = $session
|
|||
|
||||
for($month = 7; $month <= 9; $month ++) {
|
||||
|
||||
$sql_tax_collected = mysqli_query($mysqli,"SELECT SUM(item_tax) AS tax_collected_for_month
|
||||
$sql_tax_collected = mysqli_query($mysqli, "SELECT SUM(item_tax) AS tax_collected_for_month
|
||||
FROM invoices, invoice_items
|
||||
WHERE item_invoice_id = invoice_id
|
||||
AND invoice_status LIKE 'Paid'
|
||||
|
|
@ -139,7 +139,7 @@ $sql_tax = mysqli_query($mysqli,"SELECT * FROM taxes WHERE company_id = $session
|
|||
|
||||
for($month = 10; $month <= 12; $month ++) {
|
||||
|
||||
$sql_tax_collected = mysqli_query($mysqli,"SELECT SUM(item_tax) AS tax_collected_for_month
|
||||
$sql_tax_collected = mysqli_query($mysqli, "SELECT SUM(item_tax) AS tax_collected_for_month
|
||||
FROM invoices, invoice_items
|
||||
WHERE item_invoice_id = invoice_id
|
||||
AND invoice_status LIKE 'Paid'
|
||||
|
|
@ -176,7 +176,7 @@ $sql_tax = mysqli_query($mysqli,"SELECT * FROM taxes WHERE company_id = $session
|
|||
|
||||
for($month = 1; $month <= 3; $month ++) {
|
||||
|
||||
$sql_tax_collected = mysqli_query($mysqli,"SELECT SUM(item_tax) AS tax_collected_for_month
|
||||
$sql_tax_collected = mysqli_query($mysqli, "SELECT SUM(item_tax) AS tax_collected_for_month
|
||||
FROM invoices, invoice_items
|
||||
WHERE item_invoice_id = invoice_id
|
||||
AND invoice_status LIKE 'Paid'
|
||||
|
|
@ -199,7 +199,7 @@ $sql_tax = mysqli_query($mysqli,"SELECT * FROM taxes WHERE company_id = $session
|
|||
|
||||
for($month = 4; $month <= 6; $month ++) {
|
||||
|
||||
$sql_tax_collected = mysqli_query($mysqli,"SELECT SUM(item_tax) AS tax_collected_for_month
|
||||
$sql_tax_collected = mysqli_query($mysqli, "SELECT SUM(item_tax) AS tax_collected_for_month
|
||||
FROM invoices, invoice_items
|
||||
WHERE item_invoice_id = invoice_id
|
||||
AND invoice_status LIKE 'Paid'
|
||||
|
|
@ -222,7 +222,7 @@ $sql_tax = mysqli_query($mysqli,"SELECT * FROM taxes WHERE company_id = $session
|
|||
|
||||
for($month = 7; $month <= 9; $month ++) {
|
||||
|
||||
$sql_tax_collected = mysqli_query($mysqli,"SELECT SUM(item_tax) AS tax_collected_for_month
|
||||
$sql_tax_collected = mysqli_query($mysqli, "SELECT SUM(item_tax) AS tax_collected_for_month
|
||||
FROM invoices, invoice_items
|
||||
WHERE item_invoice_id = invoice_id
|
||||
AND invoice_status LIKE 'Paid'
|
||||
|
|
@ -245,7 +245,7 @@ $sql_tax = mysqli_query($mysqli,"SELECT * FROM taxes WHERE company_id = $session
|
|||
|
||||
for($month = 10; $month <= 12; $month ++) {
|
||||
|
||||
$sql_tax_collected = mysqli_query($mysqli,"SELECT SUM(item_tax) AS tax_collected_for_month
|
||||
$sql_tax_collected = mysqli_query($mysqli, "SELECT SUM(item_tax) AS tax_collected_for_month
|
||||
FROM invoices, invoice_items
|
||||
WHERE item_invoice_id = invoice_id
|
||||
AND invoice_status LIKE 'Paid'
|
||||
|
|
|
|||
|
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
|
||||
require_once("inc_all_reports.php");
|
||||
validateTechRole();
|
||||
|
||||
if (isset($_GET['year'])) {
|
||||
$year = intval($_GET['year']);
|
||||
} else {
|
||||
$year = date('Y');
|
||||
}
|
||||
|
||||
$sql_ticket_years = mysqli_query($mysqli,"SELECT DISTINCT YEAR(ticket_created_at) AS ticket_year FROM tickets WHERE company_id = $session_company_id ORDER BY ticket_year DESC");
|
||||
|
||||
$sql_clients = mysqli_query($mysqli,"SELECT client_id, client_name FROM clients WHERE company_id = $session_company_id ORDER BY client_name ASC");
|
||||
|
||||
?>
|
||||
|
||||
<div class="card card-dark">
|
||||
<div class="card-header py-2">
|
||||
<h3 class="card-title mt-2"><i class="fa fa-fw fa-life-ring"></i> Tickets 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"></i> Print</button>
|
||||
</div>
|
||||
</div>
|
||||
<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_ticket_years)) {
|
||||
$ticket_year = $row['ticket_year']; ?>
|
||||
<option <?php if ($year == $ticket_year) { ?> selected <?php } ?> > <?php echo $ticket_year; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</form>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Client</th>
|
||||
<th class="text-right">Ticket Count</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
while ($row = mysqli_fetch_array($sql_clients)) {
|
||||
$client_id = $row['client_id'];
|
||||
$client_name = htmlentities($row['client_name']);
|
||||
|
||||
$sql_ticket_count = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS ticket_count FROM tickets WHERE YEAR(ticket_created_at) = $year AND ticket_client_id = '$client_id'");
|
||||
$row = mysqli_fetch_array($sql_ticket_count);
|
||||
|
||||
$ticket_count = intval($row['ticket_count']);
|
||||
|
||||
if ($ticket_count > 0) {
|
||||
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td><?php echo $client_name; ?></td>
|
||||
<td class="text-right"><?php echo $ticket_count; ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
require_once("footer.php");
|
||||
|
|
@ -0,0 +1,159 @@
|
|||
<?php
|
||||
|
||||
require_once("inc_all_reports.php");
|
||||
validateTechRole();
|
||||
|
||||
if (isset($_GET['year'])) {
|
||||
$year = intval($_GET['year']);
|
||||
} else {
|
||||
$year = date('Y');
|
||||
}
|
||||
|
||||
$sql_ticket_years = mysqli_query($mysqli, "SELECT DISTINCT YEAR(ticket_created_at) AS ticket_year FROM tickets WHERE company_id = $session_company_id ORDER BY ticket_year DESC");
|
||||
|
||||
$sql_tickets = mysqli_query($mysqli, "SELECT ticket_id FROM tickets WHERE company_id = $session_company_id");
|
||||
|
||||
?>
|
||||
|
||||
<div class="card card-dark">
|
||||
<div class="card-header py-2">
|
||||
<h3 class="card-title mt-2"><i class="fa fa-fw fa-life-ring"></i> Ticket Summary</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"></i> Print</button>
|
||||
</div>
|
||||
</div>
|
||||
<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_ticket_years)) {
|
||||
$ticket_year = $row['ticket_year']; ?>
|
||||
<option <?php if ($year == $ticket_year) { ?> selected <?php } ?> > <?php echo $ticket_year; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</form>
|
||||
|
||||
<canvas id="tickets" width="100%" height="20"></canvas>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-right">January</th>
|
||||
<th class="text-right">February</th>
|
||||
<th class="text-right">March</th>
|
||||
<th class="text-right">April</th>
|
||||
<th class="text-right">May</th>
|
||||
<th class="text-right">June</th>
|
||||
<th class="text-right">July</th>
|
||||
<th class="text-right">August</th>
|
||||
<th class="text-right">September</th>
|
||||
<th class="text-right">October</th>
|
||||
<th class="text-right">November</th>
|
||||
<th class="text-right">December</th>
|
||||
<th class="text-right">Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<?php
|
||||
|
||||
$total_tickets_for_all_months = 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);
|
||||
$tickets_for_month = $row['tickets_for_month'];
|
||||
|
||||
$total_tickets_for_all_months = $tickets_for_month + $total_tickets_for_all_months;
|
||||
?>
|
||||
|
||||
<td class="text-right"><?php echo $tickets_for_month; ?></td>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
|
||||
<td class="text-right"><b><?php echo $total_tickets_for_all_months; ?></b></td>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require_once("footer.php"); ?>
|
||||
|
||||
<script>
|
||||
// Set new default font family and font color to mimic Bootstrap's default styling
|
||||
Chart.defaults.global.defaultFontFamily = '-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif';
|
||||
Chart.defaults.global.defaultFontColor = '#292b2c';
|
||||
|
||||
// Area Chart Example
|
||||
var ctx = document.getElementById("tickets");
|
||||
var myLineChart = new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
|
||||
datasets: [{
|
||||
label: "Tickets Raised",
|
||||
fill: false,
|
||||
borderColor: "#007bff",
|
||||
pointBackgroundColor: "#007bff",
|
||||
pointBorderColor: "#007bff",
|
||||
pointHoverRadius: 5,
|
||||
pointHoverBackgroundColor: "#007bff",
|
||||
pointHitRadius: 50,
|
||||
pointBorderWidth: 2,
|
||||
data: [
|
||||
<?php
|
||||
|
||||
$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);
|
||||
$tickets_for_month = $row['tickets_for_month'];
|
||||
|
||||
if ($tickets_for_month > 0 && $tickets_for_month > $largest_ticket_month) {
|
||||
$largest_ticket_month = $tickets_for_month;
|
||||
}
|
||||
|
||||
echo "$tickets_for_month,";
|
||||
}
|
||||
?>
|
||||
|
||||
],
|
||||
}],
|
||||
},
|
||||
options: {
|
||||
scales: {
|
||||
xAxes: [{
|
||||
time: {
|
||||
unit: 'date'
|
||||
},
|
||||
gridLines: {
|
||||
display: false
|
||||
},
|
||||
ticks: {
|
||||
maxTicksLimit: 12
|
||||
}
|
||||
}],
|
||||
yAxes: [{
|
||||
ticks: {
|
||||
min: 0,
|
||||
max: <?php echo $largest_ticket_month ?>,
|
||||
maxTicksLimit: 5
|
||||
},
|
||||
gridLines: {
|
||||
color: "rgba(0, 0, 0, .125)",
|
||||
}
|
||||
}],
|
||||
},
|
||||
legend: {
|
||||
display: false
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
@ -63,6 +63,23 @@
|
|||
</li>
|
||||
<?php } // End financial reports IF statement ?>
|
||||
|
||||
<?php if ($session_user_role == 2 || $session_user_role == 3) { ?>
|
||||
<li class="nav-header">TECHNICAL</li>
|
||||
<li class="nav-item">
|
||||
<a href="report_ticket_summary.php" class="nav-link <?php if (basename($_SERVER["PHP_SELF"]) == "report_ticket_summary.php") { echo "active"; } ?>">
|
||||
<i class="nav-icon fas fa-life-ring"></i>
|
||||
<p>Tickets</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="report_ticket_by_client.php" class="nav-link <?php if (basename($_SERVER["PHP_SELF"]) == "report_ticket_by_client.php") { echo "active"; } ?>">
|
||||
<i class="nav-icon fas fa-life-ring"></i>
|
||||
<p>Tickets by Client</p>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<?php } // End technical reports IF statement ?>
|
||||
|
||||
</ul>
|
||||
|
||||
</nav>
|
||||
|
|
|
|||
Loading…
Reference in New Issue