Commit 61bc6f97 by hannan

changes in timesheet viewer, update on chargeable and overhead viewer

parent c5dacab1
......@@ -11,33 +11,25 @@
<table class="ui unstackable collapsing table">
<tbody>
<tr>
<td rowspan="4">
<td rowspan="3">
<img src="https://www.3fresources.com/app/themes/3f/images/3f-logo.svg" height="126" width="126" alt="3f-logo">
</td>
<td>Name</td>
<td>:</td>
<td>Azhan Hannan</td>
<td rowspan="4"></td>
<td>{{ $user->fullname }}</td>
<td rowspan="3"></td>
<td>Department</td>
<td>:</td>
<td>PSS</td>
<td rowspan="4"></td>
<td>{{ $dept->description }}</td>
<td rowspan="3"></td>
</tr>
<tr>
<td>Staff No</td>
<td>:</td>
<td>999</td>
<td>{{ $user->staff_id }}</td>
<td>Reporting Manager</td>
<td>:</td>
<td>En. Faizal</td>
</tr>
<tr>
<td>Designation</td>
<td>:</td>
<td>Intern</td>
<td></td>
<td></td>
<td></td>
<td>{{ $hod }}</td>
</tr>
<tr>
<td>Month</td>
......@@ -46,8 +38,19 @@
<div class="ui form">
<div class="field">
<select class="ui search dropdown">
<option value="" selected="">{{$strMonth}}</option>
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
<option value="7">July</option>
<option value="8">August</option>
<option value="9">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
</div>
</div>
......@@ -58,8 +61,13 @@
<div class="ui form">
<div class="field">
<select class="ui search dropdown">
<option value="1">1</option>
@if($phase == 1)
<option value="{{ $phase }}">{{ $phase }}</option>
<option value="2">2</option>
@else
<option value="{{ $phase }}">{{ $phase }}</option>
<option value="1">1</option>
@endif
</select>
</div>
</div>
......@@ -73,15 +81,16 @@
<table class="ui celled structured table unstackable">
<thead>
<tr>
<th colspan="2">Chargeable</th>
<th colspan="3">Chargeable</th>
<th colspan="@if($phase == 1) 15 @else {{$daymonth-15}} @endif" class="center aligned">Date</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>Project Code</td>
<td>Project Name</td>
<td style="width: 3%;"></td>
<td style="width: 10%;">Project Code</td>
<td style="width: 13%;">Project Name</td>
@if($phase == 1)
@for($i = 0; $i < 15 ; $i++)
......@@ -95,18 +104,230 @@
@endif
<td>Total Hours</td>
</tr>
@foreach($chargeablelist as $key => $projectchargeable)
<?php $total = 0; ?>
<tr>
<td style="width: 3%;"></td>
<td style="width: 10%;">{{ $projectchargeable['pcode']}}</td>
<td style="width: 13%;">{{ $projectchargeable['pname']}}</td>
@if($phase == 1)
@for($i = 0; $i < 15 ; $i++)
<?php
$valchargehour = '';
$date = $year.'-'.sprintf('%02d', $month).'-'.sprintf('%02d', $i+1);
if($chargehour)
{
$valchargehour = $chargehour->where('td_date','=',$date)
->where('td_project',$projectchargeable['pid'])
->where('tm_phase',$phase)
->first();
$total += data_get($valchargehour,'td_hours');
}
?>
@if($valchargehour)
<td>{{ $valchargehour->td_hours }}</td>
@else
<td></td>
@endif
@endfor
@else
@for($i = 15; $i < $daymonth; $i++)
<?php
$valchargehour = '';
$date = $year.'-'.sprintf('%02d', $month).'-'.sprintf('%02d', $i+1);
if($chargehour)
{
$valchargehour = $chargehour->where('td_date','=',$date)
->where('td_project',$projectchargeable['pid'])
->where('tm_phase',$phase)
->first();
$total += data_get($valchargehour,'td_hours');
}
?>
@if($valchargehour)
<td>{{ $valchargehour->td_hours }}</td>
@else
<td></td>
@endif
@endfor
@endif
@if($valchargehour)
<td>{{ $total }}</td>
@else
<td>0</td>
@endif
</tr>
@endforeach
</tbody>
<tfoot>
<th colspan="@if($phase == 1) 18 @else {{$daymonth-18}} @endif">Total</th>
<th>{{ $totalchargehrs }}</th>
</tfoot>
</table>
</div>
<div class="ui segment">
Non Chargeable
<table class="ui celled structured table unstackable">
<thead>
<tr>
<th colspan="2">Non-Chargeable</th>
<th colspan="@if($phase == 1) 15 @else {{$daymonth-15}} @endif" class="center aligned">Date</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td style="width: 3%;"></td>
<td style="width: 23%;">Task</td>
@if($phase == 1)
@for($i = 0; $i < 15 ; $i++)
<td>{{$i+1}}</td>
@endfor
@else
@for($i = 15; $i < $daymonth; $i++)
<td>{{$i+1}}</td>
@endfor
@endif
<td>Total Hours</td>
</tr>
</tbody>
<tfoot>
<th colspan="@if($phase == 1) 17 @else {{$daymonth-17}} @endif">Total</th>
<th>20</th>
</tfoot>
</table>
</div>
<div class="ui segment">
Overhead
<table class="ui celled structured table unstackable">
<thead>
<tr>
<th colspan="2">Overhead</th>
<th colspan="@if($phase == 1) 15 @else {{$daymonth-15}} @endif" class="center aligned">Date</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td style="width: 3%;"></td>
<td style="width: 23%;">Overhead</td>
@if($phase == 1)
@for($i = 0; $i < 15 ; $i++)
<td>{{$i+1}}</td>
@endfor
@else
@for($i = 15; $i < $daymonth; $i++)
<td>{{$i+1}}</td>
@endfor
@endif
<td>Total Hours</td>
</tr>
@foreach($overheadlist as $key => $projectoverhead)
<?php $total = 0; ?>
<tr>
<td style="width: 3%;"></td>
<td style="width: 10%;">{{ $projectoverhead['pname']}}</td>
@if($phase == 1)
@for($i = 0; $i < 15 ; $i++)
<?php
$valoverheadhour = '';
$date = $year.'-'.sprintf('%02d', $month).'-'.sprintf('%02d', $i+1);
if($overheadhour)
{
$valoverheadhour = $overheadhour->where('td_date','=',$date)
->where('fk_o_id',$projectoverhead['pid'])
->where('tm_phase',$phase)
->first();
$total += data_get($valoverheadhour,'td_hours');
}
?>
@if($valoverheadhour)
<td>{{ $valoverheadhour->td_hours }}</td>
@else
<td></td>
@endif
@endfor
@else
@for($i = 0; $i < 15 ; $i++)
<?php
$valoverheadhour = '';
$date = $year.'-'.sprintf('%02d', $month).'-'.sprintf('%02d', $i+1);
if($overheadhour)
{
$valoverheadhour = $overheadhour->where('td_date','=',$date)
->where('fk_o_id',$projectoverhead['pid'])
->where('tm_phase',$phase)
->first();
$total += data_get($valoverheadhour,'td_hours');
}
?>
@if($valoverheadhour)
<td>{{ $valoverheadhour->td_hours }}</td>
@else
<td></td>
@endif
@endfor
@endif
@if($valchargehour)
<td>{{ $total }}</td>
@else
<td>0</td>
@endif
</tr>
@endforeach
</tbody>
<tfoot>
<th colspan="@if($phase == 1) 17 @else {{$daymonth-17}} @endif">Total</th>
<th>{{ $totaloverheadhrs }}</th>
</tfoot>
</table>
</div>
<div class="ui segment">
Notes
<table class="ui celled structured table unstackable">
<thead>
<tr>
<th colspan="2">Note:</th>
</tr>
</thead>
<tbody>
<tr>
<td style="width: 13.5%;">Date</td>
<td>Description</td>
</tr>
</tbody>
</table>
</div>
</div>
......
......@@ -75,7 +75,6 @@ input[type=number] {
</tr>
</thead>
<tbody>
@foreach($projectlist as $key => $project)
<?php $total = 0; ?>
<tr>
......
......@@ -85,7 +85,7 @@ class DashboardController extends Controller
return view('timesheet::dashboard.timesheetReview');
}
public function timesheetViewer()
public function timesheetViewer(Request $request)
{
$user = Staff_info::where('fk_users', Auth::id())
->first();
......@@ -93,21 +93,13 @@ class DashboardController extends Controller
$dept = Department::where('id', $user->fk_lkp_department)
->first();
// $udetail[] = [
// 'name' => $user->fullname,
// 'staffno' => $user->staff_id,
// 'dept' => $dept->description,
// ];
// dd($udetail['0']['name']);
$date = Carbon::now();
$hod = Staff_info::find($user->penyokong)
->fullname;
$month = date('n');
$year = date('Y');
$day = date('j');
// $day = 16;
if ($day < 16) {
$phase = 1;
} else {
......@@ -118,10 +110,8 @@ class DashboardController extends Controller
$myDate = $month.'/'.$day.'/'.$year;
$date = Carbon::createFromFormat('m/d/Y', $myDate);
$strMonth = $date->format('F');
if(isset($request->phase))
{
$phase = $request->phase;
......@@ -137,8 +127,78 @@ class DashboardController extends Controller
$year = $request->year;
}
$chargeable = 1;
$nonchargeable = 2;
$overhead = 3;
$chargeableproject = Pteam::where('pt_staff_id',$user->staff_id)
->where('pt_project_type', $chargeable)
->get();
$overheadproject = Overhead::where('o_overhead_sts',1)
->get();
$chargeablelist = [];
$overheadlist = [];
foreach($chargeableproject as $key => $value) {
$chargeablelist[] = [
'pid' => $value->fk_project_id,
'pcode' => $value->toProject->p_project_code,
'pname' => $value->toProject->p_project_description,
];
}
foreach ($overheadproject as $key => $value) {
$overheadlist[] = [
'pid' => $value->id,
'pname' => $value->o_overhead_desc,
];
}
$check = Ts_master::where('tm_staff_id', $user->staff_id)
->where('tm_year', $year)
->where('tm_month', $month)
->where('tm_phase', $phase)
->first();
if($check)
{
$chargehour = Ts_detail::where('fk_tm_id',$check->id)
->where('td_project_type', $chargeable)
->get();
$nonchargehour = Ts_detail::where('fk_tm_id',$check->id)
->where('td_project_type', $nonchargeable)
->get();
$overheadhour = Ts_detail::where('fk_tm_id',$check->id)
->where('td_project_type', $overhead)
->get();
}
else
{
$chargehour = null;
$nonchargehour = null;
$overheadhour = null;
}
$totalchargehrs = $check->tm_chargeable_hrs;
$totalnonchargehrs = $check->tm_nonchargeable_hrs;
$totaloverheadhrs = $check->tm_overhead_hrs;
return view('timesheet::dashboard.timesheetViewer', compact('user', 'dept', 'phase', 'month', 'year', 'day', 'strMonth', 'daymonth'));
return view('timesheet::dashboard.timesheetViewer', compact('user', 'dept', 'hod', 'phase', 'month', 'year', 'day', 'strMonth', 'daymonth', 'chargeablelist', 'overheadlist', 'chargehour', 'totalchargehrs', 'totalnonchargehrs', 'totaloverheadhrs', 'overheadhour'));
}
......
......@@ -210,12 +210,12 @@ class FormController extends Controller
}
}
//update total ke master;
//buat query sum td_hours where condition :
$sumdetailhour = Ts_detail::where('td_project_type', $chargeable)
->where('tm_year', $request->year)
->where('tm_month', $request->month)
->where('tm_phase', $request->phase)
->where('tm_staff_id', $userId)
->sum('td_hours');
// checktotalhours
$checktotalhours = Ts_master::where('id', $tmasterid)->first();
$checktotalhours->tm_chargeable_hrs = $sumdetailhour;
......@@ -586,7 +586,6 @@ class FormController extends Controller
if($check)
{
$hour = Ts_detail::where('fk_tm_id',$check->id)
// ->with('project:p_project_code')
->get();
// dd($hour);
}
......
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