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

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

<?php $orient=$_POST['orient']; ?>

<?php $fecha1=date('Y-m-01',strtotime ('-1 year')); ?>

<?php
$sql_updt='alter table item0 add column item_raiz varchar(13)';
$res_updt=mysql_query($sql_updt,$link_vcrx);

$sql_updt='alter table item0 add column item_ctlg varchar(1)';
$res_updt=mysql_query($sql_updt,$link_vcrx);

$sql_updt='update item0 set item_raiz=left(item_codigo,10) where length(trim(item_codigo))=10 or length(trim(item_codigo))=13';
$res_updt=mysql_query($sql_updt,$link_vcrx);

$sql_updt='update item0 set item_raiz=left(item_codigo,6) where length(trim(item_codigo))=6 or length(trim(item_codigo))=8';
$res_updt=mysql_query($sql_updt,$link_vcrx);
// echo $sql_updt;
// echo $res_updt;


$total_sql ='max(item_mrca) as tmrca,';
$total_sql ='max(item_nctlg) as tnctlg,';
$total_sql ='max(item_pctlg) as tpctlg,';
$total_sql.='max(item_modelo) as tmodelo,';
$total_sql.='max(item_tlla) as ttlla,';
$total_sql.='max(item_ice) as tice,';
$total_sql.='max(item_iva) as tiva,';
$total_sql.='max(item_irbp) as tirbp';


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

$hpant1 =ceil($screenh*0.30);
$hpant11=ceil($screenh*0.10);
$hpant2 =ceil($screenh*0.30);

$wpant1 =$screenw-20;
	
if ($orient=='V')
{
	$hpant1 =ceil($screenh*0.90);
	$hpant11=ceil($screenh*0.40);
	$hpant2 =ceil($screenh*0.90);
}

// TOTALES
// {
// 	$docuitem=0;
// 	$docuiimp=0;
// // 				$docuinve=0;
// 	$docudocu=0;
// 	$docurete=0;
// 	$docuctas=0;

	$dispcolu=1;
	if($mobile=='true'){$dispcolu=0;}
// }

?>

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

