<?php echo $__env->make('dashboard.include.header', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

  
  <div class="content-wrapper" style="">
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1 class="m-0">Adding Expenses</h1>
          </div>
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="/home">Home</a></li>
              <li class="breadcrumb-item active">Adding Expenses</li>
            </ol>
          </div>
        </div>
      </div>
    </div>
   
    <section class="content">
      <div class="container-fluid">

      <div class="card">
        <div class="card-body">
        <form method="post" action="/addexpenses">
          <?php echo e(csrf_field()); ?>

          <div class="row">

            <input type="hidden" name="payment" value="Debit">

            <div class="col-md-3">
              <div class="form-group">
                <label>Account No</label>
                <select class="form-control" name="bankche" id="bankche" style="width: 100%;" required>
                    <option value="" selected="selected" disabled>Select</option>
                    <?php $__currentLoopData = $supdata; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $supdatadata): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($supdatadata->id); ?>"><?php echo e($supdatadata->accountno); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>
            </div>
            <div class="col-md-3">
            <div class="form-group">
                <label for="">Account Name</label>
                <input type="text" class="form-control" id="accname" name="accname" placeholder="Account Name"  readonly required>
            </div>
            </div>
            <div class="col-md-2">
            <div class="form-group">
                <label for="">Bank</label>
                <input type="text" class="form-control" id="bank" name="bank" placeholder="Bank" readonly required>
            </div>
            </div>
            <div class="col-md-2">
            <div class="form-group">
                <label for="">Branch</label>
                <input type="text" class="form-control" id="branch" name="branch" placeholder="Branch" readonly required>
            </div>
            </div>
            <div class="col-md-2">
            <div class="form-group">
                <label for="">Balance</label>
                <input type="text" class="form-control" id="balance" name="balance" placeholder="Balance" readonly required>
            </div>
            </div>

            <div class="col-md-3">
              <div class="form-group">
                <label>Expenses Type</label>
                <select class="form-control" name="accoption" id="accoption" style="width: 100%;" required>
                    <option value="" selected="selected" disabled>Select</option>
                      <?php $__currentLoopData = $accoption; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $accoptiondata): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($accoptiondata->option); ?>"><?php echo e($accoptiondata->option); ?></option>
                      <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>
            </div>

            <div class="col-md-3">
              <div class="form-group">
                <label>Payment Type</label>
                <select class="form-control" name="paymenttype" id="paymenttype" style="width: 100%;" required>
                    <option value="" selected="selected" disabled>Select</option>
                        <option value="cash">Cash</option>
                        <option value="cheque">Cheque</option>
                        <option value="Wire Transfer">Wire Tranfer</option>
                </select>
            </div>
            </div>
            <div class="col-md-3">
                <div class="form-group">
                    <label for="">Amount</label><input type="number" step=".01" class="form-control" id="amount" name="amount" placeholder="Amount" required>
                </div>
            </div>
            <div class="col-md-3">
            </div>
            <div class="col-md-3 recipname">
            <div class="form-group">
                <label for="">Cheque Recipient Name</label>
                <input type="text" class="form-control" id="ownname" name="ownname" value="-" required>
            </div>
            </div>

            <div class="col-md-3 ChequeNumber">
            <div class="form-group">
                <label for="">Cheque Number</label>
                <input type="text" class="form-control" id="Chequeno" name="Chequeno" value="-" required>
            </div>
            </div>
            <div class="col-md-3 chequedate">
            <div class="form-group">
            <label id="pdate2">Cheque Date</label>
                <div class="input-group date" id="reservationdate2" data-target-input="nearest">
                    <input type="text" class="form-control datetimepicker-input" id="Cheque_date" name="Cheque_date" data-target="#reservationdate2"/ required>
                    <div class="input-group-append" data-target="#reservationdate2" data-toggle="datetimepicker">
                        <div class="input-group-text"><i class="fa fa-calendar"></i></div>
                    </div>
                </div>
            </div>
            </div>

            <div class="col-md-10">
                    <div class="form-group">
                        <label>Description</label>
                        <textarea type="text" placeholder="" value="" id="note" name="note" class="form-control" required></textarea>
                    </div>
                </div>
                <div class="col-md-2" style="padding-top:35px;"><button type="submit" class="btn btn-primary btn-block">Add Expenses</button></div>
         

          </div>

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

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



  <?php echo $__env->make('dashboard.include.footer', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>;



<script>
$('.recipname').hide();
$('.ChequeNumber').hide();
$('.chequedate').hide();


$('#paymenttype').on('change', function(){
  var id = $(this).val();

  if(id=="cash"){
    $("#pdate").html("Paid Date");
    $('.recipname').hide();
    $('.ChequeNumber').hide();
    $('.chequedate').hide();
}else if(id=="cheque"){
  $("#pdate").html("Cheque Date");
  $('.recipname').show();
  $('.ChequeNumber').show();
  $('.chequedate').show();
}
else if(id=="Wire Transfer"){
    $("#pdate").html("Paid Date");
    $('.recipname').hide();
    $('.ChequeNumber').hide();
    $('.chequedate').hide();
    }
else if(id=="credit"){
  $("#pdate").html("Credit Date");
  $('.recipname').hide();
    $('.ChequeNumber').hide();
    $('.chequedate').hide();
}    
});



$('#reservationdate2').datetimepicker({
format: 'YYYY-MM-DD HH:mm:ss',
defaultDate: new Date()
});

$('#bankche').on('change', function(){
    var id = $(this).val();
    $.ajax({
            url: "<?php echo e(url('/getbankdata')); ?>/"+id ,
            method: "get",
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            },
            cache: false,
            contentType: false,
            processData: false,
            dataType: 'JSON',
            data:{
                "id":id
            },
            success: function (data) {
                // swal("Done!", "It was successfully deleted!", "success");

                    jQuery.each(data, function(key,value){
                        for(i=0; i<value.length; i++){
                            var rid = value[i].id;
                            $('#accname').val(value[i].accountname);
                            $('#bank').val(value[i].bank);
                            $('#branch').val(value[i].branch);
                            $('#balance').val(value[i].balance);
                            // $("#branch").val(value[i].balance).change();
                        }

                    });

            },
            error: function (jqXHR, textStatus, errorThrown) {
                swal("Warning", "Unable to Process your request", "error");
            },
        });
});


<?php if(session('success')): ?>
        //swal("Success!","<?php echo e(session('success')); ?>","success");

toastr.success('Expenses Adding successfully!')


<?php endif; ?>
<?php if(session('error')): ?>
    swal({
            title: "Error!",
            text: "<?php echo e(session('error')); ?>",
            icon: "error",
            button: "OK",
        });
<?php endif; ?>
</script>








