Commit eaf562e1 by Azhan Hannan

select approval and approve all pages

parent 37a1a6de
......@@ -338,6 +338,7 @@
@endif
</div>
<div class="ui segment">
<form action="{{ route('timesheet::dashboard.approval') }}" method="POST" class="ui form">
{{csrf_field()}}
......@@ -367,7 +368,7 @@
<div class="two fields">
<div class="field">
<input type="hidden" name="approval" value="{{ data_get($bod,'id') }}">
<label>Pelulus</label>
<label>Approver</label>
<input type="text" readonly="readonly" value="{{ data_get($bod,'name') }}">
</div>
<div class="field">
......
@extends('ui::layouts.app')
@section('content')
<div class="ui segment">
<a class="ui green left ribbon label">Project Approval</a>
<a class="ui right floated center aligned teal compact button" href="{{ route('timesheet::dashboard.timesheetViewer', [ 'user'=>data_get($staff,'STAFF_ID') ,'phase' => $phase, 'month' => $month , 'year' => $year ]) }}" target="_blank">View Timesheet</a>
<br>
<table class="ui unstackable collapsing table" style="width: 100%">
<tbody>
<tr>
<td rowspan="3">
<img src="{{ url('img/3f-logo.svg') }}" height="126" width="126" alt="3f-logo">
</td>
<td>Name</td>
<td>:</td>
<td>{{ data_get($staff,'STAFF_NAME') }}</td>
<td rowspan="3"></td>
<td>Department</td>
<td>:</td>
<td>{{ data_get($staff,'DEPARTMENT') }}</td>
<td rowspan="3"></td>
</tr>
<tr>
<td>Staff No</td>
<td>:</td>
<td>{{ data_get($staff,'STAFF_ID') }}</td>
<td>Reporting Manager</td>
<td>:</td>
<td>{{ data_get($staff,'HOD_NAME') }}</td>
</tr>
<tr>
<td>Month</td>
<td>:</td>
<td>{{ $strMonth }}</td>
<td>Phase</td>
<td>:</td>
<td>
@if($phase == 1) 1st Half-month
@else 2nd Half-month
@endif
</td>
</tr>
</tbody>
</table>
@if(count($chargeablelist) > 0)
<table class="ui celled structured table unstackable">
<thead>
<tr>
<th colspan="3" rowspan="2" class="center aligned">Chargeable</th>
<th colspan="@if($phase == 1) 15 @else {{$daymonth-15}} @endif" class="center aligned">Date</th>
<th colspan="2" rowspan="2" class="center aligned">Total</th>
</tr>
<tr>
@if($phase == 1)
@for($i = 0; $i < 15 ; $i++)
<th>{{$i+1}}</th>
@endfor
@else
@for($i = 15; $i < $daymonth; $i++)
<th>{{$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>
@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)
{
// dd('masuk');
// dd($chargehour);
$valchargehour = $chargehour->where('td_date','=',$date)
->where('td_project',$projectchargeable['pid'])
->where('tm_phase',$phase)
->first();
$totalcharge += data_get($valchargehour,'td_hours');
// dump($totalcharge);
}
// dump($valchargehour);
?>
@if($valchargehour)
<td style="width: 4%;">{{ data_get($valchargehour,'td_hours') }}</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%;">{{ data_get($valchargehour,'td_hours') }}</td>
@else
<td style="width: 4%;"></td>
@endif
@endfor
@endif
@if($totalcharge)
<td>{{ number_format($totalcharge, 1, '.', '') }}</td>
<td>{{ number_format($totalcharge/8, 1, '.', '') }}</td>
@else
<td>0</td>
<td>0</td>
@endif
</tr>
@endforeach
</tbody>
<!-- <tfoot>
<th colspan="3">Total (A)</th>
@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');
}
}
?>
<th>{{ $totalcbyday }}</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');
}
}
?>
<th>{{ $totalcbyday }}</th>
@endfor
@endif
<th>@if($totalchargehrs){{ $totalchargehrs }}@else 0 @endif</th>
<th>@if($totalchargehrs){{ number_format($totalchargehrs/8, 1, '.', '') }}@else 0 @endif</th>
</tfoot> -->
</table>
@endif
@if(count($overheadlist) > 0)
<table class="ui celled structured table unstackable">
<thead>
<tr>
<th colspan="2" rowspan="3" class="center aligned" style="width: 27%;">Overhead</th>
<th colspan="@if($phase == 1) 15 @else {{$daymonth-15}} @endif" class="center aligned">Date</th>
<th colspan="2" 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>
@foreach($overheadlist as $key => $projectoverhead)
<?php $totaloverhead = 0; ?>
<tr>
<td style="width: 4%;"></td>
<td style="width: 23%;">{{ $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)
{
// dd('masuk');
$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</td>
<td style="width: 5%">0</td>
@endif
</tr>
@endforeach
</tbody>
<!-- <tfoot>
<th colspan="2">Total (B)</th>
@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');
}
}
?>
<th style="width: 4%">{{ $totaloverheadbyday }}</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');
}
}
?>
<th style="width: 4%">{{ $totaloverheadbyday }}</th>
@endfor
@endif
<th style="width: 5%">@if($totaloverheadhrs) {{ number_format($totaloverheadhrs, 1, '.', '') }} @else 0 @endif</th>
<th style="width: 5%">@if($totaloverheadhrs) {{ number_format($totaloverheadhrs/8, 1, '.', '') }} @else 0 @endif</th>
</tfoot> -->
</table>
@endif
</div>
<div class="ui segment">
<form action="{{ route('timesheet::dashboard.approvalall') }}" method="POST" class="ui form">
{{csrf_field()}}
<input type="hidden" name="page" value="{{$page}}">
<input type="hidden" name="tmid" value="{{data_get($tm,'id')}}">
@foreach($chargeableproject as $key => $value)
<input type="hidden" name="cid[{{$key}}]" value="{{ data_get($value,'id') }}">
@endforeach
@foreach($overheadproject as $key => $value)
<input type="hidden" name="oid[{{$key}}]" value="{{ data_get($value,'id') }}">
@endforeach
<div class="two fields">
<div class="field">
<input type="hidden" name="approval" value="{{ data_get($bod,'id') }}">
<label>Approver</label>
<input type="text" readonly="readonly" value="{{ data_get($bod,'name') }}">
</div>
<div class="field">
<label>Action</label>
<select class="ui fluid dropdown" name="action">
<option value="1">Approval</option>
<option value="2">Reject</option>
</select>
</div>
</div>
<div class="field">
<label>Remarks</label>
<textarea rows="3" name="remarks"></textarea>
</div>
<button class="ui green button" type="submit">Submit</button>
</form>
</div>
@endsection
\ No newline at end of file
......@@ -54,7 +54,10 @@
</div>
<div class="content" style="padding-top: 0px;">
<form class="ui form" action="{{ route('timesheet::dashboard.selectapproval') }}" method="POST">
{{csrf_field()}}
<input type="hidden" name="tmid" value="{{data_get($staff,'tmid')}}">
<input type="hidden" name="page" value="{{$page}}">
@if($checkchargeable)
<table class="ui unstackable celled table">
<thead>
......@@ -71,9 +74,23 @@
</thead>
@if($detail->where('tp_project_type', 1))
@foreach($detail->where('tp_project_type', 1) as $key => $chargeable)
<?php
// dd($chargeable);
?>
@if(data_get($staff,'tmid') == data_get($chargeable,'fk_tm_id'))
<tr>
<td style="width: 10%;">{{ data_get($chargeable, 'project.p_project_code') }}</td>
<td style="width: 10%;" class="single line">
@if(data_get($chargeable,'tp_timesheet_sts') == 3)
<div class="ui toggle checkbox">
<input type="checkbox" name="pid[{{data_get($chargeable,'id')}}]" value="{{data_get($chargeable,'id')}}">
</div>
@else
<div class="ui toggle checkbox">
<input type="checkbox" disabled="disabled">
</div>
@endif
{{ data_get($chargeable, 'project.p_project_code') }}
</td>
<td style="width: 15%;">{{ data_get($chargeable, 'tp_project_name') }}</td>
<td style="width: 10%;" class="center aligned">{{ data_get($chargeable, 'tp_hours') }}</td>
<td style="width: 10%;" class="center aligned">{{ number_format(data_get($chargeable, 'tp_hours')/8, 1, '.', '') }}</td>
......@@ -121,7 +138,18 @@
@foreach($detail->where('tp_project_type', 3) as $key => $overhead)
@if(data_get($staff,'tmid') == data_get($overhead,'fk_tm_id'))
<tr>
<td style="width: 25%;">{{ data_get($overhead, 'tp_project_name') }}</td>
<td style="width: 25%;" class="single line">
@if(data_get($overhead,'tp_timesheet_sts') == 3)
<div class="ui toggle checkbox">
<input type="checkbox" name="pid[{{data_get($overhead,'id')}}]" value="{{data_get($overhead,'id')}}">
</div>
@else
<div class="ui toggle checkbox">
<input type="checkbox" disabled="disabled">
</div>
@endif
{{ data_get($overhead, 'tp_project_name') }}
</td>
<td style="width: 10%;" class="center aligned">{{ data_get($overhead, 'tp_hours') }}</td>
<td style="width: 10%;" class="center aligned">{{ number_format(data_get($overhead, 'tp_hours')/8, 1, '.', '') }}</td>
<td style="width: 15%;">{{data_get($overhead, 'verifier_remark')}}</td>
......@@ -138,11 +166,11 @@
</td>
<td style="width: 10%;" class="text-center single line">
@if(data_get($overhead, 'tp_timesheet_sts') == 3)
<button class="center aligned ui green icon button" onclick="window.location.href='{{ route('timesheet::dashboard.approvalaction', ['tpid'=>data_get($overhead, 'id'), 'phase'=>data_get($overhead, 'tp_phase'), 'month'=>data_get($overhead, 'tp_month'), 'year'=>data_get($overhead, 'tp_year'), 'page'=>$page ]) }}';">Approval</button>
<button type="button" class="center aligned ui green icon button" onclick="window.location.href='{{ route('timesheet::dashboard.approvalaction', ['tpid'=>data_get($overhead, 'id'), 'phase'=>data_get($overhead, 'tp_phase'), 'month'=>data_get($overhead, 'tp_month'), 'year'=>data_get($overhead, 'tp_year'), 'page'=>$page ]) }}';">Approval</button>
@else
<button class="center aligned ui green icon button disabled">Approval</button>
<button type="button" class="center aligned ui green icon button disabled">Approval</button>
@endif
<button class="center aligned ui blue icon button" onclick="window.location.href='{{ route('timesheet::dashboard.timesheetViewer', [ 'user'=>data_get($staff,'staffid') ,'phase' => data_get($staff,'phase'), 'month' => data_get($staff,'month'), 'year' => data_get($staff,'year')]) }}';" target='_blank'>View</button>
<a href="{{ route('timesheet::dashboard.timesheetViewer', [ 'user'=>data_get($staff,'staffid') ,'phase' => data_get($staff,'phase'), 'month' => data_get($staff,'month'), 'year' => data_get($staff,'year')]) }}" type="button" class="center aligned ui blue icon button" target='_blank'>View</a>
</td>
</tr>
@endif
......@@ -247,6 +275,11 @@
</tbody>
</table>
@endif
<button type="submit" class="center aligned ui green icon button">Approve</button>
<button type="button" class="center aligned ui green icon button" onclick="window.location.href='{{ route('timesheet::dashboard.approveallaction', ['tmid'=>data_get($staff, 'tmid'), 'phase'=>data_get($staff, 'phase'), 'month'=>data_get($staff, 'month'), 'year'=>data_get($staff, 'year'), 'page'=>$page ]) }}';">Approve All</button>
</form>
</div>
@endif
......
@extends('ui::layouts.app')
@section('content')
<div class="ui segment">
<a class="ui green left ribbon label">Timesheet Approval</a>
<a class="ui right floated center aligned teal compact button" href="{{ route('timesheet::dashboard.timesheetViewer', [ 'user'=>data_get($staff,'STAFF_ID') ,'phase' => $phase, 'month' => $month , 'year' => $year ]) }}" target="_blank">View Timesheet</a>
<br>
<table class="ui unstackable collapsing table" style="width: 100%">
<tbody>
<tr>
<td rowspan="3">
<img src="{{ url('img/3f-logo.svg') }}" height="126" width="126" alt="3f-logo">
</td>
<td>Name</td>
<td>:</td>
<td>{{ data_get($staff,'STAFF_NAME') }}</td>
<td rowspan="3"></td>
<td>Department</td>
<td>:</td>
<td>{{ data_get($staff,'DEPARTMENT') }}</td>
<td rowspan="3"></td>
</tr>
<tr>
<td>Staff No</td>
<td>:</td>
<td>{{ data_get($staff,'STAFF_ID') }}</td>
<td>Reporting Manager</td>
<td>:</td>
<td>{{ data_get($staff,'HOD_NAME') }}</td>
</tr>
<tr>
<td>Month</td>
<td>:</td>
<td>{{ $strMonth }}</td>
<td>Phase</td>
<td>:</td>
<td>
@if($phase == 1) 1st Half-month
@else 2nd Half-month
@endif
</td>
</tr>
</tbody>
</table>
@if(count($chargeablelist) > 0)
<table class="ui celled structured table unstackable">
<thead>
<tr>
<th colspan="3" rowspan="2" class="center aligned">Chargeable</th>
<th colspan="@if($phase == 1) 15 @else {{$daymonth-15}} @endif" class="center aligned">Date</th>
<th colspan="2" rowspan="2" class="center aligned">Total</th>
</tr>
<tr>
@if($phase == 1)
@for($i = 0; $i < 15 ; $i++)
<th>{{$i+1}}</th>
@endfor
@else
@for($i = 15; $i < $daymonth; $i++)
<th>{{$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>
@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)
{
// dd('masuk');
// dd($chargehour);
$valchargehour = $chargehour->where('td_date','=',$date)
->where('td_project',$projectchargeable['pid'])
->where('tm_phase',$phase)
->first();
$totalcharge += data_get($valchargehour,'td_hours');
// dump($totalcharge);
}
// dump($valchargehour);
?>
@if($valchargehour)
<td style="width: 4%;">{{ data_get($valchargehour,'td_hours') }}</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%;">{{ data_get($valchargehour,'td_hours') }}</td>
@else
<td style="width: 4%;"></td>
@endif
@endfor
@endif
@if($totalcharge)
<td>{{ number_format($totalcharge, 1, '.', '') }}</td>
<td>{{ number_format($totalcharge/8, 1, '.', '') }}</td>
@else
<td>0</td>
<td>0</td>
@endif
</tr>
@endforeach
</tbody>
<!-- <tfoot>
<th colspan="3">Total (A)</th>
@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');
}
}
?>
<th>{{ $totalcbyday }}</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');
}
}
?>
<th>{{ $totalcbyday }}</th>
@endfor
@endif
<th>@if($totalchargehrs){{ $totalchargehrs }}@else 0 @endif</th>
<th>@if($totalchargehrs){{ number_format($totalchargehrs/8, 1, '.', '') }}@else 0 @endif</th>
</tfoot> -->
</table>
@endif
@if(count($overheadlist) > 0)
<table class="ui celled structured table unstackable">
<thead>
<tr>
<th colspan="2" rowspan="3" class="center aligned" style="width: 27%;">Overhead</th>
<th colspan="@if($phase == 1) 15 @else {{$daymonth-15}} @endif" class="center aligned">Date</th>
<th colspan="2" 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>
@foreach($overheadlist as $key => $projectoverhead)
<?php $totaloverhead = 0; ?>
<tr>
<td style="width: 4%;"></td>
<td style="width: 23%;">{{ $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)
{
// dd('masuk');
$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</td>
<td style="width: 5%">0</td>
@endif
</tr>
@endforeach
</tbody>
<!-- <tfoot>
<th colspan="2">Total (B)</th>
@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');
}
}
?>
<th style="width: 4%">{{ $totaloverheadbyday }}</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');
}
}
?>
<th style="width: 4%">{{ $totaloverheadbyday }}</th>
@endfor
@endif
<th style="width: 5%">@if($totaloverheadhrs) {{ number_format($totaloverheadhrs, 1, '.', '') }} @else 0 @endif</th>
<th style="width: 5%">@if($totaloverheadhrs) {{ number_format($totaloverheadhrs/8, 1, '.', '') }} @else 0 @endif</th>
</tfoot> -->
</table>
@endif
<div class="ui segment">
<form action="{{ route('timesheet::dashboard.approvalselected') }}" method="POST" class="ui form">
{{csrf_field()}}
<input type="hidden" name="page" value="{{$page}}">
<input type="hidden" name="tmid" value="{{data_get($tm,'id')}}">
@foreach($profile as $key => $value)
<input type="hidden" name="pid[{{$key}}]" value="{{ data_get($value,'id') }}">
@endforeach
<div class="two fields">
<div class="field">
<input type="hidden" name="approval" value="{{ data_get($bod,'id') }}">
<label>Approver</label>
<input type="text" readonly="readonly" value="{{ data_get($bod,'name') }}">
</div>
<div class="field">
<label>Action</label>
<select class="ui fluid dropdown" name="action">
<option value="1">Approval</option>
<option value="2">Reject</option>
</select>
</div>
</div>
<div class="field">
<label>Remarks</label>
<textarea rows="3" name="remarks"></textarea>
</div>
<button class="ui green button" type="submit">Submit</button>
</form>
</div>
</div>
@endsection
\ No newline at end of file
......@@ -1312,8 +1312,8 @@ class DashboardController extends Controller
$chargeablelist[] = [
'pid' => $value->td_project,
'pcode' => $value->project->p_project_code,
'pname' => $value->project->p_project_description,
'pcode' => data_get($value,'project.p_project_code'),
'pname' => data_get($value,'tp_project_name'),
];
......@@ -1551,4 +1551,580 @@ class DashboardController extends Controller
return redirect()->route('timesheet::dashboard.index')->withSuccess('Timesheet has been submitted!');
}
public function selectapproval(Request $request)
{
// dd($request->pid);
if($request->pid)
{
}
else
{
return redirect()->route('timesheet::dashboard.index')->withErrors('Please choose at lease one project for approval action');
}
$pid = [];
foreach ($request->pid as $key => $value) {
$pid[] = $value;
}
// dd($pid);
$page = data_get($request,'page');
$user = Staff_info::where('id', Auth::id())->first();
// dd($user);
$bod = Users::find(Auth::id());
$tm = Ts_master::where('id', $request->tmid)->first();
$staffid = data_get($tm,'tm_staff_id');
$profile = Tproject::whereIn('id', $pid)
->with('team')
->get();
// dd($profile);
$phase = $tm->tm_phase;
$month = $tm->tm_month;
$year = $tm->tm_year;
$staff = VwViewer::where('STAFF_ID', $tm->tm_staff_id)
->first();
$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 = [];
for ($i=0; $i < $daymonth; $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);
}
$chargeable = 1;
$overhead = 3;
$check = Ts_master::where('tm_staff_id', $tm->tm_staff_id)
->where('tm_year', $year)
->where('tm_month', $month)
->where('tm_phase', $phase)
->with('attachement')
->first();
$chargeableproject = Tproject::whereIn('id', $pid)
->where('tp_project_type', 1)
->with('project')
->get();
$chargeablelist = [];
$overheadlist = [];
foreach($chargeableproject as $key => $value) {
// dd($value);
$chargeablelist[] = [
'pid' => $value->td_project,
'pcode' => data_get($value,'project.p_project_code'),
'pname' => data_get($value,'tp_project_name'),
];
}
// dd($chargeablelist);
if($check)
{
$chargehour = Ts_detail::where('fk_tm_id',$check->id)
->where('td_project_type', $chargeable)
// ->where('td_hours', '!=', 0)
->get();
$overheadhour = Ts_detail::where('fk_tm_id',$check->id)
->where('td_project_type', $overhead)
->where('td_hours', '!=', 0)
->get();
$tempOverhead[0] = "";
$tempOverheadid[0] = 0;
if(isset($overheadhour[0]))
{
// dd('sini ke?');
$tempOverhead[0] = $overheadhour[0]->td_overhead_desc;
$tempOverheadid[0] = $overheadhour[0]->fk_o_id;
$j = 0;
for($i = 0; $i < count($overheadhour); $i++)
{
if ($tempOverhead[$j] == $overheadhour[$i]->td_overhead_desc) {
}
else
{
$j++;
$tempOverhead[$j] = $overheadhour[$i]->td_overhead_desc;
$tempOverheadid[$j] = $overheadhour[$i]->fk_o_id;
}
}
if (count($profile) > 0) {
foreach ($profile as $key => $value) {
if($value->tp_project_type == 3){
$overheadlist[] = [
'pid' => $value->fk_o_id,
'pname' => $value->tp_project_name,
];
}
}
// dd($overheadlist);
}
}
else
{
// dd('ke sini?');
}
$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', $tm->tm_staff_id)
->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::dashboard.selectapprovalpage', compact('tm' ,'phase', 'month', 'year', 'staff', 'strMonth', 'profile', 'strdays', 'overheadlist', 'overheadhour', 'totaloverheadhrs', 'chargeablelist', 'chargehour', 'totalchargehrs', 'page', 'bod', 'daymonth'));
}
public function approvalselected(Request $request)
{
// dd($request);
$pid = [];
foreach ($request->pid as $key => $value) {
$pid[] = $value;
}
// dd($pid);
$tmid = $request->tmid;
$page = data_get($request,'page');
if($request->action == 2 && $request->remarks == null)
{
$profile = Tproject::whereIn('id', $pid)
->with('team')
->get();
// dd($request);
// $tpid = $profile->id;
// $year = $profile->tp_year;
// $month = $profile->tp_month;
// $phase = $profile->tp_phase;
$bod = Users::find(Auth::id());
if(data_get($request,'page') == 1){
return redirect()->route('timesheet::dashboard.index')->with('warning', 'You wanted to reject the submission. Kindly give remarks for staff references. Thank you');
}
return redirect()->route('timesheet::dashboard.approvalaction', compact('profile', 'bod', 'tpid', 'year', 'month', 'phase'))->with('warning', 'You wanted to reject the submission. Kindly give remarks for staff references. Thank you 😊');
}
// dd($request);
if ($request->action == 1) {
$projects = Tproject::whereIn('id',$pid)
->update([
'tp_timesheet_sts' => 4,
'approver_remark' => data_get($request,'remarks')
]);
$checkprojectsapproved = Tproject::where('fk_tm_id', $tmid)
->where('tp_timesheet_sts', 4)
->get();
$totalprojects = Tproject::where('fk_tm_id', $tmid)->get();
if(count($checkprojectsapproved) == count($totalprojects))
{
Ts_master::where('id', $tmid)
->update([
'tm_timesheet_master_sts' => 4,
]);
}
if (count($pid) == 1)
{
return redirect()->route('timesheet::dashboard.index')->withSuccess('The project has been approved successfully');
}
else
{
return redirect()->route('timesheet::dashboard.index')->withSuccess('The projects has been approved successfully');
}
}
if ($request->action == 2) {
$projects = Tproject::whereIn('id',$pid)
->update([
'tp_timesheet_sts' => 5,
'approver_remark' => data_get($request,'remarks')
]);
$checkprojectsrejected = Tproject::where('fk_tm_id', $tmid)
->where('tp_timesheet_sts', 5)
->get();
$totalprojects = Tproject::where('fk_tm_id', $tmid)->get();
if(count($checkprojectsrejected) == count($totalprojects))
{
Ts_master::where('id', $tmid)
->update([
'tm_timesheet_master_sts' => 5,
]);
}
if (count($pid) == 1)
{
return redirect()->route('timesheet::dashboard.index')->withSuccess('The project has been rejected');
}
else
{
return redirect()->route('timesheet::dashboard.index')->withSuccess('The project?s has been rejected');
}
}
}
public function approveallaction(Request $request)
{
$user = Staff_info::where('id', Auth::id())->first();
$chargeableproject = Tproject::where('tp_project_type', 1)
->where('fk_tm_id', $request->tmid)
->where('tp_timesheet_sts', 3)
->where('tp_pd', $user->id)
->with('project')
->get();
$overheadproject = Tproject::where('tp_project_type', 3)
->where('fk_tm_id', $request->tmid)
->where('tp_timesheet_sts', 3)
->where('tp_pd', $user->id)
->with('overhead')
->get();
$checktp = Tproject::where('fk_tm_id', $request->tmid)
->where('tp_timesheet_sts', 3)
->where('tp_pd', $user->id)
->with('overhead')
->get();
if (count($checktp) == 0) {
return redirect()->route('timesheet::dashboard.index')->withWarning('No pending approval for the staff');
}
$tm = Ts_master::where('id', data_get($request,'tmid'))->first();
$page = data_get($request,'page');
$bod = Users::find(Auth::id());
$staffid = data_get($tm,'tm_staff_id');
// $profile = Tproject::whereIn('id', $pid)
// ->with('team')
// ->get();
// dd($profile);
$phase = $tm->tm_phase;
$month = $tm->tm_month;
$year = $tm->tm_year;
// dd($tm);
$staff = VwViewer::where('STAFF_ID', data_get($tm,'tm_staff_id'))
->first();
$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 = [];
for ($i=0; $i < $daymonth; $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);
}
// $profiles = Tproject::where('fk_tm_id', $request->tmid)
// ->where('tp_timesheet_sts', 3)
// ->with('team')
// ->get();
// dd($profiles);
$chargeable = 1;
$overhead = 3;
$check = Ts_master::where('id', $request->tmid)
->with('attachement')
->first();
$chargeablelist = [];
$overheadlist = [];
foreach($chargeableproject as $key => $value)
{
$chargeablelist[] = [
'pid' => $value->td_project,
'pcode' => data_get($value,'project.p_project_code'),
'pname' => data_get($value,'tp_project_name'),
];
}
// dd($check);
if($check)
{
$chargehour = Ts_detail::where('fk_tm_id',$check->id)
->where('td_project_type', $chargeable)
->get();
$overheadhour = Ts_detail::where('fk_tm_id',$check->id)
->where('td_project_type', $overhead)
->where('td_hours', '!=', 0)
->get();
$tempOverhead[0] = "";
$tempOverheadid[0] = 0;
if(isset($overheadhour[0]))
{
// dd('sini ke?');
$tempOverhead[0] = $overheadhour[0]->td_overhead_desc;
$tempOverheadid[0] = $overheadhour[0]->fk_o_id;
$j = 0;
for($i = 0; $i < count($overheadhour); $i++)
{
if ($tempOverhead[$j] == $overheadhour[$i]->td_overhead_desc) {
}
else
{
$j++;
$tempOverhead[$j] = $overheadhour[$i]->td_overhead_desc;
$tempOverheadid[$j] = $overheadhour[$i]->fk_o_id;
}
}
if (count($overheadproject) > 0) {
foreach ($overheadproject as $key => $value) {
if($value->tp_project_type == 3){
$overheadlist[] = [
'pid' => $value->fk_o_id,
'pname' => $value->tp_project_name,
];
}
}
// dd($overheadlist);
}
}
else
{
// dd('ke sini?');
}
$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', $tm->tm_staff_id)
->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::dashboard.approveallaction', compact('tm', 'user', 'staff', 'year', 'month', 'phase', 'strMonth', 'chargeablelist', 'daymonth', 'strdays', 'chargehour', 'totalchargehrs', 'overheadlist', 'overheadhour', 'totaloverheadhrs', 'page', 'chargeableproject', 'overheadproject', 'bod'));
}
public function approvalall(Request $request)
{
$user = Staff_info::where('id', Auth::id())->first();
if (data_get($request,'action') == 2 && data_get($request,'remarks') == null) {
// dd('sini');
return redirect()->route('timesheet::dashboard.index')->withErrors('Please enter remarks for the timesheet rejection');
}
// dd($request);
if (data_get($request,'cid')) {
$cid = [];
$cpid = [];
foreach (data_get($request,'cid') as $key => $value) {
$cid[] = $value;
$data = Tproject::where('id', $value)->first();
$cpid[] = data_get($data,'td_project');
}
}
if (data_get($request,'oid')) {
$oid = [];
$opid = [];
foreach (data_get($request,'oid') as $key => $value) {
$oid[] = $value;
$odata = Tproject::where('id', $value)->first();
$opid[] = data_get($odata,'fk_o_id');
}
}
if (data_get($request,'action') == 1)
{
if (data_get($request,'cid')) {
Tproject::whereIn('id', $cid)
->where('tp_pd', $user->id)
->update([
'tp_timesheet_sts' => 4,
'approver_remark' => data_get($request,'remark')
]);
Ts_detail::where('fk_tm_id', $request->tmid)
->whereIn('td_project', $cpid)
->update([
'td_timesheet_sts' => 4
]);
}
if (data_get($request,'oid')) {
Tproject::whereIn('id', $oid)
->where('tp_pd', $user->id)
->update([
'tp_timesheet_sts' => 4,
'approver_remark' => data_get($request,'remark')
]);
Ts_detail::where('fk_tm_id', $request->tmid)
->whereIn('fk_o_id', $opid)
->update([
'td_timesheet_sts' => 4
]);
}
$approvedprojects = Tproject::where('fk_tm_id', data_get($request,'tmid'))
->where('tp_timesheet_sts', 4)
->get();
$allprojects = Tproject::where('fk_tm_id', data_get($request,'tmid'))
->get();
// dump(count($approvedprojects));
// dd(count($allprojects));
if(count($approvedprojects) == count($allprojects))
{
Ts_master::where('id', data_get($request,'tmid'))
->update([
'tm_timesheet_master_sts' => 4
]);
}
return redirect()->route('timesheet::dashboard.index')->withSuccess('The projects has been approved successfully');
}
if (data_get($request,'action') == 2)
{
if (data_get($request,'cid')) {
Tproject::whereIn('id', $cid)
->update([
'tp_timesheet_sts' => 5,
'approver_remark' => data_get($request,'remark')
]);
Ts_detail::where('fk_tm_id', $request->tmid)
->whereIn('td_project', $cpid)
->update([
'td_timesheet_sts' => 5
]);
}
if (data_get($request,'oid')) {
Tproject::whereIn('id', $oid)
->update([
'tp_timesheet_sts' => 5,
'approver_remark' => data_get($request,'remark')
]);
Ts_detail::where('fk_tm_id', $request->tmid)
->whereIn('fk_o_id', $opid)
->update([
'td_timesheet_sts' => 5
]);
}
$rejectedprojects = Tproject::where('fk_tm_id', data_get($request,'tmid'))
->where('tp_timesheet_sts', 5)
->get();
$allprojects = Tproject::where('fk_tm_id', data_get($request,'tmid'))
->get();
// dump(count($rejectedprojects));
// dd(count($allprojects));
if(count($rejectedprojects) == count($allprojects))
{
Ts_master::where('id', data_get($request,'tmid'))
->update([
'tm_timesheet_master_sts' => 5
]);
}
return redirect()->route('timesheet::dashboard.index')->withSuccess('The project has been rejected successfully');
}
}
}
\ 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