<?php if(mb_stristr('XLSX',$pant)) { ?>
<?php
$origen = $_FILES['archivo']['tmp_name'];
$destino="../upld_maes.xlsx";
// echo '***';
echo move_uploaded_file($origen,$destino);
	
$xlsfile="../upld_maes.xlsx";
$xlsx = new SimpleXLSX($xlsfile);
$hojas=	$xlsx->sheetNames();

// echo $hojas;	
	
for( $choja = 0; $choja <= count($hojas); $choja++)
{
	echo $hojas[$choja];
	echo '<br>';
	if(mb_stristr('item.item0',$hojas[$choja]))
	{
			$xfila=$xlsx->rows($choja);

			$xcabe= $xfila[0];
			for( $ccolu = 0; $ccolu <= count($xcabe); $ccolu++)
			{
				if($xcabe[$ccolu]=='codigo'){$col_codigo=$ccolu;}
				if($xcabe[$ccolu]=='descripcion'){$col_descri=$ccolu;}
				if($xcabe[$ccolu]=='descripcion2'){$col_descri2=$ccolu;}
				if($xcabe[$ccolu]=='linea'){$col_linea=$ccolu;}
				if($xcabe[$ccolu]=='sublinea'){$col_sublinea=$ccolu;}
				if($xcabe[$ccolu]=='marca'){$col_mrca=$ccolu;}
				if($xcabe[$ccolu]=='modelo'){$col_modelo=$ccolu;}
				if($xcabe[$ccolu]=='puni'){$col_puni=$ccolu;}
				if($xcabe[$ccolu]=='descri2'){$col_sublinea=$ccolu;} 
			}
		
// 		$date=new DateTime();
			echo date('H:i:s',strtotime('now'));
			for( $cfila = 1; $cfila <= count($xfila); $cfila++)
			{
				$xregi= $xfila[$cfila];

				
				if (trim($xregi[$col_descri])>'' and 1==1)
				{
				$xnewitem=new_item();
				
				$sql_regi='insert into item0(item_codigo)value('.$xnewitem.')';
				$res_regi=mysql_query($sql_regi,$link_vcrx);
				
				$sql_regi='update item0 set ';
				$sql_regi.='item_descri="'.$xregi[$col_descri].' /'.$xregi[$col_descri2].' /'.$xregi[$col_mrca].' /'.$xregi[$col_modelo].'", ';
				$sql_regi.='item_descri2="'.$xregi[$col_descri2].'", ';
				$sql_regi.='item_lineasub="'.$xregi[$col_linea].'-'.$xregi[$col_sublinea].'", ';
				$sql_regi.='item_mrca="'.$xregi[$col_mrca].'", ';
				$sql_regi.='item_modelo="'.$xregi[$col_modelo].'", ';
				$sql_regi.='item_puni="'.$xregi[$col_puni].'", ';
				$sql_regi.='item_status="-" ';
				$sql_regi.='where item_codigo="'.$xnewitem.'"';
				$res_regi=mysql_query($sql_regi,$link_vcrx);
				echo '<br>';
				echo '<br>';
				echo $sql_regi;
				echo '<br>';
				echo mysql_error();
				}
				
			}
// 			echo $xcolu[2];
// 				$sql_regi='update item0 set item_lsub="ACCA-RUTA" where item_lineasub like "%RUTA%" and item_lineasub like "%AC%"' ;
// 				$res_regi=mysql_query($sql_regi,$link_vcrx);
// 				echo mysql_error();
// 				$sql_regi='update item0 set item_lsub="ACRE-ESTA" where item_lineasub like "%ESTACIONA%"';
// 				$res_regi=mysql_query($sql_regi,$link_vcrx);
// 				echo mysql_error();
// 				$sql_regi='update item0 set item_lsub="COMP-COMP" where item_lineasub like "%COMPRESOR%"';
// 				$res_regi=mysql_query($sql_regi,$link_vcrx);
// 				echo mysql_error();
// 				$sql_regi='update item0 set item_lsub="TRDI-AUTO" where item_lineasub like "%DIESEL%" and item_lineasub like "%AUTO%"' ;
// 				$res_regi=mysql_query($sql_regi,$link_vcrx);
// 				echo mysql_error();
// 				$sql_regi='update item0 set item_lsub="TRDI-ELEC" where item_lineasub like "%DIESEL%" and item_lineasub like "%ELEC%"' ;
// 				$res_regi=mysql_query($sql_regi,$link_vcrx);
// 				echo mysql_error();
// 				$sql_regi='update item0 set item_lsub="TRDI-MECA" where item_lineasub like "%DIESEL%" and item_lineasub like "%MECA%"' ;
// 				$res_regi=mysql_query($sql_regi,$link_vcrx);
// 				echo mysql_error();
// 				$sql_regi='update item0 set item_lsub="TRDR-ECOR" where item_lineasub like "%DRIVE%" and item_lineasub like "%ECO%"' ;
// 				$res_regi=mysql_query($sql_regi,$link_vcrx);
// 				echo mysql_error();
// 				$sql_regi='update item0 set item_lsub="TRDR-ELEC" where item_lineasub like "%DRIVE%" and item_lineasub like "%ELECT%"' ;
// 				$res_regi=mysql_query($sql_regi,$link_vcrx);
// 				echo mysql_error();
// 				$sql_regi='update item0 set item_lsub="TRDR-MECA" where item_lineasub like "%DRIVE%" and item_lineasub like "%MECA%"' ;
// 				$res_regi=mysql_query($sql_regi,$link_vcrx);
// 				echo mysql_error();
// 				$sql_regi='insert into lsub0(lsub_codigo,lsub_descri) from select distinct item_lsub,item_lineasub from item0 where item_codigo like "88%" ';
// 				$res_regi=mysql_query($sql_regi,$link_vcrx);
// 				echo mysql_error();


	}

// 				$sql_regi='update item0 set item_sexo="1" where item_sexo="H"';
// 				$res_regi=mysql_query($sql_regi,$link_vcrx);
				
// 				$sql_regi='update item0 set item_sexo="2" where item_sexo="M"';
// 				$res_regi=mysql_query($sql_regi,$link_vcrx);
	
	
// 	if($hojas[$choja]=='Informes')
// 	{
// 			$xfila=$xlsx->rows($choja);

// 			$xcabe= $xfila[0];
// 			for( $ccolu = 0; $ccolu <= count($xcabe); $ccolu++)
// 			{
// 				if($xcabe[$ccolu]=='idPub'){$col_enti=$ccolu;}
// 				if($xcabe[$ccolu]=='mes'){$col_fecha=$ccolu;}
// 				if($xcabe[$ccolu]=='codTp'){$col_tipo=$ccolu;}
// 				if($xcabe[$ccolu]=='publicaciones'){$col_public=$ccolu;}
// 				if($xcabe[$ccolu]=='presentaciones'){$col_presen=$ccolu;}
// 				if($xcabe[$ccolu]=='horas'){$col_horas=$ccolu;}
// 				if($xcabe[$ccolu]=='revisitas'){$col_revisi=$ccolu;}
// 				if($xcabe[$ccolu]=='estudios'){$col_cursos=$ccolu;}
// 				if($xcabe[$ccolu]=='nota'){$col_concepto=$ccolu;}
// 			}

// 				$sql_regi='delete from jwrt1';
// 				$res_regi=mysql_query($sql_regi,$link_vcrx);
				
// 				$sql_regi='alter table jwrt1 AUTO_INCREMENT=1';
// 				$res_regi=mysql_query($sql_regi,$link_vcrx);
		
// 			for( $cfila = 1; $cfila <= count($xfila); $cfila++)
// 			{
// 				$xregi= $xfila[$cfila];

// 				$sql_regi='insert into jwrt1(docu,status,idate)value("RPC1","-",now())';
// 				$res_regi=mysql_query($sql_regi,$link_vcrx);
				
// 				$sql_regi='select max(idnum1) as idnum1 from jwrt1';
// 				$res_regi=mysql_query($sql_regi,$link_vcrx);
// 				$idnum1 = mysql_result($res_regi,0,'idnum1');
				
// 				$sql_regi='update jwrt1 set ';
// 				$sql_regi.='enti="'.$xregi[$col_enti].'", ';
// 				$sql_regi.='fecha="'.$xregi[$col_fecha].'01'.'", ';
// 				$sql_regi.='public="'.$xregi[$col_public].'", ';
// 				$sql_regi.='presen="'.$xregi[$col_presen].'", ';
// 				$sql_regi.='horas="'.$xregi[$col_horas].'", ';
// 				$sql_regi.='revisi="'.$xregi[$col_revisi].'", ';
// 				$sql_regi.='cursos="'.$xregi[$col_cursos].'", ';
// 				$sql_regi.='concepto="'.$xregi[$col_concepto].'", ';
// 				$sql_regi.='status="-" ';
// 				$sql_regi.='where idnum1='.$idnum1;
// 				$res_regi=mysql_query($sql_regi,$link_vcrx);
				
// 			}

// 	}

	
}


?> 
			
<?php } ?>
	
