/** * Construye la lista dinamica * @param $showQueryForm Mostrar formulario de consulta * @param $showFirstRule Mostrar primera regla de formulario de consulta * @return unknown_type */ private function buildList($showQueryForm, $showFirstRule) { $buf = ''; if ($this->sqlORobject) { if (is_object($this->sqlORobject)) { // Objeto $this->objConn = $this->sqlORobject; $sql = $this->sql = ''; $countFields = count($fields = get_class_vars($table = get_class($this->sqlORobject))); $subSqlF = ''; $iCounter = 1; foreach ($fields as $field => $value) { $subSqlF .= $field; $this->setRealNameInQuery($field, $field); if ($iCounter < $countFields) { $subSqlF .= ', '; } ++$iCounter; } $sql = 'SELECT ' . $subSqlF . ' FROM ' . $table; $this->sql = $sql; } else { // Cadena $this->objConn = new OPF_myActiveRecord(); $sql = $this->sql = $this->sqlORobject; } if ($this->objConn->isSuccessfulConnect()) { $this->resSql = $this->objConn->query($this->sql . '' . $this->getSqlPartOrderBy() . '' . $this->getSqlPartLimit()); } $this->engineDb = $this->objConn->getEngine(); } else { $this->restVarsSess(); $this->objConn = new OPF_myActiveRecord(); $sql = $this->sql . '' . $this->getSqlPartWhere() . '' . $this->getSqlPartOrderBy() . '' . $this->getSqlPartLimit(); if ($this->objConn->isSuccessfulConnect()) { $this->resSql = $this->objConn->query($sql); } } if ($this->objConn->getErrorLog(true)) { $this->successFul = false; } # Numero de campos afectados $this->numFldsAftd = $this->objConn->getNumFieldsAffected(); # Numero de registro afectados $this->numAffectedRows = $this->objConn->getNumRowsAffected(); /** * Calcular el ancho de cada columna si no hay definido * un ancho especifico definido antes por el usuario. */ $widByCol = 0; $totWid = $this->width; $return = $bufHead = $cadParam = ''; $buf .= '<div id="' . $this->idList . '" name="' . $this->idList . '">' . "\n"; if ($this->useSqlDebug) { $buf .= '<div style="text-align:left" class="form_cont_filter"><b>Sql: </b>' . $sql . '<br>'; $buf .= '<b>Registros: </b>' . $this->numAffectedRows . '</div><br>'; } if (!$this->successFul) { $buf .= $this->objConn->getErrorLog(true); } else { $i = 0; if ($this->numAffectedRows) { $buf .= "\n" . '<table border="0" width="' . $this->width . '' . $this->formatWidthList . '" cellspacing="0" cellpadding="0" align="center"><tr><td class="list">' . "\n"; foreach ($this->arrayWidthsCols as $col => $wid) { $totWid -= $wid; } if ($totWid) { $widByCol = $totWid / ($this->numFldsAftd - count($this->arrayWidthsCols)); } $sw = false; $buf .= "\n" . '<table border="0" width="100%" cellspacing="' . $this->borderCellSize . '" cellpadding="0" id="table_' . $this->idList . '">' . "\n"; $i = 0; $classTd = 'td_default'; $rows = $this->resSql; foreach ($rows as $row) { if ($this->useDistBetwRows) { if ($i % 2) { $classTd = 'td_default'; } else { $classTd = 'td_middle'; } } # Titulos de las columnas if (!$sw) { $this->arrayFieldsOnQuery = array(); $arrColOrd = array(); $sw = true; $bufHead .= '<tr>' . "\n" . "\t"; $arrayOrdNum = array(); $cOrd = 1; foreach ($this->arrayOrdNum as $nom) { $arrayOrdNum[$nom] = $cOrd; ++$cOrd; } $this->firsKey = true; foreach ($row as $key => $val) { if (!is_numeric($key)) { $key = $key; $this->arrayFieldsOnQuery[] = $key; $widCol = 0; if (isset($this->arrayWidthsCols[$key])) { $widCol = $this->arrayWidthsCols[$key]; } else { $widCol = $widByCol; } $orderBy = ''; $numOrder = ' '; if ($this->firsKey) { $htmlGlobal = '{htmlGlobal}'; $this->firsKey = false; } else { $htmlGlobal = ' '; } if ($this->useOrderMethod && !isset($this->arrayEventOnColumn[$key])) { $orderBy = ''; if (isset($this->arrayOrdMethod[$key])) { $orderBy = $this->arrayOrdMethod[$key]; } $styleName = 'cell_title'; if ($orderBy) { $cadParam .= '2,'; $styleName = 'cell_title_selected'; $arrColOrd[] = $key; $numOrder = $arrayOrdNum[$key]; } else { $cadParam .= '1,'; } $bufHead .= '<td class="' . $styleName . '" width="' . $widCol . '" align="center">'; $bufHead .= '<table border="0" cellspacing="0" cellpadding="0" width="100%" align="center"><tr><td width="20px">' . $htmlGlobal . '</td><td width="" style="text-align:center">'; $bufHead .= '<a class="column_title" href="javascript:;" onClick="MYLIST_moveTo(\'' . $this->idList . '\',\'' . $key . '\')">' . ucwords($key) . '</a>'; $classOrd = 'num_ord_ref'; switch ($orderBy) { case 'ASC': $classOrd = 'num_ord_ref_asc'; break; case 'DESC': $classOrd = 'num_ord_ref_desc'; break; } $bufHead .= '</td><td width="20px" class="' . $classOrd . '">' . $numOrder . '</td></tr></table>'; $bufHead .= '</td>'; } else { $cadParam .= '1,'; $bufHead .= '<td width="' . $widCol . '" align="center" class="cell_title">'; $bufHead .= '<table border="0" cellspacing="0" cellpadding="0" width="100%" align="center"><tr><td width="20px">' . $htmlGlobal . '</td><td align="center">'; $bufHead .= '<font class="column_title">' . ucwords($key) . '</font>'; $bufHead .= '</td><td width="20px"> </td></tr></table>'; $bufHead .= '</td>'; } } } $bufHead .= '</tr>' . "\n"; $bufHead = str_replace('{htmlGlobal}', $this->returnCheckBox($this->numFldsAftd, $cadParam), $bufHead); $buf .= '{bufHead}'; } $nmCheck = ''; if ($this->globalEventOnColumn) { $alsGbl = $this->globalEventOnColumn; if ($row->{$alsGbl}) { $nmCheck = $this->idList . '_' . $row->{$alsGbl}; } } $buf .= '<tr '; $buf .= 'id="tr_' . $this->idList . '_' . $i . '" '; $buf .= 'onDblClick="markRow(this, \'' . $classTd . '\',\'' . substr($cadParam, 0, -1) . '\', ' . $this->numFldsAftd . ', \'' . $nmCheck . '\')" '; $buf .= 'onmouseover="onRow(this, ' . $this->numFldsAftd . ')" '; $buf .= 'onmouseout="outRow(this, \'' . $classTd . '\',\'' . substr($cadParam, 0, -1) . '\', ' . $this->numFldsAftd . ')" '; $buf .= '>' . "\n" . "\t"; $firsVal = true; foreach ($row as $key => $val) { if (!is_numeric($key)) { if (!$val) { $Value = ' '; } $buf .= '<td class="'; if (in_array($key, $arrColOrd)) { $class = 'cell_content_selected'; } else { $class = $classTd; } $buf .= $class . '">'; if ($firsVal && $this->globalEventOnColumn) { $nmCheck = $this->idList . '_' . $row->{$alsGbl}; if ($row->{$alsGbl}) { $this->objForm->addEvent($nmCheck, 'onclick', 'check_onlist', array($nmCheck)); $buf .= '<table border="0" cellspacing="0" cellpadding="0" width="100%" align="center"><tr><td width="20px">' . $this->objForm->getCheckBox($nmCheck) . '</td><td class="' . $class . '_checkbox">'; } else { $buf .= '<table border="0" cellspacing="0" cellpadding="0" width="100%" align="center"><tr><td width="20px"></td><td class="' . $class . '_checkbox">'; } } if (isset($this->arrayEventOnColumn[$key])) { list($event, $strMsg) = explode('::', $this->arrayEventOnColumn[$key]); if ($strMsg) { $strMsg = ' onClick="return confirm(\'' . $strMsg . '\')"'; } if ($val) { $buf .= '<a href="javascript:void(' . $event . '(\'' . $val . '\',\'' . $this->idList . '\'))"' . $strMsg . '>' . ucwords($key) . '</a>'; } } else { if (isset($this->externalMethods[$key])) { $strNameMethod = $this->externalMethods[$key]['strNameMethod']; $buf .= $this->externalMethods[$key]['objClass']->{$strNameMethod}($val) . ' '; } else { $buf .= $val . ' '; } } if ($firsVal && $this->globalEventOnColumn) { $buf .= '</td><td width="20px"> </td></tr></table>'; $firsVal = false; } $buf .= '</td>'; } } $buf .= "\n" . '</tr>' . "\n"; ++$i; } $buf .= '</tbody>' . "\n"; $buf .= '</table>' . "\n"; $buf .= '</td></tr></table>' . "\n"; } else { //TODO: No hay registros afectados } } $buf .= '<div style="width:' . $this->width . '' . $this->formatWidthList . '" id="pag_' . $this->idList . '" name="pag_' . $this->idList . '">' . "\n"; $buf .= '<table cellspacing="0" cellpadding="0" border="0" align="center" width="100%"><tr><td align="left" width="33%">'; if ($this->globalEventOnColumn && $this->successFul) { $idSelect = 'global_event_' . $this->idList; $this->objForm->name = $this->idList; $this->objForm->selectStringFirstLabelOption = LABEL_FIRST_OPT_SELECT_GLOBAL_ACTION; $this->objForm->styleTypeHelp = 2; $this->objForm->addEvent($idSelect, 'onchange', 'execGlobalEventOnList', $this->idList, $idSelect); $this->objForm->addHelp($idSelect, LABEL_HELP_SELECT_GLOBAL_ACTION); $buf .= $this->objForm->getSelect($idSelect, array_flip($this->globalEventsName)); } else { $buf .= ' '; } $buf .= '</td><td width="34%" align="center">'; # Usar paginacion if ($this->usePagination && $this->successFul) { $arrBut = array('_ini_page' => array(' -- ', 'beg', 'button'), '_back_page' => array(' -1 ', 'bac', 'button'), '_goto_page' => array($this->currentPage + 1, 'goto', 'field'), '_chg_pag' => array(array(1 => $this->recordsPerPage * 1, 2 => $this->recordsPerPage * 2, 3 => $this->recordsPerPage * 3, 4 => $this->recordsPerPage * 4, 5 => $this->recordsPerPage * 5), 'amp_pag', 'select'), '_next_page' => array(' +1 ', 'nex', 'button'), '_end_page' => array(' ++ ', 'end', 'button')); $objMyForm = new OPF_myForm(); $objMyForm->selectUseFirstValue = false; $objMyForm->setParamTypeOnEvent('field'); $objMyForm->styleTypeHelp = 2; $objMyForm->addHelp($this->idList . '_end_page', ' ' . GOTO_LAST_PAGE . ' '); $objMyForm->addHelp($this->idList . '_ini_page', ' ' . GOTO_FIRST_PAGE . ' '); $objMyForm->addHelp($this->idList . '_next_page', ' ' . GOTO_NEXT_PAGE . ' '); $objMyForm->addHelp($this->idList . '_back_page', ' ' . GOTO_BACK_PAGE . ' '); $buf .= '<table cellspacing="0" cellpadding="0" border="0" align="center" width="250"><tr>'; if ($this->currentPage == 0) { $objMyForm->addDisabled($this->idList . '_ini_page'); $objMyForm->addDisabled($this->idList . '_back_page'); } if ($i < $this->recordsPerPage * $this->recordsPerPageForm) { $objMyForm->addDisabled($this->idList . '_next_page'); $objMyForm->addDisabled($this->idList . '_end_page'); } if ($this->currentPage == $this->maxNumPage) { $objMyForm->addDisabled($this->idList . '_end_page'); } foreach ($arrBut as $id => $attr) { $buf .= '<td>'; switch ($attr[2]) { case 'button': $objMyForm->addEvent($this->idList . $id, 'onclick', 'MYLIST_page', $this->idList, $attr[1]); $buf .= $objMyForm->getButton($this->idList . $id, '', '' . '../mylist/' . $id . '.gif'); break; case 'field': $objMyForm->addHelp($this->idList . $id, ' ' . LABEL_HELP_PAGACT_FORM . ' <b>' . $attr[0] . '</b>' . ' '); $buf .= $objMyForm->getText($this->idList . $id, $attr[0], 1, NULL, true); break; case 'select': $objMyForm->addHelp($this->idList . $id, ' ' . LABEL_HELP_CHPAG_SELECT_FORM . ' '); $objMyForm->addEvent($this->idList . $id, 'onchange', 'MYLIST_chPag', $this->idList); $buf .= $objMyForm->getSelect($this->idList . $id, $attr[0], $this->recordsPerPageForm); break; } $buf .= '</td>'; } $buf .= '</tr></table>'; } $buf .= '</td><td width="33%" align="right" class="texto_formularios"> </td></tr></table></div>' . "\n"; $buf .= '' . '</div>' . "\n"; $this->bufHtml = str_replace('{bufHead}', $bufHead, $buf); if ($showQueryForm && $this->successFul) { $this->bufHtml = $this->buildQueryForm($showFirstRule) . $this->bufHtml; } # Registramos las variables que se han usado $this->regAttClass(get_class_vars(get_class($this))); }
public function __construct($nA, $nM, $nDp, $update, $form_name = '') { $nDp = intval($nDp); $sw = false; $nSem = intval(date('W', mktime(0, 0, 0, $nM, 1, $nA))); $nDsh = $nMsh = ''; $arrMonth = array(); foreach ($this->arrMonth as $id => $month) { $arrMonth[$nDp . '_' . $id . '_' . $nA] = $month; } /** * Construimos un arreglo de datos para los años */ for ($aIni = $nA - 30; $aIni < $nA + 5; ++$aIni) { if ($aIni >= 1902) { $this->arrYears[$nDp . '_' . $nM . '_' . $aIni] = $aIni; } } $objMyForm = new OPF_myForm(); $iniCell = '<td class="cellday" onmouseover="this.className=\'cellday_over\'" onmouseout="this.className=\'cellday\'" {onclick}>'; $endCell = '</td>'; $htm = ''; $htm .= '<table cellpadding="0" cellspacing="0"><tr><td class="tablecal">'; $htm .= '<table cellpadding="1" cellspacing="1" border=0>'; $htm .= '<tr>'; $htm .= '<td class="celldays">' . CAL_WK_LABEL . '</td>'; foreach ($this->arrDsem as $id => $le) { $htm .= '<td class="celldays">' . $le . '</td>'; } $htm .= '</tr>'; $nDmax = date('d', mktime(0, 0, 0, $nM + 1, 0, $nA)); $nD = 1; $cDpm = 1; $fNdf = 0; $cDam = 0; $toShow = true; while ($nD <= $nDmax) { foreach ($this->arrDsem as $id => $le) { $w = date('N', mktime(0, 0, 0, $nM, $nD, $nA)); if ($w == 1 || !$sw) { $htm .= '<tr>'; $sw = true; $htm .= '<td class="cell_week">' . $nSem . '</td>'; } if ($nD <= $nDmax) { if ($w == $id) { $nMsh = $nM; if ($nM < 10) { $nMsh = '0' . $nM; } $nDsh = $nD; if ($nD < 10) { $nDsh = '0' . $nD; } if (!$fNdf) { $fNdf = $id; } $onclick = 'onclick="selectDate(\'' . $nA . '-' . $nMsh . '-' . $nDsh . '\',\'' . $update . '\',\'' . $form_name . '\')"'; $iniA = '<a href="javascript:;" class="celldays_a" ' . $onclick . '>'; $endA = '</a>'; if ($nM . $nD . $nA == date('mjY')) { $htm .= '<td class="cellday_today" ' . $onclick . '>' . $iniA . $nD . $endA . $endCell; } else { $htm .= str_replace('{onclick}', $onclick, $iniCell) . $iniA . $nD . $endA . $endCell; } ++$nD; } else { if (!$cDam) { $cDam = date('t', mktime(0, 0, 0, $nM, 0, $nA)) - ($w - 2); } $htm .= $iniCell . '<div class="cell_other_days">' . $cDam . '</div>' . $endCell; ++$cDam; } } else { $htm .= $iniCell . '<div class="cell_other_days">' . $cDpm . '</div>' . $endCell; ++$cDpm; } } $nSem = intval(date('W', mktime(0, 0, 0, $nM, $nD, $nA))); } $objMyForm->setParamTypeOnEvent('field'); $objMyForm->selectUseFirstValue = false; $objMyForm->styleClassFields = 'select_calendar'; $objMyForm->addEvent('cal_month', 'onchange', 'MYFORM_calOnChange', $update, $form_name); $objMyForm->addEvent('cal_year', 'onchange', 'MYFORM_calOnChange', $update, $form_name); $objMyForm->addEvent('close_call', 'onclick', 'closeCalendarWindow', $update); $htm .= '<tr>'; $htm .= '<td colspan="8" class="cell_control">' . '<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr>' . '<td>' . $objMyForm->getSelect('cal_month', $arrMonth, $nDp . '_' . $nM . '_' . $nA) . '</td>' . '<td>' . $objMyForm->getSelect('cal_year', $this->arrYears, $nDp . '_' . $nM . '_' . $nA) . '</td>' . '<td align="right">' . $objMyForm->getButton('close_call', 'X') . '</td>' . '</tr></table>' . '</td>'; $htm .= '</tr>'; $htm .= '</table>'; $htm .= '</td></tr></table>'; $this->calOut = $htm; }
public function getFormInstall($type, $datForm = '', $disabled = false) { $myForm = new OPF_myForm('install_essentials'); $arEngine = array('mysql' => 'MySQL', 'pgsql' => 'PostgreSQL'); $myForm->setParamTypeOnEvent('field'); $myForm->addEvent('engine', 'onchange', 'onChangeEngine'); $myForm->setParamTypeOnEvent('global'); $engine = ''; if (isset($datForm['engine'])) { $engine = $datForm['engine']; } if ($disabled) { $myForm->addDisabled('engine'); } $myForm->addSelect(OPF_myLang::getPhrase('OPF_LOGIN_8'), 'engine', $arEngine, $engine); $db = ''; if (isset($datForm['db'])) { $db = $datForm['db']; } $myForm->addText(OPF_myLang::getPhrase('OPF_LOGIN_12'), 'db', $db); $encoding = 'UTF8'; if (isset($datForm['encoding'])) { $encoding = $datForm['encoding']; } $myForm->addDisabled('encoding'); $myForm->addText(OPF_myLang::getPhrase('OPF_LOGIN_12A'), 'encoding', $encoding); $user_db = ''; if (isset($datForm['user_db'])) { $user_db = $datForm['user_db']; } $myForm->addText(OPF_myLang::getPhrase('OPF_LOGIN_9'), 'user_db', $user_db); $passwd_db = ''; if (isset($datForm['passwd_db'])) { $passwd_db = $datForm['passwd_db']; } $myForm->addPassword(OPF_myLang::getPhrase('OPF_LOGIN_10'), 'passwd_db', $passwd_db); $host_db = ''; if (isset($datForm['host_db'])) { $host_db = $datForm['host_db']; } $myForm->addText(OPF_myLang::getPhrase('OPF_LOGIN_11'), 'host_db', $host_db); $host_port = ''; if (isset($datForm['host_port'])) { $host_port = $datForm['host_port']; } $myForm->addText(OPF_myLang::getPhrase('OPF_LOGIN_13'), 'host_port', $host_port, NULL, 5, true); if ($type == 'tables') { $str = OPF_myLang::getPhrase('OPF_LOGIN_30'); $myForm->addButton('btn_install', OPF_myLang::getPhrase('OPF_LOGIN_14'), 'list.gif'); $myForm->addEvent('btn_install', 'onclick', 'onClickInstall'); } else { $str = OPF_myLang::getPhrase('OPF_LOGIN_29'); if ($disabled) { $myForm->addDisabled('btn_install'); } $myForm->addButton('btn_install', OPF_myLang::getPhrase('OPF_LOGIN_17'), 'add.gif'); $myForm->addEvent('btn_install', 'onclick', 'onClickCreateBD'); } $myForm->addGroup('grp1', $str, array('engine', 'db', 'encoding', 'user_db', 'passwd_db', 'host_db', 'host_port'), 1); return $myForm->getForm(1); }