Commit 46ded914 by Azhan Hannan

Project Manager reject -> send notification to staff

parent cc004fe3
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class PmRejectProject extends Mailable
{
use Queueable, SerializesModels;
public $data_email;
public $data_timesheet;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($data_email, $data_timesheet)
{
$this->data_email = $data_email;
$this->data_timesheet = $data_timesheet;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->subject($this->data_email['subject'])
->from($this->data_email['sender_name'])
->markdown('mail.content.PmRejectProject');
}
}
...@@ -29,6 +29,7 @@ use Redirect; ...@@ -29,6 +29,7 @@ use Redirect;
use App\Mail\StatusAccept; use App\Mail\StatusAccept;
use App\Mail\StatusReject; use App\Mail\StatusReject;
use App\Mail\EditProject; use App\Mail\EditProject;
use App\Mail\PmRejectProject;
use Mail; use Mail;
use Curl; use Curl;
use Auth; use Auth;
...@@ -941,13 +942,16 @@ class DashboardController extends Controller ...@@ -941,13 +942,16 @@ class DashboardController extends Controller
return redirect()->route('timesheet::dashboard.projectaction', compact('profile', 'pm', 'tpid', 'year', 'month', 'phase'))->with('warning', 'You wanted to rejected the project submission. Kindly give remarks for team references. Thank you.'); return redirect()->route('timesheet::dashboard.projectaction', compact('profile', 'pm', 'tpid', 'year', 'month', 'phase'))->with('warning', 'You wanted to rejected the project submission. Kindly give remarks for team references. Thank you.');
} }
// dd($request);
$pm = Users::find(Auth::id()); $pm = Users::find(Auth::id());
$today = Carbon::today()->toDateString(); $today = Carbon::today()->toDateString();
$profile = Tproject::where('id', $request->tpid) $profile = Tproject::where('id', $request->tpid)
->with('team')
->with('pm')
->with('bod')
->with('project')
->first(); ->first();
// dd($profile); // dd($profile);
...@@ -987,9 +991,7 @@ class DashboardController extends Controller ...@@ -987,9 +991,7 @@ class DashboardController extends Controller
// if(data_get($request,'page') == 1){ // if(data_get($request,'page') == 1){
return redirect()->route('timesheet::dashboard.index')->withSuccess('Staff project has been verified.'); return redirect()->route('timesheet::dashboard.index')->withSuccess('Staff project has been verified.');
// } // }
// return redirect()->route('timesheet::dashboard.projectVerify', compact('month', 'phase'))->withSuccess('Staff project has been verified.'); // return redirect()->route('timesheet::dashboard.projectVerify', compact('month', 'phase'))->withSuccess('Staff project has been verified.');
} else { } else {
$profile->tp_timesheet_sts = 6; $profile->tp_timesheet_sts = 6;
...@@ -998,6 +1000,52 @@ class DashboardController extends Controller ...@@ -998,6 +1000,52 @@ class DashboardController extends Controller
$profile->verifier_remark = data_get($request,'remarks'); $profile->verifier_remark = data_get($request,'remarks');
$profile->save(); $profile->save();
// dd($profile->);
// email start
if (env('EMAIL_ENV') == 'local')
{
$mailTo = '143hannan@gmail.com';
}
elseif (env('EMAIL_ENV') == 'DEVELOPMENT')
{
$mailTo = '3fetimesheet@gmail.com';
}
elseif (env('EMAIL_ENV') == 'PRODUCTION')
{
$mailTo = data_get($profile,'team.email');
}
$detailmaster = Ts_master::where('id', $request->tmid)->first();
$data_timesheet = [
'year' => data_get($detailmaster,'tm_year'),
'month' => data_get($detailmaster,'tm_month'),
'phase' => data_get($detailmaster,'tm_phase'),
'submissionDate' => data_get($detailmaster,'tm_submission_at'),
];
// dd($data_timesheet);
$data_email = [
'subject' => 'Timesheet Project: Timesheet Project has been rejected',
'sender_name' => '3fetimesheet@gmail.com',
'pcode' => data_get($profile,'project.p_project_code'),
'projectmanager' => data_get($profile,'pm.fullname'),
'projectdirector' => data_get($profile,'bod.fullname'),
'projectname' => data_get($profile,'tp_project_name'),
'status' => data_get($profile,'tp_timesheet_sts'),
'remarks' => data_get($request,'remarks'),
'staffname' => data_get($profile,'team.fullname'),
];
// Mail::to($mailTo)->send(new PmRejectProject($data_email));
return new PmRejectProject($data_email, $data_timesheet);
dd($data_email);
// email end
Ts_detail::where('fk_tm_id', $request->tmid) Ts_detail::where('fk_tm_id', $request->tmid)
->where('td_project', $request->pid) ->where('td_project', $request->pid)
->update(['td_timesheet_sts' => 6 ]); ->update(['td_timesheet_sts' => 6 ]);
...@@ -1019,9 +1067,8 @@ class DashboardController extends Controller ...@@ -1019,9 +1067,8 @@ class DashboardController extends Controller
} }
// if(data_get($request,'page') == 1){ // if(data_get($request,'page') == 1){
return redirect()->route('timesheet::dashboard.index')->withSuccess('Staff project has been rejected'); return redirect()->route('timesheet::dashboard.index')->withSuccess('Staff project has been rejected');
// } // }
// return redirect()->route('timesheet::dashboard.projectVerify', compact('month', 'phase'))->withErrors('Staff project has been rejected with remarks'); // return redirect()->route('timesheet::dashboard.projectVerify', compact('month', 'phase'))->withErrors('Staff project has been rejected with remarks');
} }
} }
......
@component('mail::message')
# Your project has been rejected!
Assalamualaikum w.b.t Dato' /Datin /En /Pn / Cik
{!! ucwords(strtolower($data_email['staffname'])) !!}
We would like to inform you as one of your timesheet project namely, {!! $data_email['projectname'] !!}, has been rejected.
The details of timesheet submission is as below: <br>
<table style="border: black 1px solid; font-size: 16px; text-align: center; width: 150%;" id="project">
<thead>
<tr>
<th style="border: black 1px solid;">Phase</th>
<th style="border: black 1px solid;">Month</th>
<th style="border: black 1px solid;">Year</th>
<th style="border: black 1px solid;">Submission Date</th>
</tr>
</thead>
<tbody>
<tr>
<td style="border: black 1px solid;">@if($data_timesheet['phase'] == 1) 1st Halfmonth @else 2nd Halfmonth @endif</td>
<td style="border: black 1px solid;">{!! date("F", mktime(0, 0, 0, $data_timesheet['month'], 10)) !!}</td>
<td style="border: black 1px solid;">{!! ucwords(strtolower($data_timesheet['year'])) !!}</td>
<td style="border: black 1px solid;">{!! date("d F Y", strtotime($data_timesheet['submissionDate'])) !!}</td>
</tr>
</tbody>
</table>
<br>
The details of the project rejection is as below: <br>
<table style="border: black 1px solid; font-size: 16px; text-align: center; width: 150%;" id="project">
<thead>
<tr>
<th style="border: black 1px solid;">Project Code</th>
<th style="border: black 1px solid;">Project Name</th>
<th style="border: black 1px solid;">Rejected By</th>
<th style="border: black 1px solid;">Remarks</th>
</tr>
</thead>
<tbody>
<tr>
<td style="border: black 1px solid;">{!! $data_email['pcode'] !!} </td>
<td style="border: black 1px solid;">{!! ucwords(strtolower($data_email['projectname'])) !!}</td>
<td style="border: black 1px solid;">{!! ucwords(strtolower($data_email['projectmanager'])) !!}</td>
<td style="border: black 1px solid;">{!! ucwords(strtolower($data_email['remarks'])) !!}</td>
</tr>
</tbody>
</table>
<br>
Thank you. <br>
<!-- <br> -->
---
<br>
<i>This is an auto generated message, please do not reply.</i>
<!-- Thanks,<br> -->
<!-- {{ config('app.name') }} -->
@endcomponent
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment