Commit 4b9c1506 by Azhan Hannan

Suggestion to display hours overhead when user fills in the chargeable form and…

Suggestion to display hours overhead when user fills in the chargeable form and display chargeable hours details when user fills in the overhead for, for user to refer.
parent 33df299c
......@@ -27,7 +27,7 @@ input[type=number] {
<br>
@if($lastupdated)
<div class="ui right floated center compact aligned basic right button">
<div class="tiny ui right floated center compact aligned basic right button">
<div class="header item" style="color: #000000;">
<strong>
Last Updated : {{ date('d/m/Y', strtotime(data_get($lastupdated,'updated_at'))) }}
......@@ -36,7 +36,7 @@ input[type=number] {
</div>
@endif
<div class="ui right floated center compact aligned basic right button">
<div class="tiny ui right floated center compact aligned basic right button">
<div class="header item" style="color: #000000;">
<strong>
@if($phase == 1) 1st Halfmonth @else 2nd Half-month @endif - {{ date("F", mktime(0, 0, 0, $month, 10)) }} - {{ $year }}
......@@ -44,16 +44,180 @@ input[type=number] {
</div>
</div>
<button class="center aligned ui purple right compact labeled icon button" onclick="window.location.href='{{ route('timesheet::form.overheadForm', ['phase' => $phase, 'month' => $month, 'year' => $year]) }}';">
<button class="tiny center aligned ui purple right compact labeled icon button" onclick="window.location.href='{{ route('timesheet::form.overheadForm', ['phase' => $phase, 'month' => $month, 'year' => $year]) }}';">
<i class="angle double right icon"></i>
Go to Overhead Form
</button>
<a href="{{ route('timesheet::dashboard.timesheetViewer', ['phase' => $phase, 'month' => $month, 'year' => $year]) }}" class="center aligned ui pink right compact labeled icon button" target="_blank">
<a href="{{ route('timesheet::dashboard.timesheetViewer', ['phase' => $phase, 'month' => $month, 'year' => $year]) }}" class="tiny center aligned ui pink right compact labeled icon button" target="_blank">
<i class="angle double right icon"></i>
View and Submit Timesheet
</a>
<br>
<!-- <br> -->
<!-- overhead detail start -->
<table id="printtable4" class="ui celled structured table unstackable">
<thead>
<tr>
<th colspan="" rowspan="3" class="center aligned" @if($phase == 2 && ($daymonth-15) == 16) style="width: 21.5%;" @elseif($phase == 2 && ($daymonth-15) == 13) style="width: 17.5%;" @elseif($phase == 2 && ($daymonth-15) == 14) style="width: 19%;" @else style="width: 20%;" @endif>Overhead</th>
<th colspan="@if($phase == 1) 15 @else {{$daymonth-15}} @endif" class="center aligned">Date</th>
<th colspan="" rowspan="2" class="center aligned">Total</th>
</tr>
<tr>
@if($phase == 1)
@for($i = 0; $i < 15 ; $i++)
<th style="width: 4%;">{{$i+1}}</th>
@endfor
@else
@for($i = 15; $i < $daymonth; $i++)
<th style="width: 4%;">{{$i+1}}</th>
@endfor
@endif
</tr>
<tr>
@if($phase == 1)
@for($i = 0; $i < 15 ; $i++)
<th>{{$strdays[$i]}}</th>
@endfor
@else
@for($i = 15; $i < $daymonth; $i++)
<th>{{$strdays[$i]}}</th>
@endfor
@endif
<th>Hours</th>
<!-- <th>Days</th> -->
</tr>
</thead>
<tbody>
@if(count($overheadlist) > 0)
@foreach($overheadlist as $key => $projectoverhead)
<?php
$totaloverhead = 0;
?>
<tr>
<!-- <td style="width: 4%;"></td> -->
<td style="width: 20%;">{{ $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();
$totaloverhead += data_get($valoverheadhour,'td_hours');
}
?>
@if($valoverheadhour)
<td style="width: 4%;">{{ data_get($valoverheadhour,'td_hours') }}</td>
@else
<td style="width: 4%;"></td>
@endif
@endfor
@else
@for($i = 15; $i < $daymonth ; $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();
$totaloverhead += data_get($valoverheadhour,'td_hours');
}
?>
@if($valoverheadhour)
<td style="width: 4%;">{{ data_get($valoverheadhour,'td_hours') }}</td>
@else
<td style="width: 4%;"></td>
@endif
@endfor
@endif
@if($totaloverhead)
<td style="width: 5%">{{ number_format($totaloverhead, 1, '.', '') }}</td>
<!-- <td style="width: 5%">{{ number_format($totaloverhead/8, 1, '.', '') }}</td> -->
@else
<td style="width: 5%">0.0</td>
<!-- <td style="width: 5%">0.0</td> -->
@endif
</tr>
@endforeach
@else
<tr>
<td class="text-center" colspan="@if($phase==1){{4+15}} @else {{4+($daymonth-15)}} @endif">No Data Overhead</td>
</tr>
@endif
</tbody>
<tfoot>
<th colspan="">Total (Overhead)</th>
<?php $totaloverheadall = 0; ?>
@if($phase == 1)
@for($i = 0; $i < 15 ; $i++)
<?php
$totaloverheadbyday = 0;
$date = $year.'-'.sprintf('%02d', $month).'-'.sprintf('%02d', $i+1);
if ($overheadhour) {
$valoverheadbyday = $overheadhour->where('td_date','=', $date)
->where('tm_phase',$phase);
foreach($valoverheadbyday as $key => $value) {
$totaloverheadbyday += data_get($value,'td_hours');
}
$totaloverheadall += $totaloverheadbyday;
}
?>
<th style="width: 4%">{{ number_format($totaloverheadbyday, 1, '.', '') }}</th>
@endfor
@else
@for($i = 15; $i < $daymonth; $i++)
<?php
$totaloverheadbyday = 0;
$date = $year.'-'.sprintf('%02d', $month).'-'.sprintf('%02d', $i+1);
if ($overheadhour) {
$valoverheadbyday = $overheadhour->where('td_date','=', $date)
->where('tm_phase',$phase);
foreach($valoverheadbyday as $key => $value) {
$totaloverheadbyday += data_get($value,'td_hours');
}
$totaloverheadall += $totaloverheadbyday;
}
?>
<th style="width: 4%">{{ number_format($totaloverheadbyday, '1', '.', '') }}</th>
@endfor
@endif
<?php
// dd($totaloverheadhrs);
?>
<th style="width: 5%">@if($totaloverheadall) {{ number_format($totaloverheadall, 1, '.', '') }} @else 0.0 @endif</th>
<!-- <th style="width: 5%">@if($totaloverheadall) {{ number_format($totaloverheadall/8, 1, '.', '') }} @else 0.0 @endif</th> -->
</tfoot>
</table>
<!-- overhead detail end -->
<form class="ui form" action="{{ route('timesheet::form.savechargeablehours' )}}" method="POST">
{{csrf_field()}}
<!-- <input type="text" disabled="disabled" name="" value="{{$year}}"> -->
......@@ -70,7 +234,7 @@ input[type=number] {
<th colspan="2" rowspan="2" class="center aligned">Chargeable</th>
<!-- <th colspan="{{count($lat)}}" class="center aligned">Date</th> -->
<th colspan="@if($phase == 1) 15 @else {{$daymonth-15}} @endif" class="center aligned">Date</th>
<th rowspan="2">
<th rowspan="2" class="center aligned">Total
<!-- @if($projectlist == [])
<button type="submit" class="ui disabled fluid center aligned ui blue compact labeled icon button">
<i class="save icon"></i>
......@@ -163,7 +327,6 @@ input[type=number] {
<?php
$all = 0;
$lasttd = count($projectlist);
// dd($lat);
?>
@if(count($projectlist) > 0)
@foreach($projectlist as $key => $project)
......
......@@ -23,16 +23,16 @@ input[type=number] {
<div class="ui segment">
<a class="ui purple left ribbon label">
<h3>
<!-- <h3> -->
Overhead Form
</h3>
<!-- </h3> -->
</a>
<br>
<br>
@if($lastupdated)
<div class="ui right floated center compact aligned basic right button">
<div class="tiny ui right floated center compact aligned basic right button">
<div class="header item" style="color: #000000;">
<strong>
Last Updated : {{ date('d/m/Y', strtotime(data_get($lastupdated,'updated_at'))) }}
......@@ -41,7 +41,7 @@ input[type=number] {
</div>
@endif
<div class="ui right floated center compact aligned basic right button">
<div class="tiny ui right floated center compact aligned basic right button">
<div class="header item" style="color: #000000;">
<strong>
@if($phase == 1) 1st Halfmonth @else 2nd Half-month @endif - {{ date("F", mktime(0, 0, 0, $month, 10)) }} - {{ $year }}
......@@ -49,23 +49,192 @@ input[type=number] {
</div>
</div>
<button class="center aligned ui blue compact labeled icon button" onclick="window.location.href='{{ route('timesheet::form.chargeableForm', ['phase' => $phase, 'month' => $month, 'year' => $year]) }}';">
<button class="tiny center aligned ui blue compact labeled icon button" onclick="window.location.href='{{ route('timesheet::form.chargeableForm', ['phase' => $phase, 'month' => $month, 'year' => $year]) }}';">
<i class="angle double left icon"></i>
Go to Chargeable Form
</button>
@if($checkoverhead)
<button class="center 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] ) }} ';">
<button class="tiny center 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] ) }} ';">
<i class="plus icon"></i>
Add Task Description
</button>
@else
@endif
<a href="{{ route('timesheet::dashboard.timesheetViewer', ['phase' => $phase, 'month' => $month, 'year' => $year]) }}" class="center aligned ui pink compact right labeled icon button" target="_blank">
<a href="{{ route('timesheet::dashboard.timesheetViewer', ['phase' => $phase, 'month' => $month, 'year' => $year]) }}" class="tiny center aligned ui pink compact right labeled icon button" target="_blank">
<i class="angle double right icon"></i>
View and Submit Timesheet
</a>
<!-- Table Chargeable Start -->
<table id="printtable2" class="ui celled structured table unstackable">
<thead>
<tr>
<th colspan="2" rowspan="2" class="center aligned" style="width: 27%;">Chargeable</th>
<th colspan="@if($phase == 1) 15 @else {{$daymonth-15}} @endif" class="center aligned">Date</th>
<th colspan="" rowspan="2" class="center aligned">Total</th>
</tr>
<tr>
@if($phase == 1)
@for($i = 0; $i < 15 ; $i++)
<th style="width: 4%;">{{$i+1}}</th>
@endfor
@else
@for($i = 15; $i < $daymonth; $i++)
<th style="width: 4%;">{{$i+1}}</th>
@endfor
@endif
</tr>
<tr>
<!-- <th style="width: 4%;"></th> -->
<th style="width: 10%;">Project Code</th>
<th style="width: 13%;">Project Name</th>
@if($phase == 1)
@for($i = 0; $i < 15 ; $i++)
<th>{{$strdays[$i]}}</th>
@endfor
@else
@for($i = 15; $i < $daymonth; $i++)
<th>{{$strdays[$i]}}</th>
@endfor
@endif
<th>Hours</th>
<!-- <th>Days</th> -->
</tr>
</thead>
<tbody>
@if(count($chargeablelist) > 0)
@foreach($chargeablelist as $key => $projectchargeable)
<?php $totalcharge = 0; ?>
<tr>
<!-- <td style="width: 4%;"></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();
$totalcharge += data_get($valchargehour,'td_hours');
}
?>
@if($valchargehour)
<td style="width: 4%;">
@if(data_get($valchargehour,'td_hours') == 0)
@else {{ data_get($valchargehour,'td_hours') }}
@endif
</td>
@else
<td style="width: 4%;"></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();
$totalcharge += data_get($valchargehour,'td_hours');
}
?>
@if($valchargehour)
<td style="width: 4%;">
@if(data_get($valchargehour,'td_hours') == 0)
@else {{ data_get($valchargehour,'td_hours') }}
@endif
</td>
@else
<td style="width: 4%;"></td>
@endif
@endfor
@endif
@if($totalcharge)
<td style="width: 5%">{{ number_format($totalcharge, 1, '.', '') }}</td>
<!-- <td style="width: 5%">{{ number_format($totalcharge/8, 1, '.', '') }}</td> -->
@else
<td style="width: 5%">0</td>
<!-- <td style="width: 5%">0</td> -->
@endif
</tr>
@endforeach
@else
<tr>
<td class="text-center" colspan="@if($phase==1){{5+15}} @else {{5+($daymonth-15)}} @endif">No Data Project</td>
</tr>
@endif
</tbody>
<tfoot>
<th colspan="2">Total</th>
<?php $totalchargeableall = 0; ?>
@if($phase == 1)
@for($i = 0; $i < 15 ; $i++)
<?php
$totalcbyday = 0;
$date = $year.'-'.sprintf('%02d', $month).'-'.sprintf('%02d', $i+1);
if ($chargehour) {
$valcbyday = $chargehour->where('td_date','=', $date)
->where('tm_phase',$phase);
foreach($valcbyday as $key => $value) {
$totalcbyday += data_get($value,'td_hours');
}
$totalchargeableall += $totalcbyday;
}
?>
<th>{{ number_format($totalcbyday, '1', '.', '') }}</th>
@endfor
@else
@for($i = 15; $i < $daymonth; $i++)
<?php
$totalcbyday = 0;
$date = $year.'-'.sprintf('%02d', $month).'-'.sprintf('%02d', $i+1);
if ($chargehour) {
$valcbyday = $chargehour->where('td_date','=', $date)
->where('tm_phase',$phase);
foreach($valcbyday as $key => $value) {
$totalcbyday += data_get($value,'td_hours');
}
$totalchargeableall += $totalcbyday;
}
?>
<th>{{ number_format($totalcbyday, '1', '.', '') }}</th>
@endfor
@endif
<th style="width: 5%">@if($totalchargeableall){{ number_format($totalchargeableall, 1, '.', '') }}@else 0.0 @endif</th>
<!-- <th style="width: 5%">@if($totalchargeableall){{ number_format($totalchargeableall/8, 1, '.', '') }}@else 0.0 @endif</th> -->
</tfoot>
</table>
<!-- Table Chargeable End -->
<form class="ui form" action="{{ route('timesheet::form.saveoverheadhours' )}}" method="POST">
{{csrf_field()}}
<input type="hidden" name="userId" value="{{$userId}}">
......@@ -76,11 +245,11 @@ input[type=number] {
<table class="ui celled structured unstackable table" >
<thead>
<tr>
<th rowspan="3" class="center aligned">Overhead</th>
<th rowspan="3" class="center aligned" style="width: 27%;">Overhead</th>
<!-- <th colspan="{{count($lat)}}" class="center aligned">Date</th> -->
<th colspan="@if($phase == 1) 15 @else {{$daymonth-15}} @endif" class="center aligned">Date</th>
<th rowspan="2">
<th rowspan="2" class="center aligned" style="width: 10%;">Total
<!-- <button type="submit" class="fluid center aligned ui blue compact labeled icon button">
<i class="save icon"></i>
Save as Draft
......
......@@ -1667,7 +1667,8 @@ class DashboardController extends Controller
public function timesheetViewer(Request $request)
{
// dd($request->month);
// dd($request);
$curruser = $user = Staff_info::where('fk_users', Auth::id())
->first();
......
......@@ -113,15 +113,11 @@ class FormController extends Controller
$userId = users::find(Auth::id())
->u_staffID;
$project = Pteam::where('pt_staff_id',$userId)
->where('pt_project_type', $chargeable)
->where('pt_project_task_sts', 1)
->with('toProject')
->get();
// dd('hi');
// dd($project);
$projectlist = [];
......@@ -179,6 +175,7 @@ class FormController extends Controller
->where('tm_year', $year)
->where('tm_month', $month)
->where('tm_phase', $phase)
->with('attachement')
->first();
if($check)
......@@ -220,7 +217,57 @@ class FormController extends Controller
// dd(date_parse_from_format('Y-m-d', data_get($lat1,'DATE'))['day']);
// dd(date('d'));
return view('timesheet::form.chargeableForm', compact('projectlist','userId','month','phase','daymonth','year', 'hour', 'strdays', 'lat', 'check', 'lastupdated'));
// display overhead
$overhead = 3;
$overheadlist = [];
if($check)
{
$overheadhour = Ts_detail::where('fk_tm_id',$check->id)
->where('td_project_type', $overhead)
->where('td_hours', '!=', 0)
// ->groupby('fk_o_id')
->get();
$ovlist = Ts_detail::where('fk_tm_id',$check->id)
->where('td_project_type', $overhead)
->where('td_hours', '!=', 0)
->groupby('fk_o_id')
->orderby('fk_o_id', 'asc')
->get();
foreach ($ovlist as $key => $value)
{
$overheadlist[] = [
'pid' => data_get($value,'fk_o_id') ,
'pname' => data_get($value,'td_overhead_desc'),
];
}
$totalchargehrs = $check->tm_chargeable_hrs;
$totaloverheadhrs = $check->tm_overhead_hrs;
$notes = Ts_detail::where('tm_year', $year)
->where('tm_month', $month)
->where('tm_phase', $phase)
->where('fk_tm_id', $check->id)
->where('tm_staff_id', $userId)
->where('td_project_type', $overhead)
->whereNotNull('td_hours')
->orderby('td_date')
->get();
}
else
{
$chargehour = null;
$overheadhour = null;
$totalchargehrs = null;
$totaloverheadhrs = null;
$notes = null;
$check = null;
}
return view('timesheet::form.chargeableForm', compact('projectlist','userId','month','phase','daymonth','year', 'hour', 'strdays', 'lat', 'check', 'lastupdated', 'overheadlist', 'overheadhour'));
}
public function savechargeablehours(Request $request)
......@@ -1481,7 +1528,59 @@ class FormController extends Controller
$fk_tm_id = null;
}
return view('timesheet::form.overheadForm', compact('checkoverhead','projectlist','userId','month','phase','daymonth','year', 'hour', 'project', 'fk_tm_id', 'strdays', 'lat', 'lastupdated'));
// display chargeable
// dd($year);
$chargeable = 1;
$check = Ts_master::where('tm_staff_id', $user->staff_id)
->where('tm_year', $year)
->where('tm_month', $month)
->where('tm_phase', $phase)
->with('attachement')
->first();
$chargeableproject = Tproject::where('fk_tm_id', $fk_tm_id)
->where('tp_project_type', 1)
->with('project')
->get();
// dd($chargeableproject);
$chargeablelist = [];
$overheadlist = [];
foreach($chargeableproject as $key => $value) {
$chargeablelist[] = [
'pid' => $value->td_project,
'pcode' => data_get($value,'project.p_project_code'),
'pname' => data_get($value,'project.p_project_description'),
];
}
if($check)
{
$chargehour = Ts_detail::where('fk_tm_id', $fk_tm_id)
->where('td_project_type', $chargeable)
// ->where('td_hours', '!=', 0)
->get();
$totalchargehrs = $check->tm_chargeable_hrs;
}
else
{
$chargehour = null;
$overheadhour = null;
$totalchargehrs = null;
$totaloverheadhrs = null;
$notes = null;
$check = null;
}
// end display chargeable
return view('timesheet::form.overheadForm', compact('checkoverhead','projectlist','userId','month','phase','daymonth','year', 'hour', 'project', 'fk_tm_id', 'strdays', 'lat', 'lastupdated', 'chargeablelist', 'chargehour'));
}
public function saveoverheadhours(Request $request)
......
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