<?php 



//ini_set('display_errors',1);



date_default_timezone_set('America/Lima');

session_start();





require_once ("../../config/Cado.php");

require_once ("cCuentacobrar.php");

$oCuentacobrar = new cCuentacobrar();

require_once ("../ingreso/cIngreso.php");

$oIngreso = new cIngreso();

require_once ("../formatos/formato.php");

require_once ("../formatos/fechas.php");



$fecha_hoy=date('d-m-Y');

list($day,$mon,$year) = explode('-',$fecha_hoy);

$fecha30dias=date('Y-m-d',mktime(0,0,0,$mon,$day+30,$year));

$fecha_pasado_pasado=date('d-m-Y',mktime(0,0,0,$mon,$day+4,$year));

$fecha_mes=date('d-m-Y',mktime(0,0,0,$mon,$day+30,$year));

$fecha11 = strtotime($fecha_hoy);

$fecha12 = strtotime($fecha_mes);



$fecha_ayer=date('d-m-Y',mktime(0,0,0,$mon,$day-1,$year)); 

$fecha_mañana=date('d-m-Y',mktime(0,0,0,$mon,$day+1,$year)); 

$fecha_pasado=date('d-m-Y',mktime(0,0,0,$mon,$day+2,$year));

$fecha_pasado_mañana=date('d-m-Y',mktime(0,0,0,$mon,$day+3,$year));

$fecha7dias=date('Y-m-d',mktime(0,0,0,$mon,$day+7,$year));



$color1="#F6CECE";

$color2="#F6E3CE";

$color3="#F5F6CE";

$color4="#E3F6CE";



$colorhoy="#f9a825";

$colormañana="#00c851";

$colorpasado="#007e33";

$colorpasadomañana="#0099cc";

$colormucho="#0d47a1";



$emp_id = $_SESSION['empresa_id'];

$emp_id1 = '1';

?>



<div id="cuadro-contain" class="col-lg-4 col-sm-12 col-xs-12" style="background-color:#fff;">

		<div class="col-lg-12 col-sm-12 col-xs-12" style="height:10px;"></div>

	

	<div>

	<span  style="font-weight:bold;font-size:1.5rem;color:#FF8800;" >CUENTAS POR COBRAR F B NV</span>

	</div>

	

	<div>

	<span class="">	Desde <span style="font-weight:bold;" class="subr">Hoy</span>  hasta el <span style="font-weight:bold;"  class="subr"><?php echo fecha_entexto($fecha30dias); ?></span></span>

	</div>

		

		<?php

		$con = '5';

		$dts1=$oCuentacobrar->cuentas_por_pagar_por_fecven_doc(1,$emp_id1,$con);

		$num_rows1= mysqli_num_rows($dts1);

		if($num_rows1>0)

		{

		?>

		<div class="col-lg-12 col-sm-12 col-xs-12" style="font-weight:bold;;padding:1%;color:#CC0000;border-bottom-style:solid;border-bottom-width: 1px;">

		<span ><?php echo " VENCIDOS "?> </span>

		</div>

			<?php

			while($dt1 = mysqli_fetch_array($dts1))

			{

				$monto = $dt1['tb_ventapago_mon'];						

				$mone_id = $dt1['tb_moneda_id'];						

				$abonos = 0;



				$mod_id=3;

				$est1=1;

				$est2=2;

				$dts3 = $oIngreso->mostrar_por_modulo($mod_id,$dt1['tb_ventapagoingresos_id'],$est1,$est2);

				$num_rows3= mysqli_num_rows($dts3);

				while($dt3 = mysqli_fetch_array($dts3))

				{

					$abonos+= $dt3['tb_ingreso_imp'];

				} 

				mysqli_free_result($dts3);



				$saldo = ($monto - $abonos);

				

				if($mone_id==1){

					$lbl_mone = 'S/ ';

					$totsol += $saldo;

				}else if($mone_id==2){

					$lbl_mone = 'US$ ';

					$totdol += $saldo;

				}

				

				$prov = $dt1['tb_cliente_nom'];

				$cont_prov = strlen($prov); 

				if($cont_prov>25)

				{

					$prov =  substr($prov,0,25);

					$prov = $prov.'...';

				}else{

					$prov = $prov;

				}

				

				?> 

			<div class="col-lg-12 col-sm-12 col-xs-12 no-padding" style="" >

			<div class="pull-left">

			<span title="Registrar Pago ::  <?php echo $dt1['tb_documento_abr'].' '.$dt1['tb_venta_numdoc'];?>" 

			style="border-bottom-style:dashed;border-bottom-width:1px;cursor:pointer;" onClick="ingreso_form('insertar',<?php echo $dt1['tb_ventapago_id']?>)"  > <?php echo $prov; ?>

			</span>			

			

			</div>

			<div class="pull-left">

			<?php echo  '<strong> &nbsp;&nbsp;&nbsp;'.$dt1['tb_documento_abr'].'</strong>'?>

			</div>

			<div class="pull-right">

			<?php echo $lbl_mone.'<strong>'.formato_money($saldo).'</strong>';?>

			</div>

			</div>

				

		<?php

			}

		}

		mysqli_free_result($dts1);



		if($num_rows1>0){



		?>

		

				

<div class="col-lg-12 col-sm-12 col-xs-12">

<div class="pull-right">

	<span  style="font-weight:bold;font-size:1.5rem;" >

	 <strong><?php echo 'S/ '. formato_money($totsol); ?></strong>

	 <br />

	 <strong><?php echo 'US$ '. formato_money($totdol); ?></strong>

	</span>

</div>	

</div>	

		

		

<?php 

	}



