Merge pull request #577 from wrongecho/misc

Misc refactoring/cleanups
This commit is contained in:
Johnny 2023-01-26 10:57:41 -05:00 committed by GitHub
commit 78951b3e3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 1922 additions and 1942 deletions

View File

@ -4,10 +4,13 @@ define('number_regex', '/[^0-9]/');
$name = trim(strip_tags(mysqli_real_escape_string($mysqli, $_POST['contact_name']))); $name = trim(strip_tags(mysqli_real_escape_string($mysqli, $_POST['contact_name'])));
$title = trim(strip_tags(mysqli_real_escape_string($mysqli, $_POST['contact_title']))); $title = trim(strip_tags(mysqli_real_escape_string($mysqli, $_POST['contact_title'])));
$department = trim(strip_tags(mysqli_real_escape_string($mysqli, $_POST['contact_department']))); $department = trim(strip_tags(mysqli_real_escape_string($mysqli, $_POST['contact_department'])));
$email = trim(strip_tags(mysqli_real_escape_string($mysqli, $_POST['contact_email'])));
$phone = preg_replace(number_regex, '', $_POST['contact_phone']); $phone = preg_replace(number_regex, '', $_POST['contact_phone']);
$extension = preg_replace(number_regex, '', $_POST['contact_extension']); $extension = preg_replace(number_regex, '', $_POST['contact_extension']);
$mobile = preg_replace(number_regex, '', $_POST['contact_mobile']); $mobile = preg_replace(number_regex, '', $_POST['contact_mobile']);
$email = trim(strip_tags(mysqli_real_escape_string($mysqli, $_POST['contact_email'])));
$notes = trim(strip_tags(mysqli_real_escape_string($mysqli, $_POST['contact_notes']))); $notes = trim(strip_tags(mysqli_real_escape_string($mysqli, $_POST['contact_notes'])));
$auth_method = trim(strip_tags(mysqli_real_escape_string($mysqli, $_POST['contact_auth_method']))); $auth_method = trim(strip_tags(mysqli_real_escape_string($mysqli, $_POST['contact_auth_method'])));
$location_id = intval($_POST['contact_location_id']); $important = intval($_POST['contact_important']);
$billing = intval($_POST['contact_billing']);
$technical = intval($_POST['contact_technical']);
$location_id = intval($_POST['contact_location_id']);

View File

