@php $project_reference = $project->unique_reference_no; $base_margin = $project->base_margin; $hr_rate = $project->hr_rate; $mhr_rate = $project->mhr_rate; $i = 1; $project_total = 0; $project_hr_total = 0; $project_mhr_total = 0; $labour_total = 0; $labour_total_hour = 0; $manager_total = 0; $material_cost = 0; $plant_cost = 0; $design_total = 0; $manager_total_hour = 0; $material_cost_hour = 0; $plant_cost_hour = 0; $design_total_hour = 0; /////////////////////////////////////////////////////////////// $project_totalwb = 0; $project_hr_totalwb = 0; $project_mhr_totalwb = 0; $labour_totalwb = 0; $labour_total_hourwb = 0; $manager_totalwb = 0; $material_costwb = 0; $plant_costwb = 0; $design_totalwb = 0; $manager_total_hourwb = 0; $material_cost_hourwb = 0; $plant_cost_hourwb = 0; $design_total_hourwb = 0; $labour_total_formula = ""; $count_td = 21; if($project->formulas->isNotempty()){ foreach($project->formulas as $formula){ $str = $formula->formula; $pt1 = "/x/i"; $str = preg_replace($pt1, "*", $str); $pt2 = "/([a-z])+/i"; $str = preg_replace($pt2, "\$$0", $str); $pt3 = "/([0-9])+%/"; $str = preg_replace($pt3, "($0/100)", $str); $pt4 = "/%/"; $str = preg_replace($pt4, "", $str); $rate = $project->hr_rate; $e = "\$comm = $str;"; eval($e); $formula_value = $comm; $labour_total_formula.=" + ".$formula->keyword; $count_td = $count_td + 2; } } $srno = 0; $main = 0; $sub = 0; $act = 0; if($project->mainActivities->isNotEmpty()){ foreach($project->mainActivities as $mainActivity){ $project_total = $project_total + $mainActivity->total; $project_hr_total = $project_hr_total + $mainActivity->total_hr; $project_mhr_total = $project_mhr_total + $mainActivity->total_mhr; $project_totalwb = $project_totalwb + $mainActivity->total; $project_hr_totalwb = $project_hr_totalwb + $mainActivity->total_hr; $project_mhr_totalwb = $project_mhr_totalwb + $mainActivity->total_mhr; if($mainActivity->subActivities->isNotEmpty()){ foreach($mainActivity->subActivities as $subActivity){ $expr = '/(?<=\s|^)[a-z]/i'; $string_sub_act = $subActivity->activity; preg_match_all($expr, $string_sub_act, $matches_sub_act); $result_sub_act = implode('', $matches_sub_act[0]); $result_sub_act = strtoupper($result_sub_act); $result_sub_act = substr($result_sub_act, 0, 2); $sact = 0; if($subActivity->activities->isNotEmpty()){ foreach($subActivity->activities as $activity){ $sact = $sact + 1; // substr($row['area'], 0, 1) $expr = '/(?<=\s|^)[a-z]/i'; $string_area = $activity->area; preg_match_all($expr, $string_area, $matches_area); $result_area = implode('', $matches_area[0]); $result_area = strtoupper($result_area); $string_level = $activity->level; preg_match_all($expr, $string_level, $matches_level); $result_level = implode('', $matches_level[0]); $result_level = strtoupper($result_level); $act = $act+1; $w=0; $unit_trim = preg_replace('/\s+/', '', $activity->unit); if($project->formulas->isNotempty()){ foreach($project->formulas as $formula){ if($unit_trim == $formula->keyword) { $labour_total = $labour_total + (($activity->total * $subActivity->quantity) * $mainActivity->quantity); $labour_total_hour = $labour_total_hour + (($activity->quantity * $subActivity->quantity) * $mainActivity->quantity); @$fq[$unit_trim] = $fq[$unit_trim]+($activity->quantity * $subActivity->quantity * $mainActivity->quantity); @$fk[$unit_trim] = $fk[$unit_trim] + (($activity->total * $subActivity->quantity) * $mainActivity->quantity); ///////////////////////////////////////////////////////////////////////////// $labour_totalwb = $labour_totalwb + ((($activity->rate * $activity->quantity) * $subActivity->quantity) * $mainActivity->quantity); $labour_total_hourwb = $labour_total_hourwb + (($activity->quantity * $subActivity->quantity) * $mainActivity->quantity); @$fqwb[$unit_trim] =$fqwb[$unit_trim]+($activity->quantity * $subActivity->quantity * $mainActivity->quantity); @$fkwb[$unit_trim] = $fkwb[$unit_trim] + ((($activity->rate * $activity->quantity) * $subActivity->quantity) * $mainActivity->quantity); ///////////////////////////////////////////////////////////////////////////// $w=$w+1; } } } if($unit_trim == "mhr"){ $manager_total = $manager_total + (($activity->total * $subActivity->quantity) * $mainActivity->quantity); $manager_total_hour = $manager_total_hour + (($activity->quantity * $subActivity->quantity) * $mainActivity->quantity); /////////////////////////////////////////////////////////////// $manager_totalwb = $manager_totalwb + ((($activity->rate * $activity->quantity) * $subActivity->quantity) * $mainActivity->quantity); $manager_total_hourwb = $manager_total_hourwb + (($activity->quantity * $subActivity->quantity) * $mainActivity->quantity); /////////////////////////////////////////////////////////////// } if($unit_trim == "dhr"){ $design_total = $design_total + (($activity->total * $subActivity->quantity) * $mainActivity->quantity); $design_total_hour = $design_total_hour + (($activity->quantity * $subActivity->quantity) * $mainActivity->quantity); ///////////////////////////////////////////////////////////////////////////// $design_totalwb = $design_totalwb + ((($activity->rate * $activity->quantity) * $subActivity->quantity) * $mainActivity->quantity); $design_total_hourwb = $design_total_hourwb + (($activity->quantity * $subActivity->quantity) * $mainActivity->quantity); ////////////////////////////////////////////////////////////////////////////// } if($unit_trim == "nr"){ $material_cost = $material_cost + (($activity->total * $subActivity->quantity) * $mainActivity->quantity); $material_cost_hour = $material_cost_hour + (($activity->quantity * $subActivity->quantity) * $mainActivity->quantity); ///////////////////////////////////////////////////////////////////////// $material_costwb = $material_costwb + ((($activity->rate * $activity->quantity) * $subActivity->quantity) * $mainActivity->quantity); $material_cost_hourwb = $material_cost_hourwb + (($activity->quantity * $subActivity->quantity) * $mainActivity->quantity); ///////////////////////////////////////////////////////////////////////// } if($unit_trim == "nrp"){ $plant_cost = $plant_cost + (($activity->total * $subActivity->quantity) * $mainActivity->quantity); $plant_cost_hour = $plant_cost_hour + (($activity->quantity * $subActivity->quantity) * $mainActivity->quantity); //////////////////////////////////////////////////////////////////////////////// $plant_costwb = $plant_costwb + ((($activity->rate * $activity->quantity) * $subActivity->quantity) * $mainActivity->quantity); $plant_cost_hourwb = $plant_cost_hourwb + (($activity->quantity * $subActivity->quantity) * $mainActivity->quantity); /////////////////////////////////////////////////////////////////////////////// } } } $sub = $sub+1; } } $i++; $srno++; } } $project_totalwb = $project_totalwb * (1-($base_margin/100)); @endphp @isset($fq) @foreach($fq as $key=>$value) @endforeach @endisset @isset($fq) @foreach($fq as $key=>$value) @endforeach @endisset
Estimate Table #ID : {{ $project_reference }} , Project : {{ $project->project_title }} Project Total Base Labour Base Margin {{ $key }}
{{ $key }}       cost
Labour Total
{{ $labour_total_formula }}
Manager Total
mhr
Design Total
dhr
Material Cost
nr
Plant Cost
nrp
£{{ number_format((float) $project_total, 2) }} {{ $hr_rate }} {{ $base_margin }} {{ $value }}hrs £{{ @$fk[$key] }}{{ number_format((float) $labour_total_hour) }}hrs £{{ number_format((float) $labour_total, 2) }} {{ number_format((float) $manager_total_hour) }}hrs £{{ number_format((float) $manager_total, 2) }} {{ number_format((float) $design_total_hour) }}hrs £{{ number_format((float) $design_total, 2) }} £{{ number_format((float) $material_cost, 2) }} £{{ number_format((float) $plant_cost, 2) }}
@isset($fqwb) @foreach($fqwb as $key=>$value) @endforeach @endisset @isset($fqwb) @foreach($fqwb as $key=>$value) @endforeach @endisset
Project Total Base Labour Base Margin {{ $key }}
{{ $key }}       cost
Labour Total
{{ $labour_total_formula }}
Manager Total
mhr
Design Total
dhr
Material Cost
nr
Plant Cost
nrp
£{{ number_format((float) $project_totalwb, 2) }} {{ $hr_rate }} 0 {{ $value }}hrs £{{ @$fkwb[$key] }} £{{ @$fkwb[$key] }} {{ number_format((float) $labour_total_hourwb) }}hrs £{{ number_format((float) $labour_totalwb, 2) }} {{ number_format((float) $manager_total_hourwb) }}hrs £{{ number_format((float) $manager_totalwb, 2) }} {{ number_format((float) $design_total_hourwb) }}hrs £{{ number_format((float) $design_totalwb, 2) }} £{{ number_format((float) $material_costwb, 2) }} £{{ number_format((float) $plant_costwb, 2) }}
@php $i = 1; $project_total = 0; $project_hr_total = 0; $project_mhr_total = 0; $labour_total = 0; $labour_total_hour = 0; $manager_total = 0; $material_cost = 0; $plant_cost = 0; $design_total = 0; $manager_total_hour = 0; $material_cost_hour = 0; $plant_cost_hour = 0; $design_total_hour = 0; @endphp @isset($fq) @foreach($fq as $key=>$value) @endforeach @endisset @php $srno = 0; $main = 0; $sub = 0; $act = 0; $sub_activity_id = 0; $main_code_sr = 0; @endphp @if($project->mainActivities->isNotEmpty()) @foreach($project->mainActivities as $mainActivity) @php $main_code_sr = $main_code_sr + 1; $main_activity_id = $mainActivity->id; $project_total = $project_total + $mainActivity->total; $project_hr_total = $project_hr_total + $mainActivity->total_hr; $project_mhr_total = $project_mhr_total + $mainActivity->total_mhr; @endphp @php $labour_totalm = 0; $labour_total_hourm = 0; $manager_totalm = 0; $material_costm = 0; $plant_costm = 0; $design_totalm = 0; $manager_total_hourm = 0; $material_cost_hourm = 0; $plant_cost_hourm = 0; $design_total_hourm = 0; if($mainActivity->subActivities->isNotEmpty()){ foreach($mainActivity->subActivities as $subActivity){ $sub_activity_id = $subActivity->id; $expr = '/(?<=\s|^)[a-z]/i'; $string_sub_act = $subActivity->activity; preg_match_all($expr, $string_sub_act, $matches_sub_act); $result_sub_act = implode('', $matches_sub_act[0]); $result_sub_act = strtoupper($result_sub_act); $result_sub_act = substr($result_sub_act, 0, 2); $sact = 0; if($subActivity->activities->isNotEmpty()){ foreach($subActivity->activities as $activity){ $sact = $sact + 1; $expr = '/(?<=\s|^)[a-z]/i'; $string_area = $activity->area; preg_match_all($expr, $string_area, $matches_area); $result_area = implode('', $matches_area[0]); $result_area = strtoupper($result_area); $string_level = $activity->level; preg_match_all($expr, $string_level, $matches_level); $result_level = implode('', $matches_level[0]); $result_level = strtoupper($result_level); $act = $act + 1; $w = 0; $unit_trim = preg_replace('/\s+/', '', $activity->unit); if($project->formulas->isNotEmpty()){ foreach($project->formulas as $formula){ if ($unit_trim == $formula->keyword) { $labour_totalm = $labour_totalm + ((($activity->rate * $activity->quantity) * $subActivity->quantity) * $mainActivity->quantity); $labour_total_hourm = $labour_total_hourm + (($activity->quantity * $subActivity->quantity) * $mainActivity->quantity); @$fqm[$unit_trim] = $fqm[$unit_trim] + ($activity->quantity * $subActivity->quantity * $mainActivity->quantity); @$fkm[$unit_trim] = $fkm[$unit_trim] + ((($activity->rate * $activity->quantity) * $subActivity->quantity) * $mainActivity->quantity); $w = $w + 1; } } if ($unit_trim == "mhr") { $manager_totalm = $manager_totalm + ((($activity->rate * $activity->quantity) * $subActivity->quantity) * $mainActivity->quantity); $manager_total_hourm = $manager_total_hourm + (($activity->quantity * $subActivity->quantity) * $mainActivity->quantity); } if($unit_trim == "dhr") { $design_totalm = $design_totalm + ((($activity->rate * $activity->quantity) * $subActivity->quantity) * $mainActivity->quantity); $design_total_hourm = $design_total_hourm + (($activity->quantity * $subActivity->quantity) * $mainActivity->quantity); } if ($unit_trim == "nr") { $material_costm = $material_costm + ((($activity->rate * $activity->quantity) * $subActivity->quantity) * $mainActivity->quantity); $material_cost_hourm = $material_cost_hourm + (($activity->quantity * $subActivity->quantity) * $mainActivity->quantity); } if ($unit_trim == "nrp") { $plant_costm = $plant_costm + ((($activity->rate * $activity->quantity) * $subActivity->quantity) * $mainActivity->quantity); $plant_cost_hourm = $plant_cost_hourm + (($activity->quantity * $subActivity->quantity) * $mainActivity->quantity); } } } } $sub = $sub + 1; } } @endphp @isset($fq) @foreach($fq as $key=>$value) @endforeach @endisset @php $fqm=array(); $fkm=array(); @endphp @php $i++; $srno++; @endphp @endforeach @endif
Main Code Area Level Activity Quantity Rate Total Unit Qty Unit Rate Unit {{ $key }} cost{{ $labour_total_formula }} cost mhr cost dhr cost nr cost nrp cost
{{ Arr::get($mainActivity, 'main_code', $main_code_sr) }} {{ Arr::get($mainActivity, 'area', '') }} {{ Arr::get($mainActivity, 'level', '') }} {{ Arr::get($mainActivity, 'activity', '') }} {{ Arr::get($mainActivity, 'quantity', '') }} {{ Arr::get($mainActivity, 'rate', '') }} {{ Arr::get($mainActivity, 'total', '') }} {{ Arr::get($mainActivity, 'unit_qty', '') }} {{ Arr::get($mainActivity, 'unit_rate', '') }} {{ Arr::get($mainActivity, 'unit', '') }} {{ @$fqm[$key] }} {{ @$fkm[$key] }}{{ $labour_total_hourm }} {{ $labour_totalm }} {{ $manager_total_hourm }} {{ $manager_totalm }} {{ $design_total_hourm }} {{ $design_totalm }} {{ $material_costm }} {{ $plant_costm }}
@isset($fq) @foreach($fq as $key=>$value) @endforeach @endisset @if($mainActivity->subActivities->isNotEmpty()) @foreach($mainActivity->subActivities as $subActivity) @php $expr = '/(?<=\s|^)[a-z]/i'; $string_sub_act = $subActivity->activity; preg_match_all($expr, $string_sub_act, $matches_sub_act); $result_sub_act = implode('', $matches_sub_act[0]); $result_sub_act = strtoupper($result_sub_act); $result_sub_act = substr($result_sub_act, 0, 2); @endphp @php $labour_totals = 0; $labour_total_hours = 0; $manager_totals = 0; $material_costs = 0; $plant_costs = 0; $design_totals = 0; $manager_total_hours = 0; $material_cost_hours = 0; $plant_cost_hours = 0; $design_total_hours = 0; $sact=0; if($subActivity->activities->isNotEmpty()){ foreach($subActivity->activities as $activity){ $sact = $sact + 1; $expr = '/(?<=\s|^)[a-z]/i'; $string_area = $mainActivity->area; preg_match_all($expr, $string_area, $matches_area); $result_area = implode('', $matches_area[0]); $result_area = strtoupper($result_area); $string_level = $mainActivity->level; preg_match_all($expr, $string_level, $matches_level); $result_level = implode('', $matches_level[0]); $result_level = strtoupper($result_level); $act = $act+1; $w = 0; $unit_trim = preg_replace('/\s+/', '', $activity->unit); if($project->formulas->isNotEmpty()){ foreach($project->formulas as $furmula){ if($unit_trim == $furmula->keyword) { $labour_totals = $labour_totals + (($activity->rate * $activity->quantity) * $subActivity->quantity); $labour_total_hours = $labour_total_hours + ($activity->quantity * $subActivity->quantity); @$fqs[$unit_trim]=$fqs[$unit_trim]+($activity->quantity * $subActivity->quantity); @$fks[$unit_trim]=$fks[$unit_trim] + (($activity->rate * $activity->quantity) * $subActivity->quantity); $w = $w+1; } } } if($unit_trim == "mhr"){ $manager_totals = $manager_totals + (($activity->rate * $activity->quantity) * $subActivity->quantity); $manager_total_hours = $manager_total_hours + ($activity->quantity * $subActivity->quantity); } if($unit_trim == "dhr"){ $design_totals = $design_totals + (($activity->rate * $activity->quantity) * $subActivity->quantity); $design_total_hours = $design_total_hours + ($activity->quantity * $subActivity->quantity); } if($unit_trim == "nr"){ $material_costs = $material_costs + (($activity->rate * $activity->quantity) * $subActivity->quantity); $material_cost_hours = $material_cost_hours + ($activity->quantity * $subActivity->quantity); } if($unit_trim == "nrp"){ $plant_costs = $plant_costs + (($activity->rate * $activity->quantity) * $subActivity->quantity); $plant_cost_hours = $plant_cost_hours + ($activity->quantity * $subActivity->quantity); } } } @endphp @isset($fq) @foreach($fq as $key=>$value) @endforeach @endisset @php $fqs=array(); $fks=array(); @endphp @php $sub = $sub+1; @endphp @endforeach @endif
Sub Code Activity Quantity Rate Total {{ $key }} cost{{ $labour_total_formula }} cost mhr cost dhr cost nr cost nrp cost
{{ Arr::get($subActivity, 'sub_code', $result_sub_act) }} GYan12345 {{ Arr::get($subActivity, 'activity', '') }} {{ Arr::get($subActivity, 'quantity', '') }} {{ Arr::get($subActivity, 'rate', '') }} {{ Arr::get($subActivity, 'total', '') }} {{ @$fqs[$key] }} {{ @$fks[$key] }}{{ $labour_total_hours }} {{ $labour_totals }} {{ $manager_total_hours }} {{ $manager_totals }} {{ $design_total_hours }} {{ $design_totals }} {{ $material_costs }} {{ $plant_costs }}
@isset($fq) @foreach($fq as $key=>$value) @endforeach @endisset @php $sact = 0; @endphp @if($subActivity->activities->isNotEmpty()){ @foreach($subActivity->activities as $activity){ @php $sact = 0; $sact = $sact + 1; $expr = '/(?<=\s|^)[a-z]/i'; $string_area = $mainActivity->area; preg_match_all($expr, $string_area, $matches_area); $result_area = implode('', $matches_area[0]); $result_area = strtoupper($result_area); $string_level = $mainActivity->level; preg_match_all($expr, $string_level, $matches_level); $result_level = implode('', $matches_level[0]); $result_level = strtoupper($result_level); @endphp @php $labour_totala = 0; $labour_total_houra = 0; $manager_totala = 0; $material_costa = 0; $plant_costa = 0; $design_totala = 0; $manager_total_houra = 0; $material_cost_houra = 0; $plant_cost_houra = 0; $design_total_houra = 0; $act = $act+1; $w = 0; $unit_trim = preg_replace('/\s+/', '', $activity->unit); if($project->formulas->isNotempty()){ foreach($project->formulas as $formula){ if($unit_trim == $formula->keyword){ $labour_totala = $labour_totala + ($activity->rate * $activity->quantity); $labour_total_houra = $labour_total_houra + ($activity->quantity); @$fqa[$unit_trim] = $fqa[$unit_trim]+($activity->quantity); @$fka[$unit_trim] = $fka[$unit_trim] + ($activity->rate * $activity->quantity); $w = $w+1; } } } if($unit_trim == "mhr"){ $manager_totala = $manager_totala + ($activity->rate * $activity->quantity); $manager_total_houra = $manager_total_houra + ($activity->quantity); } if($unit_trim == "dhr"){ $design_totala = $design_totala + ($activity->rate * $activity->quantity); $design_total_houra = $design_total_houra + ($activity->quantity); } if($unit_trim == "nr"){ $material_costa = $material_costa + ($activity->rate * $activity->quantity); $material_cost_houra = $material_cost_houra + ($activity->quantity); } if($unit_trim == "nrp"){ $plant_costa = $plant_costa + ($activity->rate * $activity->quantity); $plant_cost_houra = $plant_cost_houra + ($activity->quantity); } @endphp @isset($fq) @foreach($fq as $key=>$value) @endforeach @endisset @php $fqa=array(); $fka=array(); @endphp @endforeach @endif
Sr No. Activity Quantity Rate Total Unit Cost Rate Profit {{ $key }} cost{{ $labour_total_formula }} cost mhr cost dhr cost nr cost nrp cost
{{ Arr::get($activity, 'item_code', $result_area.'-'.$mainActivity->main_code.'-'.$result_level.'-'.$subActivity->sub_code.'-'.$sact) }} {{ Arr::get($activity, 'activity', '') }} {{ Arr::get($activity, 'quantity', '') }} {{ Arr::get($activity, 'selling_cost', '') }} {{ Arr::get($activity, 'total', '') }} {{ Arr::get($activity, 'unit', '') }} {{ Arr::get($activity, 'rate', '') }} {{ $activity->selling_cost-$activity->rate }}{{ @$fqa[$key] }} {{ @$fka[$key] }}{{ $labour_total_houra }} {{ $labour_totala }} {{ $manager_total_houra }} {{ $manager_totala }} {{ $design_total_houra }} {{ $design_totala }} {{ $material_costa }} {{ $plant_costa }}