<?php



//ini_set('display_errors',1);



session_start();

unset($_SESSION['can_numdoc']);

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

require_once ("../canjeproveedor/cCanjeproveedor.php");

$oCanjeproveedor = new cCanjeproveedor();

require_once ("../egreso/cEgreso.php");

$oEgreso = new cEgreso();

require_once ("../compra/cComprapago.php");

$oComprapago = new cComprapago();

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

 

$contadorpro = 0;

$total_soles = 0;

$total_dolares = 0;



if($_POST['cmb_fil_mon_id']==1){

	$lbl_filmon = 'S/';

}else if($_POST['cmb_fil_mon_id']==2){



	$lbl_filmon = 'US$';

}







$dts = $oCanjeproveedor->mostrar_filtro($_POST['hdd_fil_pro_id'],$_POST['cmb_fil_empresa_id'],$_POST['cmb_fil_mon_id']);

$num_row= mysql_num_rows($dts);



?>





<section class="content" id="table" style="min-height:0px;padding-bottom:0px;margin-bottom:-30px;">

  <div class="row">

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

      <div class="box">

        <div class="box-body" id="div_tabla_proveedores">

		

		<form action="" id="for_canje" method="post">



			<input type="hidden" name="hdd_action" value="insertar" id="hdd_action">



			<?php //echo $_POST['hdd_fil_pro_id'].' - '.$_POST['cmb_fil_empresa_id'].' - '.$_POST['cmb_fil_mon_id'];?>



		<table id="tabla_canje" class="table table-bordered table-striped">



           <thead>

			<tr >



				<th align="left">FECHA DE CANJE</th>

				<th align="left">EMPRESA</th>	

				<th align="left">PROVEEDOR</th>	

				<th align="left">AVAL</th>		

				<th align="right">MONTO CANJEADO</th>

				<th></th>

			</tr>

		</thead>

         <tbody>

         <?php 



         if($num_row>0){



		while($dt = mysql_fetch_array($dts))

		{ 





		?>



		<tr class="even" data-canid =<?php echo $dt['tb_canjeproveedor_id']; ?>>

				<td><?php echo mostrarFecha($dt['tb_canjeproveedor_fec']); ?></td>		

				<td><?php echo $dt['tb_empresa_nomcom']; ?></td>			

				<td align="left" ><?php echo $dt['tb_proveedor_nom']; ?></td>

				<td align="left" ><?php echo $dt['tb_canjeproveedor_aval']; ?></td>

				<td align="left" ><?php echo $lbl_filmon.' '.formato_money($dt['tb_canjeproveedor_mon']); ?></td>

				<td>

				<!--

				<span onClick="canje_form_vista('insertar',<?php echo $dt['tb_canjeproveedor_id']?>)" 

								class="btn btn-primary btn-sm"  > <i class="fa fa-pencil"></i></span>

				-->

				<a  class="btn btn-sm" style="background-color:#00897b;color:#fff;text-align:left" 

		href="../../files/canjeproveedor/canjeproveedor_impcpe_doc.php?canproid=<?php echo $dt['tb_canjeproveedor_id'] ?>" 

		target="_blank"><i class="fa fa-file-pdf-o"></i> </a>				



				</td>

		</tr>



		<?php 

		}



		}else{

		?>



		<tr class="even">

				<td colspan="6" >CANJES NO ENCONTRADOS</td>		

		</tr>



		<?php

		}





         ?>





         </tbody>

     	</table>





      </form>



   

    </div>

  </div>

</div>

</div>

</section>





<script type="text/javascript" src="../cotizacion/NumberFormat.js"></script>

  <script type="text/javascript">

	$(function(){



	



	});





/*var tot = 0;

function vertot(mon,id,numdoc){



	if( $("#chk_imprimir_"+id).prop('checked') ) {

	tot += mon*1;

	}else{

	tot -= mon*1;

	}





$("#hdd_totcanje").val(new NumberFormat(tot).toFormatted());



$("#lbl_montot").text(new NumberFormat(tot).toFormatted());







if(tot>0){

	$("#btn_canje").attr('disabled', false);

	$("#btn_canje").attr('readonly', false);

	$("#btn_canje").attr('onclick', 'canje_form()');

}else{

	$("#btn_canje").attr('disabled', true);

	$("#btn_canje").attr('readonly', true);

	$("#btn_canje").attr('onclick', '');

}





if($("#chk_imprimir_"+id).is(':checked')){



	$.ajax({

		type: "POST",

		url: "../canjeproveedor/canjeproveedor_reg.php",

		async:false,

		dataType: "html",                  

		data: ({

			action:	 'agregarnumdoc',

			can_numdoc: numdoc

		}),

		beforeSend: function() {

			

		},

		success: function(html){

			

		},

		complete: function(){			

			

		}

	});



}else{



	  $.ajax({

		type: "POST",

		url: "../canjeproveedor/canjeproveedor_reg.php",

		async:false,

		dataType: "html",                  

		data: ({

			action:	 'quitarnumdoc',

			can_numdoc: numdoc

		}),

		beforeSend: function() {

			

		},

		success: function(html){

			

		},

		complete: function(){			

			

		}

	});



}





	

	

}

	*/



	function canjeardocumentos(){



	$.ajax({

		type: "POST",

		url: "../canjeproveedor/canjeproveedor_reg.php",

		async:true,

		dataType: "html", 

		data: $("#for_canje").serialize(),                    

		beforeSend: function() {

			

		},

		success: function(html){

			

		},

		complete: function(){			

			

		}

	});     

		

	}

	  

	  </script>