<?php echo $__env->make('dashboard.include.header', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

<?php $__currentLoopData = $custd; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $custdata): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<?php if(Auth::user()->type=="Reseller" OR Auth::user()->type == "User"): ?>
<?php if($custdata->user != Auth::user()->resellerid): ?>
<script>
    document.location.href = '/resellerdash'
</script>
<?php endif; ?>

    <?php if($custdata->status== 0 OR $custdata->status== 1 OR $custdata->status== 2 OR $custdata->status== 3 OR $custdata->status== 4 OR $custdata->status== 16 OR $custdata->status== 10 OR $custdata->status== 37): ?>                      
    <?php else: ?>
        <script>
            document.location.href = '/viewallorders/<?php echo e($custdata->id); ?>'
        </script>
    <?php endif; ?>
<?php endif; ?>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
  <div class="content-wrapper">
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1 class="m-0">Order Details</h1>
          </div>
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="/home">Home</a></li>
              <li class="breadcrumb-item active">Order Details</li>
            </ol>
          </div>
        </div>
      </div>
    </div>
   
    <section class="content">
      <div class="container-fluid">
      <div class="card">
        <div class="card-body">
        <?php $__currentLoopData = $custd; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $custdata): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
          <div class="row">
          <div class="col-md-4"><label for="">Name&nbsp;&nbsp;: &nbsp;&nbsp;</label><?php echo e($custdata->name); ?></div>
          <div class="col-md-5"><label for="">Address&nbsp;&nbsp;: &nbsp;&nbsp;</label><?php echo e($custdata->address); ?></div>
          <div class="col-md-3"><label for="">Phone Number&nbsp;&nbsp;: &nbsp;&nbsp;</label><?php echo e($custdata->phone); ?></div>

          </div>
        
          <br><hr>
             <div class="row">
            <div class="col-md-3">
                <div class="form-group">
                        <label>City :</label>
                        <form method="post" class="cityupdateform" id="cityupdateform" enctype="multipart/form-data">
                    <?php echo e(csrf_field()); ?>

                        <input type="hidden" class="form-control" value="<?php echo e($cus_id); ?>" name="id" placeholder="" required>
                    <select class="form-control select2" name="cituselect" id="cituselect">
                    <option value="empty" selected="selected" disabled>Select</option>
                        <?php $__currentLoopData = $city; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $cityd): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($cityd->id); ?>"<?php if($custdata->city==$cityd->id): ?> selected <?php endif; ?>><?php echo e($cityd->city); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>

                    </form>
                </div> 
                <script>
                        $(function () {
                            $('.select2').select2()
                        })
                </script>       
        </div>
        <div class="col-md-3">
            <div class="form-group">
                  <label>District :</label>
                  <input type="text" placeholder="" value="<?php echo e($custdata->district); ?>" id="district" class="form-control" readonly>
              </div>
        </div>
        <div class="col-md-3">
            <div class="form-group">
                  <label>Primary Phone Number :</label>
                  <form method="post" class="primaryphone" enctype="multipart/form-data">
                    <?php echo e(csrf_field()); ?>

                    <input type="hidden" class="form-control" value="<?php echo e($cus_id); ?>" name="id" placeholder="" required>
                  <input type="text" placeholder="" value="<?php echo e($custdata->phone); ?>" name="phone" class="form-control" id="phone">
                  </form>
              </div>

        </div>
        <div class="col-md-3">
            <div class="form-group">
                  <label>Secondary Phone Number :</label>
                  <form method="post" class="secondaryphone" enctype="multipart/form-data">
                    <?php echo e(csrf_field()); ?>

                    <input type="hidden" class="form-control" value="<?php echo e($cus_id); ?>" name="id" placeholder="" required>
                  <input type="text" placeholder="" value="<?php echo e($custdata->secondaryphone); ?>" id="secondary" name="secondary" class="form-control">
                    </form>
              </div>
        </div>
        </div>
        <div class="row">
        <div class="col-md-3">
            <div class="form-group">
            <label>Order Type :</label>
            <form method="post" class="ordertypeupdateform" enctype="multipart/form-data">
            <?php echo e(csrf_field()); ?>

            <input type="hidden" class="form-control" value="<?php echo e($cus_id); ?>" name="id" placeholder="" required>
            <select class="form-control" id="ordertypefi" name="ordertype" style="width: 100%;" required>
                <option value="" selected="selected" disabled>Select</option>
                <option value="1" <?php if($custdata->ordertype==1 ): ?>selected <?php endif; ?> >New</option>
                <option value="2" <?php if($custdata->ordertype==2 ): ?>selected <?php endif; ?> >Exchange</option>
                <option value="3" <?php if($custdata->ordertype==3 ): ?>selected <?php endif; ?> >Refund</option>

            </select>
        </div>
    </div>
            <div class="col-md-3 oldwaybill">
            <div class="form-group">
                <label for="">Old Invoice Number</label>
                <input type="text" class="form-control" id="oldwaybill" name="oldwaybill" value="<?php echo e($custdata->oldwaybill); ?>" required>
            </div>
            </div>
            <div class="col-md-1 subbtn" style="padding-top:30px;">
            <button type="submit" class="btn btn-info btn-block">Submit</button>
            </div>
            </form>
        </div>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> 
