New Feature: Added Hourly Rate to Client

This commit is contained in:
johnnyq
2023-03-28 15:29:54 -04:00
parent 1e2535359a
commit c544dc4a2a
11 changed files with 42 additions and 8 deletions

View File

@@ -225,6 +225,17 @@
<div class="tab-pane fade" id="pills-additional"> <div class="tab-pane fade" id="pills-additional">
<?php if ($config_module_enable_accounting) { ?> <?php if ($config_module_enable_accounting) { ?>
<div class="form-group">
<label>Hourly Rate</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-clock"></i></span>
</div>
<input type="number" step="0.01" min="0" class="form-control" name="rate" placeholder="Hourly rate">
</div>
</div>
<div class="form-group"> <div class="form-group">
<label>Currency <strong class="text-danger">*</strong></label> <label>Currency <strong class="text-danger">*</strong></label>
<div class="input-group"> <div class="input-group">

View File

@@ -86,6 +86,17 @@
</div> </div>
<?php if ($config_module_enable_accounting) { ?> <?php if ($config_module_enable_accounting) { ?>
<div class="form-group">
<label>Hourly Rate</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-clock"></i></span>
</div>
<input type="number" step="0.01" min="0" class="form-control" name="rate" placeholder="Hourly rate" value="<?php echo $client_rate; ?>">
</div>
</div>
<div class="form-group"> <div class="form-group">
<label>Currency <strong class="text-danger">*</strong></label> <label>Currency <strong class="text-danger">*</strong></label>
<div class="input-group"> <div class="input-group">

View File

@@ -122,6 +122,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
$contact_mobile = formatPhoneNumber($row['contact_mobile']); $contact_mobile = formatPhoneNumber($row['contact_mobile']);
$contact_email = htmlentities($row['contact_email']); $contact_email = htmlentities($row['contact_email']);
$client_website = htmlentities($row['client_website']); $client_website = htmlentities($row['client_website']);
$client_rate = floatval($row['client_rate']);
$client_currency_code = htmlentities($row['client_currency_code']); $client_currency_code = htmlentities($row['client_currency_code']);
$client_net_terms = intval($row['client_net_terms']); $client_net_terms = intval($row['client_net_terms']);
$client_referral = htmlentities($row['client_referral']); $client_referral = htmlentities($row['client_referral']);
@@ -242,6 +243,8 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<span class="text-secondary">Paid</span> <?php echo numfmt_format_currency($currency_format, $amount_paid, $session_company_currency); ?> <span class="text-secondary">Paid</span> <?php echo numfmt_format_currency($currency_format, $amount_paid, $session_company_currency); ?>
<br> <br>
<span class="text-secondary">Monthly</span> <?php echo numfmt_format_currency($currency_format, $recurring_monthly, $session_company_currency); ?> <span class="text-secondary">Monthly</span> <?php echo numfmt_format_currency($currency_format, $recurring_monthly, $session_company_currency); ?>
<br>
<span class="text-secondary">Hourly Rate</span> <?php echo numfmt_format_currency($currency_format, $client_rate, $session_company_currency); ?>
</td> </td>
<?php } ?> <?php } ?>

View File

@@ -934,11 +934,17 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) {
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.4.7'"); mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.4.7'");
} }
//if (CURRENT_DATABASE_VERSION == '0.4.7') { if (CURRENT_DATABASE_VERSION == '0.4.7') {
// Insert queries here required to update to DB version 0.4.8
mysqli_query($mysqli, "ALTER TABLE `clients` ADD `client_rate` DECIMAL(15,2) NULL DEFAULT NULL AFTER `client_referral`");
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.4.8'");
}
//if (CURRENT_DATABASE_VERSION == '0.4.8') {
// Insert queries here required to update to DB version 0.4.9
// Then, update the database to the next sequential version // Then, update the database to the next sequential version
// mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.4.8'"); // mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.4.9'");
//} //}
} else { } else {

View File

@@ -5,4 +5,4 @@
* It is used in conjunction with database_updates.php * It is used in conjunction with database_updates.php
*/ */
DEFINE("LATEST_DATABASE_VERSION", "0.4.7"); DEFINE("LATEST_DATABASE_VERSION", "0.4.8");

3
db.sql
View File

@@ -220,6 +220,7 @@ CREATE TABLE `clients` (
`client_type` varchar(200) DEFAULT NULL, `client_type` varchar(200) DEFAULT NULL,
`client_website` varchar(200) DEFAULT NULL, `client_website` varchar(200) DEFAULT NULL,
`client_referral` varchar(200) DEFAULT NULL, `client_referral` varchar(200) DEFAULT NULL,
`client_rate` decimal(15,2) DEFAULT NULL,
`client_currency_code` varchar(200) NOT NULL, `client_currency_code` varchar(200) NOT NULL,
`client_net_terms` int(10) NOT NULL, `client_net_terms` int(10) NOT NULL,
`client_notes` text DEFAULT NULL, `client_notes` text DEFAULT NULL,
@@ -1468,4 +1469,4 @@ CREATE TABLE `vendors` (
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2023-03-18 15:21:29 -- Dump completed on 2023-03-28 15:29:24

View File

@@ -922,4 +922,3 @@ $asset_status_array = array(
'Lost/Stolen', 'Lost/Stolen',
'Retired' 'Retired'
); );

View File

@@ -34,6 +34,7 @@ if (isset($_GET['client_id'])) {
if ($client_net_terms == 0) { if ($client_net_terms == 0) {
$client_net_terms = $config_default_net_terms; $client_net_terms = $config_default_net_terms;
} }
$client_rate = floatval($row['client_rate']);
$client_notes = htmlentities($row['client_notes']); $client_notes = htmlentities($row['client_notes']);
$client_created_at = htmlentities($row['client_created_at']); $client_created_at = htmlentities($row['client_created_at']);
$primary_contact = intval($row['primary_contact']); $primary_contact = intval($row['primary_contact']);

View File

@@ -60,6 +60,7 @@
<?php if ($session_user_role == 1 || $session_user_role == 3 && $config_module_enable_accounting == 1) { ?> <?php if ($session_user_role == 1 || $session_user_role == 3 && $config_module_enable_accounting == 1) { ?>
<div class="col-md border-left"> <div class="col-md border-left">
<h4 class="text-secondary">Billing</h4> <h4 class="text-secondary">Billing</h4>
<h6 class="ml-1 text-secondary">Hourly Rate <div class="text-dark float-right"> <?php echo numfmt_format_currency($currency_format, $client_rate, $client_currency_code); ?></div></h6>
<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">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">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">Monthly Recurring <div class="text-dark float-right"> <?php echo numfmt_format_currency($currency_format, $recurring_monthly, $client_currency_code); ?></div></h6>

View File

@@ -3,6 +3,7 @@ $name = sanitizeInput($_POST['name']);
$type = sanitizeInput($_POST['type']); $type = sanitizeInput($_POST['type']);
$website = sanitizeInput($_POST['website']); $website = sanitizeInput($_POST['website']);
$referral = sanitizeInput($_POST['referral']); $referral = sanitizeInput($_POST['referral']);
$rate = floatval($_POST['rate']);
$currency_code = sanitizeInput($_POST['currency_code']); $currency_code = sanitizeInput($_POST['currency_code']);
$net_terms = intval($_POST['net_terms']); $net_terms = intval($_POST['net_terms']);
$notes = sanitizeInput($_POST['notes']); $notes = sanitizeInput($_POST['notes']);

View File

@@ -1471,7 +1471,7 @@ if(isset($_POST['add_client'])){
$extended_log_description = ''; $extended_log_description = '';
mysqli_query($mysqli,"INSERT INTO clients SET client_name = '$name', client_type = '$type', client_website = '$website', client_referral = '$referral', client_currency_code = '$currency_code', client_net_terms = $net_terms, client_notes = '$notes', client_accessed_at = NOW()"); mysqli_query($mysqli,"INSERT INTO clients SET client_name = '$name', client_type = '$type', client_website = '$website', client_referral = '$referral', client_rate = $rate, client_currency_code = '$currency_code', client_net_terms = $net_terms, client_notes = '$notes', client_accessed_at = NOW()");
$client_id = mysqli_insert_id($mysqli); $client_id = mysqli_insert_id($mysqli);
@@ -1567,7 +1567,7 @@ if(isset($_POST['edit_client'])){
$client_id = intval($_POST['client_id']); $client_id = intval($_POST['client_id']);
mysqli_query($mysqli,"UPDATE clients SET client_name = '$name', client_type = '$type', client_website = '$website', client_referral = '$referral', client_currency_code = '$currency_code', client_net_terms = $net_terms, client_notes = '$notes' WHERE client_id = $client_id"); mysqli_query($mysqli,"UPDATE clients SET client_name = '$name', client_type = '$type', client_website = '$website', client_referral = '$referral', client_rate = $rate, client_currency_code = '$currency_code', client_net_terms = $net_terms, client_notes = '$notes' WHERE client_id = $client_id");
//Tags //Tags
//Delete existing tags //Delete existing tags