Я пытаюсь распечатать данные в табличном формате, если они доступны в заданном диапазоне дат, а затем распечатать как «P-Present» или «A-Absent», но данные не печатаются так, как я хотел.Я не знаю, что можно сделать, поскольку я не могу изменить формат данных массива.
Данные массива:
Array
(
[0] => Array
(
[id] => 39
[asset_id] => 1
[description] => PA25
[created_at] => 2017-08-17 08:13:11
[updated_at] => 2019-02-11 11:48:39
[status] => 1
[cost_code] => P0005
[weight] => 0.00
[deleted_at] =>
[active_from] => 2019-01-21
[inactive_from] => 0000-00-00
[asset] => Array
(
[id] => 1
[name] => Mini Paver
[default_rate] =>
[tax_id] => 1
[nominal_code] => 00001
[created_at] => 2017-07-24 20:35:55
[updated_at] => 2018-09-06 17:53:08
[status] => 1
[weekday_am] => 260
[weekday_pm] => 260
[weekend_am] => 260
[weekend_pm] => 260
[group_id] => 1
[cost_weekday_am] => 200
[cost_weekend_am] => 200
[cost_weekend_pm] => 200
[cost_weekday_pm] => 200
[project_code] =>
[manufacturer] =>
[model] =>
[purchase_date] => 1970-01-01
[warranty_expiry] =>
[mot_due] =>
[group] => Array
(
[id] => 1
[name] => Pavers
[status] => 1
[created_at] => 2017-07-13 16:45:42
[updated_at] => 2017-07-13 16:45:42
)
)
[asset_id_allocations] => Array
(
[0] => Array
(
[id] => 16541
[job_id] => 9623
[job_details_id] => 27430
[asset_types_id] => 39
[date] => 2019-01-14
[shift] => AM
[created_at] => 2019-01-11 16:33:51
[updated_at] => 2019-01-11 16:33:51
[supplier_id] => 0
[asset_types] => Array
(
[id] => 39
[asset_id] => 1
[description] => PA25
[created_at] => 2017-08-17 08:13:11
[updated_at] => 2019-02-11 11:48:39
[status] => 1
[cost_code] => P0005
[weight] => 0.00
[deleted_at] =>
[active_from] => 2019-01-21
[inactive_from] => 0000-00-00
)
[job_details] => Array
(
[id] => 27430
[asset_id] => 1
[job_id] => 9623
[qty] => 1
[est_start_date] => 2019-01-08
[days] =>
[est_off_date] => 2019-01-14
[rate] => 1300
[row_total] => 1300
[extra] => 0
[assigned_asset] => 1
[status] =>
[comments] =>
[created_at] => 2019-01-04 15:44:55
[updated_at] => 2019-01-17 19:33:51
[bundle_id] =>
[bundle_code] =>
[week_count] => 5
[nonweek_count] =>
[week_rate] => 260
[nonweek_rate] => 260
[week_total] => 260
[nonweek_total] => 260
[cost_only] => 0
[switcher] => T
[jobs] => Array
(
[id] => 9623
[enquiry_date] => 2018-12-20
[customer_id] => 8
[customer_name] => C R MacDonald Ltd
[site_address] => 1750
[enquiry_contact] => 484
[customer_ref] => 074993
[appl_payment] => 0
[total_net] => 1690
[total_vat] => 338
[total_gross] => 2028
[job_notes] => Delivery F6 - Collection F3
[invoice_Date] => 2019-01-17
[invoice_no] => H9578
[invoice_notes] =>
[reminder_date] =>
[reminder_notes] =>
[status] => Archived
[created_at] => 2018-12-20 19:23:25
[updated_at] => 2019-01-18 16:15:57
[taxcode] => 1
[shift] => AM
[weekend] => 0
[supply_lay] => 0
[profit_loss] =>
[paid] => 0
[job_cancel_option] =>
[job_cancel_text] =>
[shift_time] => 07:30
[query_date] =>
[query_notes] =>
[cost_only] => 0
[order_value] =>
[credit_net] => 0
[discount_total] => 0
[site_contact] => 411
[latitude] =>
[longitude] =>
[d_a] => 0
[service_charge] => 0
[service_charge_amount] => 0
[utilisation_sheet] => 0
[end_time] => 15:30
[user_id] => 26
[customer_sites] => Array
(
[id] => 1750
[customer_id] => 8
[address1] => Poplars Farm
[address2] => Forshaw Heath Road
[address3] => Earlswood
[town] => Solihull
[area] =>
[postcode] => B94 5JX
[created_at] => 2019-01-04 15:42:49
[updated_at] => 2019-01-08 15:02:39
[custom_transport] => 0
[customer] => Array
(
[id] => 8
[customer_code] => 1094
[customer_name] => C R MacDonald Ltd
[address1] => 27 Heming Road
[address2] => Washford Industrial Estate
[address3] =>
[town] => Redditch
[area] => Worcestershire
[postcode] => B98 0DH
[phone] => 01527 518998
[price_id] => 4
[appl_payment] => 0
[created_at] => 2018-01-16 13:38:47
[updated_at] => 2019-01-21 21:57:03
[status] => 1
[pay_up_front] => 0
[contact_method] => Email
)
)
)
)
)
[1] => Array
(
[id] => 16875
[job_id] => 9780
[job_details_id] => 28423
[asset_types_id] => 39
[date] => 2019-01-17
[shift] => PM
[created_at] => 2019-01-17 18:13:07
[updated_at] => 2019-01-17 18:13:07
[supplier_id] => 0
[asset_types] => Array
(
[id] => 39
[asset_id] => 1
[description] => PA25
[created_at] => 2017-08-17 08:13:11
[updated_at] => 2019-02-11 11:48:39
[status] => 1
[cost_code] => P0005
[weight] => 0.00
[deleted_at] =>
[active_from] => 2019-01-21
[inactive_from] => 0000-00-00
)
[job_details] => Array
(
[id] => 28423
[asset_id] => 1
[job_id] => 9780
[qty] => 1
[est_start_date] => 2019-01-17
[days] =>
[est_off_date] => 2019-01-17
[rate] => 300
[row_total] => 300
[extra] => 0
[assigned_asset] => 1
[status] =>
[comments] =>
[created_at] => 2019-01-17 18:12:10
[updated_at] => 2019-01-22 21:15:20
[bundle_id] =>
[bundle_code] =>
[week_count] => 1
[nonweek_count] =>
[week_rate] => 300
[nonweek_rate] => 300
[week_total] => 300
[nonweek_total] => 300
[cost_only] => 0
[switcher] => T
[jobs] => Array
(
[id] => 9780
[enquiry_date] => 2019-01-17
[customer_id] => 15
[customer_name] => Eurovia - Surfacing (5054)
[site_address] => 1825
[enquiry_contact] => 27
[customer_ref] => 4240610480
[appl_payment] => 0
[total_net] => 1171.85
[total_vat] => 234.37
[total_gross] => 1406.22
[job_notes] =>
[invoice_Date] => 2019-01-21
[invoice_no] => H9733
[invoice_notes] =>
[reminder_date] =>
[reminder_notes] =>
[status] => Locked
[created_at] => 2019-01-17 18:09:14
[updated_at] => 2019-01-22 21:16:12
[taxcode] => 1
[shift] => PM
[weekend] => 0
[supply_lay] => 0
[profit_loss] =>
[paid] => 0
[job_cancel_option] =>
[job_cancel_text] =>
[shift_time] => 21:30
[query_date] =>
[query_notes] =>
[cost_only] => 0
[order_value] =>
[credit_net] => 0
[discount_total] => 0
[site_contact] => 27
[latitude] =>
[longitude] =>
[d_a] => 0
[service_charge] => 0
[service_charge_amount] => 0
[utilisation_sheet] => 0
[end_time] => 05:30
[user_id] => 26
[customer_sites] => Array
(
[id] => 1825
[customer_id] => 15
[address1] => M5 Junction 11
[address2] => Southbound
[address3] =>
[town] =>
[area] =>
[postcode] =>
[created_at] => 2019-01-17 18:08:49
[updated_at] => 2019-01-18 22:21:58
[custom_transport] => 0
[customer] => Array
(
[id] => 15
[customer_code] => 1058
[customer_name] => Eurovia - Surfacing (5054)
[address1] => PO Box 724
[address2] =>
[address3] =>
[town] => Winchester
[area] =>
[postcode] => SO23 5BU
[phone] => 01992 781101
[price_id] => 2
[appl_payment] => 0
[created_at] => 2018-01-16 14:00:47
[updated_at] => 2019-01-18 22:21:58
[status] => 1
[pay_up_front] => 0
[contact_method] => Email
)
)
)
)
)
)
)
)
Код таблицы в блейде:
<table id="card_tbl" class="table table-bordered card_tbl_main card_view" cellspacing="0" width="100%">
<thead>
<tr>
<th colspan="3" style="width: 90px;"></th>
@foreach($daterange as $date)
<th colspan="2" style="width:280px;">{{ $date->format('D d M Y') }}</th>
@endforeach
</tr>
<tr role="row">
<th></th>
<th></th>
<th></th>
@foreach($daterange as $date)
<th>AM</th>
<th>PM</th>
@endforeach
</tr>
</thead>
<tbody>
@foreach($asset_array as $final)
<tr>
<td>
{{ trim($final['asset']['group']['name']) }}
</td>
<td>
{{ trim($final['asset']['name']) }}
</td>
<td>
{{ trim($final['description']) }}
</td>
@foreach($daterange as $day)
<td>
@if(count($final['asset_id_allocations']) > 0)
@foreach($final['asset_id_allocations'] as $allocation)
@if($allocation['date'] == $day->format('Y-m-d') && $allocation['job_details']['jobs']['shift'] == "AM")
P
@else
A
@endif
@endforeach
@else
A
@endif
</td>
<td>
@if(count($final['asset_id_allocations']) > 0)
@foreach($final['asset_id_allocations'] as $allocation)
@if($allocation['date'] == $day->format('Y-m-d') && $allocation['job_details']['jobs']['shift'] == "PM")
P
@else
A
@endif
@endforeach
@else
A
@endif
</td>
@endforeach
</tr>
@endforeach
</tbody>
</table>
Это вывод, который я получаю:
Но я хочу, чтобы вывод был похож на следующий формат:
Любые предложения, пожалуйста.
Этот код выводит меня неверно: здесь у меня есть диапазон дат на 5 дней, что означает 10 столбцов, но у меня есть asset_id_allocations
выходных данных только для двух дат, одна для AM
другая для PM
на другую дату.
@foreach($daterange as $day)
<td>
@if(count($final['asset_id_allocations']) > 0)
@foreach($final['asset_id_allocations'] as $allocation)
@if($allocation['date'] == $day->format('Y-m-d') && $allocation['job_details']['jobs']['shift'] == "AM")
P
@else
A
@endif
@endforeach
@else
A
@endif
</td>
<td>
@if(count($final['asset_id_allocations']) > 0)
@foreach($final['asset_id_allocations'] as $allocation)
@if($allocation['date'] == $day->format('Y-m-d') && $allocation['job_details']['jobs']['shift'] == "PM")
P
@else
A
@endif
@endforeach
@else
A
@endif
</td>
@endforeach