


<!-- Modal ADD BOOKING -->
<div class="modal fade" id="md_make_installment" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg cls-xl-lg" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Make Installment Plan</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true"></span>
        </button>
      </div>
      <div class="modal-body">

        <div class="row">
<div class="col-sm-12">
               <center> <strong style="color: red; text-align: center;">The payment plan start date must be  after or equal to booking approve date (<?php echo e(EF::dateFormat($booking->approve_date)); ?>)</strong></center>
          </div>

                 <?php if($all_installment == 0): ?>
             <div class="alert alert-primary card-alert mb-0 col-md-12 cls-banner-width" style = "font-weight: bold;">
              <div class="row">
                <div class = "col-md-4">
                </div>
           
                         <div class="col-md-8">
                     
                     <label class="radio-inline cls-radio"><input type="radio" value="0"  onClick="chooseOneTime(event,this)" name="choose_plan" autocomplete="off" > One Time Payment</label>
                    
                    <label  class="radio-inline cls-radio"><input type="radio" onClick="chooseOneTime(event,this)" value="1" autocomplete="off" name="choose_plan"> Installment</label>
                          </div>
                        </div>
                        </div>
                         <?php endif; ?>
          


          <div class="col-lg-12" id="onetimediv"  style="display: none;">
            <br>
        <?php echo e(Form::open(array('route' => 'onetime.store','id' => 'form_add_onetime', 'class' => 'cls_from'))); ?>


          <table class="table table-hover cls-installment-border" >
          <thead>
            <tr style ="background-color:#dae5f5;">
              <th class = "table-color">#</th>
              <th class = "table-color">Description</th>
              <th class = "table-color">Type of Payment</th>
              <th class = "table-color">%</th>
              <th class = "table-color">Amount</th>
              <th class = "table-color">Due Date</th>
              <th class = "table-color">Action</th>
            </tr>
          </thead>
          <tbody id="onetime_table">
            <tr>
              <th scope="row">1</th>

              <td>
                <div>
           
                <input  class="cls-one-time-description form-control form-control-sm cls_alpha_numeric_space" placeholder="Description"  value="One Time Payment" readonly="true" type="text" name="description[]"/>
                   <small class="form-errors pull-right req" value="*"><?php echo e($errors->first('description[]',":message")); ?></small>
              </div>
              </td>
              <td>
                <div>
              <?php ($type_list = ['One Time'=>'One Time ']); ?>

              

             <?php echo e(Form::select('payment_type[]', $type_list, 'One Time' , array('class' => 'select-style form-control form-control-sm  cls_selection','onChange' => 'getUserList(event,this)'))); ?>

                <small class="form-errors pull-right req" value="*"><?php echo e($errors->first('payment_type[]',":message")); ?></small>
           </div>
              </td>
                <td><input class=" cls_decimal_digit cls-one-time-percentage form-control form-control-sm"  readonly="true" value="100" type="text" id="percentage" name="percentage[]"/></td>
              <td><input class="cls-one-time-amount form-control form-control-sm cls_decimal_digit"  readonly="true" value="<?php echo e($remaining_plan_amount); ?>" type="text" id="amount" name="amount[]"/></td>
              <td>
                <div>
                <input type="date" name= "date[]"class="cls-one-time-duedate form-control form-control-sm cls_date"/>
                 <small class="form-errors pull-right req" value="*"><?php echo e($errors->first('payment_type[]',":message")); ?></small>

              </div>
              </td>
              <td><button class=" btn-success btn-sm" onclick="addRowOnetime(event,'#onetime_table')"><i class="fa fa-plus"></i></button> 

                <input type="hidden" name="booking_id" value ="<?php echo e(Crypt::encrypt($booking->id)); ?>" />
             
              </td>
            </tr>    
          </tbody>

          <tfoot>
            <tr>
              <td colspan="6"></td>
              <input type="hidden" name="plan_type" value='One Time'>
              <input type="hidden" name="installment_mode" value='One Time'>
              <td><button type="submit" class="form-control btn-primary" content="one time plan" onclick="storeOneTimePlan(event,this);">Submit</button></td>
            </tr>
          </tfoot>

        </table>
        <?php echo e(Form::close()); ?>


         </div>



          <div class="col-md-12" id="installmentdiv"  <?php if($booking->agreed_amount == $remaining_plan_amount): ?> style="display: none;" <?php endif; ?> >
        <?php echo e(Form::open(array('route' => 'installment.store','id' => 'form_add_installment', 'class' => 'cls_from'))); ?>


            <br>
            <div class = "row">
              <div class = "col-md-12">
                    <button class="btn btn-danger pull-right cls-button-margin" onclick = "clearInstallmentPlan(event,'#installment_table')">Clear Plan </button>
                <button class="btn btn-primary pull-right cls-button-margin" onclick="clickAutomateButton(event)" >Automate Plan</button>
                 <button class="btn btn-primary pull-right " onclick="addRow_Installment(event,'#installment_table')"  >Add Payment </button>
              
              </div>
            </div>
            <br>
              <table class="table table-hover cls-installment-border" >
          <thead>
            <tr style ="background-color:#dae5f5; " >
              <th class = "table-color">#</th>
              <th class = "table-color">Description</th>
              <th class = "table-color" style="width: 20%;">Payment Type</th>
              <th class = "table-color" style="width: 10%;">%</th>

              <th class = "table-color" style="width: 15%;">Amount</th>
              <th class = "table-color">Due Date (YY/MM/DD)</th>
              <th class = "table-color">Action</th>
            </tr>
          </thead>

          <?php ($key_element = '1'); ?>
          <tbody id="installment_table">
   
            <?php if(@count($installment_amount) == "0"): ?>
            <!-- DOWN PAYMENT -->
            <tr>
              <td>1</td>
              <td><input readonly="" class = "form-control form-control-sm cls_alpha_numeric" placeholder="Description" value="Down Payment" type="text" name="description[]"/></td>
              <td>
                <select readonly class = "form-control form-control-sm cls_selection" name="payment_type[]"><option value = "Down Payment" selected>Down Payment</option>
              </td>

              <td>
                <input onchange="showInstallmentPercentage(event,this,'<?php echo e($key_element); ?>','false');" placeholder="%" value="25" class="plan_percentage_<?php echo e($key_element); ?> form-control form-control-sm cls_decimal_digit" type="text" name="plan_percentage[] "/>
              </td>

              <td>
                <input placeholder="Amount"  value="<?php echo e($lagging_amount * 0.25); ?>" class="installment_planamount new_plan_amount_<?php echo e($key_element); ?> form-control form-control-sm cls_decimal_digit" type="text" name="amount[]" onchange="showInstallmentPercentage(event,this,'<?php echo e($key_element); ?>','true');"/>
              </td>
              <td>
                <input class = "form-control form-control-sm cls_date" type="date" name="date[]"/>
              </td>

              <td><button class="btn-danger btn-sm" onclick="remove_InstallmentRow(event,this)"><i class="fa fa-times"></i></button></td>

            </tr>
            <!-- END -->

            
            <?php (++$key_element); ?>
            <!-- POSSESSION PAYMENT -->
            <tr>
              <td>2</td>
              <td><input readonly="" class = "form-control form-control-sm cls_alpha_numeric" placeholder="Description" value="Possession" type="text" name="description[]"/></td>
              <td>
                <select readonly class = "form-control form-control-sm cls_selection" name="payment_type[]"><option value = "Possession" selected>Possession</option>
              </td>
              <td>
                <input onchange="showInstallmentPercentage(event,this,'<?php echo e($key_element); ?>','false');" placeholder="%" value="" class="plan_percentage_<?php echo e($key_element); ?> form-control form-control-sm cls_decimal_digit" type="text" name="plan_percentage[] "/>
              </td>
              <td>
                <input placeholder="Amount" value="" class="installment_planamount new_plan_amount_<?php echo e($key_element); ?> form-control form-control-sm cls_decimal_digit" onchange="showInstallmentPercentage(event,this,'<?php echo e($key_element); ?>','true');" type="text" name="amount[]"/>
              </td>
              <td>
                <input value="<?php echo e(EF::dateHtml($booking->branch->end_date)); ?>" class = "form-control form-control-sm cls_date" type="date" name="date[]"/>
              </td>

              <td><button class="btn-danger btn-sm" onclick="remove_InstallmentRow(event,this)"><i class="fa fa-times"></i></button></td>

            </tr>
            <!-- END -->
            <?php endif; ?>

      
          </tbody>
          <tfoot>
            <tr>
              <td colspan="6"></td> 
              <input type="hidden" name="plan_type" value="Installment">
              <input type="hidden" class="setvalueonmodechange" name="installment_mode" value="monthly">
                <input type="hidden" name="booking_id" value ="<?php echo e(Crypt::encrypt($booking->id)); ?>" />
              <td><button style="display: none;" id ="btn_installment_plan"  type="submit" class="form-control btn-primary" onclick="storeInsallmentPlan(event,this)" content="Installment plan">Submit</button></td>
            </tr>
          </tfoot>
        </table>
      
              <br>
              </div>
        <?php echo e(Form::close()); ?>



          </div>   
             <div  id="automatediv" style="display: none;" class="cls-installment-border cls-automatediv-padding">

          <div class="row">
          <div class="col-md-12">
                <div class="alert alert-primary card-alert mb-0 col-md-12 cls-banner-width cls-type-styling"> Automate Plan   <i  style = "color: red; float:right;">Remaining Plan Amount: <label id="show_remaining_amount"><?php echo e(EF::numberFormat($lagging_amount)); ?></label> </i> </div>
              
  
          </div>
        </div>
    

      <?php if(($installments_by_type) == 0): ?>
                     <div class="row">
          <div class = "col-md-12">
            <br>
             <input type="checkbox" id="biannual_checkbox" onchange="calculate_InstallmentDivision(event,this);" value=""  > 
        <b> Interval Based </b> 

          </div>
        </div>
        <?php endif; ?>
    
      
                <div class="row" style="padding-top: 2%;">
                
                 <div class="col-md-4">
                  <h6 >Plan Start Date*</h6>
                 <input type="date" name = "date" id="installmentdate" class="form-control form-control-sm  cls_date"/>
                   <small class="form-errors pull-right req" value="*"><?php echo e($errors->first('date',":message")); ?></small>
                 </div>
                <div class="col-md-4">
                   <h6>Monthly / Quarterly / Semi Annually / Annually</h6>
                      <select class="form-control form-control-sm cls_required"  placeholder="Gap between months" id='installmentgap' onChange = "changeInstallmentMode(event,this,'setvalueonmodechange')"  type="text" name="gap" >
                        <option value="1">Monthly</option>
                        <option value="3">Quarterly</option>
                        <option value="6">Bi Annual</option>
                        <option value="12">Annual</option>



                      </select>
                   
                      <small class="form-errors pull-right req" value="*"><?php echo e($errors->first('gap',":message")); ?></small>
                </div>
           
           
            <div class="col-md-4">
                  <h6 >No. of Installments*</h6>
               <input class="form-control form-control-sm cls_required number"  placeholder="No. of Installments" onkeyup= "calculate_InstallmentDivision(event,this)"  type="text" name="number"  id="number"/>
               <small class="form-errors pull-right req" value="*"><?php echo e($errors->first('number',":message")); ?></small>
                </div>
                   </div>
            
         

     <div class = "row annual_plan_section" style = "display:none;">
            
              <div class="col-md-6">
                <br>
                  <h6 >Interval</h6>
               <input class="form-control form-control-sm cls_required"  placeholder="Interval"   type="text" id="interval"  onChange = "intervalReset(event)" />
               <small class="form-errors pull-right req" value=""><?php echo e($errors->first('interval',":message")); ?></small>
                </div>
                 <div class="col-md-6">
                  <br>
                  <h6 >Interval Amount</h6>
               <input class="form-control form-control-sm cls_required"  placeholder="Interval Amount" type="text" name="number" id ="interval_amount" onChange = "intervalReset(event);" onkeyup="calculate_InstallmentDivision(event,this)"   />
               <small class="form-errors pull-right req" value=""><?php echo e($errors->first('amount',":message")); ?></small>
                </div>
              </div>

                <div class = "row">
                <div class="col-md-4">
                  <br>
                    <h6 >Installment Amount*</h6>
                    <input class="form-control form-control-sm cls_required"  placeholder="Installment Amount"  id="installmentamount" type="number" name="installmentamount" onchange="showFinalAmount(event,2);"/>
                      <small class="form-errors pull-right req" value="*"><?php echo e($errors->first('installmentamount',":message")); ?></small>
                </div>
                    <div class="col-md-8">
                        <br>
                          <h6 >Installment Amount In Words</h6>
              <input placeholder="Installment Amount In Words" type="text" readonly="true" class="form-control-sm form-control amount_into_words" >
                  <small class="form-errors pull-right req" value=""></small>
            
          </div>
              </div>

                
          
              <div class = "row ">
                <div class = "col-md-12">
                  <strong style = "color:red;" id ="plan_message"></strong>
                </div>
              </div>
              
              <br>
              <div class="row">
                <div class="col-md-12">
                     
                    <button class="btn btn-primary  pull-right" onclick="create_InstallmentPlan(event,this)" >Create Plan</button>
                </div>
              </div>        
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>

<!-- END MODAL MAKE BOOKING --><?php /**PATH /var/www/skylite/resources/views/installment/modals/make_installment.blade.php ENDPATH**/ ?>