Ability to create a referral when adding a client

This commit is contained in:
johnnyq 2023-11-08 23:30:44 -05:00
parent 89cbdd1038
commit 0103e05093
2 changed files with 13 additions and 10 deletions

View File

@ -65,7 +65,7 @@
<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">
<select class="form-control select2" data-tags="true" name="referral">
<option value="">N/A</option>
<?php
@ -76,9 +76,6 @@
<?php } ?>
</select>
<div class="input-group-append">
<button type="button" class="btn btn-secondary" data-toggle="modal" data-target="#addQuickReferralModal"><i class="fas fa-fw fa-plus"></i></button>
</div>
</div>
</div>

View File

@ -26,6 +26,13 @@ if (isset($_POST['add_client'])) {
$extended_log_description = '';
// Create Referral if it doesn't exist
$sql = mysqli_query($mysqli, "SELECT category_name FROM categories WHERE category_type = 'Referral' AND category_archived_at IS NULL AND category_name = '$referral'");
if(mysqli_num_rows($sql) == 0) {
mysqli_query($mysqli, "INSERT INTO categories SET category_name = '$referral', category_type = 'Referral'");
}
// Create client
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_tax_id_number = '$tax_id_number', client_lead = $lead, client_notes = '$notes', client_accessed_at = NOW()");
$client_id = mysqli_insert_id($mysqli);
@ -35,7 +42,7 @@ if (isset($_POST['add_client'])) {
file_put_contents("uploads/clients/$client_id/index.php", "");
}
//Add Location
// Create Location
if (!empty($location_phone) || !empty($address) || !empty($city) || !empty($state) || !empty($zip)) {
mysqli_query($mysqli, "INSERT INTO locations SET location_name = 'Primary', location_address = '$address', location_city = '$city', location_state = '$state', location_zip = '$zip', location_phone = '$location_phone', location_country = '$country', location_primary = 1, location_client_id = $client_id");
@ -44,7 +51,7 @@ if (isset($_POST['add_client'])) {
}
//Add Contact
// Create Contact
if (!empty($contact) || !empty($title) || !empty($contact_phone) || !empty($contact_mobile) || !empty($contact_email)) {
mysqli_query($mysqli, "INSERT INTO contacts SET contact_name = '$contact', contact_title = '$title', contact_phone = '$contact_phone', contact_extension = '$contact_extension', contact_mobile = '$contact_mobile', contact_email = '$contact_email', contact_primary = 1, contact_important = 1, contact_client_id = $client_id");
@ -52,7 +59,7 @@ if (isset($_POST['add_client'])) {
$extended_log_description .= ", primary contact $contact added";
}
//Add Tags
// Add Tags
if (isset($_POST['tags'])) {
foreach($_POST['tags'] as $tag) {
$tag = intval($tag);
@ -60,7 +67,7 @@ if (isset($_POST['add_client'])) {
}
}
//Add domain to domains/certificates
// Create domain in domains/certificates
if (!empty($website) && filter_var($website, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)) {
// Get domain expiry date
$expire = getDomainExpirationDate($website);
@ -96,7 +103,7 @@ if (isset($_POST['add_client'])) {
}
//Logging
// Logging
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Client', log_action = 'Create', log_description = '$session_name created client $name$extended_log_description', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $client_id");
$_SESSION['alert_message'] = "Client <strong>$name</strong> created";
@ -110,7 +117,6 @@ if (isset($_POST['edit_client'])) {
require_once 'post/client_model.php';
validateAdminRole();
$client_id = intval($_POST['client_id']);