 <?php if(isset($open_buy_bill) && !empty($open_buy_bill)): ?>
<?php $__env->startSection('title', ' فاتورة مشتريات '.$open_buy_bill->buy_bill_number ); ?>
 <?php else: ?>
<?php $__env->startSection('title', ' فاتورة مشتريات '.$pre_bill ); ?>
 <?php endif; ?>

<?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">
                <?php if(isset($open_buy_bill) && !empty($open_buy_bill)): ?>تعديل فاتورة مشتريات <?php else: ?> إضافة فاتورة مشتريات <?php endif; ?>
             </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.buy_bills.index')); ?>">المشتريات</a>
                  </li>
                  <li class="breadcrumb-item active" >               
                    <?php if(isset($open_buy_bill) && !empty($open_buy_bill)): ?>تعديل فاتورة  <?php else: ?> إضافة فاتورة  <?php endif; ?>
                  </li>
                  <li class="breadcrumb-item active" >               
                    <?php if(isset($open_buy_bill) && !empty($open_buy_bill)): ?><?php echo e($open_buy_bill->buy_bill_number); ?><?php else: ?><?php echo e($pre_bill); ?><?php endif; ?>
                  </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.buy_bills.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 class="invoice-add-wrapper" data-select2-id="13">
            <form target="_blank" action="#" method="POST" id="invoice">
                <?php echo csrf_field(); ?>
                <input id="company_id" value="<?php echo e($company_id); ?>" type="hidden">

                <?php if(isset($open_buy_bill) && !empty($open_buy_bill)): ?>
                <input type="hidden" value="<?php echo e($open_buy_bill->id); ?>" id="buy_bill_id">
                <input type="hidden" value="<?php echo e($open_buy_bill->buy_bill_number); ?>" id="buy_bill_number"/>
                <input type="hidden" value="<?php echo e($open_buy_bill->status); ?>" id="status"/>
                
                <?php else: ?>
                <input id="buy_bill_number" value="<?php echo e($pre_bill); ?>" type="hidden">
                <input type="hidden" value="open" id="status"/>

                <?php endif; ?>

            <div class="row invoice-add">
              <!-- Invoice Add Left starts -->
              <div class="col-xl-9 col-md-8 col-12" data-select2-id="12">
                <div class="card invoice-preview-card" data-select2-id="11">
                  <!-- Header starts -->
                  <div class="card-body invoice-padding pb-0 row">
                    
                    <div class="col-xl-3 col-md-3 col-12" >
                        <div class="mb-1" align="center">
                          <b  class="form-label" for="client_name" >اسم المورد</b>
          
                          <select  name="supplier_id" id="supplier_id" class="search select2-selection__placeholder" <?php if(!empty($buy_bill_cash)||!empty($buy_bill_bank_cash)): ?> disabled <?php endif; ?>>
                      <option value="">إختر المورد</option>
                      <?php $__currentLoopData = $suppliers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $supplier): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                          <option
                              <?php if(isset($open_buy_bill) && !empty($open_buy_bill) && $supplier->id == $open_buy_bill->supplier_id): ?>
                              selected value="<?php echo e($open_buy_bill->supplier_id); ?>"
                              <?php else: ?>
                              value="<?php echo e($supplier->id); ?>"
                              <?php endif; ?>
                          ><?php echo e($supplier->supplier_name); ?></option>
                      <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                  </select>
                        </div>
                     </div>

                     <div class="col-xl-3 col-md-3 col-12" >
                        <div class="mb-1" align="center">
                          <b class="form-label" for="date" >تاريخ الفاتورة</b>
                          <input type="date"  name="date"
                                 <?php if(isset($open_buy_bill) && !empty($open_buy_bill)): ?>
                                 value="<?php echo e($open_buy_bill->date); ?>"
                                 <?php else: ?>
                                 value="<?php echo date("Y-m-d"); ?>"
                                 <?php endif; ?>
                                 id="date"
                                 class="form-control"/>
                      </div>
                        </div>

                        <div class="col-xl-3 col-md-3 col-12" >
                            <div class="mb-1" align="center">
                              <b class="form-label" for="time" >وقت الفاتورة</b>
                              <input type="time"  name="time"
                                     <?php if(isset($open_buy_bill) && !empty($open_buy_bill)): ?>
                                     value="<?php echo e($open_buy_bill->time); ?>"
                                     <?php else: ?>
                                     value="<?php echo date("H:i:s"); ?>"
                                     <?php endif; ?>
                                     id="time"
                                     class="form-control"/>
                          </div>
                            </div>

                            <div class="col-xl-3 col-md-3 col-12" >
                                <div class="mb-1" align="center">
                                  <b class="form-label" for="time" >اختر المخزن </b>
                                  <select name="store_id" id="store_id" class="search select2-selection__placeholder"
                                          title="اختر المخزن">
                                      <?php $i = 0; ?>
                                      <?php $__currentLoopData = $stores; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $store): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                          <?php if($stores->count() == 1): ?>
                                              <option selected value="<?php echo e($store->id); ?>"><?php echo e($store->store_name); ?></option>
                                          <?php else: ?>
                                              <?php if($i ==  0): ?>
                                                  <option selected value="<?php echo e($store->id); ?>"><?php echo e($store->store_name); ?></option>
                                              <?php else: ?>
                                                  <option value="<?php echo e($store->id); ?>"><?php echo e($store->store_name); ?></option>
                                              <?php endif; ?>
                                          <?php endif; ?>
                                          <?php $i++; ?>
                                      <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                  </select>
                                  
                              </div>
                                </div>
                                <div class=" supplier_details no-print row"
                                <?php if(!isset($open_buy_bill) || empty($open_buy_bill) || empty($open_buy_bill->buy_bill_number)): ?>
                                style="display: none !important;"
                               <?php endif; ?>>
                               <div class="col-xl-3 col-md-3 col-12" >
                                <label class="form-label"> الفئة </label>
                                   <input type="text" class="form-control"
                                          <?php if(isset($open_buy_bill) && !empty($open_buy_bill) && !empty($open_buy_bill->buy_bill_number)): ?>
                                          value="<?php echo e($open_buy_bill->supplier->supplier_category); ?>"
                                          <?php endif; ?>
                                          readonly id="category"/>
                               </div>
                               <div class="col-xl-3 col-md-3 col-12" >
                                   <label class="form-label">المديونية   </label>
                                   <input type="text"
                                          <?php if(isset($open_buy_bill) && !empty($open_buy_bill) && !empty($open_buy_bill->buy_bill_number)): ?>
                                          value="<?php if($open_buy_bill->supplier->prev_balance>0): ?>لة <?php else: ?> علية <?php endif; ?><?php echo e(abs($open_buy_bill->supplier->prev_balance)); ?>"
                                          <?php endif; ?>
                                          class="form-control" readonly id="balance_before"/>
                               </div>
                               <div class="col-xl-3 col-md-3 col-12" >
                                   <label class="form-label">جنسية العميل</label>
                                   <input type="text" class="form-control"
                                          <?php if(isset($open_buy_bill) && !empty($open_buy_bill) && !empty($open_buy_bill->buy_bill_number)): ?>
                                          value="<?php echo e($open_buy_bill->supplier->supplier_national); ?>"
                                          <?php endif; ?>
                                          readonly id="supplier_national"/>
                               </div>
                               <div class="col-xl-3 col-md-3 col-12" >
                                <div class="form-group" dir="rtl">
                                       <label class="form-label">ملاحظات  </label>
                                       <input type="text" name="notes"
                                              <?php if(isset($open_buy_bill) && !empty($open_buy_bill)): ?>
                                              value="<?php echo e($open_buy_bill->notes); ?>"
                                              <?php endif; ?> id="notes"
                                              class="form-control"/>
                                   </div>
                               </div>
                               <div class="clearfix"></div>
                           </div>

                     </div>
                            
                  <!-- Header ends -->
          
                  <hr class="invoice-spacing">
                  <div class="card-body invoice-padding pb-0 row">

                    <div class="col-xl-3 col-md-3 col-12" >
                        <div class="mb-1" align="center">
                          <b  class="form-label" for="product_id" > كود المنتج او الاسم </b>

                        <select name="product_id" id="product_id" class="search select2-selection__placeholder">
                            <option value="">اختر المنتج</option>
                              <?php $__currentLoopData = $all_products; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $product): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                              <option data-name="<?php echo e($product->product_name); ?>"  value="<?php echo e($product->id); ?>"><?php echo e($product->product_name); ?> <?php if(!empty($product->code_universal)): ?>- <?php echo e($product->code_universal); ?> <?php endif; ?> </option>
                              <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                          </select>
                <div class="available text-center" style="color: #000; font-size: 14px; margin-top: 10px;"></div>
                        </div>
                     </div>

                     <div class="col-xl-3 col-md-3 col-12" >
                        <div class="mb-2" align="center" >
                            <b class="form-label" for="price" >السعر  </b>
                          <input type="text" name="product_price" value="0" id="product_price" class="form-control"/>
                      </div>
                      
                        </div>

                        <div class="col-xl-3 col-md-3 col-12" >
                            <div class="mb-1 row" align="center">
                              <b class="form-label" for="time" >الكمية</b>
                              <input style="width: 50%;" type="number" name="quantity" id="quantity" min="1" value="1" class="form-control "/>
                       <select style="width: 50%;" class="form-control" name="unit_id" id="unit_id">
                           <option value="">اختر الوحدة</option>
                           <?php $__currentLoopData = $units; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $unit): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                               <option data-name="<?php echo e($unit->unit_name); ?>" value="<?php echo e($unit->id); ?>"><?php echo e($unit->unit_name); ?></option>
                           <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                       </select>
                       <input type="hidden" value="0" id="product_unit_quantity" >
                          </div>
                            </div>

                            <div class="col-xl-2 col-md-2 col-12" >
                                <div class="mb-1" align="center">
                                  <b class="form-label" for="quantity_price"> الاجمالى</b>
                    <input readonly type="text" name="quantity_price" id="quantity_price" class="form-control"/>
                              </div>
                                </div>
                                <div class="col-xl-1 col-md-1 col-12" >
                                    <div class="mb-1 row" align="center">
                                      <b class="form-label" for="time" >م</b>
                                      <button type="button" id="addRow" class="btn btn-success"><i data-feather='plus'></i></button>
                                  </div>
                                    </div>

                            </div>

                  <hr class="invoice-spacing">

                  
                  <div class="card-body  bill_details" id="productsTable">
                    <?php $c=0 ?>  
                    <?php if($open_buy_bill): ?>       
                    <?php $__currentLoopData = $open_buy_bill->elements; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $element): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?> 

                    <div class="mb-3 invItem" data-repeater-list="group-a" id="row-<?php echo e(++$c); ?>">
                      <div class="repeater-wrapper pt-0 pt-md-4" data-repeater-item="">
                        <div class="d-flex border rounded position-relative pe-0">
                          <div class="row w-100 p-3">

                            <div class="col-md-2 col-12 mb-md-0 mb-3">
                              <p class="mb-2 repeater-title">المنتج</p>
                              <div id="productName_<?php echo e($c); ?>"><?php echo e($element->product->product_name); ?></div><input type="hidden" name="product[]" id="product_<?php echo e($c); ?>"  value="<?php echo e($element->product_id); ?>"  class="form-control product"  autocomplete="off" required>
                            </div>

                            <div class="col-md-2 col-12 mb-md-0 mb-3">
                              <p class="mb-2 repeater-title">الكمية</p>
                              <input class="form-control quantity" type="number" value="<?php echo e($element->quantity); ?>"  name="quantity[]"  id="quantity_<?php echo e($c); ?>" product="<?php echo e($element->product_id); ?>" min="0" step="any">
                            </div>

                            <div class="col-md-2 col-12 mb-md-0 mb-3">
                              <p class="mb-2 repeater-title">الوحدة</p>
                              <?php echo e($element->unit->unit_name); ?><input type="hidden" name="unit[]" id="unit_<?php echo e($c); ?>"  value="<?php echo e($element->unit_id); ?>"  class="form-control unit"  autocomplete="off" required>
                              <input type="hidden" name="product_unit_quantity[]" id="product_unit_quantity_<?php echo e($c); ?>"  value="<?php echo e($element->elements_unit->quantity); ?>"  class="form-control unit"  autocomplete="off" required>
                            </div>

                            <div class="col-md-3 col-12 mb-md-0 mb-3">
                              <p class="mb-2 repeater-title">السعر</p>
                              <input class="form-control" type="number" step="any" value="<?php echo e($element->product_price); ?>" name="price[]" id="price_<?php echo e($c); ?>" product="<?php echo e($element->product_id); ?>" min="0" step="any">
                            </div>



                            <div class="col-md-3 col-12 mb-md-0 mb-3">
                              <p class="mb-2 repeater-title">الإجمالي</p>
                              <input type="text" name="total[]" id="total_<?php echo e($c); ?>" class="form-control total" id="total_<?php echo e($c); ?>" value="<?php echo e($element->quantity_price); ?>" readonly required>
                            </div>

                        </div>

                        <div class="d-flex flex-column align-items-center justify-content-between border-start p-2">
                          <a class="delete" id="removeRows" data-unit="<?php echo e($element->unit_id); ?>" data-div="<?php echo e($c); ?>" data-product="<?php echo e($element->product_id); ?>" data-invoice="<?php echo e($open_buy_bill->buy_bill_number); ?>"><i class="la la-trash" style="font-size:20px;color:red" ></i></a>
                        </div>
                      </div>
                    </div>
                  </div>

                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    <input id="elementCout" type="hidden" value="<?php echo e($open_buy_bill->elements->count()); ?>">
                    <?php endif; ?>
                  
                  </div>
          
         
          
                  <hr class="invoice-spacing mt-0" >
                  <div class="card-body invoice-padding-extra" <?php if(empty($element)): ?> style="display:none" <?php endif; ?> >
                    <div class="row invoice-sales-total-wrapper">
                      <div class="col-md-6 order-md-1 order-2 mt-md-0 mt-3">
                        <div class="d-flex align-items-center mb-1">
                          <b for="extra_type" class="form-label">&nbsp;  الشحن  &nbsp;</b> 
                          <select name="extra_type" id="extra_type" class="form-control"
                                  style="width: 30%;display: inline;float: right;margin-left: 5px">
                              <option <?php if(!empty($open_buy_bill) && !empty($open_buy_bill->extra->action_type) && $open_buy_bill->extra->action_type =='pound' ): ?> selected <?php endif; ?> value="pound"><?php echo e($extra_settings->currency); ?></option>
                              <option  <?php if(!empty($open_buy_bill) && !empty($open_buy_bill->extra->action_type) && $open_buy_bill->extra->action_type =='percent' ): ?> selected <?php endif; ?> value="percent">نسبة مئوية</option>
                          </select>
                          <input type="number" name="extra_value"min="1"
                                 style="width: 50%;display: inline;float: right;"
                                 id="extra_value" class="form-control" placeholder=" قيمة أو نسبة الشحن "  <?php if(!empty($open_buy_bill->extra)): ?> value="<?php echo e($open_buy_bill->extra->value); ?>" <?php endif; ?>/>
                 </div> 
                        <div class="d-flex align-items-center mb-1">
                            <b for="discount_type" class="form-label">&nbsp;  الخصم  &nbsp;</b> 
                            <select name="discount_type" id="discount_type" class="form-control"
                            style="width: 30%;display: inline;float: right;margin-left: 5px">
                        <option <?php if(!empty($open_buy_bill) && !empty($open_buy_bill->discount->action_type) && $open_buy_bill->discount->action_type =='pound' ): ?> selected <?php endif; ?> value="pound"><?php echo e($extra_settings->currency); ?></option>
                        <option <?php if(!empty($open_buy_bill) && !empty($open_buy_bill->discount->action_type) && $open_buy_bill->discount->action_type =='percent' ): ?> selected <?php endif; ?> value="percent">نسبة مئوية</option>
                    </select>
                    <input  type="number" name="discount_value"min="1"  <?php if(!empty($open_buy_bill) && !empty($open_buy_bill->discount)): ?> value="<?php echo e($open_buy_bill->discount->value); ?>" <?php endif; ?>
                           style="width: 50%;display: inline;float: right;"
                           id="discount_value" class="form-control" placeholder=" قيمة أو نسبة الخصم "/>
                          </div>
                      </div>
                      <div class="col-md-6 d-flex justify-content-end order-md-2 order-1">
                        <div class="invoice-total-wrapper">
                          <div class="d-flex justify-content-between mb-2">
                            <p class="w-px-100">الإجمالي : </p>
                            <p class="fw-medium"><div id="subtotal">0</div></p>
                          </div>
                          <div class="d-flex justify-content-between mb-2">
                            <p class="w-px-100"> الشحن : </p>
                            <p class="fw-medium"><?php if(!empty($open_buy_bill->extra)): ?><div id="extra"><?php echo e($open_buy_bill->extra->value); ?></div> <div id="exType"><?php if($open_buy_bill->extra->action_type =='pound'): ?> <?php echo e($extra_settings->currency); ?> <?php else: ?> % <?php endif; ?></div><?php else: ?> <div id="extra">0</div><div id="exType"></div><?php endif; ?></p>
                          </div>
                          <div class="d-flex justify-content-between mb-2">
                            <p class="w-px-100"> الخصم :</p>
                            <p class="fw-medium"><?php if(!empty($open_buy_bill->discount)): ?> <div id="discount"><?php echo e($open_buy_bill->discount->value); ?></div> <div id="disType"><?php if($open_buy_bill->discount->action_type =='pound'): ?> <?php echo e($extra_settings->currency); ?>  <?php else: ?> % <?php endif; ?> </div><?php else: ?> <div id="discount">0</div><div id="disType"></div><?php endif; ?> </p>
                          </div>

                          <hr class="my-50">
                          <div class="d-flex justify-content-between mb-2">
                            <p class="w-px-100"> إجمالي الفاتورة :</p>
                            <p class="fw-medium"><div id="finalTotal"></div></p>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                 
                </div>
              </div>
              <!-- Invoice Add Left ends -->
          
              <!-- Invoice Add Right starts -->
              <div class="col-xl-3 col-md-4 col-12">
                <div class="card">
                  <div class="card-body">
                    <button class="btn btn-primary w-100 mb-75 waves-effect waves-float waves-light submit" id="saveAllWithOutPrint" type="submit"
                     <?php if(!isset($open_buy_bill) || empty($element) || empty($open_buy_bill)): ?> disabled <?php endif; ?>>
                        <?php if(isset($open_buy_bill) && !empty($open_buy_bill) && $open_buy_bill->status == 'done'): ?>
                        تحديث <i class="la la-check"></i>
                        <?php else: ?>
                        حفظ 
                        <?php endif; ?>
                        
                    </button>


                    <button class="btn btn-success w-100 mb-75 waves-effect waves-float waves-light submit" id="saveAll" type="submit"
                     <?php if(!isset($open_buy_bill) || empty($element) || empty($open_buy_bill)): ?> disabled <?php endif; ?>>
                        <?php if(isset($open_buy_bill) && !empty($open_buy_bill) && $open_buy_bill->status == 'done'): ?>
                        تحديث و طباعة
                        <?php else: ?>
                        حفظ و طباعة
                        <?php endif; ?>
                        
                    </button>
                 </form>
                    
                        <?php if(isset($open_buy_bill) && !empty($open_buy_bill)): ?>
                            <input type="hidden" value="<?php echo e($open_buy_bill->buy_bill_number); ?>" name="buy_bill_number"/>
                        <?php else: ?>
                            <input type="hidden" value="<?php echo e($pre_bill); ?>" name="buy_bill_number"/>
                        <?php endif; ?>
                        <?php if(isset($open_buy_bill) && !empty($open_buy_bill) && $open_buy_bill->status == 'done'): ?>
                           <a href="<?php echo e(route('client.buy_bills.print',$open_buy_bill->buy_bill_number)); ?>"> <button class="btn btn-primary w-100 mb-75 waves-effect waves-float waves-light" id="viewInvoice" type="button">
                                عرض <i data-feather="eye"></i>
                            </button></a>
                            <button class="btn btn-outline-danger w-100 mb-75 waves-effect " onclick="window.history.back()"> رجوع  <i class="la la-arrow-left"></i></button>
                        <?php else: ?>
                        <form  method="post" action="<?php echo e(route('client.buy_bills.cancel')); ?>">
                            <?php echo csrf_field(); ?>
                         <?php if(isset($open_buy_bill) && !empty($open_buy_bill)): ?>
                            <input type="hidden" value="<?php echo e($open_buy_bill->buy_bill_number); ?>" name="buy_bill_number"/>
                        <?php else: ?>
                            <input type="hidden" value="<?php echo e($pre_bill); ?>" name="buy_bill_number"/>
                        <?php endif; ?>                
                        <button  type="submit" id="cancel" <?php if(!isset($open_buy_bill) || empty($open_buy_bill)): ?> disabled <?php endif; ?>
                        
                        class="btn btn-outline-danger w-100 mb-75 waves-effect ">
                        إلغاء الفاتورة
                        <i class="la la-arrow-left"></i>
                        </button>
                        
                    </form> 
                    <?php endif; ?>                 
                </div>
                </div>
                <form method="POST" id="payForm" action="#">
                    <?php echo csrf_field(); ?>

                <div class="mt-2" >
                  <p class="mb-50">طريقة الدفع</p>
                  <select  id="payment_method" name="payment_method" class="form-select" <?php if(empty($open_buy_bill) ): ?> disabled <?php endif; ?>   >
                    <option value="">اختر طريقة الدفع</option>
                    <option value="cash">دفع كاش نقدى</option>
                    <?php if(count($banks) > 0): ?>
                        <option value="bank">دفع بنكى شبكة</option>
                    <?php endif; ?>    
                </select>
                </div>



                <div id="payCash" style="display: none">
                    <div class="mt-2" id="safes" style="display: none" <?php if(true): echo 'disabled'; endif; ?>>
                        <p class="mb-50">إختر خزنة الدفع</p>
                        <select  id="safe_id"class="form-select">
                        <option value="">اختر خزنة الدفع</option>
                        <?php $__currentLoopData = $safes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $safe): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                         <option value="<?php echo e($safe->id); ?>" <?php if($safe->safe_name=="الخزنة الرئيسية"): ?> selected  <?php endif; ?> ><?php echo e($safe->safe_name); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                      </div>

                      <div class="mt-2">
                        <input  readonly value="<?php echo e($pre_cash); ?>" class="form-control" name="cash_number"  id="cash_number" type="hidden">
                        <p class="mb-50">المبلغ المدفوع</p>
                        <input  class="form-control"
                        id="payAmountCash" name="amount" type="text">
                      </div>


                </div>
                
                <div id="payBank" style="display: none">
                    <div class="mt-2" id="banks" style="display: none">
                        <p class="mb-50">إختر البنك </p>
                        <select  id="bank_id"class="form-select">
                        <option value="">اختر البنك  </option>
                        <?php $__currentLoopData = $banks; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $bank): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option
                            value="<?php echo e($bank->id); ?>"><?php echo e($bank->bank_name); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                      </div>
                      <div class="mt-2">
                        <input required readonly value="<?php echo e($pre_cash); ?>" class="form-control" name="cash_number"  id="cash_number" type="hidden">
                        <p class="mb-50">المبلغ المدفوع</p>
                        <input  class="form-control"
                        id="payAmountBank" name="amount" type="text">
                      </div>
                      <div class="mt-2">
                        <p class="mb-50">رقم المعاملة</p>
                        <input type="text" class="form-control" id="bank_check_number"/>
                        </div>
                        <div class="mt-2">
                        <p class="mb-50">ملاحظات</p>
                        <input type="text" class="form-control" id="bank_notes"/>
                      </div>

      
                    </div>

                 <div class="mt-2" align="center">

                    <button  type="submit" id="submitPay" style="display: none" class="btn btn-outline-primary w-50 mb-50 waves-effect "><i class="fa fa-check"></i>تسجيل الدفع</button>

                  </div>
                <div class="mt-2" id="cashPaied" <?php if(empty($buy_bill_bank_cash) && empty($buy_bill_cash)): ?> style="display:none;"<?php endif; ?> >
                <center>
                    <p class="mb-50">سجل دفعات الفاتورة</p>
            <hr class="invoice-spacing">
            <?php if(isset($open_buy_bill) && !empty($open_buy_bill)): ?>
                    <?php if(!empty($buy_bill_cash)): ?>
                    <div class="opreation" id="<?php echo e($buy_bill_cash->id); ?>">
                        <td> <?php echo e($buy_bill_cash->amount); ?> </td>
                        <td> ( <?php echo e($buy_bill_cash->safe->safe_name); ?> )</td>
                        <td> <button type="button" payment_method="cash" id="deleteCash" cash_id="<?php echo e($buy_bill_cash->id); ?>" class="btn delete_pay"><i style="font-size:20px ; color:red " class="la la-trash"></i></button> </td>
                    </div>
                    <?php endif; ?>
                <?php if(!empty($buy_bill_bank_cash)): ?>
                <div class="opreation" id="<?php echo e($buy_bill_bank_cash->id); ?>">
                    <td> <?php echo e($buy_bill_bank_cash->amount); ?> </td>
                    <td> ( <?php echo e($buy_bill_bank_cash->bank->bank_name); ?> )</td>
                    <td> <button type="button" payment_method="bank" id="deleteCash" cash_id="<?php echo e($buy_bill_bank_cash->id); ?>" class="btn delete_pay"><i style="font-size:20px ; color:red " class="la la-trash"></i></button> </td>
                </div>
            <?php endif; ?>
                <?php endif; ?>
            <div id="pay" style="display:none">
            </div>
            <hr class="invoice-spacing">
                </center>
                </div>
                 

                </form>
              </div>
              <!-- Invoice Add Right ends -->
            </div>
          </section>
      </div>
    </div>
 </div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('script'); ?>
<script src="<?php echo e(asset('app-assets/js/select2.min.js')); ?>"></script>
<script src="<?php echo e(asset('app-assets/js/pages/buy.js')); ?>"></script>
<script>
    
        $('.search').select2();

</script>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('style'); ?>
<link href="<?php echo e(asset('app-assets/css/app-invoice.css')); ?>" rel="stylesheet" />
<?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/buy_bills/create.blade.php ENDPATH**/ ?>