mirror of https://github.com/itflow-org/itflow
Merge branch 'itflow-org:master' into docker
This commit is contained in:
commit
a2765ae480
18
clients.php
18
clients.php
|
|
@ -247,7 +247,21 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
|
|||
$balance_text_color = "text-danger font-weight-bold";
|
||||
}else{
|
||||
$balance_text_color = "";
|
||||
}
|
||||
}
|
||||
|
||||
//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");
|
||||
$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");
|
||||
$row = mysqli_fetch_array($sql_recurring_yearly_total);
|
||||
|
||||
$recurring_yearly_total = $row['recurring_yearly_total'] / 12;
|
||||
|
||||
$recurring_monthly = $recurring_monthly_total + $recurring_yearly_total;
|
||||
|
||||
?>
|
||||
<tr>
|
||||
|
|
@ -316,6 +330,8 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
|
|||
<span class="text-secondary">Balance</span> <span class="<?php echo $balance_text_color; ?>"><?php echo numfmt_format_currency($currency_format, $balance, $session_company_currency); ?></span>
|
||||
<br>
|
||||
<span class="text-secondary">Paid</span> <?php echo numfmt_format_currency($currency_format, $amount_paid, $session_company_currency); ?>
|
||||
<br>
|
||||
<span class="text-secondary">Monthly</span> <?php echo numfmt_format_currency($currency_format, $recurring_monthly, $session_company_currency); ?>
|
||||
</td>
|
||||
<?php } ?>
|
||||
|
||||
|
|
|
|||
|
|
@ -392,11 +392,32 @@ if(LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION){
|
|||
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.2.3'");
|
||||
}
|
||||
|
||||
//if(CURRENT_DATABASE_VERSION == '0.2.3'){
|
||||
// Insert queries here required to update to DB version 0.2.4
|
||||
if(CURRENT_DATABASE_VERSION == '0.2.3'){
|
||||
|
||||
//Create New interfaces Table
|
||||
mysqli_query($mysqli, "CREATE TABLE `interfaces` (`interface_id` int(11) AUTO_INCREMENT PRIMARY KEY,
|
||||
`interface_number` int(11) NULL DEFAULT NULL,
|
||||
`interface_description` varchar(200) NULL DEFAULT NULL,
|
||||
`interface_connected_asset` varchar(200) NULL DEFAULT NULL,
|
||||
`interface_ip` varchar(200) NULL DEFAULT NULL,
|
||||
`interface_created_at` datetime DEFAULT CURRENT_TIMESTAMP,
|
||||
`interface_updated_at` datetime NULL ON UPDATE CURRENT_TIMESTAMP,
|
||||
`interface_archived_at` datetime NULL DEFAULT NULL,
|
||||
`interface_connected_asset_id` int(11) NOT NULL DEFAULT 0,
|
||||
`interface_network_id` int(11) NOT NULL DEFAULT 0,
|
||||
`interface_asset_id` int(11) NOT NULL,
|
||||
`company_id` int(11) NOT NULL
|
||||
)");
|
||||
|
||||
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.2.4'");
|
||||
|
||||
}
|
||||
|
||||
//if(CURRENT_DATABASE_VERSION == '0.2.4'){
|
||||
// Insert queries here required to update to DB version 0.2.5
|
||||
|
||||
// Then, update the database to the next sequential version
|
||||
// mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.2.4'");
|
||||
// mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.2.5'");
|
||||
//}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,4 +5,4 @@
|
|||
* It is used in conjunction with database_updates.php
|
||||
*/
|
||||
|
||||
DEFINE("LATEST_DATABASE_VERSION", "0.2.3");
|
||||
DEFINE("LATEST_DATABASE_VERSION", "0.2.4");
|
||||
26
db.sql
26
db.sql
|
|
@ -502,6 +502,30 @@ CREATE TABLE `history` (
|
|||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `interfaces`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `interfaces`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `interfaces` (
|
||||
`interface_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`interface_number` int(11) DEFAULT NULL,
|
||||
`interface_description` varchar(200) DEFAULT NULL,
|
||||
`interface_connected_asset` varchar(200) DEFAULT NULL,
|
||||
`interface_ip` varchar(200) DEFAULT NULL,
|
||||
`interface_created_at` datetime DEFAULT current_timestamp(),
|
||||
`interface_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(),
|
||||
`interface_archived_at` datetime DEFAULT NULL,
|
||||
`interface_connected_asset_id` int(11) NOT NULL DEFAULT 0,
|
||||
`interface_network_id` int(11) NOT NULL DEFAULT 0,
|
||||
`interface_asset_id` int(11) NOT NULL,
|
||||
`company_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`interface_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `invoice_items`
|
||||
--
|
||||
|
|
@ -1498,4 +1522,4 @@ CREATE TABLE `vendors` (
|
|||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2022-12-19 11:42:40
|
||||
-- Dump completed on 2023-01-09 19:14:30
|
||||
|
|
|
|||
|
|
@ -89,6 +89,20 @@ if(isset($_GET['client_id'])){
|
|||
|
||||
$balance = $invoice_amounts - $amount_paid;
|
||||
|
||||
//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");
|
||||
$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");
|
||||
$row = mysqli_fetch_array($sql_recurring_yearly_total);
|
||||
|
||||
$recurring_yearly_total = $row['recurring_yearly_total'] / 12;
|
||||
|
||||
$recurring_monthly = $recurring_monthly_total + $recurring_yearly_total;
|
||||
|
||||
//Badge Counts
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('contact_id') AS num FROM contacts WHERE contact_archived_at IS NULL AND contact_client_id = $client_id"));
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ $location_phone = formatPhoneNumber($location_phone);
|
|||
<h4 class="text-secondary">Billing</h4>
|
||||
<h6 class="ml-1 text-secondary">Paid <div class="text-dark float-right"> <?php echo numfmt_format_currency($currency_format, $amount_paid, $client_currency_code); ?></div></h6>
|
||||
<h6 class="ml-1 text-secondary">Balance <div class="<?php if($balance > 0){ echo "text-danger"; }else{ echo "text-dark"; } ?> float-right"> <?php echo numfmt_format_currency($currency_format, $balance, $client_currency_code); ?></div></h6>
|
||||
<h6 class="ml-1 text-secondary">Monthly Recurring <div class="text-dark float-right"> <?php echo numfmt_format_currency($currency_format, $recurring_monthly, $client_currency_code); ?></div></h6>
|
||||
<h6 class="ml-1 text-secondary">Net Terms <div class="text-dark float-right"><?php echo $client_net_terms; ?> <small class="text-secondary">Days</small></div></h6>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,67 @@
|
|||
<?php include("inc_all_reports.php"); ?>
|
||||
<?php
|
||||
|
||||
$sql_clients = mysqli_query($mysqli,"SELECT * FROM clients 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-sync"></i> Recurring Income By Client</h3>
|
||||
<div class="card-tools">
|
||||
<button type="button" class="btn btn-primary d-print-none" onclick="window.print();"><i class="fas fa-fw fa-print"></i> Print</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Client</th>
|
||||
<th class="text-right">Monthly Recurring</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
while($row = mysqli_fetch_array($sql_clients)){
|
||||
$client_id = $row['client_id'];
|
||||
$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");
|
||||
$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");
|
||||
$row = mysqli_fetch_array($sql_recurring_yearly_total);
|
||||
|
||||
$recurring_yearly_total = $row['recurring_yearly_total'] / 12;
|
||||
|
||||
$recurring_monthly = $recurring_monthly_total + $recurring_yearly_total;
|
||||
$recurring_total = $recurring_total + $recurring_monthly;
|
||||
|
||||
if($recurring_monthly > 0){
|
||||
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td><?php echo $client_name; ?></td>
|
||||
<td class="text-right"><?php echo numfmt_format_currency($currency_format, $recurring_monthly, $session_company_currency); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<th>Total</th>
|
||||
<th class="text-right"><?php echo numfmt_format_currency($currency_format, $recurring_total, $session_company_currency); ?></th>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include("footer.php"); ?>
|
||||
|
|
@ -30,6 +30,12 @@
|
|||
<p>Income By Client</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="report_recurring_by_client.php" class="nav-link <?php if(basename($_SERVER["PHP_SELF"]) == "report_recurring_by_client.php") { echo "active"; } ?>">
|
||||
<i class="fa fa-sync nav-icon"></i>
|
||||
<p>Recurring Income By Client</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="report_expense_summary.php" class="nav-link <?php if(basename($_SERVER["PHP_SELF"]) == "report_expense_summary.php") { echo "active"; } ?>">
|
||||
<i class="far fa-credit-card nav-icon"></i>
|
||||
|
|
|
|||
Loading…
Reference in New Issue