
<div class='row'>
  <div class='col-md-10'>
    <h1>Close Cashier</h1>
    <br>
    <table class='table table-striped'>
      <tr>
        <td>Shift Started At</td>
        <td><%= @shift.shift_started_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-' %></td>
      </tr>
      <tr>
        <td>Cashier Name</td>
        <td><%= @shift.employee.name rescue ''%></td>
      </tr>

    </table>
    <hr>
    <div class='row'>
      <div class='col-md-5'>
        <span style='font-size:20px;'><b>Closing Balance</b></span>
      </div>
      <div class='col-md-6'>
        <span style='font-size:20px;'><b><input type='text' id='closing_balance_amount' value=''></b></span>
      </div>
    </div>
  </div>
  <div class="col-lg-2 col-md-2 col-sm-2">
    <button type="button" class="btn btn-primary btn-block" id='back'> Back </button>
    <button type="button" class="btn btn-primary btn-block green" id='close_cashier'> Close Cashier </button>
  </div>
</div>
<script>
$('#close_cashier').on('click',function(){
  var amount = $('#closing_balance_amount').val();
  var shift_id = "<%= @shift.id %>"
  $.ajax({type: "POST",
    url: "<%= origami_close_shift_path %>",
    data: "closing_balance="+ amount + "&shift_id="+ shift_id,
    success:function(result){
      console.log(result)
      window.location.href = '/';
    }
  });
})
$('#back').on('click',function(){
  window.location.href = '/origami';
})
</script>
