Added Referral as a category option, removed Hours and Client Size undr client, rerranged client add and edit New DB Dump

This commit is contained in:
johnny@pittpc.com 2021-01-15 19:03:07 -05:00
parent b4b1326c99
commit ad979ac8fd
7 changed files with 86 additions and 111 deletions

View File

@ -20,9 +20,6 @@
<li class="nav-item">
<a class="nav-link" id="pills-contact-tab" data-toggle="pill" href="#pills-contact">Contact</a>
</li>
<li class="nav-item">
<a class="nav-link" id="pills-more-tab" data-toggle="pill" href="#pills-more">More</a>
</li>
<li class="nav-item">
<a class="nav-link" id="pills-notes-tab" data-toggle="pill" href="#pills-notes">Notes</a>
</li>
@ -54,6 +51,43 @@
</div>
</div>
<div class="form-group">
<label>Referral</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-smile-wink"></i></span>
</div>
<select class="form-control select2" name="referral">
<option value="">N/A</option>
<?php
$referral_sql = mysqli_query($mysqli,"SELECT * FROM categories WHERE category_type = 'Referral' AND company_id = $session_company_id ORDER BY category_name ASC");
while($row = mysqli_fetch_array($referral_sql)){
$referral = $row['category_name'];
?>
<option><?php echo $referral; ?></option>
<?php
}
?>
</select>
</div>
</div>
<div class="form-group">
<label>Invoice Net Terms</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
</div>
<select class="form-control select2" name="net_terms">
<?php foreach($net_terms_array as $net_term_value => $net_term_name) { ?>
<option <?php if($config_default_net_terms == $net_term_value){ echo "selected"; } ?> value="<?php echo $net_term_value; ?>"><?php echo $net_term_name; ?></option>
<?php } ?>
</select>
</div>
</div>
</div>
<div class="tab-pane fade" id="pills-address">
@ -169,34 +203,6 @@
<input type="email" class="form-control" name="email" placeholder="Email Address">
</div>
</div>
</div>
<div class="tab-pane fade" id="pills-more">
<div class="form-group">
<label>Hours</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="text" class="form-control" name="hours" placeholder="Hours of operation">
</div>
</div>
<div class="form-group">
<label>Invoice Net Terms</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
</div>
<select class="form-control select2" name="net_terms">
<?php foreach($net_terms_array as $net_term_value => $net_term_name) { ?>
<option <?php if($config_default_net_terms == $net_term_value){ echo "selected"; } ?> value="<?php echo $net_term_value; ?>"><?php echo $net_term_name; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group">
<label>Website</label>
@ -207,23 +213,6 @@
<input type="url" class="form-control" name="website" placeholder="ex. https://google.com">
</div>
</div>
<div class="form-group">
<label>Company Size</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-users"></i></span>
</div>
<select class="form-control select2" name="company_size">
<option>1 - 3</option>
<option>4 - 10</option>
<option>11 - 50</option>
<option>51 - 100</option>
<option>101 - 500</option>
<option>500+</option>
</select>
</div>
</div>
</div>

View File

@ -16,11 +16,11 @@ if(isset($_GET['client_id'])){
$row = mysqli_fetch_array($sql);
$client_name = $row['client_name'];
$client_type = $row['client_type'];
$client_country = $row['client_country'];
$client_address = $row['client_address'];
$client_city = $row['client_city'];
$client_state = $row['client_state'];
$client_zip = $row['client_zip'];
$client_country = $row['client_country'];
$client_contact = $row['client_contact'];
$client_email = $row['client_email'];
$client_phone = $row['client_phone'];
@ -32,11 +32,11 @@ if(isset($_GET['client_id'])){
$client_mobile = substr($row['client_mobile'],0,3)."-".substr($row['client_mobile'],3,3)."-".substr($row['client_mobile'],6,4);
}
$client_website = $row['client_website'];
$client_referral = $row['client_referral'];
$client_net_terms = $row['client_net_terms'];
if($client_net_terms == 0){
$client_net_terms = $config_default_net_terms;
}
$client_company_size = $row['client_company_size'];
$client_notes = $row['client_notes'];
//Add up all the payments for the invoice and get the total amount paid to the invoice

View File

@ -135,8 +135,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
$client_email = $row['client_email'];
$client_website = $row['client_website'];
$client_net_terms = $row['client_net_terms'];
$client_hours = $row['client_hours'];
$client_company_size = $row['client_company_size'];
$client_referral = $row['client_referral'];
$client_notes = $row['client_notes'];
//Add up all the payments for the invoice and get the total amount paid to the invoice

5
db.sql
View File

@ -145,9 +145,8 @@ CREATE TABLE `clients` (
`client_mobile` varchar(200) DEFAULT NULL,
`client_email` varchar(200) DEFAULT NULL,
`client_website` varchar(200) DEFAULT NULL,
`client_referral` varchar(200) DEFAULT NULL,
`client_net_terms` int(10) NOT NULL,
`client_hours` varchar(200) DEFAULT NULL,
`client_company_size` varchar(200) DEFAULT NULL,
`client_notes` text DEFAULT NULL,
`client_created_at` datetime NOT NULL,
`client_updated_at` datetime DEFAULT NULL,
@ -882,4 +881,4 @@ CREATE TABLE `vendors` (
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2021-01-15 15:05:00
-- Dump completed on 2021-01-15 19:01:39

View File

@ -21,9 +21,6 @@
<li class="nav-item">
<a class="nav-link" id="pills-contact-tab<?php echo $client_id; ?>" data-toggle="pill" href="#pills-contact<?php echo $client_id; ?>">Contact</a>
</li>
<li class="nav-item">
<a class="nav-link" id="pills-more-tab<?php echo $client_id; ?>" data-toggle="pill" href="#pills-more<?php echo $client_id; ?>">More</a>
</li>
<li class="nav-item">
<a class="nav-link" id="pills-notes-tab<?php echo $client_id; ?>" data-toggle="pill" href="#pills-notes<?php echo $client_id; ?>">Notes</a>
</li>
@ -55,6 +52,44 @@
</div>
</div>
<div class="form-group">
<label>Referral</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-smile-wink"></i></span>
</div>
<select class="form-control select2" name="referral">
<option value="">N/A</option>
<?php
$referral_sql = mysqli_query($mysqli,"SELECT * FROM categories WHERE category_type = 'Referral' AND company_id = $session_company_id ORDER BY category_name ASC");
while($row = mysqli_fetch_array($referral_sql)){
$referral = $row['category_name'];
?>
<option <?php if($client_referral == $referral){ echo "selected"; } ?> > <?php echo $referral; ?></option>
<?php
}
?>
</select>
</div>
</div>
<div class="form-group">
<label>Invoice Net Terms</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
</div>
<select class="form-control select2" name="net_terms">
<option value="">- Net Terms -</option>
<?php foreach($net_terms_array as $net_term_value => $net_term_name) { ?>
<option <?php if($net_term_value == $client_net_terms) { echo "selected"; } ?> value="<?php echo $net_term_value; ?>"><?php echo $net_term_name; ?></option>
<?php } ?>
</select>
</div>
</div>
</div>
<div class="tab-pane fade" id="pills-address<?php echo $client_id; ?>">
@ -169,35 +204,6 @@
<input type="email" class="form-control" name="email" placeholder="Email Address" value="<?php echo $client_email; ?>">
</div>
</div>
</div>
<div class="tab-pane fade" id="pills-more<?php echo $client_id; ?>">
<div class="form-group">
<label>Hours</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="text" class="form-control" name="hours" placeholder="Hours of operation" value="<?php echo $client_hours; ?>">
</div>
</div>
<div class="form-group">
<label>Invoice Net Terms</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
</div>
<select class="form-control select2" name="net_terms">
<option value="">- Net Terms -</option>
<?php foreach($net_terms_array as $net_term_value => $net_term_name) { ?>
<option <?php if($net_term_value == $client_net_terms) { echo "selected"; } ?> value="<?php echo $net_term_value; ?>"><?php echo $net_term_name; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group">
<label>Website</label>
@ -208,23 +214,6 @@
<input type="text" class="form-control" name="website" placeholder="ex. https://google.com" value="<?php echo $client_website; ?>">
</div>
</div>
<div class="form-group">
<label>Company Size</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-users"></i></span>
</div>
<select class="form-control select2" name="company_size">
<option <?php if($client_company_size == "1 - 3"){ echo "selected"; } ?>>1 - 3</option>
<option <?php if($client_company_size == "4 - 10"){ echo "selected"; } ?>>4 - 10</option>
<option <?php if($client_company_size == "11 - 50"){ echo "selected"; } ?>>11 - 50</option>
<option <?php if($client_company_size == "51 - 100"){ echo "selected"; } ?>>51 - 100</option>
<option <?php if($client_company_size == "101 - 500"){ echo "selected"; } ?>>101 - 500</option>
<option <?php if($client_company_size == "500+"){ echo "selected"; } ?>>500+</option>
</select>
</div>
</div>
</div>

View File

@ -161,7 +161,8 @@ $timezones_array = array(
$category_types_array = array(
'Expense',
'Income',
'Payment Method'
'Payment Method',
'Referral'
);
$asset_types_array = array(

View File

@ -511,12 +511,11 @@ if(isset($_POST['add_client'])){
$mobile = preg_replace("/[^0-9]/", '',$mobile);
$email = strip_tags(mysqli_real_escape_string($mysqli,$_POST['email']));
$website = strip_tags(mysqli_real_escape_string($mysqli,$_POST['website']));
$referral = strip_tags(mysqli_real_escape_string($mysqli,$_POST['referral']));
$net_terms = intval($_POST['net_terms']);
$hours = strip_tags(mysqli_real_escape_string($mysqli,$_POST['hours']));
$company_size = strip_tags(mysqli_real_escape_string($mysqli,$_POST['company_size']));
$notes = 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_net_terms = $net_terms, client_hours = '$hours', client_company_size = '$company_size', 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_net_terms = $net_terms, client_notes = '$notes', client_created_at = NOW(), company_id = $session_company_id");
$client_id = mysqli_insert_id($mysqli);
@ -551,12 +550,11 @@ if(isset($_POST['edit_client'])){
$mobile = preg_replace("/[^0-9]/", '',$mobile);
$email = strip_tags(mysqli_real_escape_string($mysqli,$_POST['email']));
$website = strip_tags(mysqli_real_escape_string($mysqli,$_POST['website']));
$referral = strip_tags(mysqli_real_escape_string($mysqli,$_POST['referral']));
$net_terms = intval($_POST['net_terms']);
$hours = strip_tags(mysqli_real_escape_string($mysqli,$_POST['hours']));
$company_size = strip_tags(mysqli_real_escape_string($mysqli,$_POST['company_size']));
$notes = 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_net_terms = $net_terms, client_hours = '$hours', client_company_size = '$company_size', 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_net_terms = $net_terms, 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");