|
1 | 1 | <?php |
2 | 2 |
|
3 | 3 | // Default Column Sort by Filter |
4 | | - $sort = "document_name"; |
| 4 | + $sort = "document_template_name"; |
5 | 5 | $order = "ASC"; |
6 | 6 |
|
7 | 7 | require_once "includes/inc_all_admin.php"; |
8 | 8 |
|
9 | | - // Search query SQL snippet |
10 | | - if (!empty($q)) { |
11 | | - $query_snippet = "AND (MATCH(document_content_raw) AGAINST ('$q') OR document_name LIKE '%$q%')"; |
12 | | - } else { |
13 | | - $query_snippet = ""; // empty |
14 | | - } |
15 | | - |
16 | | - // Rebuild URL |
17 | | - $url_query_strings_sort = http_build_query($get_copy); |
18 | | - |
19 | 9 | $sql = mysqli_query( |
20 | 10 | $mysqli, |
21 | | - "SELECT SQL_CALC_FOUND_ROWS * FROM documents |
22 | | - LEFT JOIN users ON document_created_by = user_id |
23 | | - WHERE document_template = 1 |
24 | | - $query_snippet |
| 11 | + "SELECT SQL_CALC_FOUND_ROWS * FROM document_templates |
| 12 | + LEFT JOIN users ON document_template_created_by = user_id |
| 13 | + WHERE user_name LIKE '%$q%' OR document_template_name LIKE '%$q%' |
25 | 14 | ORDER BY $sort $order LIMIT $record_from, $record_to" |
26 | 15 | ); |
27 | 16 |
|
|
55 | 44 | <thead class="text-dark <?php if ($num_rows[0] == 0) { echo "d-none"; } ?>"> |
56 | 45 | <tr> |
57 | 46 | <th> |
58 | | - <a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=document_name&order=<?php echo $disp; ?>"> |
59 | | - Template Name <?php if ($sort == 'document_name') { echo $order_icon; } ?> |
| 47 | + <a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=document_template_name&order=<?php echo $disp; ?>"> |
| 48 | + Template Name <?php if ($sort == 'document_template_name') { echo $order_icon; } ?> |
60 | 49 | </a> |
61 | 50 | </th> |
62 | 51 | <th> |
63 | | - <a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=document_created_at&order=<?php echo $disp; ?>"> |
64 | | - Created <?php if ($sort == 'document_created_at') { echo $order_icon; } ?> |
| 52 | + <a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=document_template_created_at&order=<?php echo $disp; ?>"> |
| 53 | + Created <?php if ($sort == 'document_template_created_at') { echo $order_icon; } ?> |
65 | 54 | </a> |
66 | 55 | </th> |
67 | 56 | <th> |
68 | | - <a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=document_updated_at&order=<?php echo $disp; ?>"> |
69 | | - Updated <?php if ($sort == 'document_updated_at') { echo $order_icon; } ?> |
| 57 | + <a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=document_template_updated_at&order=<?php echo $disp; ?>"> |
| 58 | + Updated <?php if ($sort == 'document_template_updated_at') { echo $order_icon; } ?> |
70 | 59 | </a> |
71 | 60 | </th> |
72 | 61 | <th class="text-center"> |
|
78 | 67 | <?php |
79 | 68 |
|
80 | 69 | while ($row = mysqli_fetch_array($sql)) { |
81 | | - $document_id = intval($row['document_id']); |
82 | | - $document_name = nullable_htmlentities($row['document_name']); |
83 | | - $document_description = nullable_htmlentities($row['document_description']); |
84 | | - $document_content = nullable_htmlentities($row['document_content']); |
85 | | - $document_created_by_name = nullable_htmlentities($row['user_name']); |
86 | | - $document_created_at = nullable_htmlentities($row['document_created_at']); |
87 | | - $document_updated_at = nullable_htmlentities($row['document_updated_at']); |
88 | | - $document_folder_id = intval($row['document_folder_id']); |
| 70 | + $document_template_id = intval($row['document_template_id']); |
| 71 | + $document_template_name = nullable_htmlentities($row['document_template_name']); |
| 72 | + $document_template_description = nullable_htmlentities($row['document_template_description']); |
| 73 | + $document_template_content = nullable_htmlentities($row['document_template_content']); |
| 74 | + $document_template_created_by_name = nullable_htmlentities($row['user_name']); |
| 75 | + $document_template_created_at = nullable_htmlentities($row['document_template_created_at']); |
| 76 | + $document_template_updated_at = nullable_htmlentities($row['document_template_updated_at']); |
89 | 77 |
|
90 | 78 | ?> |
91 | 79 |
|
92 | 80 | <tr> |
93 | 81 | <td> |
94 | | - <a class="text-bold" href="admin_document_template_details.php?document_id=<?php echo $document_id; ?>"><i class="fas fa-fw fa-file-alt text-dark"></i> <?php echo $document_name; ?></a> |
95 | | - <div class="mt-1 text-secondary"><?php echo $document_description; ?></div> |
| 82 | + <a class="text-bold" href="admin_document_template_details.php?document_template_id=<?php echo $document_template_id; ?>"><i class="fas fa-fw fa-file-alt text-dark"></i> <?php echo $document_template_name; ?></a> |
| 83 | + <div class="mt-1 text-secondary"><?php echo $document_template_description; ?></div> |
96 | 84 | </td> |
97 | 85 | <td> |
98 | | - <?php echo $document_created_at; ?> |
99 | | - <div class="text-secondary"><?php echo $document_created_by_name; ?></div> |
| 86 | + <?php echo $document_template_created_at; ?> |
| 87 | + <div class="text-secondary"><?php echo $document_template_created_by_name; ?></div> |
100 | 88 | </td> |
101 | | - <td><?php echo $document_updated_at; ?></td> |
| 89 | + <td><?php echo $document_template_updated_at; ?></td> |
102 | 90 | <td> |
103 | 91 | <div class="dropdown dropleft text-center"> |
104 | 92 | <button class="btn btn-secondary btn-sm" type="button" data-toggle="dropdown"> |
|
109 | 97 | data-toggle="ajax-modal" |
110 | 98 | data-modal-size="xl" |
111 | 99 | data-ajax-url="ajax/ajax_document_template_edit.php" |
112 | | - data-ajax-id="<?php echo $document_id; ?>" |
| 100 | + data-ajax-id="<?php echo $document_template_id; ?>" |
113 | 101 | > |
114 | 102 | <i class="fas fa-fw fa-edit mr-2"></i>Edit |
115 | 103 | </a> |
116 | 104 | <div class="dropdown-divider"></div> |
117 | | - <a class="dropdown-item text-danger text-bold" href="post.php?delete_document=<?php echo $document_id; ?>"> |
| 105 | + <a class="dropdown-item text-danger text-bold" href="post.php?delete_document_template=<?php echo $document_template_id; ?>"> |
118 | 106 | <i class="fas fa-fw fa-trash mr-2"></i>Delete |
119 | 107 | </a> |
120 | 108 | </div> |
|
0 commit comments