<div class="container-fluid">
  <div class='row'>
    <div class="col-lg-10 col-md-10 col-sm-10">
      <h2><%= t :cash_out %></h2>
      <table class='table table-striped'>
        <tr>
          <td> <%= t :payment_reference %></td>
          <td><input type="text" class="form-control" placeholder="Reference" id="reference"></td>
        </tr>
        <tr>
          <td> <%= t("views.right_panel.detail.remark") %></td>
          <td><input type="text" class="form-control" placeholder="Remark" id="remark"></td>
        </tr>
        <tr>
          <td> <%= t("views.right_panel.detail.amount") %> </td>
          <td><input type="text" class="form-control" placeholder="Amount" id="amount"></td>
        </tr>
      </table>
    </div>
    <div class="col-lg-2 col-md-2 col-sm-2">
      <br><br>
      <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" id='cash_out'> <%= t("views.btn.cash_out") %> </button>
    </div>
  </div>
</div>
<script>
 cashier_type   = '<%= @cashier_type %>';
  $('#cash_out').on('click',function(){
    var reference = $('#reference').val();
    var remark = $('#remark').val();
    var amount = $('#amount').val();
    $.ajax({type: "POST",
      url: "<%= origami_cash_outs_path %>",
      data: "reference="+ reference + "&remark=" + remark + "&amount="+ amount,
      success:function(result){
        if (cashier_type == 'quick_service' || cashier_type == 'food_court') {
          window.location.href = '/origami/'+cashier_type+'/pending_order';
        }else{
          window.location.href = '/origami';
        }
      }
    });
  })

  $('#back').on('click',function(){
    if (cashier_type == 'quick_service' || cashier_type == 'food_court') {
      window.location.href = '/origami/'+cashier_type+'/pending_order';
    }else{
      window.location.href = '/origami';
    }
  })
</script>
