<script type="text/javascript">
function mpedido_d(indxd)
{
	for(i=0;i<=document.getElementsByClassName('pdc_t1').length-1;i++)
	{
		document.getElementsByClassName('pdc_t1').item(i).style.background='none';
		document.getElementsByName('btn_ped_c').item(i).disabled=true;
		document.getElementsByName('btn_ped_c').item(i).style.cursor='progress';
	}
	
	document.getElementById(indxd).style.background='#eee';
	document.getElementById('mpedido_d').innerHTML='<img src="../img/loader.gif" width="40" />';
	document.body.style.cursor='progress';
	$.ajax({
		url:'../lib/mpedido_d.php',
		type:'POST',
		data:{indx:indxd},
		success: function(dato)
		{
			
			document.getElementById('mpedido_d').innerHTML='';
			document.getElementById('mpedido_d').innerHTML=dato;
			document.body.style.cursor='auto';
			for(i=0;i<=document.getElementsByClassName('pdc_t1').length-1;i++)
			{
				document.getElementsByName('btn_ped_c').item(i).disabled=false;
				document.getElementsByName('btn_ped_c').item(i).style.cursor='auto';
			}

		}			
	});
}

function anular_pedido(inda)
{
	if (confirm('¿Desea Anular su Pedido?')) 
	{
		document.getElementById('e_pedido').disabled=false;
		$.ajax({
			url:'../lib/pedido.php',
			type:'POST',
			data:{inda:inda},
			success: function(dato)
			{
				console.log(dato);
				window.location.reload();
				//alert('Pedido Eliminado');
			},
			error: function(objeto)
			{
				console.log(objeto);
			}
		});
		document.getElementById('e_pedido').disabled=true;
	}
}

</script>
<div align="center" style="padding:5px;">
<?php
require('../cfg/res.php');
$sql_ped='select *from clie11  where enti="'.$_SESSION['user_vcrx_id'].'" ORDER BY fecha DESC, idnum1 DESC';
//echo $sql_ped;
$res_ped=mysql_query($sql_ped,$link_vcrx);
if(mysql_num_rows($res_ped)!=0)
{
?> 
<div style=" max-height:500px; overflow-y:scroll;">
<table id="tabla_cab_ped" width="100%" border="0" cellspacing="0" cellpadding="2" style="border-collapse:collapse;font-size:12px; border:#000000 solid 1px;">
	
    <tr style="border-bottom:#000000 solid 2px; ">
    <th width="25"></th>
    <th width="25"></th>
    <th>NUMERO</th>
    <th>FECHA</th>
    <th>TCANT</th>
    <th>TSUB</th>
    <th>TDCTO</th>
    <th>TIVA</th>
    <th>TOTAL</th>
    <th>STATUS</th>
    <th></th>
    </tr>

	<?php
	$filax=1;
	while($r_ped=mysql_fetch_assoc($res_ped))
	{
	?>
	<tr class="pdc_t1" id="<?php echo $r_ped['idnum1']; ?>" align="center" style=" <?php if($filax==3){echo 'border-bottom:dotted 1px #000;';$filax=1;}else{$filax++;} ?>" >
        <td>
    <a href="../lib/celectop1.php?docu=<?php echo $r_ped['docu']; ?>&idnnum=<?php echo $r_ped['idnum1']; ?>&formato=1" target="_blank"><img src="../img/print2.png" width="20"  title="Imprimir"  /></a>
    </td>

    <td>
    <input type="image" onclick="mpedido_d('<?php echo $r_ped['idnum1']; ?>');" src="../img/hpedido.png" width="20" class="btn_ped_c" name="btn_ped_c" />
    </td>
    <td style="border-left:#000000 solid 1px; border-right:#000000 solid 1px;">
		<?php echo $r_ped['numero'];?>
    </td>
    <td>
    	<?php echo $r_ped['fecha'];?>
    </td>
    <td style="border-left:#000000 solid 1px; border-right:#000000 solid 1px;">
    	<?php echo $r_ped['tcant'];?>
    </td>
    <td>
    	<?php echo $r_ped['tsubt'];?>
    </td>
    <td style="border-left:#000000 solid 1px; border-right:#000000 solid 1px;">
    	<?php echo $r_ped['tdcto'];?>
    </td>
    <td>
    	<?php echo $r_ped['tiva'];?>
    </td>
    <td style="border-left:#000000 solid 1px;">
    	<?php echo $r_ped['total'];?>
    </td>
    
    <td style="border-left:#000000 solid 1px;">
    	<?php echo $r_ped['stat_descri'];?>
    </td>
   
    <td style="border-left:#000000 solid 1px;">
    	<?php 
		if($r_ped['status']=='-')
		{
		?>
        	<input type="image" id="e_pedido" src="../img/cancel.png" width="25"   title="Anular Pedido"  onclick="anular_pedido('<?php echo $r_ped['idnum1'];?>');"  />
        <?php	
		}
		
		?>
    </td>

    </tr>

	<?php	
	}
	?>
</table>
</div>
<?php	
}
else
{
echo '<h2>AUN NO HA REALIZADO NINGUN PEDIDO</h2>';
}
?>
<div id="mpedido_d" style="padding-top:10px; "></div>
<?php 
if($_SESSION['user_vcrx_empr']=='gnya')
{
?>
<div align="center" style="font-size:12px;">
Realice su pago mediante deposito o<br /> 
transferencia a la cuenta:<br />
Banco Internacional<br />
#1300815920<br />
Cta. Ahorros<br />
Germanya S.A.

<br /><br />
Banco Pichincha<br />
#5247589000<br />
Cta. Ahorros <br />
Germania Zambrano Moncayo

</div>
<?php	
}

?>
</div>