@php $nett = ''; $vat = ''; $gross = ''; $company_name = ''; $total = 0; $total_h = 0; $total_p = 0; $total_hp = 0; $total_estimate = 0; $total_cost = 0; $all_total_cost = 0; $total_profit = 0; $total_loss = 0; $gtotal_cost = 0; $gall_total_cost = 0; $gtotal_estimate = 0; $gtotal_profit = 0; $gtotal_loss = 0; $total_estimate = 0; $total_cost = 0; $all_total_cost = 0; $all_total_hours = 0; $total_profit = 0; $total_loss = 0; $th = 0; $tm = 0; $monday_total_hours = 0; $tuesday_total_hours = 0; $wednesday_total_hours = 0; $thursday_total_hours = 0; $friday_total_hours = 0; $saturday_total_hours = 0; $sunday_total_hours = 0; $monday_total_tmj = 0; $tuesday_total_tmj = 0; $wednesday_total_tmj = 0; $thursday_total_tmj = 0; $friday_total_tmj = 0; $saturday_total_tmj = 0; $sunday_total_tmj = 0; @endphp
@if($project)

{{ $project->company->company_name }}

{!! $project->company->address_line1 ? $project->company->address_line1.'
' : '' !!} {!! $project->company->address_line2 ? $project->company->address_line2.'
' : '' !!} telephone: {{ $project->company->phone }}
fax: {{ $project->company->fax }}
e-mail: {{ $project->company->email }}
@endif
NAME: {{ $supervisor_name }} INVOICE No :
ROLE : {{ $supervisor_role }}
Week Ending : {{ date('M d, Y', strtotime($sunday)) }} DATE APPROVED :
@if($timesheets->isNotEmpty()) @foreach($timesheets as $timesheet) @php $user = $timesheet->supervisor; $total_hours=0; $a_total_cost=0; $thj = 0; $monday_tmj = 0; $tuesday_tmj = 0; $wednesday_tmj = 0; $thursday_tmj = 0; $friday_tmj = 0; $saturday_tmj = 0; $sunday_tmj = 0; $project_title = $timesheet->project->unique_reference_no.' '.$timesheet->project->project_title; $project_ids = $timesheet->project_id; $estimate = $timesheet->activityOfTimesheet->total; $per_estimate = $timesheet->selling_cost; $mhr_role = $timesheet->activityOfTimesheet->mhr_role; $invoice_no = $timesheet->subActivity->sub_code; $date = date("d/m/Y", strtotime($timesheet->timesheet_date)); $area = $timesheet->mainActivity->area; $level = $timesheet->mainActivity->level; $supervisor = ucfirst($user->full_name ?? ''); $notes = $timesheet->notes; $hours = $timesheet->hours; $peoples = $timesheet->peoples; $total_h = $total_h+ (float)$timesheet->hours; $total_p = $total_p+$timesheet->peoples; $total_hp = $total_hp+ (float)$timesheet->total_hours; $profit = 0; $loss = 0; $monday_hr = 0; $tuesday_hr = 0; $wednesday_hr = 0; $thursday_hr = 0; $friday_hr = 0; $saturday_hr = 0; $sunday_hr = 0; $timesheets1 = Modules\TimesheetManager\Entities\StaffTimesheet::where('project_id', $project_ids) ->where('role', 'detail') ->where('activity_id', $timesheet->activity_id) ->whereDate('timesheet_date', $monday) ->where('supervisor_id', $supervisor_id) ->get(); if($timesheets1->isNotEmpty()){ foreach($timesheets1 as $timesheet1){ $per_total_cost = $per_estimate * (float)$timesheet1->total_hours; $tt = (float)$timesheet1->total_hours; $a = ''; $a = (float)$timesheet1->total_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; $date1 = date("d/m/Y", strtotime($timesheet1->timesheet_date)); $monday_tmj = $monday_tmj+$pm; $monday_hr = $monday_hr+$ph; @$monday_total_hours = $monday_total_hours+$ph; @$monday_a_total_cost = $monday_a_total_cost+$monday_per_total_cost; } if($monday_tmj > 60){ $monday_hr = $monday_hr+floor($monday_tmj/60); $monday_total_hours = $monday_total_hours+floor($monday_tmj/60); $monday_tmj= floor($monday_tmj%60); } $monday_total_tmj = $monday_total_tmj+$monday_tmj; } $timesheets2 = Modules\TimesheetManager\Entities\StaffTimesheet::where('project_id', $project_ids) ->where('role', 'detail') ->where('activity_id', $timesheet->activity_id) ->whereDate('timesheet_date', $tuesday) ->where('supervisor_id', $supervisor_id) ->get(); if($timesheets2->isNotEmpty()){ foreach($timesheets2 as $timesheet2){ $per_total_cost = $per_estimate * (float)$timesheet2->total_hours; $tt = (float)$timesheet2->total_hours; $a = ''; $a = (float)$timesheet2->total_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; $date1 = date("d/m/Y", strtotime($timesheet2->timesheet_date)); $tuesday_tmj = $tuesday_tmj+$pm; $tuesday_hr = $tuesday_hr+$ph; @$tuesday_total_hours = $tuesday_total_hours+$ph; @$tuesday_a_total_cost = $tuesday_a_total_cost+$tuesday_per_total_cost; } if($tuesday_tmj > 60){ $tuesday_hr = $tuesday_hr+floor($tuesday_tmj/60); $tuesday_total_hours = $tuesday_total_hours+floor($tuesday_tmj/60); $tuesday_tmj = floor($tuesday_tmj%60); } $tuesday_total_tmj = $tuesday_total_tmj+$tuesday_tmj; } $timesheets3 = Modules\TimesheetManager\Entities\StaffTimesheet::where('project_id', $project_ids) ->where('role', 'detail') ->where('activity_id', $timesheet->activity_id) ->whereDate('timesheet_date', $wednesday) ->where('supervisor_id', $supervisor_id) ->get(); if($timesheets3->isNotEmpty()){ foreach($timesheets3 as $timesheet3){ $per_total_cost = $per_estimate * (float)$timesheet3->total_hours; $tt = (float)$timesheet3->total_hours; $a = ''; $a = (float)$timesheet3->total_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; $date1=date("d/m/Y", strtotime($timesheet3->timesheet_date)); $wednesday_tmj = $wednesday_tmj+$pm; $wednesday_hr = $wednesday_hr+$ph; @$wednesday_total_hours = $wednesday_total_hours+$ph; @$wednesday_a_total_cost = $wednesday_a_total_cost+$wednesday_per_total_cost; } if($wednesday_tmj>60){ $wednesday_hr=$wednesday_hr+floor($wednesday_tmj/60); $wednesday_total_hours=$wednesday_total_hours+floor($wednesday_tmj/60); $wednesday_tmj=floor($wednesday_tmj%60); } $wednesday_total_tmj=$wednesday_total_tmj+$wednesday_tmj; } $timesheets4 = Modules\TimesheetManager\Entities\StaffTimesheet::where('project_id', $project_ids) ->where('role', 'detail') ->where('activity_id', $timesheet->activity_id) ->whereDate('timesheet_date', $thursday) ->where('supervisor_id', $supervisor_id) ->get(); if($timesheets4->isNotEmpty()){ foreach($timesheets4 as $timesheet4){ $per_total_cost = $per_estimate * (float)$timesheet4->total_hours; $tt = (float)$timesheet4->total_hours; $a = ''; $a = (float)$timesheet4->total_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; $date1 = date("d/m/Y", strtotime($timesheet4->timesheet_date)); $thursday_tmj = $thursday_tmj+$pm; $thursday_hr = $thursday_hr+$ph; @$thursday_total_hours = $thursday_total_hours+$ph; @$thursday_a_total_cost = $thursday_a_total_cost+$thursday_per_total_cost; } if($thursday_tmj>60){ $thursday_hr=$thursday_hr+floor($thursday_tmj/60); $thursday_total_hours=$thursday_total_hours+floor($thursday_tmj/60); $thursday_tmj=floor($thursday_tmj%60); } $thursday_total_tmj=$thursday_total_tmj+$thursday_tmj; } $timesheets5 = Modules\TimesheetManager\Entities\StaffTimesheet::where('project_id', $project_ids) ->where('role', 'detail') ->where('activity_id', $timesheet->activity_id) ->whereDate('timesheet_date', $friday) ->where('supervisor_id', $supervisor_id) ->get(); if($timesheets5->isNotEmpty()){ foreach($timesheets5 as $timesheet5){ $per_total_cost=$per_estimate * (float)$timesheet5->total_hours; $tt = (float)$timesheet5->total_hours; $a = ''; $a = (float)$timesheet5->total_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; $date1=date("d/m/Y", strtotime($timesheet5->timesheet_date)); $friday_tmj=$friday_tmj+$pm; $friday_hr=$friday_hr+$ph; @$friday_total_hours=$friday_total_hours+$ph; @$friday_a_total_cost=$friday_a_total_cost+$friday_per_total_cost; } if($friday_tmj>60){ $friday_hr=$friday_hr+floor($friday_tmj/60); $friday_total_hours=$friday_total_hours+floor($friday_tmj/60); $friday_tmj=floor($friday_tmj%60); } $friday_total_tmj=$friday_total_tmj+$friday_tmj; } $timesheets6 = Modules\TimesheetManager\Entities\StaffTimesheet::where('project_id', $project_ids) ->where('role', 'detail') ->where('activity_id', $timesheet->activity_id) ->whereDate('timesheet_date', $saturday) ->where('supervisor_id', $supervisor_id) ->get(); if($timesheets6->isNotEmpty()){ foreach($timesheets6 as $timesheet6){ $per_total_cost = $per_estimate * (float)$timesheet6->total_hours; $tt = (float)$timesheet6->total_hours; $a = ''; $a = (float)$timesheet6->total_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; $date1=date("d/m/Y", strtotime($timesheet6->timesheet_date)); $saturday_tmj=$saturday_tmj+$pm; $saturday_hr=$saturday_hr+$ph; @$saturday_total_hours=$saturday_total_hours+$ph; @$saturday_a_total_cost=$saturday_a_total_cost+$saturday_per_total_cost; } if($saturday_tmj>60){ $saturday_hr=$saturday_hr+floor($saturday_tmj/60); $saturday_total_hours=$saturday_total_hours+floor($saturday_tmj/60); $saturday_tmj=floor($saturday_tmj%60); } $saturday_total_tmj=$saturday_total_tmj+$saturday_tmj; } $timesheets7 = Modules\TimesheetManager\Entities\StaffTimesheet::where('project_id', $project_ids) ->where('role', 'detail') ->where('activity_id', $timesheet->activity_id) ->whereDate('timesheet_date', $sunday) ->where('supervisor_id', $supervisor_id) ->get(); if($timesheets7->isNotEmpty()){ foreach($timesheets7 as $timesheet7){ $per_total_cost=$per_estimate * (float)$timesheet7->total_hours; $tt= (float)$timesheet7->total_hours; $a = ''; $a = (float)$timesheet7->total_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; $date1=date("d/m/Y", strtotime($timesheet7->timesheet_date)); $sunday_tmj=$sunday_tmj+$pm; $sunday_hr=$sunday_hr+$ph; @$sunday_total_hours=$sunday_total_hours+$ph;//$rowsb['total_hours']; @$sunday_a_total_cost=$sunday_a_total_cost+$sunday_per_total_cost; } if($sunday_tmj>60){ $sunday_hr=$sunday_hr+floor($sunday_tmj/60); $sunday_total_hours=$sunday_total_hours+floor($sunday_tmj/60); $sunday_tmj=floor($sunday_tmj%60); } $sunday_total_tmj=$sunday_total_tmj+$sunday_tmj; } $week_hr_total=$monday_hr+$tuesday_hr+$wednesday_hr+$thursday_hr+$friday_hr+$saturday_hr+$sunday_hr; $week_tmj_total=$monday_tmj+$tuesday_tmj+$wednesday_tmj+$thursday_tmj+$friday_tmj+$saturday_tmj+$sunday_tmj; if($week_tmj_total>60){ $week_hr_total=$week_hr_total+floor($week_tmj_total/60); $week_tmj_total=floor($week_tmj_total%60); } @endphp @endforeach @php 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; if($monday_total_tmj>60){ $monday_total_hours=$monday_total_hours+floor($monday_total_tmj/60); $monday_total_tmj=floor($monday_total_tmj%60); } if($tuesday_total_tmj>60){ $tuesday_total_hours=$tuesday_total_hours+floor($tuesday_total_tmj/60); $tuesday_total_tmj=floor($tuesday_total_tmj%60); } if($wednesday_total_tmj>60){ $wednesday_total_hours=$wednesday_total_hours+floor($wednesday_total_tmj/60); $wednesday_total_tmj=floor($wednesday_total_tmj%60); } if($thursday_total_tmj>60){ $thursday_total_hours=$thursday_total_hours+floor($thursday_total_tmj/60); $thursday_total_tmj=floor($thursday_total_tmj%60); } if($friday_total_tmj>60){ $friday_total_hours=$friday_total_hours+floor($friday_total_tmj/60); $friday_total_tmj=floor($friday_total_tmj%60); } if($saturday_total_tmj>60){ $saturday_total_hours=$saturday_total_hours+floor($saturday_total_tmj/60); $saturday_total_tmj=floor($saturday_total_tmj%60); } if($sunday_total_tmj>60){ $sunday_total_hours=$sunday_total_hours+floor($sunday_total_tmj/60); $sunday_total_tmj=floor($sunday_total_tmj%60); } $week_total_hours=$monday_total_hours+$tuesday_total_hours+$wednesday_total_hours+$thursday_total_hours+$friday_total_hours+$saturday_total_hours+$sunday_total_hours; $week_total_hours_tmj=$monday_total_tmj+$tuesday_total_tmj+$wednesday_total_tmj+$thursday_total_tmj+$friday_total_tmj+$saturday_total_tmj+$sunday_total_tmj; if($week_total_hours_tmj>60){ $week_total_hours=$week_total_hours+floor($week_total_hours_tmj/60); $week_total_hours_tmj=floor($week_total_hours_tmj%60); } @endphp @endif
Project Activity code Activity MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY SUNDAY TOTAL APPROVAL SIGNATURE
{{ $project_title }} {{ $timesheet->item_code }} {{ $invoice_no }} @if($monday_hr != 0) {{ $monday_hr.':'.$monday_tmj }} @endif @if($tuesday_hr != 0) {{ $tuesday_hr.':'.$tuesday_tmj }} @endif @if($wednesday_hr != 0) {{ $wednesday_hr.':'.$wednesday_tmj }} @endif @if($thursday_hr != 0) {{ $thursday_hr.':'.$thursday_tmj }} @endif @if($friday_hr != 0) {{ $friday_hr.':'.$friday_tmj }} @endif @if($saturday_hr != 0) {{ $saturday_hr.':'.$saturday_tmj }} @endif @if($sunday_hr != 0) {{ $sunday_hr.':'.$sunday_tmj }} @endif     {{ $week_hr_total.':'.$week_tmj_total }} approver_id > 0) checked @endif>

TOTALS :

{{ $monday_total_hours.':'.$monday_total_tmj }}

{{ $tuesday_total_hours.':'.$tuesday_total_tmj }}

{{ $wednesday_total_hours.':'.$wednesday_total_tmj }}

{{ $thursday_total_hours.':'.$thursday_total_tmj }}

{{ $friday_total_hours.':'.$friday_total_tmj }}

{{ $saturday_total_hours.':'.$saturday_total_tmj }}

{{ $sunday_total_hours.':'.$sunday_total_tmj }}

   

{{ $week_total_hours.':'.$week_total_hours_tmj }}