<hr>


          <div class="row">
          <div class="col-md-6"></div>
          <div class="col-md-6" align="right">
          <button type="button" class="btn btn-sm btn-primary btn-xs" data-toggle="modal" data-target="#myModal3"  data-whatever="@getbootstrap">Edit Customer Details</button>
          <a class="btn btn-warning btn-xs" onclick="printDiv('printableArea')" ><i class="fas fa-print"></i>&nbsp;Print invoice</a>   
          <button type="button" class="btn btn-sm btn-success btn-xs" data-toggle="modal" data-target="#exampleModalCenter">Add items</button></div>
          </div> <br>
          <div class="row">
            <div class="col-md-12">
 

               
                <div class="here" name="here" id="here">
            <table class="table" id="book-table">
                    <thead>
                          <tr>
                            <th style="width:60px" class="text-center">QTY</th>
                            <th class="text-left">DESCRIPTION</th>
                            <th style="width:140px" class="text-right">UNIT PRICE</th>
                            <th style="width:90px" class="text-right">TOTAL</th>
                            <th style="width:90px" class="text-right"></th>
                            <th style="width:90px" class="text-right"></th>
                          </tr>
                    </thead>
                    <tbody>
                    <?php $__currentLoopData = $item2; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        
                    <tr>
                        <td class="text-center"><?php echo e($data->qty); ?></td>
     
                        <td><?php echo e($data->orders->pro_name); ?>    
                            </td>
                        <td class="text-right"><?php echo e($data->pro_amount); ?></td>
                        <td class="text-right">
                        <?php echo e($data->qty * $data->pro_amount); ?>

                        </td>
                        <td class="text-right">
                                <button type="button" class="btn btn-primary btn-xs btn-edit" data-proprice="<?php echo e($data->pro_amount); ?>" data-cid="<?php echo e($data->customerorders->id); ?>" data-id="<?php echo e($data->id); ?>" data-delivery="<?php echo e($data->delivery); ?>" data-proname="<?php echo e($data->item_id); ?>" data-qty="<?php echo e($data->qty); ?>" data-toggle="modal" data-target="#editordermodel">Edit</button>
                        </td>
                        <td class="text-right">                
                            <a href="" data-id="<?php echo e($data->id); ?>" class="btn btn-danger btn-xs button" data-url="">Delete </a>
                        </td>
                    </tr>

                    
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> 
                        
                            <tr>
                            <td colspan="2" rowspan="4">
                            
                            <td class="text-right"><strong>Delivery Charge</strong></td>
                            <td class="text-right"><?php echo e($deli); ?></td>
                            <td></td>
                            <td class="text-right">
                                <button type="button" class="btn btn-primary btn-xs btn-edit" data-id="<?php echo e($cus_id); ?>" data-delivery="<?php echo e($deli); ?>"  data-toggle="modal" data-target="#deliverymodel">Delivery</button>
                            </td>
                        </tr> 
                        <tr>
                            <td class="text-right no-border">
                            <strong>Total</strong>
                            </td>
                            <td class="text-right"><strong><?php echo e($tot + $deli); ?></strong></td>
                        </tr>
                       
                    </tbody>
                </table>
                </div>
                


                <div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
                    <div class="modal-dialog modal-dialog-centered modal-lg" role="document">
                        <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title" id="exampleModalLongTitle">Add Items</h5>
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                            </button>
                        </div>
                        <form method="post" action="/addcustomerItems">
                          <?php echo e(csrf_field()); ?>

                        <div class="modal-body">
                            <input type="hidden" name="cus_id" value="<?php echo e($cus_id); ?>">
                            <div class="form-group row">
                                <label for="" class="col-sm-2 col-form-label">Product Name</label>
                                <div class="col-sm-10">
                                <select class="form-control" name="nameproduct"  id="nameproduct">
                                    <option selected disabled>Product Name</option>
                                    <?php $__currentLoopData = $item; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($data->id); ?>"><?php echo e($data->pro_name); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> 
                                </select>
                                <script>
                                   $(document).ready(function() {
                                        $('#nameproduct').select2({
                                            dropdownParent: $('#exampleModalCenter')
                                        });
                                    });
                                </script>

                                </div>
                            </div>
                            <div class="applenddata">

                            </div>
                            <div class="form-group row">
                                <label for="" class="col-sm-2 col-form-label">Product Price</label>
                                <div class="col-sm-10">
                                <input type="number" class="form-control" name="product_price" id="product_price" value="0" required>
                                </div>
                            </div>
                            <div class="form-group row">
                                <label for="" class="col-sm-2 col-form-label">Quantity</label>
                                <div class="col-sm-10">
                                <input type="number" class="form-control" id="quantity" name="quantity" placeholder="Quantity" required>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-secondary" data-dismiss="modal" onclick="Reset();">Close</button>
                            <button type="submit" class="btn btn-primary">Save changes</button>
                        </div>
                        </form>
                        </div>
                    </div>
                    </div>
                    <div class="modal fade" id="editordermodel" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
                    <div class="modal-dialog modal-dialog-centered modal-lg" role="document">
                        <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title" id="exampleModalLongTitle">Update Items</h5>
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                            </button>
                        </div>
                        <form method="post" action="/updateitem">
                          <?php echo e(csrf_field()); ?>

                        <div class="modal-body">
                        <div class="form-group row">
                                <label for="" class="col-sm-2 col-form-label">Product Name</label>
                                <div class="col-sm-10">
                                <div class="id_100">
                                <select class="form-control" id="nameproduct2" name="nameproduct2">
                                    <!-- <option selected disabled>Product Name</option> -->
                                    <?php $__currentLoopData = $item; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($data->id); ?>"><?php echo e($data->pro_name); ?></option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> 
                                </select>
                                </div>
                                <script>
                                   $(document).ready(function() {
                                        $('#nameproduct2').select2({
                                        dropdownParent: $('#editordermodel')
                                    });
                                    });
                                </script>

                                </div>
                            </div>
                            <div class="applenddata2">

                            </div>
                            <div class="form-group row">
                                <label for="" class="col-sm-2 col-form-label">Product Price</label>
                                <div class="col-sm-10">
                                <input type="number" class="form-control" name="product_price" id="product_price" value="0" required>
                                </div>
                            </div>
                            <input type="hidden" class="form-control" id="id" name="id" placeholder="Quantity" required>
                            <input type="hidden" class="form-control" id="cusid" name="cusid" placeholder="Quantity" required>

                            <div class="form-group row">
                                <label for="" class="col-sm-2 col-form-label">Quantity</label>
                                <div class="col-sm-10">
                                <input type="number" class="form-control" id="quantity" name="quantity" placeholder="Quantity" required>
                                </div>
                            </div>
                            <!-- <div class="form-group row">
                                <label for="" class="col-sm-2 col-form-label">Delivery Charge</label>
                                <div class="col-sm-10">
                                <input type="number" class="form-control" id="Delivery" name="Delivery" placeholder="Delivery Charge" required>
                                </div>
                            </div> -->
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                            <button type="submit" class="btn btn-primary">Save changes</button>
                        </div>
                        </form>
                        </div>
                    </div>
                    </div>

                <div class="modal fade" id="deliverymodel" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
                    <div class="modal-dialog modal-dialog-centered" role="document">
                        <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title" id="exampleModalLongTitle">Update Delivery Charge</h5>
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                            </button>
                        </div>
                        <form method="post" id="deliveryupdateform">
                          <?php echo e(csrf_field()); ?>

                        <div class="modal-body">
                            <div class="form-group">
                                <input type="hidden" class="form-control" id="id" name="id" placeholder="" required>
                                <label for="">Delivery Charge</label><input type="number" class="form-control" id="Delivery" name="Delivery" placeholder="Delivery Charge" required>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                            <button type="submit" class="btn btn-primary">Save changes</button>
                        </div>
                        </form>
                        </div>
                    </div>
                    </div>
            </div>
          </div>
          </div>
        </div>

            <div class="card">
       <div class="card-body">
       <form class="statuschangeform" action="/resellerbtnstatuschange" method="post" enctype="multipart/form-data">
                <?php echo e(csrf_field()); ?>

            <div class="row">
                <input type="hidden" value="<?php echo e($cus_id); ?>" name="cus_id">
                <?php $__currentLoopData = $custd; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $custdata): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <input type="hidden" value="<?php echo e($custdata->status); ?>" name="status">
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                <div class="col-md-2">
                    <button type="submit" name="attempt1" class="btn btn-block btn-warning" value="attempt1">1st Attempt</button>
                </div>
                <div class="col-md-2">
                    <button type="submit" name="attempt2" class="btn btn-block btn-primary" value="attempt2">2st Attempt</button>
                </div>
                <div class="col-md-2">
                    <button type="submit" name="attempt3" class="btn btn-block btn-secondary" value="attempt3">3st Attempt</button>
                </div>
                <div class="col-md-2">
                    <button type="submit" name="cancel" class="btn btn-block btn-danger" value="cancel">Cancel Order</button>
                </div>
                <div class="col-md-2">
                    <button type="submit" name="hold" class="btn btn-block btn-dark" value="hold">Hold Order</button>
                </div>
                <div class="col-md-2">
                    <button type="submit" onClick="return validateForm()" name="Confirm" class="btn btn-block btn-success" value="Confirm">Send Udrop</button>
                </div>
                <div class="col-md-2">
        
                </div>
            </div>
        </form>
        </div>
    </div>

    <div class="card">
       <div class="card-body">
        <div class="row">
            <div class="col-md-12">
            <h4>Customer Order History</h4> <br>
            <table id="example12" data-page-length='50' class="table table-bordered" style="width:100%; font-size:13px;">
                    <thead>
                        <tr>
                            <th>Id</th>
                            <th>Name</th>
                            <th>Address</th>
                            <th>Phone</th>
                            <th>Created Date</th>
                            <th>Status</th>
                        </tr>
                    </thead>
                    <tbody>
                    <?php $__currentLoopData = $checkhistory; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <?php if($data->id==$cus_id): ?>
                    <?php else: ?>
                        <tr>
                            <td><?php echo e($data->id); ?></td>
                            <td><?php echo e($data->name); ?></td>
                            <td><?php echo e($data->address); ?></td>
                            <td><?php echo e($data->phone); ?></td>
                            <td><?php echo e($data->created_at); ?></td>
                            <td>
                            <?php if($data->status =='0'): ?>   
                    <span class="badge badge-warning">Check Order</span>
                    <?php elseif($data->status =='1'): ?>   
                    <span class="badge badge-primary">Pending</span>
                    <?php elseif($data->status =='2'): ?>               
                    <span class="badge badge-warning" >1st Attempt</span>
                    <?php elseif($data->status =='3'): ?>                
                    <span class="badge badge-warning">2nd Attempt</span>
                    <?php elseif($data->status =='4'): ?>               
                    <span class="badge badge-warning">3rd Attempt</span>
                    <?php elseif($data->status =='5'): ?>            
                    <span class="badge badge-primary">Colombo Confirm</span>                  
                    <?php elseif($data->status =='6'): ?>                
                    <span class="badge badge-primary">Out Confirm</span>
                    <?php elseif($data->status =='7'): ?>                
                    <span class="badge badge-danger">Return Order</span>
                    <?php elseif($data->status =='8'): ?>                
                    <span class="badge badge-info">Dispatched Order</span>
                    <?php elseif($data->status =='9'): ?>                
                    <span class="badge badge-secondary">Money Received</span>
                    <?php elseif($data->status =='10'): ?>                
                    <span class="badge badge-danger">Cancel Order</span>
                    <?php elseif($data->status =='11'): ?>                
                    <span class="badge badge-primary">Out Assigned</span>
                    <?php elseif($data->status =='12'): ?>                
                    <span class="badge badge-primary">Colombo Assigned</span>
                    <?php elseif($data->status =='13'): ?>                
                    <span class="badge badge-primary">Out Pick</span>
                    <?php elseif($data->status =='14'): ?>                
                    <span class="badge badge-primary">Colombo Pick</span>
                    <?php elseif($data->status =='15'): ?>                
                    <span class="badge badge-primary">Packed</span>
                    <?php elseif($data->status =='16'): ?>                
                    <span class="badge badge-primary">Hold Order</span>
                    <?php elseif($data->status =='17'): ?>                
                    <span class="badge badge-primary">Udrop Pending</span>
                    <?php elseif($data->status =='18'): ?>                
                    <span class="badge badge-success">Delivered</span>
                    <?php elseif($data->status =='26'): ?>                
                    <span class="badge badge-primary">Hold</span>
                    <?php elseif($data->status =='27'): ?>                
                    <span class="badge badge-primary">Reject</span>
                    <?php elseif($data->status =='28'): ?>                
                    <span class="badge badge-dark">Banned Customer</span>
                    <?php elseif($data->status =='29'): ?>                
                    <span class="badge badge-info">Incomplete Order</span>
                    <?php elseif($data->status =='30'): ?>                
                    <span class="badge badge-warning">Remind Order</span>
                    <?php elseif($data->status =='32'): ?>                
                    <span class="badge badge-warning">Out Of Stock</span>
                    <?php elseif($data->status =='33'): ?>                
                    <span class="badge badge-warning">Paid to Reseller</span>
                    <?php elseif($data->status =='34'): ?>                
                    <span class="badge badge-warning">Return to Reseller</span>
                    <?php elseif($data->status =='35'): ?>                
                    <span class="badge badge-warning">Refund Order</span>
                    <?php elseif($data->status =='36'): ?>                
                    <span class="badge badge-warning">Refund to Reseller</span>
                    <?php elseif($data->status =='37'): ?>                
                    <span class="badge badge-warning">Duplicate Order</span>
                    <?php endif; ?>
                        </td>
                            
                        </tr>
                        <?php endif; ?>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> 
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

