
<div class="modal fade" id="addTank" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1"
    aria-labelledby="addTank" aria-hidden="true" style="z-index: 12;">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title"><strong>إضافة عميل جديد </strong></h4>
            </div>
            <div class="modal-body">

                <form id="addNewAddressForm" method="POST" action="<?php echo e(route('storeClint')); ?>"
                    class="row g-3 fv-plugins-bootstrap5 fv-plugins-framework" novalidate="novalidate">
                    <?php echo csrf_field(); ?>
                    <div class="row">
                    <div class="col-12 mb-3">
                        <label class="form-label" for="name">الاسم</label>
                        <input type="text" id="name" name="name" class="form-control"placeholder="يرجى ادخال الاسم">
                        <div class="fv-plugins-message-container invalid-feedback">
                            
                        </div>
                    </div>
                    <div class="col-12 mb-3">
                        <label class="form-label" for="accountType">نوع الحساب</label>
                        <select id="accountType" name="accountType" class="form-control">
                            <option value="0">بترول</option>
                            <option value="1">ديزل</option>
                        </select>
                        <div class="fv-plugins-message-container invalid-feedback">
                            
                        </div>
                    </div>

                    <input type="hidden" value="4" name="role">

                    <div class="col-12 mb-3">
                        <label class="form-label" for="phone">رقم الهاتف او الجوال</label>
                        <input type="tel" id="phone" name="phone" class="form-control"
                            placeholder="يرجى ادخال رقم الهاتف او  الجوال">
                        <div class="fv-plugins-message-container invalid-feedback">
                            
                        </div>
                    </div>
                    <div class="col-12 mb-3">
                        <label class="form-label" for="address">العنوان</label>
                        <input type="text" id="address" name="address" class="form-control"
                            placeholder="يرجى ادخال اللعنوان">
                        <div class="fv-plugins-message-container invalid-feedback">
                            
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                        <button type="submit" class="btn btn-primary me-sm-3 me-1">اضافة</button>
                        <button type="reset" class="btn btn-label-secondary" data-bs-dismiss="modal"
                            aria-label="Close">الغاء</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<!-- Modal Quantity To Clint -->
<div class="modal fade" id="newDistrubutionToclint" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true" style="z-index: 11;">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
            <h4 class="modal-title"><strong>توزبع جديد للعملاء</strong></h4>
        </div>
        <div class="modal-body">
            <form id="addNewAddressForm"  class="row g-3 fv-plugins-bootstrap5 fv-plugins-framework needs-validation"  novalidate="" method="POST" action="<?php echo e(route('DistributionStore')); ?>">
                <?php echo csrf_field(); ?>
                <div class="row">
                    <div class="col-md-12 mb-2">
                            <label class="form-label" for="validationCustom01">اسم العميل<span class="text-danger">*</span>
                            </label>
                                <select class="form-control form-white" data-placeholder="Choose a color..." name="clintName" required>
                                    <option disabled="disabled" selected value="">الرجاء اختيار احد العملاء</option>
                                    <?php $__currentLoopData = $niceNames; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $niceName): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($niceName); ?>"><?php echo e($niceName); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                                <div class="invalid-feedback">
                                    يرجاء ادخال اسم المورد
                                </div>
                    </div>
                    <div class="col-md-12 mb-2">
                            <label class="form-label" for="validationCustom06">الكمية
                                <span class="text-danger">*</span>
                            </label>
                                <input name="quantity" type="number" class="form-control" id="validationCustom06" placeholder="ادخل الكمية.." required="">
                                <div class="invalid-feedback">
                                    يرجاء ادخل الكمية بشكل صحيح
                                </div>
                    </div>


                    <div class="col-md-12 mb-2">
                            <label class="form-label" for="validationCustom05">التوريدة الموزع منها
                                <span class="text-danger">*</span>
                            </label>
                            <select class="form-control form-white" data-placeholder="Choose a color..." name="supplyId" required>
                                <option  disabled="disabled" selected value="">الرجاء اختيار احدى التوريدات</option>
                                <?php $__currentLoopData = $supplies; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $supply): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <?php if($supply->supplier->balance>1): ?>
                                <option value="<?php echo e($supply->id); ?>">
                                    <?php echo e($supply->notice); ?> متبقي <?php echo e($supply->supplier->balance); ?>

                                </option>
                                <?php endif; ?>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                            <div class="invalid-feedback">
                                يرجاء اختيار احد التوريدات
                            </div>
                    </div>
                    <div class="col-md-12 mb-2">
                            <label class="col-lg-12 col-form-label" for="validationCustom02">ملاحظة لعملية التوزيع<span class="text-danger">*</span>
                            </label>
                            <div class="col-lg-12 post-input">
                                
                                <textarea name="notice" id="validationCustom02" cols="30" rows="5" class="form-control bg-transparent" placeholder="أكتب الملاحظة..." required=""></textarea>
                            <div class="invalid-feedback">
                                الرجاء ادخال  ملاحظة لعملية التوزيع
                            </div>
                            </div>

                    </div>
                </div>

        </div>
                <div class="modal-footer">
                <button type="button" class="btn btn-outline-primary  me-1" data-bs-toggle="modal" data-bs-target="#addTank" >
                    <i class="mdi mdi-plus-circle ms-2"></i>اضافة عميل جديد
                </button>
                <button type="submit" class="btn btn-primary me-sm-3 me-1">حفظ</button>
                <button type="reset" class="btn btn-label-secondary" data-bs-dismiss="modal" aria-label="Close">الغاء</button>
              </div>
              <input type="hidden">
             </form>
          </div>
      </div>
    </div>


