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

  
  <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">Invoice ID - <?php echo e($cus_id); ?></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">View Order Details</li>
            </ol>
          </div>
        </div>
      </div>
    </div>
    
    <section class="content">
      <div class="container-fluid">
      <div class="card">
        <div class="card-body">
        <div class="row">
        <?php $__currentLoopData = $item; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <div class="col-md-6">
        <b>Branch :</b>&nbsp;&nbsp;<?php echo e($data->branch); ?> &nbsp;&nbsp;&nbsp;&nbsp;<b>Order Source :</b>&nbsp;&nbsp;<?php echo e($data->ordersource); ?>&nbsp;&nbsp;&nbsp;&nbsp;
        
        </div>

        </div><hr>
        <div class="row">
       
            <div class="col-md-5">
                    <b>Order Status :</b> 
                    <?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-info">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-success">Money Recive Order</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">Phone Off</span>
                    <?php elseif($data->status =='17'): ?>                
                    <span class="badge badge-primary">He will call</span>
                    <?php endif; ?>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <b>Print Status : </b>
                    <?php if($data->print =='1'): ?>   
                    <span class="badge badge-success">Print</span>
                    <?php elseif($data->print =='0'): ?>
                    <span class="badge badge-danger">Not Print</span>
                    <?php endif; ?>


            </div>
            <div class="col-md-5">

            </div>
            <div class="col-md-2"><button type="button" class="btn btn-block btn-primary btn-sm" data-toggle="modal" data-target="#myModal3"  style="float:right" data-whatever="@getbootstrap">Edit Customer Details</button></div>
          </div> <hr>
            <div class="row" style="padding-top:10px;">
                <div class="col-md-12" id="">
                    <table class="table borderless"  border="0">
                        <tbody>
                            <tr>
                            <td class="text-left"><b>Customer Name - </b>  <?php echo e($data->name); ?></td>
                            <td class="text-right"><b>Date - </b> <?php echo e($data->created_at); ?></td>
                            </tr>
                            <tr>
                            <td class="text-left"><b>Address - </b>  <?php echo e($data->address); ?></td>
                            <td class="text-right"><b>Page - </b> <?php $__currentLoopData = $pages; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data3): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?> <?php echo e($data3->pagename); ?>   <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></td>
                            </tr>
                            <tr>
                            <td class="text-left"><b>Phone Number - </b> <?php echo e($data->phone); ?></td>
                            <td class="text-right">
                            <b>Tracking Code - </b><?php echo e($data->tracking); ?>                            
                            </td>
                            </tr>
                            <tr>
                            <td class="text-left"><b>Note - </b> <b style="color:red;"><?php echo e($data->note); ?></b></td>
                            <td class="text-right">
                            <?php if($data->deliveryservice=="-"): ?>
                                <?php if($data->companydelivery=="1"): ?>
                                <b>Rider Name - </b><?php echo e($data->userget->name); ?>

                                <?php endif; ?>
                            <?php else: ?>
                            <b>Delivery Service - </b><?php echo e($data->deliveryse->deliveryname); ?>

                            <?php endif; ?>
                            </td>
                            </td>
                            </tr>
                        </tbody>
                    </table>  
                </div>
            </div> 

             <hr>
             <div class="row">
            <div class="col-md-3">
                <div class="form-group">
                        <label>City :</label>
                        <form method="post" class="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="" 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($data->city==$cityd->id): ?> selected <?php endif; ?>><?php echo e($cityd->city); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                    <script>
                                    $(function () {
                                    $('.select2').select2()
                                })
                    </script>
                    </form>
                </div>          
        </div>
        <div class="col-md-3">
            <div class="form-group">
                  <label>District :</label>
                  <input type="text" placeholder="" value="<?php echo e($data->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($data->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($data->secondaryphone); ?>" id="secondary" name="secondary" class="form-control">
                    </form>
              </div>
        </div>
        </div>
          </div>
        </div>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
         <div class="card">
            <div class="card-body">
            <div class="row">
                <div class="col-md-10"></div>
                <div class="col-md-2" align="right"><button type="button" class="btn btn-sm btn-success" data-toggle="modal" data-target="#exampleModalCenter">Add items</button></div>
            </div> <br>
            <div class="row">
                <div class="col-md-12 here" name="here" id="here">
                <table class="table" id="book-table" name="book-table">
                    <thead>
                          <tr>
                            <th class="text-left">DESCRIPTION</th>
                            <th style="width:60px" class="text-right">IMAGE</th>
                            <th style="width:10px" class="text-right">QTY</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 = $item3; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        
                    <tr>
                        
     
                        <td><?php echo e($data->orders->name); ?>

                        <?php if($data->attribute=="null" or $data->attribute==""): ?>
                        <?php else: ?>
                            <?php $__currentLoopData = json_decode($data->attribute); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $val): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                (<?php echo e($key); ?>:<?php echo e($val); ?>)
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        <?php endif; ?>
                            </td>
                            <!-- $data->orders->image -->
                        <td class="text-center"><img style="width:40px;" src="<?php echo e(URL::asset("storage/{$data->orders->image}")); ?>" /></td>
                        <td class="text-center"><?php echo e($data->qty); ?></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-sm 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-sm button dangeritem" data-url="">Delete </a>
                        </td>
                    </tr>

                    
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> 
                        
                            <tr>
                            <td colspan="3" rowspan="4">
                            
                            <td class="text-right"><strong>Delivery Charge</strong></td>
                            <td class="text-right">
                            <form method="post" id="deliveryupdateform" 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="number" value="<?php echo e($deli); ?>" class="form-control" name="Delivery" required>
                           
                            </td>
                            <td></td>
                            <td class="text-right">
                                <!-- <button type="button" class="btn btn-primary btn-sm btn-edit" data-id="<?php echo e($cus_id); ?>" data-delivery="<?php echo e($deli); ?>"  data-toggle="modal" data-target="#deliverymodel">Delivery</button> -->
                                <button type="submit" class="btn btn-primary btn-sm">Delivery</button>
                            </td>
                            </form>
                        </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>
            <div class="row">
                <div class="col-md-3">
                <div class="form-group">
                    <label for="">Delivery Date :</label>
                    
                    <form method="post" class="deliverydate1" 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>
                        <?php $__currentLoopData = $item; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <div class="input-group date" id="reservationdate" data-target-input="nearest">
                            <input type="text" class="form-control datetimepicker-input" value="<?php echo e($data->deliverydate); ?>" id="delivery_date" name="delivery_date" data-target="#reservationdate"/  required>
                            <div class="input-group-append" data-target="#reservationdate" data-toggle="datetimepicker">
                                <div class="input-group-text"><i class="fa fa-calendar"></i></div>
                            </div>
                        </div>
                        <input type="submit" style="visibility: hidden;" />
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </form>
                    

                </div>
                </div>
                <?php $__currentLoopData = $item; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <div class="col-md-3">
                        <div class="form-group">
                        <label>Payment Method :</label>
                        <form method="post" id="paymentmethodupdate" 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" name="payment" id="payment" style="width: 100%;" required>
                            <option value="" selected="selected" disabled>Select</option>
                            <option value="cash" <?php if($data->paymentmethod=="cash" ): ?>selected <?php endif; ?> >Cash on delivery</option>
                            <option value="paid" <?php if($data->paymentmethod=="paid" ): ?>selected <?php endif; ?> >Paid</option>

                        </select>
                        </form>
                    </div>
                </div>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                <div class="col-md-4"></div>
                <div class="col-md-1" style="padding-top:32px;">
                <form method="post" id="deliveryform100" 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>
                    <button type="submit" name="deliverydown" class="btn btn-block btn-info" value="deliverydown">100</button>
                    </form>
                </div>
                <div class="col-md-1" style="padding-top:32px;">
                <form method="post" id="deliveryform300" 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>
                    <button type="submit" name="deliveryup" class="btn btn-block btn-info" value="deliveryup">300</button>
                    </form>
                </div>
                
            </div>
            </div>
        </div>

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

        <div class="row">
            <?php $__currentLoopData = $item; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                <input type="hidden" value="<?php echo e($data->id); ?>" name="cus_id">
                <input type="hidden" value="<?php echo e($data->status); ?>" name="nowstatus">
            <div class="col-md-2">
            <button type="submit" name="Attempt" class="btn btn-block btn-warning" value="Attempt">1st Attempt</button>
            <button type="submit" name="pending" style="display:none" id="pendingbtn" value="pending"></button>
            </div>
            <?php if($data->status =='12'): ?>  
            <div class="col-md-2"><button type="submit" onClick="return validateForm()" name="Colombo" class="btn btn-block btn-info" value="Colombo" disabled>Colombo Confirm</button></div>
            <?php else: ?>
            <div class="col-md-2"><button type="submit" onClick="return validateForm()" name="Colombo" class="btn btn-block btn-info" value="Colombo">Colombo Confirm</button></div>
            <?php endif; ?>
            <div class="col-md-2"><button type="submit" name="Confirm" class="btn btn-block btn-success" value="Confirm">Out Confirm</button></div>
            <div class="col-md-2"><button type="submit" name="Cancel" class="btn btn-block btn-danger" value="Cancel">Cancel</button></div>
            </form>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            <div class="col-md-2">
                <div class="form-group">
                <form action="/updatestatus" method="post" enctype="multipart/form-data">
                    <?php echo e(csrf_field()); ?>

                    <?php $__currentLoopData = $item; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <input type="hidden" value="<?php echo e($data->id); ?>" name="cus_id">
                        <input type="hidden" value="<?php echo e($data->status); ?>" name="nowstatus">
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        <input type="hidden" value="<?php echo e($tot + $deli); ?>" name="total">
                        <select class="form-control" name="statusValu"  required>
                        <option value="" selected="selected" disabled>Change Status</option>
                        <option value="1">Pending</option>
                        <option value="2">1st Attempt</option>
                        <option value="3">2nd Attempt</option>
                        <option value="4">3rd Attempt</option>
                        <option value="5">Colombo Confirm</option>
                        <option value="6">Confirm </option>
                        <!-- <option value="7">Return Order</option> -->
                        <!-- <option value="8">Complete Order</option> -->
                        <option value="9">Paid</option>
                        <option value="10">Cancel</option>
                        <option value="17">He will call</option>
                        <option value="16">Phone off</option>
                        </select>
                </div>
            </div>
            <div class="col-md-2">
            <button type="submit" class="btn btn-block btn-primary" >Change Status</button>
            </div>
            </form>
          </div>

        </div>
    </div>
