Commit 90a64481 by Azhan Hannan

staff - flow rejected overhead

parent 54d14ceb
......@@ -27,7 +27,10 @@
<div class="ui unstackable segment">
<a class="ui blue left ribbon label">List Description of Task</a>
<br><br>
<br>
<br>
@if(data_get($staff,'fk_lkp_department') == 7)
<button type="button" class="right floated aligned ui olive compact labeled icon button" id="uploadmodal">
......@@ -48,6 +51,21 @@
<i class="plus icon"></i>Add New Notes
</a> -->
@if($page)
<input type="hidden" name="page" value="{{$page}}">
<button type="submit" class="right floated aligned ui orange compact button">
Save
</button>
<button type="button" class="center aligned ui purple compact labeled icon button" onclick="window.location.href='{{ route('timesheet::form.rejected', ['tpid' => data_get($checktp,'id') ]) }}';">
<i class="angle double left icon"></i>
Back To Resubmit Overhead
</button>
@else
<button type="submit" class="right floated aligned ui orange compact button">
Save
</button>
......@@ -61,6 +79,7 @@
<i class="angle double right icon"></i>
Timesheet Viewer
</button>
@endif
<table class="ui celled structured table unstackable">
<thead>
......
......@@ -4,19 +4,43 @@
<div class="ui segment">
<a class="ui purple left ribbon label">Rejected Overhead</a>
<?php
$month = data_get($checkoverhead,'tm_month');
$phase = data_get($checkoverhead,'tm_phase');
$year = data_get($checkoverhead,'tm_year');
$fk_tm_id = data_get($checkoverhead,'id');
$page = 6;
?>
@if($checkoverhead)
<button class="right floated aligned ui yellow compact labeled icon button" id="notes" onclick="window.location.href='{{ route('timesheet::form.notelist', ['year'=> $year, 'month'=> $month, 'phase'=> $phase, 'fk_tm_id'=> $fk_tm_id, 'page'=> $page] ) }} ';">
<i class="plus icon"></i>
Add Task Description
</button>
@else
@endif
<br>
<br>
<form class="ui form" action="" method="POST">
<form class="ui form" action="{{ route('timesheet::form.resubmitoverhead') }}" method="POST">
{{csrf_field()}}
<input type="hidden" name="userId" value="{{$userId}}">
<input type="hidden" name="year" value="{{$year}}">
<input type="hidden" name="month" value="{{$month}}">
<input type="hidden" name="phase" value="{{$phase}}">
<input type="hidden" name="page" value="{{$page}}">
<table class="ui celled structured unstackable table" >
<thead>
<tr>
<th rowspan="3" class="center aligned">Overhead</th>
<th colspan="@if($phase == 1) 15 @else {{$daymonth-15}} @endif" class="center aligned">Date</th>
<th rowspan="2">
<button type="submit" class="fluid center aligned ui blue button">
<button type="submit" class="fluid center aligned ui compact blue button">
<!-- <i class="save icon"></i> -->
Save
</button>
<br>
<button type="button" class="fluid center aligned ui compact purple button" onclick="window.location.href='{{ route('timesheet::form.resubmitconfirm', ['fk_tm_id'=> $fk_tm_id, 'page'=> $page] ) }} ';">
Resubmit
</button>
</th>
......
......@@ -104,6 +104,7 @@ Route::group(
Route::get('rejected',['uses' => 'FormController@rejected', 'as' => 'form.rejected']);
Route::post('resubmit',['uses' => 'FormController@resubmit', 'as' => 'form.resubmit']);
Route::post('resubmitoverhead',['uses' => 'FormController@resubmitoverhead', 'as' => 'form.resubmitoverhead']);
Route::get('resubmitconfirm',['uses' => 'FormController@resubmitconfirm', 'as' => 'form.resubmitconfirm']);
// nonChargeableForm
......
......@@ -69,7 +69,7 @@ class DashboardController extends Controller
->get();
$details = Tproject::where('tp_project_type', 3)
// ->where('tp_timesheet_sts', 2)
->where('tp_timesheet_sts','<>', 1)
->where('tp_pm', $verifier->id)
->with('notes')
->get();
......
......@@ -1124,6 +1124,8 @@ class FormController extends Controller
{
// dd($request);
$page = data_get($request,'page');
$overhead = 3;
$userId = Users::find(Auth::id())
......@@ -1157,6 +1159,7 @@ class FormController extends Controller
// dd($checknotelist);
if ($checknotelist) {
$notes = Ts_detail::where('fk_tm_id', $checknotelist->id)
->where('td_project_type', $overhead)
......@@ -1164,6 +1167,12 @@ class FormController extends Controller
->orderby('td_date')
->get();
$fk_tm_id = $checknotelist->id;
$checktp = Tproject::where('fk_tm_id', $fk_tm_id)
->where('tp_project_type', 3)
// ->where('fk_o_id', data_get($notes, 'fk_o_id'))
->first();
// dd($checktp);
}
else
{
......@@ -1179,8 +1188,7 @@ class FormController extends Controller
// dd($list);
return view('timesheet::form.notelist', compact('notes', 'phase', 'month', 'year', 'fk_tm_id', 'staff', 'onotes'));
return view('timesheet::form.notelist', compact('notes', 'phase', 'month', 'year', 'fk_tm_id', 'staff', 'onotes', 'page', 'checktp'));
}
public function penambahannote()
......@@ -1267,7 +1275,7 @@ class FormController extends Controller
public function savenote(Request $request)
{
// dd($request->note[0]);
// dd($request);
$overhead = 3;
$userId = Users::find(Auth::id())
......@@ -1315,6 +1323,11 @@ class FormController extends Controller
$tdetail->save();
}
if(data_get($request,'page'))
{
return redirect()->route('timesheet::form.notelist', ['page'=>data_get($request,'page'), 'year'=> $year, 'month' =>$month, 'phase' => $phase, 'fk_tm_id' => $request->fk_tm_id])->with('success', 'Notes Updated!');
}
return redirect()->route('timesheet::form.notelist', ['year'=> $year, 'month' =>$month, 'phase' => $phase, 'fk_tm_id' => $request->fk_tm_id])->with('success', 'Notes Updated!');
}
else
......@@ -1324,13 +1337,6 @@ class FormController extends Controller
}
/**
* undocumented function
*
* @return void
* @author
**/
public function uploadAttachement(Request $request)
{
// dd($request->attachment);
......@@ -1400,6 +1406,7 @@ class FormController extends Controller
public function rejected(Request $request)
{
// dd($request);
$userId = users::find(Auth::id())
->u_staffID;
......@@ -1407,9 +1414,11 @@ class FormController extends Controller
->with('project')
->with('overhead')
->first();
// dd($profile);
$month = data_get($profile,'tp_month');
// dump($month);
$year = data_get($profile,'tp_year');
// dd($year);
$phase = data_get($profile,'tp_phase');
$daymonth=cal_days_in_month(CAL_GREGORIAN,$month,$year);
......@@ -1424,6 +1433,9 @@ class FormController extends Controller
}
$checkoverhead = Ts_master::where('id', data_get($profile,'fk_tm_id'))
->first();
$projectlist = [];
if ($profile->tp_project_type == 1)
......@@ -1439,12 +1451,32 @@ class FormController extends Controller
}
else
{
// dd($profile);
$overhead = Overhead::where('o_overhead_sts',1)
->get();
$projectlist = [];
// nanti project code query dari table project:
foreach ($overhead as $key => $value) {
$projectlist[] = [
'td_project' => $profile->fk_o_id,
'td_project_name' => $profile->overhead->o_overhead_desc,
'td_project' => $value->id,
'td_project_name' => $value->o_overhead_desc,
];
}
// $projectlist[] = [
// 'td_project' => $profile->fk_o_id,
// 'td_project_name' => $profile->overhead->o_overhead_desc,
// ];
}
......@@ -1462,7 +1494,7 @@ class FormController extends Controller
else
{
$hour = Ts_detail::where('fk_tm_id',$check->id)
->where('fk_o_id', $profile->fk_o_id)
->where('td_project_type', 3)
->get();
// dd($hour);
}
......@@ -1478,18 +1510,17 @@ class FormController extends Controller
}
else
{
return view('timesheet::form.rejectedoverhead', compact('month', 'phase', 'year', 'profile', 'strdays', 'daymonth', 'projectlist', 'check' ,'hour'));
return view('timesheet::form.rejectedoverhead', compact('userId', 'month', 'phase', 'year', 'profile', 'strdays', 'daymonth', 'projectlist', 'check' ,'hour', 'checkoverhead'));
}
}
public function resubmit(Request $request)
{
// dd($request);
$profile = Tproject::where('id', $request->tpid)
->first();
// dd($profile);
$chargeable = 1;
$userId = users::find(Auth::id())
......@@ -1648,4 +1679,397 @@ class FormController extends Controller
return redirect()->route('timesheet::dashboard.index');
}
public function resubmitoverhead(Request $request)
{
// dd($request);
// dd(gettype($request->hour[1][3]));
$overhead = 3;
$userId = users::find(Auth::id())
->u_staffID;
$staffinfo = Staff_info::where('staff_id', $userId)
->first();
// dd($staffinfo);
$check = Ts_master::where('tm_staff_id', $userId)
->where('tm_year', $request->year)
->where('tm_month', $request->month)
->where('tm_phase', $request->phase)
->first();
if($check)
{
}
else
{
$check = new Ts_master;
$check->tm_staff_id = $userId;
$check->tm_year = $request->year;
$check->tm_month = $request->month;
$check->tm_phase = $request->phase;
$check->tm_timesheet_master_sts = 1;
$check->updated_by = $userId;
$check->save();
}
$tmasterid = $check->id;
$detail = $request->hour;
foreach ($detail as $key => $value)
{
$projectid = $key;
// dump($projectid);
foreach ($value as $keyday => $day)
{
if($day == "0" || $day == "NaN"){
$day = null;
$date = $request->year.'-'.$request->month.'-'.sprintf('%02d', $keyday);
$checkTimesheetDetail = Ts_detail::where('fk_o_id', $projectid)
->where('fk_tm_id', $tmasterid)
->where('td_project_type', $overhead)
->where('td_date', $date)
->where('tm_phase', $request->phase)
->first();
if($checkTimesheetDetail)
{
$checkTimesheetDetail->td_hours = $day;
$checkTimesheetDetail->updated_by = $userId;
$checkTimesheetDetail->save();
$checktproject = Tproject::where('fk_tm_id', $tmasterid)
->where('fk_o_id', $projectid)
->first();
if ($checktproject) {
$checkhours = Ts_detail::where('fk_tm_id', $tmasterid)
->where('fk_o_id', $projectid)
->get();
$checktproject->tp_hours = $checkhours->sum('td_hours');
$checktproject->save();
}
$checkTimesheetDetail->delete();
}
// dd($checkTimesheetDetail->td_hours);
}
if($day){
$date = $request->year.'-'.$request->month.'-'.sprintf('%02d', $keyday);
$checkTimesheetDetail = Ts_detail::where('fk_o_id', $projectid)
->where('fk_tm_id', $tmasterid)
->where('td_project_type', $overhead)
->where('td_date', $date)
->where('tm_phase', $request->phase)
->first();
$valuehour = $day;
if($valuehour == null)
{
$valuehour = 0;
}
if($valuehour == "NaN")
{
$valuehour = null;
}
if($checkTimesheetDetail)
{
$checkTimesheetDetail->td_hours = $valuehour;
$checkTimesheetDetail->updated_by = $userId;
$checkTimesheetDetail->save();
$checkhours = Ts_detail::where('fk_tm_id', $tmasterid)
->where('fk_o_id', $projectid)
->where('td_hours', '!=', '0')
->get();
$checktproject = Tproject::where('fk_tm_id', $tmasterid)
->where('fk_o_id', $projectid)
->first();
if ($checktproject) {
$checktproject->tp_hours = $checkhours->sum('td_hours');
$checktproject->save();
}
else
{
$tpdetail = new Tproject;
$tpdetail->fk_o_id = $projectid;
$tpdetail->staffid = $userId;
$tpdetail->fk_tm_id = $tmasterid;
$tpdetail->tp_project_type = 3;
$tpdetail->tp_year = $request->year;
$tpdetail->tp_month = $request->month;
$tpdetail->tp_phase = $request->phase;
$tpdetail->tp_pm = data_get($staffinfo,'penyokong');
$tpdetail->tp_pd = data_get($staffinfo,'pelulus');
$project = Overhead::where('id', $projectid)
->first();
$tpdetail->tp_project_name = $project->o_overhead_desc;
$tpdetail->tp_hours = $checkhours->sum('td_hours');
$tpdetail->tp_timesheet_sts = 1;
$tpdetail->updated_by = $userId;
$tpdetail->save();
}
}
else
{
$tmdetail = new Ts_detail;
$tmdetail->td_date = $date;
$tmdetail->fk_o_id = $projectid;
$tmdetail->fk_tm_id = $tmasterid;
$tmdetail->tm_staff_id = $userId;
$tmdetail->tm_month = $check->tm_month;
$tmdetail->tm_year = $check->tm_year;
$tmdetail->tm_phase = $check->tm_phase;
$tmdetail->td_project_type = 3;
$tmdetail->updated_by = $userId;
$project = Overhead::where('id', $projectid)
->first();
$tmdetail->td_overhead_desc = $project->o_overhead_desc;
$tmdetail->td_hours = $valuehour;
$tmdetail->td_timesheet_sts = 1;
$tmdetail->save();
$checkhours = Ts_detail::where('fk_tm_id', $tmasterid)
->where('fk_o_id', $projectid)
->where('td_hours', '!=', '0')
->get();
$checktproject = Tproject::where('fk_tm_id', $tmasterid)
->where('fk_o_id', $projectid)
->first();
if ($checktproject) {
$checktproject->tp_hours = $checkhours->sum('td_hours');
$checktproject->save();
}
else
{
$tpdetail = new Tproject;
$tpdetail->fk_o_id = $projectid;
$tpdetail->staffid = $userId;
$tpdetail->fk_tm_id = $tmasterid;
$tpdetail->tp_project_type = 3;
$tpdetail->tp_year = $request->year;
$tpdetail->tp_month = $request->month;
$tpdetail->tp_phase = $request->phase;
$tpdetail->tp_pm = data_get($staffinfo,'penyokong');
$tpdetail->tp_pd = data_get($staffinfo,'pelulus');
$project = Overhead::where('id', $projectid)
->first();
$tpdetail->tp_project_name = $project->o_overhead_desc;
$tpdetail->tp_hours = $checkhours->sum('td_hours');
$tpdetail->tp_timesheet_sts = 1;
$tpdetail->updated_by = $userId;
$tpdetail->save();
}
}
}
}
$zeroedproject = Tproject::where('fk_tm_id', $tmasterid)
->where('fk_o_id', $projectid)
->first();
if($zeroedproject)
{
if($zeroedproject->tp_hours == '0')
{
$zeroedproject->delete();
}
}
}
$sumdetailhour = Ts_detail::where('td_project_type', $overhead)
->where('fk_tm_id', $tmasterid)
->where('tm_phase', $request->phase)
->sum('td_hours');
$checktotalhours = Ts_master::where('id', $tmasterid)->first();
$checktotalhours->tm_overhead_hrs = $sumdetailhour;
$checktotalhours->tm_overhead_days = $sumdetailhour/8.0;
$checktotalhours->save();
$checko = Tproject::where('fk_tm_id', $tmasterid)
->first();
// dd($request);
return redirect()->route('timesheet::form.rejected', ['tpid' => data_get($checko,'id'), 'page'=> data_get($request,'page')])->with('success', 'Overhead form updated! Kindly update your notes accordingly before proceed to resubmit overhead. Thank you 😊');
}
public function resubmitconfirm(Request $request)
{
// dd(now());
$roleid = auth()->user()->roles['0']->id;
$user = Staff_info::where('fk_users', Auth::id())
->with('penyokongpm')
->first();
$userId = users::find(Auth::id())
->u_staffID;
$tmaster = Ts_master::where('id', data_get($request,'fk_tm_id'))->first();
$checktp = Tproject::where('fk_tm_id', data_get($request, 'fk_tm_id'))
->where('tp_project_type', 3)
->get();
$checktd = Ts_detail::where('fk_tm_id', data_get($request, 'fk_tm_id'))
->where('td_project_type', 3)
->get();
$checknotes = Ts_detail::where('fk_tm_id', data_get($request,'fk_tm_id'))
->whereNotNull('td_hours')
->where('td_project_type', 3)
->get();
// dd($checknotes);
foreach ($checknotes as $key => $value)
{
if($value->td_overhead_note == null)
{
return redirect()->route('timesheet::form.notelist', ['year' => $tmaster->tm_year, 'month'=> $tmaster->tm_month, 'phase'=> $tmaster->tm_phase, 'fk_tm_id'=> $request->fk_tm_id, 'page'=>$request->page ])->withErrors('Kindly fill in and save your notes before submit your timesheet. Thank you 😊');
}
}
Tproject::where('fk_tm_id', $request->fk_tm_id)
->where('tp_project_type', 3)
->update([
'tp_timesheet_sts' => 2,
'updated_by' => $userId
]);
Ts_detail::where('fk_tm_id', $request->fk_tm_id)
->where('td_project_type', 3)
->update([
'td_timesheet_sts' => 2,
'updated_by' => $userId
]);
// if( $roleid == '8' )
// {
// $checkpm = Tproject::where('tp_project_type', 3)
// ->where('fk_tm_id',$request->tid)
// ->first();
// if($checkpm)
// {
// Ts_detail::where('fk_tm_id', $request->tid)
// ->where('td_project_type', 3)
// ->update(['td_timesheet_sts' => 2 ]);
// Tproject::where('fk_tm_id', $request->tid)
// ->where('tp_project_type', 3)
// ->update(['tp_timesheet_sts' => 2] );
// }
// else
// {
// Ts_master::where('id', $request->tid)
// ->update([ 'tm_timesheet_master_sts' => 2 ]);
// Ts_detail::where('fk_tm_id', $request->tid)
// ->where('td_project_type', 3)
// ->update([ 'td_timesheet_sts' => 2 ]);
// Tproject::where('fk_tm_id', $request->tid)
// ->where('tp_project_type', 3)
// ->update([
// 'tp_timesheet_sts' => 2,
// 'tp_pm' => data_get($user,'penyokongpm.staff_id')
// ] );
// }
// }
// if( $roleid == '2' )
// {
// $checkhod = Tproject::where('tp_project_type', 1)
// ->where('fk_tm_id',$request->tid)
// ->first();
// if($checkhod)
// {
// Ts_detail::where('fk_tm_id', $request->tid)
// ->where('td_project_type', 3)
// ->update([ 'td_timesheet_sts' => 3 ]);
// Tproject::where('fk_tm_id', $request->tid)
// ->where('tp_project_type', 3)
// ->update([ 'tp_timesheet_sts' => 3] );
// }
// else
// {
// Ts_master::where('id', $request->tid)
// ->update([ 'tm_timesheet_master_sts' => 3 ]);
// Ts_detail::where('fk_tm_id', $request->tid)
// ->where('td_project_type', 3)
// ->update([ 'td_timesheet_sts' => 3 ]);
// Tproject::where('fk_tm_id', $request->tid)
// ->where('tp_project_type', 3)
// ->update([ 'tp_timesheet_sts' => 3] );
// }
// }
// if( $roleid == '9' )
// {
// Ts_master::where('id', $request->tid)
// ->update([ 'tm_timesheet_master_sts' => 3 ]);
// Ts_detail::where('fk_tm_id', $request->tid)
// ->update([ 'td_timesheet_sts' => 3 ]);
// Tproject::where('fk_tm_id', $request->tid)
// ->update([ 'tp_timesheet_sts' => 3] );
// }
// if( ($roleid != ('9'||'2'||'8')) && (data_get($user,'penyokong') == '0') )
// {
// Ts_master::where('id', $request->tid)
// ->update([ 'tm_timesheet_master_sts' => 3 ]);
// Ts_detail::where('fk_tm_id', $request->tid)
// ->update([ 'td_timesheet_sts' => 3 ]);
// Tproject::where('fk_tm_id', $request->tid)
// ->update([ 'tp_timesheet_sts' => 3] );
// }
return redirect()->route('timesheet::dashboard.index')->withSuccess('Rejected overhead has been resubmit 😊');
}
}
\ 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