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();
+4 -4
View File
@@ -159,9 +159,9 @@ class TaskController extends Controller
} else {
$tasks = Tasks::with(['duration', 'comments.user'])->where('created_by', $user->id)
->orWhereJsonContains('assignees', (string)$user->id)
->orderByRaw('target_date IS NULL') // تسک‌های دارای مهلت اول بیایند (NULL آخر)
->orderBy('target_date', 'asc') // نزدیک‌ترین مهلت اول
->orderBy('updated_at', 'desc') // در صورت یکسان بودن مهلت، آخرین تغییر اول
// ->orderByRaw('target_date IS NULL')
// ->orderBy('target_date', 'asc')
->orderBy('updated_at', 'desc')
->get();
// dd($tasks);
@@ -333,7 +333,7 @@ class TaskController extends Controller
// dd($data, $message, $message_admin);
$this->send_level1_admins($message_admin);
return back()->with('message', [
return redirect('/tasks')->with('message', [
'color' => 'green',
'text' => $message
]);
+1
View File
@@ -1091,6 +1091,7 @@ $state = [
const modal = document.getElementById('taskDetailsModal');
modal.classList.add('hidden');
modal.style.display = 'none';
window.location.reload();
}
// فرمت تاریخ شمسی (ساده)
+9 -2
View File
@@ -122,12 +122,19 @@ Route::post('attendance/enter', function (Request $request) {
Route::post('/1', function (Request $request) {
$data = $request->all();
if(isset($data['callback_query']))
unset($data['callback_query']['message']['text']);
try{
Http::withoutVerifying()->timeout(3)->post('https://tapi.bale.ai/1590900041:Bguk5alo4fv83JmN4kdkOTZ1A4mnvASqVwE/sendMessage', [
Http::withoutVerifying()->timeout(3)->retry(3, 2000)->post('https://tapi.bale.ai/1590900041:Bguk5alo4fv83JmN4kdkOTZ1A4mnvASqVwE/sendMessage', [
"chat_id"=> "985309723",
"text"=> json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT),
]);
}catch(\Exception $e){}
}catch(\Exception $e){
Http::withoutVerifying()->timeout(3)->post('https://tapi.bale.ai/1590900041:Bguk5alo4fv83JmN4kdkOTZ1A4mnvASqVwE/sendMessage', [
"chat_id"=> "985309723",
"text"=> json_encode($e->getMessage(), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT),
]);
}
return true;
});