diff --git a/client_contact_edit_modal.php b/client_contact_edit_modal.php index 1a67a5b6..ef866edf 100644 --- a/client_contact_edit_modal.php +++ b/client_contact_edit_modal.php @@ -183,7 +183,7 @@
-
+
contact_photo"> diff --git a/client_document_add_modal.php b/client_document_add_modal.php index 33437a7b..c83ca209 100644 --- a/client_document_add_modal.php +++ b/client_document_add_modal.php @@ -71,8 +71,19 @@
diff --git a/client_document_edit_modal.php b/client_document_edit_modal.php index 7678b8c4..c7cf0dfc 100644 --- a/client_document_edit_modal.php +++ b/client_document_edit_modal.php @@ -14,34 +14,6 @@
- - - -
-
- - -
-
- -
@@ -69,8 +41,17 @@
diff --git a/client_document_folder_add_modal.php b/client_document_folder_add_modal.php new file mode 100644 index 00000000..d555cbf1 --- /dev/null +++ b/client_document_folder_add_modal.php @@ -0,0 +1,32 @@ + diff --git a/client_documents.php b/client_documents.php index ef5f703c..16387108 100644 --- a/client_documents.php +++ b/client_documents.php @@ -1,5 +1,12 @@ $sb, 'o' => $o))); -# Currently using two separate queries: one with and one without tags -# If we use a query with tags with no tags set (or even %), then documents appear twice - -$sql_no_tag = "SELECT SQL_CALC_FOUND_ROWS * FROM documents +$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM documents WHERE document_client_id = $client_id AND documents.company_id = $session_company_id AND document_template = 0 + AND document_folder_id = $folder $query_snippet - ORDER BY $sb $o LIMIT $record_from, $record_to"; - -$sql_with_tag = "SELECT SQL_CALC_FOUND_ROWS * FROM documents - LEFT JOIN documents_tagged ON documents.document_id = documents_tagged.document_id - WHERE document_client_id = $client_id - AND documents.company_id = $session_company_id - AND document_template = 0 - $query_snippet - AND documents_tagged.tag_id LIKE '%$tag%' - ORDER BY $sb $o LIMIT $record_from, $record_to"; - -if (empty($tag)) { - $sql = mysqli_query($mysqli, $sql_no_tag); -} -else { - $sql = mysqli_query($mysqli, $sql_with_tag); -} + ORDER BY $sb $o LIMIT $record_from, $record_to" +); $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); @@ -68,120 +47,138 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); -
-
- 0) { - foreach($document_tags as $document_tag) { - echo ""; echo htmlentities($document_tag['tag_name']); echo ""; - } - } - else { - $document_tags = FALSE; - } - ?> -
-
- - -
- -
- -
-
-
-
+
+
+

Folders

+
+
+ +
- + - - \ No newline at end of file + \ No newline at end of file diff --git a/post.php b/post.php index 938c8741..6842891b 100644 --- a/post.php +++ b/post.php @@ -7008,6 +7008,85 @@ if(isset($_GET['delete_document'])){ } +if(isset($_POST['add_folder'])){ + + if($session_user_role == 1){ + $_SESSION['alert_type'] = "danger"; + $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED; + header("Location: " . $_SERVER["HTTP_REFERER"]); + exit(); + } + + $client_id = intval($_POST['client_id']); + $folder_name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['folder_name']))); + + // Document folder add query + $add_folder = mysqli_query($mysqli,"INSERT INTO folders SET folder_name = '$folder_name', folder_client_id = $client_id, company_id = $session_company_id"); + $folder_id = $mysqli->insert_id; + + // Logging + mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Folder', log_action = 'Create', log_description = 'Created $folder_name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = '$client_id', company_id = $session_company_id, log_user_id = $session_user_id"); + + $_SESSION['alert_message'] = "Folder created"; + + header("Location: " . $_SERVER["HTTP_REFERER"]); + +} + +if(isset($_POST['edit_folder'])){ + + if($session_user_role == 1){ + $_SESSION['alert_type'] = "danger"; + $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED; + header("Location: " . $_SERVER["HTTP_REFERER"]); + exit(); + } + + $folder_id = intval($_POST['folder_id']); + $folder_name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['folder_name']))); + + // Folder edit query + mysqli_query($mysqli,"UPDATE folders SET folder_name = '$folder_name' WHERE folder_id = $folder_id AND company_id = $session_company_id"); + + //Logging + mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Folder', log_action = 'Modify', log_description = '$folder_name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id, company_id = $session_company_id"); + + $_SESSION['alert_message'] = "Folder renamed"; + + header("Location: " . $_SERVER["HTTP_REFERER"]); + +} + +if(isset($_GET['delete_folder'])){ + + if($session_user_role != 3){ + $_SESSION['alert_type'] = "danger"; + $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED; + header("Location: " . $_SERVER["HTTP_REFERER"]); + exit(); + } + + $folder_id = intval($_GET['delete_folder']); + + mysqli_query($mysqli,"DELETE FROM folders WHERE folder_id = $folder_id AND company_id = $session_company_id"); + + // Move files in deleted folder back to the root folder / + $sql_documents = mysqli_query($mysqli,"SELECT * FROM documents WHERE document_folder_id = $folder_id"); + while($row = mysqli_fetch_array($sql_documents)){ + $document_id = $row['document_id']; + + mysqli_query($mysqli,"UPDATE documents SET document_folder_id = 0 WHERE document_id = $document_id"); + } + + //Logging + mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Folder', log_action = 'Delete', log_description = '$folder_id', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id, company_id = $session_company_id"); + + $_SESSION['alert_message'] = "Folder deleted"; + + header("Location: " . $_SERVER["HTTP_REFERER"]); + +} + if (isset($_POST['add_document_tag'])) { if($session_user_role == 1){