diff --git a/.vscode/ftp-kr.sync.cache.json b/.vscode/ftp-kr.sync.cache.json index c7b22bc..1c0938f 100644 --- a/.vscode/ftp-kr.sync.cache.json +++ b/.vscode/ftp-kr.sync.cache.json @@ -89,8 +89,8 @@ }, "class.Projects.php": { "type": "-", - "size": 9777, - "lmtime": 0, + "size": 9521, + "lmtime": 1764104901603, "modified": false }, "class.Site.php": { @@ -101,8 +101,8 @@ }, "class.Tasks.php": { "type": "-", - "size": 16529, - "lmtime": 1745269305993, + "size": 17944, + "lmtime": 1764184406249, "modified": false }, "class.Users.php": { @@ -151,8 +151,8 @@ }, "class.Tasks.php": { "type": "-", - "size": 20898, - "lmtime": 1745876411486, + "size": 21487, + "lmtime": 1764109249950, "modified": false }, "class.Users.php": { @@ -203,20 +203,20 @@ "layout": { "style.css": { "type": "-", - "size": 22151, - "lmtime": 1757277842593, + "size": 22678, + "lmtime": 1764183540355, "modified": false }, "style.css.map": { "type": "-", - "size": 39717, - "lmtime": 1757277842593, + "size": 40575, + "lmtime": 1764183540367, "modified": false }, "style.scss": { "type": "-", - "size": 27628, - "lmtime": 1757277842454, + "size": 28194, + "lmtime": 1764183540380, "modified": false } }, @@ -416,7 +416,62 @@ "cron": {}, "finances": {}, "html": {}, - "projects": {}, + "projects": { + "closed-tasks.php": { + "type": "-", + "size": 5365, + "lmtime": 0, + "modified": false + }, + "inprogress-tasks.php": { + "type": "-", + "size": 6860, + "lmtime": 0, + "modified": false + }, + "main_view.php": { + "type": "-", + "size": 2500, + "lmtime": 0, + "modified": false + }, + "project_edit.php": { + "type": "-", + "size": 2429, + "lmtime": 0, + "modified": false + }, + "task-details.php": { + "type": "-", + "size": 5602, + "lmtime": 0, + "modified": false + }, + "task-edit.php": { + "type": "-", + "size": 7707, + "lmtime": 0, + "modified": false + }, + "tasks.php": { + "type": "-", + "size": 27718, + "lmtime": 1764104901602, + "modified": false + }, + "toreview-tasks.php": { + "type": "-", + "size": 6399, + "lmtime": 0, + "modified": false + }, + "unassigned-tasks.php": { + "type": "-", + "size": 6002, + "lmtime": 0, + "modified": false + } + }, "site": { "layout-cron.php": { "type": "-", @@ -452,8 +507,8 @@ }, "main_view.php": { "type": "-", - "size": 32125, - "lmtime": 1754600819046, + "size": 34412, + "lmtime": 1764112957755, "modified": false }, "task_edit.php": { @@ -464,8 +519,8 @@ }, "task_popup.php": { "type": "-", - "size": 6272, - "lmtime": 1743622901914, + "size": 7349, + "lmtime": 1764108641205, "modified": false }, "task_single.php": { diff --git a/autoload/controls/class.Tasks.php b/autoload/controls/class.Tasks.php index 1de4321..36ca35b 100644 --- a/autoload/controls/class.Tasks.php +++ b/autoload/controls/class.Tasks.php @@ -533,4 +533,15 @@ class Tasks echo json_encode( $response ); exit; } + + static function filtr_get() { + $filtr = \factory\Tasks::filtr_details( \S::get( 'filtr_id' ) ); + + echo json_encode( [ + 'status' => 'success', + 'projects' => $filtr['projects'], + 'users' => $filtr['users'] + ] ); + exit; + } } \ No newline at end of file diff --git a/autoload/factory/class.Projects.php b/autoload/factory/class.Projects.php index ae309c0..a227332 100644 --- a/autoload/factory/class.Projects.php +++ b/autoload/factory/class.Projects.php @@ -385,7 +385,7 @@ class Projects . 'tasks AS t ' . 'LEFT JOIN task_user AS tu ON tu.task_id = t.id ' . 'WHERE ' - . '( user_id = ' . (int)$user_id . ' OR created_by = ' . (int)$user_id . ' ) AND project_id = ' . $row['id'] . ' AND ( status = 0 OR status = 1 ) AND deleted = 0 AND ( date_complete IS NULL OR date_complete > \'' . date( 'Y-m-d', strtotime( "-21 days") ) . '\' ) ' + . '( user_id = ' . (int)$user_id . ' OR created_by = ' . (int)$user_id . ' ) AND project_id = ' . $row['id'] . ' AND ( status = 0 OR status = 5 ) AND deleted = 0 AND ( date_complete IS NULL OR date_complete > \'' . date( 'Y-m-d', strtotime( "-21 days") ) . '\' ) ' . 'GROUP BY t.id' ) -> fetchAll( \PDO::FETCH_ASSOC ); $row['total_tasks'] = count( $count ); diff --git a/autoload/factory/class.Tasks.php b/autoload/factory/class.Tasks.php index d98d3f1..8ad81b2 100644 --- a/autoload/factory/class.Tasks.php +++ b/autoload/factory/class.Tasks.php @@ -6,6 +6,11 @@ class Tasks public static $statuses = [ 0 => 'nowe', 3 => 'do rozliczenia', 5 => 'do zrobienia', 1 => 'do sprawdzenia', 2 => 'zamknięte' ]; public static $priorities = [ 0 => 'niski', 1 => 'normalny', 2 => 'wysoki', 3 => 'pilny' ]; + static public function filtr_details( $filtr_id ) { + global $mdb; + return $mdb -> get( 'tasks_filtrs', '*', [ 'id' => $filtr_id ] ); + } + static public function get_priorities() { diff --git a/templates/tasks/main_view.php b/templates/tasks/main_view.php index 079a827..4b2ac18 100644 --- a/templates/tasks/main_view.php +++ b/templates/tasks/main_view.php @@ -3,7 +3,7 @@
@@ -832,50 +832,68 @@ e.preventDefault(); isProgrammaticUpdate = true; - var projects = $( this ).find( 'option:selected' ).attr( 'projects' ); - var users = $( this ).find( 'option:selected' ).attr( 'users' ); - // parsowanie wejść (string "1,2,3" -> ['1','2','3']) - const projectsArr = String(projects || '') - .split(',') - .map(s => s.trim()) - .filter(Boolean); + var filtr_id = $(this).val(); - const usersArr = String(users || '') - .split(',') - .map(s => s.trim()) - .filter(Boolean); + // Pobierz dane filtra przez AJAX + $.ajax({ + type: 'POST', + cache: false, + url: '/tasks/filtr_get/', + data: { + filtr_id: filtr_id + }, + success: function(response) { + var data = jQuery.parseJSON(response); - // Selektor dla checkboxów w filtrze - const $projectInputs = $('.tasks_main_view input[name="projects"].g-checkbox'); - const $userInputs = $('.tasks_main_view input[name="users"].g-checkbox'); + if (data.status == 'success') { + var projects = data.projects || ''; + var users = data.users || ''; - // najpierw czyścimy wszystkie - $projectInputs.each(function() { - $(this).iCheck('uncheck'); - }); - $userInputs.each(function() { - $(this).iCheck('uncheck'); - }); + // parsowanie wejść (string "1,2,3" -> ['1','2','3']) + const projectsArr = String(projects) + .split(',') + .map(s => s.trim()) + .filter(Boolean); - // ustawiamy zaznaczenia - $projectInputs.each(function () { - const val = String($(this).val()).trim(); - if (projectsArr.includes(val)) { - $(this).iCheck('check'); + const usersArr = String(users) + .split(',') + .map(s => s.trim()) + .filter(Boolean); + + // Selektor dla checkboxów w filtrze + const $projectInputs = $('.tasks_main_view input[name="projects"].g-checkbox'); + const $userInputs = $('.tasks_main_view input[name="users"].g-checkbox'); + + // najpierw czyścimy wszystkie + $projectInputs.each(function() { + $(this).iCheck('uncheck'); + }); + $userInputs.each(function() { + $(this).iCheck('uncheck'); + }); + + // ustawiamy zaznaczenia + $projectInputs.each(function () { + const val = String($(this).val()).trim(); + if (projectsArr.includes(val)) { + $(this).iCheck('check'); + } + }); + + $userInputs.each(function () { + const val = String($(this).val()).trim(); + if (usersArr.includes(val)) { + $(this).iCheck('check'); + } + }); + + isProgrammaticUpdate = false; + // wywołuj z tablicami, nie ze stringami + reload_tasks(projectsArr, usersArr); + } } }); - $userInputs.each(function () { - const val = String($(this).val()).trim(); - if (usersArr.includes(val)) { - $(this).iCheck('check'); - } - }); - - isProgrammaticUpdate = false; - // wywołuj z tablicami, nie ze stringami - reload_tasks(projectsArr, usersArr); - }); $( 'body' ).on( 'click', '.task_popup .task-delete', function(e) {