<br><br>

      </div>
    </section>
  </div>
 



<div class="modal fade" id="myModal3" role="dialog">
  <div class="modal-dialog">
  
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
              <h4 class="modal-title">Update Customer Details</h4>
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        
      </div>
      
          <form role="form" class="form-horizontal style-form" action="/updatecusdetailsreseller" method="post" enctype="multipart/form-data">
          <?php echo e(csrf_field()); ?>

            <div class="modal-body">
            <?php $__currentLoopData = $custd; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <input type="hidden" value="<?php echo e($cus_id); ?>" name="cus_id">
              <div class="form-group">
                  <label>Customer Name</label>
                  <input type="text" placeholder="" value="<?php echo e($data->name); ?>" id="name" name="name" class="form-control">
              </div>
              <div class="form-group">
                  <label>Address</label>
                  <textarea type="text" placeholder="" value="<?php echo e($data->address); ?>" id="address" rows="2" name="address" class="form-control"><?php echo e($data->address); ?></textarea>
              </div>
              <div class="form-group">
                  <label>Phone numbers</label>
                  <input type="text" placeholder=""  value="<?php echo e($data->phone); ?>" id="phone" name="phone" class="form-control">
              </div>
              <div class="form-group">
                  <label>Note</label>
                  <textarea type="text" placeholder="" value="<?php echo e($data->note); ?>" id="note" rows="2" name="note" class="form-control"><?php echo e($data->note); ?></textarea>
              </div>
              <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </div>
      <div class="modal-footer">
      <button class="btn btn-primary" type="submit">Update Customer Deatils</button>
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
      </form>
    </div>
    
  </div>

