<script type="text/jscript">
function Valtext(e) {
    key = e.keyCode || e.which;
    tecla = String.fromCharCode(key).toLowerCase();
    letras = " áéíóúabcdefghijklmnñopqrstuvwxyz";
    especiales = [8, 37, 39, 46];

    tecla_especial = false
    for(var i in especiales) {
        if(key == especiales[i]) {
            tecla_especial = true;
            break;
        }
    }

    if(letras.indexOf(tecla) == -1 && !tecla_especial)
        return false;
}

function ValNumero(e) {
    key = e.keyCode || e.which;
    tecla = String.fromCharCode(key).toLowerCase();
    letras = "0123456789";
    especiales = [8, 37, 39, 46];

    tecla_especial = false
    for(var i in especiales) {
        if(key == especiales[i]) {
            tecla_especial = true;
            break;
        }
    }

    if(letras.indexOf(tecla) == -1 && !tecla_especial)
        return false;
}
	
	
</script>


	<?php
		if (isset($con))
		{
	?>
	<!-- Modal -->
	<div class="modal fade" id="nuevoProducto" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
	  <div class="modal-dialog" role="document">
		<div class="modal-content">
		  <div class="modal-header">
			<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
			<h4 class="modal-title" id="myModalLabel"><i class='glyphicon glyphicon-edit'></i> Agregar nuevo producto</h4>
		  </div>
		  <div class="modal-body">
			<form class="form-horizontal" method="post" id="guardar_producto" name="guardar_producto">
			<div id="resultados_ajax_productos"></div>
              
			  <div class="form-group">
				<label for="codigo" class="col-sm-3 control-label">Código</label>
				<div class="col-sm-8">
				  <input type="text" class="form-control" id="codigo" name="codigo" placeholder="Código del producto" maxlength="30">
				</div>
			  </div>
			  
			  
              
			  <div class="form-group">
				<label for="nombre" class="col-sm-3 control-label">Descripcion</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="nombre" name="nombre" placeholder="Nombre del producto" required maxlength="200" >				  
				</div>
			  </div>
			  
              <div class="form-group">
				<label for="codigo" class="col-sm-3 control-label">Tipo o Rubro</label>
				<div class="col-sm-8">
				 <select class="form-control" id="rubro" name="rubro" onchange='load(1);'/>
	 			          			<option value="">---Seleccione una opcion---</option>
						  			<?php 
              															
									$count_query= mysqli_query($con, "SELECT * FROM `rubros`");
		     						while($dato= mysqli_fetch_array($count_query))
									{
			 							$rubro=$dato['rubro'];
			  							?>
                  						<option value="<?php echo $rubro; ?>"><?php echo $rubro; ?></option>
                  					<?php 
									}	 
										 
						  			?>
									
                          			</select> 
				</div>
			  </div>
              
			  <div class="form-group">
				<label for="codigo" class="col-sm-3 control-label">Marca</label>
				<div class="col-sm-8">
				<select class="form-control" id="marca" name="marca" onchange='load(1);'/>
	 			          			<option value="">---Seleccione una opcion---</option>
						  			<?php 
              						$count_query= mysqli_query($con, "SELECT * FROM `marcas`");
		     						while($dato= mysqli_fetch_array($count_query))
									{
			 							$marca=$dato['marca'];
			  						?>
                  						<option value="<?php echo $marca; ?>"><?php echo $marca; ?></option>
                  					<?php 
									} 
						  			?>
                          			</select> 
				</div>
			  </div>
              
              
               <div class="form-group">
				<label for="codigo" class="col-sm-3 control-label">Presentacion</label>
				<div class="col-sm-8">
				<select class="form-control" id="presentacion" name="presentacion" onchange='load(1);'/>
	 			          			<option value="">---Seleccione una opcion---</option>
						  			<?php 
              						$count_query= mysqli_query($con, "SELECT * FROM `presentacions`");
		     						while($dato= mysqli_fetch_array($count_query))
									{
			 							$presentacion=$dato['presentacion'];
			  							?>
                  						<option value="<?php echo $presentacion; ?>"><?php echo $presentacion; ?></option>
                  					<?php 
									} 
						  			?>
                          			</select> 
				</div>
			  </div>
			  
			  
		
		  <div class="modal-footer">
			<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
			<button type="submit" class="btn btn-primary" id="guardar_datos">Guardar datos</button>
		  </div>
		  </form>
		</div>
	  </div>
	</div>
    </div>
	<?php
		}
	?>