Commit 3dae253d by Azhan Hannan

Display details staff & project hours dalam timesheet approval

parent 38a0e852
...@@ -3,15 +3,197 @@ ...@@ -3,15 +3,197 @@
@section('content') @section('content')
<div class="ui segment"> <div class="ui segment">
<a class="ui blue left ribbon label">{{data_get($profile,'tp_project_name')}}</a> <a class="ui green left ribbon label">Project Approval</a>
<br><br> <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>
<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>
</div>
<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()}}
<input type="hidden" name="tpid" value="{{ data_get($profile,'id') }}"> <input type="hidden" name="tpid" value="{{ data_get($profile,'id') }}">
<input type="hidden" name="page" value="{{$page}}"> <input type="hidden" name="page" value="{{$page}}">
<div class="six wide field"> <!-- <div class="six wide field">
<label>Staff Name</label> <label>Staff Name</label>
<input type="text" readonly="readonly" value="{{ data_get($profile,'team.fullname') }}"> <input type="text" readonly="readonly" value="{{ data_get($profile,'team.fullname') }}">
</div> </div>
...@@ -29,15 +211,15 @@ ...@@ -29,15 +211,15 @@
<label>Phase</label> <label>Phase</label>
<input type="text" readonly="readonly" value="{{ data_get($profile,'tp_phase') }}"> <input type="text" readonly="readonly" value="{{ data_get($profile,'tp_phase') }}">
</div> </div>
</div> </div> -->
<div class="two fields"> <div class="two fields">
<div class="six wide 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>Pelulus</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="three wide field"> <div class="field">
<label>Action</label> <label>Action</label>
<select class="ui fluid dropdown" name="action"> <select class="ui fluid dropdown" name="action">
<option value="1">Approval</option> <option value="1">Approval</option>
...@@ -47,7 +229,7 @@ ...@@ -47,7 +229,7 @@
</div> </div>
<div class="field"> <div class="field">
<label>Remarks</label> <label>Remarks</label>
<textarea name="remarks"></textarea> <textarea rows="3" name="remarks"></textarea>
</div> </div>
<button class="ui green button" type="submit">Submit</button> <button class="ui green button" type="submit">Submit</button>
......
...@@ -848,15 +848,143 @@ class DashboardController extends Controller ...@@ -848,15 +848,143 @@ class DashboardController extends Controller
{ {
$page = data_get($request,'page'); $page = data_get($request,'page');
// dd($page); // dd($page);
$bod = Users::find(Auth::id());
$profile = Tproject::where('id', $request->tpid) $profile = Tproject::where('id', $request->tpid)
->with('team') ->with('team')
->first(); ->first();
$bod = Users::find(Auth::id());
// dd($profile); // dd($profile);
return view('timesheet::dashboard.approvalaction', compact('profile', 'bod', 'page')); $phase = $profile->tp_phase;
$month = $profile->tp_month;
$year = $profile->tp_year;
$daymonth=cal_days_in_month(CAL_GREGORIAN,$month,$year);
$myDate = $month.'/'.'1'.'/'.$year;
$date = Carbon::createFromFormat('m/d/Y', $myDate);
$staff = VwViewer::where('STAFF_ID', $profile->staffid)
->first();
$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);
}
// dd($staff);
$chargeable = 1;
$overhead = 3;
$check = Ts_master::where('tm_staff_id', $profile->staffid)
->where('tm_year', $year)
->where('tm_month', $month)
->where('tm_phase', $phase)
->with('attachement')
->first();
$chargeableproject = Tproject::where('fk_tm_id', data_get($check,'id'))
->where('tp_project_type', 1)
->with('project')
->get();
$chargeablelist = [];
$overheadlist = [];
foreach($chargeableproject as $key => $value) {
$chargeablelist[] = [
'pid' => $value->td_project,
'pcode' => $value->project->p_project_code,
'pname' => $value->project->p_project_description,
];
}
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;
}
}
foreach ($tempOverhead as $key => $value) {
$overheadlist[] = [
'pid' => $tempOverheadid[$key],
'pname' => $tempOverhead[$key],
];
}
}
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', $profile->staffid)
->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.approvalaction', compact('profile', 'bod', 'page', 'staff', 'daymonth', 'strMonth', 'year', 'month', 'phase', 'strdays', 'chargeablelist', 'chargehour', 'totalchargehrs'));
} }
public function approval(Request $request) public function approval(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