<?php $__env->startSection('title','اضافة مورد جديد'); ?>
<?php $__env->startSection('content'); ?>
  <!-- BEGIN: Content-->
  <div class="app-content content ">
    <div class="content-overlay"></div>
    <div class="header-navbar-shadow"></div>
    <div class="content-wrapper container-xxl p-0">
      <div class="content-header row">
        <div class="content-header-left col-md-9 col-12 mb-2">
          <div class="row breadcrumbs-top">
            <div class="col-12">
              <h2 class="content-header-title float-start mb-0">إضافة مورد</h2>
              <div class="breadcrumb-wrapper">
                <ol class="breadcrumb">
                  <li class="breadcrumb-item"><a href="<?php echo e(route('client.home')); ?>">لوحة التحكم</a>
                  </li>
                  <li class="breadcrumb-item"><a href="<?php echo e(route('client.suppliers.index')); ?>">الموردين</a>
                  </li>
                  <li class="breadcrumb-item active">إضافة
                  </li>
                </ol>
              </div>
            </div>
          </div>
        </div>
        <div class="content-header-right text-md-end col-md-3 col-12 d-md-block d-none">
          <div class="mb-1 breadcrumb-right">
            <div class="dropdown">
                <a  href="<?php echo e(route('client.suppliers.index')); ?>">
                    <button class="btn-icon btn btn-primary" type="button"><i data-feather='eye'> </i></button>
                </a>
            </div>
          </div>
        </div>
      </div>
      <div class="content-body">
        <!-- Basic Horizontal form layout section start -->
        <!-- Basic multiple Column Form section start -->
<section id="multiple-column-form">
<div class="row">
  <div class="col-12">
    <div class="card">
      <div class="card-header">
        <h4 class="card-title">البيانات الاساسية</h4>
      </div>
      <div class="card-body">
        <form class="form" id="addForm" action="#">
            <input type="hidden" name="company_id" value="<?php echo e($company_id); ?>">

            <?php echo csrf_field(); ?>
          <div class=" row">

            <div class="col-xl-6 col-md-6 col-12" >

            <div class="col-6 md-6 col-12">
              <div class="mb-1">
                <b class="form-label" for="supplier_name">اسم المورد</b>

                <input
                  type="text"
                  id="supplier_name"
                  class="form-control"
                  placeholder="اسم المورد"
                  name="supplier_name"
                />
              </div>
            </div>
            
            <div class="col-6 md-6 col-12">
                <div class="mb-1">
                  <b class="form-label" for="notes">ملاحظات المورد</b>
                  <input type="text" name="notes[]" class="form-control"
                  style="width:90%; display: inline; float: right;" placeholder="ملاحظات المورد">
                 <button type="button" id="add_note" class="btn btn-md btn-info"
                   style="width:7%;height: 35px;display: inline; float: left;padding: 5px;">
                   <i data-feather='plus'></i>
                    </button>
                    <div class="dom2"></div>

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

            <div class="col-xl-6 col-md-6 col-12 " >
        
             <div class="col-xl-12 col-md-12 col-12 row" >
          
            <div class="col-md-6 col-12">
              <div class="mb-1">
                <b class="form-label" for="prev_balance">المديونية :  </b>
                <input  checked type="radio" value="for" name="balance"/> له
                <input   type="radio" value="on" name="balance" /> عليه
                <input  type="text" value="0" name="prev_balance" class="form-control" placeholder="مديونية المورد" >
                 </div>
            </div>

                <div class="col-md-6 col-12">
                    <div class="mb-1">
                    <b class="form-label" for="phone">رقم الهاتف بمفتاح الدولة</b>
                                <input type="text" name="phones[]" class="form-control"
                                       style="width:80%; display: inline; float: right;" placeholder="رقم الهاتف بمفتاح الدولة">
                                       <button type="button" id="add_phone" class="btn btn-md btn-success"
                                        style="width:15%;height: 30px;display: inline; float: left;padding: 5px;">
                                        <i data-feather='plus'></i>
                                    </button>
                                <div class="dom1"></div>
                    </div>
                </div>
                
            </div>

            <div class="col-6 md-6 col-12">
                <div class="mb-1">
                    <b class="form-label" for="address"> عنوان المورد </b>
                    <br>
                    <input type="text" name="addresses[]" class="form-control" placeholder="عنوان المورد "
                           style="width:90%; display: inline; float: right;" >
                    <button type="button" id="add_address" class="btn btn-md btn-warning"
                            style="width:7%;height: 35px;display: inline; float: left;padding: 5px;">
                            <i data-feather='plus'></i>
                        </button>
                    <div class="dom3"></div>
                </div>
              </div>
              
            </div>
        </div>
