<?php echo $__env->make('Admin.header', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

<br>
<br>
<br>






<div class="main-content" style="overflow: hidden;">
    <?php echo $__env->make('Admin.modal', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
            <!--page title start-->
            <div class="page-title" style="float: left;">
                <h4 class="mb-0">View Total Order
                    <small></small>
                </h4>
              
            </div>
            
             <div class="page-title" style="float: right; ">
                   
             <div class="page-title" style="float: right; ">
                 <a href="<?php echo e(url('/Admin-dashboard')); ?>" class="btn btn-danger">X</a>
            </div>
            </div>
            <!--page title end-->


            <div class="container" style="overflow-x: scroll; max-height:726px">

                <!-- state start-->
                <div class="row">
                    <div class=" col-sm-12">
                        <div class="mb-4">
                   
                                    <span id="sms"></span>
                            <div class="card-body">
                                <table id="example" class="display nowrap" style="width:100%;text-align:center;">
                                    <thead>
                                    <tr>
                                       <th>SL</th>
                                       <!--<th>SL</th>-->
                                        <th>Order ID</th>
                                        <th>Date</th>
                                        <th>Billing Name</th>
                                        <th>Shipping Name</th>
                                        <th>Billing Phone</th>
                                        <th>Shipping Phone</th>
                                        <th>Shipping Area</th>
                                        <th>Payment Method</th>
                                        <th>Transaction ID</th>
                                      
                                        <th>Product Id</th>
                                        <th>Unit Price</th>
                                        <th>Quantity</th>
                                        <th>Delivery Charge</th>
                                        <th>Sub Total</th>
                                        <th>Grand Total</th>
                                        <th>Status</th>
                                        <th>Action</th>
                                    </tr>
                                    </thead>
                                    <tfoot>
                                    <tr>
                                       <th>SL</th>
                                       <!--<th>SL</th>-->
                                        <th>Order ID</th>
                                        <th>Date</th>
                                        <th>Billing Name</th>
                                        <th>Shipping Name</th>
                                        <th>Billing Phone</th>
                                        <th>Shipping Phone</th>
                                        <th>Shipping Area</th>
                                        <th>Payment Method</th>
                                        <th>Transaction ID</th>
                                        <th>Product Id</th>
                                        
                                        <th>Unit Price</th>
                                        <th>Quantity</th>
                                        <th>Delivery Charge</th>
                                        <th>Sub Total</th>
                                        <th>Grand Total</th>
                                        <th>Status</th>
                                        <th>Action</th>
                                    </tr>
                                    </tfoot>
                                    <tbody>
                                        <?php
                                        $sl=1;
                                        ?>
                                        <?php if(isset($data)): ?>
                                        <?php $__currentLoopData = $data; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $showdata): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        
                                        <?php 
                                            $guest = DB::table('guest')->where('id', $showdata->guest_id)->first();
                                            $delivery_info = DB::table('delivery_infos')->where('id', $showdata->delivery_id)->first();
                                            $zone = DB::table('zones')->where('id', $delivery_info->zone_id)->first();
                                            $shopping_cart = DB::table('shopping_carts')->where('session_id', $showdata->session_id)->first();
                                            $product_productinfo = DB::table('product_productinfo')->where('id', $shopping_cart->product_id)->first();

                                            $product = DB::table('invoices')
                                                ->join('shopping_carts','shopping_carts.session_id','invoices.session_id')
                                                ->join('product_productinfo','product_productinfo.id','shopping_carts.product_id')
                                                ->select('product_productinfo.product_name','product_productinfo.current_price',
                                                'product_productinfo.product_id','invoices.invoice_id','shopping_carts.quantity','shopping_carts.discount_price as dp',
                                                'shopping_carts.sale_price as sp','shopping_carts.current_price as cp')
                                                ->where('invoices.invoice_id',$showdata->invoice_id)
                                                ->get();

                                        ?>

                                        <?php
                                        




                                        ?>
                                      <tr id="tr-<?php echo e($showdata->invoice_id); ?>">

                                        <td title="SL"><?php echo e($sl++); ?></td>
                                        <td title="Order ID"><?php echo e($showdata->invoice_id); ?></td>
                                        <td title="Date"><?php echo e($showdata->created_at); ?></td>
                                        <td title="Bill To Name"><?php echo e($guest->first_name); ?></td>
                                        <td title="Bill To Name"><?php echo e($delivery_info->first_name); ?></td>

                                        <td title="Billing Phone"><?php echo e($guest->phone); ?></td>
                                        <td title="Billing Phone"><?php echo e($delivery_info->phone); ?></td>
                                        <td title="Shipping Area"><?php echo e($delivery_info->address); ?>, <?php echo e($zone->zone_name); ?></td>
                                        <td title="Payment Method"><?php echo e($showdata->payment_type); ?></td>
                                        <td title="Transaction ID"><?php echo e($showdata->trans_id); ?></td>
                                      
                                        <td title="SKU">
                                            <?php if($product): ?>
                                            <?php $__currentLoopData = $product; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $productdata): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                                           <li><?php echo e($productdata->product_id); ?>,</li>

                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            <?php endif; ?>
                                            <br>
                                        
                                        </td>
   

                                      <td title="Unit Price">
                                            
                                             <?php if($product): ?>
                                            <?php $__currentLoopData = $product; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $productdata): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                                           <li><?php echo e($productdata->sp); ?>,</li>

                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            <?php endif; ?>
                                            <!--<?php echo e($shopping_cart->sale_price); ?>-->
                                        
                                        
                                        </td>
                                        <td title="Quantity">
                                            <?php if($product): ?>
                                            <?php $__currentLoopData = $product; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $productdata): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                                           <li><?php echo e($productdata->quantity); ?>,</li>

                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            <?php endif; ?>
                                            <br>
                                        
                                        </td>
                                        <td title="Delivery Charge"><?php echo e($showdata->delivery_charge); ?></td>

                                     
                                        <td title="Sub Total"><?php echo e($showdata->sub_total); ?></td>
                                        <td title="Grand Total"><?php echo e($showdata->grand_total); ?></td>
                                        <td>
                                            <?php if($showdata->status == '0'): ?>
                                            <a class="btn btn-warning btn-sm">pending</a>
                                            <?php elseif($showdata->status == '1'): ?>
                                              <a class="btn btn-info btn-sm">process</a>
                                            
                                            <?php elseif($showdata->status == '5'): ?>
                                              <a class="btn btn-primary btn-sm">shipping</a>
                                            <?php elseif($showdata->status == '2'): ?>
                                              <a class="btn btn-secondary btn-sm">on the way</a>
                                            <?php elseif($showdata->status == '3'): ?>
                                              <a class="btn btn-success btn-sm">complete</a>
                                            <?php elseif($showdata->status == '6'): ?>
                                              <a class="btn btn-info btn-sm">Refound</a>
                                            <?php elseif($showdata->status == '4'): ?>
                                              <a class="btn btn-danger btn-sm">Reject</a>
                                             <?php endif; ?>
                                        </td>
                                        <?php if(Auth('admin')->user()->type == '1'): ?>
                                        <td>
                                            <a class="btn btn-outline-info btn-sm" onclick="loadModelss('<?php echo e($showdata->invoice_id); ?>')" data-toggle="modal" data-target="#myModal" >Edit</a>
                                             <?php if($showdata->status == '0'): ?>
                                             
                                            
                                            <a class="btn btn-outline-info btn-sm" onclick="loadModel('<?php echo e($showdata->invoice_id); ?>')" data-toggle="modal" data-target="#myModal" >Process</a>
                                            <a class="btn btn-outline-warning btn-sm" onclick="protoShipping('<?php echo e($showdata->invoice_id); ?>')">Shipping</a>
                                            <a class="btn btn-outline-primary btn-sm" onclick="proToontheOrder('<?php echo e($showdata->invoice_id); ?>')">On the Way</a>
                                            <a class="btn btn-outline-success btn-sm" onclick="rejecttorefundOrder('<?php echo e($showdata->invoice_id); ?>')">Refound</a>
                                            <a class="btn btn-outline-success btn-sm" onclick="ontheTosuccOrder('<?php echo e($showdata->invoice_id); ?>')">Complete</a>
                                            <a class="btn btn-outline-danger btn-sm" onclick="loadModels('<?php echo e($showdata->invoice_id); ?>')" data-toggle="modal" data-target="#myModal">Reject</a>
                                            <?php elseif($showdata->status == '1'): ?>

                                            <a class="btn btn-outline-warning btn-sm" onclick="protoShipping('<?php echo e($showdata->invoice_id); ?>')">Shipping</a>
                                            <a class="btn btn-outline-primary btn-sm" onclick="proToontheOrder('<?php echo e($showdata->invoice_id); ?>')">On the Way</a>
                                            <a class="btn btn-outline-success btn-sm" onclick="rejecttorefundOrder('<?php echo e($showdata->invoice_id); ?>')">Refound</a>
                                            <a class="btn btn-outline-success btn-sm" onclick="ontheTosuccOrder('<?php echo e($showdata->invoice_id); ?>')">Complete</a>
                                            <a class="btn btn-outline-danger btn-sm" onclick="loadModels('<?php echo e($showdata->invoice_id); ?>')" data-toggle="modal" data-target="#myModal">Reject</a>
                                            
                                            <?php elseif($showdata->status == '5'): ?>
                                            <a class="btn btn-outline-primary btn-sm" onclick="proToontheOrder('<?php echo e($showdata->invoice_id); ?>')">On the Way</a>
                                            <a class="btn btn-outline-success btn-sm" onclick="rejecttorefundOrder('<?php echo e($showdata->invoice_id); ?>')">Refound</a>
                                            <a class="btn btn-outline-success btn-sm" onclick="ontheTosuccOrder('<?php echo e($showdata->invoice_id); ?>')">Complete</a>
                                            <a class="btn btn-outline-danger btn-sm" onclick="loadModels('<?php echo e($showdata->invoice_id); ?>')" data-toggle="modal" data-target="#myModal">Reject</a>
                                            <?php elseif($showdata->status == '2'): ?>

                                            <a class="btn btn-outline-success btn-sm" onclick="rejecttorefundOrder('<?php echo e($showdata->invoice_id); ?>')">Refound</a>
                                            <a class="btn btn-outline-success btn-sm" onclick="ontheTosuccOrder('<?php echo e($showdata->invoice_id); ?>')">Complete</a>
                                            <a class="btn btn-outline-danger btn-sm" onclick="loadModels('<?php echo e($showdata->invoice_id); ?>')" data-toggle="modal" data-target="#myModal">Reject</a>
                                            <?php elseif($showdata->status == '3'): ?>
                                                  <a class="btn btn-outline-success btn-sm" onclick="rejecttorefundOrder('<?php echo e($showdata->invoice_id); ?>')">Refound</a>
                                            <a class="btn btn-outline-danger btn-sm" onclick="loadModels('<?php echo e($showdata->invoice_id); ?>')" data-toggle="modal" data-target="#myModal">Reject</a>
                                            <?php elseif($showdata->status == '6'): ?>
                                              <a class="btn btn-info btn-sm">Refound</a>
                                            <?php elseif($showdata->status == '4'): ?>
                                              <a class="btn btn-danger btn-sm">Reject</a>
                                             <?php endif; ?>
                                            <a href="<?php echo e(url('invoice-paper')); ?>/<?php echo e($showdata->session_id); ?>" class="btn btn-outline-warning btn-sm" target="_blank">View</a>
                                            <!--<a href="<?php echo e(url('invoice-balance')); ?>/<?php echo e($showdata->invoice_id); ?>" class="btn btn-outline-info btn-sm" target="_blank">View Balance</a>-->
                                            <!--<a href="<?php echo e(url('invoice-trans')); ?>/<?php echo e($showdata->invoice_id); ?>" class="btn btn-outline-primary btn-sm" target="_blank">Pay History</a>-->
                                        </td>
                                        <?php else: ?>
                                        <td>
                                            <a href="<?php echo e(url('invoice-paper')); ?>/<?php echo e($showdata->session_id); ?>" class="btn btn-outline-warning btn-sm" target="_blank">View</a>
                                        </td>
                                        <?php endif; ?>
                                    </tr>
                                         <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                         <?php endif; ?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>


                <!-- state end-->

            </div>
        </div>

