Feature: Vendors can now be linked to documents

This commit is contained in:
johnnyq
2023-08-24 17:03:45 -04:00
parent 6325301a00
commit 6858d1f293
5 changed files with 221 additions and 2 deletions

View File

@@ -132,6 +132,43 @@ if (isset($_POST['move_document'])) {
}
if (isset($_POST['associate_vendor_to_document'])) {
validateTechRole();
$client_id = intval($_POST['client_id']);
$document_id = intval($_POST['document_id']);
$vendor_id = intval($_POST['vendor_id']);
// Document add query
mysqli_query($mysqli,"INSERT INTO vendor_documents SET vendor_id = $vendor_id, document_id = $document_id");
// Logging
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Document', log_action = 'Create', log_description = 'Created Document Vendor Relation', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id");
$_SESSION['alert_message'] = "Vendor associated with Document";
header("Location: " . $_SERVER["HTTP_REFERER"]);
}
if (isset($_GET['unassociate_vendor_from_document'])) {
validateTechRole();
$vendor_id = intval($_GET['vendor_id']);
$document_id = intval($_GET['document_id']);
mysqli_query($mysqli,"DELETE FROM vendor_documents WHERE vendor_id = $vendor_id AND document_id = $document_id");
//Logging
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Document', log_action = 'Delete', log_description = 'Document Vendor relationship removed', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id");
$_SESSION['alert_message'] = "Vendor has been unassciated";
header("Location: " . $_SERVER["HTTP_REFERER"]);
}
if (isset($_POST['edit_document_template'])) {
validateTechRole();