	<?php
		if (isset($con))
		{
	?>
	<!-- Modal -->
	<div class="modal fade" id="myModal3" 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> Modificar Existencia de un Producto</h4>
		  </div>
		  <div class="modal-body">
			<form class="form-horizontal" method="post" id="editar_existencia" name="editar_existencia">
				<div id="resultados_ajax3"></div>
            
			  <div class="form-group">
				<label for="mod_codigo" class="col-sm-3 control-label">Código</label>
				<div class="col-sm-8">
					<input type="hidden" class="form-control" name="mod_id" id="mod_id" readonly="readonly">
					<input type="hidden" class="form-control" name="mod_almacen" id="mod_almacen" readonly="readonly">
				  <input type="text" class="form-control" id="mod_codigo" name="mod_codigo" placeholder="Código del producto" required readonly="readonly">
				</div>
			  </div>
			   <div class="form-group">
				<label for="mod_nombre" class="col-sm-3 control-label">Nombre</label>
				<div class="col-sm-8">
				  <textarea class="form-control" id="mod_nombre" name="mod_nombre" placeholder="Nombre del producto" required readonly="readonly"></textarea>
				</div>
			  </div>
              
              <div class="form-group">
				<label for="usuario" class="col-sm-3 control-label">Usuario</label>
				<div class="col-sm-8">
				  <?php 
             $cs=mysqli_query($con, "select count(id_sesion),Max(id_sesion) from historico_sesiones");
		while($resul=mysqli_fetch_array($cs)){
			$count=$resul[0];
			$max=$resul[1];
		}
			 $cs2=mysqli_query($con, "select * from historico_sesiones where id_sesion='$max'");
		while($resul2=mysqli_fetch_array($cs2)){
			$usu=$resul2['usuario'];
			$user_name=$resul2['user_name'];
			}
			  ?>
                  <input type="text" name="usuario" id="usaurio" class="form-control" value="<?php echo $usu; ?>" required="required" readonly="readonly">
				 
                   </div>
			  </div>
			  
              <div class="form-group">
              <label for="modalidad" class="col-sm-3 control-label">Accion a Realizar</label>
              <div class="col-sm-8">
				<select class="form-control" name="mod" id="mod" onChange='show()' required>
                	<option value="" selected="selected">---Seleccione una Opcion---</option>
					<option value="agregar" >Agregar</option>
					<option value="eliminar" >Eliminar</option>
                </select>
               </div>
               </div>
               
             <div style="margin-left:20%;">
             <div id="agrega" style="display:none;">
	          	<div class="form-group">
    	        	<label for="mod_estado" class="col-sm-3 control-label">Motivo</label>
					<div class="col-sm-8">
					<select class="form-control" id="mod_estado_a" name="mod_estado_a">
						<option value="" selected>-- Selecciona motivo --</option>
						<option value="mal_conteo">Mal Conteo</option>
						<option value="guardado">Guardado</option>
					</select>
					</div>
				 </div>
                 <div class="form-group">
					<label for="mod_cantidad" class="col-sm-3 control-label">cantidad</label>
					<div class="col-sm-8">
						<input type="text" class="form-control" id="mod_cantidad_a" name="mod_cantidad_a" placeholder="Cantidad a agregar" title="Ingresa sólo números" maxlength="10">
					</div>
				</div>
             </div>
             
               <div id="elimina" style="display:none;">
	          	<div class="form-group">
    	        	<label for="mod_estado" class="col-sm-3 control-label">Motivo</label>
					<div class="col-sm-8">
					<select class="form-control" id="mod_estado_e" name="mod_estado_e">
						<option value="" selected>-- Selecciona motivo --</option>
						<option value="deterioro">Deterioro</option>
						<option value="perdida">Perdida</option>
					</select>
					</div>
				 </div>
                 <div class="form-group">
					<label for="mod_cantidad" class="col-sm-3 control-label">cantidad</label>
					<div class="col-sm-8">
						<input type="text" class="form-control" id="mod_cantidad_e" name="mod_cantidad_e" placeholder="Cantidad a eliminar" title="Ingresa sólo números" maxlength="10">
					</div>
				</div>
             </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="actualizar_datos2">Procesar</button>
		  </div>
		  </form>
		</div>
	  </div>
	</div>
    </div>
	<?php
		}
	?>
	<script>
	
	function show()
				{
					getSelectValue = document.getElementById("mod").value;
					
  					if(getSelectValue=="agregar")
					{
						document.getElementById("agrega").style.display = "inline-block";
						document.getElementById("elimina").style.display = "none";  
    					document.getElementById("mod_cantidad_a").setAttribute("required" , "required");
						
 						
					}
  					if(getSelectValue=="eliminar")
					{
    					document.getElementById("elimina").style.display = "inline-block";
						document.getElementById("agrega").style.display = "none";  
    					document.getElementById("mod_cantidad_e").setAttribute("required" , "required");
						
   					}
  					if(getSelectValue=="")
					{
    					document.getElementById("agrega").style.display = "none";
						document.getElementById("elimina").style.display = "none";
					}
				}
				
			
	</script>