<br><br>
            <div style="text-align:right;">
                <?php $__currentLoopData = $item; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <h6>Order Created By - <?php echo e($data->user); ?></h6>
                    <h6>Last Updated Date  - <?php echo e($data->updated_at); ?></h6>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </div>
      </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="/updatecusdetails" method="post" enctype="multipart/form-data">
          <?php echo e(csrf_field()); ?>

            <div class="modal-body">
            <?php $__currentLoopData = $item; $__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>Page Name</label>
                        <select class="form-control" name="pageName" required>
                            <?php $__currentLoopData = $page; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $paged): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($paged->id); ?>"<?php if($paged->id==$data->pageName): ?> selected <?php endif; ?>><?php echo e($paged->pagename); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                </div>
                <div class="form-group">
                    <label>Branch</label>
                            <select class="form-control" name="branch" id="branch" required>
                            <option value="Battaramulla"<?php if($data->branch=="Battaramulla"): ?> selected <?php endif; ?>>Battaramulla</option>
                            <option value="Borella"<?php if($data->branch=="Borella"): ?> selected <?php endif; ?>>Borella</option>                            
                        </select>
                </div>
                <div class="form-group">
                    <label>Order Source</label>
                            <select class="form-control" name="source" id="source" required>
                            <option value="Facebook Leads"<?php if($data->ordersource=="Facebook Leads"): ?> selected <?php endif; ?>>Facebook Leads</option>
                            <option value="Facebook Message"<?php if($data->ordersource=="Facebook Message"): ?> selected <?php endif; ?>>Facebook Message</option>                            
                            <option value="Whatsapp"<?php if($data->ordersource=="Whatsapp"): ?> selected <?php endif; ?>>Whatsapp</option>                            
                            <option value="Call Order"<?php if($data->ordersource=="Call Order"): ?> selected <?php endif; ?>>Call Order</option>                            
                            <option value="Store Pickup"<?php if($data->ordersource=="Store Pickup"): ?> selected <?php endif; ?>>Store Pickup</option>                            
                        </select>
                </div>
              <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>Tracking Code</label>
                  <input type="text" placeholder=""  value="<?php echo e($data->tracking); ?>" id="tracking" name="tracking" 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>


                <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" id="additemform" enctype="multipart/form-data">
                          <?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">
                                <input type="hidden" class="form-control" id="id" name="id" value="<?php echo e($cus_id); ?>" required>
                                <select class="js-example-basic-single" name="nameproduct"  id="nameproduct">
                                    <option selected disabled>Product Name</option>
                                    <?php $__currentLoopData = $prods; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $prodsda): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($prodsda->id); ?>"><?php echo e($prodsda->name); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> 
                                </select>
                                <script>
                                   $(document).ready(function() {
                                        $('.js-example-basic-single').select2();
                                    });
                                </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" value="1" 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" enctype="multipart/form-data" id="updateproditform">
                          <?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="js-example-basic-single" id="nameproduct2" name="nameproduct2">
                                    <!-- <option selected disabled>Product Name</option> -->
                                    <?php $__currentLoopData = $prods; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $prodsda): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($prodsda->id); ?>"><?php echo e($prodsda->name); ?></option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> 
                                </select>
                                </div>
                                <script>
                                   $(document).ready(function() {
                                        $('.js-example-basic-single').select2();
                                    });
                                </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>
                        <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="deliveryupdateform22" enctype="multipart/form-data">
                          <?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="Delivery3" 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>



