<div class="container-fluid">
  <div class='row clearfix'>
    <div class='col-md-10'>
      <h1><%= t :close_cashier %></h1>
      <br>
      <table class='table table-striped'>
        <tr>
          <td><%= t :shift_started_at %></td>
          <td><%= @shift.shift_started_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-' %></td>
        </tr>
        <tr>
          <td><%= t :cashier_name %></td>
          <td><%= @shift.employee.name rescue ''%></td>
        </tr>

      </table>
      <hr>
      <div class='row clearfix '>
        <div class='col-md-5'>
          <span style='font-size:20px;'><b><%= t :closing_balance %></b></span>
        </div>
        <div class='col-md-6'>
          <span style='font-size:20px;'><b><input type='text' class="form-control" 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 bg-default btn-block" id='back'><i class="material-icons">reply</i> <%= t("views.btn.back") %> </button>
    <button type="button" class="btn bg-blue btn-block green" id='close_cashier'> <%= t("views.btn.close_cashier") %> </button>
    </div>
  </div>
</div>
<script>
  $('#close_cashier').on('click',function(){
    var amount = $('#closing_balance_amount').val();
    var shift_id = "<%= @shift.id rescue ""%>"
    $.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>