<!-- End Modal Quantity To Clint -->

 
 <div class="modal fade" id="editModal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="modalEdit" aria-hidden="true">
    <div class="modal-dialog modal-lg modal-simple modal-add-new-address">
        <div class="modal-content">
            <div class="modal-body">
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                <div class="text-center mb-4">
                <h3 class="address-title">التعديل على التوزيعة</h3>
                <p class="address-subtitle">الرجاء التحقق من جميع الحقول</p>
            </div>
            <form id="addNewAddressForm"  class="row g-3 fv-plugins-bootstrap5 fv-plugins-framework needs-validation"  novalidate="" method="POST" action="<?php echo e(route('update_distribution')); ?>">
                <?php echo csrf_field(); ?>
                <div class="row">
                    <div class="col-xl-6">
                        <div class="mb-3 row">
                            <label class="col-lg-12 col-form-label" for="validationCustom01">اسم العميل<span class="text-danger">*</span>
                            </label>
                            <div class="col-lg-12">
                                <select id="clintName" class="form-control form-white" data-placeholder="Choose a color..." name="clintName" required>
                                    <option disabled="disabled" selected value="">الرجاء اختيار احد العملاء</option>
                                    <?php $__currentLoopData = $niceNames; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $niceName): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($niceName); ?>"><?php echo e($niceName); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                                <div class="invalid-feedback">
                                    يرجاء ادخال اسم العميل
                                </div>
                            </div>

                        </div>

                        <div class="mb-3 row">
                            <label class="col-lg-12 col-form-label" for="validationCustom02">ملاحظة لعملية التوريد<span class="text-danger">*</span>
                            </label>
                            <div class="col-lg-12">
                                <input name="notice" type="text" class="form-control form-control-sm" id="notice" placeholder="ادخل عدد ملاحظة " required="">
                                <div class="invalid-feedback">
                                    الرجاء ادخال  ملاحظة لعملية التوريد
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="col-xl-6">
                        <div class="mb-3 row">
                            <label class="col-lg-12 col-form-label" for="validationCustom05">التوريدة الموزع منها
                                <span class="text-danger">*</span>
                            </label>
                            <select id="supplyId" class="form-control form-white" data-placeholder="Choose a color..." name="supplyId" required>
                                <option  disabled="disabled" selected value="">الرجاء اختيار احدى التوريدات</option>
                                <?php $__currentLoopData = $supplies; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $supply): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <?php if($supply->supplier->balance>1): ?>
                                <option value="<?php echo e($supply->id); ?>">
                                    <?php echo e($supply->notice); ?> متبقي <?php echo e($supply->supplier->balance); ?>

                                </option>
                                <?php endif; ?>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                            <div class="invalid-feedback">
                                يرجاء اختيار احد التوريدات
                            </div>
                        </div>
                        <div class="mb-3 row">
                            <label class="col-lg-12 col-form-label" for="validationCustom06">الكمية
                                <span class="text-danger">*</span>
                            </label>
                            <div class="col-lg-12">
                                <input name="quantity" type="number" class="form-control" id="quantity" placeholder="ادخل الكمية.." required="">
                                <div class="invalid-feedback">
                                    يرجاء ادخل الكمية بشكل صحيح
                                </div>
                            </div>
                        </div>
                        </div>
                    </div>
              <div class="col-12 text-center">
                <button type="submit" class="btn btn-primary me-sm-3 me-1">تعديل</button>
                <button type="reset" class="btn btn-label-secondary" data-bs-dismiss="modal" aria-label="Close">الغاء</button>
              </div>
              <input type="hidden" id="id" name="id">
            </form>
            </div>
            </div>
        </div>
    </div>
