@extends('layouts.report') @section('title', '請求明細書') @section('content') @php $RECORDS_PER_PAGE = 18; $pages = []; $page = []; $total = []; $total['件数'] = 0; $total['金額'] = 0; $total['入金額'] = 0; $total['入金値引額'] = 0; foreach($viewdata['billingCustomers'] as $billingCustomer) { $page = $billingCustomer; $page['Details'] = []; $pagenum = 1; $page['pagenum'] = $pagenum; if (count($billingCustomer['Details']) == 0) { // 明細が無い場合でも 1 ページは印刷する $page['pagetotal'] = 1; } else { $page['pagetotal'] = ceil(count($billingCustomer['Details']) / $RECORDS_PER_PAGE); } foreach($billingCustomer['Details'] as $detail) { $page[] = $detail; $page['Details'][] = $detail; if (count($page['Details']) >= $RECORDS_PER_PAGE) { $pages[] = $page; $page = $billingCustomer; $page['Details'] = []; $pagenum++; $page['pagenum'] = $pagenum; if (count($billingCustomer['Details']) == 0) { // 明細が無い場合でも 1 ページは印刷する $page['pagetotal'] = 1; } else { $page['pagetotal'] = ceil(count($billingCustomer['Details']) / $RECORDS_PER_PAGE); } } } if ($page['pagenum'] <= $page['pagetotal']) { $pages[] = $page; } } @endphp @foreach($pages as $i => $page) @include('closing/report02-01',[ 'title' => '請求明細書', 'pagenum' => $page['pagenum'], 'pagetotal' => $page['pagetotal'], 'record_per_page' => $RECORDS_PER_PAGE, 'pagedata'=>$page, 'total' => $total, ]) @endforeach @endsection