update crontab send report
This commit is contained in:
		
							parent
							
								
									be1f207886
								
							
						
					
					
						commit
						4ec269cafb
					
				| 
						 | 
					@ -178,31 +178,12 @@ class JiraController extends Controller
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function sendReport()
 | 
					    public function sendReport()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $now = new DateTime('now', new DateTimeZone('Asia/Bangkok'));
 | 
					        $dateFormatted = Carbon::yesterday()->setTimezone(env('TIME_ZONE'))->format('Y-m-d');
 | 
				
			||||||
        $dateFormatted = $now->format('Y-m-d');
 | 
					        // $dateFormatted = Carbon::create(2024, 06, 28)->format('Y-m-d');
 | 
				
			||||||
        $workLogs = $this->jiraService->getAllUserWorkLogs($dateFormatted, $dateFormatted);
 | 
					        $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);
 | 
					        $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));
 | 
					        Mail::to(['luanlt632000@gmail.com', 'admin@apactech.io'])->send(new WorklogReport($tasksByUser));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // return "Email sent successfully!";
 | 
					        // return "Email sent successfully!";
 | 
				
			||||||
| 
						 | 
					@ -223,28 +204,27 @@ class JiraController extends Controller
 | 
				
			||||||
            if (!isset($tasksByUser[$user])) {
 | 
					            if (!isset($tasksByUser[$user])) {
 | 
				
			||||||
                $tasksByUser[$user] = [];
 | 
					                $tasksByUser[$user] = [];
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            $tasksByUser[$user]['user'] = $log['user'];
 | 
				
			||||||
            foreach ($log['information']['issues'] as $issue) {
 | 
					            foreach ($log['information']['issues'] as $issue) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                $today = Carbon::today('Asia/Ho_Chi_Minh');
 | 
					                $today = Carbon::yesterday()->setTimezone(env('TIME_ZONE'))->format('Y-m-d');
 | 
				
			||||||
                // $today = Carbon::create('2024','6','14');
 | 
					                // $today = Carbon::create('2024','6','28');
 | 
				
			||||||
                $filteredWorklogs = [];
 | 
					                $filteredWorklogs = [];
 | 
				
			||||||
 | 
					 | 
				
			||||||
                foreach ($issue['fields']['worklog']['worklogs'] as $worklog) {
 | 
					                foreach ($issue['fields']['worklog']['worklogs'] as $worklog) {
 | 
				
			||||||
                    $started = Carbon::parse($worklog['started']);
 | 
					                    $started = Carbon::parse($worklog['started']);
 | 
				
			||||||
                    if ($started->isSameDay($today) && $worklog['updateAuthor']['displayName'] == $user) {
 | 
					                    if ($started->isSameDay($today) && $worklog['updateAuthor']['displayName'] == $user) {
 | 
				
			||||||
                        $filteredWorklogs[] = $worklog;
 | 
					                        $filteredWorklogs[] = $worklog;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                $tasksByUser[$user][] = [
 | 
					                $tasksByUser[$user]["allStatus"][$issue['fields']['status']['name']][] = [
 | 
				
			||||||
                    'status' => $issue['fields']['status']['name'],
 | 
					 | 
				
			||||||
                    'summary' => $issue['fields']['summary'],
 | 
					                    'summary' => $issue['fields']['summary'],
 | 
				
			||||||
 | 
					                    'project' => $issue['fields']['project'],
 | 
				
			||||||
                    'estimate' => $issue['fields']['timeoriginalestimate'],
 | 
					                    'estimate' => $issue['fields']['timeoriginalestimate'],
 | 
				
			||||||
                    'time_spent' => $issue['fields']['timespent'],
 | 
					                    'time_spent' => $issue['fields']['timespent'],
 | 
				
			||||||
                    'worklogs' => $filteredWorklogs,
 | 
					                    'worklogs' => $filteredWorklogs,
 | 
				
			||||||
                ];
 | 
					                ];
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
        return $tasksByUser;
 | 
					        return $tasksByUser;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,6 +2,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace App\Mail;
 | 
					namespace App\Mail;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use Carbon\Carbon;
 | 
				
			||||||
use Illuminate\Bus\Queueable;
 | 
					use Illuminate\Bus\Queueable;
 | 
				
			||||||
use Illuminate\Contracts\Queue\ShouldQueue;
 | 
					use Illuminate\Contracts\Queue\ShouldQueue;
 | 
				
			||||||
use Illuminate\Mail\Mailable;
 | 
					use Illuminate\Mail\Mailable;
 | 
				
			||||||
| 
						 | 
					@ -23,7 +24,7 @@ class WorklogReport extends Mailable
 | 
				
			||||||
    public function build()
 | 
					    public function build()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return $this->markdown('email.worklog')
 | 
					        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);
 | 
					                    ->with('tasksByUser', $this->tasksByUser);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,29 +6,50 @@
 | 
				
			||||||
@endforeach
 | 
					@endforeach
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
<div id="list-user">
 | 
					<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)}}">
 | 
					<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)
 | 
					@foreach($tasks as $task)
 | 
				
			||||||
<div class="task {{ strtolower(str_replace(' ', '', $task['status'])) }}">
 | 
					<div class="issue">
 | 
				
			||||||
<strong>{{ $task['summary'] }}</strong><br>
 | 
					<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>
 | 
					Estimate: {{ (int)$task['estimate']/60/60 }}h<br>
 | 
				
			||||||
 | 
					<!-- worklogs -->
 | 
				
			||||||
@foreach($task['worklogs'] as $worklog)
 | 
					@foreach($task['worklogs'] as $worklog)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<div class="worklog">
 | 
					<div class="worklog">
 | 
				
			||||||
Time spent: {{ $worklog['timeSpent'] }}<br>
 | 
					Time spent: {{ $worklog['timeSpent'] }}<br>
 | 
				
			||||||
Start date: {{ $worklog['started'] }}<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'] : "" }}
 | 
					{{ 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>
 | 
					</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<br>
 | 
					<br>
 | 
				
			||||||
@endforeach
 | 
					
 | 
				
			||||||
 | 
					@endforeach <!-- worklogs end -->
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
@endforeach
 | 
					@endforeach <!-- task end -->
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
@endforeach
 | 
					
 | 
				
			||||||
 | 
					@endforeach <!-- status end -->
 | 
				
			||||||
 | 
					</div>
 | 
				
			||||||
 | 
					</div>
 | 
				
			||||||
 | 
					@endforeach  <!-- user end -->
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -39,54 +60,76 @@ Thanks,<br>
 | 
				
			||||||
    #main{
 | 
					    #main{
 | 
				
			||||||
        position: relative;
 | 
					        position: relative;
 | 
				
			||||||
        display: flex;
 | 
					        display: flex;
 | 
				
			||||||
        width: 1000px;
 | 
					        width: 1700px;
 | 
				
			||||||
 | 
					        font-size: 13px;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    #list{
 | 
					    #list{
 | 
				
			||||||
        position: sticky;
 | 
					        position: sticky;
 | 
				
			||||||
        top: 10px;
 | 
					        top: 10px;
 | 
				
			||||||
        left: 10px;
 | 
					        left: 10px;
 | 
				
			||||||
        z-index: 1000;
 | 
					        z-index: 1000;
 | 
				
			||||||
        width: 20%;
 | 
					        width: 10%;
 | 
				
			||||||
 | 
					        font-size: 13px;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    #list-user{
 | 
					    #list-user{
 | 
				
			||||||
        z-index: 100;
 | 
					        z-index: 100;
 | 
				
			||||||
        width: 80%;
 | 
					        width: 90%;
 | 
				
			||||||
        max-height: 700px;
 | 
					        max-height: 700px;
 | 
				
			||||||
        overflow: auto;
 | 
					        overflow: auto;
 | 
				
			||||||
 | 
					        font-size: 13px;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    .user{
 | 
					    .user{
 | 
				
			||||||
        border: solid 2px gray;
 | 
					        border: solid 2px gray;
 | 
				
			||||||
        border-radius: 5px;
 | 
					        border-radius: 5px;
 | 
				
			||||||
        padding: 10px;
 | 
					        padding: 10px;
 | 
				
			||||||
        margin-bottom: 10px;
 | 
					        margin-bottom: 10px;
 | 
				
			||||||
 | 
					        font-size: 13px;
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    .task{
 | 
					    .list-task{
 | 
				
			||||||
        margin-bottom: 5px;
 | 
					        display: flex;
 | 
				
			||||||
 | 
					        width: 100%;
 | 
				
			||||||
 | 
					        font-size: 13px;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    .task.done {
 | 
					
 | 
				
			||||||
        background-color: #e0ffe0;
 | 
					    .task{
 | 
				
			||||||
 | 
					        width: 100%;
 | 
				
			||||||
 | 
					        margin-bottom: 5px;
 | 
				
			||||||
        padding: 10px;
 | 
					        padding: 10px;
 | 
				
			||||||
        border-radius: 5px;
 | 
					        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 {
 | 
					    .task.inprogress {
 | 
				
			||||||
        background-color: #fff8e0;
 | 
					        background-color: #fff8e0;
 | 
				
			||||||
        padding: 10px;
 | 
					 | 
				
			||||||
        border-radius: 5px;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    .task.backlog {
 | 
					    .task.backlog {
 | 
				
			||||||
        background-color: #EEEEEE;
 | 
					        background-color: #EEEEEE;
 | 
				
			||||||
        padding: 10px;
 | 
					 | 
				
			||||||
        border-radius: 5px;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    .task.todo {
 | 
					    .task.todo {
 | 
				
			||||||
        background-color: #ADD8E6;
 | 
					        background-color: #c5effd7a;
 | 
				
			||||||
        padding: 10px;
 | 
					    }
 | 
				
			||||||
        border-radius: 5px;
 | 
					
 | 
				
			||||||
 | 
					    .task.closed {
 | 
				
			||||||
 | 
					        background-color: #ecdeff;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    .worklog{
 | 
					    .worklog{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue