diff --git a/client_add_modal.php b/client_add_modal.php index 8a4491dd..dcc62e5b 100644 --- a/client_add_modal.php +++ b/client_add_modal.php @@ -65,7 +65,7 @@
- -
- -
diff --git a/post/client.php b/post/client.php index efc99a47..e8be32a1 100644 --- a/post/client.php +++ b/post/client.php @@ -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 $name created"; @@ -110,7 +117,6 @@ if (isset($_POST['edit_client'])) { require_once 'post/client_model.php'; - validateAdminRole(); $client_id = intval($_POST['client_id']);