diff --git a/client_documents.php b/client_documents.php index c826c5d63..f7a7e9bf0 100644 --- a/client_documents.php +++ b/client_documents.php @@ -33,17 +33,31 @@ // Set Folder Location Var used when creating folders $folder_location = 0; -$sql = mysqli_query( - $mysqli, - "SELECT SQL_CALC_FOUND_ROWS * FROM documents - LEFT JOIN users ON document_created_by = user_id - WHERE document_client_id = $client_id - AND document_template = 0 - AND document_folder_id = $folder - AND document_archived_at IS NULL - $query_snippet - ORDER BY $sort $order LIMIT $record_from, $record_to" -); +if ($get_folder_id == 0 && $_GET["q"]) { + $sql = mysqli_query( + $mysqli, + "SELECT SQL_CALC_FOUND_ROWS * FROM documents + LEFT JOIN users ON document_created_by = user_id + WHERE document_client_id = $client_id + AND document_template = 0 + + AND document_archived_at IS NULL + $query_snippet + ORDER BY $sort $order LIMIT $record_from, $record_to" + ); +}else{ + $sql = mysqli_query( + $mysqli, + "SELECT SQL_CALC_FOUND_ROWS * FROM documents + LEFT JOIN users ON document_created_by = user_id + WHERE document_client_id = $client_id + AND document_template = 0 + AND document_folder_id = $folder + AND document_archived_at IS NULL + $query_snippet + ORDER BY $sort $order LIMIT $record_from, $record_to" + ); +} $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); diff --git a/client_files.php b/client_files.php index c9ba024bc..f21eca9fa 100644 --- a/client_files.php +++ b/client_files.php @@ -39,16 +39,29 @@ // Set Folder Location Var used when creating folders $folder_location = 1; -$sql = mysqli_query( - $mysqli, - "SELECT SQL_CALC_FOUND_ROWS * FROM files - WHERE file_client_id = $client_id - AND file_folder_id = $folder_id - AND file_archived_at IS NULL - AND (file_name LIKE '%$q%' OR file_ext LIKE '%$q%' OR file_description LIKE '%$q%') - $query_images - ORDER BY $sort $order LIMIT $record_from, $record_to" -); +if ($get_folder_id == 0 && $_GET["q"]) { + $sql = mysqli_query( + $mysqli, + "SELECT SQL_CALC_FOUND_ROWS * FROM files + WHERE file_client_id = $client_id + + AND file_archived_at IS NULL + AND (file_name LIKE '%$q%' OR file_ext LIKE '%$q%' OR file_description LIKE '%$q%') + $query_images + ORDER BY $sort $order LIMIT $record_from, $record_to" + ); +}else{ + $sql = mysqli_query( + $mysqli, + "SELECT SQL_CALC_FOUND_ROWS * FROM files + WHERE file_client_id = $client_id + AND file_folder_id = $folder_id + AND file_archived_at IS NULL + AND (file_name LIKE '%$q%' OR file_ext LIKE '%$q%' OR file_description LIKE '%$q%') + $query_images + ORDER BY $sort $order LIMIT $record_from, $record_to" + ); +} $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));