<?php
include("../php/config.php");
include("../header.php");
?>

<script>
///....
	if(myLevel!="Master"){
		alert("No tiene acceso a este modulo del sitema")
		window.location.href="../menu/menu.php";
		
	}
</script>
<div class="container">
	
			
			<div class="row">
                        <div class="col-md-2 mt-2">
                            <b>Almacen principal</b>
                        </div>
                        <div class="col-md-2">
                            <select class="form-control  mb-2" id="almacen" onChange="lista()">

                                <option value="" selected disabled>Sel. almacen</option>
                                <?php $sql2 = mysql_query("select * from almacen order by nombre asc")?>

                                <?php while ($r = mysql_fetch_array($sql2)) { ?>
                                    <option value="<?php echo $r['nombre'] ?>"><?php  echo $r['nombre'] ?></option>
                                <?php } ?>
                            </select>
                        </div>
                       
                         
                    </div>
                    <div class="row">
                        <div class="col-md-2 mt-2">
                            <b>Almacen Secundario</b>
                        </div>
                        <div class="col-md-2">
                            <select class="form-control  mb-2" id="almacen2" onChange="lista()">

                                <option value="" selected disabled>Sel. almacen</option>
                                <?php $sql3 = mysql_query("select * from almacen order by nombre asc")?>

                                <?php while ($r1 = mysql_fetch_array($sql3)) { ?>
                                    <option value="<?php echo $r1['nombre'] ?>"><?php  echo $r1['nombre'] ?></option>
                                <?php } ?>
                            </select>
                        </div>
                       
                    </div> 
					
					 <div class="row">
                        <div class="col-md-2 mt-2">
                            <b>Avisar sobre producto agotado</b>
                        </div>
                        <div class="col-md-2">
                            <select class="form-control  mb-2" id="resp_check">

                                <option value="" selected disabled>Sel. opcion</option>
                                <option value="" >Avisarmen</option>
								<option value="1" >No avisarme</option>
                            </select>
                        </div>
                       
                    </div> 
					
					<h3>Etiquetas de precio</h3>
					<hr>
								 <div class="row">
                        <div class="col-md-2 mt-2">
                            <b>Mostrar nombre empresa</b>
                        </div>
                        <div class="col-md-2">
                            <select class="form-control  mb-2" id="label_empresa">

                                <option value="" selected disabled>Sel. opcion</option>
                                <option value="0" >Mostrar</option>
								<option value="1" >No mostrar</option>
                            </select>
                        </div>
                       
                    </div> 
                  
                             <div class="row">
                        <div class="col-md-2 mt-2">
                            <b>Precios en etiquetas</b>
                        </div>
                        <div class="col-md-2">
                            <select class="form-control  mb-2" id="label_precio">

                                <option value="" selected>Sel. opcion</option>
                                <option value="0" >Mostrar</option>
                                <option value="1" >No mostrar</option>
                            </select>
                        </div>
                       
                    </div>
					<hr>
					 <div class="col-md-3  ml-2">
                             <a class="btn btn-md btn-success" href="javascript:void(0)" onclick="grabar()"><i class="fa fa-save fa-lg"> </i> Grabar</a> 
               
                             <a class="btn btn-md btn-danger" href="parametros.php"><i class="fa fa-home fa-lg"> </i> Ir atras</a>
                        </div>
				  
	
    
</div>		

<?php
include("../footer.php");
?>


<script type="text/javascript">

 $("#almacen option[value='"+myAlmacen+"']").prop('selected', true);
 $("#almacen2 option[value='"+myAlmacen2+"']").prop('selected', true);
  $("#resp_check option[value='"+localStorage.getItem("resp_check")+"']").prop('selected', true);
    $("#label_empresa option[value='"+localStorage.getItem("label_empresa")+"']").prop('selected', true);
	$("#label_precio option[value='"+localStorage.getItem("label_precio")+"']").prop('selected', true);
  function grabar(){
     if(!confirm("Seguro(a) que desea aztualizar este registro?")){return;}                   
    localStorage.setItem("resp_check",$("#resp_check").val());
	localStorage.setItem("label_empresa",$("#label_empresa").val());
        localStorage.setItem("label_precio",$("#label_precio").val());

     var almacen = $("#almacen").val();
     var almacen2 = $("#almacen2").val();
     if(almacen=="" || almacen2==""){alert("Debe seleccionar un almacen"); return;}
     localStorage.setItem("almacen",almacen);
     localStorage.setItem("almacen2",almacen2);
     alert("Almacen configurado con exito")
     }
</script>