<?php //echo '*/*/*/'.uplctasuper();?>	
	
<?php if(mb_stristr('PANT0',$pant)) { ?>
<?php $fecha1=date('Y-m-01',strtotime ('-1 year')); ?>
<?php $fecha2=$fechaa; ?>
		<div id="pant0" style="border:solid 2px; overflow:auto;">
		<?php if($mobile=='true' and $orient=="V") { ?>
			<table id="tpant0" cellpadding="2" width="100%" border="0"
						 style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse; background-color:white;">
				<tr><?php $pidtxt='lsub';  $ptabla='lsub'; $ptodos=1; $psize=$xfontsize; $pcaption='LINEAS'; include('vrselopt.php'); ?></tr>
				<tr><?php //$pidtxt='lsub';  $ptabla='lsub'; $pnotob="1"; $psize=$xfontsize; $pcaption='LINEA'; include('vrgetcod.php'); ?></tr>
				<tr><?php $pidtxt='item';  $ptabla='item'; $pnotob="1"; $psize=$xfontsize; $pcaption='ITEM'; include('vrgetcod.php'); ?></tr>
				<tr><?php $pidtxt='stat'; $pcaption='status'; $ptabla='stat'; $pnotob="1"; $psize=$xfontsize; include('vrgetcod.php'); ?></tr>
			</table>	
			<br>
			<table id="tpant00" cellpadding="2" width="100%" border="0"
						 style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse; background-color:white;">
				<tr>
					<td align="center" width="50%">
					<?php $pidtxt='consul'; $pcaption='Consultar '.$docu; $ponclick='upld_maes("PANT1","'.$docu.'")'; $psize=$xfontsize; include('vrbutton.php'); ?>
					</td>
					<td>
						<?php 	$pidtxt='subir'; $pcaption='Subir'; $ponclick='upld_maes("XLSX","'.$pidtxt.'")'; include('vrgetfil.php'); ?>
					</td>
					
					<td align="center">
					<?php $pidtxt='nueva'; $pcaption='Nuevo'; $ponclick='upld_maes("PANT1")'; $psize=$xfontsize; include('vrbutton.php'); ?>
					</td>
					<td align="center">
					<?php $pidtxt='detadocu'; $pcaption='Detalle'; $ponclick='upld_maes("DETA")'; $psize=$xfontsize; $pdefa=0; include('vrchkbox.php'); ?>
					</td>
				</tr>
			</table>			
			<br>
		<?php }else{ ?>
			<table id="tpant0" cellpadding="2" width="100%" border="0"
					 style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse; background-color:white;">
				<tr>
					<td>
						<table width="100%" cellpadding="2" width="100%" border="0"
									style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse; background-color:white;">
							<tr>
								<td>
									<table width="100%" cellpadding="2" width="100%" border="0"
												style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse; background-color:white;">
										<tr>
											<td><?php $pidtxt='lsub'; $ptabla='lsub'; $ptodos="1"; $psize=$xfontsize; $pcaption='LINEA'; include('vrselopt.php'); ?></td>
										</tr>
										<tr>
											<td><?php// $pidtxt='lsub'; $ptabla='lsub'; $pnotob="1"; $psize=$xfontsize; $pcaption='LINEA'; include('vrgetcod.php'); ?></td>
										</tr>
										<tr>
											<td><?php $pidtxt='item'; $ptabla='item'; $pnotob="1"; $psize=$xfontsize; $pcaption='ITEM'; include('vrgetcod.php'); ?></td>
										</tr>
										<tr>
											<td><?php $pidtxt='stat'; $pcaption='status'; $ptabla='stat'; $pnotob="1"; $psize=$xfontsize; include('vrgetcod.php'); ?></td>
										</tr>
									</table>
								</td>
								<td><?php $pidtxt='consul'; $pcaption='Consultar '.$docu; $ponclick='upld_maes("PANT1","'.$docu.'")'; $psize=$xfontsize; include('vrbutton.php'); ?></td>
								<td>
									<?php 	$pidtxt='subir'; $pcaption='Subir'; $ponclick='upld_maes("XLSX","'.$pidtxt.'")'; include('vrgetfil.php'); ?>
								</td>
								<td><?php $pidtxt='nuevo'; $pcaption='Nuevo'; $ponclick='upld_maes("PANT1");'; $psize=$xfontsize; include('vrbutton.php'); ?></td>
								<td><?php $pidtxt='detadocu'; $pcaption='Detalle'; $ponclick='upld_maes("DETA");'; $psize=$xfontsize; $pdefa=0; include('vrchkbox.php'); ?></td>
							</tr>
						</table>
					</td>	
				</tr>	
			</table>
		<?php } ?>
		</div>	
		<div id="pant1" style="border:solid 1px; overflow:auto; font-family:arial;"></div>
		<hr>
		<div id="pant11" style="border:solid 1px; overflow:auto; font-family:arial; display:none;"></div>
		<div id="pant2"  style="border:solid 1px; overflow:auto; font-family:arial; display:none;"></div>
		<div id="pant9"></div>
<?php } ?>			
	
