<?php require('../cfg/res.php');
$month = date('m');
$year = date('Y');
$day = date("d", mktime(0,0,0, $month+1, 0, $year));


if(!isset($_POST['fini']) || empty($_POST['fini'])){$_POST['fini']=date('Y-m-01');}
if(!isset($_POST['ffin']) || empty($_POST['ffin'])){$_POST['ffin']=date('Y-m').'-'.$day;}

//$prov_sql='select *from prov12 where ';
$prov_sql='select *from comp12 where ';

$prov_sql.='fecha>="'.$_POST['fini'].'" and fecha<="'.$_POST['ffin'].'"';
if( isset($_POST['proveedor']) && !empty($_POST['proveedor']) ){$prov_sql.='and proveedor="'.$_POST['proveedor'].'" ';}
if( isset($_POST['item']) && !empty($_POST['item']) ){$prov_sql.='and item1="'.$_POST['item'].'" ';}
if( isset($_POST['numero']) && !empty($_POST['numero']) ){$prov_sql.='and numero="'.$_POST['numero'].'" ';}

$prov_sql.='order by idnum1 ';
if( isset($_POST['prov_order']) && !empty($_POST['prov_order']) ){$prov_sql.=' ,proveedor ';}
if( isset($_POST['docu_order']) && !empty($_POST['docu_order']) ){$prov_sql.=' ,docu  ';}
if( isset($_POST['fecha_order']) && !empty($_POST['fecha_order']) ){$prov_sql.=' ,fecha ';}
$prov_sql.=' desc ';

echo $prov_sql;
$prov_res=mysql_query($prov_sql,$link_vcrx);
?>
<table>
<tr>
<th>Proveedor</th>
<th>Fecha</th>
<th>Ptoe</th>
<th>Numero</th>
<th>Item</th>
<th>NewItem</th>
<th>Cuenta</th>
<th>Accion</th>
<th>Mensaje</th>
</tr>

<?php while($prov_r=mysql_fetch_assoc($prov_res)){?>
<tr>
<td><?php echo $prov_r['proveedor'];?></td>
<td><?php echo $prov_r['fecha'];?></td>
<td><?php echo $prov_r['ptoe'];?></td>
<td><?php echo $prov_r['numero'];?></td>
<td><?php echo $prov_r['item'];?></td>
<td><input type="text" value="<?php echo $prov_r['item'];?>" id="item_<?php echo $prov_r['idnum1'];?>_<?php echo $prov_r['iddet'];?>" /></td>
<td><input type="text" value="<?php echo $prov_r['ctas'];?>" id="ctas_<?php echo $prov_r['idnum1'];?>_<?php echo $prov_r['iddet'];?>"/></td>
<td><input type="button" value="Actualizar" onclick="_asignar('<?php echo $prov_r['idnum1'];?>','<?php echo $prov_r['iddet'];?>');" /></td>
<td><div id="error_<?php echo $prov_r['idnum1'];?>_<?php echo $prov_r['iddet'];?>"></div></td>
</tr>

<?php }?>
</table>