<?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">Add Order</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">Add Order</li>
            </ol>
          </div>
        </div>
      </div>
    </div>
   
    <section class="content">
      <div class="container-fluid">
      <div class="card">
        <div class="card-body">
          <div class="row">
            <div class="col-md-12">
                <form method="post" action="/addcustomer">
                <?php echo e(csrf_field()); ?>

                <div class="form-group row">
                    <label for="" class="col-sm-2 col-form-label">Page Name</label>
                    <div class="col-sm-10">
                        <select class="form-control" name="pageName" id="pageName" required>
                            <!-- <option selected disabled>Page Name</option> -->
                            <?php $__currentLoopData = $items; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($data->id); ?>"><?php echo e($data->pagename); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>
                </div>
                <div class="form-group row">
                    <label for="" class="col-sm-2 col-form-label">Branch</label>
                    <div class="col-sm-10">
                    <select class="form-control" name="branch" id="branch" readonly>
                        <option value="Battaramulla">Battaramulla</option>
                        <option value="Borella">Borella</option>                            
                    </select>
                    </div>
                </div>
                <div class="form-group row">
                    <label for="" class="col-sm-2 col-form-label">Order Source</label>
                    <div class="col-sm-10">
                      <select class="form-control" name="source" id="source">
                          <option value="Facebook Leads">Facebook Leads</option>
                          <option value="Facebook Message">Facebook Message</option>                            
                          <option value="Whatsapp">Whatsapp</option>                            
                          <option value="Call Order">Call Order</option>                            
                          <option value="Store Pickup">Store Pickup</option>                            
                          <option value="Web Order">Web Order</option>                            
                      </select>
                    </div>
                </div>
                <div class="form-group row">
                    <label for="" class="col-sm-2 col-form-label">Customer Name</label>
                    <div class="col-sm-10">
                    <input type="text" class="form-control" id="name" name="name" placeholder="Customer Name" required>
                    </div>
                </div>
                <div class="form-group row">
                    <label for="" class="col-sm-2 col-form-label">Customer Adress</label>
                    <div class="col-sm-10">
                    <textarea class="form-control" id="address" name="address" rows="6"></textarea>
                    </div>
                </div>
                <div class="form-group row">
                    <label for="" class="col-sm-2 col-form-label">Primary Phone Number</label>
                    <div class="col-sm-10">
                    <input type="text" class="form-control" id="phone" name="phone" placeholder="Primary Phone Number" required>
                    </div>
                </div> 
                <div class="form-group row">
                    <label for="" class="col-sm-2 col-form-label">Secondary Phone Number</label>
                    <div class="col-sm-10">
                    <input type="text" class="form-control" id="phone2" name="phone2" placeholder="Secondary Phone Number" required>
                    </div>
                </div><br><br>           
                <div class="form-group row">
                    <div class="col-sm-4"></div>
                    <div class="col-sm-4">
                    <button type="submit" class="btn btn-primary btn-block">Add Order</button>
                    </div>
                </div>
            </form>
            </div>
          </div>
          </div>
        </div>

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



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

<script>
$('#pageName').on('change', function(){
    var id = $(this).val();
    $.ajax({
            url: "<?php echo e(url('/getpagebranch')); ?>/"+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);
                            $("#branch").val(value[i].branch).change();
                        }

                    });

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