<%= form_for(setup_pointsale(@pointsale), :html => {:class=>"form-horizontal"}) do |f| %>
	<div class="portlet-body form">
		<% if @pointsale.errors.any? %>
		<div class="alert alert-danger">
			<strong>Tiene <%= pluralize(@pointsale.errors.count, "error") %> no se puede guardar el punto de venta</strong><br>
		</div>
		<% end %>
		<div class="form-body">
			<!-- <div class="profile-sidebar"></div>	-->
			<h4 class="form-section">Información del punto de venta</h4>
			<div class="form-group">
				<%= f.label :name, "Nombre del punto de venta", {:class=>"col-md-3 control-label"} do %> Nombre del punto de venta
					<span class="required">*</span>
				<% end %>
				<div class="col-md-9">
					<%= f.text_field :name, {:class=>"form-control"} %>
				</div>
			</div>
			<div class="form-group">
				<%= f.label :prefix, "Prefijo", {:class=>"col-md-3 control-label"} do %> Prefijo
					<span class="required">*</span>
				<% end %>
				<div class="col-md-9">
					<%= f.text_field :prefix, {:class=>"form-control"} %>
					<span class="help-block">El prefijo es la abreviación que se utilizará para identificar al punto de venta, debe conformarse de 3 letras.</span>
				</div>
			</div>
			<div class="form-group">
				<%= f.label :address, "Dirección", {:class=>"col-md-3 control-label"} %>
				<div class="col-md-9">
					<%= f.text_field :address, {:class=>"form-control"} %>
				</div>
			</div>
			<div class="form-group">
				<%= f.label :haggle_percent, {:class=>"col-md-3 control-label"} do %> Porcentaje de regateo para ventas <% end %>
				<div class="col-md-2">
					<%= f.number_field :haggle_percent, {:class=>"form-control" }  %>
				</div>
			</div>
			<div class="form-group">
				<%= f.label :notes, "Encabezado para el ticket", {:class=>"col-md-3 control-label"} %>
				<div class="col-md-9">
					<%= f.text_area :notes, {:class=>"form-control", :rows => 5} %>
				</div>
			</div>
			<div class="form-group">
				<%= f.label :ticket_footer, "Pie de pagina para ticket", {:class=>"col-md-3 control-label"} %>
				<div class="col-md-9">
					<%= f.text_area :ticket_footer, {:class=>"form-control", :rows => 5} %>
				</div>
			</div>
			<div class="form-group">
				<%= f.label :img_pointsale, "Imagen para el ticket", {:class=>"col-md-3 control-label"} %>
				<div class="col-md-9">
					<div class="fileinput fileinput-new" data-provides="fileinput">
						<div class="fileinput-new thumbnail" style="width: 200px; height: 150px;">
							<% if @pointsale.img_pointsale? %>
							<%= image_tag @pointsale.img_pointsale %>
							<% else %>
							<%= image_tag "no-image.png" %>
							<% end %>
						</div>
						<div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 150px;"> </div>
						<div>
							<span class="btn default btn-file">
								<span class="fileinput-new"> Seleccione imagen </span>
								<span class="fileinput-exists"> Cambiar </span>
								<%= f.file_field :img_pointsale, {:class=>"default"} %>
								<%= f.hidden_field :img_pointsale_cache %>
							</span>
							<a href="javascript:;" class="btn red fileinput-exists" data-dismiss="fileinput"> Borrar </a>
						</div>
					</div>
				</div>
			</div>
			<% unless @pointsale.persisted? %>
				<h4 class="form-section">Usuario responsable de punto de venta</h4>
				<%= f.fields_for :users, @pointsale.users do |u| %>
					<div class="form-group">
						<%= u.label :first_name, "Nombre", {:class=>"col-md-3 control-label"} do %> Nombre
							<span class="required">*</span>
						<% end %>
						<div class="col-md-9">
							<%= u.text_field :first_name, {:class=>"form-control"} %>
						</div>
					</div>
					<div class="form-group">
						<%= u.label :last_name, "Apellidos", {:class=>"col-md-3 control-label"} do %> Apellidos
							<span class="required">*</span>
						<% end %>
						<div class="col-md-9">
							<%= u.text_field :last_name, {:class=>"form-control"} %>
						</div>
					</div>
					<div class="form-group">
						<%= u.label :email, "Correo", {:class=>"col-md-3 control-label"} do %> Correo electrónico
							<span class="required">*</span>
						<% end %>
						<div class="col-md-9">
							<%= u.text_field :email, {:class=>"form-control"} %>
						</div>
					</div>
					<div class="form-group">
						<%= u.label :userid, "Nombre del punto de venta", {:class=>"col-md-3 control-label"} do %> Usuario
							<span class="required">*</span>
						<% end %>
						<div class="col-md-9">
							<%= u.text_field :userid, {:class=>"form-control"} %>
						</div>
					</div>
					<div class="form-group">
						<%= u.label :password, "Nombre del punto de venta", {:class=>"col-md-3 control-label"} do %> Contraseña
							<span class="required">*</span>
						<% end %>
						<div class="col-md-9">
							<%= u.password_field :password, {:class=>"form-control"} %>
						</div>
					</div>
					<div class="form-group">
						<%= u.label :password_confirmation, "Confirmar contraseña", {:class=>"col-md-3 control-label"} do %> Confirmar Contraseña
							<span class="required">*</span>
						<% end %>
						<div class="col-md-9">
							<%= u.password_field :password_confirmation, {:class=>"form-control"} %>
						</div>
					</div>
				<% end %>
			<% end %>
		</div>
		<div class="form-actions">
			<div class="row">
				<div class="col-md-offset-3 col-md-9">
					<%= f.submit 'Guardar', {:class=>"btn green"} %>
					<%= link_to 'Cancelar', pointsales_path(:filter => @filter, :current_page => @current_page), {:class=>"btn default"} %>
				</div>
			</div>
		</div>
	</div>
<% end %>
<script type="text/javascript">
	$(document).ready(function() {
		App.init();
	});
</script>