<?php echo $__env->make('Admin.footer', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
<script type="text/javascript">

function loadModel(id)
        {
          $(".modal-body").load("<?php echo e(URL::to('processorder_note')); ?>"+'/'+id);
        }
        
        
        
function loadModels(id)
        {
          $(".modal-body").load("<?php echo e(URL::to('rejectorder_note')); ?>"+'/'+id);
        }
        
function loadModelss(id)
        {
          $(".modal-body").load("<?php echo e(URL::to('shipping_address')); ?>"+'/'+id);
        }
        
function penToProOrder(id)
{
    let note = $("#note").val();
   if(confirm('are you sure?'))
    $.ajax({

            headers:{ 'X-CSRF-TOKEN': "<?php echo e(csrf_token()); ?>" },
            url:'<?php echo e(url("penToProOrder")); ?>',
            type:'POST',
            data:{id:id,note:note},
            success:function(data)
            {
                $("#tr-"+id).hide();
                $("#sms").html('<span class="alert alert-success">Order Sent to Proccessign</span>');
            }
        })  

    
}
function protoShipping(id)
{
    if(confirm('are you sure?'))

    $.ajax({

            headers:{ 'X-CSRF-TOKEN': "<?php echo e(csrf_token()); ?>" },
            url:'<?php echo e(url("protoShipping")); ?>',
            type:'POST',
            data:{id:id},
            success:function(data)
            {
                $("#tr-"+id).hide();
                $("#sms").html('<span class="alert alert-success">Order Sent to Shipping</span>');
            }
        })  

    
}
  
function proToontheOrder(id)
{
   if(confirm('are you sure?'))
   
    $.ajax({

            headers:{ 'X-CSRF-TOKEN': "<?php echo e(csrf_token()); ?>" },
            url:'<?php echo e(url("proToontheOrder")); ?>',
            type:'POST',
            data:{id:id},
            success:function(data)
            {
                $("#tr-"+id).hide();
                $("#sms").html('<span class="alert alert-success">Order Sent By Rider</span>');
            }
        })  

    
}
  
function ontheTosuccOrder(id)
{
   if(confirm('are you sure?'))
   
    $.ajax({

            headers:{ 'X-CSRF-TOKEN': "<?php echo e(csrf_token()); ?>" },
            url:'<?php echo e(url("ontheTosuccOrder")); ?>',
            type:'POST',
            data:{id:id},
            success:function(data)
            {
                $("#tr-"+id).hide();
                $("#sms").html('<span class="alert alert-success">Order Delivery Success</span>');
            }
        })  

    
}
  
function penTorejectOrder(id)
{
     let note=$("#note").val();
    if(confirm('are you sure?'))
   
    $.ajax({

            headers:{ 'X-CSRF-TOKEN': "<?php echo e(csrf_token()); ?>" },
            url:'<?php echo e(url("penTorejectOrder")); ?>',
            type:'POST',
            data:{id:id,note:note},
            success:function(data)
            {
                $("#tr-"+id).hide();
                $("#sms").html('<span class="alert alert-danger">Order Reject</span>');
            }
        })  

    
}
  
  
function rejecttorefundOrder(id)
{
    if(confirm('are you sure?'))
   
    $.ajax({

            headers:{ 'X-CSRF-TOKEN': "<?php echo e(csrf_token()); ?>" },
            url:'<?php echo e(url("rejecttorefundOrder")); ?>',
            type:'POST',
            data:{id:id},
            success:function(data)
            {
                $("#tr-"+id).hide();
                $("#sms").html('<span class="alert alert-danger">Order Refound</span>');
            }
        })  

    
}
  
</script><?php /**PATH D:\xampp\htdocs\office\electronics\resources\views/Admin/Order_system/totalorder.blade.php ENDPATH**/ ?>