<?php if(mb_stristr('PANT1',$pant)) { ?>
	<?php { 
		
		$sql_pant='select * from item00 ';
		$sql_pant.=' where item_codigo*1>100000 and item_status!="X" ';
		$sql_pant.=' and item_lused>="'.$fecha1.'"';
		if($lsub!=""){$sql_pant.=' and (item_lsub like "'.$lsub.'%" or lsub_descri like "%'.$lsub.'%")';}
		if($item!=""){$sql_pant.=' and (item_codigo like "'.$item.'%" or item_descri like "%'.$item.'%")';}
		if($stat!=""){$sql_pant.=' and (item_status="'.$stat.'")';}

		$sql_tpant=str_replace('select *','select *,'.$total_sql,$sql_pant);
// 		$sql_pant=str_replace('select *','select *,'.$total_sql,$sql_pant);
// 		$sql_tpant=$sql_pant;
	
// 		{$sql_pant.=' group by item_raiz';}	

// 		$sql_pant.=' order by lsub_descri, item_descri, item_codigo';
		$sql_pant.=' order by lsub_descri, item_codigo ';

		$res_pant=mysql_query($sql_pant,$link_vcrx);
		$res_tpant=mysql_query($sql_tpant,$link_vcrx);

	
		$tmarca=mysql_result($res_tpant,0,'tmarca');
		$tmodelo=mysql_result($res_tpant,0,'tmodelo');
		$ttlla=mysql_result($res_tpant,0,'ttlla');
// 		$tsubt=mysql_result($res_tpant,0,'stsubt');
// 		if($docuiimp==1)
// 		{
// 			$tsubtiva0=mysql_result($res_tpant,0,'stsubtiva0');
// 			$tsubtiva=mysql_result($res_tpant,0,'stsubtiva');
// 			$tdcto=mysql_result($res_tpant,0,'stdcto');
// 			$tice=mysql_result($res_tpant,0,'stice');
// 			$tiva=mysql_result($res_tpant,0,'stiva');
// 			$tirbp=mysql_result($res_tpant,0,'stirbp');
// 		}

	
// 		if($dispcolu=='true')
// 		{
// 			$tsubt=0;
// 			$tsubtiva=0;	
// 			$tsubtiva0=0;
// 			$tdcto=0;
// 			$tiva=0;
// 			$tice=0;
// 			$tirbp=0;

// 			$trrta=0;
// 			$triva=0;
// 		}

	}	?>

	
	<?php $crow=0; ?>
	<?php $ccol=0; ?>
	<?php $tnumero=0; ?>
	<?php //echo '***'.date('H:i:s') .'<br>';?>
	<pant1>
						<?php //explain_sql($sql_pant); die();?>

		<table id="tpant1" class="pant1" border="0"
					 onclick="resizeTab('<?php echo "tpant1"?>','');"
					 align="center" border="0" cellpadding="3" width="100%"
					 style="font-size:<?php if($mobile=='true'){echo $xfontsize-8;}else{echo $xfontsize;} ?>px;
									 border-collapse:collapse;background-color:white;"
						 >
			<?php { // THEAD ?>
			<thead style="display:block; <?php if($mobile!='true'){echo 'max-width:'.($screenw-20).'px;';} ?>;background-color:#eee;">
				<tr style="border-bottom:solid 1px; cursor:pointer;" title="Reordenar">
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);" title="Imprimir">I</th>
					<th onclick="sortTable(this,0<?php $ccol++; ?>);" title="Detalle" style="<?php if($dispcolu==0){echo'display:none;';}?>">D</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);">LINEA</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);">CODIGO</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);">DESCRIPCION</th>
					<?php if($tmarca!=""){?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);">MARCA</th>
					<?php } ?>
					<?php if($tmodelo!=""){?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);">MODELO</th>
					<?php } ?>
					<?php if($ttlla!=""){?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);">TALLA</th>
					<?php } ?>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);">STOCK</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);">PVP</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);">ONLINE</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);">ST</th>
					<th <?php$ccol++;?> >OX</th>
					<th onclick="sortTable(this,<?php echo $ccol++; ?>);"></th>
				</tr>
			</thead>
			<?php } ?>
			<?php { // TBODY ?>
			<tbody id="tpant1b" style="overflow-y:auto; display:block; 
							<?php if($orient=='V'){echo'min-height:'.($hpant1-7).'px;';}		else{echo'min-height:'.($hpant1-75).'px;';}  ?> 
							<?php if($orient=='V'){echo'height:'.($hpant1-7)*(2.4).'px;';}	else{echo'height:'.($hpant1-75)*(2.4).'px;';}  ?> 
							">
				<?php while($aso_pant=mysql_fetch_assoc($res_pant)){ ?>
				<?php $crow++; ?> 
				<?php $pvp1=$aso_pant['item_puni']; ?>
				<?php $duni=$aso_pant['item_duni']; ?>
				<?php //$item_codigo=str_replace(trim($aso_pant['item_tlla']),'',$aso_pant['item_codigo']); ?>
				<?php $item_codigo=$aso_pant['item_codigo'];?>
				<?php $item_raiz=$aso_pant['item_raiz'];?>
				<?php $item_descri=str_replace(trim($aso_pant['tlla_descri']),'',$aso_pant['item_descri']); ?>
				<?php $item_modelo=substr($aso_pant['item_modelo'],0,6);?>
				<?php if($item_raiz==""){$item_raiz=$item_codigo;} ?>
				<?php //$struc=$aso_pant['item_struc']; ?>
				<tr id="tr_fila<?php echo $crow;?>" class="tr_fila" valign="top" height="<?php //if($mobile=='true'){echo '55px';};?>"
						style="<?php if ($crow%5==0){echo 'border-bottom:dotted 1px;'; } ?> "
						onclick="_filabg(event,'tr_fila','<?php echo $crow; ?>','');
										upld_maes('PANT2','<?php echo $item_codigo; ?>');
										 "
						ondblclick="{document.getElementById('detadocu').checked='true';document.getElementById('detadocu').onchange();this.onclick();}"
						>
					<td align="center"><span style="display:none;"><?php echo fillzero($crow,5); ?></span>
					<?php ?>
					</td>
					<td align="center" style="<?php if($dispcolu==0){echo'display:none;';}?>" title="<?php echo 'ID:'.$item_codigo;?>"
							onclick="
										<?php if($touchs=='false'){?>
										upld_maes('PANT2','<?php echo $item_codigo; ?>');
										<?php } ?>
										 ">
						<?php if($mobile!='true'){$pidtxt='radio'.'tr_fila'.$crow; $pname='rtr_fila'; $pcaption=''; $psize=$xfontsize; include('vrradio.php');} ?>
					</td>
					<td align="center">
						<div style="display:none;"><?php echo $aso_pant['lsub_descri']; ?></div>
						<?php echo $aso_pant['lsub_descri']; ?>
					</td>
					<td align="left"><?php echo $aso_pant['item_codigo']; ?></td>
					<td align="left"><?php echo $item_descri; ?></td>
					<?php if($tmarca!=""){?>
					<td align="center"><?php echo $aso_pant['mrca_descri']; ?></td>
					<?php } ?>
					<?php if($tmodelo!=""){?>
					<td align="left"><?php echo $aso_pant['item_modelo']; ?></td>
					<?php } ?>
					<?php if($ttlla!=""){?>
					<td align="center"><div style="display:none;"><?php echo $aso_pant['item_tlla']; ?></div>
						<?php echo $aso_pant['tlla_descri']; ?>
					</td>
					<?php } ?>
					<td align="center"><?php echo number_format(sal_item($aso_pant['item_codigo']),$duni); ?></td>
					<td align="right" style="">
						<div style="display:none;"><?php echo fillzero($aso_pant['item_pvp0'],15); ?></div>
						<?php echo number_format(abs($aso_pant['item_pvp0']),2); ?>
					</td>	
					<td align="center">
						<?php $pidtxt='chkctlg'.$aso_pant['item_codigo'];  $pdefa=$aso_pant['item_ctlg']; $ptabla='item'; $pline=$aso_pant['item_codigo']; $pcolu='ctlg'; include('vrchkbox.php'); ?>
					</td>
<!-- 					<td valign="top"> -->
<!-- 							<?php
							$sql_imgi='select * from imgi0 ';
							$sql_imgi.='where imgi_item like "'.$item_modelo.'%" ';
							$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_file ';
							$sql_imgi.='limit 1';
							$res_imgi=mysql_query($sql_imgi,$link_vcrx);
						?>
						<?php if(mysql_num_rows($res_imgi)>0){?>
						<?php
							$sql_defa='update imgi0 set imgi_defa=1 where imgi_codigo="'.mysql_result($res_imgi,0,'imgi_codigo').'"';
							$res_defa=mysql_query($sql_defa,$link_vcrx);
							$res_imgi=mysql_query($sql_imgi,$link_vcrx);
						?>
								<?php while($aso_imgi=mysql_fetch_assoc($res_imgi))	{ ?>
								<?php $imgfile=$aso_imgi['imgi_file'];?>
								<?php if(file_exists('../imgi/'.$imgfile)){?>
									<img id="img_<?php echo $imgfile;?>"
											 src="../imgi/<?php echo $imgfile;?>" 
											 width="50px" 
											 onclick="_clickimg('img_<?php echo $imgfile;?>');" 
											 onmouseover="" 
											 title="<?php echo $imgfile;?>"
											 >
									<div id="imgs_<?php echo $imgfile;?>" style="display:none;">
									</div>
								<?php } ?>
								<?php } ?>
						<?php } ?>

										 -->
<!-- 									</td> -->
					<td align="center"><?php echo $aso_pant['item_status']; ?></td>
					<td align="center" >
					<?php
						if($aso_pant['item_status']!='O' and $aso_pant['item_status']!='X'){$tnumero++;}
						if($aso_pant['item_status']=='O')
						{$pcaption='Eliminar: '.$aso_pant['docu'].'-'.$aso_pant['codigo']; $pabrev='X';}
						if(!mb_stristr('ROX',$aso_pant['item_status']))
						{$pcaption='Anular: '.$aso_pant['docu'].'-'.$aso_pant['codigo']; $pabrev='O';}
						if(!mb_stristr('RX',$aso_pant['item_status']))
						{
							$pidtxt='anul'.'tr_fila'.$crow; $pname='itr_fila';
							$pcodigo=$aso_pant['item_codigo'];$pdocu=$aso_pant['docu'];
							$psize=$xfontsize;
							$ponclick='upld_maes("PANTX","'.$aso_pant['item_codigo'].'")';
							include('vrbutton.php');
						}
					?>
					</td>
					<td valign="top">
						<?php $pidtxt=$item_raiz; $ptabla='imgi'; $pcodigo=$item_raiz; $pobj=1; $plimit=1; include('vrsayimgs.php');?>
					</td>
				</tr>
								<?php } ?>
			</tbody>
		<?php } ?>	
			<?php { // FOOT ?>
			<tfoot style="display:block; <?php if($mobile!='true'){echo 'max-width:'.($screenw-20).'px;';} ?>;background-color:#eee;">
				<tr style="border-top:solid 1px;">
					<?php echo str_repeat('<th></th>',$ccol);?>
				</tr>
			</tfoot>
			<?php } ?>	
		</table>
	<pant1>
	<?php //echo '***'.date('H:i:s') .'<br>';?>
				
