mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 12:07:23 +08:00
fix attendance retroactive
This commit is contained in:
@@ -281,7 +281,7 @@ class AttendanceRepository extends BaseRepository
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function retroactive($user, $timestampMs)
|
public function retroactive($user, $dateStr)
|
||||||
{
|
{
|
||||||
if (!$user instanceof User) {
|
if (!$user instanceof User) {
|
||||||
$user = User::query()->findOrFail((int)$user);
|
$user = User::query()->findOrFail((int)$user);
|
||||||
@@ -290,7 +290,7 @@ class AttendanceRepository extends BaseRepository
|
|||||||
if (!$attendance) {
|
if (!$attendance) {
|
||||||
throw new \LogicException(nexus_trans('attendance.have_not_attendance_yet'));
|
throw new \LogicException(nexus_trans('attendance.have_not_attendance_yet'));
|
||||||
}
|
}
|
||||||
$date = Carbon::createFromTimestampMs($timestampMs);
|
$date = Carbon::parse($dateStr);
|
||||||
$now = Carbon::now();
|
$now = Carbon::now();
|
||||||
if ($date->gte($now) || $now->diffInDays($date) > Attendance::MAX_RETROACTIVE_DAYS) {
|
if ($date->gte($now) || $now->diffInDays($date) > Attendance::MAX_RETROACTIVE_DAYS) {
|
||||||
throw new \LogicException(nexus_trans('attendance.target_date_can_no_be_retroactive', ['date' => $date->format('Y-m-d')]));
|
throw new \LogicException(nexus_trans('attendance.target_date_can_no_be_retroactive', ['date' => $date->format('Y-m-d')]));
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.9');
|
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.9');
|
||||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-09-29');
|
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-10-12');
|
||||||
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
||||||
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
||||||
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ class AjaxInterface{
|
|||||||
{
|
{
|
||||||
global $CURUSER;
|
global $CURUSER;
|
||||||
$rep = new \App\Repositories\AttendanceRepository();
|
$rep = new \App\Repositories\AttendanceRepository();
|
||||||
return $rep->retroactive($CURUSER['id'], $params['timestamp']);
|
return $rep->retroactive($CURUSER['id'], $params['date']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getPtGen($params)
|
public static function getPtGen($params)
|
||||||
|
|||||||
@@ -89,23 +89,19 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
eventClick: function(info) {
|
eventClick: function(info) {
|
||||||
console.log(info.event);
|
console.log(info.event);
|
||||||
if (info.event.groupId == 'to_do') {
|
if (info.event.groupId == 'to_do') {
|
||||||
retroactive(info.event.start)
|
retroactive(info.event.startStr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
calendar.render();
|
calendar.render();
|
||||||
});
|
});
|
||||||
|
|
||||||
function retroactive(start) {
|
function retroactive(dateStr) {
|
||||||
let year = start.getFullYear()
|
if (!window.confirm(confirmText + dateStr + ' ?')) {
|
||||||
let month = start.getMonth() + 1
|
|
||||||
let day = start.getDate()
|
|
||||||
let date = year + '-' + month + '-' + day
|
|
||||||
if (!window.confirm(confirmText + date + ' ?')) {
|
|
||||||
console.log("cancel")
|
console.log("cancel")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
jQuery.post('ajax.php', {params: {timestamp: start.getTime()}, action: 'attendanceRetroactive'}, function (response) {
|
jQuery.post('ajax.php', {params: {date: dateStr}, action: 'attendanceRetroactive'}, function (response) {
|
||||||
console.log(response);
|
console.log(response);
|
||||||
if (response.ret != 0) {
|
if (response.ret != 0) {
|
||||||
alert(response.msg)
|
alert(response.msg)
|
||||||
|
|||||||
Reference in New Issue
Block a user