<?php
function vrinves1d($grupo,$idnum,$fini,$ffin)
{
	if(isset($_POST['fini']) && !empty($_POST['fini']))
	{$fini=$_POST['fini'];}
	else
	{$fini=date('2000-01-01');}
	
	if(isset($_POST['ffin']) && !empty($_POST['ffin']))
	{$ffin=$_POST['ffin'];}
	else
	{$ffin=date('Y-m-d');}

	if(isset($_POST['grupox']) && !empty($_POST['grupox']))
	{$fgrupo=$_POST['grupox'];}
	

	require('../cfg/res.php');
	mysql_query("SET NAMES 'utf8'");
?>

<?php
  include ('php_gene1.php');
  cost_prom($idnum);
?>

<?php if($fgrupo=='I'){?>
<?php
  $sql_item ='select * from inve12 where item="'.$idnum.'" and fecha>="'.$fini.'" and fecha<="'.$ffin.'" order by fecha desc, idnum1' ;
  $res_item=mysql_query($sql_item,$link_vcrx);
?>
<?php } ?>

<table>
<tr>
<?php $pcaption='item'; $ptabla='item'; $pcodigo=$idnum; include('vrsaycod.php');?>
</tr>	
</table>	
<div style="overflow-y:scroll; height:250px; font-size:12px;">

<table id="tabla_inves1"  border="0" width="90%" cellpadding="2" cellspacing="0" style="border-collapse:collapse">

<tr align="center" style="background: #F7F7F7; border-top:solid 1px#000;border-bottom:solid 1px#000">
<?php if($fgrupo=='I'){?>
	<th></th>
	<th>DOCU</th>
	<th>PTO/NUMERO</th>
	<th>FECHA</th>
	<th>INGRESO</th>
	<th>EGRESO</th>
	<th>COSTO</th>
	<th>SUB.TOT</th>
	<th>.</th>
	<th>BODE</th>
	<th>NOMBRE</th>
	<th>DETALLE</th>
	<th>ST</th>
<?php } ?>	

</tr>
<?php 
$filax=0; 
$idcont=0;
?>	
	
<?php if($fgrupo=='I'){?>
<?php while($r_item=mysql_fetch_assoc($res_item)){ ?> 
<?php $idcont++;	?>
<tr style=" <?php if($filax!=3){$filax++;}else{echo 'border-bottom:dotted 1px #000000;'; $filax=0;}?> ">
  <td>
    <a href="../lib/celectop1.php?docu=<?php echo $r_item['docu']; ?>&idnum=<?php echo $r_item['idnum1']; ?>&formato=1" target="_blank">
		<img src="../img/print2.png" width="20"  title="Imprimir  <?php echo $r_item['docu'];?>-<?php echo $r_item['numero'];?>"  /></a>
	</td>
  <td align="center"><?php echo $r_item['docu']; ?></td>
  <td align="center"><?php echo $r_item['ptonumero']; ?></td>
  <td align="center"><?php echo $r_item['fechadmy']; ?></td>
  <td align="right"><?php if($r_item['tingreso']!=0){echo number_format($r_item['tingreso'],$r_item['item_duni']);} ?></td>
  <td align="right"><?php if($r_item['tegreso']!=0){echo '<i>'.number_format($r_item['tegreso'],$r_item['item_duni']);} ?></td>
  <td align="right"><?php if($r_item['puni']!=0){echo number_format($r_item['puni'],$r_item['item_dval']);} ?></td>
  <td align="right"><?php if($r_item['puni']!=0){echo number_format(abs($r_item['tsubt']),$r_item['item_dval']);} ?></td>
  <td align="center"><?php echo $r_item['bode']; ?></td>
  <td align="left"><?php echo $r_item['enti_descri']; ?></td>
  <td align="left"><?php echo $r_item['concepto'].' /'.$r_item['detalle']; ?></td>
  <td align="center"><?php echo $r_item['status']; ?></td>
</tr>
<?php } ?>	
<?php }?>

	
<?php if($fgrupo=='G'){?>
	<tr>
<?php
	$xcodigo6=substr($idnum,0,6);
$sql_imgi='select *  from imgi0 ';
$sql_imgi.=' where imgi_item like "'.$xcodigo6.'%" and imgi_status!="X"';
$sql_imgi.=' group by imgi_item,imgi_file';
$sql_imgi.=' order by imgi_defa desc, imgi_file';
$res_imgi=mysql_query($sql_imgi,$link_vcrx);
// echo $sql_imgi;
?>
<?php if(mysql_num_rows($res_imgi)!=0){	?>	
		<?php $imgidefa=mysql_result($res_imgi,0,'imgi_file');?>
		<?php $res_imgi=mysql_query($sql_imgi,$link_vcrx);?>
		<?php while($r_imgi=mysql_fetch_assoc($res_imgi)){	?>	
				<?php if($r_imgi['imgi_defa']==1){$imgidefa=$r_imgi['imgi_file']; }?>
				<td id="td_<?php echo $r_imgi['imgi_file'] ?>" align="center" valign="top" style="">
				<?php $pname='imgi_'.$idnum; $pidtxt='rad_'.$r_imgi['imgi_file']; $pcaption='Principal'; if($r_imgi['imgi_defa']==1){$pdefa='checked';}; $ponclick="_codi_defa('imgi','".$r_imgi['imgi_codigo']."');"; include('vrradio.php'); ?>	
				<table style="max-width:50px; height:100px;">
				<tr>
				<?php $pidtxt=$r_imgi['imgi_file']; $pruta='../imgi/'; $psrc=$r_imgi['imgi_file']; $ponmouse=""; include ('vrsayimg.php')?>	
				</tr>
				</table>	
				<?php $pcaption='Eliminar'; $ponclick="_codi_stox('imgi','".$r_imgi['imgi_codigo']."','X','td_".$r_imgi['imgi_file']."')"; include('vrbutton.php'); ?>	
				</td>
		<?php } ?>
<?php } ?>

	</tr>
<?php } ?>	

	
	
</table>
<hr/>

<div>

<?php }?>