</div>


<div class="modal fade" id="toggleModal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="modalEdit" aria-hidden="true">
    <div class="modal-dialog modal-lg modal-simple modal-add-new-address">
    <div class="modal-content">
        <div class="modal-body">
            <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            <div class="text-center mb-4">
            <h3 class="address-title"> ايقاف هذه التوزيعة</h3>
            <p class="address-subtitle text-danger">هل انت متأكد من ايقاف هذه التوزيعة</p>
            </div>
            <form id="addNewAddressForm" method="GET" action="<?php echo e(route('toggle_distribution')); ?>" class="row g-3 fv-plugins-bootstrap5 fv-plugins-framework needs-validation" novalidate="">
                <?php echo csrf_field(); ?>
            <input type="hidden" name="id" id="id_toggle">
            <div class="col-12 text-center">
                <button type="submit" class="btn btn-danger me-sm-3 me-1 ">نعم</button>
                <button type="reset" class="btn btn-label-secondary" data-bs-dismiss="modal" aria-label="Close">الغاء</button>
            </div>
            </form>
        </div>
    </div>
    </div>
</div>





<?php $__env->startSection('script'); ?>
<script>
//edit clint
const edit =document.querySelectorAll('.edit');
document.querySelectorAll('.edit').forEach(item => {
        item.addEventListener('click', e => {
        document.getElementById("id").value =item.dataset.id;
        document.getElementById("notice").value =item.dataset.notice;
        document.getElementById("quantity").value =item.dataset.quantity;
        const selectClint = document.querySelector("#clintName");
        const selectSupply = document.querySelector("#supplyId");
        for(var i=0; i < selectClint.options.length; i++)
        {
                if(selectClint.options[i].text === item.dataset.name)
                {
                    selectClint.selectedIndex = i;
                    break;
                }
        }

        for(var i=0; i < selectSupply.options.length; i++)
        {
                if(selectSupply.options[i].text === item.dataset.name)
                {
                    selectSupply.selectedIndex = i;
                    break;
                }
        }

        $('#editModal').modal('show');
    })
})

//toggle clint
const toggle =document.querySelectorAll('.toggle');
document.querySelectorAll('.toggle').forEach(item => {
        item.addEventListener('click', e => {
        console.log(item.dataset.id);
        const id = item.dataset.id;
        document.getElementById("id_toggle").value =item.dataset.id;
        $('#toggleModal').modal('show');
    })
})

$(document).ready(function () {
    $('table.display').DataTable();
});
</script>
<?php /**PATH C:\Users\Nasser\Desktop\petrol_store\resources\views/supply/modalsClint.blade.php ENDPATH**/ ?>