@php
$total = 0;
$total_h = 0;
$total_p = 0;
$total_hp = 0;
$gtotal_cost = 0;
$gall_total_cost = 0;
$gtotal_estimate = 0;
$gtotal_profit = 0;
$gtotal_loss = 0;
@endphp
@if($labourTimesheets->isNotEmpty())
@foreach($labourTimesheets as $labourTimesheet)
@php
$total_estimate = 0;
$total_cost = 0;
$all_total_cost = 0;
$all_total_hours = 0;
$total_profit = 0;
$total_loss = 0;
$tm = 0;
$profit=0;
$loss=0;
$gtotal_estimate = ($gtotal_estimate + $total_estimate);
$gtotal_profit = ($gtotal_profit + $total_profit);
$gtotal_loss = ($gtotal_loss + $total_loss);
$gall_total_cost = ($gall_total_cost + $all_total_cost);
$all_per_estimate = $labourTimesheet->activityOfTimesheet->selling_cost;
$aph = strtok((float)$labourTimesheet->allocated_hour, ':');
$total_estimate = $aph*$all_per_estimate;
$mptotal_hours = 0;
$mpa_total_cost = 0;
$mptmj = 0;
$mpthj = 0;
$eaph = strtok((float)$labourTimesheet->total_spent_hour, ':');
$eapm = substr(strstr((float)$labourTimesheet->total_spent_hour, ':'), 1);
$mpa_total_cost = $eaph*$all_per_estimate;
$mpph = $eaph;
$mppm = $eapm;
$mptmin = (($mpph*60)+$mppm);
$mpminpercost = $all_per_estimate/60;
$mpper_total_cost = $mptmin*$mpminpercost;
$mptotal_cost = $mpper_total_cost;
$mpprofit = 0;
$mploss = 0;
if($mptotal_cost > $total_estimate){
$mploss = ($mptotal_cost - $total_estimate);
}
if($mptotal_cost < $total_estimate){
$mpprofit = ($total_estimate - $mptotal_cost);
}
@endphp
{{ $labourTimesheet->subActivity->sub_code }}
|
{{ $labourTimesheet->activityOfTimesheet->item_code }}
|
{{ $labourTimesheet->activityOfTimesheet->activity }}
|
{{ $labourTimesheet->allocated_hour }}
|
{{ $labourTimesheet->total_spent_hour }} |
{{ $labourTimesheet->remaining_hour }} |
£{{ number_format($mptotal_cost,4) }} |
£{{ number_format($total_estimate,4) }} |
£{{ number_format($mpprofit,4) }} |
£{{ number_format($mploss,4) }} |
Lab code |
Date |
Operative |
Start time |
End time |
Peoples |
Spent/hr |
Rate |
Total cost |
Estimate |
Profit |
Loss |
@php
$labourTimesheets1 = $labourTimesheet->project->labourTimesheets()
->where('activity_id', $labourTimesheet->activity_id)
->get();
@endphp
@if($labourTimesheets1->isNotEmpty())
@foreach($labourTimesheets1 as $labourTimesheet1)
@php
$total_hours = 0;
$a_total_cost = 0;
$tmj = 0;
$thj = 0;
$estimate = $labourTimesheet1->activityOfTimesheet->total;
$per_estimate = $labourTimesheet1->activityOfTimesheet->selling_cost;
$ptotal_hours = 0;
$pa_total_cost = 0;
$ptmj = 0;
$pthj = 0;
@endphp
@if($labourTimesheet1->timesheetMaterials->isNotEmpty())
@foreach($labourTimesheet1->timesheetMaterials as $timesheetMaterial1)
@php
$ptt = (float)$timesheetMaterial1->hours;
$pa = '';
$pa = (float)$timesheetMaterial1->hours;
if (strpos($pa, ':') !== false) {
}else{
$ptt = str_pad($ptt, 2, '0', STR_PAD_LEFT).':00';
}
$pdtm = new DateTime('2019-11-09 '.$ptt.'');
$ptime = $pdtm->format('H:i');
$pph = $pdtm->format('H');
$ppm = $pdtm->format('i');
$ptmin = ($pph*60)+$ppm;
$pminpercost = $per_estimate/60;
$rate = 0;
$rate = $timesheetMaterial1->rate;
$rate_minpercost = $rate/60;
$pper_total_cost = $ptmin*$rate_minpercost;
$ptmj = ($ptmj+$ppm);
@$ptotal_hours = ($ptotal_hours+$pph);
@$pa_total_cost = ($pa_total_cost+$pper_total_cost);
@endphp
@endforeach
@endif
@php
if($ptmj > 60){
$ptotal_hours = $ptotal_hours+floor($ptmj/60);
$ptmj = floor($ptmj%60);
}
$ptotal_cost = $pa_total_cost;
$pprofit = 0;
$ploss = 0;
if($ptotal_cost > $estimate){
$ploss = ($ptotal_cost - $estimate);
}
if($ptotal_cost < $estimate){
$pprofit= ($estimate - $ptotal_cost);
}
@endphp
{{ $labourTimesheet1->activityOfTimesheet->item_code }}
|
{{ date("d/m/Y", strtotime($labourTimesheet1->date)) }} |
|
|
Estimate: {{ number_format($labourTimesheet1->activityOfTimesheet->quantity, 2) }}
|
{{ $labourTimesheet1->peoples }} |
{{ $labourTimesheet1->spent_hour }}
|
|
£{{ number_format($pa_total_cost, 4) }} |
£{{ number_format($estimate, 4) }} |
£{{ number_format($pprofit, 4) }} |
£{{ number_format($ploss, 4) }} |
@if($labourTimesheet1->timesheetMaterials->isNotEmpty())
@foreach($labourTimesheet1->timesheetMaterials as $timesheetMaterial2)
@php
$per_total_cost = ($per_estimate * (float)$timesheetMaterial2->hours);
$tt = (float)$timesheetMaterial2->hours;
$a = '';
$a = (float)$timesheetMaterial2->hours;
if (strpos($a, ':') !== false) {
}else{
$tt = str_pad($tt, 2, '0', STR_PAD_LEFT).':00';
}
$dtm = new DateTime('2019-11-09 '.$tt.'');
$time = $dtm->format('H:i');
$ph = $dtm->format('H');
$pm = $dtm->format('i');
$tmin = ($ph*60)+$pm;
$minpercost = $per_estimate/60;
$per_total_cost = $tmin*$minpercost;
@endphp
{{ $timesheetMaterial2->lab_code }}
|
{{ date("d/m/Y", strtotime($timesheetMaterial2->date)) }}
|
{{ $timesheetMaterial2->operative }}
|
{{ $timesheetMaterial2->start_time }}
|
{{ $timesheetMaterial2->end_time }}
|
1 |
{{ $timesheetMaterial2->hours }}
|
{{ $timesheetMaterial2->rate }}
|
£{{ number_format($per_total_cost, 4) }}
|
£{{ number_format($per_estimate, 4) }}/hr
|
|
|
@php
$tmj = ($tmj+$pm);
@$total_hours = ($total_hours+$ph);
@$a_total_cost = ($a_total_cost+$per_total_cost);
@endphp
@endforeach
@endif
@php
if($tmj > 60){
$total_hours = ($total_hours+floor($tmj/60));
$tmj = floor($tmj%60);
}
$total_cost = $a_total_cost;
$profit = 0;
$loss = 0;
if($total_cost > $estimate){
$loss = $total_cost - $estimate;
}
if($total_cost < $estimate){
$profit = $estimate - $total_cost;
}
$all_total_hours = ($all_total_hours+$total_hours);
$all_total_cost = ($all_total_cost+$total_cost);
$total_estimate = (float)$labourTimesheet->allocated_hour*$per_estimate;
$tm = ($tm+$tmj);
@endphp
@endforeach
@endif
@php
if($tm > 60){
$all_total_hours = ($all_total_hours+floor($tm/60));
$tm = floor($tm%60);
}
if($all_total_cost > $total_estimate){
$total_loss = $all_total_cost - $total_estimate;
}elseif($all_total_cost < $total_estimate){
$total_profit = ($total_estimate - $all_total_cost);
}
$gall_total_cost = ($gall_total_cost+$all_total_cost);
$gtotal_estimate = ($gtotal_estimate+$total_estimate);
$gtotal_profit = ($gtotal_profit+$total_profit);
$gtotal_loss = ($gtotal_loss+$total_loss);
@endphp
|
@endforeach
|
Total Cost : £{{ number_format($gall_total_cost,4) }} |
Estimate : £{{ number_format($gtotal_estimate,4) }} |
Profit : £{{ number_format($gtotal_profit,4) }} |
Loss : £{{ number_format($gtotal_loss,4) }} |
@endif