<!-- PANEL ADMINISTRATIVO -->	
<link rel='stylesheet prefetch' href='css/bootstrap-select.min.css'>
<script src="js/jquery.min_busqueda.js"></script>
<script src="js/bootstrap-select.min.js"></script>
<script src="js/jquery.min_productos.js"></script>  
<script src="js/bootstrap.min_productos.js.js"></script>  
<div class="contentpanel">
 <div class="row row-stat">
	<div class="col-md-12">
        <div class="panel panel-default">
            <div class="panel-heading">
                <div class="panel-btns">
                    <a href="#" class="panel-minimize tooltips" data-toggle="tooltip" title="Minimize Panel"><i class="fa fa-minus"></i></a>
                    <a href="#" class="panel-close tooltips" data-toggle="tooltip" title="Close Panel"><i class="fa fa-times"></i></a>
                </div>
                <h4 class="panel-title"><?php echo $ver_cpanel_sub_menu['titulo']; ?></h4>
                <p><?php echo $ver_cpanel_sub_menu['descripcion']; ?>.</p>
            </div>
            <div class="panel-body nopadding">
				<div class="col-md-12">
                    <div class="table-responsive"><br>
						<!--BOTONES DE EXPORTACION-->
						<div class="pull-left">
							<div class="btn-group">
                                <button class="btn btn-default btn-sm " type="button"><i class="fa fa-print mr5"></i> Imprimir</button>
								<a href='xls/xls-reg_almacen.php' TARGET="_BLANK"  class="btn btn-default btn-sm " type="submit" id="export_data" name='export_data'><i class="fa fa-file-excel-o mr5"></i> Descargar XLS</a>
								<button class="btn btn-default btn-sm " type="button"><i class="fa fa-file-pdf-o mr5"></i> Descargar PDF</button>
			      			</div>
						</div>
						<!--BOTONES DE EXPORTACION-->						
						<!--BOTONES DE AGREGAR-->						
						<div class="pull-right">
						    <div class="btn-group">
                                <button class="btn btn-success btn-sm " type="button" data-toggle="modal" data-target=".bs-example-modal-lg"><i class="fa  fa-plus-square mr5"></i> AJUSTE DE PRECIOS </button>
                                <a href='cpanel.php?control_menu=report-estadisticas&condicion=auditor_precios&proceso=convenios'  class="btn btn-primary btn-sm" ><i class="fa  fa-plus-square mr5"></i> CONVENIOS </a>

						   </div>
						</div>
						<br>
						<br>
						<br>
						<!--
								<div class="col-md-4">
								  <div class="well well-sm"><b>PRECIO 1:</b> DECONTADO</div>
								</div>
								<div class="col-md-4">
								  <div class="well well-sm"><b>PRECIO 2:</b> CREDITO CRs.</div>
								</div>
								<div class="col-md-4">
								  <div class="well well-sm"><b>PRECIO 3:</b> ESPECIAL</div>
								</div>
								-->
						<div class="input-group mb15 has-warning">
                            <span class="input-group-addon"><b>BUSCAR</b></span>
                            <input type="text"  placeholder="Buscar productos" id="searchx" class="form-control" />
                        </div>
											

							<table id="employee_tablex" class="table table-striped table-bordered responsive">
                                <thead class="">
                                    <tr>
                                        <!-- <th>Almacen</th>-->
                                        <th>Descripcion del producto</th>
                                        <th>Unidad m.</th>
                                        <!--<th>Existencia</th>-->
                                        <th>COSTO</th>
                                        <th>PRECIO 1</th>
                                        <th>PRECIO 2</th>
                                        <th>PRECIO 3</th>
                                      <!--  <th>Opcion</th>-->
                                    </tr>
                                </thead>
                                <tbody>
								<?php
								
									$consultar_sql_ver1=mysql_query("select * from tabla_producto_inventario where eliminar='0'  ",$link);
									while($ver_consultar_sql_ver1=mysql_fetch_array($consultar_sql_ver1)){
									$cod_producto=$ver_consultar_sql_ver1['cod_producto']; 
									
									$consultar_sql_ver=mysql_query("select * from  tabla_productos where eliminar='0' and id='$cod_producto' ",$link);
									$ver_consultar_sql_ver=mysql_fetch_array($consultar_sql_ver);
									$id_control_edit=$ver_consultar_sql_ver['cod_rubro']; 
									$id_control_cod_medida=$ver_consultar_sql_ver['cod_medida']; 
									$id_control_cod_marca=$ver_consultar_sql_ver['cod_marca']; 
									$cod_almacen=$ver_consultar_sql_ver1['cod_almacen']; 
									
									$consultar_sql_ver_rubro=mysql_query("select * from  tabla_rubro_categoria where id='$id_control_edit'",$link);
									$ver_consultar_sql_ver_rubro=mysql_fetch_array($consultar_sql_ver_rubro);

									$consultar_sql_ver_marca=mysql_query("select * from   tabla_marca where id='$id_control_cod_marca'",$link);
									$ver_consultar_sql_ver_marca=mysql_fetch_array($consultar_sql_ver_marca);	

									$consultar_sql_ver_medida=mysql_query("select * from   tabla_unidad_medida where id='$id_control_cod_medida'",$link);
									$ver_consultar_sql_ver_medida=mysql_fetch_array($consultar_sql_ver_medida);	

									$consultar_sql_ver_almacen=mysql_query("select * from tabla_almacen where id='$cod_almacen'",$link);
									$ver_consultar_sql_ver_almacen=mysql_fetch_array($consultar_sql_ver_almacen);										
										
										
										$id_control_edit=$ver_consultar_sql_ver1['id']; 
										
									
									if($_GET['proceso']=='C0N5ULT4R_AJUSTE' and $_GET['token']=="$id_control_edit"){ ?>
										<form action="cpanel.php?control_menu=facturacion&condicion=ajuste-precio&proceso=EDITAR_AJUSTE_INVENTARIO&token=<?php echo $ver_consultar_sql_ver1['id']; ?>" method="POST" class="form-bordered" name='formulario'>
									<?php } ?>				
										
								    <tr>
                                       <!-- <td><?php echo $ver_consultar_sql_ver_almacen['nombre']; ?></td>-->
                                       <!-- <td><?php echo $ver_consultar_sql_ver['cod_producto']; ?></td>-->
                                        <td><?php// echo $ver_consultar_sql_ver_rubro['nombre'].'/'; ?> <?php echo $ver_consultar_sql_ver['cod_producto']; ?> - <?php echo $ver_consultar_sql_ver_marca['nombre']; ?> / <?php echo $ver_consultar_sql_ver['nombre_producto']; ?> </td>
										<td><?php echo $ver_consultar_sql_ver_medida['nombre']; ?></td>
										
										
										<!-- <td>
											 <?php if($_GET['proceso']=='C0N5ULT4R_AJUSTE' and $_GET['token']=="$id_control_edit"){ ?>
												<input name="cantidad" value="<?php echo $ver_consultar_sql_ver1['cantidad']; ?>" class="form-control" type='number' min='0' <?php if($monto_decimal>0) { echo 'step="any"'; }?> required="required" style="width:80px" />
											 <?php } else { ?>
												<?php echo $ver_consultar_sql_ver1['cantidad']; ?>
											 <?php } ?>
										 </td>-->
										 <td>
											<?php if($_GET['proceso']=='C0N5ULT4R_AJUSTE' and $_GET['token']=="$id_control_edit"){ ?>
												<input name="costo" value="<?php echo $ver_consultar_sql_ver1['costo']; ?>" class="form-control" type='number' min='0' <?php if($monto_decimal>0) { echo 'step="any"'; }?>  required="required" style="width:80px" />
											 <?php } else { ?>
												<?php echo $ver_consultar_sql_ver1['costo']; ?> <?php echo $moneda; ?>
											 <?php } ?>
										</td>
										 <td>
											<?php if($_GET['proceso']=='C0N5ULT4R_AJUSTE' and $_GET['token']=="$id_control_edit"){ ?>
												<input name="precio1" value="<?php echo $ver_consultar_sql_ver1['precio1']; ?>" class="form-control" type='number' min='0' <?php if($monto_decimal>0) { echo 'step="any"'; }?>  required="required" style="width:80px" />
											 <?php } else { ?>
												<?php echo $ver_consultar_sql_ver1['precio1']; ?> <?php echo $moneda; ?>
											 <?php } ?>
										 </td>
										 <td>
											<?php if($_GET['proceso']=='C0N5ULT4R_AJUSTE' and $_GET['token']=="$id_control_edit"){ ?>
												<input name="precio2" value="<?php echo $ver_consultar_sql_ver1['precio2']; ?>" class="form-control" type='number' min='0' <?php if($monto_decimal>0) { echo 'step="any"'; }?>  required="required" style="width:80px" />
											 <?php } else { ?>
												<?php echo $ver_consultar_sql_ver1['precio2']; ?> <?php echo $moneda; ?>
											 <?php } ?>
										 </td>		
										 <td>
											<?php if($_GET['proceso']=='C0N5ULT4R_AJUSTE' and $_GET['token']=="$id_control_edit"){ ?>
												<input name="precio3" value="<?php echo $ver_consultar_sql_ver1['precio3']; ?>" class="form-control" type='number' min='0' <?php if($monto_decimal>0) { echo 'step="any"'; }?>  required="required" style="width:80px" />
											 <?php } else { ?>
												<?php echo $ver_consultar_sql_ver1['precio3']; ?> <?php echo $moneda; ?>
											 <?php } ?>
										 </td>
										<!--<td>
										<?php if($_GET['proceso']=='C0N5ULT4R_AJUSTE' and $_GET['token']=="$id_control_edit"){ ?>
											<button type="submit" name="submit" value='GUARDAR' class="btn btn-success btn-sm" title="GUARDAR" > <i class="fa fa-floppy-o ml5"></i></button>	
										 <?php } else { ?>
										 <?php if($ver_consultar_sql_ver1['estatus']==0) {?>
										    <a href="cpanel.php?control_menu=facturacion&condicion=ajuste-precio&proceso=ESTATUS_AJUSTE_INVENTARIO&token=<?php echo $ver_consultar_sql_ver1['id']; ?>&estatus=<?php echo $ver_consultar_sql_ver1['estatus']; ?>"   title="ACTIVAR"  class="btn-warning btn-sm" ><i class="fa fa-ban"></i></a>
										 <?php } else { ?>	
											<a href="cpanel.php?control_menu=facturacion&condicion=ajuste-precio&proceso=ESTATUS_AJUSTE_INVENTARIO&token=<?php echo $ver_consultar_sql_ver1['id']; ?>&estatus=<?php echo $ver_consultar_sql_ver1['estatus']; ?>"   title="DESACTIVADAR"  class="btn-success btn-sm" ><i class="fa fa-check"></i></a>
										 <?php } ?>
											<a href="cpanel.php?control_menu=facturacion&condicion=ajuste-precio&proceso=C0N5ULT4R_AJUSTE&token=<?php echo $ver_consultar_sql_ver1['id']; ?>"   title="AJUSTAR"  class="btn-primary btn-sm" ><i class="fa fa-pencil"></i></a>
											<a href="cpanel.php?control_menu=facturacion&condicion=ajuste-precio&proceso=D3L3T3_AJUSTE_INVENTARIO&token=<?php echo $ver_consultar_sql_ver1['id']; ?>"   title="ELIMINAR"  class="btn-danger btn-sm" ><i class="fa fa-trash-o"></i></a>
										<?php }?>
										</td>-->
                                    </tr>
									<?php if($_GET['proceso']=='C0N5ULT4R_AJUSTE' and $_GET['token']=="$id_control_edit"){ ?>
										</form>
									<?php } ?>
									<?php }?>
                                </tbody>
                            </table>

					</div>
                </div>								
            </div>     
            </div>
        </div>
	</div>
