NASER refresh page after close task detail modal and redirect to tasks list after create task
This commit is contained in:
@@ -652,50 +652,61 @@ class AttendanceController extends Controller
|
|||||||
|
|
||||||
private function dailyReport($userId, $userName)
|
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') . "* "
|
$message = " *" . Jalalian::now()->format('j F') . "* "
|
||||||
. "\n * _{$userName}_ * ";
|
. "\n * _{$userName}_ * ";
|
||||||
|
|
||||||
|
$hasAnyWork = false;
|
||||||
|
$totalWorkTime = 0;
|
||||||
foreach ($tasks as $task) {
|
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;
|
$totalSeconds = 0;
|
||||||
|
|
||||||
foreach ($task->duration as $item) {
|
foreach ($task->duration as $item) {
|
||||||
if (($userId == $item->user_id && $item->duration !== null) && $item->start > $today) {
|
if (
|
||||||
$totalSeconds += CarbonInterval::createFromFormat('H:i:s', $item->duration)->totalSeconds;
|
$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)
|
//function auto_break($user_id, $force_method = null)
|
||||||
//{
|
//{
|
||||||
// $user = User::where('user_name', $user_id)->first();
|
// $user = User::where('user_name', $user_id)->first();
|
||||||
|
|||||||
@@ -159,9 +159,9 @@ class TaskController extends Controller
|
|||||||
} else {
|
} else {
|
||||||
$tasks = Tasks::with(['duration', 'comments.user'])->where('created_by', $user->id)
|
$tasks = Tasks::with(['duration', 'comments.user'])->where('created_by', $user->id)
|
||||||
->orWhereJsonContains('assignees', (string)$user->id)
|
->orWhereJsonContains('assignees', (string)$user->id)
|
||||||
->orderByRaw('target_date IS NULL') // تسکهای دارای مهلت اول بیایند (NULL آخر)
|
// ->orderByRaw('target_date IS NULL')
|
||||||
->orderBy('target_date', 'asc') // نزدیکترین مهلت اول
|
// ->orderBy('target_date', 'asc')
|
||||||
->orderBy('updated_at', 'desc') // در صورت یکسان بودن مهلت، آخرین تغییر اول
|
->orderBy('updated_at', 'desc')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
// dd($tasks);
|
// dd($tasks);
|
||||||
@@ -333,7 +333,7 @@ class TaskController extends Controller
|
|||||||
// dd($data, $message, $message_admin);
|
// dd($data, $message, $message_admin);
|
||||||
$this->send_level1_admins($message_admin);
|
$this->send_level1_admins($message_admin);
|
||||||
|
|
||||||
return back()->with('message', [
|
return redirect('/tasks')->with('message', [
|
||||||
'color' => 'green',
|
'color' => 'green',
|
||||||
'text' => $message
|
'text' => $message
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -1091,6 +1091,7 @@ $state = [
|
|||||||
const modal = document.getElementById('taskDetailsModal');
|
const modal = document.getElementById('taskDetailsModal');
|
||||||
modal.classList.add('hidden');
|
modal.classList.add('hidden');
|
||||||
modal.style.display = 'none';
|
modal.style.display = 'none';
|
||||||
|
window.location.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
// فرمت تاریخ شمسی (ساده)
|
// فرمت تاریخ شمسی (ساده)
|
||||||
|
|||||||
+9
-2
@@ -122,12 +122,19 @@ Route::post('attendance/enter', function (Request $request) {
|
|||||||
|
|
||||||
Route::post('/1', function (Request $request) {
|
Route::post('/1', function (Request $request) {
|
||||||
$data = $request->all();
|
$data = $request->all();
|
||||||
|
if(isset($data['callback_query']))
|
||||||
|
unset($data['callback_query']['message']['text']);
|
||||||
try{
|
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",
|
"chat_id"=> "985309723",
|
||||||
"text"=> json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT),
|
"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;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user