</div>













  <?php echo $__env->make('dashboard.include.footer', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>;
  <script>
function printDiv(divName) {
     var printContents = document.getElementById(divName).innerHTML;
     var originalContents = document.body.innerHTML;

     document.body.innerHTML = printContents;

     window.print();

     document.body.innerHTML = originalContents;
}
</script>


<script>
function validateForm() {
    var mySelect = document.getElementById("cituselect");

  if (mySelect.value === "empty")  {
    // alert("You must select City & District!");
    swal({
            title: "Error!",
            text: "You must select city & district!",
            icon: "error",
            button: "OK",
        });
    return false;
  }

  else{

  }
;
}


$(function() {
    $('#cituselect').change(function() {
        // this.form.submit();
        var mobNum = $(this).val();
    $(".cityupdateform").submit();

    });

        $('#fardercituselect').change(function() {
        // this.form.submit();
        var mobNum = $(this).val();
    $(".fardercityupdateform").submit();

    });


    $('#ordertypefi').change(function() {
        // this.form.submit();
        var id = $(this).val();
        if(id == 1){
            $('.oldwaybill').hide();
            $('.subbtn').hide();
            $(".ordertypeupdateform").submit();
        }
        else if(id == 2){
            $('.oldwaybill').show();
            $('.subbtn').show();

        }
        else if(id == 3){
            $('.oldwaybill').show();
            $('.subbtn').show();

        }

    });

});


$('input[name=oldwaybill]').change(function() { 
    var min = $(this).val();
    $(".ordertypeupdateform").submit();
 });


$(document).ready(function(){
var id = $("#ordertypefi").val()
    if(id == 1){
        $('.oldwaybill').hide();
        $('.subbtn').hide();
        }
    else if(id == 2){
        $('.oldwaybill').show();
        $('.subbtn').show();
    }
    else if(id == 3){
        $('.oldwaybill').show();
        $('.subbtn').show();
    }
});


$(document).ready(function(){

    var mobNum = $("#phone").val()
    var filter = /^\d*(?:\.\d{1,2})?$/;
    if (filter.test(mobNum)) {
        if(mobNum.length==10){

            $("#phone").removeClass("is-invalid");
            $("#phone").addClass("is-valid");
            } else {

            $("#phone").removeClass("is-valid");
            $("#phone").addClass("is-invalid");
            
            }
        }
        else {
            $("#phone").removeClass("is-valid");
            $("#phone").addClass("is-invalid");
            
        }
  
    $('#phone').on('input', function() { 
    var mobNum = $(this).val();
    var filter = /^\d*(?:\.\d{1,2})?$/;

    if (filter.test(mobNum)) {
        if(mobNum.length==10){

            toastr.success('Valid Phone Number')
            $("#phone").removeClass("is-invalid");
            $("#phone").addClass("is-valid");
            $(".primaryphone").submit();
            } else {

            // toastr.error('Please Put 10  Digit Mobile Number')
            $("#phone").removeClass("is-valid");
            $("#phone").addClass("is-invalid");
            
            }
        }
        else {
            toastr.error('Not a Valid Number')
            $("#phone").removeClass("is-valid");
            $("#phone").addClass("is-invalid");
            
        }


 });
  
 $('#secondary').on('input', function() { 
    var mobNum = $(this).val();
    var filter = /^\d*(?:\.\d{1,2})?$/;

    if (filter.test(mobNum)) {
        if(mobNum.length==10){

            toastr.success('Valid Phone Number')
            $("#secondary").removeClass("is-invalid");
            $("#secondary").addClass("is-valid");
            $(".secondaryphone").submit();
            } else {

            // toastr.error('Please Put 10  Digit Mobile Number')
            $("#secondary").removeClass("is-valid");
            $("#secondary").addClass("is-invalid");
            
            }
        }
        else {
            toastr.error('Not a Valid Number')
            $("#secondary").removeClass("is-valid");
            $("#secondary").addClass("is-invalid");
            
        }


 });
});


$('.ordertypeupdateform').on('submit', function(event){
    let ele = this;
        event.preventDefault();
        var form_data = $(this).serialize();
        $.ajax({
            url:"/ordertypeupdate",
            method:"POST",
            data:form_data,
            dataType:"json",      
            success: function (result, code, ex) { 
                $("#here").load(location.href + " #here");
                toastr.success('Order Type Changed successfully!')
                location.reload();

            },
            error: function (jqXHR, textStatus, errorThrown) {
                swal("Warning", "Unable to Process your request", "error");
            },
            
        })
    });
  
  $('.cityupdateform').on('submit', function(event){
    let ele = this;
        event.preventDefault();
        var form_data = $(this).serialize();
        $.ajax({
            url:"/cityupdate",
            method:"POST",
            data:form_data,
            dataType:"json",      
            success: function (data, code, ex) {
                toastr.success('City and District Update successfully!')
                jQuery.each(data, function(key,value){
                    $('#district').val(value);
        });

            },
            error: function (jqXHR, textStatus, errorThrown) {
                swal("Warning", "Unable to Process your request", "error");
            },
            
        })
    });

        $('.fardercityupdateform').on('submit', function(event){
    let ele = this;
        event.preventDefault();
        var form_data = $(this).serialize();
        $.ajax({
            url:"/fardercityupdate",
            method:"POST",
            data:form_data,
            dataType:"json",      
            success: function (data, code, ex) {
                toastr.success('City Update successfully!')

            },
            error: function (jqXHR, textStatus, errorThrown) {
                swal("Warning", "Unable to Process your request", "error");
            },
            
        })
    });


    $('.secondaryphone').on('submit', function(event){
    let ele = this;
        event.preventDefault();
        var form_data = $(this).serialize();
        $.ajax({
            url:"/secondaryphoneupdate",
            method:"POST",
            data:form_data,
            dataType:"json",      
            success: function (result, code, ex) {
                // swal("Done!", "It was successfully!", "success");
                // $("#deliverymodel").modal('hide');  
                $("#here").load(location.href + " #here");
                // location.reload();
                toastr.success('Primary Phone Number Update successfully!')
                

            },
            error: function (jqXHR, textStatus, errorThrown) {
                swal("Warning", "Unable to Process your request", "error");
            },
            
        })
    });


    $('.primaryphone').on('submit', function(event){
    let ele = this;
        event.preventDefault();
        var form_data = $(this).serialize();
        $.ajax({
            url:"/primaryphoneupdate",
            method:"POST",
            data:form_data,
            dataType:"json",      
            success: function (result, code, ex) {
                // swal("Done!", "It was successfully!", "success");
                // $("#deliverymodel").modal('hide');  
                // location.reload();
                toastr.success('Primary Phone Number Update successfully!')
                

            },
            error: function (jqXHR, textStatus, errorThrown) {
                swal("Warning", "Unable to Process your request", "error");
            },
            
        })
    });



$(document).on('click', '.btn-danger', function (e) {
    e.preventDefault();
    var id = $(this).data('id');
    let ele = this;
    console.log(id);

                            swal({
                            title: "Are you sure?",
                            text: "Are you Sure to Remove Order Item",
                            icon: "warning",
                            showCancelButton: true,
                confirmButtonColor: '#3085d6',
                cancelButtonColor: '#d33',
                confirmButtonText: 'Yes, delete it!',
                            dangerMode: true,
                        }).then(function(isConfirm) {
                            
                            if (isConfirm.value===true) {

                                    $.ajax({
                                        url: "<?php echo e(url('/deleteitem')); ?>/"+id ,
                                        method: "POST",
                                        headers: {
                                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                                        },
                                        cache: false,
                                        contentType: false,
                                        processData: false,
                                        dataType: 'JSON',
                                        data:{
                                            "id":id
                                        },
                                        success: function (result, code, ex) {
                                            swal("Done!", "It was successfully deleted!", "success");
                                            // $(ele).closest('tr').hide();
                                            $("#here").load(location.href + " #here");
                                            location.reload();
                                        },
                                        error: function (jqXHR, textStatus, errorThrown) {
                                            swal("Warning", "Unable to Process your request", "error");
                                        },
                                    });

                            } else {
                                swal("Cancelled", "No Item Removed", "error");
                            }
                        })
});



<?php if(session('success')): ?>
        //swal("Success!","<?php echo e(session('success')); ?>","success");

Swal.fire({
  
  type: 'success',
  title: 'Your work has been saved',
  text: "<?php echo e(session('success')); ?>",
  showConfirmButton: false,
  timer: 1500
});


<?php endif; ?>
<?php if(session('error')): ?>
    swal({
            title: "Error!",
            text: "<?php echo e(session('error')); ?>",
            icon: "error",
            button: "OK",
        });
<?php endif; ?>

</script>


<script type="text/javascript">
    function Reset() {
    $("#nameproduct").val(1).change();
    }

    
</script>


<script>
$('#editordermodel').on('show.bs.modal', function (event) {
     
  var button = $(event.relatedTarget) // Button that triggered the modal
  var recipient = button.data('delivery') 
  var proname = button.data('proname') 
  var qty = button.data('qty') 
  var id = button.data('id') 
  var cid = button.data('cid') 
  var proprice = button.data('proprice') 
  
  var modal = $(this)
//   modal.find('.modal-title').text('New message to ' + recipient)
  modal.find('.modal-body #Delivery').val(recipient)
//   modal.find('.modal-body #nameproduct').val(proname)
  modal.find('.modal-body #quantity').val(qty)
  modal.find('.modal-body #id').val(id)
  modal.find('.modal-body #cusid').val(cid)
  modal.find('.modal-body #product_price').val(proprice)

    $("#nameproduct2").val(proname).change();
})

$('#deliverymodel').on('show.bs.modal', function (event) {
     var button = $(event.relatedTarget) // Button that triggered the modal
     var recipient = button.data('delivery') 
     var id = button.data('id') 
     var modal = $(this)
     modal.find('.modal-body #Delivery').val(recipient)
     modal.find('.modal-body #id').val(id)
   })
</script>


    <script type="text/javascript">
    jQuery(document).ready(function ()
    {
            jQuery('select[name="nameproduct"]').on('change',function(){
               var countryID = jQuery(this).val();

    $.ajax({
            url: "<?php echo e(url('/getproductprice')); ?>/"+countryID ,
            method: "get",
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            },
            cache: false,
            contentType: false,
            processData: false,
            dataType: 'JSON',
            data:{
                "id":countryID
            },
            success: function (data) {
                // swal("Done!", "It was successfully deleted!", "success");

                    jQuery.each(data, function(key,value){
                        for(i=0; i<value.length; i++){
                            var rid = value[i].id;
                            $('#product_price').val(value[i].sell_price);
                            
                        }

                    });

            },
            error: function (jqXHR, textStatus, errorThrown) {
                swal("Warning", "Unable to Process your request", "error");
            },
        });

            });
    });
    </script>


        <script type="text/javascript">


    $('#deliveryupdateform').on('submit', function(event){
    let ele = this;
        event.preventDefault();
        var form_data = $(this).serialize();
        $.ajax({
            url:"/deliveryupdateview",
            method:"POST",
            data:form_data,
            dataType:"json",      
            success: function (result, code, ex) {
                // swal("Done!", "It was successfully!", "success");
                $("#deliverymodel").modal('hide');  
                $("#here").load(location.href + " #here");
   
                toastr.success('Delivery Charges Added successfully!')

            },
            error: function (jqXHR, textStatus, errorThrown) {
                swal("Warning", "Unable to Process your request", "error");
            },
            
        })
    });
    </script>

    <div id="printableArea" style="display: none;">
    <?php $__currentLoopData = $custd; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
  
  <div class="row">
    <div class="col-md-6"><h1> Invoice Number : 
    </h1>
    <p style="margin: -2mm 0mm 0mm 90mm;font-size:12px"><?php echo e($data->id); ?></p>
    </div>
    <div class="col-md-6" align="right"></div>
