我在一个laravel Pos系统上工作,我想知道如何在laravel 5.4中,特别是在打印收据时,使表格部分/行仅当为空、零或null时隐藏?
我已经尝试使用@if() @endif语句,但不起作用。
<table class="" style="width: 290px;">
<thead>
<tr>
<th>@lang('form.items')</th>
<th class="text-center">@lang('form.qty')</th>
<th class="text-center">@lang('form.price')</th>
<th class="text-right">@lang('form.total')</th>
</tr>
</thead>
<tbody>
@foreach($invoice->sold_items as $lineRow)
<tr>
<td class="first-column"><?php echo $lineRow->item->item_name ." - ". $lineRow->unit->unit_name ; ?> </td>
<td class="text-center"><?php echo $lineRow['quantity']; ?></td>
<td class="text-right"><?php echo format_currency($lineRow['unit_price']); ?></td>
<td class="text-right"><?php echo format_currency($lineRow['sub_total']); ?></td>
</tr>
<tr>
<td colspan="4"></td>
</tr>
@endforeach
</tbody>
<tfoot>
@if ($invoice->gross_total)
<tr>
<td colspan="3" class="text-right">@lang('form.gross_total')</td>
<td class="text-right">{{ format_currency( $invoice->gross_total) }}</td>
</tr>
@endif
@if ($invoice->discount_total)
<tr>
<td colspan="3" class="text-right" >@lang('form.discount')</td>
<td class="text-right">{{ format_currency( $invoice->discount_total) }}</td>
</tr>
@endif
@if ($invoice->tax_total)
<tr>
<td colspan="3" class="text-right">@lang('form.tax')</td>
<td class="text-right">{{ format_currency( $invoice->tax_total) }}</td>
</tr>
@endif
@if ($invoice->net_total)
<tr>
<td colspan="3" class="text-right">@lang('form.total')</td>
<td class="text-right">{{ format_currency( $invoice->net_total ) }}</td>
</tr>
@endif
@if ($invoice->cash_rounded_amount)
<tr>
<td colspan="3" class="text-right">@lang('form.cash_round')</td>
<td class="text-right">{{ format_currency( $invoice->cash_rounded_amount ) }}</td>
</tr>
@endif
@if ($invoice->balance)
<tr>
<td colspan="3" class="text-right">@lang('form.balance')</td>
<td class="text-right">{{ format_currency( $invoice->balance ) }}</td>
</tr>
@endif
<tr>
<td colspan="3" class="text-right">@lang('form.tendered')</td>
<td class="text-right">{{ format_currency( $invoice->amount_received ) }}</td>
</tr>
<tr>
<td colspan="3" class="text-right">@lang('form.change')</td>
<td class="text-right">{{ format_currency( $invoice->amount_received - $invoice->balance ) }}</td>
</tr>
</tfoot>
</table>
我希望当我打印收据时,税金、现金周转和折扣行是不可见的,但它仍然可以打印。我目前在代码中看不到错误。只有当字段或行包含有效信息时,输出才会显示它们。
https://stackoverflow.com/questions/56679502
复制相似问题