Commit eaf562e1 by Azhan Hannan

select approval and approve all pages

parent 37a1a6de
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@if(data_get($profile,'tp_project_type') == 1) @if(data_get($profile,'tp_project_type') == 1)
<table class="ui celled structured table unstackable"> <table class="ui celled structured table unstackable">
...@@ -190,7 +190,7 @@ ...@@ -190,7 +190,7 @@
</tfoot> --> </tfoot> -->
</table> </table>
@else @else
<table class="ui celled structured table unstackable"> <table class="ui celled structured table unstackable">
<thead> <thead>
<tr> <tr>
<th colspan="2" rowspan="3" class="center aligned" style="width: 27%;">Overhead</th> <th colspan="2" rowspan="3" class="center aligned" style="width: 27%;">Overhead</th>
...@@ -338,6 +338,7 @@ ...@@ -338,6 +338,7 @@
@endif @endif
</div> </div>
<div class="ui segment"> <div class="ui segment">
<form action="{{ route('timesheet::dashboard.approval') }}" method="POST" class="ui form"> <form action="{{ route('timesheet::dashboard.approval') }}" method="POST" class="ui form">
{{csrf_field()}} {{csrf_field()}}
...@@ -367,7 +368,7 @@ ...@@ -367,7 +368,7 @@
<div class="two fields"> <div class="two fields">
<div class="field"> <div class="field">
<input type="hidden" name="approval" value="{{ data_get($bod,'id') }}"> <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') }}"> <input type="text" readonly="readonly" value="{{ data_get($bod,'name') }}">
</div> </div>
<div class="field"> <div class="field">
...@@ -385,6 +386,6 @@ ...@@ -385,6 +386,6 @@
<button class="ui green button" type="submit">Submit</button> <button class="ui green button" type="submit">Submit</button>
</form> </form>
</div> </div>
@endsection @endsection
\ No newline at end of file
@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,199 +54,232 @@ ...@@ -54,199 +54,232 @@
</div> </div>
<div class="content" style="padding-top: 0px;"> <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>
<tr>
<th style="width: 10%;">Project Code</th>
<th style="width: 15%;">Project Name</th>
<th style="width: 10%;" class="center aligned">Total Hours</th>
<th style="width: 10%;" class="center aligned">Total Days</th>
<th style="width: 15%;">PM Remarks</th>
<th style="width: 15%;">PD Remarks</th>
<th style="width: 15%;" class="center aligned">Status</th>
<th style="width: 10%;" class="center aligned">Action</th>
</tr>
</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%;" 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>
<td style="width: 15%;">{{data_get($chargeable, 'verifier_remark')}}</td>
<td style="width: 15%;">{{data_get($chargeable, 'approver_remark')}}</td>
<td style="width: 15%;" class="center aligned">
@if(data_get($chargeable, 'tp_timesheet_sts') == 1 || data_get($chargeable, 'tp_timesheet_sts') == null) In Preparation
@elseif(data_get($chargeable, 'tp_timesheet_sts') == 2) <i class="red attention icon"></i> Submitted
@elseif(data_get($chargeable, 'tp_timesheet_sts') == 3) <i class="red attention icon"></i> Verified by PM
@elseif(data_get($chargeable, 'tp_timesheet_sts') == 4) <i class="green check icon"></i>Verified by PD
@elseif(data_get($chargeable, 'tp_timesheet_sts') == 5) <i class="red attention icon"></i>Dissaproved by PD
@elseif(data_get($chargeable, 'tp_timesheet_sts') == 6) <i class="red attention icon"></i>Rejected by PM
@elseif(data_get($chargeable, 'tp_timesheet_sts') == 7) <i class="red attention icon"></i>Rejected by HR
@endif
</td>
<td style="width: 10%;" class="text-center single line">
@if(data_get($chargeable, 'tp_timesheet_sts') == 3)
<button class="center aligned ui green icon button" onclick="window.location.href='{{ route('timesheet::dashboard.approvalaction', ['tpid'=>data_get($chargeable, 'id'), 'phase'=>data_get($chargeable, 'tp_phase'), 'month'=>data_get($chargeable, 'tp_month'), 'year'=>data_get($chargeable, 'tp_year'), 'page'=>$page ]) }}';">Approval</button>
@else
<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>
</td>
</tr>
@endif
@endforeach
@endif
</table>
@endif
@if($checkchargeable) @if($checkoverhead)
<table class="ui unstackable celled table"> <table class="ui unstackable celled table">
<thead> <thead>
<tr> <tr>
<th style="width: 10%;">Project Code</th> <th style="width: 25%;">Overhead</th>
<th style="width: 15%;">Project Name</th> <th style="width: 10%;" class="center aligned">Total Hours</th>
<th style="width: 10%;" class="center aligned">Total Hours</th> <th style="width: 10%;" class="center aligned">Total Days</th>
<th style="width: 10%;" class="center aligned">Total Days</th> <th style="width: 15%;">HOD Remarks</th>
<th style="width: 15%;">PM Remarks</th> <th style="width: 15%;">BOD Remarks</th>
<th style="width: 15%;">PD Remarks</th> <th style="width: 15%;" class="center aligned">Status</th>
<th style="width: 15%;" class="center aligned">Status</th> <th style="width: 10%;" class="center aligned">Action</th>
<th style="width: 10%;" class="center aligned">Action</th> </tr>
</tr> </thead>
</thead> @if($detail->where('tp_project_type', 3))
@if($detail->where('tp_project_type', 1)) @foreach($detail->where('tp_project_type', 3) as $key => $overhead)
@foreach($detail->where('tp_project_type', 1) as $key => $chargeable) @if(data_get($staff,'tmid') == data_get($overhead,'fk_tm_id'))
@if(data_get($staff,'tmid') == data_get($chargeable,'fk_tm_id')) <tr>
<tr> <td style="width: 25%;" class="single line">
<td style="width: 10%;">{{ data_get($chargeable, 'project.p_project_code') }}</td> @if(data_get($overhead,'tp_timesheet_sts') == 3)
<td style="width: 15%;">{{ data_get($chargeable, 'tp_project_name') }}</td> <div class="ui toggle checkbox">
<td style="width: 10%;" class="center aligned">{{ data_get($chargeable, 'tp_hours') }}</td> <input type="checkbox" name="pid[{{data_get($overhead,'id')}}]" value="{{data_get($overhead,'id')}}">
<td style="width: 10%;" class="center aligned">{{ number_format(data_get($chargeable, 'tp_hours')/8, 1, '.', '') }}</td> </div>
<td style="width: 15%;">{{data_get($chargeable, 'verifier_remark')}}</td> @else
<td style="width: 15%;">{{data_get($chargeable, 'approver_remark')}}</td> <div class="ui toggle checkbox">
<td style="width: 15%;" class="center aligned"> <input type="checkbox" disabled="disabled">
@if(data_get($chargeable, 'tp_timesheet_sts') == 1 || data_get($chargeable, 'tp_timesheet_sts') == null) In Preparation </div>
@elseif(data_get($chargeable, 'tp_timesheet_sts') == 2) <i class="red attention icon"></i> Submitted @endif
@elseif(data_get($chargeable, 'tp_timesheet_sts') == 3) <i class="red attention icon"></i> Verified by PM {{ data_get($overhead, 'tp_project_name') }}
@elseif(data_get($chargeable, 'tp_timesheet_sts') == 4) <i class="green check icon"></i>Verified by PD </td>
@elseif(data_get($chargeable, 'tp_timesheet_sts') == 5) <i class="red attention icon"></i>Dissaproved by PD <td style="width: 10%;" class="center aligned">{{ data_get($overhead, 'tp_hours') }}</td>
@elseif(data_get($chargeable, 'tp_timesheet_sts') == 6) <i class="red attention icon"></i>Rejected by PM <td style="width: 10%;" class="center aligned">{{ number_format(data_get($overhead, 'tp_hours')/8, 1, '.', '') }}</td>
@elseif(data_get($chargeable, 'tp_timesheet_sts') == 7) <i class="red attention icon"></i>Rejected by HR <td style="width: 15%;">{{data_get($overhead, 'verifier_remark')}}</td>
@endif <td style="width: 15%;">{{data_get($overhead, 'approver_remark')}}</td>
</td> <td style="width: 15%;" class="center aligned">
<td style="width: 10%;" class="text-center single line"> @if(data_get($overhead, 'tp_timesheet_sts') == 1 || data_get($overhead, 'tp_timesheet_sts') == null) In Preparation
@if(data_get($chargeable, 'tp_timesheet_sts') == 3) @elseif(data_get($overhead, 'tp_timesheet_sts') == 2) <i class="red attention icon"></i> Submitted
<button class="center aligned ui green icon button" onclick="window.location.href='{{ route('timesheet::dashboard.approvalaction', ['tpid'=>data_get($chargeable, 'id'), 'phase'=>data_get($chargeable, 'tp_phase'), 'month'=>data_get($chargeable, 'tp_month'), 'year'=>data_get($chargeable, 'tp_year'), 'page'=>$page ]) }}';">Approval</button> @elseif(data_get($overhead, 'tp_timesheet_sts') == 3) <i class="red attention icon"></i> Verified by HOD
@else @elseif(data_get($overhead, 'tp_timesheet_sts') == 4) <i class="green check icon"></i>Verified by BOD
<button class="center aligned ui green icon button disabled">Approval</button> @elseif(data_get($overhead, 'tp_timesheet_sts') == 5) <i class="red attention icon"></i>Dissaproved by BOD
@endif @elseif(data_get($overhead, 'tp_timesheet_sts') == 6) <i class="red attention icon"></i>Rejected by HOD
<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> @elseif(data_get($overhead, 'tp_timesheet_sts') == 7) <i class="red attention icon"></i>Rejected by HR
</td> @endif
</tr> </td>
@endif <td style="width: 10%;" class="text-center single line">
@endforeach @if(data_get($overhead, 'tp_timesheet_sts') == 3)
@endif <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>
</table> @else
@endif <button type="button" class="center aligned ui green icon button disabled">Approval</button>
@endif
<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
@endforeach
@else
<tr>
<td class="text-center" colspan="6">No overhead submitted</td>
</tr>
@endif
</table>
@endif
@if($checkoverhead) <?php
<table class="ui unstackable celled table"> $checknotes = $td->where('td_overhead_note', '<>', null);
<thead> // dd($checknotes);
<tr> ?>
<th style="width: 25%;">Overhead</th>
<th style="width: 10%;" class="center aligned">Total Hours</th>
<th style="width: 10%;" class="center aligned">Total Days</th>
<th style="width: 15%;">HOD Remarks</th>
<th style="width: 15%;">BOD Remarks</th>
<th style="width: 15%;" class="center aligned">Status</th>
<th style="width: 10%;" class="center aligned">Action</th>
</tr>
</thead>
@if($detail->where('tp_project_type', 3))
@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: 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>
<td style="width: 15%;">{{data_get($overhead, 'approver_remark')}}</td>
<td style="width: 15%;" class="center aligned">
@if(data_get($overhead, 'tp_timesheet_sts') == 1 || data_get($overhead, 'tp_timesheet_sts') == null) In Preparation
@elseif(data_get($overhead, 'tp_timesheet_sts') == 2) <i class="red attention icon"></i> Submitted
@elseif(data_get($overhead, 'tp_timesheet_sts') == 3) <i class="red attention icon"></i> Verified by HOD
@elseif(data_get($overhead, 'tp_timesheet_sts') == 4) <i class="green check icon"></i>Verified by BOD
@elseif(data_get($overhead, 'tp_timesheet_sts') == 5) <i class="red attention icon"></i>Dissaproved by BOD
@elseif(data_get($overhead, 'tp_timesheet_sts') == 6) <i class="red attention icon"></i>Rejected by HOD
@elseif(data_get($overhead, 'tp_timesheet_sts') == 7) <i class="red attention icon"></i>Rejected by HR
@endif
</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>
@else
<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>
</td>
</tr>
@endif
@endforeach
@else
<tr>
<td class="text-center" colspan="6">No overhead submitted</td>
</tr>
@endif
</table>
@endif
<?php @if(count($checknotes) < 0)
$checknotes = $td->where('td_overhead_note', '<>', null); @if(data_get($staff,'team.pelulus') == data_get($approval,'id'))
// dd($checknotes); <table class="ui unstackable celled table">
?> <thead>
<tr>
<th style="width: 10%" class="center aligned">Date</th>
<th style="width: 25%" class="single line"> Overhead Description</th>
<th class="center aligned">Notes</th>
</tr>
</thead>
@if($td)
@foreach($td as $key => $value)
@if($value->td_overhead_note && $value->fk_tm_id == $staff->tmid)
<tr>
<td style="width: 10%" class="center aligned">{{data_get($value, 'td_date')}}</td>
<td style="width: 25%" class="single line">{{data_get($value, 'td_overhead_desc')}}</td>
<td>{{data_get($value, 'td_overhead_note')}}</td>
</tr>
@endif
@endforeach
@endif
</table>
@endif
@endif
@if(count($checknotes) < 0) @if(data_get($staff,'attachment'))
@if(data_get($staff,'team.pelulus') == data_get($approval,'id')) <table class="ui unstackable celled table">
<table class="ui unstackable celled table">
<thead> <thead>
<tr> <tr>
<th style="width: 10%" class="center aligned">Date</th> <th colspan="2" class="center aligned">Notes Attachment</th>
<th style="width: 25%" class="single line"> Overhead Description</th>
<th class="center aligned">Notes</th>
</tr> </tr>
</thead> </thead>
@if($td) <tbody>
@foreach($td as $key => $value) <tr>
@if($value->td_overhead_note && $value->fk_tm_id == $staff->tmid) <td style="width: 4%;"></td>
<tr> <td>
<td style="width: 10%" class="center aligned">{{data_get($value, 'td_date')}}</td> <a href="{{ asset(data_get($value,'attachment.path'))}}" target="_blank">
<td style="width: 25%" class="single line">{{data_get($value, 'td_overhead_desc')}}</td>
<td>{{data_get($value, 'td_overhead_note')}}</td> <button class="ui active button">
</tr> <i class="download icon"></i>
@endif Download
@endforeach </button>
@endif </a>
</td>
</tr>
</tbody>
</table> </table>
@endif @endif
@endif
@if(data_get($staff,'attachment'))
<table class="ui unstackable celled table">
<thead>
<tr>
<th colspan="2" class="center aligned">Notes Attachment</th>
</tr>
</thead>
<tbody>
<tr>
<td style="width: 4%;"></td>
<td>
<a href="{{ asset(data_get($value,'attachment.path'))}}" target="_blank">
<button class="ui active button">
<i class="download icon"></i>
Download
</button>
</a>
</td>
</tr>
</tbody>
</table>
@endif
@if(data_get($staff,'hodremarks'))
<table class="ui unstackable celled table">
<thead>
<tr>
<th class="center aligned">Date</th>
<th class="center aligned">Verifier</th>
<th class="center aligned">Remarks by Verifier</th>
</tr>
</thead>
<tbody>
<tr>
<td style="width: 15%;">{{ data_get($staff,'verified_at') }}</td>
<td style="width: 25%;">{{ data_get($staff,'hodname') }}</td>
<td style="width: 60%;">{{ data_get($staff,'hodremarks') }}</td>
</tr>
</tbody>
</table>
@endif
@if(data_get($staff,'hodremarks')) @if(data_get($staff,'bodremarks'))
<table class="ui unstackable celled table"> <table class="ui unstackable celled table">
<thead> <thead>
<tr> <tr>
<th class="center aligned">Date</th> <th class="center aligned">Date</th>
<th class="center aligned">Verifier</th> <th class="center aligned">Approver</th>
<th class="center aligned">Remarks by Verifier</th> <th class="center aligned">Remarks by Approver</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td style="width: 15%;">{{ data_get($staff,'verified_at') }}</td> <td style="width: 15%;" class="center aligned">{{ data_get($staff,'approved_at') }}</td>
<td style="width: 25%;">{{ data_get($staff,'hodname') }}</td> <td style="width: 25%;" class="center aligned">{{ data_get($staff,'bodname') }}</td>
<td style="width: 60%;">{{ data_get($staff,'hodremarks') }}</td> <td style="width: 60%;" class="center aligned">{{ data_get($staff,'bodremarks') }}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@endif @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>
@if(data_get($staff,'bodremarks')) </form>
<table class="ui unstackable celled table">
<thead>
<tr>
<th class="center aligned">Date</th>
<th class="center aligned">Approver</th>
<th class="center aligned">Remarks by Approver</th>
</tr>
</thead>
<tbody>
<tr>
<td style="width: 15%;" class="center aligned">{{ data_get($staff,'approved_at') }}</td>
<td style="width: 25%;" class="center aligned">{{ data_get($staff,'bodname') }}</td>
<td style="width: 60%;" class="center aligned">{{ data_get($staff,'bodremarks') }}</td>
</tr>
</tbody>
</table>
@endif
</div> </div>
@endif @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 ...@@ -1312,8 +1312,8 @@ class DashboardController extends Controller
$chargeablelist[] = [ $chargeablelist[] = [
'pid' => $value->td_project, 'pid' => $value->td_project,
'pcode' => $value->project->p_project_code, 'pcode' => data_get($value,'project.p_project_code'),
'pname' => $value->project->p_project_description, 'pname' => data_get($value,'tp_project_name'),
]; ];
...@@ -1550,5 +1550,581 @@ class DashboardController extends Controller ...@@ -1550,5 +1550,581 @@ class DashboardController extends Controller
return redirect()->route('timesheet::dashboard.index')->withSuccess('Timesheet has been submitted!'); 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