diff --git a/.idea/leantime-oss.iml b/.idea/leantime-oss.iml
index 7c0ff9f072..fc8d27cf07 100644
--- a/.idea/leantime-oss.iml
+++ b/.idea/leantime-oss.iml
@@ -124,4 +124,4 @@
-
\ No newline at end of file
+
diff --git a/app/Domain/Timesheets/Controllers/ShowMyList.php b/app/Domain/Timesheets/Controllers/ShowMyList.php
index a882c7f8fc..5a7ac34be1 100644
--- a/app/Domain/Timesheets/Controllers/ShowMyList.php
+++ b/app/Domain/Timesheets/Controllers/ShowMyList.php
@@ -6,6 +6,8 @@
use Leantime\Core\Controller\Controller;
use Leantime\Domain\Auth\Models\Roles;
use Leantime\Domain\Auth\Services\Auth;
+use Leantime\Domain\Clients\Services\Clients as ClientService;
+use Leantime\Domain\Projects\Services\Projects as ProjectService;
use Leantime\Domain\Timesheets\Services\Timesheets as TimesheetService;
use Symfony\Component\HttpFoundation\Response;
@@ -13,9 +15,15 @@ class ShowMyList extends Controller
{
private TimesheetService $timesheetService;
- public function init(TimesheetService $timesheetService): void
+ private ProjectService $projectService;
+
+ private ClientService $clientService;
+
+ public function init(TimesheetService $timesheetService, ProjectService $projectService, ClientService $clientService): void
{
$this->timesheetService = $timesheetService;
+ $this->projectService = $projectService;
+ $this->clientService = $clientService;
session(['lastPage' => BASE_URL.'/timesheets/showMyList']);
}
@@ -31,15 +39,38 @@ public function run(): Response
$kind = 'all';
if (! empty($_POST['kind'])) {
- $kind = ($_POST['kind']);
+ $kind = (string) $_POST['kind'];
}
- // Use UTC here as all data stored in the database should be UTC (start in user's timezone and convert to UTC).
- // The front end javascript is hardcode to start the week on mondays, so we use that here too.
+ $projectId = -1;
+ if (isset($_POST['projectId']) && $_POST['projectId'] !== '' && $_POST['projectId'] !== 'all') {
+ $projectId = (int) $_POST['projectId'];
+ }
- // Get start of the week in current users timezone and then switch to UTC
- $dateFrom = dtHelper()->userNow()->startOfWeek(CarbonInterface::MONDAY)->setToDbTimezone();
- $dateTo = dtHelper()->userNow()->endOfWeek()->setToDbTimezone();
+ $clientId = -1;
+ if (isset($_POST['clientId']) && $_POST['clientId'] !== '' && $_POST['clientId'] !== '-1') {
+ $clientId = (int) $_POST['clientId'];
+ }
+
+ $invEmplCheck = '-1';
+ if (isset($_POST['invEmpl']) && $_POST['invEmpl'] === '1') {
+ $invEmplCheck = '1';
+ }
+
+ $invCompCheck = '0';
+ if (isset($_POST['invComp'])) {
+ $invCompCheck = $_POST['invComp'] === 'on' || $_POST['invComp'] === '1' ? '1' : '0';
+ }
+
+ $paidCheck = '0';
+ if (isset($_POST['paid'])) {
+ $paidCheck = ($_POST['paid'] === 'on' || $_POST['paid'] === '1') ? '1' : '0';
+ }
+
+ // Use UTC here as all data stored in the database should be UTC (start in user's timezone and convert to UTC).
+ // Default view: This Month (start and end of current month in user's timezone).
+ $dateFrom = dtHelper()->userNow()->startOfMonth()->setToDbTimezone();
+ $dateTo = dtHelper()->userNow()->endOfMonth()->setToDbTimezone();
if (! empty($_POST['dateFrom'])) {
$dateFrom = dtHelper()->parseUserDateTime($_POST['dateFrom'])->setToDbTimezone();
@@ -49,19 +80,36 @@ public function run(): Response
$dateTo = dtHelper()->parseUserDateTime($_POST['dateTo'])->setToDbTimezone();
}
+ $userId = session('userdata.id');
+ $allProjects = $this->projectService->getProjectsUserHasAccessTo($userId);
+ if (! is_array($allProjects)) {
+ $allProjects = [];
+ }
+
+ $allClients = $this->clientService->getAll();
+
$this->tpl->assign('dateFrom', $dateFrom);
$this->tpl->assign('dateTo', $dateTo);
$this->tpl->assign('actKind', $kind);
+ $this->tpl->assign('projectFilter', $projectId);
+ $this->tpl->assign('allProjects', $allProjects);
+ $this->tpl->assign('clientFilter', $clientId);
+ $this->tpl->assign('allClients', $allClients);
+ $this->tpl->assign('invEmpl', $invEmplCheck);
+ $this->tpl->assign('invComp', $invCompCheck);
+ $this->tpl->assign('paid', $paidCheck);
$this->tpl->assign('kind', $this->timesheetService->getLoggableHourTypes());
$this->tpl->assign('allTimesheets', $this->timesheetService->getAll(
dateFrom: $dateFrom,
dateTo: $dateTo,
- projectId: -1,
+ projectId: $projectId,
kind: $kind,
- userId: session('userdata.id'),
- invEmpl: -1,
- invComp: -1,
- paid: -1
+ userId: $userId,
+ invEmpl: $invEmplCheck,
+ invComp: $invCompCheck,
+ paid: $paidCheck,
+ ticketFilter: '-1',
+ clientId: (string) $clientId
));
// Pass user's hours format preference to template for CSV export
diff --git a/app/Domain/Timesheets/Js/timesheetsController.js b/app/Domain/Timesheets/Js/timesheetsController.js
index 6141ff8f2e..d4e4a16682 100644
--- a/app/Domain/Timesheets/Js/timesheetsController.js
+++ b/app/Domain/Timesheets/Js/timesheetsController.js
@@ -105,74 +105,37 @@ leantime.timesheetsController = (function () {
});
};
-var isReady = false;
-var pendingClick = null;
-
-document.addEventListener('click', function(e) {
- var target = e.target.closest('.editTimeModal');
- if (target && !isReady) {
- e.preventDefault();
- e.stopPropagation();
-
- target.style.opacity = '0.5';
- target.style.cursor = 'wait';
-
- pendingClick = target;
- }
-}, true);
-
-function initWhenReady() {
-
- if (typeof jQuery.fn.nyroModal === 'undefined') {
- setTimeout(initWhenReady, 100);
- return;
- }
-
- initEditTimeModal();
- isReady = true;
-
- if (pendingClick) {
- var $pending = jQuery(pendingClick);
- pendingClick.style.opacity = '';
- pendingClick.style.cursor = '';
- $pending.trigger('click');
- pendingClick = null;
- }
-}
-
-var initEditTimeModal = function () {
- var canvasoptions = {
- sizes: {
- minW: 700,
- maxW: 1000,
- minH: 1000,
- },
- resizable: false,
- autoSizable: false,
- callbacks: {
- beforeShowCont: function () {
- jQuery(".showDialogOnLoad").show();
-
- if (closeModal === true) {
- closeModal = false;
+ var initEditTimeModal = function () {
+ var canvasoptions = {
+ sizes: {
+ minW: 700,
+ maxW: 1000,
+ minH: 1000,
+ },
+ resizable: false,
+ autoSizable: false,
+ callbacks: {
+ beforeShowCont: function () {
+ jQuery(".showDialogOnLoad").show();
+
+ if (closeModal === true) {
+ closeModal = false;
+ location.reload();
+ }
+ },
+ beforeClose: function () {
location.reload();
}
},
- beforeClose: function () {
- location.reload();
- }
- },
- titleFromIframe: true
- };
+ titleFromIframe: true
+ };
- jQuery(document).on('click', '.editTimeModal', function (e) {
- if (!isReady) return;
- e.preventDefault();
- jQuery(this).nyroModal(canvasoptions);
- });
-};
+ jQuery(document).on('click', '.editTimeModal', function (e) {
+ e.preventDefault();
+ jQuery(this).nyroModal(canvasoptions);
+ });
+ };
-initWhenReady();
var formatHours = function (hours) {
var hoursFormat = jQuery('.timesheetTable').data('hours-format') ||
diff --git a/app/Domain/Timesheets/Templates/showMy.tpl.php b/app/Domain/Timesheets/Templates/showMy.tpl.php
index e83ec42234..5a8dca4163 100644
--- a/app/Domain/Timesheets/Templates/showMy.tpl.php
+++ b/app/Domain/Timesheets/Templates/showMy.tpl.php
@@ -198,9 +198,6 @@
jQuery("#finalSum").text(roundedSum);
});
-
- leantime.timesheetsController.initEditTimeModal();
-
});
diff --git a/app/Domain/Timesheets/Templates/showMyList.tpl.php b/app/Domain/Timesheets/Templates/showMyList.tpl.php
index 83d9ec7f2c..f768a9d635 100644
--- a/app/Domain/Timesheets/Templates/showMyList.tpl.php
+++ b/app/Domain/Timesheets/Templates/showMyList.tpl.php
@@ -8,7 +8,43 @@
}
$hoursFormat = session('usersettings.hours_format', 'decimal');
?>
+
+
+
+
+