{{ $complain->company->company_name ?? '' }}

{{ $complain->company->company_address ?? '' }}
{{ $complain->company->area->area_name ?? '' }}, {{ $complain->company->city->city_name ?? '' }}, {{ $complain->company->state->state_name ?? '' }}, {{ $complain->company->country->country_name ?? '' }}, {{ $complain->company->company_pincode ?? '' }}
@if ( $complain->company->company_gstin) GST No: {{ $complain->company->company_gstin ?? '' }}, @endif Email: {{ $complain->company->company_email ?? '' }}
Phone No: {{ $complain->company->company_phone_no_1 ?? '' }}, {{ $complain->company->company_phone_no_2 ?? '' }}

To,

{{ $complain->customer->customer_name ?? '' }}

{{ $complain->customerAddress->customer_address ?? '' }}, {{ $complain->customerAddress->area->area_name ?? '' }}, {{ $complain->customerAddress->city->city_name ?? '' }}, {{ $complain->customerAddress->state->state_name ?? '' }}, {{ $complain->customerAddress->customer_pincode ?? '' }}, {{ $complain->customerAddress->country->country_name ?? '' }}
@if ($complain->customer->customer_phone_no_1) Phone No: {{ $complain->customerAddress->customer_address_phone_no ?? $complain->customer->customer_phone_no_1 }}
@endif @if ($complain->customer->customer_gstin) GST No: {{ $complain->customer->customer_gstin ?? '' }} @endif

@if ($complain->complain_reported_by != NULL) @endif @if ($complain->technician_id != NULL) @endif
Complain No {{ $complain->complain_prefix }}/{{ $complain->complain_financial_year }}/{{ $complain->complain_number }}
Complain Register Date {{ \Carbon\Carbon::parse($complain->complain_date)->format('d/m/Y') ?? '' }}
Complain Reported By

{{$complain->complain_reported_by}}

Technician Name

{{$complain->technician->employee_first_name}} {{$complain->technician->employee_last_name}}

