Commit b7a75e4f by Azhan Hannan

checking minimum 8 jam untuk hari bekerja dan 4 jam utk sabtu bekerja

parent 80ec8cc4
...@@ -11,6 +11,7 @@ use Portal\Timesheet\Model\Ts_detail; ...@@ -11,6 +11,7 @@ use Portal\Timesheet\Model\Ts_detail;
use Portal\Timesheet\Model\Project; use Portal\Timesheet\Model\Project;
use Portal\Timesheet\Model\Tproject; use Portal\Timesheet\Model\Tproject;
use Portal\Timesheet\Model\Department; use Portal\Timesheet\Model\Department;
use Portal\Timesheet\Model\LAttendance;
use Portal\Timesheet\Model\Pteam; use Portal\Timesheet\Model\Pteam;
use Portal\Timesheet\Model\Staff_info; use Portal\Timesheet\Model\Staff_info;
use Portal\Timesheet\Model\Overhead; use Portal\Timesheet\Model\Overhead;
...@@ -1423,13 +1424,11 @@ class DashboardController extends Controller ...@@ -1423,13 +1424,11 @@ class DashboardController extends Controller
return view('timesheet::dashboard.timesheetViewer', compact('curruser', 'user','profile', 'dept', 'phase', 'month', 'year', 'strMonth', 'daymonth', 'chargeablelist', 'overheadlist', 'chargehour', 'totalchargehrs', 'totaloverheadhrs', 'overheadhour', 'notes', 'check', 'strdays')); return view('timesheet::dashboard.timesheetViewer', compact('curruser', 'user','profile', 'dept', 'phase', 'month', 'year', 'strMonth', 'daymonth', 'chargeablelist', 'overheadlist', 'chargehour', 'totalchargehrs', 'totaloverheadhrs', 'overheadhour', 'notes', 'check', 'strdays'));
} }
public function tsubmit(Request $request) public function tsubmit(Request $request)
{ {
$roleid = auth()->user()->roles['0']->id; $roleid = auth()->user()->roles['0']->id;
$user = Staff_info::where('fk_users', Auth::id())
->with('penyokongpm')
->first();
// dd(data_get($user,'penyokongpm.staff_id')); // dd(data_get($user,'penyokongpm.staff_id'));
$checknotes = Ts_detail::where('fk_tm_id', $request->tid) $checknotes = Ts_detail::where('fk_tm_id', $request->tid)
...@@ -1446,6 +1445,100 @@ class DashboardController extends Controller ...@@ -1446,6 +1445,100 @@ class DashboardController extends Controller
} }
$tm = Ts_master::where('id', data_get($request,'tid'))->first();
$tp = Tproject::where('fk_tm_id', data_get($request,'tid'))->get();
$td = Ts_detail::where('fk_tm_id', data_get($request,'tid'))->orderby('td_date','asc')->get();
$phase = data_get($tm,'tm_phase');
$month = data_get($tm,'tm_month');
$year = data_get($tm,'tm_year');
$daymonth=cal_days_in_month(CAL_GREGORIAN,$month,$year);
$myDate = $month.'/'.'1'.'/'.$year;
$date = Carbon::createFromFormat('m/d/Y', $myDate);
$strMonth = $date->format('F');
$strdays = [];
$fulldate = [];
if ($phase == 1) {
for ($i=0; $i < 15; $i++) {
$tempdate = $year.'-'.sprintf('%02d', $month).'-'.sprintf('%02d', $i+1);
$strday = Carbon::createFromFormat('Y-m-d', $tempdate)->format('l');
$strdays[$i] = substr($strday, 0, 3);
$fulldate[] = $year.'-'.sprintf('%02d', $month).'-'.sprintf('%02d', $i+1);
}
} else {
for ($i=15; $i < $daymonth-15; $i++) {
$tempdate = $year.'-'.sprintf('%02d', $month).'-'.sprintf('%02d', $i+1);
$strday = Carbon::createFromFormat('Y-m-d', $tempdate)->format('l');
$strdays[$i] = substr($strday, 0, 3);
$fulldate[] = $year.'-'.sprintf('%02d', $month).'-'.sprintf('%02d', $i+1);
}
}
$user = Users::find(Auth::id())
->u_staffID;
$haribekerja = LAttendance::where('staff_id', $user)
->whereIn('DATE', $fulldate)
->get();
$kurang = [];
foreach ($haribekerja as $key => $hari)
{
// dd($td->where('td_date', data_get($hari,'DATE')));
// dd(data_get($hari,'DATE'));
$minimumhari = $td->where('td_date', data_get($hari,'DATE'));
// dump($minimumhari);
if (data_get($hari,'day_type') == 1)
{
$checkminimumhari = $minimumhari->sum('td_hours');
if (date('D', strtotime(data_get($hari,'DATE'))) == 'Sat')
{
if ($checkminimumhari < 4)
{
$kurang[] =
[
'tarikh'=>data_get($hari,'DATE'),
'hourskurang'=>4-$checkminimumhari,
];
}
}
else
{
if ($checkminimumhari < 8)
{
$kurang[] =
[
'tarikh'=>data_get($hari,'DATE'),
'hourskurang'=>8-$checkminimumhari,
];
}
}
}
}
if (count($kurang) > 0) {
$intro = 'The timesheet is not complete. Please refer to the date and hours required.<br>';
$text = '';
foreach ($kurang as $key => $value) {
// dd($value);
$text = $text.'<br>'.strval(data_get($value,'tarikh')).' : not enough '.strval(data_get($value,'hourskurang')).' hours';
}
$fulltext = $intro.$text;
return redirect()->route('timesheet::dashboard.timesheetViewer', compact('user','phase', 'month', 'year'))->withErrors($fulltext);
}
$today = Carbon::today()->toDateString(); $today = Carbon::today()->toDateString();
Ts_master::where('id', $request->tid) Ts_master::where('id', $request->tid)
...@@ -1464,6 +1557,9 @@ class DashboardController extends Controller ...@@ -1464,6 +1557,9 @@ class DashboardController extends Controller
Tproject::where('fk_tm_id', $request->tid) Tproject::where('fk_tm_id', $request->tid)
->update(['tp_timesheet_sts' => 2]); ->update(['tp_timesheet_sts' => 2]);
$user = Staff_info::where('fk_users', Auth::id())
->with('penyokongpm')
->first();
if( $roleid == '8' ) if( $roleid == '8' )
{ {
......
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