update crontab send report

This commit is contained in:
JOSEPH LE 2024-07-01 15:35:26 +07:00
parent be1f207886
commit 4ec269cafb
3 changed files with 75 additions and 51 deletions

View File

@ -178,31 +178,12 @@ class JiraController extends Controller
public function sendReport()
{
$now = new DateTime('now', new DateTimeZone('Asia/Bangkok'));
$dateFormatted = $now->format('Y-m-d');
$dateFormatted = Carbon::yesterday()->setTimezone(env('TIME_ZONE'))->format('Y-m-d');
// $dateFormatted = Carbon::create(2024, 06, 28)->format('Y-m-d');
$workLogs = $this->jiraService->getAllUserWorkLogs($dateFormatted, $dateFormatted);
// $tasks = [
// [
// 'status' => 'Done',
// 'summary' => '[LT-37] TEST TỔNG THỂ & BUILD PRODUCTION GD 1',
// 'estimate' => '8H',
// 'total_time_spent' => '8.5H',
// 'time_spent' => '2H',
// 'start_date' => '00:30 2024/05/28',
// 'comment' => 'Check on stage'
// ],
// [
// 'status' => 'In Progress',
// 'summary' => '[IPSPro-826] TEST TASK ERP',
// 'estimate' => '0H',
// 'total_time_spent' => '13H',
// 'time_spent' => '1H',
// 'start_date' => '03:30 2024/05/28',
// 'comment' => 'check ERP update Incoming & PO add SN'
// ]
// ];
$tasksByUser = $this->formatWorkLogsByUser($workLogs);
// Mail::to(['luanlt632000@gmail.com'])->send(new WorklogReport($tasksByUser));
Mail::to(['luanlt632000@gmail.com', 'admin@apactech.io'])->send(new WorklogReport($tasksByUser));
// return "Email sent successfully!";
@ -223,28 +204,27 @@ class JiraController extends Controller
if (!isset($tasksByUser[$user])) {
$tasksByUser[$user] = [];
}
$tasksByUser[$user]['user'] = $log['user'];
foreach ($log['information']['issues'] as $issue) {
$today = Carbon::today('Asia/Ho_Chi_Minh');
// $today = Carbon::create('2024','6','14');
$today = Carbon::yesterday()->setTimezone(env('TIME_ZONE'))->format('Y-m-d');
// $today = Carbon::create('2024','6','28');
$filteredWorklogs = [];
foreach ($issue['fields']['worklog']['worklogs'] as $worklog) {
$started = Carbon::parse($worklog['started']);
if ($started->isSameDay($today) && $worklog['updateAuthor']['displayName'] == $user) {
$filteredWorklogs[] = $worklog;
}
}
$tasksByUser[$user][] = [
'status' => $issue['fields']['status']['name'],
$tasksByUser[$user]["allStatus"][$issue['fields']['status']['name']][] = [
'summary' => $issue['fields']['summary'],
'project' => $issue['fields']['project'],
'estimate' => $issue['fields']['timeoriginalestimate'],
'time_spent' => $issue['fields']['timespent'],
'worklogs' => $filteredWorklogs,
];
}
}
return $tasksByUser;
}
}

View File

@ -2,6 +2,7 @@
namespace App\Mail;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
@ -23,7 +24,7 @@ class WorklogReport extends Mailable
public function build()
{
return $this->markdown('email.worklog')
->subject('Worklog Report')
->subject('[SYSTEM] Daily Report - '.Carbon::yesterday()->setTimezone(env('TIME_ZONE'))->format('Y/m/d'))
->with('tasksByUser', $this->tasksByUser);
}
}

View File

@ -6,29 +6,50 @@
@endforeach
</div>
<div id="list-user">
<strong>Worklog Report</strong>
<!-- <strong>Worklog Report</strong> -->
<!-- user -->
@foreach($tasksByUser as $user => $data)
@foreach($tasksByUser as $user => $tasks)
<div class="user" id="{{str_replace(' ', '', $user)}}">
<strong style="margin-bottom: 15px;">{{ $user }}</strong>
<div style="margin-bottom: 15px; display: flex; align-items: center;">
<img src="{{ $data['user']['avatarUrls']['24x24'] }}" style="margin-right: 5px; width: 30px; height: 30px; border-radius: 50%;"/>
<strong>{{ $user }}</strong>
</div>
<div class="list-task">
<!-- status -->
@foreach($data['allStatus'] as $status => $tasks)
<div class="task {{ strtolower(str_replace(' ', '', $status)) }}">
{{ $status }}<br>
<!-- task -->
@foreach($tasks as $task)
<div class="task {{ strtolower(str_replace(' ', '', $task['status'])) }}">
<div class="issue">
<strong>{{ $task['summary'] }}</strong><br>
Status: {{ $task['status'] }}<br>
<div style="display: flex; align-items: center;">
<img src="{{ $task['project']['avatarUrls']['24x24'] }}" style="margin-right: 5px; width: 15px; height: 15px; border-radius: 50%;"/>
<span>Project: {{ $task['project']['name'] }}</span>
</div>
Estimate: {{ (int)$task['estimate']/60/60 }}h<br>
<!-- worklogs -->
@foreach($task['worklogs'] as $worklog)
<div class="worklog">
Time spent: {{ $worklog['timeSpent'] }}<br>
Start date: {{ $worklog['started'] }}<br>
{{ isset($worklog['comment']) && isset($worklog['comment']['content'][0]['content'][0])&& isset($worklog['comment']['content'][0]['content'][0]['text']) ? 'Comment: ' . $worklog['comment']['content'][0]['content'][0]['text'] : "" }}
</div>
<br>
@endforeach
@endforeach <!-- worklogs end -->
</div>
@endforeach
@endforeach <!-- task end -->
</div>
@endforeach
@endforeach <!-- status end -->
</div>
</div>
@endforeach <!-- user end -->
</div>
</div>
@ -39,54 +60,76 @@ Thanks,<br>
#main{
position: relative;
display: flex;
width: 1000px;
width: 1700px;
font-size: 13px;
}
#list{
position: sticky;
top: 10px;
left: 10px;
z-index: 1000;
width: 20%;
width: 10%;
font-size: 13px;
}
#list-user{
z-index: 100;
width: 80%;
width: 90%;
max-height: 700px;
overflow: auto;
font-size: 13px;
}
.user{
border: solid 2px gray;
border-radius: 5px;
padding: 10px;
margin-bottom: 10px;
font-size: 13px;
}
.task{
margin-bottom: 5px;
.list-task{
display: flex;
width: 100%;
font-size: 13px;
}
.task.done {
background-color: #e0ffe0;
.task{
width: 100%;
margin-bottom: 5px;
padding: 10px;
border-radius: 5px;
border: solid 1px gray;
margin-right: 5px;
font-size: 13px;
}
.issue{
margin-bottom: 5px;
padding: 10px;
border-radius: 5px;
border: solid 2px;
background-color: white;
font-size: 13px;
}
.task.done {
background-color: #e0ffe0;
}
.task.inprogress {
background-color: #fff8e0;
padding: 10px;
border-radius: 5px;
}
.task.backlog {
background-color: #EEEEEE;
padding: 10px;
border-radius: 5px;
}
.task.todo {
background-color: #ADD8E6;
padding: 10px;
border-radius: 5px;
background-color: #c5effd7a;
}
.task.closed {
background-color: #ecdeff;
}
.worklog{