$totsol = 0;

$totdol = 0;

for($fecha11; $fecha11<=$fecha12; $fecha11=strtotime('+1 day ' . date('Y-m-d',$fecha11)))

{ 

$fecha=date('d-m-Y',$fecha11);

//echo $fecha;



	

	$t_vence='VENCE';

	$color=$colormucho;

	$texto='EL';				

	if($fecha==$fecha_hoy)

	{

		$color=$colorhoy;

		$texto='HOY';

	}

	if($fecha==$fecha_mañana)

	{

		$color=$colormañana;

		$texto='MAÑANA';

	}

	if($fecha==$fecha_pasado)

	{

		$color=$colorpasado;

		$texto='PASADO';

	}

	if($fecha==$fecha_pasado_mañana)

	{

		$color=$colorpasadomañana;

		$texto='EL';

	}	



			$dts1=$oCuentacobrar->cuentas_por_pagar_por_fecven_doc(fecha_mysql($fecha),$emp_id1,$con);

			$num_rows1= mysqli_num_rows($dts1);

			if($num_rows1>0)

			{

	?>	

	

	<div class="col-lg-12 col-sm-12 col-xs-12" style="height:10px;"> </div>

	<div class="col-lg-12 col-sm-12 col-xs-12" style="font-weight:bold;;padding:1%;color:<?php echo $color?>; border-bottom-style:solid;border-bottom-width: 1px;">

		<span style=""><?php echo $t_vence .' '.$texto .' '.strtoupper(nombre_dia($fecha)).' '.fecha_entexto_corto(fecha_mysql($fecha),1)?> </span>

	</div>

	<?php

			while($dt1 = mysqli_fetch_array($dts1))

			{

				$monto = $dt1['tb_ventapago_mon'];						

				$abonos = 0;

				$mone_id = $dt1['tb_moneda_id'];	

				$mod_id=3;

				$est1=1;

				$est2=2;

				$dts3 = $oIngreso->mostrar_por_modulo($mod_id,$dt1['tb_ventapagoingresos_id'],$est1,$est2);

				$num_rows3= mysqli_num_rows($dts3);

				while($dt3 = mysqli_fetch_array($dts3))

				{

					$abonos+= $dt3['tb_ingreso_imp'];

				} 

				mysqli_free_result($dts3);



				$saldo = ($monto - $abonos);



				if($mone_id==1){

					$lbl_mone = 'S/ ';

					$totsol += $saldo;

				}else if($mone_id==2){

					$lbl_mone = 'US$ ';

					$totdol += $saldo;

				}

				

				$prov = $dt1['tb_cliente_nom'];

				$cont_prov = strlen($prov); 

				if($cont_prov>25)

				{

					$prov =  substr($prov,0,25);

					$prov = $prov.'...';

				}else{

					$prov = $prov;

				}

				

			?> 

			

			<div class="col-lg-12 col-sm-12 col-xs-12">

			<div class="pull-left">

			<span title="Registrar Pago ::  <?php echo $dt1['tb_documento_abr'].' '.$dt1['tb_venta_numdoc'];?>" style="border-bottom-style:dashed;border-bottom-width:1px;cursor:pointer;"

			onClick="ingreso_form('insertar',<?php echo $dt1['tb_ventapago_id']?>)"  > <?php echo $prov; 

			?>

			</span>

			</div>

			<div class="pull-left">

			<?php echo  '<strong> &nbsp;&nbsp;&nbsp;'.$dt1['tb_documento_abr'].'</strong>'?>

			</div>

			<div class="pull-right">

			<?php echo $lbl_mone.'<strong>'.formato_money($saldo).'</strong>';?>

			</div>

			</div>

			<?php

			}

		}

		mysqli_free_result($dts1);

		

		if($num_rows1>0){

		if($totsol==0 && $totdol == 0){}else{

	?>



			

<div class="col-lg-12 col-sm-12 col-xs-12">

<div class="pull-right">

	<span  style="font-weight:bold;font-size:1.5rem;" >

	 <strong><?php echo 'S/ '. formato_money($totsol); ?></strong>

	 <br />

	 <strong><?php echo 'US$ '. formato_money($totdol); ?></strong>

	</span>

</div>	

</div>	



<?php 	

		}

		}

	$totsol = 0;

	$totdol = 0;

		

}

