<%= form_for(@customer, :remote => true, :html => {:class=>"form-horizontal"}) do |f| %>
	<div class="portlet-body form">
    	<div class="alert alert-danger hidden" id="error_explanation_remote_customer"></div>
		<div class="form-body">
			<div class="row">
				<div class="form-group ">
					<%= f.label :nick_name,  {:class=>"col-md-3 control-label"} do %>Nombre <span class="required">*</span>
					<% end %> 
					<div class="col-md-9">
						<%= f.text_field :nick_name, {:class=>"form-control input-xlarge" }  %>
					</div>
				</div>
				<div class="form-group">
					<%= f.label :phone, "Teléfono", {:class=>"col-md-3 control-label"} do %> Teléfono 
					<% end %> 
					<div class="col-md-5">
						<div class="input-icon">
							<i class="fa fa-phone"></i>
							<%= f.text_field :phone, {:class=>"form-control mask_phone input-small" } %>
						</div>
					</div>
				</div>
				<div class="form-group ">
					<%= f.label :credit, "¿Se le otorgará crédito?", {:class=>"col-md-3 control-label"} %>
					<div class="col-md-9">
						<%= f.check_box(:credit, 
							{ 
								class: "make-switch",
								data: {
									on_color: "success",
									off_color: "danger",
									on_text: "Si", 
									off_text: "No"
								}
							}, "true","false"
						) %>
					</div>
				</div>
				<div class="form-group credit_limits" <% if !@customer.credit? %> style="display:none;"  <% end %>  >
					<%= f.label :credit_limit, {:class=>"col-md-3 control-label"} do %> Limite de crédito <span class="required">*</span> <% end %>
					<div class="col-md-5">
						<div class="input-group">
							<span class="input-group-addon"> $ </span>
							<%= f.text_field :credit_limit, {:class=>"form-control mask_decimal input-small"} %>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="form-actions">
			<div class="row">
				<div class="col-md-9">
			        <%= f.submit 'Guardar', {:class=>"btn green"} %>
	                <button type="button" class="btn default" onclick="cerrarDialog()">Cerrar</button>
				</div>
			</div>
		</div>
	</div>
<% end %>
<script type="text/javascript">

	$(document).ready(function() {
		handleInputMasks();
		App.init();
		$('input[name="customer[credit]"]').on('switchChange.bootstrapSwitch', function(event, state) {
			if (state) {
				$(".credit_limits").show();
			}else{
				$(".credit_limits").hide();
			}
		});
	});

    function cerrarDialog() {
        $('#dialog').modal('toggle');
    }	
</script>
