<div class="form-horizontal">
    <div class="portlet-body form">
        <div class="form-body">
            <div class="row">     
                <div class="col-md-12">
                    <div class="form-group">
                       <%= label_tag :customer_id,  {:class=>"col-md-4 control-label"} do %>Cliente <span class="required">*</span> <% end %> 
                        <div class="col-md-6">
                          <%= select_tag :customer_id, options_from_collection_for_select(@customers, :id, :nick_name), :include_blank => "Seleccione cliente",  class: "form-control select2" %>
                        </div>
                    </div>
                </div>
                <div class="col-md-12">
                <table class="table table-striped table-bordered table-hover" id="reserved_table">
                    <thead>
                      <tr>
                        <th>Folio</th>                      
                        <th>Fecha</th>
                        <th>Vence</th>
                        <th>Productos</th>
                        <th>Status</th>
                        <th>Total</th>
                        <th>Adeudo</th>
                        <th>Acciones</th>
                      </tr>
                    </thead>
                    <tbody>
                    </tbody>
                </table>
                </div>
            </div>
        </div>
    </div>   
</div>
<script>
    $('#customer_id').on('change', function() {
        getReservedSales();
    });

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

    function getReservedSales() {
        var customerId = $('#customer_id').val();
        if(customerId) {
          $.ajax({
            type: "GET",
            url: "/customers/"+ customerId + "/reserved_sales/",
            dataType: "script",
            success: function(xhr, status, error) {
            }
          });             
        }
    }
</script>
	