Added Support Type option to clients, added date added field in client listing, added client_accessed_at and sorted clients listing by recently accessed by default within client listing

This commit is contained in:
johnnyq 2021-08-10 20:12:58 -04:00
parent 83f2550d81
commit 63c986ab3c
7 changed files with 51 additions and 10 deletions

View File

@ -51,6 +51,19 @@
</div>
</div>
<div class="form-group">
<label>Support</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-handshake"></i></span>
</div>
<select class="form-control select2" name="support">
<option>Non-Maintenance</option>
<option>Maintenance</option>
</select>
</div>
</div>
<div class="form-group">
<label>Referral</label>
<div class="input-group">

View File

@ -6,6 +6,8 @@
if(isset($_GET['client_id'])){
$client_id = intval($_GET['client_id']);
$sql = mysqli_query($mysqli,"UPDATE clients SET client_accessed_at = NOW() WHERE client_id = $client_id AND company_id = $session_company_id");
$sql = mysqli_query($mysqli,"SELECT * FROM clients WHERE client_id = $client_id AND company_id = $session_company_id");
if(mysqli_num_rows($sql) == 0){
@ -39,6 +41,7 @@ if(isset($_GET['client_id'])){
if($client_net_terms == 0){
$client_net_terms = $config_default_net_terms;
}
$client_support = $row['client_support'];
$client_notes = $row['client_notes'];
//Add up all the payments for the invoice and get the total amount paid to the invoice

View File

@ -13,6 +13,9 @@
<p>Back</p> |
<p><strong><?php echo $client_name; ?></strong></p>
</a>
<center>
<small class="text-secondary"><i class="fas fa-handshake"></i> <strong>SUPPORT: </strong><span style="color:<?php echo ($client_support=="Maintenance"?"green":"red");?>;"><?php echo $client_support;?></span></small>
</center>
</li>
<li class="nav-header mt-3">CLIENT</li>

View File

@ -29,7 +29,7 @@ if(isset($_GET['q'])){
if(!empty($_GET['sb'])){
$sb = mysqli_real_escape_string($mysqli,$_GET['sb']);
}else{
$sb = "client_name";
$sb = "client_accessed_at";
}
//Column Order Filter
@ -42,8 +42,8 @@ if(isset($_GET['o'])){
$disp = "ASC";
}
}else{
$o = "ASC";
$disp = "DESC";
$o = "DESC";
$disp = "ASC";
}
//Date From and Date To Filter
@ -59,7 +59,7 @@ if(!empty($_GET['dtf'])){
$url_query_strings_sb = http_build_query(array_merge($_GET,array('sb' => $sb, 'o' => $o)));
$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM clients
WHERE (client_name LIKE '%$q%' OR client_type LIKE '%$q%' OR client_email LIKE '%$q%' OR client_contact LIKE '%$q%' OR client_phone LIKE '%$q%'
WHERE (client_name LIKE '%$q%' OR client_type LIKE '%$q%' OR client_support LIKE '%$q%' OR client_email LIKE '%$q%' OR client_contact LIKE '%$q%' OR client_phone LIKE '%$q%'
OR client_mobile LIKE '%$q%' OR client_address LIKE '%$q%' OR client_city LIKE '%$q%' OR client_state LIKE '%$q%' OR client_zip LIKE '%$q%')
AND DATE(client_created_at) BETWEEN '$dtf' AND '$dtt'
AND company_id = $session_company_id $permission_sql
@ -147,6 +147,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
$client_currency_code = $row['client_currency_code'];
$client_net_terms = $row['client_net_terms'];
$client_referral = $row['client_referral'];
$client_support = $row['client_support'];
$client_notes = $row['client_notes'];
$client_created_at = $row['client_created_at'];
$client_updated_at = $row['client_updated_at'];
@ -176,6 +177,10 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
<a href="client.php?client_id=<?php echo $client_id; ?>&tab=contacts"><?php echo $client_name; ?></a>
<br>
<small class="text-secondary"><?php echo $client_type; ?></small>
<br>
<small class="text-secondary"><i class="fas fa-handshake fa-fw"></i> <b>SUPPORT: </b><span style="color:<?php echo ($client_support == "Maintenance" ? "green" : "red");?>;"><?php echo $client_support;?></span></small>
<br>
<small class="text-secondary"><b>Contract started: </b><?php echo $client_created_at; ?></small>
</td>
<td>
<?php echo "$client_address<br>$client_city $client_state $client_zip"; ?>

10
db.sql
View File

@ -1,8 +1,8 @@
-- MariaDB dump 10.19 Distrib 10.5.9-MariaDB, for debian-linux-gnu (x86_64)
-- MariaDB dump 10.19 Distrib 10.5.11-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: localhost Database: admin_crm
-- Host: localhost Database: pittpc_crm
-- ------------------------------------------------------
-- Server version 10.5.9-MariaDB-1:10.5.9+maria~focal
-- Server version 10.5.11-MariaDB-1:10.5.11+maria~focal
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@ -176,10 +176,12 @@ CREATE TABLE `clients` (
`client_referral` varchar(200) DEFAULT NULL,
`client_currency_code` varchar(200) NOT NULL,
`client_net_terms` int(10) NOT NULL,
`client_support` varchar(100) DEFAULT NULL,
`client_notes` text DEFAULT NULL,
`client_created_at` datetime NOT NULL,
`client_updated_at` datetime DEFAULT NULL,
`client_archived_at` datetime DEFAULT NULL,
`client_accessed_at` datetime DEFAULT NULL,
`company_id` int(11) NOT NULL,
PRIMARY KEY (`client_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
@ -1005,4 +1007,4 @@ CREATE TABLE `vendors` (
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2021-04-30 17:52:53
-- Dump completed on 2021-08-10 20:10:46

View File

@ -52,6 +52,19 @@
</div>
</div>
<div class="form-group">
<label>Support</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-handshake"></i></span>
</div>
<select class="form-control select2" name="support">
<option <?php if($client_support == "Non-Maintenance"){ echo "selected"; } ?>>Non-Maintenance</option>
<option <?php if($client_support == "Maintenance"){ echo "selected"; } ?>>Maintenance</option>
</select>
</div>
</div>
<div class="form-group">
<label>Referral</label>
<div class="input-group">

View File

@ -676,6 +676,7 @@ if(isset($_POST['add_client'])){
$name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])));
$type = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['type'])));
$support = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['support'])));
$country = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['country'])));
$address = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['address'])));
$city = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['city'])));
@ -692,7 +693,7 @@ if(isset($_POST['add_client'])){
$net_terms = intval($_POST['net_terms']);
$notes = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes'])));
mysqli_query($mysqli,"INSERT INTO clients SET client_name = '$name', client_type = '$type', client_country = '$country', client_address = '$address', client_city = '$city', client_state = '$state', client_zip = '$zip', client_contact = '$contact', client_phone = '$phone', client_extension = '$extension', client_mobile = '$mobile', client_email = '$email', client_website = '$website', client_referral = '$referral', client_currency_code = '$currency_code', client_net_terms = $net_terms, client_notes = '$notes', client_created_at = NOW(), company_id = $session_company_id");
mysqli_query($mysqli,"INSERT INTO clients SET client_name = '$name', client_type = '$type', client_country = '$country', client_address = '$address', client_city = '$city', client_state = '$state', client_zip = '$zip', client_contact = '$contact', client_phone = '$phone', client_extension = '$extension', client_mobile = '$mobile', client_email = '$email', client_website = '$website', client_referral = '$referral', client_currency_code = '$currency_code', client_net_terms = $net_terms, client_support = '$support', client_notes = '$notes', client_created_at = NOW(), company_id = $session_company_id");
$client_id = mysqli_insert_id($mysqli);
@ -714,6 +715,7 @@ if(isset($_POST['edit_client'])){
$client_id = intval($_POST['client_id']);
$name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])));
$type = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['type'])));
$support = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['support'])));
$country = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['country'])));
$address = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['address'])));
$city = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['city'])));
@ -730,7 +732,7 @@ if(isset($_POST['edit_client'])){
$net_terms = intval($_POST['net_terms']);
$notes = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['notes'])));
mysqli_query($mysqli,"UPDATE clients SET client_name = '$name', client_type = '$type', client_country = '$country', client_address = '$address', client_city = '$city', client_state = '$state', client_zip = '$zip', client_contact = '$contact', client_phone = '$phone', client_extension = '$extension', client_mobile = '$mobile', client_email = '$email', client_website = '$website', client_referral = '$referral', client_currency_code = '$currency_code', client_net_terms = $net_terms, client_notes = '$notes', client_updated_at = NOW() WHERE client_id = $client_id AND company_id = $session_company_id");
mysqli_query($mysqli,"UPDATE clients SET client_name = '$name', client_type = '$type', client_country = '$country', client_address = '$address', client_city = '$city', client_state = '$state', client_zip = '$zip', client_contact = '$contact', client_phone = '$phone', client_extension = '$extension', client_mobile = '$mobile', client_email = '$email', client_website = '$website', client_referral = '$referral', client_currency_code = '$currency_code', client_net_terms = $net_terms, client_support = '$support', client_notes = '$notes', client_updated_at = NOW() WHERE client_id = $client_id AND company_id = $session_company_id");
//Logging
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Client', log_action = 'Modified', log_description = '$name', log_created_at = NOW(), client_id = $client_id, company_id = $session_company_id, user_id = $session_user_id");