<?php $__env->startSection('content'); ?>
    <div class="card card-outline-info">
        <div class="card-header">
            <h4 class="m-b-0 text-white">Create Payment</h4>
        </div>
    <div class="card-body">
    <?php if($deal->due_amount>0): ?>
    <?php echo Form::open(['method' => 'POST','id'=> 'register_frm', 'data-parsley-validate'=>'', 'url' => [url('/admin/payments/addpayments/').'/'.$deal->id]]); ?>

        <div class="form-body control-group">
            <h3 class="card-title">Select Method</h3>
            <div class="row">
              <div class="col-md-3">
                  <div class="form-group">
                      <label class="control-label" for="payment_type">Payment Mode*</label>
                      <?php echo Form::select('payment_type', $payment_methods, [], ['class' => 'form-control form-control-normal', 'id'=>'payment_type']); ?>

                      <?php if($errors->has('payment_type')): ?>
                          <p class="help-block error alert">
                            <?php echo e($errors->first('payment_type')); ?>

                          </p>
                      <?php endif; ?>
                  </div>
              </div>
              <div class="col-md-3">
                  <div class="form-group">
                      <label class="control-label" for="amount">Amount*</label>
                      <input type="text" id="amount" name="amount" required="required" class="form-control" value="">
                        <?php if($errors->has('amount')): ?>
                          <p class="help-block">
                              <strong><?php echo e($errors->first('amount')); ?></strong>
                          </p>
                        <?php endif; ?>
                  </div>
              </div>
              <div class="col-md-3 payOpt">
                  <div class="form-group">
                      <label class="control-label" for="bank_name">Bank Name*</label>
                      <input type="text" id="bank_name" name="bank_name" required="required" class="form-control" value="">
                        <?php if($errors->has('bank_name')): ?>
                          <p class="help-block">
                              <strong><?php echo e($errors->first('bank_name')); ?></strong>
                          </p>
                        <?php endif; ?>
                  </div>
              </div>
              <div class="col-md-3 payOpt">
                  <div class="form-group">
                      <label class="control-label" for="bank_branch">Branch Address*</label>
                      <input type="text" id="bank_branch" name="bank_branch" required="required" class="form-control" value="">
                        <?php if($errors->has('bank_branch')): ?>
                          <p class="help-block">
                              <strong><?php echo e($errors->first('bank_branch')); ?></strong>
                          </p>
                        <?php endif; ?>
                  </div>
              </div>
              <div class="col-md-3 payOpt">
                  <div class="form-group">
                      <label class="control-label" for="payment_reference">Cheque/DD/UTR/TXN No.*</label>
                      <input type="text" id="payment_reference" name="payment_reference" required="required" class="form-control" value="">
                        <?php if($errors->has('payment_reference')): ?>
                          <p class="help-block">
                              <strong><?php echo e($errors->first('payment_reference')); ?></strong>
                          </p>
                        <?php endif; ?>
                  </div>
              </div>
              <div class="col-md-3 payOpt">
                  <div class="form-group">
                      <label class="control-label" for="payment_date">Cheque/DD/NEFT/RTGS Date*</label>
                      <input type="text" id="payment_date" name="payment_date" required="required" class="form-control mydatepicker" value="">
                        <?php if($errors->has('payment_date')): ?>
                          <p class="help-block">
                              <strong><?php echo e($errors->first('payment_date')); ?></strong>
                          </p>
                        <?php endif; ?>
                  </div>
              </div>
              <div class="col-md-3">
                  <div class="form-group">
                      <label class="control-label" for="comment">Remarks</label>
                      <input type="text" id="comment" name="comment" class="form-control" value="">
                        <?php if($errors->has('comment')): ?>
                          <p class="help-block">
                              <strong><?php echo e($errors->first('comment')); ?></strong>
                          </p>
                        <?php endif; ?>
                  </div>
              </div>
            </div>
            <div class="row" id="emi_payment">
            </div>
            <input type="hidden" name="deal_id" id="deal_id" value="<?php echo e($deal->id); ?>">
            <input type="hidden" name="invoice_id" id="invoice_id" value="<?php echo e($invoice->id); ?>">
    <?php echo Form::submit('Submit', ['class' => 'btn btn-danger', 'id' => 'submit-button']); ?>

    <?php echo Form::close(); ?>

    <?php else: ?>
      <div class="col-md-3">
        <p class="help-block text-danger">
          <strong>
            Payment complete.
          </strong>
        </p>
      </div>
    <?php endif; ?>
    </div>
    </div>
    <div class="row">
    <div class="card-body">
            <h3 class="card-title">Plot Summary</h3>
            <div class="row">
              <div class="col-md-3" id="registryAmount">
                  <div class="form-group">
                      <label class="control-label font-bold" for="registry_amount">Name : </label>
                      <span class="" id="registry_amount"><?php echo e($plot->name); ?></span>
                  </div>
              </div>
              <div class="col-md-3" id="registryAmount">
                  <div class="form-group">
                      <label class="control-label font-bold" for="registry_amount">Area : </label>
                      <span class="" id="registry_amount"><?php echo e($plot->area); ?></span>
                  </div>
              </div>
              <div class="col-md-3" id="registryAmount">
                  <div class="form-group">
                      <label class="control-label font-bold" for="registry_amount">Dimension : </label>
                      <span class="" id="registry_amount"><?php echo e($plot->dimension); ?></span>
                  </div>
              </div>
              <div class="col-md-3" id="registryAmount">
                  <div class="form-group">
                      <label class="control-label font-bold" for="registry_amount">Project Name : </label>
                      <span class="" id="registry_amount"><?php echo e($plot->projectName); ?></span>
                  </div>
              </div>
              <div class="col-md-3" id="registryAmount">
                  <div class="form-group">
                      <label class="control-label font-bold" for="registry_amount">Sector Name : </label>
                      <span class="" id="registry_amount"><?php echo e($plot->sectorName); ?></span>
                  </div>
              </div>
              <div class="col-md-3" id="registryAmount">
                  <div class="form-group">
                      <label class="control-label font-bold" for="registry_amount">Block Name : </label>
                      <span class="" id="registry_amount"><?php echo e($plot->blockName); ?></span>
                  </div>
              </div>
              <div class="col-md-3" id="registryAmount">
                  <div class="form-group">
                      <label class="control-label font-bold" for="registry_amount">Status : </label>
                      <span class="" id="registry_amount"><?php echo e(ucfirst($plot->status)); ?></span>
                  </div>
              </div>
            </div>
            <h3 class="card-title">Deal Summary</h3>
            <div class="row" id="full_payment">
              <?php $remaining_temp=$deal->paid_amount; $status_temp=true; ?>
              <?php $__currentLoopData = $invoices; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $invoice): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <div class="col-md-3" id="registryAmount">
                    <div class="form-group">
                        <label class="control-label font-bold" for="registry_amount"><?php echo e($invoice->comment); ?> : </label>
                        <span class="" id="registry_amount"><?php echo e(($invoice->status)?IND_money_format($invoice->amount, 2):(($remaining_temp > 0 && $remaining_temp < $invoice->amount && $status_temp)?IND_money_format($invoice->amount-$remaining_temp, 2):IND_money_format($invoice->amount, 2))); ?></span>
                        <span class="label label-<?php echo e(($invoice->status)?'info':'warning'); ?>" style="color:#fff;">[<?php echo e(($invoice->status)?'Paid on '.$invoice->paid_on:'Pending'); ?>]</span>
                    </div>
                </div>

              <?php
              if($invoice->status){
                $remaining_temp=$remaining_temp-$invoice->amount;
              }elseif($remaining_temp < $invoice->amount && $remaining_temp > 0 && $status_temp){
                $remaining_temp=$invoice->amount-$remaining_temp;
                $status_temp = false;
              }else{
                $remaining_temp=0;
              }
              ?>
              <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                <div class="col-md-3" id="registryAmount">
                    <div class="form-group">
                        <label class="control-label font-bold" for="registry_amount">Total Payment Done : </label>
                        <span class="" id="registry_amount"><?php echo e(IND_money_format($deal->paid_amount, 2)); ?></span>
                    </div>
                </div>
                <div class="col-md-3" id="registryAmount">
                    <div class="form-group">
                        <label class="control-label font-bold" for="registry_amount">Total Due Amount : </label>
                        <span class="" id="registry_amount"><?php echo e(IND_money_format($deal->due_amount, 2)); ?></span>
                    </div>
                </div>
            </div>
        <h3 class="card-title">Payments Done</h3>
        <div class="x_content">
          <table id="datatable-fixed-header" class="table table-striped table-bordered">
            <thead>
              <tr>
                <th>Amount</th>
                <th>Remark</th>
                <th>Status</th>
                <th>Created at</th>
                <th>Action</th>
              </tr>
            </thead>


            <tbody>
            <?php $__currentLoopData = $payments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $payment): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
              <tr>
                <td><?php echo e(IND_money_format($payment->amount)); ?></td>
                <td><?php echo str_replace('/////////////', '<br />', $payment->comment); ?></td>
                <td><?php echo e(($payment->status==1)?'Approved':'Pending'); ?></td>
                <td><?php echo e($payment->created_at); ?></td>
                <td>
                  <?php if($payment->status == 0): ?>
                    <a type="button" class="btn btn-sm waves-effect waves-light btn-success" href="<?php echo e(url('/admin/payments/approvepayment'.'/'.$payment->id)); ?>">Approve</a>
                    <button type="button" class="btn btn-sm btn-danger cancel_payment" data-url="<?php echo e(url('/admin/payments/cancelpayment'.'/'.$payment->id)); ?>">Cancel</button>
                  <?php else: ?>
                    <span class="bg-<?php echo e(($payment->status == 1)?'info':'danger'); ?>" style="color: #fff;"><?php echo e(($payment->status == 1)?'Paid':'Cancelled/Revoked'); ?> on <?php echo e($payment->paid_on); ?></span>
                    <?php if($payment->status == 1): ?>
                      <!-- <button type="button" class="btn btn-sm btn-danger cancel_payment" data-url="<?php echo e(url('/admin/payments/revokepayment'.'/'.$payment->id)); ?>">Revoke</button> -->
                    <?php endif; ?>
                  <?php endif; ?>
                </td>
              </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </tbody>
          </table>
        </div>
      </div>
    </div>
