
<section class="content-header">
    <h1>
       <?php echo app('translator')->getFromJson('front.ordreturn'); ?>
        <small>
            <?php echo e($return->id); ?>

        </small>
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i></button>
    </h1>
</section>

<!-- Main content -->
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <h1>
                <a class="btn print-window pull-right" href="javascript:void(0)" onclick="PrintElem('<?php echo e(route('returns.getPrint',$return->id)); ?>')" role="button">
                    <i class="fa fa-print" aria-hidden="true"></i>
                </a>
            </h1>
        </div>
        <div class="col-md-12">
            <div class="box">
                <div class="box-body">
                    <div class="col-md-12">
                        <div class="invoice-title">

                            <div class="row">
                                <div class="col-md-12">
                                    <div class="col-md-6">
                                        <?php if($settings['logo']): ?>
                                            <div class="pull-left">
                                                <img style="width: 155px;" src="<?php echo e(\Illuminate\Support\Facades\Storage::url($settings['logo'])); ?>">
                                            </div>
                                        <?php endif; ?>
                                        <div class="pull-left">
                                            <h4>
                                                <?php echo $settings['SiteName']; ?>

                                            </h4>
                                            <div class="clearfix"></div>
                                            <?php if($settings['Address']): ?>
                                                <span style="font-size: 16px; "><?php echo $settings['Address']; ?></span>
                                                <div class="clearfix"></div>
                                            <?php endif; ?>
                                            <?php if($settings['mobile']): ?>
                                                <span style="line-height: 30px;"><?php echo e($settings['mobile']); ?></span>
                                            <?php endif; ?>
                                            <br/>
                                            <p style=" background-color: #ccc; padding: 5px;">إشعار دائن للفاتورة الضريبية</p>
                                        </div>
                                    </div>
                                    <div class="col-md-6">
                                        <h5 style="line-height: 25px;" class="pull-right"><?php echo app('translator')->getFromJson('front.invoicenumber'); ?> : <?php echo e($return->id); ?><br>
                                            <?php echo app('translator')->getFromJson('front.client'); ?> : <?php echo e($return->client->name); ?><br>



                                            <?php echo app('translator')->getFromJson('front.payment'); ?> : <?php echo e($return->is_cash?trans('front.cash'):trans('front.from previous balance')); ?> <br>
                                            <?php echo app('translator')->getFromJson('front.date'); ?> : <?php echo e($return->return_date); ?></br>
                                            <?php if($return->order_id): ?>
                                                <p style=" background-color: #ccc; padding: 5px; "><?php echo app('translator')->getFromJson('front.returndfrom'); ?>: <?php echo e(optional($return->order)->invoice_number); ?></p>
                                            <?php endif; ?>

                                        </h5>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <div class="panel panel-default">
                            
                            <div class="panel-body">
                                <div class="table-responsive">

                                    <h3 class="text-center">
                                        <?php if($return->return_type=='sales'): ?>
                                            <?php echo app('translator')->getFromJson('front.ordreturn'); ?>
                                        <?php else: ?>
                                            <?php echo app('translator')->getFromJson('front.purreturn'); ?>
                                        <?php endif; ?>
                                    </h3>
                                    <table class="table table-bordered table-striped">
                                        <thead>
                                        <tr>
                                            <td>#</td>
                                            <td><?php echo app('translator')->getFromJson('front.product'); ?></td>
                                            <?php if($settings['show_category_in_invoice']): ?>
                                                <td><?php echo app('translator')->getFromJson('front.parent'); ?></td>
                                            <?php endif; ?>
                                            <?php if($settings['show_stores_in_invoices']==1): ?>
                                                <td><?php echo app('translator')->getFromJson('front.parent'); ?></td>
                                            <?php endif; ?>
                                            <td><?php echo app('translator')->getFromJson('front.quantity'); ?></td>
                                            <td><?php echo app('translator')->getFromJson('front.unit'); ?></td>
                                            <td><?php echo app('translator')->getFromJson('front.price'); ?></td>
                                            <td><?php echo app('translator')->getFromJson('front.total'); ?></td>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <?php
                                            $total = 0;
                                            $totalQty = 0;
                                            $colspan = 4;
                                        ?>
                                        <?php $__currentLoopData = $return->details; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                                            <?php
                                                $subtotal = $item->pivot->qty*$item->pivot->price;
                                                $total += $subtotal;
                                                $totalQty += ($item->pivot->qty);
                                            ?>
                                            <tr>
                                                <td><?php echo e($loop->iteration); ?></td>
                                                <td><?php echo e($item->name); ?></td>
                                                <?php if($settings['show_category_in_invoice']): ?>
                                                    <td><?php echo e(optional($item->category)->name); ?></td>
                                                    <?php
                                                        $colspan = 5;
                                                    ?>
                                                <?php endif; ?>
                                                <?php if($settings['show_stores_in_invoices']==1): ?>
                                                    <td><?php echo e($item->pivot->store_name); ?></td>
                                                    <?php
                                                        $colspan = 6;
                                                    ?>
                                                <?php endif; ?>
                                                <td><?php echo e($item->pivot->qty); ?></td>
                                                <td><?php echo e($item->pivot->unit_name); ?></td>
                                                <td><?php echo e($item->pivot->price); ?></td>
                                                <td><?php echo e($subtotal); ?></td>
                                            </tr>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                                        </tbody>
                                        <tfoot>
                                            <tr >
                                                <td style="border: none!important;" colspan="<?php echo e($colspan); ?>">
                                                    <div class="row">
                                                        <div class="col-md-12">
                                                            <p class="pull-left">استلمت الاصناف المذكوره عاليه بحالة جيدة وبالكميات المحدده</p>
                                                        </div>
                                                        <div class="clearfix"></div>
                                                        <div class="col-md-12">
                                                            <p class="pull-left">
                                                                إجمالى الكميات : <?php echo e($totalQty); ?>

                                                            </p>
                                                        </div>
                                                        <div class="clearfix"></div>
                                                        <div class="col-md-12">
                                                            <p class="pull-left">
                                                                توقيع المندوب :
                                                            </p>
                                                        </div>
                                                        <div class="clearfix"></div>
                                                        <div class="col-md-12">
                                                            <p class="pull-left">
                                                                توقيع المستلم :
                                                            </p>
                                                        </div>

                                                        <div class="clearfix"></div>
                                                        <div style="direction: rtl" class="col-md-12">
                                                            <?php echo $settings['InvoiceNotes']; ?>

                                                        </div>

                                                    </div>
                                                </td>
                                                <td style="border: none!important;" colspan="2">
                                                    <table class="table table-bordered">
                                                        <tbody>
                                                        <tr>
                                                            <td class="no-line text-center"><?php echo app('translator')->getFromJson('front.tax'); ?> :</td>
                                                            <td class="no-line text-center"><?php echo e($return->tax); ?>%</td>
                                                        </tr>
                                                        <tr>
                                                            <td class="no-line text-center"><?php echo app('translator')->getFromJson('front.total'); ?> :</td>
                                                            <td class="no-line text-center"><?php echo e(currency($return->total,$return->currency, currency()->getUserCurrency(), $format = true)); ?></td>
                                                        </tr>

                                                        <tr>
                                                            <td class="no-line text-center"><?php echo app('translator')->getFromJson('front.discount'); ?></td>
                                                            <td class="no-line text-center">

                                                                <?php
                                                                    $discount = 0;
                                                                    $dist = $return->discount;
                                                                    if($return->discount){
                                                                        if($return->discount_type==2){
                                                                            $discount=$return->total*($return->discount/100);
                                                                            $dist=$discount;
                                                                            //$dist = "%".$return->discount. " ( $discount )";
                                                                        }
                                                                    }
                                                                ?>
                                                                <?php echo e(currency($dist,$return->currency, currency()->getUserCurrency(), $format = true)); ?>


                                                            </td>

                                                        </tr>
                                                        <tr>
                                                            <td class="no-line text-center text-bold"><?php echo app('translator')->getFromJson('front.balance'); ?> :</td>
                                                            <td class="no-line text-center text-bold"><?php echo e($return->client->balnce_text); ?>  </td>
                                                        </tr>

                                                        <tr>
                                                            <td colspan="2" style="border: none!important;">
                                                                <?php
                                                                $check = true;
                                                                try{
                                                                    $datahtml = $settings['SiteName']."\n".
                                                                    " الرقم الضريبى: ".$settings['taxNumber']."\n".
                                                                    "التاريخ : ".$return->created_at->format('Y-m-d')."\n".
                                                                    "رقم الفاتورة: ".$return->id."\n".
                                                                    "إجمالى: ".$return->total."\n".
                                                                    "قيمة الضريبة: ". $return->tax_value;
                                                                    $Qcode = base64_encode(\SimpleSoftwareIO\QrCode\Facades\QrCode::format('png')
                                                                    ->encoding('UTF-8')
                                                                    ->size(200)
                                                                    ->generate($datahtml));
                                                                }catch (\Exception $e){
                                                                    //dd($e->getMessage());
                                                                    $check = false;
                                                                }
                                                            ?>
                                                            <?php if($check): ?>
                                                                <div style="margin-bottom: 5px;">
                                                                    <img src="data:image/png;base64,  <?php echo $Qcode; ?>">
                                                                </div>
                                                            <?php endif; ?>
                                                            </td>
                                                        </tr>
                                                        </tbody>
                                                    </table>
                                                </td>
                                            </tr>
                                        </tfoot>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

</section>
<style>
    .table tr>td{
        text-align: center;
    }
    .table thead tr>td{
        font-weight: bold;
    }
</style>
