class splitPageResults {
function splitPageResults(&$current_page_number, $max_rows_per_page, &$sql_query, &$query_num_rows) {
global $db;
$reviews_count_query = $db->query($sql_query);
if (DB::isError($reviews_count_query)) die("SQL Error: " . $reviews_count_query->userinfo);
if (empty($current_page_number)) $current_page_number = 1;
$offset = ($max_rows_per_page * ($current_page_number - 1));
$sql_query .= " limit " . $offset . ", " . $max_rows_per_page;
$query_num_rows = $reviews_count_query->numRows();
}
function display_links($query_numrows, $max_rows_per_page, $max_page_links, $current_page_number, $parameters = '') {
global $PHP_SELF;
$parameters = ($parameters == '') ? '' : $parameters . '&';
$num_pages = intval($query_numrows / $max_rows_per_page);
if ($query_numrows % $max_rows_per_page) $num_pages++; // has remainder so add one page
if ($current_page_number > 1) echo ' ';
$cur_window_num = intval($current_page_number / $max_page_links);
if ($current_page_number % $max_page_links) $cur_window_num++;
$max_window_num = intval($num_pages / $max_page_links);
if ($num_pages % $max_page_links) $max_window_num++;
if ($cur_window_num > 1) echo ' ';
if ($current_page_number > 1) echo ' ';
for ($jump_to_page = 1 + (($cur_window_num - 1) * $max_page_links); ($jump_to_page <= ($cur_window_num * $max_page_links)) && ($jump_to_page <= $num_pages); $jump_to_page++) {
if ($jump_to_page == $current_page_number) {
echo '[' . $jump_to_page . ' ] ';
} else {
echo '' . $jump_to_page . ' ';
}
}
if (($current_page_number < $num_pages) && ($num_pages != 1)) echo ' ';
if ($cur_window_num < $max_window_num) echo ' ';
if (($current_page_number < $num_pages) && ($num_pages != 1)) echo ' ';
}
function display_count($query_numrows, $max_rows_per_page, $current_page_number, $text_output) {
$to_num = ($max_rows_per_page * $current_page_number);
if ($to_num > $query_numrows) $to_num = $query_numrows;
return sprintf($text_output, ($max_rows_per_page * ($current_page_number - 1))+1, $to_num, $query_numrows);
}
}
?>
function plantilla_parse($file, &$plantilla, &$tags) {
// Get file contents
$plantilla_array = file($file);
$plantilla_contents = implode('', $plantilla_array);
// Get pieces
$plantilla = explode('((CORTE))', ereg_replace('\(\(([A-Z0-9_]+)\)\)', '((CORTE))', $plantilla_contents));
// Get tags
$tags = array();
while (ereg('\(\(([A-Z0-9_]+)\)\)', $plantilla_contents, $results)) {
list($before, $after) = explode($results[0], $plantilla_contents, 2);
$plantilla_contents = $before . $after;
$tags[] = $results[1];
}
$tags[] = 'END';
}
function date_to_timestamp($date) {
$parts = explode(' ', $date);
$date_parts = explode('-', $parts[0]);
$time_parts = explode(':', $parts[1]);
return mktime((int)$time_parts[0], (int)$time_parts[1], (int)$time_parts[2], (int)$date_parts[1], (int)$date_parts[2], (int)$date_parts[0]);
}
function timestamp_to_date($date) {
return ($date) ? "'" . implode("-", array_reverse(explode("/", $date))) . "'": 'NULL';
}
function draw_select($name, $values, $selected = '', $additional = '') {
$result = '';
if ($additional) $additional = ' ' . $additional;
$result .= '';
reset($values);
while (list($key, $value) = each($values)) {
$result .= '';
}
$result .= ' ';
return $result;
}
function draw_input_date($name, $value) {
$return = '';
$return .= ' ';
$return .= ' ';
return $return;
}
function header_title($client, $asunto = '', $saldo = false) {
global $db, $savepage, $savesort;
$res = '
';
if ($client) {
$res .= ' Cliente: ';
$values = $db->getRow("select * from CLIENTES where NUMERO = '$client'");
$res .= $client . ' - ' . $values['APELLIDOS'];
if ($values['NOMBRE']) {
$res .= ', ' . $values['NOMBRE'];
}
$res .= ' ';
}
if ($asunto) {
$res .= ' Asunto: ';
$values = $db->getRow("select NUMERO, ASUNTO from ASUNTOS where CLIENTE = '$client' and NUMERO = '$asunto'");
$res .= $values['NUMERO'] . ' - ' . $values['ASUNTO'];
$res .= ' ';
}
if ($saldo) {
$res .= ' Saldo: ';
$total = $db->getOne("select sum(INGRESO-PAGO) as total from CUENTAS where NUMERO = '$client' and ASUNTO = '$values[NUMERO]'");
$res .= ' ' . number_format($total, 2);
$res .= ' € ';
}
$res .= '
';
if ($client and !$asunto) {
$values['ALTA'] = date('d/m/Y', date_to_timestamp($values['ALTA']));
$values['DOMICILIO1'] = nl2br($values['DOMICILIO1']);
$values['DOMICILIO2'] = nl2br($values['DOMICILIO2']);
$values['NOTAS'] = nl2br($values['NOTAS']);
$res .= <<
ALTA $values[ALTA]
PASAPORTE $values[CIF]
NIE $values[NIE]
DOMICILIO HABITUAL $values[DOMICILIO1]
TELEFONO $values[TELEFONO1]
FAX $values[FAX1]
MOVIL $values[MOVIL1]
EMAIL $values[EMAIL1]
DOMICILIO EN ESPAŅA $values[DOMICILIO2]
TELEFONO $values[TELEFONO2]
FAX $values[FAX2]
MOVIL $values[MOVIL2]
CONYUGE $values[CONYUGE]
PASAPORTE $values[CIF2]
NIE $values[NIE2]
ENVIADO POR $values[ENVIADO]
BANCO $values[BANCO]
CUENTA $values[CUENTA]
REP. FISCAL $values[ADMINISTRA]
CONJUNTA $values[CONJUNTA]
AGENCIA $values[AGENCIA]
TELEFONO $values[AGENCIA_TEL]
FAX $values[AGENCIA_FAX]
PODER COMPRA $values[PC]
PODER PLEITOS $values[PP]
PODER FISCAL $values[PG1]
PODER VENTA $values[PG2]
PODER GENERAL $values[PG3]
EXP. PATRIMONIO $values[EP]
EOD;
}
return $res;
}
?>