<?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 $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 if(empty($pant)){$pant='PANT0';} ?>

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

<?php if(mb_stristr('M3U',$pant)) { ?>
<?php
$exte = substr($_FILES['ffile']['name'],-3);
$origen = $_FILES['ffile']['tmp_name'];
$destino="../iptv1.txt";
if($exte=='m3u')
{
	$fm3u=file_get_contents($origen);

	$iserv=$fm3u;
	$iserv=substr($iserv,0,strpos($iserv,'/live/'));
	$iserv=substr($iserv,strrpos($iserv,'http://')+7);
	$iserv=substr($iserv,0,strpos($iserv,':'));
		
	$iuser=$fm3u;
	$iuser=substr($iuser,strpos($iuser,'/live/')+6);
	$iuser=substr($iuser,0,strpos($iuser,'/'));
		
	$ipass=$fm3u;
	$ipass=substr($ipass,strpos($ipass,'/live/')+6);
	$ipass=substr($ipass,strpos($ipass,'/')+1);
	$ipass=substr($ipass,0,strpos($ipass,'/'));
	
	$fm3u=str_replace($iserv,'**miserv**',$fm3u);
	$fm3u=str_replace('/'.$iuser.'/','/**miuser**/',$fm3u);
	$fm3u=str_replace('/'.$ipass.'/','/**mipass**/',$fm3u);

	if(mb_stristr($iserv,'jomyson')){$destino='../srvjson.jpg';}
	if(mb_stristr($iserv,'nous')){$destino='../srvnous.jpg';}
	if(mb_stristr($iserv,'xtrego')){$destino='../srviotv.jpg';}
	
	if(file_put_contents($destino,$fm3u)){echo $iserv.' - '.$destino;}
	else{echo 'ERROR';}
}	
// echo move_uploaded_file($origen,$destino);

	
?>
<?php }?>	
	
<?php if(mb_stristr('EPG',$pant)) { ?>
<?php
$origen = $_FILES['ffile']['tmp_name'];
$destino="../iptv2.txt";
?>
<resultado>
<?php	
echo '***'.$origen;
echo '***'.$destino;
echo move_uploaded_file($origen,$destino);
?>
</resultado>
<?php }?>	
	
<?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="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='m3u'; $pcaption='M3U'; $ponclick='upld_iptv("M3U","'.$pidtxt.'")'; include('vrgetfil.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>
									<?php 	$pidtxt='m3u'; $pcaption='Subir '.$pidtxt; $paccept='.m3u'; $ponclick='upld_iptv("M3U","'.$pidtxt.'")'; $pobj=0; $pmulti=1; include('vrgetfil.php'); ?>
								</td>
							
								<td>
									<?php 	$pidtxt='epg'; $pcaption='Subir '.$pidtxt; $paccept='.xml'; $ponclick='upld_iptv("EPG","'.$pidtxt.'")';; $pobj=0; $pmulti=1; include('vrgetfil.php'); ?>
								</td>
									<?php 	//$pidtxt='subir'; $pcaption='Subir'; $ponclick='jwib_rpc1("XLSX","'.$pidtxt.'")'; include('vrgetfil.php'); ?>
						</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=msql_query($sql_pant,$link_vcrx);
		$res_tpant=msql_query($sql_tpant,$link_vcrx);

	
		$tmarca=msql_result($res_tpant,0,'tmarca');
		$tmodelo=msql_result($res_tpant,0,'tmodelo');
		$ttlla=msql_result($res_tpant,0,'ttlla');
// 		$tsubt=msql_result($res_tpant,0,'stsubt');
// 		if($docuiimp==1)
// 		{
// 			$tsubtiva0=msql_result($res_tpant,0,'stsubtiva0');
// 			$tsubtiva=msql_result($res_tpant,0,'stsubtiva');
// 			$tdcto=msql_result($res_tpant,0,'stdcto');
// 			$tice=msql_result($res_tpant,0,'stice');
// 			$tiva=msql_result($res_tpant,0,'stiva');
// 			$tirbp=msql_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=msql_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=msql_query($sql_imgi,$link_vcrx);
						?>
						<?php if(msql_num_rows($res_imgi)>0){?>
						<?php
							$sql_defa='update imgi0 set imgi_defa=1 where imgi_codigo="'.msql_result($res_imgi,0,'imgi_codigo').'"';
							$res_defa=msql_query($sql_defa,$link_vcrx);
							$res_imgi=msql_query($sql_imgi,$link_vcrx);
						?>
								<?php while($aso_imgi=msql_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=msql_query($sql_pant,$link_vcrx); 
	$item_codigo=msql_result($res_pant,0,'item_codigo');
	$item_descri=msql_result($res_pant,0,'item_descri');
	$item_raiz=msql_result($res_pant,0,'item_raiz');
{
// 	$res_tpant=msql_query($sql_tpant,$link_vcrx); 
// 	$tsubt=msql_result($res_tpant,0,'stsubt');
// 	$tcant=msql_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("'.msql_result($res_tpant,0,'docu').'","'.msql_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=msql_query($sql_imgi,$link_vcrx);	
				// 	echo explain_sql($sql_imgi);
				?>
				<?php $numrows=msql_num_rows($res_pant); ?>
						<?php if(msql_num_rows($res_imgi)>0){?>
								<?php while($aso_imgi=msql_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=msql_query($sql_imgi,$link_vcrx); 
	// explain_sql($sql_pant);
}	?>

<?php if (msql_num_rows($res_imgi)>0){?>
	<?php while($aso_imgi=msql_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;	?>

		