<style>
.borderless td, .borderless th {
    border: none;
}
.borderless tr{
    line-height: 1px;
}
</style>

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

<script>
// delivery_date
$(function() {
    $('#cituselect').change(function() {
        // this.form.submit();
    $(".cityupdateform").submit();

    });

$("#payment").change(function () {
    $("#paymentmethodupdate").submit();
    });

});
$(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");
            
        }


 });
});



// $(function() {
//     $(window).unload(function() {
//     alert("you leaving this page");
//    
// });
// });
$('#reservationdate').datetimepicker({
    format: 'YYYY/MM/DD'
    });

document.getElementById('reservationdate').onchange = function(){ 
    $(".deliverydate1").submit();
}


$(document).ready(function()
{
    $(window).bind("beforeunload", function() { 
        $("#pendingbtn").trigger('click'); 
    });
});


$(document).on('click', '.dangeritem', function (e) {
    e.preventDefault();
    var id = $(this).data('id');
    let ele = this;
                            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();
                                            toastr.error('Product Removed successfully!')
                                            $("#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(0).change();
    }

    
</script>


<script>
$('#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>
$('#nameproduct').on('change', function(){
    var id = $(this).val();

    $.ajax({
            url: "<?php echo e(url('/getproductprice')); ?>/"+id ,
            method: "get",
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            },
            cache: false,
            contentType: false,
            processData: false,
            dataType: 'JSON',
            data:{
                "id":id
            },
            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");
            },
        });



    if(id){
        $.ajax({
    url: "<?php echo e(url('/dependdata')); ?>/"+id ,
    method: "get",
    headers: {
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    },
    cache: false,
    contentType: false,
    processData: false,
    dataType: 'JSON',
    data:{
        "id":id
    },
    success: function (data) {
        $('.att-group').remove()
        jQuery.each(data, function(key,value){
            $('.applenddata').append('<div class="form-group row att-group"><label for="'+value.attname+'" class="col-sm-2 col-form-label">Select '+value.attname+'</label><div class="col-sm-10"><select class="form-control" id="'+value.attname+'" name="product_properties['+value.attname+']"></select></div></div>')
                    word = value.attributes;

                    result = word.split(","); 
                    // console.log(result);
                    var i;
                    for (i = 0; i < result.length; i++) { 
                    $('#'+value.attname).append('<option value="'+ result[i] +'">'+ result[i] +'</option>');
                    }

        });

    },
    error: function (jqXHR, textStatus, errorThrown) {
        swal("Warning", "Unable to Process your request", "error");
    },
});
    }else{
        $('#nameproduct').empty();
    }

});



$('#nameproduct2').on('change', function(){
    var id = $(this).val();
    if(id){
        $.ajax({
    url: "<?php echo e(url('/dependdata2')); ?>/"+id ,
    method: "get",
    headers: {
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    },
    cache: false,
    contentType: false,
    processData: false,
    dataType: 'JSON',
    data:{
        "id":id
    },
    success: function (data) {
        $('.att-group2').remove()
        jQuery.each(data, function(key,value){
            $('.applenddata2').append('<div class="form-group row att-group2"><label for="'+value.attname+'" class="col-sm-2 col-form-label">Select '+value.attname+'</label><div class="col-sm-10"><select class="form-control" id="e'+value.attname+'" name="product_properties2['+value.attname+']"></select></div></div>')
                    word = value.attributes;

                    result = word.split(","); 
                    // console.log(result);
                    var i;
                    for (i = 0; i < result.length; i++) { 
                    $('#e'+value.attname).append('<option value="'+ result[i] +'">'+ result[i] +'</option>');
                    }
                    
        });

    },
    error: function (jqXHR, textStatus, errorThrown) {
        swal("Warning", "Unable to Process your request", "error");
    },
});
    }else{
        $('#nameproduct2').empty();
    }

});
$(function() {
    const Toast = Swal.mixin({
      toast: true,
      position: 'top-end',
      showConfirmButton: false,
      timer: 3000
    });
  });

$('#additemform').on('submit', function(event){
    let ele = this;
        event.preventDefault();
        var form_data = $(this).serialize();
        $.ajax({
            url:"/addcustomerItemsview",
            method:"POST",
            data:form_data,
            dataType:"json",      
            success: function (result, code, ex) {
                // swal("Done!", "It was successfully!", "success");
                $("#exampleModalCenter").modal('hide');  
                $("#here").load(location.href + " #here");
                toastr.success('Product Added successfully!')
                location.reload();
            },
            error: function (jqXHR, textStatus, errorThrown) {
                swal("Warning", "Unable to Process your request", "error");
            },
            
        })
    });

$('#updateproditform').on('submit', function(event){
    let ele = this;
        event.preventDefault();
        var form_data = $(this).serialize();
        $.ajax({
            url:"/updateitemview",
            method:"POST",
            data:form_data,
            dataType:"json",      
            success: function (result, code, ex) {
                // swal("Done!", "It was successfully!", "success");
                $("#editordermodel").modal('hide');  
                $("#here").load(location.href + " #here");
   
                toastr.success('Product Updated successfully!')
                location.reload();
            },
            error: function (jqXHR, textStatus, errorThrown) {
                swal("Warning", "Unable to Process your request", "error");
            },
            
        })
    });


    $('#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");
                location.reload();
                toastr.success('Delivery Charges Added successfully!')
                

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


        $('#paymentmethodupdate').on('submit', function(event){
    let ele = this;
        event.preventDefault();
        var form_data = $(this).serialize();
        $.ajax({
            url:"/paymentmethodup",
            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('Payment Method Added successfully!')
                

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

    
    $('.deliverydate1').on('submit', function(event){
    let ele = this;
        event.preventDefault();
        var form_data = $(this).serialize();
        $.ajax({
            url:"/deliverydate",
            method:"POST",
            data:form_data,
            dataType:"json",      
            success: function (data, code, ex) {
                toastr.success('Delivery Date Update successfully!')
                jQuery.each(data, function(key,value){
        });

            },
            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");
            },
            
        })
    });


    $('.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");
            },
            
        })
    });


    $('#deliveryform100').on('submit', function(event){
    let ele = this;
        event.preventDefault();
        var form_data = $(this).serialize();
        $.ajax({
            url:"/deliverybtnupdate",
            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('Delivery Charges Added successfully!')
                

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

        $('#deliveryform300').on('submit', function(event){
    let ele = this;
        event.preventDefault();
        var form_data = $(this).serialize();
        $.ajax({
            url:"/deliverybtnupdate2",
            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('Delivery Charges Added successfully!')
                

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


$('#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();   
   })
</script>