</div>

<!-- FIN DE MODAL DE PRODUCTOS -->
<!--MODAL DE PRODUCTOS -->
    
<!-- FIN DE MODAL DE PRODUCTOS -->
<?php if($_GET['proceso']=='convenios') { ?>
<div class="locked">
            <div class="modal-dialog modal-lg">
              <div class="modal-content">
                  <div class="modal-header">
                      <a href='cpanel.php?control_menu=report-estadisticas&condicion=auditor_precios'><button aria-hidden="true" data-dismiss="modal" class="close" type="button">&times;</button></a>
                      <h4 class="modal-title">Convenios por clientes </h4>
                  </div>
				  <div class="panel-heading">
                      <p>La negociación se puede definir como un proceso de comunicación entre al menos dos partes dirigido a alcanzar un acuerdo sobre intereses que se perciben como divergentes.</p>
                  </div>
                  <div class="modal-body">
				  <!-- CONTROL DEL FORMULARIO -->
                     	<div class="alert alert-success fade in">
							<i class="fa-fw fa fa-success"></i>
								<strong>Recordar !</strong>Los precios deben estar reflejados en la siguiente moneda  <b> <?php echo $moneda; ?></b>
						</div>	
						<?php if($_GET['consulta']!='cliente') { ?>
							<form  enctype="multipart/form-data"  action="cpanel.php?control_menu=report-estadisticas&condicion=auditor_precios&proceso=convenios&consulta=cliente" method="POST" class="form-bordered" name='formulario'>
								<div class="col-sm-12">
									<select class="selectpicker" data-show-subtext="true" data-live-search="true" name="cod_cliente"  >
										<option value='' selected="true">Seleccionar un cliente</option>
										<?php
											$consultar_sql_ver=mysql_query("select * from  tabla_clintes_xls where eliminar='0' ORDER BY id DESC ",$link);
											while($ver_consultar_sql_ver=mysql_fetch_array($consultar_sql_ver)){ ?>
											 <option value='<?php echo $ver_consultar_sql_ver['id']; ?>'><?php echo $ver_consultar_sql_ver['rif']; ?> - <?php echo $ver_consultar_sql_ver['descripcion']; ?></option>
										<?php } ?>
									</select>                                             
								</div>
										<div class="pull-right">
											<a href='cpanel.php?control_menu=report-estadisticas&condicion=auditor_precios&' class="btn btn-default btn-sm">CERRAR</a>
											<button type="submit" name="submit" value='CONSULTAR' data-toggle="modal" data-target=".bs-example-modal-lg_precios" class="btn btn-success btn-sm">CONSULTAR <i class="fa fa-floppy-o ml5"></i></button>
										</div>
							</form>  
						<?php } else { 
							$cod_cliente=$_POST['cod_cliente'];
							$consultar_sql_ver=mysql_query("select * from  tabla_clintes_xls where id='$cod_cliente'  ",$link);
							$ver_consultar_sql_ver=mysql_fetch_array($consultar_sql_ver);	
									
									$consulta_convenios_global=mysql_query("select * from   tabla_convenios_global_xls where cod_cliente='$cod_cliente' and estatus='0' ORDER BY id DESC",$link);
									$ver_convenios_global=mysql_fetch_array($consulta_convenios_global);							
						?>
							<h3><?php echo $ver_consultar_sql_ver['rif']; ?> - <?php echo $ver_consultar_sql_ver['descripcion']; ?></h3>
						
							<form action="cpanel.php?control_menu=report-estadisticas&condicion=auditor_precios" method="POST" class="form-bordered" name='formulario'>
								<input type="hidden" id="cod_cliente" name="cod_cliente" value="<?php echo $cod_cliente; ?>" />
								<div class="col-sm-2">
								Saldo max credito $
									<input name="saldo_max_credito" value='<?php echo $ver_convenios_global['saldo_max_credito']; ?>' class="form-control input-sm mb15" min='0' type='hidden'  required="required"/>
								</div>	
								<div class="col-sm-2">
								Dias max credito
									<input name="dias_max_credito" value='<?php echo $ver_convenios_global['dias_max_credito']; ?>' class="form-control input-sm mb15" min='0' type='hidden'  required="required"/>
								</div>
								<div class="col-sm-3">
								Fact. max credito
									<input name="fact_max_credito" value='<?php echo $ver_convenios_global['fact_max_credito']; ?>' class="form-control input-sm mb15" min='0' type='hidden'  required="required"/>
								</div>	
								<div class="col-sm-3">
								Tolerancia en romana Klg.
									<input name="tolerancia_max_credito" value='<?php echo $ver_convenios_global['tolerancia_max_credito']; ?>' class="form-control input-sm mb15" min='1' type='hidden'  required="required"/>
								</div>	
								<br>
								<div class="pull-right">
									<button type="submit" name="submit" value='Guardar' class="btn btn-success btn-sm">GUARDAR <i class="fa fa-floppy-o ml5"></i></button>
								</div>
							</form>
						<br>
						<br>
						<br>
				
						<div class="input-group mb15 has-warning">
                            <span class="input-group-addon"><b>BUSCAR</b></span>
                            <input type="text" autofocus="autofocus" placeholder="Buscar productos" id="search" class="form-control" />
                        </div>
						<div class="table-responsive">
						<table id="employee_table" class="table table-striped table-bordered responsive">
                                <thead class="">
                                    <tr>
                                        <!-- <th>Almacen</th>-->
                                        <th>Descripcion del producto</th>
                                       <!-- <th>Unidad m.</th>-->
                                        <!--<th>Existencia</th>-->
                                        <!--<th>COSTO</th>-->
                                        <th>PRECIO 1</th>
                                        <th>PRECIO 2</th>
                                        <th>PRECIO 3</th>
                                        <th>PRECIO PREFERENCIAL</th>
                                    </tr>
                                </thead>
                                <tbody>

								<?php
								
									$consultar_sql_ver1=mysql_query("select * from tabla_producto_inventario where eliminar='0'  ",$link);
									while($ver_consultar_sql_ver1=mysql_fetch_array($consultar_sql_ver1)){
									$cod_producto=$ver_consultar_sql_ver1['cod_producto']; 
									
									$consultar_sql_ver=mysql_query("select * from  tabla_productos where eliminar='0' and id='$cod_producto' ",$link);
									$ver_consultar_sql_ver=mysql_fetch_array($consultar_sql_ver);
									$id_control_edit=$ver_consultar_sql_ver['cod_rubro']; 
									$id_control_cod_medida=$ver_consultar_sql_ver['cod_medida']; 
									$id_control_cod_marca=$ver_consultar_sql_ver['cod_marca']; 
									$cod_almacen=$ver_consultar_sql_ver1['cod_almacen']; 
									
									$consultar_sql_ver_rubro=mysql_query("select * from  tabla_rubro_categoria where id='$id_control_edit'",$link);
									$ver_consultar_sql_ver_rubro=mysql_fetch_array($consultar_sql_ver_rubro);

									$consultar_sql_ver_marca=mysql_query("select * from   tabla_marca where id='$id_control_cod_marca'",$link);
									$ver_consultar_sql_ver_marca=mysql_fetch_array($consultar_sql_ver_marca);	

									$consultar_sql_ver_medida=mysql_query("select * from   tabla_unidad_medida where id='$id_control_cod_medida'",$link);
									$ver_consultar_sql_ver_medida=mysql_fetch_array($consultar_sql_ver_medida);	

									$consultar_sql_ver_almacen=mysql_query("select * from tabla_almacen where id='$cod_almacen'",$link);
									$ver_consultar_sql_ver_almacen=mysql_fetch_array($consultar_sql_ver_almacen);										
										
									$consulta_convenios=mysql_query("select * from  tabla_convenios_precios_xls where cod_cliente='$cod_cliente' and cod_producto='$cod_producto' and estatus='0' ORDER BY id DESC",$link);
									$ver_convenios=mysql_fetch_array($consulta_convenios);
									
										$id_control_edit=$ver_consultar_sql_ver1['id']; 
										
									
									?>
											<tr>
												<form action="cpanel.php?control_menu=report-estadisticas&condicion=auditor_precios" method="POST" class="form-bordered" name='formulario'>
													<input type="hidden" id="cod_cliente" name="cod_cliente" value="<?php echo $cod_cliente; ?>" />
													<input type="hidden" id="cod_producto" name="cod_producto" value="<?php echo $cod_producto; ?>" />
													<td><?php echo $ver_consultar_sql_ver['nombre_producto']; ?> </td>
													<td><?php echo $ver_consultar_sql_ver1['precio1']; ?> <?php echo $moneda; ?> </td>
													<td><?php echo $ver_consultar_sql_ver1['precio2']; ?> <?php echo $moneda; ?> </td>		
													<td><?php echo $ver_consultar_sql_ver1['precio3']; ?> <?php echo $moneda; ?> </td>		
													<td><?php echo $ver_convenios['precio']; ?></td>
												</form>
											</tr>
								
									<?php } ?>
                                </tbody>
                            </table>
							</div>
									<div class="pull-right">
											<a href='cpanel.php?control_menu=report-estadisticas&condicion=auditor_precios' class="btn btn-default btn-sm">CERRAR</a>
									</div>	
						<?php } ?>	
						<br>
						<br>
						<br>
						<br>
				  </div>
              </div>
            </div>
        </div>
<?php } ?>