<?php } ?>			
			
<?php if(mb_stristr('PANT2',$pant)) { ?>

<?php {
	$sql_pant ='select * from item00 where item_codigo="'.$item.'"';

	$sql_tpant =str_replace('select *','select *,'.$total_sql,$sql_pant);

	$res_pant=mysql_query($sql_pant,$link_vcrx); 
	$item_codigo=mysql_result($res_pant,0,'item_codigo');
	$item_descri=mysql_result($res_pant,0,'item_descri');
	$item_raiz=mysql_result($res_pant,0,'item_raiz');
{
// 	$res_tpant=mysql_query($sql_tpant,$link_vcrx); 
// 	$tsubt=mysql_result($res_tpant,0,'stsubt');
// 	$tcant=mysql_result($res_tpant,0,'stcant');

}
// explain_sql($sql_pant);
}	?>

<pant11>
<?php //echo explain_sql($sql_pant); ?>
	<div style="font-size:<?php echo $xfontsize; ?>px;">
		<table border="0" width="<?php if($orient=='V'){echo '200%';}else{echo '100%';} ?>" cellpadding="2" width="100%"
						style="font-size:<?php if($mobile=='true'){echo $xfontsize-12;}else{echo $xfontsize;} ?>px;
										max-height:<?php echo $hpant11-15; ?>px;
										border-collapse:collapse; background-color:#eee;">
			<tr valign="top" >
				<td width="10%">
					<?php
							$pcaption='Imprimir: '.$item_codigo.'-'.$item_descri; $pabrev='I';
							$pcodigo=$item_codigo;
							$psize=$xfontsize;
// 							$ponclick='print_docu("'.mysql_result($res_tpant,0,'docu').'","'.mysql_result($res_tpant,0,'item_codigo').'")';
							$ponclick='{window.open("print1.php?item='.$item_codigo.'&idnum='.$item_codigo.'","_blank")}';
 							include('vrbutton.php');
					?>
				</td>
				<td style="font-weight:bold; font-size:80%" width="10%">
					<?php echo $item_descri.'<br>'.$item_codigo; ?><br>
					<?php echo 'RAIZ: '.$item_raiz; ?>
				</td>
				<td>
				</td>
				<?php $crow=0; ?>
				<?php $ccol=0; ?>
				<?php
					$sql_imgi='select * from imgi0 ';
					$sql_imgi.='where imgi_item like "'.$item_raiz.'%" ';
					$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_file ';
					$res_imgi=mysql_query($sql_imgi,$link_vcrx);	
				// 	echo explain_sql($sql_imgi);
				?>
				<?php $numrows=mysql_num_rows($res_pant); ?>
						<?php if(mysql_num_rows($res_imgi)>0){?>
								<?php while($aso_imgi=mysql_fetch_assoc($res_imgi))	{ ?>
								<?php $imgfile=$aso_imgi['imgi_file'];?>
								<?php if(file_exists('../imgi/'.$imgfile)){?>
				<td id="imgi<?php echo $aso_imgi['imgi_codigo'];?>"; align="center" valign="center" style="">
					<?php //echo 'DF '.$aso_imgi['imgi_defa'];?>
				<?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'); ?>
<!-- 					<br><br> -->
									<img id="img_<?php echo $imgfile;?>"
											 src="../imgi/<?php echo $imgfile;?>" 
											 width="50px" 
											 onclick="_clickimg('img_<?php echo $imgfile;?>');" 
											 onmouseover="" 
											 title="<?php echo $imgfile;?>"
											 >
<!-- 					<br><br> -->
				<?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'].")');
								}}"; 
						include('vrbutton.php'); ?>
					
				</td>
								<?php } ?>
								<?php } ?>
						<?php } ?>
			</tr>
		</table>
