diff --git a/client_asset_bulk_assign_contact_modal.php b/client_asset_bulk_assign_contact_modal.php new file mode 100644 index 00000000..fd5dd915 --- /dev/null +++ b/client_asset_bulk_assign_contact_modal.php @@ -0,0 +1,44 @@ + \ No newline at end of file diff --git a/client_assets.php b/client_assets.php index 31b3a2c9..5e79483a 100644 --- a/client_assets.php +++ b/client_assets.php @@ -144,6 +144,10 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); Bulk Action (0) + diff --git a/post/asset.php b/post/asset.php index a46d275e..73f3173a 100644 --- a/post/asset.php +++ b/post/asset.php @@ -260,6 +260,45 @@ if (isset($_POST['bulk_assign_asset_location'])) { } +if (isset($_POST['bulk_assign_asset_contact'])) { + + validateTechRole(); + + $contact_id = intval($_POST['contact_id']); + + // Get Contact name and client id for logging and Notification + $sql = mysqli_query($mysqli,"SELECT contact_name, contact_client_id FROM contacts WHERE contact_id = $contact_id"); + $row = mysqli_fetch_array($sql); + $contact_name = sanitizeInput($row['contact_name']); + $client_id = intval($row['contact_client_id']); + + // Get Selected Contacts Count + $asset_count = count($_POST['asset_ids']); + + // Assign Contact to Selected Assets + if (!empty($_POST['asset_ids'])) { + foreach($_POST['asset_ids'] as $asset_id) { + $asset_id = intval($asset_id); + + // Get Asset Details for Logging + $sql = mysqli_query($mysqli,"SELECT asset_name FROM assets WHERE asset_id = $asset_id"); + $row = mysqli_fetch_array($sql); + $asset_name = sanitizeInput($row['asset_name']); + + mysqli_query($mysqli,"UPDATE assets SET asset_contact_id = $contact_id WHERE asset_id = $asset_id"); + + //Logging + mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Asset', log_action = 'Modify', log_description = '$session_name assigned $asset_name to contact $contact_name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $asset_id"); + + } // End Assign Contact Loop + + $_SESSION['alert_message'] = "You assigned $asset_count assets to contact $contact_name"; + } + + header("Location: " . $_SERVER["HTTP_REFERER"]); + +} + if (isset($_POST["import_client_assets_csv"])) { validateTechRole();