NASER refresh page after close task detail modal and redirect to tasks list after create task

This commit is contained in:
Montzar.ah.01
2026-05-03 13:29:25 +00:00
parent f4ce38e560
commit afd07f611a
4 changed files with 57 additions and 38 deletions
+43 -32
View File
@@ -652,50 +652,61 @@ class AttendanceController extends Controller
private function dailyReport($userId, $userName)
{
$tasks = Tasks::with(['duration'])->where('created_by', $userId)->orWhereJsonContains('assignees', $userId)->get();
$tasks = Tasks::with(['duration'])
->where('created_by', $userId)
->orWhereJsonContains('assignees', $userId)
->get();
$todayStart = now()->startOfDay();
// $todayStart = '2026-04-28 00:00:00'; // ابتدای امروز
$message = " *" . Jalalian::now()->format('j F') . "* "
. "\n * _{$userName}_ * ";
$hasAnyWork = false;
$totalWorkTime = 0;
foreach ($tasks as $task) {
switch ($task->priority) {
case 'none':
$message .= "\n⚪";
break;
case 'low':
$message .= "\n🟢";
break;
case 'medium':
$message .= "\n🟡";
break;
case 'high':
$message .= "\n🟠";
break;
case 'urgent':
$message .= "\n🔴";
break;
}
$message .= "$task->title";
$today = now()->format('Y-m-d 00:00:00');
$totalSeconds = 0;
foreach ($task->duration as $item) {
if (($userId == $item->user_id && $item->duration !== null) && $item->start > $today) {
$totalSeconds += CarbonInterval::createFromFormat('H:i:s', $item->duration)->totalSeconds;
if (
$item->user_id == $userId &&
!empty($item->duration) &&
!empty($item->start) &&
Carbon::parse($item->start)->greaterThanOrEqualTo($todayStart)
) {
$totalWorkTime += $totalSeconds += CarbonInterval::createFromFormat('H:i:s', $item->duration)->totalSeconds;
}
}
$task->totalDuration = CarbonInterval::seconds($totalSeconds)->cascade()->format('%H:%I');
$message .= " $task->totalDuration";
}
Http::withoutVerifying()->post('https://tapi.bale.ai/1482838710:sYbLzby0tuLRzHvP4d3LsbcNwg2sjSDLTAU/sendMessage', [
"chat_id" => '985309723',
'text' => $message,
]);
// $this->send_level1_admins($message);
if ($totalSeconds > 0) {
$hasAnyWork = true;
$prioritySymbol = [
'none' => '⚪',
'low' => '🟢',
'medium' => '🟡',
'high' => '🟠',
'urgent' => '🔴',
];
$formattedDuration = CarbonInterval::seconds($totalSeconds)->cascade()->format('%H:%I');
$message .= "\n{$prioritySymbol[$task->priority]} {$task->title} {$formattedDuration}";
}
}
// $message .= "\nمجموع زمان ها: ".CarbonInterval::seconds($totalWorkTime)->cascade()->format('%H:%I');
//dd($message);
if ($hasAnyWork) {
// Http::withoutVerifying()->post('https://tapi.bale.ai/1482838710:sYbLzby0tuLRzHvP4d3LsbcNwg2sjSDLTAU/sendMessage', [
// 'chat_id' => '985309723',
// 'text' => $message,
// ]);
$this->send_admins($message);
}
}
}
//function auto_break($user_id, $force_method = null)
//{
// $user = User::where('user_name', $user_id)->first();