<div class="portlet-body form">
    <div class="form-body">
        <div class="row">     
            <div class="col-md-12">
                <!-- tipo de destino -->
                <div class="form-group">
                  <%= label_tag 'return_cash', {:class=>"col-md-5 control-label"} do %> ¿Regresar el dinero del apartado al cliente?  
                  <span class="required">*</span>
                  <% end %>
                  <div class="col-md-3" style="padding-left:0px;padding-right:0px">
                    <%= check_box_tag('return_cash', '', false, { 
                        class: "make-switch",
                        data: {
                          on_color: "success",
                          off_color: "warning",
                          on_text: "SI", 
                          off_text: "NO"
                        }
                    }) %>
                  </div>
                </div>                    
            </div>
        </div>
    </div>
</div>
<div class="form-actions">
    <h4 class="form-section"> </h4>
    <div class="row">
        <div class="col-md-12">
            <button type="button" class="btn green" onclick="deleteReservedSale()">Cancelar apartado</button>

            <button type="button" class="btn default" onclick="cerrarDialog()">Cerrar</button>
        </div>
    </div>
</div>
<script>
    $(document).ready(function(){
        App.init();
    });

    function cerrarDialog() {
        $('#dialog').modal('toggle');
    }

    function deleteReservedSale() {
        var flag = $('#return_cash').bootstrapSwitch('state');
        console.log(flag);
      $.ajax({
        type: "delete",
        url:  '/sales/' + <%= @sale.id %>,
        dataType: "json",
        data: {
            return_cash: flag
        },
        success: function(xhr, status, error) {
          window.location = "<%= sales_reserved_path %>"; 
        }
      });        
    }
</script>
    
    