<?php die(); ?>
<?php session_start();?>
<?php include('../_cfg/config.php');?>
<?php include('php_gene1.php'); ?>
<?php include('php_session.php');?>

<?php $orient=$_POST['orient']; ?>
<?php $pant=$_POST['pant']; ?>
<?php //$ctlg=$_POST['ctlg']; ?>
<?php //$docu=$_POST['docu']; ?>
<?php //$idnum=$_POST['idnum']; ?>
<?php //$item=$_POST['item']; ?>
<?php //$lsub=$_POST['lsub']; ?>
<?php //$buscar=$_POST['buscar']; ?>
<?php //$stat=$_POST['stat']; ?>
<?php //$fecha1=$_POST['fecha1']; ?>
<?php //$fecha2=$_POST['fecha2']; ?>

<?php foreach($_POST as $campo => $valor){${$campo}=$valor;} ?>

<?php
$itemxlin=4;

if($mobile=='true' and $orient=='V')
{$itemxlin=1;}



if($user_codigo==''){die ('<msgalert>Usuario desconectado...</msgalert>');}


$verpvp=0;
if($user_tipo!='invi' and $user_tipo!=''){$verpvp=1;}

$xfontsize=12;
if($mobile=='true' and $orient=='V'){$xfontsize=30;}

if($oswin==0 and $screenr>=75){$xfontsize=20;}

$verpvp=1;


$sel_bus='';
$busca=strtoupper(alltrim($buscar));
$busca=explode(' ',$busca);
for ($cbusca=0; $cbusca<count($busca); $cbusca++)
{
	$sel_bus.='and (';
	$sel_bus.='item_codigo like "'.$busca[$cbusca].'%"';
	$sel_bus.='or item_codigov like "%'.$busca[$cbusca].'%"';
	$sel_bus.='or item_descri like "%'.$busca[$cbusca].'%"';
	$sel_bus.=')';
}


$sql_ctlg ='select * from item0 ';
$sql_ctlg.=' where 1=1 ';
if($item!="")
{
  $sql_ctlg.=' and (trim(item_codigo) like "'.$item.'"';
  $sql_ctlg.=' or trim(item_codigov) like "'.$item.'"';
  $sql_ctlg.=' or trim(item_ean) like "'.$item.'")';
}

if($buscar!=""){$sql_ctlg.=$sel_bus;}
if($item==''){$sql_ctlg='';}

$res_ctlg=msql_query($sql_ctlg,$link_vcrx);
$numrows=msql_num_rows($res_ctlg);
$item=msql_result($res_ctlg,0,'item_codigo');


?>

<?php ob_start(); ?>
<resultado>
<?php val_usercodigo(); ?>  
<pant1>

<div id="taginicial" style="float:inherit;"></div>		
<div width="100%" style="overflow:auto;">
<?php if($mobile=='true'){?>	
<br>
<?php } ?>
	
<?php $classtab='filtro'; ?>
<?php $classcol=$classtab.'_coligua'; ?>
<div style="height:20px;"></div>  
<table id="filtro" cellpadding="2" width="100%" border="0" class="<?php echo $classtab?>"
			 onclick="resizeTab('<?php echo $classtab?>','<?php echo $classcol; ?>');"  onmouseover="this.onclick();"
			style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse;  ">
<!-- 	<tr> -->
<!--     <td> -->
<!--       <table> -->
          <tr align="center">
          <?php $pidtxt='item'; $ptabla='item'; $psize=$xfontsize; $pcaption='ITEM'; $pvalue=$item; $pobj=3; 
            $ponblur="{document.getElementById('consul').click();}";
            $pnotob=0;
            include('vrgetcod.php'); ?>
          </tr>
<!--       </table> -->
<!--     </td> -->
<!--   </tr> -->

  <tr>
    <td width="10%" colspan="2">
      <?php $pidtxt='consul';  $pcaption='CONSULTAR'; $psize=$xfontsize; 
      $ponclick ='';
//       $ponclick.='{document.getElementByID("item").onblur();}';
      $ponclick.='{setTimeout(() => {console.log("World!");},5000);}';
      $ponclick.='{location.href="?scri=upld_imgi';
//       $ponclick.='&lsub="+document.getElementById("lsub").value+"';
//       $ponclick.='&buscar="+document.getElementById("buscar").value+"';
      $ponclick.='&item="+document.getElementById("item").value+"';
      $ponclick.='"}';
      include('vrbutton.php'); ?>
    </td>
  </tr>
   
</table>	
<?php if($mobile=='true'){?>	
<br>
<?php } ?>
</div>
	<?php //echo '**'.$user_tipo;?>
<hr>
<?php $crow=0; ?>
<?php $ccol=0; ?>
<?php 
//   echo explain_sql($sql_ctlg);
  ?>
	
<?php if($numrows==0){?>
	<?php echo 'NO SE ENCONTRARON RESULTADOS'; ?>
<?php }else{ ?>
  <div style="font-size:<?php echo $xfontsize*(1.5); ?>;">
  <?php //echo $numrows.' Resultados'; ?>
  </div>
<?php } ?>
		<table id="getf" cellpadding="2" border="0" align="center"
						 style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse;  ">
      <tr>
				<td>
          <?php //echo '*/*/'.$mobile; ?>
					<?php $pcaption='SUBIR FOTOS'; $pidtxt='imgi'; $paccept=".JPG"; $pobj=3; $psize=$xfontsize;
								$ponclick="upl_imgi('".$pidtxt."','".$item."');location.reload(); ";
								include('vrgetfil.php'); ?>
				</td>
      </tr>
      
        
      </table>

  <hr size="5" noshade>