COMPLAIN
Machine Details
{{-- --}} {{-- --}} @php // Group complain items by machine number $groupedItems = $complain->complainItems ->groupBy(function($item) { return $item->serviceItems->serviceMachines->machine_no ?? 'unknown'; }); @endphp @foreach ($groupedItems as $machineNo => $items) @php // Unique items by service_id to get AMC info $filteredItems = $items->unique('service_id'); // Get AMC display values for comparison $amcDetails = $filteredItems->map(function($item) { return [ 'amc_status' => $item->amc_status, 'amc_type' => $item->serviceItems->service->amc_type ?? '', 'start' => \Carbon\Carbon::parse($item->serviceItems->service->amc_start_date)->format('d/m/Y'), 'end' => \Carbon\Carbon::parse($item->serviceItems->service->amc_end_date)->format('d/m/Y'), ]; }); // Check if all AMC details are the same $firstAmc = $amcDetails->first(); $isSameAmc = $amcDetails->every(fn($amc) => $amc === $firstAmc); @endphp @foreach ($items->values() as $index => $complainItem) @if ($index === 0) @endif {{-- AMC Status Column --}} @if ($isSameAmc && $index === 0) @elseif (!$isSameAmc) @php $amcItem = $filteredItems->firstWhere('service_id', $complainItem->service_id); @endphp @endif @if ($index === 0) @endif @endforeach @endforeach
Machine No AMC StatusProduct CategoryProduct Brand AC TypeAC Indoor Type AC Location AreaModel No Serial No Complain Type Complain Remarks
{{ $complainItem->serviceItems->serviceMachines->machine_no ?? '' }} {{ $firstAmc['amc_status'] }} ({{ $firstAmc['amc_type'] }})
Start Date: {{ $firstAmc['start'] }}
End Date: {{ $firstAmc['end'] }}
@if ($amcItem) {{ $amcItem->amc_status }} ({{ $amcItem->serviceItems->service->amc_type ?? '' }})
Start Date: {{ \Carbon\Carbon::parse($amcItem->serviceItems->service->amc_start_date)->format('d/m/Y') ?? '' }}
End Date: {{ \Carbon\Carbon::parse($amcItem->serviceItems->service->amc_end_date)->format('d/m/Y') ?? '' }} @endif
{{ $complainItem->serviceItems->product_brand->product_brand_name ?? '' }} {{ $complainItem->serviceItems->service_item_type }} {{ $complainItem->serviceItems->model_no }} {{ $complainItem->serviceItems->serial_no }}{{ $complainItem->complain_type }} {{ $complainItem->remarks }}
Breakdown Report
@foreach ($breakdowns as $breakdown) @php $parameters = [ ['Voltage (1-Ph)', $breakdown->voltage_1_ph_before, $breakdown->voltage_1_ph_after], ['Voltage (3-Ph)', $breakdown->voltage_3_ph_before, $breakdown->voltage_3_ph_after], ['Earthing Volt(N-E)', $breakdown->earthing_volt_before, $breakdown->earthing_volt_after], ['Section Pressure (PSI)', $breakdown->section_pressure_before, $breakdown->section_pressure_after], ['Discharge Pressure (PSI)', $breakdown->discharge_pressure_before, $breakdown->discharge_pressure_after], ['Compressor (AMP)', $breakdown->compressor_before, $breakdown->compressor_after], ['Unit (AMP)', $breakdown->unit_before, $breakdown->unit_after], ['Room Temperature', $breakdown->room_temperature_before, $breakdown->room_temperature_after], ['Return Air Temperature', $breakdown->return_air_before, $breakdown->return_air_after], ['Grill Air Temperature', $breakdown->grill_air_before, $breakdown->grill_air_after], ['Ambient Temperature', $breakdown->ambient_before, $breakdown->ambient_after], ['Grill Temp', $breakdown->grill_temp_before, $breakdown->grill_temp_after], ['AMP', $breakdown->amp_before, $breakdown->amp_after], ]; $parts = [ ['Compressor', $breakdown->compressor, $breakdown->compressor_action], ['IDU Fan Motor', $breakdown->idu_fan_motor, $breakdown->idu_fan_motor_action], ['ODU Fan Motor', $breakdown->odu_fan_motor, $breakdown->odu_fan_motor_action], ['Contector', $breakdown->contector, $breakdown->contector_action], ['Capacitor', $breakdown->capacitor, $breakdown->capacitor_action], ['Relay / OLP', $breakdown->relay_olp, $breakdown->relay_olp_action], ['IDU PCB', $breakdown->idu_pcb, $breakdown->idu_pcb_action], ['ODU PCB', $breakdown->odu_pcb, $breakdown->odu_pcb_action], ['IDU Cooling Coil', $breakdown->idu_colling_coil, $breakdown->idu_colling_coil_action], ['ODU Cooling Coil', $breakdown->odu_colling_coil, $breakdown->odu_colling_coil_action], ['Refrigeration', $breakdown->refrigeration, $breakdown->refrigeration_action], ['IDU Service Required', $breakdown->idu_service_required, $breakdown->idu_service_required_action], ['ODU Service Required', $breakdown->odu_service_required, $breakdown->odu_service_required_action], ]; $rowCount = max(count($parameters), count($parts)); @endphp @for ($i = 0; $i < $rowCount; $i++) @if ($i === 0) @endif {{-- Technical Parameter --}} {{-- Parts & Material --}} @if ($i === 0) @endif @endfor @endforeach
Machine No Technical Parameter Before After Part Name Requirement Action Breakdown Remarks
{{ $breakdown->complainItems->machine->machine_no }}{{ $parameters[$i][0] ?? '' }} {{ $parameters[$i][1] ?? '' }} {{ $parameters[$i][2] ?? '' }}{{ $parts[$i][0] ?? '' }} {{ $parts[$i][1] ?? '' }} {{ $parts[$i][2] ?? '' }}{{ $breakdown->remarks }}