Skip to content

Commit

Permalink
fix attendance retroactive
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaomlove committed Oct 11, 2023
1 parent a4e0bc6 commit 4f24ba3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
4 changes: 2 additions & 2 deletions app/Repositories/AttendanceRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public function getContinuousDays(Attendance $attendance, $start): int

}

public function retroactive($user, $timestampMs)
public function retroactive($user, $dateStr)
{
if (!$user instanceof User) {
$user = User::query()->findOrFail((int)$user);
Expand All @@ -290,7 +290,7 @@ public function retroactive($user, $timestampMs)
if (!$attendance) {
throw new \LogicException(nexus_trans('attendance.have_not_attendance_yet'));
}
$date = Carbon::createFromTimestampMs($timestampMs);
$date = Carbon::parse($dateStr);
$now = Carbon::now();
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')]));
Expand Down
2 changes: 1 addition & 1 deletion include/constants.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
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('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
Expand Down
2 changes: 1 addition & 1 deletion public/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static function attendanceRetroactive($params)
{
global $CURUSER;
$rep = new \App\Repositories\AttendanceRepository();
return $rep->retroactive($CURUSER['id'], $params['timestamp']);
return $rep->retroactive($CURUSER['id'], $params['date']);
}

public static function getPtGen($params)
Expand Down
12 changes: 4 additions & 8 deletions public/attendance.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,19 @@
eventClick: function(info) {
console.log(info.event);
if (info.event.groupId == 'to_do') {
retroactive(info.event.start)
retroactive(info.event.startStr)
}
}
});
calendar.render();
});
function retroactive(start) {
let year = start.getFullYear()
let month = start.getMonth() + 1
let day = start.getDate()
let date = year + '-' + month + '-' + day
if (!window.confirm(confirmText + date + ' ?')) {
function retroactive(dateStr) {
if (!window.confirm(confirmText + dateStr + ' ?')) {
console.log("cancel")
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);
if (response.ret != 0) {
alert(response.msg)
Expand Down

0 comments on commit 4f24ba3

Please sign in to comment.