Commit 6a5e073f by Azhan Hannan

Log Pia #192 -> Notification EDIT PROJECT. Tambah details ‘Updated By’ Display…

Log Pia #192 -> Notification  EDIT PROJECT. Tambah details ‘Updated By’  Display Updated By from table project.updated_by
parent f902d054
...@@ -12,6 +12,7 @@ class EditProject extends Mailable ...@@ -12,6 +12,7 @@ class EditProject extends Mailable
use Queueable, SerializesModels; use Queueable, SerializesModels;
public $data_email; public $data_email;
public $old_data;
/** /**
* Create a new message instance. * Create a new message instance.
...@@ -19,9 +20,10 @@ class EditProject extends Mailable ...@@ -19,9 +20,10 @@ class EditProject extends Mailable
* @return void * @return void
*/ */
public function __construct($data_email) public function __construct($data_email, $old_data)
{ {
$this->data_email = $data_email; $this->data_email = $data_email;
$this->old_data = $old_data;
} }
/** /**
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
</div> </div>
<div class="field"> <div class="field">
<label>Project Manager</label> <label>Project Manager</label>
<select name="projectmanager" class="ui fluid dropdown"> <select name="projectmanager" class="ui fluid dropdown search">
<option value="{{data_get($project,'p_project_task_team')}}"> <option value="{{data_get($project,'p_project_task_team')}}">
@foreach($pm as $key => $value) @foreach($pm as $key => $value)
@if($value->staff_id == $project->p_project_task_team){{data_get($value,'fullname')}}@endif @if($value->staff_id == $project->p_project_task_team){{data_get($value,'fullname')}}@endif
......
...@@ -244,16 +244,25 @@ class MaintenanceController extends Controller ...@@ -244,16 +244,25 @@ class MaintenanceController extends Controller
public function editproject(Request $request) public function editproject(Request $request)
{ {
// dd($request);
$user = Staff_info::where('fk_users', Auth::id())->first(); $user = Staff_info::where('fk_users', Auth::id())->first();
$project = Project::where('id', $request->pid)->first(); $project = Project::where('id', $request->pid)->first();
$old_data = [
'pcode' => data_get($project,'p_project_code'),
'projectmanager' => data_get($project,'projectManager.fullname'),
'projectdirector' => data_get($project,'projectDirector.fullname'),
'projectname' => data_get($project,'p_project_description'),
'username' => data_get($user,'fullname'),
'status' => data_get($project,'p_project_sts'),
'editor' => data_get($project,'editor.fullname'),
];
$project->id = $request->pid; $project->id = $request->pid;
$project->p_project_task_team = $request->projectmanager; $project->p_project_task_team = $request->projectmanager;
$project->p_project_sts = $request->status; $project->p_project_sts = $request->status;
$project->updated_by = data_get($user,'email'); $project->updated_by = data_get($user,'staff_id');
$project->save(); $project->save();
$sname = Staff_info::select('fullname') $sname = Staff_info::select('fullname')
...@@ -278,8 +287,11 @@ class MaintenanceController extends Controller ...@@ -278,8 +287,11 @@ class MaintenanceController extends Controller
$project = Project::where('id', $request->pid) $project = Project::where('id', $request->pid)
->with('projectManager') ->with('projectManager')
->with('projectDirector') ->with('projectDirector')
->with('editor')
->first(); ->first();
// dd(data_get($project,'editor.fullname'));
if (env('EMAIL_ENV') == 'local') if (env('EMAIL_ENV') == 'local')
{ {
$mailTo = '143hannan@gmail.com'; $mailTo = '143hannan@gmail.com';
...@@ -302,10 +314,11 @@ class MaintenanceController extends Controller ...@@ -302,10 +314,11 @@ class MaintenanceController extends Controller
'projectname' => data_get($project,'p_project_description'), 'projectname' => data_get($project,'p_project_description'),
'username' => data_get($user,'fullname'), 'username' => data_get($user,'fullname'),
'status' => data_get($project,'p_project_sts'), 'status' => data_get($project,'p_project_sts'),
'editor' => data_get($project,'editor.fullname'),
]; ];
Mail::to($mailTo)->send(new EditProject($data_email)); Mail::to($mailTo)->send(new EditProject($data_email, $old_data));
// return new EditProject($data_email); // return new EditProject($data_email, $old_data);
// email end // email end
...@@ -410,6 +423,7 @@ class MaintenanceController extends Controller ...@@ -410,6 +423,7 @@ class MaintenanceController extends Controller
$mandays = Pmandays::where('fk_project', $request->id) $mandays = Pmandays::where('fk_project', $request->id)
->with('role') ->with('role')
->get(); ->get();
// dd($mandays);
if (env('EMAIL_ENV') == 'local') if (env('EMAIL_ENV') == 'local')
{ {
...@@ -619,24 +633,16 @@ class MaintenanceController extends Controller ...@@ -619,24 +633,16 @@ class MaintenanceController extends Controller
$team = Pteam::where('id', $request->id) $team = Pteam::where('id', $request->id)
->with('staffdetail') ->with('staffdetail')
->first(); ->first();
// dd($team->staffdetail);
// dd($team);
$departments = Department::where('id', data_get($team,'staffdetail.fk_lkp_department'))->first(); $departments = Department::where('id', data_get($team,'staffdetail.fk_lkp_department'))
// dd($departments); ->first();
$staffs = Staff_info::where('fk_lkp_department', data_get($departments,'id')) $staffs = Staff_info::where('fk_lkp_department', data_get($departments,'id'))
->where('status',1) ->where('status',1)
->get(); ->get();
// foreach ($departments as $key => $value)
// {
// $staffs = Staff_info::where('fk_lkp_department', $value->id)
// ->get();
// }
$teamRole = Role::where('id', $team->role_id) $teamRole = Role::where('id', $team->role_id)
->first(); ->first();
// dd($teamRole);
$role = Role::where('status',1) $role = Role::where('status',1)
->where('id','<>',7) ->where('id','<>',7)
......
...@@ -31,6 +31,11 @@ class Project extends Model ...@@ -31,6 +31,11 @@ class Project extends Model
return $this->hasOne('Portal\Timesheet\Model\Pteam','fk_project_id','id'); return $this->hasOne('Portal\Timesheet\Model\Pteam','fk_project_id','id');
} }
public function editor()
{
return $this->hasOne('Portal\Timesheet\Model\Staff_info','staff_id','updated_by');
}
/** /**
* undocumented function * undocumented function
* *
......
...@@ -7,8 +7,34 @@ Assalamualaikum w.b.t Mr/Mrs. ...@@ -7,8 +7,34 @@ Assalamualaikum w.b.t Mr/Mrs.
We would like to inform you as there are changes in our project details. We would like to inform you as there are changes in our project details.
The new project details as below : <br> The previous project details : <br>
<table style="border: black 1px solid; font-size: 10px; text-align: center; width: 100%;" id="project">
<table style="border: black 1px solid; font-size: 10px; text-align: center; width: 125%;" 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;">Project Manager</th>
<th style="border: black 1px solid;">Project Director</th>
<th style="border: black 1px solid;">Status</th>
<th style="border: black 1px solid;">Updated by</th>
</tr>
</thead>
<tbody>
<tr>
<td style="border: black 1px solid;"> {!! $old_data['pcode'] !!} </td>
<td style="border: black 1px solid;"> {!! $old_data['projectname'] !!} </td>
<td style="border: black 1px solid;"> {!! $old_data['projectmanager'] !!} </td>
<td style="border: black 1px solid;"> {!! $old_data['projectdirector'] !!} </td>
<td style="border: black 1px solid;"> @if( $old_data['status'] == 1) Active @else Inactive @endif </td>
<td style="border: black 1px solid;"> {!! $old_data['editor'] !!} </td>
</tr>
</tbody>
</table>
<br>
The new project details : <br>
<table style="border: black 1px solid; font-size: 10px; text-align: center; width: 125%;" id="project">
<thead> <thead>
<tr> <tr>
<th style="border: black 1px solid;">Project Code</th> <th style="border: black 1px solid;">Project Code</th>
...@@ -16,6 +42,7 @@ The new project details as below : <br> ...@@ -16,6 +42,7 @@ The new project details as below : <br>
<th style="border: black 1px solid;">Project Manager</th> <th style="border: black 1px solid;">Project Manager</th>
<th style="border: black 1px solid;">Project Director</th> <th style="border: black 1px solid;">Project Director</th>
<th style="border: black 1px solid;">Status</th> <th style="border: black 1px solid;">Status</th>
<th style="border: black 1px solid;">Updated by</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
...@@ -25,6 +52,7 @@ The new project details as below : <br> ...@@ -25,6 +52,7 @@ The new project details as below : <br>
<td style="border: black 1px solid;"> {!! $data_email['projectmanager'] !!} </td> <td style="border: black 1px solid;"> {!! $data_email['projectmanager'] !!} </td>
<td style="border: black 1px solid;"> {!! $data_email['projectdirector'] !!} </td> <td style="border: black 1px solid;"> {!! $data_email['projectdirector'] !!} </td>
<td style="border: black 1px solid;"> @if( $data_email['status'] == 1) Active @else Inactive @endif </td> <td style="border: black 1px solid;"> @if( $data_email['status'] == 1) Active @else Inactive @endif </td>
<td style="border: black 1px solid;"> {!! $data_email['editor'] !!} </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
......
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