首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何在刀片中仅当null、zero或empty时隐藏表部分,

如何在刀片中仅当null、zero或empty时隐藏表部分,
EN

Stack Overflow用户
提问于 2019-06-20 13:29:39
回答 2查看 524关注 0票数 0

我在一个laravel Pos系统上工作,我想知道如何在laravel 5.4中,特别是在打印收据时,使表格部分/行仅当为空、零或null时隐藏?

我已经尝试使用@if() @endif语句,但不起作用。

代码语言:javascript
复制
<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>

我希望当我打印收据时,税金、现金周转和折扣行是不可见的,但它仍然可以打印。我目前在代码中看不到错误。只有当字段或行包含有效信息时,输出才会显示它们。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56679502

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档