class html {
var $lng, $conf;
function html() {
global $LNG, $CONF;
$this->lng = &$LNG;
$this->conf = &$CONF;
}
//-----------------------------------------------------------------------------------
// generateHeader
// Genera la cabecera de las paginas HTML
//
// $css => array con las rutas de las distintas hojas de estilo que se van
// a utilizar en la pagina
// $js => array con las rutas a las distintas funciones de JavaScript que
// se van a emplear.
// $js_vars => array asociativo con los nombres de las variables y sus respec-
// tivos valores que se utilizan en algunas de las funciones defi-
// nidas en '$js'.
// $body_options => parametros para la etiqueta '
'
function generateHeader( $css = '', $js = '', $js_vars = '', $body_options = '' ) {
echo '' . "\n";
echo '' . "\n";
echo ' ' . "\n";
echo ' ' . $this->lng['title'] . ' ' . "\n";
echo ' ' . "\n";
if ( is_array($css) ) { foreach ( $css as $stylesheet ) echo ' ' . "\n"; }
if ( is_array($js) ) { foreach ( $js as $javascript ) echo ' ' . "\n"; }
if ( is_array($js_vars) && sizeof($js_vars) > 0 ) {
echo ' ' . "\n";
}
echo '' . "\n";
echo '' . "\n";
}
//-----------------------------------------------------------------------------------
// managePageTitle
// Trata el título de los formularios. Se emplea normalmente para añadir al final del
// titulo el nombre del registro sobre el cual se esta trabajando.
function managePageTitle( &$title, $concat = '' ) {
if ( !empty($concat) ) $title .= ' [ ' . $concat . ' ]';
}
//-----------------------------------------------------------------------------------
// generateDefaultFrame
// Genera la pagina por defecto que se carga al pinchar en cualquiera de las seccio-
// nes del programa.
//
// $page => Nombre de la pagina que queremos cargar.
// $class => Puntero a la clase que se esta utilizando
// $page_params => parámetros a añadir a la página que queremos cargar
// $page_buttons => botonera que deseamos cargar. Este parámetro es útil cuando el
// valor $page no concuerda con la pagina de botones que necesitamos
//
function generateDefaultFrame($page, &$class, $page_params = '', $page_buttons = '', $method = 'GET', $adv_search = FALSE) {
echo '' . "\n";
echo ' ' . "\n";
echo ' ' . "\n";
include($this->conf['fs_frame_buttons'] . ( !empty($page_buttons) ? $page_buttons : $page ) );
echo ' ' . "\n";
echo ' ' . "\n";
if ( $class->records_view['search'] ) {
echo ' ' . "\n";
echo ' ' . "\n";
$this->generateFiltersDiv($class, $page, $page_params, $method, $adv_search);
echo ' ' . "\n";
echo ' ' . "\n";
}
echo ' ' . "\n";
echo ' ' . "\n";
$this->generateListBody($page . $page_params, $class);
echo ' ' . "\n";
echo ' ' . "\n";
if ( $this->lng['legend_01'] ) {
$i = 1;
echo ' ' . "\n";
echo ' ' . "\n";
echo ' ' . "\n";
while ( $i ) {
if ( $this->lng['legend_0' . $i] ) {
echo ' ' . "\n";
echo ' ' . $this->lng['legend_0' . $i] . ' ' . "\n";
$i++;
}
else break;
}
echo ' ' . "\n";
echo ' ' . "\n";
echo ' ' . "\n";
}
echo '
' . "\n";
}
//-----------------------------------------------------------------------------------
// generateListBody
function generateListBody($page, $class, $filter_fields = '', $iframe_params = '') {
echo ' ' . "\n";
echo ' ' . "\n";
echo ' ' . "\n";
$this->generateSectionFields($class, $filter_fields);
echo ' ' . "\n";
echo ' ' . "\n";
echo ' ' . "\n";
echo ' ' . "\n";
echo ' ' . "\n";
echo '
' . "\n";
}
//-----------------------------------------------------------------------------------
// generateFiltersDiv
function generateFiltersDiv($class, $page, $page_params = '', $method = 'GET', $adv_search = '') {
echo ' ' . "\n";
}
//-----------------------------------------------------------------------------------
// generateSectionFields
function generateSectionFields($class, $filter_fields = array()) {
$filter = ( is_array($filter_fields) ? true : false );
echo ' ' . "\n";
echo ' ' . "\n";
while ( list($id) = each($class->records_view['order']) ) {
$record = $class->records_view['order'][$id];
if ( ( $filter && !in_array($record, $filter_fields) ) || !$filter ) echo ' records_view['orderby'][$id] ? ' onClick="orderBy(\'' . $record . '\')"' : '' ) . ( $this->lng['title_field_' . $record . '_alt'] ? ' title="' . $this->lng['title_field_' . $record . '_alt'] . '"' : '' ) . '>' . $this->lng['title_field_' . $record ] . '
' . "\n";
}
echo ' ' . "\n";
reset($class->records_view['order']);
echo ' ' . "\n";
echo '
' . "\n";
}
//-----------------------------------------------------------------------------------
// htmlGenerateRecordsList
// Genera el listado de registros correspondiente a la seccion seleccionada.
//
// $record_list => referencia al listado de registros generado por la clase co-
// rrespondiente.
// $records_view => referencia a la variable de configuracion de la clase que co-
// rresponda. Esta variable define los campos de los cual se dis-
// pone asi como su orden de aparicion de cara al usuario final.
// $html_id => id para la identificacion de la tabla
// $params => parametros a aplicar en cada una de las filas del listado de
// registros.
function htmlGenerateRecordsList( &$record_list, &$records_view, $html_id = '', $params = '', $filter_fields = '', $exclude = '') {
$filter = ( is_array($filter_fields) ? true : false );
html_special_chars($record_list, $exclude);
echo '' . "\n";
echo ' ' . "\n";
echo ' ' . "\n";
echo ' ' . "\n";
echo ' ';
while ( list($id) = each($records_view['order']) ) {
if ( ( $filter && !in_array($records_view['order'][$id], $filter_fields) ) || !$filter ) echo ' ';
}
echo ' ' . "\n";
reset($records_view['order']);
while ( list($record) = each($record_list) ) {
echo ' ' . "\n";
while ( list($id) = each($records_view['order']) ) { if ( ( $filter && !in_array($records_view['order'][$id], $filter_fields) ) || !$filter ) echo ' ' . $record_list[$record][$records_view['order'][$id]] . ' ' . "\n"; }
echo ' ' . "\n";
reset($records_view['order']);
}
echo '
' . "\n";
echo ' ' . "\n";
echo ' ' . "\n";
echo '
' . "\n";
}
//-----------------------------------------------------------------------------------
// htmlGenerateRecordList
function htmlGenerateRecordList( &$record_list, &$records_view, $html_id = '', $params = '', $filter_fields = '') {
$filter = ( is_array($filter_fields) ? true : false );
echo '' . "\n";
echo ' ' . "\n";
echo ' ' . "\n";
echo ' ' . "\n";
echo ' ';
while ( list($id) = each($records_view['order']) ) {
if ( ( $filter && !in_array($records_view['order'][$id], $filter_fields) ) || !$filter ) echo ' ';
}
echo ' ' . "\n";
reset($records_view['order']);
while ( list($record) = each($record_list) ) {
echo ' ' . "\n";
while ( list($id) = each($records_view['order']) ) {
if ( ( $filter && !in_array($records_view['order'][$id], $filter_fields) ) || !$filter ) {
$field = $records_view['order'][$id];
$nobr = ( isset($record_list[$record][$field]['nobr']) ? $record_list[$record][$field]['nobr'] : true );
echo ' ' . ( $nobr ? '' : '' ) . $record_list[$record][$field]['value'] . ( $nobr ? ' ' : '' ) . ' ' . "\n";
}
}
echo ' ' . "\n";
reset($records_view['order']);
}
echo '
' . "\n";
echo ' ' . "\n";
echo ' ' . "\n";
echo '
' . "\n";
}
//-----------------------------------------------------------------------------------
// generateCalendar
// Genera un calendario para el mes y año indicados.
//
// $year => Año para el cual queremos obtener el calendario.
// $month => Mes para el cual queremos obtener el calendario.
// $party_days => array asociativo con los dias festivos del mes seleccionado y su
// nombre.
function generateCalendar( $year, $month, $party_days = array() ) {
$first_of_month = mktime (0,0,0, $month, 1, $year);
$num_month_days = date('t', $first_of_month);
$date_info = getdate($first_of_month);
$day_headings = array($this->lng['cal_monday'], $this->lng['cal_tuesday'], $this->lng['cal_wednesday'], $this->lng['cal_thursday'], $this->lng['cal_friday'], $this->lng['cal_saturday'], $this->lng['cal_sunday']);
$weekday = $date_info['wday'];
$previus_month_params = ( $month == 1 ? '?m=12&y=' . ( $year - 1 ) : '?m=' . ( $month - 1 ) . '&y=' . $year );
$next_month_params = ( $month == 12 ? '?m=1&y=' . ( $year + 1 ) : '?m=' . ( $month + 1 ) . '&y=' . $year );
echo '×
';
echo '' . "\n";
echo ' ' . "\n";
echo ' ' . $date_info['month'] . ' ' . $year . ' ' . "\n";
echo ' ';
foreach ( $day_headings as $day ) echo '' . $day . ' ';
echo ' ' . "\n";
echo ' ';
if ( $weekday == 0 ) $colspan = 6;
if ( $weekday > 1 ) $colspan = $weekday - 1;
if ( $colspan ) echo ' ';
for ( $day=1; $day<=$num_month_days; $day++ ) {
if ( $weekday == 7 ) $weekday = 0;
echo '' . $day . ' ';
if ( $weekday == 0 ) { echo ' ' . "\n" . ' '; }
$weekday++;
}
echo '
' . "\n";
echo ' ' . "\n";
}
//-----------------------------------------------------------------------------------
// generateClosePage
function generateClosePage($js) {
$this->generateHeader( '', array($this->conf['js_forms']), '', 'onLoad="closeWindow()"');
$this->generateFooterPage();
}
//-----------------------------------------------------------------------------------
// generateTransitionPostPage
function generateTransitionPostPage( $location, &$post_values ) {
$this->generateHeader( '', array($this->conf['js_forms']), '', 'onLoad="document.forms.values.submit();"');
$this->generateForm('values', 'POST', $post_values, $location);
$this->generateFooterPage();
}
//-----------------------------------------------------------------------------------
// generateForm
function generateForm( $name, $method, $values, $action = '' ) {
echo '' . "\n";
}
//-----------------------------------------------------------------------------------
// generateErrorDiv
function generateErrorDiv(&$error_string) {
echo '' . "\n";
echo '
×
';
echo '
' . "\n";
echo ' ' . "\n";
echo ' ' . "\n";
echo ' ' . $this->lng['text_error'] . $error_string . ' ' . "\n";
echo ' ' . "\n";
echo '
' . "\n";
echo '
' . "\n";
}
//-----------------------------------------------------------------------------------
// generateCalendarDiv
function generateCalendarDiv() {
echo '
' . "\n";
}
//-----------------------------------------------------------------------------------
// generateRecordsBar
function generateRecordsBar(&$page, &$num_records, $link, $js = '') {
$FC_rows_per_page = $this->conf['max_num_regs_list'];
$FC_num_links = $this->conf['max_num_links'];
$FC_current_page = $page;
$FC_num_ids = $num_records;
$FC_num_pages = ceil( $FC_num_ids / $FC_rows_per_page );
$FC_current_win = ceil( $FC_current_page / $FC_num_links );
$FC_max_num_win = ceil( $FC_num_pages / $FC_num_links );
$FC_id_start = ( ( $FC_current_page - 1 ) * $FC_rows_per_page ) + 1;
$FC_id_end = ( ( ( $FC_id_start + $FC_rows_per_page ) <= $FC_num_ids ) ? ( ( $FC_id_start - 1 ) + $FC_rows_per_page ) : $FC_num_ids );
echo '';
}
//-----------------------------------------------------------------------------------
// generateDivSelector
function generateDivSelector($divs) {
if ( is_array($divs) ) {
echo ' ' . "\n";
echo ' ' . "\n";
for ( $i=0; $i' . $divs[$i] . ' ' . "\n";
echo ' ' . "\n";
echo ' ' . "\n";
echo '
' . "\n";
}
}
//-----------------------------------------------------------------------------------
// generateSelectField
function generateSelectField($options = '', $name, $selected = '', $required = true, $params = '', $optgroup = array()) {
$groups = '0';
echo '' . "\n";
if ( is_array($options) ) {
if ( !$required ) echo ' ' . "\n";
foreach ( $options as $id => $value ) {
if ( in_array($id, $optgroup) ) {
if ($groups > 0) echo '' . "\n";
echo '' . "\n";
$groups++;
}
else echo '' . $value . ' ' . "\n";
}
if ( $groups > 0 ) echo ' ' . "\n";
}
echo ' ' . "\n";
if (!empty($params) && ereg("disabled",$params)) {
$valores = ( is_array($selected) ? implode(",",$selected) : $selected );
echo ' ' . "\n";
}
}
//-----------------------------------------------------------------------------------
// generateFormButtons
function generateFormButtons( $buttons = '', $button_actions = '' ) {
$global_buttons = array();
$global_buttons[] = array( 'href' => 'javascript:sendForm(true);',
'title' => $this->lng['button_save_close'],
'img' => 'boton_guardar_cerrar.gif',
'img_des' => 'boton_guardar_cerrar_des.gif',
'status' => true );
$global_buttons[] = array( 'href' => 'javascript:sendForm();',
'title' => $this->lng['button_save'],
'img' => 'boton_guardar.gif',
'img_des' => 'boton_guardar_des.gif',
'status' => true );
$global_buttons[] = array( 'href' => 'javascript:window.close();',
'title' => $this->lng['button_close'],
'img' => 'boton_cerrar.gif',
'status' => true );
$global_buttons[] = array( 'href' => 'javascript:window.print();',
'title' => $this->lng['button_print'],
'img' => 'boton_imprimir.gif',
'status' => true,
'params' => 'class="separation"' );
if ( is_array($buttons) ) $global_buttons = array_merge($global_buttons, $buttons);
if ( is_array($button_actions) ) {
while ( list($id) = each($button_actions) ) {
if ( is_array($button_actions[$id]) ) {
while ( list($key) = each($button_actions[$id]) ) $global_buttons[$id][$key] = $button_actions[$id][$key];
}
}
}
echo '' . "\n";
}
//-----------------------------------------------------------------------------------
// generateJsButtons
function generateJsButtons( $buttons ) {
if ( is_array($buttons) ) {
echo '' . "\n";
}
}
//-----------------------------------------------------------------------------------
// generateCompanySelectionPage
function generateSelectionPage($general_options, $record_list, $title_section = '', $search_var = '', &$params) {
if ( !isset($params['type_list']) ) $params['type_list'] = '1';
echo ' ' . "\n";
echo ( !empty($title_section) ? ' ' . $title_section . ' ' . "\n" : '' );
echo ' ' . "\n";
echo ' ' . "\n";
echo ' ' . "\n";
echo ' ' . $this->lng['form_action'] . '
' . "\n";
echo ' ' . "\n";
$this->generateSelectField($general_options, 'type_list', $params['type_list'], true, 'onChange="showTd(this, \'company\')"');
echo ' ' . "\n";
echo ' ' . "\n";
echo '
' . "\n";
echo ' ' . "\n";
echo ' ' . "\n";
echo ' ' . $this->lng['form_select'] . '
' . "\n";
echo ' ' . "\n";
$this->generateSelectField($record_list, 'record_id1', '', false);
echo ' ' . "\n";
echo ' ' . "\n";
echo '
' . "\n";
echo ' ' . "\n";
echo ' ' . "\n";
}
//-----------------------------------------------------------------------------------
// generateArrayList
function generateRecordsList( $records, $str_start = '', $str_end = ' ' ) {
if ( is_array($records) && count($records) > 0 ) {
while ( list($id) = each($records) ) echo $str_start . $records[$id] . $str_end . "\n";
}
}
//-----------------------------------------------------------------------------------
// generateFooterPage
function generateFooterPage() {
echo '' . "\n";
echo '' . "\n";
}
//-----------------------------------------------------------------------------------
// generateDefaultError
function generateDefaultError() {
$error = '' . $this->lng['general_error'] . ' ';
$this->generateHeader( array($this->conf['css_forms']), array($this->conf['js_forms']), '', 'onLoad="init()"');
$this->generateErrorDiv($error);
$this->generateFooterPage();
}
//-----------------------------------------------------------------------------------
// generateMasterListBar
function generateMasterListBar( $exerciseName = '', $link, $link_params = '', $params, $startDate, $endDate, $month, $year ) {
$currentDate = $year . date('m', mktime(0, 0, 0, $month, 1, $year ) );
$previusMonthParams = ( $month == 1 ? ( $year - 1 ) . '12' : $year . date('m', mktime(0, 0, 0, ( $month - 1 ), 1, $year ) ) );
$nextMonthParams = ( $month == 12 ? ( $year + 1 ) . '01' : $year . date('m', mktime(0, 0, 0, ( $month + 1 ), 1, $year ) ) );
echo '' . "\n";
}
//-----------------------------------------------------------------------------------
// generateTimeTable
function generateTimeTable( &$params, $refIds, $title = '', $startDate = '', $endDate = '', $tableType = 0 ) {
$table = array();
for ( $day=1; $day<=7; $day++ ) {
$nextId = 0;
if ( $params[$day] ) {
while ( list($interval) = each($params[$day]) ) {
if ( $tableType && $params[$day][$interval]['start'] % 2 == 0 ) $params[$day][$interval]['start'] = ( $params[$day][$interval]['start'] + 1 );
$table[$day][$params[$day][$interval]['start']] = array ( 'value' => nl2br(implode(' ', $params[$day][$interval]['groups'])), 'span' => ( $tableType ? ( ( $params[$day][$interval]['end'] - $params[$day][$interval]['start'] ) / 2 ) : ( $params[$day][$interval]['end'] - $params[$day][$interval]['start'] ) ) );
}
}
while ( list($id) = each($refIds) ) {
if ( ( !isset($table[$day][$id]) ) && ( $id >= $nextId ) ) $table[$day][$id] = '';
elseif ( $id >= $nextId ) $nextId = $id + ( $tableType ? ( $table[$day][$id]['span'] * 2 ) : $table[$day][$id]['span'] );
}
reset($refIds);
}
if ( $title ) echo '' . htmlspecialchars($title) . '
' . "\n";
echo '' . "\n";
echo ' ' . "\n";
for ( $i=0; $i<=7; $i++ ) echo ' ' . $this->lng['timetable_title_' . $i] . ' ' . "\n";
echo ' ' . "\n";
while ( list($id) = each($refIds) ) {
echo ' ' . "\n";
echo ' ' . $refIds[$id]['start'] . '-' . $refIds[$id]['end'] . ' ' . "\n";
for ( $day=1; $day<=7; $day++ ) {
if ( isset($table[$day][$id]) ) {
if ( is_array($table[$day][$id]) ) echo ' 1 ? ' rowspan="' . $table[$day][$id]['span'] . '"' : '' ) . '>' . $table[$day][$id]['value'] . ' ' . "\n";
else echo ' ' . "\n";
}
}
echo ' ' . "\n";
}
echo '
' . "\n";
}
function generateIconList( &$icons, $location, $field = 'icon' ) {
if ( is_array($icons) ) {
echo '';
foreach ( $icons AS $icon ) echo ' ';
echo ' ' . "\n";
}
}
function generateIconListSections( &$icons, $location, $field = 'icon' ) {
if ( is_array($icons) ) {
echo '';
foreach ( $icons AS $icon ) echo ' ';
echo ' ' . "\n";
}
}
}
?>