@php $scopeOfWorks = \App\Models\ScopeOfWork::all(); $areas = \App\Models\Area::all(); $setting = \App\Models\Setting::where('name', 'IfAddTierManually')->first(); $uoms = \App\Models\Uom::select('id', 'name')->get(); $scopeOfWorkItems = ''; $areaItems = ''; foreach ($scopeOfWorks as $item){ $scopeOfWorkItems .= ''; } foreach ($areas as $item){ $areaItems .= ''; } $agreement = \App\Models\Agreement::find(request()->route('id')); $agreementItem = \App\Models\AgreementItem::where('agreement_id', $agreement->id) ->where('revision', 'like', '%REV%') ->orderBy('created_at', 'desc')->first(); $agreementItemList = \App\Models\AgreementItemList::where('agreement_id', $agreement->id)->where('agreement_item_id', $agreementItem->id)->orderBy('id', 'asc')->get(); $totalCur = $agreementItemList->count(); $curItems = ''; $rowRT1IdxTemp = 0; $rowRT2IdxTemp = 0; $rowRT1Idx = 1; $rowRT2Idx = 1; $rowRT3Idx = 1; $rowRT4Idx = 1; $rowStepNum = 1; $itTier1 = 0; $itTier2 = 0; $itTier3 = 0; $endOfTier3 = 0; $marginIndex = 0; $amountTotal = 0; function mapItemMargin($margins, $rowRT3Idx, $sales_item_children_id, $marginIndex, $quantity, $isAmount=false){ $total = 0; $getTotalSum = 0; $getTotalSumWithMargin = 0; $marginChillIndex = 0; $html = null; $iMargin = 1; $html .= '
'; if ($margins->count() > 0) { foreach ($margins as $margin) { $getTotalSum += $margin->price * $margin->quantity; $getTotalSumWithMargin += ($margin->price / ( 1 - $margin->margin_percentage / 100 )) * $margin->quantity; $html .= '
is_from_system ? 'readonly': '').'/>
'; $marginChillIndex++; $iMargin++; } } else { if ($isAmount) { $getTotalSum = $isAmount; $getTotalSumWithMargin = $isAmount; } $html .= '

Item not found, please add material first.

'; } $getTotalSum = $quantity * round($getTotalSum); $getTotalSumWithMargin = $quantity * round($getTotalSumWithMargin); $html .= '
'; return $html; } function mapUomFunc($uoms, $selected=false) { $htmlUom = ''; if ($uoms && $uoms->count() > 0){ foreach ($uoms as $uom) { $htmlUom .= ''; } } return $htmlUom; } if($agreementItemList->count()>0){ $i = 0; foreach ($agreementItemList as $key => $current){ if ($current->tier_level==1 && $current->is_area != true) { $rowStepNum++; if ($rowRT1IdxTemp > 0) { $curItems .= ''; $curItems .= ''; $rowRT1IdxTemp = 0; } if ($rowRT2IdxTemp > 0) { $curItems .= ''; $curItems .= ''; $rowRT2IdxTemp = 0; } } if ($current->tier_level==1 && $current->is_area != true) { $amountTotal += $current->amount; $curItems .= '
'; $curItems .= '
Amount ($)
Total Cost : Total Profit : Total Margin % :
'; $curItems .= '
'; $curItems .= '
'; $rowRT1IdxTemp++; $rowRT1Idx++; } if ($current->tier_level==2 && $current->is_area != true) { if ($rowRT2IdxTemp > 0) { $curItems .= '
'; $curItems .= ''; $rowRT2IdxTemp = 0; } } if ($current->tier_level==2 && $current->is_area != true) { $curItems .= '
'; $curItems .= '
Amount ($)
Total Cost : Total Profit : Total Margin % :
is_modified? 'checked' : '').'>
'.mapItemMargin(\App\Models\AgreementItemMargin::where('agreement_item_list_id', $current->id)->get(), $rowRT2Idx, $current->agreement_item_id, $marginIndex, $current->quantity, $current->amount).'
'; $curItems .= '
'; $curItems .= '
'; $rowRT2IdxTemp++; $rowRT2Idx++; } if ($current->tier_level==3 && $current->is_area != true) { $curItems .= '
UOM
QTY
Amount ($)
'.mapItemMargin(\App\Models\AgreementItemMargin::where('agreement_item_list_id', $current->id)->get(), $rowRT3Idx, $current->agreement_item_id, $marginIndex, $current->quantity, $current->amount).'
'; $rowRT3Idx++; } if ($current->is_area && empty($current->title)) { $attrIdArea = ($current->tier_level == 1 ? 'areaT1' : ($current->tier_level == 2 ? 'areaT2' : 'areaT3')); $curItems .= '
'; $curItems .= '
THIS IS BLANK SPACE SECTION
'; $curItems .= '
'; } if ($current->is_area && !empty($current->title)){ $attrIdArea = ($current->tier_level == 1 ? 'areaT1' : ($current->tier_level == 2 ? 'areaT2' : 'areaT3')); $curItems .= '
'; $curItems .= '
THIS IS NOTE SECTION
'; $curItems .= '
'; } if(++$i === $agreementItemList->count()) { $curItems .= '
'; $curItems .= '
'; $rowRT2IdxTemp = 0; $curItems .= ''; $curItems .= '
'; $rowRT1IdxTemp = 0; $rowStepNum++; } $marginIndex++; } } else { $curItems .= '

Item Not Found

click add new item button below to add new requirement field
'; } @endphp

Requirement

{{$agreement->status != 'draft' ? 'Current Version: '.$agreementItem->revision : ''}}
{{-- Items --}}