<!--MODAL RUBROS -->
<!-- FIN DE MODAL DE RUBROS -->
<!--MODAL DE MARCAS -->
<!-- FIN DE MODAL DE MARCAS -->
<!--MODAL DE MODELOS -->
<!-- FIN DE MODAL DE MODELOS -->
								 <script>  
								  $(document).ready(function(){  
									   $('#search').keyup(function(){  
											search_table($(this).val());  
									   });  
									   function search_table(value){  
											$('#employee_table tr').each(function(){  
												 var found = 'false';  
												 $(this).each(function(){  
													  if($(this).text().toLowerCase().indexOf(value.toLowerCase()) >= 0)  
													  {  
														   found = 'true';  
													  }  
												 });  
												 if(found == 'true')  
												 {  
													  $(this).show();  
												 }  
												 else  
												 {  
													  $(this).hide();  
												 }  
											});  
									   }  
								  });  
								  $(document).ready(function(){  
									   $('#searchx').keyup(function(){  
											search_table($(this).val());  
									   });  
									   function search_table(value){  
											$('#employee_tablex tr').each(function(){  
												 var found = 'false';  
												 $(this).each(function(){  
													  if($(this).text().toLowerCase().indexOf(value.toLowerCase()) >= 0)  
													  {  
														   found = 'true';  
													  }  
												 });  
												 if(found == 'true')  
												 {  
													  $(this).show();  
												 }  
												 else  
												 {  
													  $(this).hide();  
												 }  
											});  
									   }  
								  });  
							 </script> 