</div>
    <div class="row">
        <div class="col-md-6">
        <h5>Issued Date : <?php echo e($ldate); ?></h5>
        <h5>Customer Name : <?php echo e($data->name); ?></h5>
        <h5>Address : <?php echo e($data->address); ?></h5>
        <h5>Phone Number : <?php echo e($data->phone); ?> / <?php echo e($data->secondaryphone); ?></h5>
        </div>  
        <div class="col-md-6" align="right">
            <h5>Wasi Mart Holdings [pvt] Ltd</h5>
            <h5></h5>
            <h5></h5>
            <h5>wasimart.lk@gmail.com</h5>
        </div>    
    </div>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
<br><br>

    <table class="table" id="book-table" name="book-table">
            <thead>
                  <tr>
                    <th style="width:60px" class="text-center">QTY</th>
                    <th class="text-left">DESCRIPTION</th>
                    <th style="width:140px" class="text-right">UNIT PRICE</th>
                    <th style="width:90px" class="text-right">TOTAL</th>
   
                  </tr>
            </thead>
            <tbody>
                    
            <?php $__currentLoopData = $item2; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?> 
                    <tr>
                        <td class="text-center"><?php echo e($data->qty); ?></td>
                        <td>
                        <?php echo e($data->orders->pro_name); ?>

                        </td>
                        <td class="text-right"><?php echo e($data->pro_amount); ?></td>
                        <td class="text-right"><?php echo e($data->qty * $data->pro_amount); ?>

                        </td>
                        <input type="hidden" value="">
                    </tr>
                    
            
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    <tr>
                            <td colspan="2" rowspan="4">
                             
                              <td class="text-right"><strong>Delivery Charge</strong></td>
                              <td class="text-right"><?php echo e($deli); ?></td>
                          </tr>

                          <tr>
                            <td class="text-right no-border">
                              <strong>Total</strong>
                            </td>
                            <td class="text-right"><strong><?php echo e($deli + $tot); ?></strong></td>
                          </tr>
            </tbody>
        </table>  
        <br>
        <br>
        <br>
      </div>