<?php ob_start(); ?>
<!-- 
1 pantalla
2 impresora
 -->
<?php $mobile= $_SESSION['user_mobile'];?>
<?php $touchs= $_SESSION['user_touchs'];?>
<?php //$orient= $_SESSION['orient'];?>

<?php include('../cfg/res.php');?>
<?php if(file_exists('../cfg/res.php')){include('../cfg/res.php');} ?>	
<?php if(file_exists('../cfg/config.php')){include('../cfg/config.php');}?>	

<?php if(empty($pobj)){$pobj=3;}?>
<?php if(empty($pdeci)){$pdeci=0;}?>
<?php if(empty($pmodi)){$pmodi=0;}?>
<?php if(empty($plimit)){$plimit=1;}?>
<?php if(empty($pdest)){$pdest=1;}?>
<?php if(empty($ptitle) || $pdest==2){$ptitle='';}?>
<?php if(empty($ptabla)){$ptabla='empr';}?>
<?php if(empty($pcodigo)){$pcodigo=$_SESSION['user_vcrx_empr'];}?>

<?php if(empty($pcaption)){$pcaption=$pcodi;}?>
<?php //if(empty($pcaption) && (mb_stristr('sist.supe',substr($_SESSION['user_vcrx_tipo'],0,4))) ){$pcaption=$ptabla;} ?>
<?php if(empty($pcolumn)){$pcolumn='descri';}?>

<?php if(empty($psize)){$psize="50";}?>
<?php if(empty($ponclick)){$ponclick="_clickimg('img_".$pidtxt."');";}?>
<?php $pfile = $pruta.$psrc;?>
<?php $pobj=1; ?>
<?php $plimit=1; ?>
<?php// echo $pruta;?>
<?php
// 		$sql_imgs='selec;'
// 		$res_imgs=mysql_query($sql_getcod,$link_vcrx);

		$sql_imgs='select * from '.$ptabla.'0 ';
		$sql_imgs.='where '.$ptabla.'_file is not null ';
		if($ptabla=='imgi'){$sql_imgs.='and '.$ptabla.'_item like "'.$pcodigo.'%" ';}
		if($ptabla=='imge'){$sql_imgs.='and '.$ptabla.'_enti like "'.$pcodigo.'%" ';}
		$sql_imgs.='and trim('.$ptabla.'_file)!="" ';
		$sql_imgs.='and '.$ptabla.'_status!="O" ';
		$sql_imgs.='and '.$ptabla.'_status!="X" ';
		$sql_imgs.='order by '.$ptabla.'_defa desc, '.$ptabla.'_file ';
		$sql_imgs.='limit '.$plimit;
		$res_imgs=mysql_query($sql_imgs,$link_vcrx);	

//  		echo explain_sql($sql_imgs);

?>



<?php if(mysql_num_rows($res_imgs)>0){ ?>
<!-- 	<table id="<?php echo 'tab_'.$pidtxt; ?>" cellpadding="0" width="100%" border="0"
					style="font-size:<?php echo $xfontsize; ?>px;border-collapse:collapse; background-color:white;"> -->
<!-- 	<table > -->
<!-- 	<tr> -->
	<?php if($pobj==3){ echo '<td width="15%">';} ?>
	<?php $crowi=0; ?>
	<?php //echo mysql_num_rows($res_imgs); ?>
	<?php $res_imgs=mysql_query($sql_imgs,$link_vcrx);	?>
	<?php //echo explain_sql($sql_imgs);?>
	<?php while ($aso_imgs=mysql_fetch_assoc($res_imgs)){  ?>
		<?php $crowi++; ?>
		<?php $pname=$aso_imgs[$ptabla.'_file'] ;?>
		<?php $pfile='../'.$ptabla.'/'.$pname;?>
		<?php //echo $pfile;?>
		<?php if(file_exists($pfile)){ ?>
			<?php //echo $crowi;?>
			<?php
				if($crowi==1)
				{
				$pfile1=$pfile;
				$sql_updt='update '.$ptabla.'0 set '.$ptabla.'_defa=1 where '.$ptabla.'_codigo='.$aso_imgs[$ptabla.'_codigo'].'';
				$res_updt=mysql_query($sql_updt,$link_vcrx);	
				}
			?>
			<?php if($pobj==2){ echo '<td align="center">';} ?>
			<?php if($pobj==3){ echo '<div align="center">';} ?>
			<?php //echo $pfile;?>
			<img  id="img_<?php echo $aso_imgs[$ptabla.'_file'];?>"
				src="<?php echo $pfile;?>" 
				style="border:solid;"
				width="<?php if($mobile=='true'){echo $psize*3;}else{echo $psize;}?>px"
				<?php if ($pobj==2){?>
					onclick="_clickimg('img_<?php echo $aso_imgs[$ptabla.'_file'];?>');" 
				<?php } ?>
				<?php if ($pobj==3){?>
					onmouseover="{document.getElementById('img1_<?php echo $pidtxt;?>').src=this.src;}"
				<?php } ?>
				title="<?php echo $pname;?>"
				valign="top"
			/>
			<?php if($pobj==2){echo '</td>';} ?>
			<?php if($pobj==3){ echo '</div>';} ?>
		<?php }else{ ?>
		<?php
			$sql_updt='update '.$ptabla.'0 set '.$ptabla.'_status="X" where '.$ptabla.'_codigo='.$aso_imgs[$ptabla.'_codigo'].'';
			$res_updt=mysql_query($sql_updt,$link_vcrx);	
		?>	
		<?php } ?>
		
	<?php } ?>
	<?php if($pobj==3){ echo '</td>';} ?>
<!-- 		<?php if($pobj==3 or 1==2){?>
		<td align="center" valign="top">
			<img id="img1_<?php echo $pidtxt; ?>"
				src="<?php echo $pfile1; ?>" 
				width="<?php if($mobile=='true'){echo $psize*9;}else{echo $psize*3;}?>px"
				onclick="<?php echo $ponclick;?>"
				onmouseover="<?php echo $ponmouse;?>"
				title="<?php echo $pfile1;?>"
				valign="top"
				/>
		</td>
		<?php } ?> -->
<!-- 	</tr> -->
<!-- 	</table> -->
<?php } ?>

<?php $pfile=''; ?>
<?php $psrc=''; ?>
<?php $pruta=''; ?>
<?php $psize=''; ?>
<?php $pobj=0; ?>
<?php $ponmouse=''; ?>
<?php $ponclick=''; ?>


<?php $pvalor=0; ?>
<?php $pdeci=0; ?>
<?php $pdest=0; ?>
<?php $ptitle=''; ?>

<?php $obstart = ob_get_clean(); ?>
<?php while(mb_stristr($obstart,'  ')){$obstart=str_replace('  ',' ',$obstart);} ?>
<?php while(mb_stristr($obstart,'\t\t')){$obstart=str_replace('\t\t','\t',$obstart);} ?>
<?php while(mb_stristr($obstart,'\n\n')){$obstart=str_replace('\n\n','\n',$obstart);} ?>
<?php echo $obstart; ?>
