<?php
//ini_Set('display_errors',1);
session_start();
require_once ("../../config/Cado.php");
require_once ("../egreso/cEgreso.php");
$oEgreso = new cEgreso();
require_once("../formatos/formato.php");
require_once ("../compra/cComprapago.php");
$oComprapago = new cComprapago();
	// echo '-'.$_POST['compag_id'];
$dts= $oComprapago->mostrarUno($_POST['compag_id']);
	$dt = mysqli_fetch_array($dts);
	$feccom_emi		=$dt['tb_compra_fec'];
	$com_numdoc		=$dt['tb_compra_numdoc'];
	$compag_numuni =$dt['tb_comprapago_numuni'];
	mysqli_free_result($dts);
	
	// echo '-'.$_POST['compag_id'];
	$dts1=$oEgreso->mostrar_pagos($_POST['compag_id']);
	$numrowspag = mysqli_num_rows($dts1);
	
	
	
?>

<div class="col-lg-12 col-md-12 col-xs-12 " >
	 <div class="modal-header">
        <h5 class="modal-title">PAGOS RELACIONADOS A LA CUENTA -  <strong style="color:red;"><?php echo  $com_numdoc .' | '. $compag_numuni; ?></strong> </h5>
      </div>
	  
	  <div class="col-lg-12 col-md-12 col-xs-12 " >
	  <h4 class="modal-title"><strong style="color:red;"><?php echo $numrowspag; ?> PAGO(S)</strong></h4>
	  </div>
	  
	  <?php //echo $modpag; ?>
  <div class="table-responsive">
	<div class="col-lg-12 col-md-12 col-xs-12 " >
         
		
		<?php 

	while($dt1 = mysqli_fetch_array($dts1)){
	
	$modpag = $dt1['tb_egreso_modo'];
	$fec = mostrarFecha($dt1['tb_egreso_fec']);
	$fecemi = mostrarFecha($dt1['tb_egreso_fecemi']);
	$cob = $dt1['tb_egreso_cob'];
	$prov_nom= $dt1['tb_proveedor_nom'];
  
		if($dt1['tb_banco_ori']==1){
			$banori = 'BCP';
		}else if($dt1['tb_banco_ori']==2){
			$banori = 'BBVA';
		}else if($dt1['tb_banco_ori']==3){
			$banori = 'SCT';
		}else if($dt1['tb_banco_ori']==4){
			$banori = 'CMA TRUJILLO';
		}else if($dt1['tb_banco_ori']==5){
			$banori = 'CMA PIURA';
		}
		if($dt1['tb_banco_des']==1){
			$bandes = 'BCP';
		}else if($dt1['tb_banco_des']==2){
			$bandes = 'BBVA';
		}else if($dt1['tb_banco_des']==3){
			$bandes = 'SCT';
		}else if($dt1['tb_banco_des']==4){
			$bandes = 'CMA TRUJILLO';
		}else if($dt1['tb_banco_des']==5){
			$bandes = 'CMA PIURA';
		}
		
		if($dt1['tb_egreso_modo']==1){
			$mod = 'EFECTIVO';
		}else if($dt1['tb_egreso_modo']==2){
			$mod = 'DEPOSITO';
		}else if($dt1['tb_egreso_modo']==3){
			$mod = 'TRANSFERENCIA';
		}else if($dt1['tb_egreso_modo']==4){
			$mod = 'CHEQUE';
		}else if($dt1['tb_egreso_modo']==5){
			$mod = 'TARJETA';
		}
  
		$totpag = $dt1['tb_egreso_imp'] + $dt1['tb_egreso_gasope'];
  

		
		
		
		?>
		
		
        <?php if($modpag==1){?>
        <table id="tabla_pago" class="table table-bordered table-striped">
        <thead>
          <tr>
          <th nowrap title="Fecha">FECHA PAGO</th> 
          <th>PROVEEDOR</th>
          <th>RUC</th>
          <th>DETALLE</th>
          <th nowrap >MODO PAGO</th>
          <th class="" >COBRADOR</th>
          <th align="right">IMPORTE</th>
          <th nowrap align="center">GASTO OPERACION</th>
          <th align="center">SUBTOTAL</th>
          </tr>
        </thead>
        <tbody>	
          <tr>
          <td nowrap="nowrap"><?php echo $fec; ?></td>                   
          <td nowrap="nowrap"><?php echo $prov_nom; ?></td>         
          <td nowrap="nowrap"><?php echo $dt1['tb_proveedor_doc']?></td>         
          <td nowrap="nowrap"><?php echo $dt1['tb_egreso_det']?></td>         
		  <td nowrap="nowrap"><?php echo $mod; ?></td>     
		  <td nowrap="nowrap"><?php echo $cob; ?></td>               
          <td nowrap="nowrap"><?php echo formato_money($dt1['tb_egreso_imp'])?></td>         
          <td nowrap="nowrap"><?php echo formato_money($dt1['tb_egreso_gasope'])?></td>     
          <td nowrap="nowrap"><?php echo formato_money($totpag) ?></td> 
          </tr>
   		</tbody>  
		</table>  
        <?php
      	}
      	?>
		
		<?php if($modpag==2){ ?>
        <table id="tabla_pago" class="table table-bordered table-striped">     
        <thead>
          <tr>
          <th nowrap title="Fecha">FECHA DEPOSITO</th> 
          <th>PROVEEDOR</th>
          <th>RUC</th>
          <th>DETALLE</th>
          <th nowrap >MODO PAGO</th>
          <th nowrap class="" >BANCO DESTINO</th>
          <th nowrap class="" >Nº CUENTA PROVEEDOR</th>
          <th nowrap class="" >Nº OPERACION</th>
          <th align="right">IMPORTE</th>
          <th nowrap align="center">GASTO OPERACION</th>
          <th align="center">SUBTOTAL</th>
          </tr>
        </thead>
         <tbody>	
          <tr>
          <td nowrap="nowrap"><?php echo $fec; ?></td>                   
          <td nowrap="nowrap"><?php echo $prov_nom; ?></td>         
          <td nowrap="nowrap"><?php echo $dt1['tb_proveedor_doc']?></td>         
          <td nowrap="nowrap"><?php echo $dt1['tb_egreso_det']?></td>         
		  <td nowrap="nowrap"><?php echo $mod; ?></td>     
		  <td nowrap="nowrap"><?php echo $bandes; ?></td>  
		  <td nowrap="nowrap"><?php echo $dt1['tb_proveedorcuenta_nrocue']?></td>
		  <td nowrap="nowrap"><?php echo $dt1['tb_egreso_nroope']?></td>
          <td nowrap="nowrap"><?php echo formato_money($dt1['tb_egreso_imp'])?></td>         
          <td nowrap="nowrap"><?php echo formato_money($dt1['tb_egreso_gasope'])?></td>     
          <td nowrap="nowrap"><?php echo formato_money($totpag) ?></td>  
          </tr>
	    </tbody>  
		</table> 
          <?php
          }
          ?>
		<?php if($modpag==3){ ?>
        <table id="tabla_pago" class="table table-bordered table-striped">     
        <thead>
          <tr>
          <th nowrap title="Fecha">FECHA TRANSFERENCIA</th> 
          <th>PROVEEDOR</th>
          <th>RUC</th>
          <th>DETALLE</th>
          <th nowrap >MODO PAGO</th>
          <th nowrap class="" >BANCO ORIGEN</th>
          <th nowrap class="" >CUENTA ORIGEN</th>
          <th nowrap class="" >BANCO DESTINO</th>
          <th nowrap class="" >CUENTA DESTINO</th>
          <th nowrap class="" >Nº OPERACION</th>
          <th align="right">IMPORTE</th>
          <th nowrap align="center">GASTO OPERACION</th>
          <th align="center">SUBTOTAL</th>
          </tr>
        </thead>
         <tbody>	
          <tr>
          <td nowrap="nowrap"><?php echo $fec; ?></td>                   
          <td nowrap="nowrap"><?php echo $prov_nom; ?></td>         
          <td nowrap="nowrap"><?php echo $dt1['tb_proveedor_doc']?></td>         
          <td nowrap="nowrap"><?php echo $dt1['tb_egreso_det']?></td>         
		  <td nowrap="nowrap"><?php echo $mod; ?></td>  
		  <td nowrap="nowrap"><?php echo $banori; ?></td> 
		  <td nowrap="nowrap"><?php echo $dt1['tb_cuenta_ori']?></td>   
		  <td nowrap="nowrap"><?php echo $bandes; ?></td>  
		  <td nowrap="nowrap"><?php echo $dt1['tb_cuenta_des']?></td> 
		  <td nowrap="nowrap"><?php echo $dt1['tb_egreso_nroope']?></td>
          <td nowrap="nowrap"><?php echo formato_money($dt1['tb_egreso_imp'])?></td>         
          <td nowrap="nowrap"><?php echo formato_money($dt1['tb_egreso_gasope'])?></td>     
          <td nowrap="nowrap"><?php echo formato_money($totpag) ?></td>  
          </tr>
	    </tbody>  
		</table> 
          <?php
          }
          ?>
		<?php if($modpag==4){ ?>
        <table id="tabla_pago" class="table table-bordered table-striped">     
        <thead>
          <tr>
          <th nowrap title="Fecha">FECHA PAGO</th> 
          <th>PROVEEDOR</th>
          <th>RUC</th>
           <th nowrap title="Fecha">FECHA EMISION</th> 
          <th>DETALLE</th>
          <th nowrap >MODO PAGO</th>
          <th nowrap class="" >BANCO CARGO</th>
          <th nowrap class="" >CUENTA CARGO</th>
          <th nowrap class="" >Nº CHEQUE</th>
          <th align="right">IMPORTE</th>
          <th nowrap align="center">GASTO OPERACION</th>
          <th align="center">SUBTOTAL</th>
          </tr>
        </thead>
         <tbody>	
          <tr>
          <td nowrap="nowrap"><?php echo $fec; ?></td>                   
          <td nowrap="nowrap"><?php echo $prov_nom; ?></td>         
          <td nowrap="nowrap"><?php echo $dt1['tb_proveedor_doc']?></td>
          <td nowrap="nowrap"><?php echo $fecemi; ?></td>         
          <td nowrap="nowrap"><?php echo $dt1['tb_egreso_det']?></td>         
		  <td nowrap="nowrap"><?php echo $mod; ?></td>  
		  <td nowrap="nowrap"><?php echo $banori; ?></td> 
		  <td nowrap="nowrap"><?php echo $dt1['tb_cuenta_ori']?></td> 
		  <td nowrap="nowrap"><?php echo $dt1['tb_egreso_nroope']?></td>
          <td nowrap="nowrap"><?php echo formato_money($dt1['tb_egreso_imp'])?></td>         
          <td nowrap="nowrap"><?php echo formato_money($dt1['tb_egreso_gasope'])?></td>     
          <td nowrap="nowrap"><?php echo formato_money($totpag) ?></td>  
          </tr>
	    </tbody>  
		</table> 
          <?php
          }
          ?>
<?php if($modpag==5){ ?>
        <table id="tabla_pago" class="table table-bordered table-striped">     
        <thead>
          <tr>
          <th nowrap title="Fecha">FECHA PAGO</th> 
          <th>PROVEEDOR</th>
          <th>RUC</th>
           <th nowrap title="Fecha">FECHA EMISION</th> 
          <th>DETALLE</th>
          <th nowrap >MODO PAGO</th>
          <th nowrap class="" >BANCO CARGO</th>
          <th nowrap class="" >CUENTA CARGO</th>
          <th nowrap class="" >Nº OPERACION</th>
          <th align="right">IMPORTE</th>
          <th nowrap align="center">GASTO OPERACION</th>
          <th align="center">SUBTOTAL</th>
          </tr>
        </thead>
         <tbody>	
          <tr>
          <td nowrap="nowrap"><?php echo $fec; ?></td>                   
          <td nowrap="nowrap"><?php echo $prov_nom; ?></td>         
          <td nowrap="nowrap"><?php echo $dt1['tb_proveedor_doc']?></td>
          <td nowrap="nowrap"><?php echo $fecemi; ?></td>         
          <td nowrap="nowrap"><?php echo $dt1['tb_egreso_det']?></td>         
		  <td nowrap="nowrap"><?php echo $mod; ?></td>  
		  <td nowrap="nowrap"><?php echo $banori; ?></td> 
		  <td nowrap="nowrap"><?php echo $dt1['tb_cuenta_ori']?></td> 
		  <td nowrap="nowrap"><?php echo $dt1['tb_egreso_nroope']?></td>
          <td nowrap="nowrap"><?php echo formato_money($dt1['tb_egreso_imp'])?></td>         
          <td nowrap="nowrap"><?php echo formato_money($dt1['tb_egreso_gasope'])?></td>     
          <td nowrap="nowrap"><?php echo formato_money($totpag) ?></td>  
          </tr>
	    </tbody>  
		</table> 
          <?php
          }
	}
	
		mysqli_free_result($dts1);
          ?>
		  
      
	</div>
	
	
	
   </div>
   
    <div class="box-footer float-right ">
				<button title="CERRAR VENTANA" type="button" data-dismiss="modal" class="btn btn-danger"><i class="fas fa-times"></i></button>			
	</div>
  </div>
	<br />