</div>
<!-- The Modal -->
<div class="modal fade" id="loadModalAjax" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" style="display: none;" aria-hidden="true">
  <div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">

      <!-- Modal Header -->
      <div class="modal-header">
        <h4 class="modal-title">Payment Cancellation</h4>
        <button type="button" class="close" data-dismiss="modal">&times;</button>
      </div>

      <!-- Modal body -->
      <div class="modal-body">
        <?php echo Form::open(['method' => 'POST','id'=> 'cancel_payment', 'data-parsley-validate'=>'', 'url' => ['']]); ?>

        <div class="row">
          <div class="col-md-12">
              <div class="form-group">
                  <label class="control-label" for="payment_reference">Remark</label>
                  <textarea type="text" id="cancel_comment" name="comment" required="required" class="form-control" value=""></textarea>
              </div>
          </div>
        </div>
        <?php echo Form::submit('Submit', ['class' => 'btn btn-danger']); ?>

        <?php echo Form::close(); ?>

      </div>

      <!-- Modal footer -->
      <div class="modal-footer">
        <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
      </div>

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

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

<?php $__env->startSection('javascript'); ?>
    <!-- Date picker plugins css -->
    <link href="<?php echo e(url('assets')); ?>/plugins/bootstrap-datepicker/bootstrap-datepicker.min.css" rel="stylesheet" type="text/css" />
    <!-- Daterange picker plugins css -->
    <link href="<?php echo e(url('assets')); ?>/plugins/timepicker/bootstrap-timepicker.min.css" rel="stylesheet">
    <link href="<?php echo e(url('assets')); ?>/plugins/bootstrap-daterangepicker/daterangepicker.css" rel="stylesheet">
    <!-- Date Picker Plugin JavaScript -->
    <script src="<?php echo e(url('assets')); ?>/plugins/bootstrap-datepicker/bootstrap-datepicker.min.js"></script>
    <!-- Date range Plugin JavaScript -->
    <script src="<?php echo e(url('assets')); ?>/plugins/timepicker/bootstrap-timepicker.min.js"></script>
    <script src="<?php echo e(url('assets')); ?>/plugins/bootstrap-daterangepicker/daterangepicker.js"></script>
    <script src="<?php echo e(url('assets')); ?>/js/jqBootstrapValidation.js"></script>
    <link href="<?php echo e(url('assets')); ?>/plugins/EasyAutocomplete/easy-autocomplete.min.css" rel="stylesheet">
    <script src="<?php echo e(url('assets')); ?>/plugins/EasyAutocomplete/jquery.easy-autocomplete.min.js"></script>
    <script src="<?php echo e(url('assets')); ?>/js/typeahead.bundle.js"></script>
    <!-- Parsley -->
    <script>
      
      jQuery(document).ready(function() {
      $('div.payOpt').hide();
      jQuery('.mydatepicker, #datepicker').datepicker({format: 'yyyy-mm-dd'});
      $('select#payment_type').on('change', function() {
        if( this.value == 'Cash' || this.value == ''){
          $('div.payOpt').hide();
        }else{
          $('div.payOpt').show();
        }
      });
       jQuery('#datatable-fixed-header').DataTable({
          fixedHeader: true
        });
        $('button.cancel_payment').click(function(){
          $('form#cancel_payment').attr('action', $(this).attr('data-url'));
          $('#loadModalAjax').modal({show:true});
        });

        $('input,textarea,select').filter('[required]').addClass('data-required');

        $('#submit-button').on('click', function(event) {
            $('.data-required').prop('required', true);
            $('input,textarea,select').filter('[required]:hidden').prop('required', false);
            return true;
        });
      });
  </script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH G:\xampp\htdocs\yespropmart2.loc\resources\views/admin/payments/create.blade.php ENDPATH**/ ?>