<?php require_once('Connections/conn.php'); ?>
<?php
$currentPage = $_SERVER["PHP_SELF"];

$maxRows_tblAranceles = 25;
$pageNum_tblAranceles = 0;
if (isset($_GET['pageNum_tblAranceles'])) {
  $pageNum_tblAranceles = $_GET['pageNum_tblAranceles'];
}
$startRow_tblAranceles = $pageNum_tblAranceles * $maxRows_tblAranceles;

mysql_select_db($database_conn, $conn);
mysql_query ("SET NAMES 'utf8'");
$query_tblAranceles = "SELECT * FROM aranceles ORDER BY aranceles.descripcion";
$query_limit_tblAranceles = sprintf("%s LIMIT %d, %d", $query_tblAranceles, $startRow_tblAranceles, $maxRows_tblAranceles);
$tblAranceles = mysql_query($query_limit_tblAranceles, $conn) or die(mysql_error());
$row_tblAranceles = mysql_fetch_assoc($tblAranceles);

if (isset($_GET['totalRows_tblAranceles'])) {
  $totalRows_tblAranceles = $_GET['totalRows_tblAranceles'];
} else {
  $all_tblAranceles = mysql_query($query_tblAranceles);
  $totalRows_tblAranceles = mysql_num_rows($all_tblAranceles);
}
$totalPages_tblAranceles = ceil($totalRows_tblAranceles/$maxRows_tblAranceles)-1;

$queryString_tblAranceles = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_tblAranceles") == false && 
        stristr($param, "totalRows_tblAranceles") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_tblAranceles = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_tblAranceles = sprintf("&totalRows_tblAranceles=%d%s", $totalRows_tblAranceles, $queryString_tblAranceles);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>sadce -- tabla de aranceles</title>
<link href="css/main.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {
	font-size: 16px;
	font-weight: bold;
	color: #CCFF00;
}
.style0 {color: #FFFF00}
.style2 {font-size: 10px}
.style3 {font-size: 10; font-weight: bold; }
.style4 {font-size: 10}
.style5 {
	font-size: 12px;
	font-weight: bold;
	color: #004980;
}
.style6 {font-size: 12px}
.style7 {font-size: 12px; font-weight: bold; color: #004080; }
.style8 {color: #004080}
.style9 {font-size: 10; font-weight: bold; color: #004080; }
-->
</style>
</head>

<body>
<table width="100%" border="1" align="center" cellpadding="0" cellspacing="0">
  <tr id="titulo1">
      <td colspan="6"><div align="center" class="hr style1 style0">TABLA DE ARANCELES VIGENTES</div></td>
  </tr>
  <tr id="titulo1">
    <td align="center">Código</td>
    <td align="center">Descripcion</td>
    <td align=""><div align="center">Costo (UT)</div></td>
    <td align="center">Costo (Bs.)</td>
    <td align="center">Fecha de Vigencia</td>
  </tr>
  <?php do { ?>
    <tr>
      <td><div align="center"><?php echo $row_tblAranceles['codigo']; ?></div></td>
      <td><?php echo $row_tblAranceles['descripcion']; ?></td>
      <td><div align="right"><?php echo number_format($row_tblAranceles['costo_UT'],2, ",", "."); ?></div></td>
      <td><div align="right"><?php echo number_format($row_tblAranceles['costo_Bs'],2, ",", "."); ?></div></td>
      <td><div align="center"><?php echo join ("-",(array_reverse(split("-",$row_tblAranceles['fecha_vigencia'])))) ?></div></td>
    </tr>
    <?php } while ($row_tblAranceles = mysql_fetch_assoc($tblAranceles)); ?>
</table>
&nbsp;
&nbsp;



<table border="0" width="100%" align="center">
  <tr>
    <td width="23%" align="center"><?php if ($pageNum_tblAranceles > 0) { // Show if not first page ?>
          <a href="<?php printf("%s?pageNum_tblAranceles=%d%s", $currentPage, 0, $queryString_tblAranceles); ?>"><img src="imagenes/resultset_first.png" border=0></a>
          <?php } // Show if not first page ?>
    </td>
    <td width="31%" align="center"><?php if ($pageNum_tblAranceles > 0) { // Show if not first page ?>
          <a href="<?php printf("%s?pageNum_tblAranceles=%d%s", $currentPage, max(0, $pageNum_tblAranceles - 1), $queryString_tblAranceles); ?>"><img src="imagenes/resultset_previous.png" border=0></a>
          <?php } // Show if not first page ?>
    </td>
    <td width="23%" align="center"><?php if ($pageNum_tblAranceles < $totalPages_tblAranceles) { // Show if not last page ?>
          <a href="<?php printf("%s?pageNum_tblAranceles=%d%s", $currentPage, min($totalPages_tblAranceles, $pageNum_tblAranceles + 1), $queryString_tblAranceles); ?>"><img src="imagenes/resultset_next.png" border=0></a>
          <?php } // Show if not last page ?>
    </td>
    <td width="23%" align="center"><?php if ($pageNum_tblAranceles < $totalPages_tblAranceles) { // Show if not last page ?>
          <a href="<?php printf("%s?pageNum_tblAranceles=%d%s", $currentPage, $totalPages_tblAranceles, $queryString_tblAranceles); ?>"><img src="imagenes/resultset_last.png" border=0></a>
          <?php } // Show if not last page ?>
    </td>
  </tr>
</table>
</body>
</html>
<?php
mysql_free_result($tblAranceles);
?>
