Suscripciones

{{-- fecha --}} @php $date = date('d-m-Y'); $general_months = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; @endphp
Fecha: {{ $date }}
{{-- tabla --}} @foreach ($records as $idx => $record) @php $parent = \App\Models\Tenant\Person::find($record->parent_id); $grade = null; $student = \Modules\Suscription\Models\Tenant\UserRelSuscriptionPlan::where('children_customer_id', $record->id) ->latest() ->first(); if ($student) { $grade = $student->grade; } $months = []; // $currentYear = date('Y'); $months = []; //for loop for last 12 months for ($i = 0; $i < 12; $i++) { $month = $i + 1; $date = Carbon\Carbon::createFromDate($currentYear, $month, 1)->format('Y-m-d'); $payment_suscription = \Modules\Suscription\Models\Tenant\SuscriptionPayment::where('child_id', $record->id) ->where('client_id', $record->parent_id) ->where('period', $date) ->get(); $total = 0; foreach ($payment_suscription as $key => $value) { if ($value->document) { $periods = count($value->document->periods) != 0 ? count($value->document->periods) : 1; $total += $value->document->total / $periods; } else { $periods = count($value->sale_note->periods) != 0 ? count($value->sale_note->periods) : 1; $total += $value->sale_note->total / $periods; } } $months[] = $total; $general_months[$i] += $total; } $color = ''; if ($record->color) { $color = 'background-color:' . $record->color . ';'; } @endphp @if ($parent) @else @endif @if ($color != '') @else @endif @foreach ($months as $month) @endforeach @endforeach @foreach ($general_months as $month) @endforeach
# Nombre Cliente Celular Comentario Categoría Fecha Color Enero Febrero Marzo Abril Mayo Junio Julio Agosto Septiembre Octubre Noviembre Diciembre
{{ $idx + 1 }} {{ $record->name }}{{ $parent->name }} {{ $parent->number }} {{ $record->observation }} {{ $grade }} {{ $record->person_date }} {{ $month }}
Total {{ $month }}