<?php
 
if(session_id()=="") 
	session_start();
$com="AS";	
require_once("DMMYSQLG.php");
	if(!isset($_POST['idPemema']))
		$idPemema= trim($_POST['fv']);
	else
		$idPemema= trim($_POST['idPemema']);
	$dt_pemema=mysqli_fetch_array(mysqli_query($con ,"SELECT * from dgpemema WHERE fol_ven='$idPemema'"));
?>

	<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>

	
	
	
	
	   <img src="logos/mover.gif" width="30" height="30" /><img src="logos/cerrar.gif" alt="cerrar" width="30" height="30" onClick="<?php
echo "cloLayAndCpy({idLayer:'".$_POST['layerToLoad']."'},{})";?>"/>
	  <input type="hidden" value="<?php
echo $idPemema;?>" name="idPemema" id="idPemema">
	
	<table  border="0" align="center" cellspacing="0">
		  <tr> 
			<td style="#FF9900"><div align="center" id="titleTableEsp" class="encPagTit">PAGOS ORDEN <?php
echo $dt_pemema['con_ven'];?></div></td>
		  </tr>
	   </table>
		<table align = "center">
		  <tr>
		    <td colspan="5" nowrap style="#CCCCCC"><div align="center"><?php
echo $dt_pemema['nom_cli_alt'];?></div></td>
	      </tr>
		  <tr>
			<td nowrap style="#CCCCCC"><div align="center" class="Estilo2">Num. Pag.</div></td>
			<td nowrap style="#CCCCCC"><div align="center" class="Estilo2">Fec. Pag.</div></td>
			<td nowrap style="#CCCCCC"><div align="center" class="Estilo2">Tip. Afe.</div></td>
			<td nowrap style="#CCCCCC"><div align="center" class="Estilo2">Imp. Pag.</div></td>
		  </tr>
		  <?php

		  	$arrStyles=array("styTabEspA","styTabEspB");
			$arrTipAfePag=array("I"=>"INGRESO","E"=>"EGRESO");
			$sq_ger_cajerosj=mysqli_query($con ,"SELECT 		
										n_rec as idger_cajerosj,
										DATE_FORMAT(fec_rec,'%d/%m/%Y') as fecPag,
										tip_afe as tipAfe,
										importe as impPag
									FROM 
										dgger_cajerosj 
									WHERE 
										dgger_cajerosj.pedido='$idPemema'");
								echo mysqli_error($con);		
			while($dt_ger_cajerosj=mysqli_fetch_array($sq_ger_cajerosj)){
				$i++;
				echo "<tr class=\"".$arrStyles[($i%2)]."\">";
				echo "<td><div align=\"left\">$dt_ger_cajerosj['idger_cajerosj']</div></td>";
				echo "<td><div align=\"left\">$dt_ger_cajerosj['fecPag']</div></td>";
				echo "<td><div align=\"left\">".$arrTipAfePag[$dt_ger_cajerosj['tipAfe']."</div></td>";
				echo "<td><div align=\"right\">".number_format($dt_ger_cajerosj['impPag'],2,'.',',')."</div></td>";
				echo "</tr>";
				($dt_ger_cajerosj['tipAfe']=='E')?($pol=-1):($pol=1);
				$totPag +=abs($dt_ger_cajerosj['impPag'])*$pol;
			}
			echo "<td colspan=\"3\"><div align=\"right\">SALDO A FAVOR:</div></td>";
			echo "<td ><div align=\"right\">".number_format($totPag,2,'.',',')."</div></td>";
		  ?>
		</table>
	
	
	