<?php msql_data_seek($res_ctlg,0); ?>	
<?php while($aso_ctlg=msql_fetch_assoc($res_ctlg)){ ?>
	<?php $crow++; ?> 
	<?php
		$item_codigo=$aso_ctlg['item_codigo'];
		$item_rfer=$aso_ctlg['item_rfer'];
		$item_codigov=$aso_ctlg['item_codigov'];
		$item_raiz=$aso_ctlg['item_raiz'];
		$item_descri=$aso_ctlg['item_descri'];
		$item_modelo=substr($aso_ctlg['item_modelo'],0,6);
    if(empty($item_rfer)){$item_rfer=$aso_ctlg['item_codigo'];}                                                 
	?>
	<div align="center" style="border:solid 0px;	float:left;
				<?php if($orient=='H' and $user_tipo=='invi'){echo'width:99%;padding:1%;';}?>
				<?php if($orient=='H' and $user_tipo!='invi' and $verpvp==0){echo'width:99%;padding:1%;';}?>
				<?php if($orient=='H' and $user_tipo!='invi' and $verpvp==1){echo'width:99%;padding:1%;';}?>
			 ">
    
		<table id="tpant1" cellpadding="2" border="0" align="center"
						 style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse;  ">
			<tr valign="top">
				<td width="<?php if($orient=='V'){echo "50%";}else{echo "40%";}?>" align="center" colspan="2"
						style="font-size:<?php echo $xfontsize;?>px; ">
							<div style="font-weight:bold;">
							<?php echo 'CODIGO : '.$item_codigov; ?>
							</div>
					
              <div style="font-size:<?php if($orient=='V'){echo $xfontsize*(1.5);}else{ echo $xfontsize*(1.2);};?>px;">
              <?php echo $item_descri; ?>
              </div>
         </td>

      </tr>
      </table>
    
				<?php
//           $item_rfer=                                       
                                                 
					$sql_imgi='select * from imgi0 ';
					$sql_imgi.='where imgi_item like "'.$item_rfer.'%" ';
					$sql_imgi.='and imgi_file is not null ';
					$sql_imgi.='and imgi_status!="O" ';
					$sql_imgi.='and imgi_status!="X" ';
					$sql_imgi.='order by imgi_defa desc, imgi_item, imgi_file ';
					$res_imgi=msql_query($sql_imgi,$link_vcrx);	
        ?>
				<?php $numrows=msql_num_rows($res_pant); ?>
        <?php if(msql_num_rows($res_imgi)!=0){?>
		<table id="tpant1" cellpadding="2" border="0" align="center"
						 style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse;  ">
			<tr align="center" valign="top">
            <?php while($aso_imgi=msql_fetch_assoc($res_imgi)){ ?>
            <?php if($citem%$itemxlin==0){echo '</tr><tr>';}?>
             <?php $citem++; ?>
      <td align="center" valign="top" width="<?php echo 100/$itemxlin; ?>%">
            <?php $imgfile=$aso_imgi['imgi_file'];?>
                <?php if(file_exists('../imgi/'.$imgfile)){?>
		            <hr size="5" noshade>
                <div id="imgi<?php echo $aso_imgi['imgi_codigo'];?>">
                  
                <div  style="float:left;">
                <?php
                    $pidtxt='radio'.'tr_imgi'.$crow; $pname='rtr_imgi'; $pcaption='';
                    $ponclick="{php_func('imgi_defa(".$aso_imgi['imgi_codigo'].")')}";
                    $pdefa=$aso_imgi['imgi_defa'] ;$psize=$xfontsize; include('vrradio.php'); 
                ?>
                </div>  
                <div  style="float:right;">
                <?php
                    $pidtxt='elim'.$aso_imgi['imgi_codigo']; $pcaption='Eliminar '; $psize=$xfontsize; $pabrev="X";
                    $ponclick="{if(confirm('Eliminar : '+'".$aso_imgi['imgi_file']."'))
                        {
                        document.getElementById('imgi".$aso_imgi['imgi_codigo']."').style.display='none';
                        php_func('imgi_dele(".$aso_imgi['imgi_codigo'].")');
                        location.reload(); 
                        }}"; 
                    include('vrbutton.php');
                ?>
                </div>
                <div>
                  <img id="imgi<?php echo $aso_imgi['imgi_codigo'];?>"
                       src="../imgi/<?php echo $imgfile;?>" 
                       width="50%" 
                       onclick="_clickimg('img_<?php echo $imgfile;?>');" 
                       onmouseover="" 
                       title="<?php echo $imgfile;?>"
                       >
                </div>
                  
                </div>
                  
              <?php } ?>        
      </td>
        
            <?php } ?>        
      </tr>
        <?php } ?>        
    </table>
        
		<hr size="5" noshade>
					
	</div>
<?php}?>
<div id="tagfinal" style="float:inherit;"></div>		
	
<?php $pant='X';?>
	
		
</pant1>		
</resultado>

<?php $obstart = ob_get_clean(); ?>
<?php $obstart = alltrim($obstart) ?>
<?php echo $obstart;	?>

		