


<?php $__env->startSection('title'); ?>
    اضافة قسيمة

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

<?php $__env->startSection('first-css'); ?>

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

<?php $__env->startSection('header-content'); ?>
اضافة قسيمة
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content-body'); ?>
  <!--**********************************
            Content body start
        ***********************************-->
        
<h1>
    <?php if(session()->has('success')): ?>
        <div data-success="success" class="alert alert-success alert-dismissible bg-success text-white border-0 fade show"
            role="alert">
            <strong id="success" ><?php echo e(session()->get('success')); ?></strong>
        </div>

    <?php elseif(session()->has('error')): ?>

        <div class="alert alert-danger alert-dismissible bg-danger text-white border-0 fade show"
            role="alert">
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
            <strong id="error"><?php echo e(session()->get('error')); ?></strong>
        </div>
    <?php endif; ?>
</h1>
            <!-- row -->
			<div class="row" style="width: 95%; margin:auto;">
				<div class="col-xl-12">
				<div class="card">
							<div class="card-header">
                                <h4 class="card-title">قسيمة جديدة</h4>
                            </div>
							<div class="card-body pb-3 tran">
                                <div class="form-validation">
                                    <form class="validation need-validation" novalidate  method="POST" action="<?php echo e(route('storeCoupon')); ?>">
                                    <?php echo csrf_field(); ?>
                                    <div class="row">
                                            <div class="col-xl-12">
                                                <div class="mb-3 row">
                                                    <label class="col-lg-12 col-form-label  titleInput" for="validationCustom01">اسم العميل<span class="text-danger">*</span>
                                                    </label>
                                                    <div class="col-lg-12">
                                                        <select class="form-control form-white  inputRead" id="informationClintWithAcountType" data-placeholder="Choose a color..." name="clintName" required>
                                                            <option 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>
                                            <select class="form-control form-white  inputRead" hidden id="informationClintType" data-placeholder="Choose a color..." name="" >
                                                <option disabled selected value="">  بيانات حسابات العملاء </option>
                                                <?php $__currentLoopData = $client; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $client): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option value="<?php echo e($niceName); ?>"><?php echo e($client->name); ?> الرصيد <?php echo e($client->balance); ?></option>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            </select>
                                            <div class="invalid-feedback">
                                                يرجاء ادخال اسم العميل
                                            </div>
                                    </div>
                                    <div id="inputs">
                                        <div class="row tr_data border my-3">

                                            <div class="mb-3 col-3">
                                                <label class="col-lg-12 col-form-label titleInput " for="validationCustom05">النوع
                                                    <span class="text-danger">*</span>
                                                </label>
                                                <div class="col-lg-12">
                                                    <select class="form-control form-white type inputRead " onchange="getTotalFromnumberOfCouponAndquantity(1)"  data-placeholder="Choose a color..." name="type[]" required>
                                                        <option disabled selected value="3">الرجاء اختيار  نوع الكمية</option>
                                                        <option value="0">بترول</option>
                                                        <option value="1">ديزيل</option>
                                                    </select>
                                                    <div class="invalid-feedback">
                                                        الرجاء اختار النوع
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="mb-3 col-3">
                                                <label class="col-lg-12 col-form-label titleInput" for="validationCustom02">عدد القسائم<span class="text-danger">*</span>
                                                </label>
                                                <div class="col-lg-12">
                                                    <input name="numberOfCoupons[]" value=""  type="number" onblur="getTotalFromnumberOfCouponAndquantity(1)" class="form-control form-control-sm inputRead numberOfCoupons" id="validationCustom02" placeholder="ادخل عدد القسائم" required="">
                                                    <div class="invalid-feedback">
                                                        الرجاء ادخال  عدد القسائم
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="mb-3 col-3">
                                                <label class="col-lg-12 col-form-label titleInput" for="validationCustom06">الكمية
                                                    <span class="text-danger">*</span>
                                                </label>
                                                <div class="col-lg-12">
                                                    <input name="quantity[]" type="number" value="" onkeyup="getTotalFromnumberOfCouponAndquantity(1)" class="form-control inputRead quantity" id="validationCustom06" placeholder="ادخل الكمية.." required="">
                                                    <div class="invalid-feedback">
                                                        يرجاء ادخل الكمية بشكل صحيح
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="mb-3 col-2">
                                                <label class="col-lg-12 col-form-label titleInput" for="validationCustom06">المجموع
                                                </label>
                                                <div class="col-lg-12">
                                                    <input name="total[]" type="number" value="" disabled class="form-control inputRead total" id="validationCustom06" placeholder="0" required="">
                                                </div>
                                            </div>
                                            <div class="col-1 mb-3" style="direction: ltr;">
                                                
                                            </div>


                                        </div>
                                    </div>

                                    
                                        <div class="row">
                                            <div class="col-xl-6" style="direction: rtl;">
                                                <span id="add" class="btn btn-success ms-2">+</span>
                                                <span class="text-danger" id="massegeError" ></span>
                                            </div>

                                        </div>
                                        <div class="row">
                                            <div class="col-xl-5 mt-3" style="direction: rtl;" id="totalPtrol">

                                            </div>
                                            <div class="col-xl-5 mt-3" style="direction: rtl;"id="totalDisal">
                                                <span  class=" fw-bold" ></span>
                                            </div>
                                            <div class="col-xl-2" style="direction: ltr;">
                                                <button type="button" class="btn btn-primary me-sm-3 me-1 showModal"
                                                data-title="هل انت متأكد من هذه القسائم ؟"
                                                >صرف</button>
                                            </div>
                                        </div>
									</div>
                                    <?php echo $__env->make('print_confirmation.print_confirmation', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

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

				</div>
			</div>



			<!--**********************************
            Content body end
        ***********************************-->
<script src="<?php echo e('/js/add-inputs.js'); ?>"></script>
<script src="<?php echo e('/js/print_confirmation/print_confirmation_coupn.js'); ?>"></script>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('script'); ?>

<script>
    // this show modal if is return validation from backend
    $(window).on('load', function() {
		showModalAdd = document.querySelectorAll(".showModalAdd");
		if(showModalAdd.length > 0)
			$('#addTank').modal('show');

		showModalEdit = document.querySelectorAll(".showModalEdit");
		console.log(showModalEdit.length)
		if(showModalEdit.length > 0)
			$('#editModal').modal('show');
	});

	//edit modal
	const edit =document.querySelectorAll('.edit');
	console.log(edit);
	document.querySelectorAll('.edit').forEach(item => {
			item.addEventListener('click', e => {
				// alert(item.dataset.id)
				document.getElementById("id").value =item.dataset.id;
				document.getElementById("nameSuppliers").value =item.dataset.name;
				document.getElementById("addressSuppliers").value =item.dataset.address;
				document.getElementById("phoneSuppliers").value =item.dataset.phone;
				let type = item.dataset.type;
				const selectType = document.querySelector("#type");

				for(var i=0; i < selectType.options.length; i++)
				{
					console.log(selectType.options[i].value);
					if(selectType.options[i].value === type)
					{
						selectType.selectedIndex = i;
						break;
					}
				}
				$('#editModal').modal('show');
			})
	})

</script>

<script src="<?php echo e('/js/add-inputs.js'); ?>"></script>

<script src="<?php echo e(asset('/vendor/datatables/js/jquery.dataTables.min.js')); ?>"></script>
<script src="<?php echo e(asset('/js/plugins-init/datatables.init.js')); ?>"></script>
<script src="<?php echo e(asset('/js/validation.js')); ?>"></script>

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

<?php echo $__env->make('coupons.inputs', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
<?php echo $__env->make('layouts.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\Users\Nasser\Desktop\petrol_store\resources\views/coupons/store.blade.php ENDPATH**/ ?>