update send mail warning
This commit is contained in:
		
							parent
							
								
									14e9e17273
								
							
						
					
					
						commit
						0e875d7cf9
					
				| 
						 | 
				
			
			@ -3,7 +3,9 @@
 | 
			
		|||
namespace Modules\Admin\app\Http\Controllers;
 | 
			
		||||
 | 
			
		||||
use App\Http\Controllers\Controller;
 | 
			
		||||
use App\Mail\WarningLongTask;
 | 
			
		||||
use App\Mail\WorklogReport;
 | 
			
		||||
use App\Models\User;
 | 
			
		||||
use App\Traits\HasFilterRequest;
 | 
			
		||||
use App\Traits\HasOrderByRequest;
 | 
			
		||||
use App\Traits\HasSearchRequest;
 | 
			
		||||
| 
						 | 
				
			
			@ -183,8 +185,8 @@ class JiraController extends Controller
 | 
			
		|||
        $workLogs = $this->jiraService->getAllUserWorkLogs($dateFormatted, $dateFormatted);
 | 
			
		||||
 | 
			
		||||
        $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'])->send(new WorklogReport($tasksByUser));
 | 
			
		||||
        Mail::to(['luanlt632000@gmail.com', 'admin@apactech.io'])->send(new WorklogReport($tasksByUser));
 | 
			
		||||
 | 
			
		||||
        // return "Email sent successfully!";
 | 
			
		||||
        return response()->json([
 | 
			
		||||
| 
						 | 
				
			
			@ -248,7 +250,6 @@ class JiraController extends Controller
 | 
			
		|||
        return $tasksByUser;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public function getAllUserDoing(Request $request)
 | 
			
		||||
    {
 | 
			
		||||
        try {
 | 
			
		||||
| 
						 | 
				
			
			@ -271,7 +272,7 @@ class JiraController extends Controller
 | 
			
		|||
            'status' => true
 | 
			
		||||
        ], 200);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    public function getDetailsProjectsById(Request $request)
 | 
			
		||||
    {
 | 
			
		||||
        $id = $request->input('id');
 | 
			
		||||
| 
						 | 
				
			
			@ -303,6 +304,7 @@ class JiraController extends Controller
 | 
			
		|||
            'status' => true
 | 
			
		||||
        ], 200);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getAllIssueByIdSprint(Request $request)
 | 
			
		||||
    {
 | 
			
		||||
        $id = $request->input('id');
 | 
			
		||||
| 
						 | 
				
			
			@ -313,4 +315,30 @@ class JiraController extends Controller
 | 
			
		|||
            'status' => true
 | 
			
		||||
        ], 200);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function sendWarningMailByAllowcation()
 | 
			
		||||
    {
 | 
			
		||||
        $data = $this->jiraService->getAllUserDoing();
 | 
			
		||||
        $user_info = [];
 | 
			
		||||
        $users = User::all();
 | 
			
		||||
        foreach ($data['projects'] as $project) {
 | 
			
		||||
            foreach ($project['users'] as $user) {
 | 
			
		||||
                foreach ($user['issues'] as $issue) {
 | 
			
		||||
                    $targetDate = Carbon::parse($issue['changelog']['histories'][0]['created']); // Target date
 | 
			
		||||
                    $daysRemaining = Carbon::now()->setTimezone(env('TIME_ZONE'))->diffInDays($targetDate);
 | 
			
		||||
                    if ($daysRemaining > 10) {
 | 
			
		||||
                        $issue['daysRemaining'] = $daysRemaining;
 | 
			
		||||
                        $user_info[$user['user']['emailAddress']][] = $issue;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        foreach ($users as $user) {
 | 
			
		||||
            if($user_info[$user->email])
 | 
			
		||||
            {
 | 
			
		||||
                Mail::to([$user->email])->cc(['admin@apactech.io', 'joseph@apactech.io'])->send(new WarningLongTask($user_info[$user->email]));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -220,4 +220,5 @@ Route::group([
 | 
			
		|||
    'prefix' => 'v1/admin/jira',
 | 
			
		||||
], function () {
 | 
			
		||||
    Route::get('/send-worklog-report', [JiraController::class, 'sendReport']);
 | 
			
		||||
    Route::get('/send-warning-mail', [JiraController::class, 'sendWarningMailByAllowcation']);
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,42 @@
 | 
			
		|||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Mail;
 | 
			
		||||
 | 
			
		||||
use Carbon\Carbon;
 | 
			
		||||
use Illuminate\Bus\Queueable;
 | 
			
		||||
use Illuminate\Contracts\Queue\ShouldQueue;
 | 
			
		||||
use Illuminate\Mail\Mailable;
 | 
			
		||||
use Illuminate\Mail\Mailables\Content;
 | 
			
		||||
use Illuminate\Mail\Mailables\Envelope;
 | 
			
		||||
use Illuminate\Queue\SerializesModels;
 | 
			
		||||
 | 
			
		||||
class WarningLongTask extends Mailable
 | 
			
		||||
{
 | 
			
		||||
    
 | 
			
		||||
    use Queueable, SerializesModels;
 | 
			
		||||
 | 
			
		||||
    public $data;
 | 
			
		||||
 | 
			
		||||
   /**
 | 
			
		||||
     * Create a new message instance.
 | 
			
		||||
     */
 | 
			
		||||
    public function __construct($data)
 | 
			
		||||
    {
 | 
			
		||||
        $this->data = $data;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the message envelope.
 | 
			
		||||
     */
 | 
			
		||||
    public function envelope(): Envelope
 | 
			
		||||
    {
 | 
			
		||||
        return new Envelope(
 | 
			
		||||
            subject: '[SYSTEM] - Task are forgotten - '.$this->data[0]['fields']['assignee']['displayName'],
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function build(): self
 | 
			
		||||
    {
 | 
			
		||||
        return $this->view('email.warningLongTask', ['data'=> $this->data]);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -259,7 +259,7 @@ class JiraService
 | 
			
		|||
            foreach ($issues['issues'] as $issue) {
 | 
			
		||||
                $projectName = $issue['fields']['project']['name'];
 | 
			
		||||
                $username = $issue['fields']['assignee']['displayName'];
 | 
			
		||||
 | 
			
		||||
                $issue['fields']['assignee']['emailAddress'] = $user['emailAddress'];
 | 
			
		||||
                if (!isset($groupedIssues[$projectName])) {
 | 
			
		||||
                    $groupedIssues[$projectName] = [];
 | 
			
		||||
                    $groupedIssues[$projectName]['project'] = $issue['fields']['project'];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,129 @@
 | 
			
		|||
<!DOCTYPE html>
 | 
			
		||||
<html lang="en">
 | 
			
		||||
 | 
			
		||||
<head>
 | 
			
		||||
    <meta charset="UTF-8" />
 | 
			
		||||
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
 | 
			
		||||
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
 | 
			
		||||
    <style>
 | 
			
		||||
        body {
 | 
			
		||||
            margin: 0;
 | 
			
		||||
            font-family: "Arial", sans-serif;
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        .container {
 | 
			
		||||
            min-height: 100vh;
 | 
			
		||||
 | 
			
		||||
            display: flex;
 | 
			
		||||
            align-items: center;
 | 
			
		||||
            justify-content: center;
 | 
			
		||||
            background-color: #f7fafc;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        .content {
 | 
			
		||||
            background-color: #fffefe;
 | 
			
		||||
            padding: 2rem 0;
 | 
			
		||||
            border-radius: 0.5rem;
 | 
			
		||||
            width: 100vw;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        .my-0 {
 | 
			
		||||
            margin-bottom: 0;
 | 
			
		||||
            margin-top: 0;
 | 
			
		||||
        }
 | 
			
		||||
    </style>
 | 
			
		||||
    <title>[SYSTEM] - Task are forgotten</title>
 | 
			
		||||
</head>
 | 
			
		||||
 | 
			
		||||
<body>
 | 
			
		||||
 | 
			
		||||
    <body style="
 | 
			
		||||
        font-family: Arial, Helvetica, sans-serif;
 | 
			
		||||
        background-color: #edf2f7;
 | 
			
		||||
    ">
 | 
			
		||||
        <table style="margin: 0 auto">
 | 
			
		||||
            <tr>
 | 
			
		||||
                <td>
 | 
			
		||||
                    <table
 | 
			
		||||
                        style="
 | 
			
		||||
                        margin: 0 auto;
 | 
			
		||||
                        width: 768px;
 | 
			
		||||
                    ">
 | 
			
		||||
                        <tr>
 | 
			
		||||
                            <td align="center" valign="top" style="padding: 36px 24px;">
 | 
			
		||||
                                <a href="{{ config('app.url') }}" target="_blank" style="display: inline-block;">
 | 
			
		||||
                                    <img src="https://apactech.io/wp-content/uploads/2022/12/APAC-TECH_side-e1670975093601-190x78.png"
 | 
			
		||||
                                        alt="Logo" border="0" width="100"
 | 
			
		||||
                                        style="display: block; width: 100px; max-width: 100px; min-width: 48px;">
 | 
			
		||||
                                </a>
 | 
			
		||||
                            </td>
 | 
			
		||||
                        </tr>
 | 
			
		||||
                    </table>
 | 
			
		||||
                </td>
 | 
			
		||||
            </tr>
 | 
			
		||||
            <tr>
 | 
			
		||||
                <td>
 | 
			
		||||
                    <table
 | 
			
		||||
                        style="
 | 
			
		||||
                        margin: 0 auto;
 | 
			
		||||
                        background-color: #ffffff;
 | 
			
		||||
                        width: 768px;
 | 
			
		||||
                        padding: 24px;
 | 
			
		||||
                    ">
 | 
			
		||||
                        <tr>
 | 
			
		||||
                            <td>
 | 
			
		||||
                                <h3 style="color: #222222; margin: 5px 0 0 0; font-weight: bold">
 | 
			
		||||
                                    Hi {{ $data[0]['fields']['assignee']['displayName'] }},
 | 
			
		||||
                                </h3>
 | 
			
		||||
                            </td>
 | 
			
		||||
                        </tr>
 | 
			
		||||
 | 
			
		||||
                        <tr>
 | 
			
		||||
                            <td>
 | 
			
		||||
                                <p style=" white-space:pre-line; margin: 0; margin-bottom: 5px">
 | 
			
		||||
                                    You currently have some tasks that have not been updated for a long time. Please check and update them!
 | 
			
		||||
                                </p>
 | 
			
		||||
                            </td>
 | 
			
		||||
                        </tr>
 | 
			
		||||
 | 
			
		||||
                        <tr>
 | 
			
		||||
                            <td>
 | 
			
		||||
                            @foreach($data as $iss)
 | 
			
		||||
                            <a href="https://apactechvn.atlassian.net/browse/{{$iss['key']}}">{{$iss['fields']['summary']}} - <b>haven't updated in {{$iss['daysRemaining']}} days</b></a><br>
 | 
			
		||||
                            @endforeach
 | 
			
		||||
                            </td>
 | 
			
		||||
                        </tr>
 | 
			
		||||
 | 
			
		||||
                    </table>
 | 
			
		||||
                </td>
 | 
			
		||||
            </tr>
 | 
			
		||||
            <tr>
 | 
			
		||||
                <td>
 | 
			
		||||
                    <table
 | 
			
		||||
                        style="
 | 
			
		||||
                        margin: 0 auto;
 | 
			
		||||
 | 
			
		||||
                        width: 768px;
 | 
			
		||||
                    ">
 | 
			
		||||
                        <tr>
 | 
			
		||||
                            <td>
 | 
			
		||||
                                <h5
 | 
			
		||||
                                    style="
 | 
			
		||||
                                    color: #222222;
 | 
			
		||||
                                    text-align: center;
 | 
			
		||||
                                    padding: 10px 36px;
 | 
			
		||||
                                    margin: 0;
 | 
			
		||||
                                ">
 | 
			
		||||
                                    <p>© 2024 APAC Tech.</p>
 | 
			
		||||
                                </h5>
 | 
			
		||||
                            </td>
 | 
			
		||||
                        </tr>
 | 
			
		||||
                    </table>
 | 
			
		||||
                </td>
 | 
			
		||||
            </tr>
 | 
			
		||||
        </table>
 | 
			
		||||
    </body>
 | 
			
		||||
</body>
 | 
			
		||||
 | 
			
		||||
</html>
 | 
			
		||||
| 
						 | 
				
			
			@ -316,7 +316,7 @@ const Allocation = () => {
 | 
			
		|||
                                          <Box
 | 
			
		||||
                                            className={
 | 
			
		||||
                                              Date.now() - date.getTime() >
 | 
			
		||||
                                              172800000 * 5
 | 
			
		||||
                                              172800000 * 5 // 10 days
 | 
			
		||||
                                                ? classes['blinking-background']
 | 
			
		||||
                                                : ''
 | 
			
		||||
                                            }
 | 
			
		||||
| 
						 | 
				
			
			@ -326,7 +326,7 @@ const Allocation = () => {
 | 
			
		|||
                                              borderRadius: '10px',
 | 
			
		||||
                                              cursor: 'pointer',
 | 
			
		||||
                                              backgroundColor: issStatus
 | 
			
		||||
                                                ? issLastHistory < 172800000
 | 
			
		||||
                                                ? issLastHistory < 172800000 // 2 days
 | 
			
		||||
                                                  ? '#d1f3d1'
 | 
			
		||||
                                                  : '#ffff8a'
 | 
			
		||||
                                                : '',
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue