<?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">Dispatch Summary</h1> -->
            <a href="/dispatchsummary">Go Back</a>
            <h3></h3>
          </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">Dispatch Summary</li>
            </ol>
          </div>
        </div>
      </div>
    </div>
   
    <section class="content">
      <div class="container-fluid">
      <div class="row">
          <div class="col-md-12">
                    <div class="alert alert-info alert-dismissible">
                    <h4><?php echo e($getcour->getdelivername->deliveryname); ?> Dispatch Summary - <?php echo e($getcour->created_at); ?></h4>
                    <h4></h4>
            </div>
        </div>
        </div>
      <div class="card">
        <div class="card-body">
          <div class="row">
            <div class="col-md-12">
                <div class="form-group">
                    <form method="post" id="dispatchordersput" class="disformsend">
                        <?php echo e(csrf_field()); ?>

                        <input type="hidden" value="<?php echo e($disid); ?>" name="dispachid" required>
                        <input type="hidden" value="<?php echo e($getcour->courierservice); ?>" name="courierid" required>
                        <input type="text" class="form-control invoiceidtext" name="waybill" id="waybill" placeholder="Invoice ID + Press Enter Key" required autofocus>
                    
                    </form>
                </div>

                <table id="example12" 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>COD</th>
                            <th>Action</th>
                        </tr>
                    </thead>

                </table>


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





      <div class="card">
        <div class="card-body">
          <div class="row">
            <div class="col-md-12">


                <table id="example" 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>COD</th>
                            <th>Action</th>
                        </tr>
                    </thead>

                </table>
            </div>
          </div><br><br>

          <form action="/exportpage" method="post" enctype="multipart/form-data">
            <?php echo e(csrf_field()); ?>

          <div class="row">
 
            <div class="col-md-2">
                <div class="form-group">
                <input type="hidden" value="<?php echo e($disid); ?>" name="dispachid" required>
                <?php $__currentLoopData = $delive; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $datac): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <input type="hidden" value="<?php echo e($datac->getdelivername->deliveryname); ?> " name="delivery" required>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                <button type="submit" value="Domex" name="Domex" class="btn btn-primary btn-block">Domex Excel</button>
                </div>
            </div>
            <div class="col-md-2">
                <div class="form-group">
                <button type="submit" value="Koobiyo" name="Koobiyo" class="btn btn-success btn-block">Koobiyo Excel</button>
                </div>
            </div>
            <div class="col-md-2">
                <div class="form-group">
                <button type="submit" value="Trans" name="Trans" class="btn btn-warning btn-block">Trans Express Excel</button>
                </div>
            </div>
            <div class="col-md-2">
                <div class="form-group">
                <button type="submit" value="Fardar" name="Fardar" class="btn btn-danger btn-block">Fardar Express Excel</button>
                </div>
            </div>
            <div class="col-md-2">
                <div class="form-group">
                <button type="submit" value="Grasshopper" name="Grasshopper" class="btn btn-secondary btn-block">Grasshopper Excel</button>
                </div>
            </div>
            </form>


            <div class="col-md-2">
                <div class="form-group">
                    <form method="post" action="/courierpdfdata" class="cusdddd">
                        <?php echo e(csrf_field()); ?>

                        <input type="hidden" value="<?php echo e($disid); ?>" name="dispachid" required>
                        <?php $__currentLoopData = $delive; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $datac): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <input type="hidden" value="<?php echo e($datac->getdelivername->deliveryname); ?> " name="delivery" required>
                        <input type="hidden" value="<?php echo e($datac->courierservice); ?> " name="courierservice" required>
                        <input type="hidden" value="<?php echo e($datac->noofline); ?> " name="noofline" required>
                        <input type="hidden" value="<?php echo e($datac->created_at); ?> " name="cdate" required>
                        <input type="hidden" value="<?php echo e($datac->createdby); ?> " name="create" required>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        <button type="submit" formtarget="_blank" class="btn btn-dark btn-block">Dispatch Summary</button>
                </div>
            </div>

            </form>
            </div>
            
            <br><hr><br>
    <h4>Send E-mail</h4> <br>
    <form method="post" action="/sendemail" enctype="multipart/form-data">
    <?php echo e(csrf_field()); ?>

    <input type="hidden" value="<?php echo e($disid); ?>" name="dispachid" required>
                <?php $__currentLoopData = $delive; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $datac): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <input type="hidden" value="<?php echo e($datac->getdelivername->deliveryname); ?> " name="delivery" required>
                <input type="hidden" value="<?php echo e($datac->noofline); ?> " name="noofline" required>
                <input type="hidden" value="<?php echo e($datac->getdelivername->email); ?> " name="email" required>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    <div class="row">
          <div class="col-md-1"></div>
          <?php $__currentLoopData = $delive; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $datac): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
          <?php if($datac->getdelivername->id == 1): ?>
            <div class="col-md-2">
                <div class="form-group">
                <button type="submit" value="Domex" name="Domex" class="btn btn-primary btn-block">Domex Excel</button>
                </div>
            </div>
            <?php elseif($datac->getdelivername->id == 1): ?>
            <div class="col-md-2">
                <div class="form-group">
                <button type="submit" value="Koobiyo" name="Koobiyo" class="btn btn-success btn-block">Koobiyo Excel</button>
                </div>
            </div>
            <?php elseif($datac->getdelivername->id == 3): ?>
            <div class="col-md-2">
                <div class="form-group">
                <button type="submit" value="Trans" name="Trans" class="btn btn-warning btn-block">Trans Express Excel</button>
                </div>
            </div>
            <?php elseif($datac->getdelivername->id == 1): ?>
            <div class="col-md-2">
                <div class="form-group">
                <button type="submit" value="Fardar" name="Fardar" class="btn btn-danger btn-block">Fardar Express Excel</button>
                </div>
            </div>
            <?php elseif($datac->getdelivername->id == 4): ?>
            <div class="col-md-2">
                <div class="form-group">
                <button type="submit" value="Grasshopper" name="Grasshopper" class="btn btn-secondary btn-block">Grasshopper Excel</button>
                </div>
            </div>
            <?php endif; ?>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </div>
    </form>







    <form method="post" action="/sendemail" enctype="multipart/form-data">
    <?php echo e(csrf_field()); ?>

    <input type="hidden" value="<?php echo e($disid); ?>" name="dispachid" required>
                <?php $__currentLoopData = $delive; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $datac): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <input type="hidden" value="<?php echo e($datac->getdelivername->deliveryname); ?> " name="delivery" required>
                <input type="hidden" value="<?php echo e($datac->noofline); ?> " name="noofline" required>
                <input type="hidden" value="<?php echo e($datac->getdelivername->email); ?> " name="email" required>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    <div class="row">
          <div class="col-md-1"></div>

            <div class="col-md-2">
                <div class="form-group">
                <button type="submit" value="Domex" name="Domex" class="btn btn-primary btn-block">Domex Excel</button>
                </div>
            </div>
            
            <div class="col-md-2">
                <div class="form-group">
                <button type="submit" value="Koobiyo" name="Koobiyo" class="btn btn-success btn-block">Koobiyo Excel</button>
                </div>
            </div>

            <div class="col-md-2">
                <div class="form-group">
                <button type="submit" value="Trans" name="Trans" class="btn btn-warning btn-block">Trans Express Excel</button>
                </div>
            </div>
  
            <div class="col-md-2">
                <div class="form-group">
                <button type="submit" value="Fardar" name="Fardar" class="btn btn-danger btn-block">Fardar Express Excel</button>
                </div>
             </div>
            <div class="col-md-2">
                <div class="form-group">
                <button type="submit" value="Grasshopper" name="Grasshopper" class="btn btn-secondary btn-block">Grasshopper Excel</button>
                </div>
            </div>
            </div>
        
    </form>









             <br><br><br><br><br><br><br><br>

          </div>
        </div>

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



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