@ -17,7 +17,7 @@ if (!empty($name) && !empty($email) && !empty($client_id)) {
if (mysqli_num_rows($email_duplication_sql) == 0) { if (mysqli_num_rows($email_duplication_sql) == 0) {
// Insert contact // Insert contact
$insert_sql = mysqli_query($mysqli, "INSERT INTO contacts SET contact_name = '$name', contact_title = '$title', contact_phone = '$phone', contact_extension = '$extension', contact_mobile = '$mobile', contact_email = '$email', contact_notes = '$notes', contact_auth_method = '$auth_method', contact_created_at = NOW(), contact_department = '$department', contact_location_id = $location_id, contact_client_id = $client_id, company_id = $company_id"); $insert_sql = mysqli_query($mysqli, "INSERT INTO contacts SET contact_name = '$name', contact_title = '$title', contact_department = '$department', contact_email = '$email', contact_phone = '$phone', contact_extension = '$extension', contact_mobile = '$mobile', contact_notes = '$notes', contact_auth_method = '$auth_method', contact_important = '$important', contact_billing = '$billing', contact_technical = '$technical', contact_created_at = NOW(), contact_location_id = $location_id, contact_client_id = $client_id, company_id = $company_id");
// Check insert & get insert ID // Check insert & get insert ID
if ($insert_sql) { if ($insert_sql) {
@ -31,4 +31,4 @@ if (!empty($name) && !empty($email) && !empty($client_id)) {
} }
// Output // Output
require_once('../create_output.php'); require_once('../create_output.php');

View File

@ -12,7 +12,7 @@ $update_count = FALSE;
if (!empty($name) && !empty($email)) { if (!empty($name) && !empty($email)) {
$update_sql = mysqli_query($mysqli, "UPDATE contacts SET contact_name = '$name', contact_title = '$title', contact_phone = '$phone', contact_extension = '$extension', contact_mobile = '$mobile', contact_email = '$email', contact_notes = '$notes', contact_auth_method = '$auth_method', contact_updated_at = NOW(), contact_department_id = $department, contact_location_id = $location_id, contact_client_id = $client_id, company_id = $company_id WHERE contact_id = $contact_id LIMIT 1"); $update_sql = mysqli_query($mysqli, "UPDATE contacts SET contact_name = '$name', contact_title = '$title', contact_department = '$department', contact_email = '$email', contact_phone = '$phone', contact_extension = '$extension', contact_mobile = '$mobile', contact_notes = '$notes', contact_auth_method = '$auth_method', contact_important = '$important', contact_billing = '$billing', contact_technical = '$technical', contact_updated_at = NOW(), contact_location_id = $location_id, contact_client_id = $client_id, company_id = $company_id WHERE contact_id = $contact_id LIMIT 1");
// Check insert & get insert ID // Check insert & get insert ID
if ($update_sql) { if ($update_sql) {
@ -25,4 +25,4 @@ if (!empty($name) && !empty($email)) {
} }
// Output // Output
require_once('../update_output.php'); require_once('../update_output.php');

View File

@ -3,7 +3,7 @@
if (isset($_GET['contact_id'])) { if (isset($_GET['contact_id'])) {
$contact_id = intval($_GET['contact_id']); $contact_id = intval($_GET['contact_id']);
$sql = mysqli_query($mysqli,"SELECT * FROM contacts $sql = mysqli_query($mysqli, "SELECT * FROM contacts
LEFT JOIN locations ON location_id = contact_location_id LEFT JOIN locations ON location_id = contact_location_id
WHERE contact_id = $contact_id WHERE contact_id = $contact_id
"); ");
@ -29,6 +29,11 @@ if (isset($_GET['contact_id'])) {
} else { } else {
$primary_contact_display = FALSE; $primary_contact_display = FALSE;
} }
if (empty($contact_name)) {
$contact_ticket_display = "-";
} else {
$contact_ticket_display = "$contact_name<br><small class='text-secondary'>$contact_email</small>";
}
$contact_location_id = $row['contact_location_id']; $contact_location_id = $row['contact_location_id'];
$location_name = htmlentities($row['location_name']); $location_name = htmlentities($row['location_name']);
if (empty($location_name)) { if (empty($location_name)) {
@ -39,20 +44,20 @@ if (isset($_GET['contact_id'])) {
$auth_method = htmlentities($row['contact_auth_method']); $auth_method = htmlentities($row['contact_auth_method']);
// Related Assets Query // Related Assets Query
$sql_related_assets = mysqli_query($mysqli,"SELECT * FROM assets WHERE asset_contact_id = $contact_id AND company_id = $session_company_id ORDER BY asset_name DESC"); $sql_related_assets = mysqli_query($mysqli, "SELECT * FROM assets WHERE asset_contact_id = $contact_id AND company_id = $session_company_id ORDER BY asset_name DESC");
$asset_count = mysqli_num_rows($sql_related_assets); $asset_count = mysqli_num_rows($sql_related_assets);
// Related Logins Query // Related Logins Query
$sql_related_logins = mysqli_query($mysqli,"SELECT * FROM logins WHERE login_contact_id = $contact_id AND company_id = $session_company_id ORDER BY login_name DESC"); $sql_related_logins = mysqli_query($mysqli, "SELECT * FROM logins WHERE login_contact_id = $contact_id AND company_id = $session_company_id ORDER BY login_name DESC");
$login_count = mysqli_num_rows($sql_related_logins); $login_count = mysqli_num_rows($sql_related_logins);
// Related Software Query // Related Software Query
$sql_related_software = mysqli_query($mysqli,"SELECT * FROM software, software_contacts WHERE software.software_id = software_contacts.software_id AND software_contacts.contact_id = $contact_id AND software.company_id = $session_company_id ORDER BY software.software_id DESC"); $sql_related_software = mysqli_query($mysqli, "SELECT * FROM software, software_contacts WHERE software.software_id = software_contacts.software_id AND software_contacts.contact_id = $contact_id AND software.company_id = $session_company_id ORDER BY software.software_id DESC");
$software_count = mysqli_num_rows($sql_related_software); $software_count = mysqli_num_rows($sql_related_software);
// Related Tickets Query // Related Tickets Query
$sql_related_tickets = mysqli_query($mysqli,"SELECT * FROM tickets WHERE ticket_contact_id = $contact_id AND company_id = $session_company_id ORDER BY ticket_id DESC"); $sql_related_tickets = mysqli_query($mysqli, "SELECT * FROM tickets LEFT JOIN users on ticket_assigned_to = user_id WHERE ticket_contact_id = $contact_id AND company_id = $session_company_id ORDER BY ticket_id DESC");
$ticket_count = mysqli_num_rows($sql_related_tickets); $ticket_count = mysqli_num_rows($sql_related_tickets);
?> ?>
@ -68,7 +73,7 @@ if (isset($_GET['contact_id'])) {
<div class="text-secondary"><?php echo $contact_title; ?></div> <div class="text-secondary"><?php echo $contact_title; ?></div>
<?php } ?> <?php } ?>
<div class="text-center"> <div class="text-center">
<?php if (!empty($contact_photo)) { ?> <?php if (!empty($contact_photo)) { ?>
<img class="img-fluid img-circle p-3" alt="contact_photo" src="<?php echo "uploads/clients/$session_company_id/$client_id/$contact_photo"; ?>"> <img class="img-fluid img-circle p-3" alt="contact_photo" src="<?php echo "uploads/clients/$session_company_id/$client_id/$contact_photo"; ?>">
<?php } else { ?> <?php } else { ?>
@ -86,7 +91,7 @@ if (isset($_GET['contact_id'])) {
<div><i class="fa fa-fw fa-envelope text-secondary mr-3"></i><a href='mailto:<?php echo $contact_email; ?>'><?php echo $contact_email; ?></a><button class='btn btn-sm clipboardjs' data-clipboard-text='<?php echo $contact_email; ?>'><i class='far fa-copy text-secondary'></i></button></div> <div><i class="fa fa-fw fa-envelope text-secondary mr-3"></i><a href='mailto:<?php echo $contact_email; ?>'><?php echo $contact_email; ?></a><button class='btn btn-sm clipboardjs' data-clipboard-text='<?php echo $contact_email; ?>'><i class='far fa-copy text-secondary'></i></button></div>
<?php } ?> <?php } ?>
<?php if (!empty($contact_phone)) { ?> <?php if (!empty($contact_phone)) { ?>
<div class="mb-2"><i class="fa fa-fw fa-phone text-secondary mr-3"></i><?php echo "$contact_phone $contact_phone_extention"; ?></div> <div class="mb-2"><i class="fa fa-fw fa-phone text-secondary mr-3"></i><?php echo "$contact_phone $contact_extension"; ?></div>
<?php } ?> <?php } ?>
<?php if (!empty($contact_mobile)) { ?> <?php if (!empty($contact_mobile)) { ?>
<div class="mb-2"><i class="fa fa-fw fa-mobile-alt text-secondary mr-3"></i><?php echo $contact_mobile; ?></div> <div class="mb-2"><i class="fa fa-fw fa-mobile-alt text-secondary mr-3"></i><?php echo $contact_mobile; ?></div>
@ -381,7 +386,7 @@ if (isset($_GET['contact_id'])) {
</thead> </thead>
<tbody> <tbody>
<?php <?php
while ($row = mysqli_fetch_array($sql_related_software)) { while ($row = mysqli_fetch_array($sql_related_software)) {
$software_id = $row['software_id']; $software_id = $row['software_id'];
$software_name = htmlentities($row['software_name']); $software_name = htmlentities($row['software_name']);
@ -397,7 +402,7 @@ if (isset($_GET['contact_id'])) {
$seat_count = 0; $seat_count = 0;
// Asset Licenses // Asset Licenses
$asset_licenses_sql = mysqli_query($mysqli,"SELECT asset_id FROM software_assets WHERE software_id = $software_id"); $asset_licenses_sql = mysqli_query($mysqli, "SELECT asset_id FROM software_assets WHERE software_id = $software_id");
$asset_licenses_array = array(); $asset_licenses_array = array();
while ($row = mysqli_fetch_array($asset_licenses_sql)) { while ($row = mysqli_fetch_array($asset_licenses_sql)) {
$asset_licenses_array[] = $row['asset_id']; $asset_licenses_array[] = $row['asset_id'];
@ -406,7 +411,7 @@ if (isset($_GET['contact_id'])) {
$asset_licenses = implode(',',$asset_licenses_array); $asset_licenses = implode(',',$asset_licenses_array);
// Contact Licenses // Contact Licenses
$contact_licenses_sql = mysqli_query($mysqli,"SELECT contact_id FROM software_contacts WHERE software_id = $software_id"); $contact_licenses_sql = mysqli_query($mysqli, "SELECT contact_id FROM software_contacts WHERE software_id = $software_id");
$contact_licenses_array = array(); $contact_licenses_array = array();
while ($row = mysqli_fetch_array($contact_licenses_sql)) { while ($row = mysqli_fetch_array($contact_licenses_sql)) {
$contact_licenses_array[] = $row['contact_id']; $contact_licenses_array[] = $row['contact_id'];
@ -432,7 +437,7 @@ if (isset($_GET['contact_id'])) {
<a class="dropdown-item text-danger" href="post.php?delete_software=<?php echo $software_id; ?>">Delete</a> <a class="dropdown-item text-danger" href="post.php?delete_software=<?php echo $software_id; ?>">Delete</a>
<?php } ?> <?php } ?>
</div> </div>
</div> </div>
</td> </td>
</tr> </tr>
@ -440,11 +445,11 @@ if (isset($_GET['contact_id'])) {
include("client_software_edit_modal.php"); include("client_software_edit_modal.php");
} }
?> ?>
</tbody> </tbody>
</table> </table>
</div> </div>
</div> </div>
</div> </div>
@ -519,25 +524,13 @@ if (isset($_GET['contact_id'])) {
} else { } else {
$ticket_assigned_to_display = htmlentities($row['user_name']); $ticket_assigned_to_display = htmlentities($row['user_name']);
} }
$contact_id = $row['contact_id'];
$contact_name = htmlentities($row['contact_name']);
if (empty($contact_name)) {
$contact_display = "-";
} else {
$contact_display = "$contact_name<br><small class='text-secondary'>$contact_email</small>";
}
$contact_title = htmlentities($row['contact_title']);
$contact_email = htmlentities($row['contact_email']);
$contact_phone = formatPhoneNumber($row['contact_phone']);
$contact_extension = htmlentities($row['contact_extension']);
$contact_mobile = formatPhoneNumber($row['contact_mobile']);
?> ?>
<tr> <tr>
<td><a href="ticket.php?ticket_id=<?php echo $ticket_id; ?>"><span class="badge badge-pill badge-secondary p-3"><?php echo "$ticket_prefix$ticket_number"; ?></span></a></td> <td><a href="ticket.php?ticket_id=<?php echo $ticket_id; ?>"><span class="badge badge-pill badge-secondary p-3"><?php echo "$ticket_prefix$ticket_number"; ?></span></a></td>
<td><a href="ticket.php?ticket_id=<?php echo $ticket_id; ?>"><?php echo $ticket_subject; ?></a></td> <td><a href="ticket.php?ticket_id=<?php echo $ticket_id; ?>"><?php echo $ticket_subject; ?></a></td>
<td><?php echo $contact_display; ?></td> <td><?php echo $contact_ticket_display; ?></td>
<td><?php echo $ticket_priority_display; ?></td> <td><?php echo $ticket_priority_display; ?></td>
<td><?php echo $ticket_status_display; ?></td> <td><?php echo $ticket_status_display; ?></td>
<td><?php echo $ticket_assigned_to_display; ?></td> <td><?php echo $ticket_assigned_to_display; ?></td>

View File

@ -28,13 +28,13 @@
?> ?>
<option value="<?php echo $document_template_id ?>"><?php echo $document_template_name; ?></option> <option value="<?php echo $document_template_id ?>"><?php echo $document_template_name; ?></option>
<?php <?php
} }
?> ?>
</select> </select>
</div> </div>
</div> </div>
<label>Document name</label> <label>Document name</label>
<div class="form-group"> <div class="form-group">
<div class="input-group"> <div class="input-group">
@ -60,17 +60,17 @@
$folder_name = htmlentities($row['folder_name']); $folder_name = htmlentities($row['folder_name']);
?> ?>
<option <?php if ($_GET['folder_id'] == $folder_id) echo "selected"; ?> value="<?php echo $folder_id ?>"><?php echo $folder_name; ?></option> <option <?php if (isset($_GET['folder_id']) && $_GET['folder_id'] == $folder_id) echo "selected"; ?> value="<?php echo $folder_id ?>"><?php echo $folder_name; ?></option>
<?php <?php
} }
?> ?>
</select> </select>
</div> </div>
</div> </div>
</div> </div>
<div class="modal-footer bg-white"> <div class="modal-footer bg-white">
<button type="button" class="btn btn-outline-secondary" data-dismiss="modal">Cancel</button> <button type="button" class="btn btn-outline-secondary" data-dismiss="modal">Cancel</button>
@ -80,4 +80,4 @@
</form> </form>
</div> </div>
</div> </div>
</div> </div>

View File

@ -33,7 +33,7 @@
$folder_name = htmlentities($row['folder_name']); $folder_name = htmlentities($row['folder_name']);
?> ?>
<option <?php if ($_GET['folder_id'] == $folder_id) echo "selected"; ?> value="<?php echo $folder_id ?>"><?php echo $folder_name; ?></option> <option <?php if (isset($_GET['folder_id']) && $_GET['folder_id'] == $folder_id) echo "selected"; ?> value="<?php echo $folder_id ?>"><?php echo $folder_name; ?></option>
<?php <?php
} }
?> ?>

File diff suppressed because it is too large Load Diff

View File

@ -535,4 +535,7 @@ function sendSingleEmail($config_smtp_host, $config_smtp_username, $config_smtp_
} }
} }
function roundUpToNearestMultiple($n, $increment = 1000)
{
return (int) ($increment * ceil($n / $increment));
}

View File

@ -9,3 +9,7 @@ include("reports_side_nav.php");
include("inc_wrapper.php"); include("inc_wrapper.php");
include("inc_alert_feedback.php"); include("inc_alert_feedback.php");
// Set variable default values
$largest_income_month = 0;
$largest_invoice_month = 0;
$recurring_total = 0;

1584
post.php

File diff suppressed because it is too large Load Diff

View File

@ -1,21 +1,15 @@
<?php include("inc_all_reports.php"); ?> <?php include("inc_all_reports.php");
<?php
function roundUpToNearestMultiple($n, $increment = 1000) if (isset($_GET['year'])) {
{ $year = intval($_GET['year']);
return (int) ($increment * ceil($n / $increment)); }else{
$year = date('Y');
} }
if (isset($_GET['year'])) { if (isset($_GET['year'])) {
$year = intval($_GET['year']); $year = intval($_GET['year']);
}else{ }else{
$year = date('Y'); $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_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");
@ -25,196 +19,196 @@ $sql_categories = mysqli_query($mysqli,"SELECT * FROM categories WHERE category_
?> ?>
<div class="card card-dark"> <div class="card card-dark">
<div class="card-header py-2"> <div class="card-header py-2">
<h3 class="card-title mt-2"><i class="fa fa-fw fa-coins"></i> Expense Summary</h3> <h3 class="card-title mt-2"><i class="fa fa-fw fa-coins"></i> Expense Summary</h3>
<div class="card-tools"> <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> <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>
</div> <div class="card-body">
<div class="card-body"> <form class="mb-3">
<form class="mb-3"> <select onchange="this.form.submit()" class="form-control" name="year">
<select onchange="this.form.submit()" class="form-control" name="year"> <?php
<?php
while ($row = mysqli_fetch_array($sql_expense_years)) {
$expense_year = $row['expense_year'];
?>
<option <?php if ($year == $expense_year) { ?> selected <?php } ?> > <?php echo $expense_year; ?></option>
<?php
}
?>
</select> while ($row = mysqli_fetch_array($sql_expense_years)) {
</form> $expense_year = $row['expense_year'];
?>
<option <?php if ($year == $expense_year) { ?> selected <?php } ?> > <?php echo $expense_year; ?></option>
<canvas id="cashFlow" width="100%" height="20"></canvas> <?php
}
?>
<div class="table-responsive"> </select>
<table class="table table-striped"> </form>
<thead class="text-dark">
<tr>
<th>Category</th>
<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
while ($row = mysqli_fetch_array($sql_categories)) {
$category_id = $row['category_id'];
$category_name = htmlentities($row['category_name']);
?>
<tr> <canvas id="cashFlow" width="100%" height="20"></canvas>
<td><?php echo $category_name; ?></td>
<?php
$total_expense_for_all_months = 0; <div class="table-responsive">
for($month = 1; $month<=12; $month++) { <table class="table table-striped">
$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"); <thead class="text-dark">
$row = mysqli_fetch_array($sql_expenses); <tr>
$expense_amount_for_month = $row['expense_amount_for_month']; <th>Category</th>
$total_expense_for_all_months = $expense_amount_for_month + $total_expense_for_all_months; <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
while ($row = mysqli_fetch_array($sql_categories)) {
$category_id = $row['category_id'];
$category_name = htmlentities($row['category_name']);
?>
<tr>
?> <td><?php echo $category_name; ?></td>
<td class="text-right"><a class="text-dark" href="expenses.php?q=<?php echo $category_name; ?>&dtf=<?php echo "$year-$month"; ?>-01&dtt=<?php echo "$year-$month"; ?>-31"><?php echo numfmt_format_currency($currency_format, $expense_amount_for_month, $session_company_currency); ?></a></td>
<?php
}
?>
<th class="text-right"><a class="text-dark" href="expenses.php?q=<?php echo $category_name; ?>&dtf=<?php echo $year; ?>-01-01&dtt=<?php echo $year; ?>-12-31"><?php echo numfmt_format_currency($currency_format, $total_expense_for_all_months, $session_company_currency); ?></a></th>
</tr>
<?php
} <?php
?>
<tr>
<th>Total</th>
<?php
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 AND company_id = $session_company_id");
$row = mysqli_fetch_array($sql_expenses);
$expense_total_amount_for_month = $row['expense_total_amount_for_month'];
$total_expense_for_all_months = $expense_total_amount_for_month + $total_expense_for_all_months;
?>
<th class="text-right"><a class="text-dark" href="expenses.php?dtf=<?php echo "$year-$month"; ?>-01&dtt=<?php echo "$year-$month"; ?>-31"><?php echo numfmt_format_currency($currency_format, $expense_total_amount_for_month, $session_company_currency); ?></a></th> $total_expense_for_all_months = 0;
<?php 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");
$row = mysqli_fetch_array($sql_expenses);
$expense_amount_for_month = $row['expense_amount_for_month'];
$total_expense_for_all_months = $expense_amount_for_month + $total_expense_for_all_months;
}
?> ?>
<td class="text-right"><a class="text-dark" href="expenses.php?q=<?php echo $category_name; ?>&dtf=<?php echo "$year-$month"; ?>-01&dtt=<?php echo "$year-$month"; ?>-31"><?php echo numfmt_format_currency($currency_format, $expense_amount_for_month, $session_company_currency); ?></a></td>
<th class="text-right"><a class="text-dark" href="expenses.php?dtf=<?php echo $year; ?>-01-01&dtt=<?php echo $year; ?>-12-31"><?php echo numfmt_format_currency($currency_format, $total_expense_for_all_months, $session_company_currency); ?></th> <?php
</tr>
</tbody> }
</table>
?>
<th class="text-right"><a class="text-dark" href="expenses.php?q=<?php echo $category_name; ?>&dtf=<?php echo $year; ?>-01-01&dtt=<?php echo $year; ?>-12-31"><?php echo numfmt_format_currency($currency_format, $total_expense_for_all_months, $session_company_currency); ?></a></th>
</tr>
<?php
}
?>
<tr>
<th>Total</th>
<?php
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 AND company_id = $session_company_id");
$row = mysqli_fetch_array($sql_expenses);
$expense_total_amount_for_month = $row['expense_total_amount_for_month'];
$total_expense_for_all_months = $expense_total_amount_for_month + $total_expense_for_all_months;
?>
<th class="text-right"><a class="text-dark" href="expenses.php?dtf=<?php echo "$year-$month"; ?>-01&dtt=<?php echo "$year-$month"; ?>-31"><?php echo numfmt_format_currency($currency_format, $expense_total_amount_for_month, $session_company_currency); ?></a></th>
<?php
}
?>
<th class="text-right"><a class="text-dark" href="expenses.php?dtf=<?php echo $year; ?>-01-01&dtt=<?php echo $year; ?>-12-31"><?php echo numfmt_format_currency($currency_format, $total_expense_for_all_months, $session_company_currency); ?></th>
</tr>
</tbody>
</table>
</div>
</div> </div>
</div>
</div> </div>
<?php include("footer.php"); ?> <?php include("footer.php"); ?>
<script> <script>
// Set new default font family and font color to mimic Bootstrap's default styling // 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.defaultFontFamily = '-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif';
Chart.defaults.global.defaultFontColor = '#292b2c'; Chart.defaults.global.defaultFontColor = '#292b2c';
// Area Chart Example // Area Chart Example
var ctx = document.getElementById("cashFlow"); var ctx = document.getElementById("cashFlow");
var myLineChart = new Chart(ctx, { var myLineChart = new Chart(ctx, {
type: 'line', type: 'line',
data: { data: {
labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
datasets: [{ datasets: [{
label: "Expense", label: "Expense",
lineTension: 0.3, lineTension: 0.3,
fill: false, fill: false,
borderColor: "#dc3545", borderColor: "#dc3545",
pointBackgroundColor: "#dc3545", pointBackgroundColor: "#dc3545",
pointBorderColor: "#dc3545", pointBorderColor: "#dc3545",
pointHoverRadius: 5, pointHoverRadius: 5,
pointHoverBackgroundColor: "#dc3545", pointHoverBackgroundColor: "#dc3545",
pointHitRadius: 50, pointHitRadius: 50,
pointBorderWidth: 2, pointBorderWidth: 2,
data: [ data: [
<?php <?php
$largest_expense_month = 0;
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 AND expenses.company_id = $session_company_id");
$row = mysqli_fetch_array($sql_expenses);
$expenses_for_month = $row['expense_amount_for_month'];
if ($expenses_for_month > 0 && $expenses_for_month > $largest_expense_month) {
$largest_expense_month = $expenses_for_month;
}
?> $largest_expense_month = 0;
<?php echo "$expenses_for_month,"; ?>
<?php
}
?> 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 AND expenses.company_id = $session_company_id");
$row = mysqli_fetch_array($sql_expenses);
$expenses_for_month = $row['expense_amount_for_month'];
], if ($expenses_for_month > 0 && $expenses_for_month > $largest_expense_month) {
}], $largest_expense_month = $expenses_for_month;
}, }
options: {
scales: {
xAxes: [{ ?>
time: { <?php echo "$expenses_for_month,"; ?>
unit: 'date'
<?php
}
?>
],
}],
}, },
gridLines: { options: {
display: false scales: {
}, xAxes: [{
ticks: { time: {
maxTicksLimit: 12 unit: 'date'
},
gridLines: {
display: false
},
ticks: {
maxTicksLimit: 12
}
}],
yAxes: [{
ticks: {
min: 0,
max: <?php $max = max(1000, $largest_expense_month, $largest_income_month, $largest_invoice_month); echo roundUpToNearestMultiple($max); ?>,
maxTicksLimit: 5
},
gridLines: {
color: "rgba(0, 0, 0, .125)",
}
}],
},
legend: {
display: false
}
} }
}], });
yAxes: [{
ticks: {
min: 0,
max: <?php $max = max(1000, $largest_expense_month, $largest_income_month, $largest_invoice_month); echo roundUpToNearestMultiple($max); ?>,
maxTicksLimit: 5
},
gridLines: {
color: "rgba(0, 0, 0, .125)",
}
}],
},
legend: {
display: false
}
}
});
</script> </script>

View File

@ -1,239 +1,235 @@
<?php include("inc_all_reports.php"); ?> <?php include("inc_all_reports.php"); ?>
<?php <?php
function roundUpToNearestMultiple($n, $increment = 1000) if (isset($_GET['year'])) {
{ $year = intval($_GET['year']);
return (int) ($increment * ceil($n / $increment)); } else {
$year = date('Y');
} }
if (isset($_GET['year'])) { if (isset($_GET['year'])) {
$year = intval($_GET['year']); $year = intval($_GET['year']);
}else{ } else {
$year = date('Y'); $year = date('Y');
} }
if (isset($_GET['year'])) { $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");
$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");
$sql_categories = mysqli_query($mysqli,"SELECT * FROM categories WHERE category_type = 'Income' AND company_id = $session_company_id ORDER BY category_name ASC");
?> ?>
<div class="card card-dark"> <div class="card card-dark">
<div class="card-header py-2"> <div class="card-header py-2">
<h3 class="card-title mt-2"><i class="fa fa-fw fa-coins"></i> Income Summary</h3> <h3 class="card-title mt-2"><i class="fa fa-fw fa-coins"></i> Income Summary</h3>
<div class="card-tools"> <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> <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>
</div> <div class="card-body p-0">
<div class="card-body p-0"> <form class="p-3">
<form class="p-3"> <select onchange="this.form.submit()" class="form-control" name="year">
<select onchange="this.form.submit()" class="form-control" name="year"> <?php
<?php
while ($row = mysqli_fetch_array($sql_payment_years)) {
$payment_year = $row['payment_year'];
?>
<option <?php if ($year == $payment_year) { ?> selected <?php } ?> > <?php echo $payment_year; ?></option>
<?php
}
?>
</select> while ($row = mysqli_fetch_array($sql_payment_years)) {
</form> $payment_year = $row['payment_year'];
?>
<option <?php if ($year == $payment_year) { ?> selected <?php } ?> > <?php echo $payment_year; ?></option>
<canvas id="cashFlow" width="100%" height="20"></canvas> <?php
}
?>
<div class="table-responsive"> </select>
<table class="table table-striped"> </form>
<thead>
<tr>
<th>Category</th>
<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
while ($row = mysqli_fetch_array($sql_categories)) {
$category_id = $row['category_id'];
$category_name = htmlentities($row['category_name']);
?> <canvas id="cashFlow" width="100%" height="20"></canvas>
<tr> <div class="table-responsive">
<td><?php echo $category_name; ?></td> <table class="table table-striped">
<thead>
<?php <tr>
<th>Category</th>
<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
while ($row = mysqli_fetch_array($sql_categories)) {
$category_id = $row['category_id'];
$category_name = htmlentities($row['category_name']);
$total_payment_for_all_months = 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");
$row = mysqli_fetch_array($sql_payments);
$payment_amount_for_month = $row['payment_amount_for_month'];
//Revenues <tr>
$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"); <td><?php echo $category_name; ?></td>
$row = mysqli_fetch_array($sql_revenues);
$revenues_amount_for_month = $row['revenue_amount_for_month'];
$payment_amount_for_month = $payment_amount_for_month + $revenues_amount_for_month; <?php
$total_payment_for_all_months = $payment_amount_for_month + $total_payment_for_all_months;
$total_payment_for_all_months = 0;
?>
<td class="text-right"><?php echo numfmt_format_currency($currency_format, $payment_amount_for_month, $session_company_currency); ?></td>
<?php
}
?>
<td class="text-right text-bold"><?php echo numfmt_format_currency($currency_format, $total_payment_for_all_months, $session_company_currency); ?></td>
</tr>
<?php
} 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");
$row = mysqli_fetch_array($sql_payments);
<tr> $payment_amount_for_month = $row['payment_amount_for_month'];
<th>Total</th>
<?php
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 AND payments.company_id = $session_company_id");
$row = mysqli_fetch_array($sql_payments);
$payment_total_amount_for_month = $row['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 AND revenues.company_id = $session_company_id"); //Revenues
$row = mysqli_fetch_array($sql_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");
$revenues_total_amount_for_month = $row['revenue_amount_for_month']; $row = mysqli_fetch_array($sql_revenues);
$revenues_amount_for_month = $row['revenue_amount_for_month'];
$payment_total_amount_for_month = $payment_total_amount_for_month + $revenues_total_amount_for_month; $payment_amount_for_month = $payment_amount_for_month + $revenues_amount_for_month;
$total_payment_for_all_months = $payment_amount_for_month + $total_payment_for_all_months;
$total_payment_for_all_months = $payment_total_amount_for_month + $total_payment_for_all_months; ?>
<td class="text-right"><?php echo numfmt_format_currency($currency_format, $payment_amount_for_month, $session_company_currency); ?></td>
?>
<th class="text-right"><?php echo numfmt_format_currency($currency_format, $payment_total_amount_for_month, $session_company_currency); ?></th> <?php
<?php
} }
?> ?>
<th class="text-right"><?php echo numfmt_format_currency($currency_format, $total_payment_for_all_months, $session_company_currency); ?></th> <td class="text-right text-bold"><?php echo numfmt_format_currency($currency_format, $total_payment_for_all_months, $session_company_currency); ?></td>
</tr> </tr>
</tbody>
</table> <?php
}
?>
<tr>
<th>Total</th>
<?php
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 AND payments.company_id = $session_company_id");
$row = mysqli_fetch_array($sql_payments);
$payment_total_amount_for_month = $row['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 AND revenues.company_id = $session_company_id");
$row = mysqli_fetch_array($sql_revenues);
$revenues_total_amount_for_month = $row['revenue_amount_for_month'];
$payment_total_amount_for_month = $payment_total_amount_for_month + $revenues_total_amount_for_month;
$total_payment_for_all_months = $payment_total_amount_for_month + $total_payment_for_all_months;
?>
<th class="text-right"><?php echo numfmt_format_currency($currency_format, $payment_total_amount_for_month, $session_company_currency); ?></th>
<?php
}
?>
<th class="text-right"><?php echo numfmt_format_currency($currency_format, $total_payment_for_all_months, $session_company_currency); ?></th>
</tr>
</tbody>
</table>
</div>
</div> </div>
</div>
</div> </div>
<?php include("footer.php"); ?> <?php include("footer.php"); ?>
<script> <script>
// Set new default font family and font color to mimic Bootstrap's default styling // 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.defaultFontFamily = '-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif';
Chart.defaults.global.defaultFontColor = '#292b2c'; Chart.defaults.global.defaultFontColor = '#292b2c';
// Area Chart Example // Area Chart Example
var ctx = document.getElementById("cashFlow"); var ctx = document.getElementById("cashFlow");
var myLineChart = new Chart(ctx, { var myLineChart = new Chart(ctx, {
type: 'line', type: 'line',
data: { data: {
labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
datasets: [{ datasets: [{
label: "Income", label: "Income",
fill: false, fill: false,
borderColor: "#007bff", borderColor: "#007bff",
pointBackgroundColor: "#007bff", pointBackgroundColor: "#007bff",
pointBorderColor: "#007bff", pointBorderColor: "#007bff",
pointHoverRadius: 5, pointHoverRadius: 5,
pointHoverBackgroundColor: "#007bff", pointHoverBackgroundColor: "#007bff",
pointHitRadius: 50, pointHitRadius: 50,
pointBorderWidth: 2, pointBorderWidth: 2,
data: [ data: [
<?php <?php
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 AND payments.company_id = $session_company_id");
$row = mysqli_fetch_array($sql_payments);
$payments_for_month = $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 > 0 AND YEAR(revenue_date) = $year AND MONTH(revenue_date) = $month AND company_id = $session_company_id"); for ($month = 1; $month<=12; $month++) {
$row = mysqli_fetch_array($sql_revenues); $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 AND payments.company_id = $session_company_id");
$revenues_for_month = $row['revenue_amount_for_month']; $row = mysqli_fetch_array($sql_payments);
$payments_for_month = $row['payment_amount_for_month'];
$income_for_month = $payments_for_month + $revenues_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 AND company_id = $session_company_id");
$row = mysqli_fetch_array($sql_revenues);
if ($income_for_month > 0 && $income_for_month > $largest_income_month) { $revenues_for_month = $row['revenue_amount_for_month'];
$largest_income_month = $income_for_month;
}
?> $income_for_month = $payments_for_month + $revenues_for_month;
<?php echo "$income_for_month,"; ?>
<?php
}
?> if ($income_for_month > 0 && $income_for_month > $largest_income_month) {
$largest_income_month = $income_for_month;
}
],
}], ?>
}, <?php echo "$income_for_month,"; ?>
options: {
scales: { <?php
xAxes: [{
time: { }
unit: 'date'
?>
],
}],
}, },
gridLines: { options: {
display: false scales: {
}, xAxes: [{
ticks: { time: {
maxTicksLimit: 12 unit: 'date'
},
gridLines: {
display: false
},
ticks: {
maxTicksLimit: 12
}
}],
yAxes: [{
ticks: {
min: 0,
max: <?php $max = max(1000, $largest_income_month, $largest_invoice_month); echo roundUpToNearestMultiple($max); ?>,
maxTicksLimit: 5
},
gridLines: {
color: "rgba(0, 0, 0, .125)",
}
}],
},
legend: {
display: false
}
} }
}], });
yAxes: [{
ticks: {
min: 0,
max: <?php $max = max(1000, $largest_income_month, $largest_invoice_month); echo roundUpToNearestMultiple($max); ?>,
maxTicksLimit: 5
},
gridLines: {
color: "rgba(0, 0, 0, .125)",
}
}],
},
legend: {
display: false
}
}
});
</script> </script>

View File

@ -1,5 +1,4 @@
<?php include("inc_all_reports.php"); ?> <?php include("inc_all_reports.php");
<?php
$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");
@ -23,6 +22,7 @@ $sql_clients = mysqli_query($mysqli,"SELECT * FROM clients WHERE company_id = $s
</thead> </thead>
<tbody> <tbody>
<?php <?php
while ($row = mysqli_fetch_array($sql_clients)) { while ($row = mysqli_fetch_array($sql_clients)) {
$client_id = $row['client_id']; $client_id = $row['client_id'];
$client_name = htmlentities($row['client_name']); $client_name = htmlentities($row['client_name']);
@ -30,13 +30,13 @@ $sql_clients = mysqli_query($mysqli,"SELECT * FROM clients WHERE company_id = $s
//Get Monthly Recurring Total //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); $row = mysqli_fetch_array($sql_recurring_monthly_total);
$recurring_monthly_total = $row['recurring_monthly_total']; $recurring_monthly_total = $row['recurring_monthly_total'];
//Get Yearly Recurring 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); $row = mysqli_fetch_array($sql_recurring_yearly_total);
$recurring_yearly_total = $row['recurring_yearly_total'] / 12; $recurring_yearly_total = $row['recurring_yearly_total'] / 12;
$recurring_monthly = $recurring_monthly_total + $recurring_yearly_total; $recurring_monthly = $recurring_monthly_total + $recurring_yearly_total;
@ -50,8 +50,8 @@ $sql_clients = mysqli_query($mysqli,"SELECT * FROM clients WHERE company_id = $s
<td><?php echo $client_name; ?></td> <td><?php echo $client_name; ?></td>
<td class="text-right"><?php echo numfmt_format_currency($currency_format, $recurring_monthly, $session_company_currency); ?></td> <td class="text-right"><?php echo numfmt_format_currency($currency_format, $recurring_monthly, $session_company_currency); ?></td>
</tr> </tr>
<?php <?php
} }
} }
?> ?>
<tr> <tr>
@ -64,4 +64,4 @@ $sql_clients = mysqli_query($mysqli,"SELECT * FROM clients WHERE company_id = $s
</div> </div>
</div> </div>
<?php include("footer.php"); ?> <?php include("footer.php"); ?>

View File

@ -17,8 +17,8 @@ $sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS * FROM tags
$num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
if ($num_row > 0) { if ($num_rows > 0) {
//Colors Used //Colors Used
$sql_colors_used = mysqli_query($mysqli, "SELECT tag_color FROM tags $sql_colors_used = mysqli_query($mysqli, "SELECT tag_color FROM tags
WHERE tag_archived_at IS NULL WHERE tag_archived_at IS NULL
AND company_id = $session_company_id" AND company_id = $session_company_id"
@ -29,7 +29,7 @@ if ($num_row > 0) {
} }
$colors_diff = array_diff($colors_array, $colors_used_array); $colors_diff = array_diff($colors_array, $colors_used_array);
}else{ } else {
$colors_diff = $colors_array; $colors_diff = $colors_array;
} }