<br>

        <div class="clearfix"></div>
        <center>
        <a href="javascript:;" class="btn btn-link open_extras">
            <i class="fa fa-plus"></i>
            خيارات اضافية
        </a>
        </center>
        <div class="clearfix"></div>
        <div class="extras row" style="display: none">


               <div class="col-md-4 col-12" >
                    <div class="mb-1">
                    <b class="form-label" for="supplier_category">فئة التعامل</b>
                    <select name="supplier_category" class="form-control" required>
                        <option value="">اختر الفئة</option>
                        <option  value="جملة">جملة</option>
                        <option  selected value="قطاعى">قطاعى</option>
                    </select>
                    </div>
                </div>

                <div class="col-md-4 col-12" >
                      <div class="mb-1">
                    <b class="form-label" for="supplier_email">البريد الالكترونى</b>
                    <input type="email" name="supplier_email"  placeholder="البريد الالكترونى"
                           class="form-control">
                      </div>
                </div>


                <div class="col-md-4 col-12" >
                  <div class="mb-1">
                    <b class="form-label" >اسم محل / شركة المورد</b>
                    <input type="text" name="shop_name" placeholder="اسم محل / شركة المورد"
                           class="form-control"  >
                  </div>
                </div>

                <div class="col-md-4 col-12" >
                  <div class="mb-1">
                    <b class="form-label" for="supplier_national">جنسية المورد</b>
                    <select name="supplier_national" class="form-control">
                        <option value="">اختر دولة</option>
                        <?php $__currentLoopData = $timezones; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $timezone): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($timezone->country_name); ?>"><?php echo e($timezone->country_name); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                  </div>
                </div>

                <div class="col-md-4 col-12" >
                  <div class="mb-1">
                    <b class="form-label" for="tax_number">الرقم الضريبى</b>
                    <input type="text" name="tax_number"
                           class="form-control"  placeholder="الرقم الضريبى" />
                </div>
                </div>
                <div class="clearfix"></div>

           
        </div>


            <div class="col-12" align="center">
            <br>
              <button type="submit" class="btn btn-success me-1">إضافة</button>
              <button type="button" class="btn btn-outline-danger" onclick="window.history.back()">رجوع</button>
            </div>
          </div>
          
        </form>
      </div>
    </div>
  </div>
</div>
</section>
<!-- Basic Floating Label Form section end -->

      </div>
    </div>
  </div>
  <!-- END: Content-->
<?php $__env->stopSection(); ?>
<?php $__env->startSection('script'); ?>

    <script>
            $('#add_phone').on("click", function () {
        $('<div><input autofocus type="text" name="phones[]" class="form-control"  style="margin:10px 0; display:inline;float:right;width:80%" placeholder="رقم الهاتف بمفتاح الدولة" />' +
            '<button type="button" class="btn btn-danger btn-sm delete_note" style="width:10%;height: 35px;display: inline; float: left;padding: 5px; margin-top: 10px"><i class="la la-trash"></i></button>' +
            '<div class="clearfix"></div></div>').insertBefore('.dom1');
        $('.delete_phone').on('click', function () {
            $(this).parent().remove();
        });
    });
    $('#add_note').on("click", function () {
        $('<div><input autofocus type="text" name="notes[]" class="form-control"  style="margin:10px 0; display:inline;float:right;width:90%"  placeholder="ملاحظات المورد" />' +
            '<button type="button" class="btn btn-danger btn-sm delete_note" style="width:7%;height: 35px;display: inline; float: left;padding: 5px; margin-top: 10px"><i class="la la-trash"></i></button>' +
            '<div class="clearfix"></div></div>').insertBefore('.dom2');
        $('.delete_note').on('click', function () {
            $(this).parent().remove();
        });
    });
    $('#add_address').on("click", function () {
        $('<div><input autofocus type="text" name="addresses[]" class="form-control"  style="margin:10px 0; display:inline;float:right;width:90%" placeholder="عنوان المورد " />' +
            '<button type="button" class="btn btn-danger btn-sm delete_address" style="width:7%;height: 35px;display: inline; float: left;padding: 5px; margin-top: 10px"><i class="la la-trash"></i></button>' +
            '<div class="clearfix"></div></div>').insertBefore('.dom3');
        $('.delete_address').on('click', function () {
            $(this).parent().remove();
        });
    });

    $('.open_extras').on('click',function () {
        $('.extras').fadeIn(300);
        $(this).fadeOut(300);
    });

        
        var selectForm = $('#addForm');

if (selectForm) {
    selectForm.validate({

        rules: {
      'supplier_name': {
        required: true,
      },
      'supplier_category': {
        required: true
      },
      'prev_balance': {
        required: true
      },'supplier_email': {
        email: true
      }
    
    }
  });
}


$("#addForm").on('submit',(function(e) {

e.preventDefault();

$.ajax({

  url: "<?php echo e(route('client.suppliers.store')); ?>",

  type: "POST",

  data:  new FormData(this),

  dataType:  'json',

  contentType: false,

  cache: false,

  processData:false,

  beforeSend : function (){var ifConnected = window.navigator.onLine;if (!ifConnected) {toastr.info("يتم الآن إعادة الإتصال","لا يوجد إتصال بالإنترنت",{positionClass: "toast-top-right",tapToDismiss: !1,timeOut: 2e3,rtl: $("html").attr("data-textdirection")});}},


  success: function(response) {

    if(response.status){

            toastr.success("",response.message,{
			positionClass: "toast-top-right",
			tapToDismiss: !1,
			timeOut: 2e3,
			rtl: $("html").attr("data-textdirection")
		    });      

    } 
    document.getElementById("addForm").reset();

  },
  error: function(response){
          $.each(response.responseJSON.errors, function (key, item) 
          {
            toastr.error("",item,{
			positionClass: "toast-top-right",
			tapToDismiss: !1,
			timeOut: 2e3,
			rtl: $("html").attr("data-textdirection")
		    });

          });
  },

 });

}));

        </script>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('style'); ?>
<style>
    .btn.dropdown-toggle.bs-placeholder {
        height: 40px;
    }
</style>
<?php $__env->stopSection(); ?>


<?php echo $__env->make('client.layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/barasys/public_html/resources/views/client/suppliers/create.blade.php ENDPATH**/ ?>