hackroot
238
11
Laravel

Hiding a section of a table when empty in laravel

Posted 1 month ago by hackroot

Hi, I am working on a pos system with laravel, currently i am trying to hide empty options on th pos receipt whe they are empty. Example I have a section for Tax, Discounts, Change, and several others however my client may not make use of Tax during sales. Is there any possible way i can make 'Tax' visible only when a value has been entered but invisible even on printed receipt when null?

My Code is Below;

@lang('form.items') @lang('form.qty') @lang('form.price') @lang('form.total')
            @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>
            <tr>
                <td colspan="3" class="text-right">@lang('form.gross_total')</td>
                <td class="text-right"><?php echo format_currency( $invoice->gross_total); ?></td>
            </tr>
            <tr>
                <td colspan="3" class="text-right" >@lang('form.discount')</td>
                <td class="text-right"><?php echo format_currency( $invoice->discount_total); ?></td>
            </tr>
            <tr>
                <td colspan="3" class="text-right">@lang('form.tax')</td>
                <td class="text-right"><?php echo format_currency( $invoice->tax_total); ?></td>
            </tr>


            <tr>
                <td colspan="3" class="text-right">@lang('form.total')</td>
                <td class="text-right"><?php echo format_currency( $invoice->net_total ); ?></td>
            </tr>
            <tr>
                <td colspan="3" class="text-right">@lang('form.cash_round')</td>
                <td class="text-right"><?php echo format_currency( $invoice->cash_rounded_amount ); ?></td>
            </tr>
            <tr>
                <td colspan="3" class="text-right">@lang('form.balance')</td>
                <td class="text-right"><?php echo format_currency( $invoice->balance ); ?></td>
            </tr>

            <tr>
                <td colspan="3" class="text-right">@lang('form.tendered')</td>
                <td class="text-right"><?php echo format_currency( $invoice->amount_received ); ?></td>
            </tr>

            <tr>
                <td colspan="3" class="text-right">@lang('form.change')</td>
                <td class="text-right"><?php echo format_currency( $invoice->amount_received - $invoice->balance ); ?></td>
            </tr>


            </tfoot>
        </table>

Please check and help me thanks

Please sign in or create an account to participate in this conversation.