<script>
$(document).ready(function() {
    $('.invoiceidtext').bind("enterKey",function(e){
  $("#dispatchordersput").submit();
});
} );

//  $('input[name=waybill]').change(function() { 
//     $("#dispatchordersput").submit();
//  });




     $('#dispatchordersput').on('submit', function(event){
    let ele = this;
        event.preventDefault();
        var form_data = $(this).serialize();
        $.ajax({
            url:"/dispatchordersputupdate",
            method:"POST",
            data:form_data,
            dataType:"json",      
            success: function (data) {
                jQuery.each(data, function(key,value){
                    if(value=="1"){
                        $('#example12').DataTable().ajax.reload();
                        $('#example').DataTable().ajax.reload();
                        $('#waybill').val("");
                        $("#waybill").focus();
                        swal({
                            title: "Error!",
                            text: "Delivery Service Not Matching",
                            icon: "error",
                            button: "OK",
                        });
                    }
                    else if(value=="2"){
                        $('#example12').DataTable().ajax.reload();
                        $('#example').DataTable().ajax.reload();
                        $('#waybill').val("");
                        $("#waybill").focus();
                        swal({
                            title: "Error!",
                            text: "Already Dispatched!",
                            icon: "error",
                            button: "OK",
                        });
                    }
                    else{
                        toastr.success('Dispatch the order successfully!')
                            $('#example12').DataTable().ajax.reload();
                            $('#example').DataTable().ajax.reload();
                                    $('#waybill').val("");
                                    $("#waybill").focus();
                    }
                
                });



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



$(document).ready(function() {
  var table = $('#example12').DataTable({
        "ajax": {   "url": '/dispatchedcusd',
                    "type": 'POST',
                    "data": function ( d ) {
                    return $('.disformsend').serialize();
                    }
        },
        columns: [
            { data: 'id', name: 'id' },
            { data: 'name', name: 'name' },
            { data: 'address', name: 'address'},
            { data: 'phone', name: 'phone'},
            { data: 'cod', name: 'cod'},
            { data: 'action', name: 'action', orderable: false, searchable: false}
        ],
        columnDefs: [
                      {
                          "targets": 5, // your case first column
                          "className": "text-center",
                          "width": "4%"
                    },
                    {
                          "targets": 4,
                          "className": "text-center",
                    },
                    {
                          "targets": 3,
                          "className": "text-left",
                          "color": "#00ff00",

                    }
                    ],
    });
} );

$(document).ready(function() {
  var table = $('#example').DataTable({
        "ajax": {   "url": '/cusdispatchedcusd',
                    "type": 'POST',
                    "data": function ( d ) {
                    return $('.cusdddd').serialize();
                    }
        },
        columns: [
            { data: 'id', name: 'id' },
            { data: 'name', name: 'name' },
            { data: 'address', name: 'address'},
            { data: 'phone', name: 'phone'},
            { data: 'cod', name: 'cod'},
            { data: 'action', name: 'action', orderable: false, searchable: false}
        ],
        columnDefs: [
                      {
                          "targets": 5, // your case first column
                          "className": "text-center",
                          "width": "4%"
                    },
                    {
                          "targets": 4,
                          "className": "text-center",
                    },
                    {
                          "targets": 3,
                          "className": "text-left",
                          "color": "#00ff00",

                    }
                    ],
    });
} );

</script>