<!-- 		."upld_maes('PANT2','".$item_raiz."','".$item_raiz."')"; -->
		<?php $pcaption='SUBIR FOTOS'; $pidtxt='imgi'; $paccept=".JPG"; $pobj=3;
					$ponclick="upl_imgi('".$pidtxt."','".$item_codigo."');";
					include('vrgetfil.php'); ?>
	</div>
</pant11>
	
<pant2>
</pant2>
		
<?php } ?>			

<?php if(mb_stristr('IMGS2',$pant)) { ?>

<?php {
	$sql_imgi = 'select * from imgi0 where imgi_status!="O" and imig_status!="X" and imgi_item="'.$item.'" order by imgi_defa desc, imgi_file';
	$res_imgi=mysql_query($sql_imgi,$link_vcrx); 
	// explain_sql($sql_pant);
}	?>

<?php if (mysql_num_rows($res_imgi)>0){?>
	<?php while($aso_imgi=mysql_fetch_assoc($res_imgi))	{ ?>
	<?php $imgfile=$aso_imgi['imgi_file'];?>
	<?php if(file_exists('../imgi/'.$imgfile)){?>
		<img id="img_<?php echo $imgfile;?>"
				 src="../imgi/<?php echo $imgfile;?>" 
				 width="50px" 
				 onclick="_clickimg('img_<?php echo $imgfile;?>');" 
				 onmouseover="" 
				 title="<?php echo $imgfile;?>"
				 >
	<?php } ?>
	<?php } ?>
		
<?php } ?>
		
<?php } ?>			
		
		
</resultado>

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

		