mercredi 19 juin 2019

How to Hide table sections only when null, zero or empty in blade,

I am working on a laravel Pos System and I want to How can I make a table section/row hidden only when empty, zero or null with blade in laravel 5.4 specially when receipt is printed?

I have already tried using @if() @endif statements but its not working.

<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"></td>
            </tr>
                @endif

                @if ($invoice->discount_total)
            <tr>
                <td colspan="3" class="text-right" >@lang('form.discount')</td>
                <td class="text-right"></td>
            </tr>
                @endif

                @if ($invoice->tax_total)
            <tr>
                <td colspan="3" class="text-right">@lang('form.tax')</td>
                <td class="text-right"></td>
            </tr>
                @endif

                @if ($invoice->net_total)
            <tr>
                <td colspan="3" class="text-right">@lang('form.total')</td>
                <td class="text-right"></td>
            </tr>
                @endif

                @if ($invoice->cash_rounded_amount)
            <tr>
                <td colspan="3" class="text-right">@lang('form.cash_round')</td>
                <td class="text-right"></td>
            </tr>
                @endif

                @if ($invoice->balance)
            <tr>
                <td colspan="3" class="text-right">@lang('form.balance')</td>
                <td class="text-right"></td>
            </tr>
                @endif
            <tr>
                <td colspan="3" class="text-right">@lang('form.tendered')</td>
                <td class="text-right"></td>
            </tr>

            <tr>
                <td colspan="3" class="text-right">@lang('form.change')</td>
                <td class="text-right"></td>
            </tr>


            </tfoot>
        </table>

I expect that the Tax, Cash round and Discount rows to be invisible when i order a print of the receipt but it still print. I see no error in code currently. The output should show the fields or rows only when they have valid information.



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2Xoa9fv
via IFTTT

Aucun commentaire:

Enregistrer un commentaire