?>



		

		



<?php



$fecha11 = "";

$fecha12 = "";

$fecha11 = strtotime($fecha_hoy);

$fecha12 = strtotime($fecha_mes);



?>

<div class="col-lg-12 col-sm-12 col-xs-12" style="height:10px;"></div>

<div class="col-lg-4 col-sm-12 col-xs-12" >

ply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.



Why do we use it?

It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web pa





</div>



</div>















<!-- formulario de registros ingresos-->

	

<div class="modal fade" id="div_ingreso_form_dialog" role="dialog" data-keyboard="true"  data-backdrop="static" tabindex="-1"  style="padding:0px;z-index:2000; overflow-y:scroll;">

			<div class="modal-dialog modal-lg"  role="document" >



			<div class="modal-content">



			<div class="modal-body div_ingreso_form"  >



			</div>

			<br />

			<br />

			</div>

			</div>

			</div>









<script type="text/javascript">



function cuentacobrar_cliente(id_cliente)

	{

		$('#div_cuentacobrar_form_dialog').modal();

		$('body').css('overflow-y','hidden');		

		

		$.ajax({

			type: "POST",

			url: "../cuentacobrar/cuentacobrar_tabladeudas_inicio.php",

			async:true,

			dataType: "html", 

			data: ({

				cli_id: id_cliente

			}),                  

			beforeSend: function() {

				var div = "<center><div class='overlay col-lg-12 col-sm-12 col-xs-12' style='background-color:#fff;padding:0%;font-size:3rem;' >  <i class='fa fa-refresh fa-spin ' ></i> </div>  </center>";				

				$('.div_cuentacobrar_form').html(div);

			},

			success: function(html){

				$('.div_cuentacobrar_form').html(html);

			},

			complete: function(){			

			}

		});   

	}

	

	



</script>