function lp_upload_quiz_main() { // variable initialisation $lp_id = isset($_GET['lp_id']) ? intval($_GET['lp_id']) : null; $form = new FormValidator('upload', 'POST', api_get_self() . '?' . api_get_cidreq() . '&lp_id=' . $lp_id, '', array('enctype' => 'multipart/form-data')); $form->addElement('header', get_lang('ImportExcelQuiz')); $form->addElement('file', 'user_upload_quiz', get_lang('FileUpload')); $link = '<a href="../exercice/quiz_template.xls">' . Display::return_icon('export_excel.png', get_lang('DownloadExcelTemplate')) . get_lang('DownloadExcelTemplate') . '</a>'; $form->addElement('label', '', $link); $table = new HTML_Table(array('class' => 'table')); $tableList = array(UNIQUE_ANSWER => get_lang('UniqueSelect'), MULTIPLE_ANSWER => get_lang('MultipleSelect'), FILL_IN_BLANKS => get_lang('FillBlanks'), MATCHING => get_lang('Matching'), FREE_ANSWER => get_lang('FreeAnswer'), GLOBAL_MULTIPLE_ANSWER => get_lang('GlobalMultipleAnswer')); $table->setHeaderContents(0, 0, get_lang('QuestionType')); $table->setHeaderContents(0, 1, '#'); $row = 1; foreach ($tableList as $key => $label) { $table->setCellContents($row, 0, $label); $table->setCellContents($row, 1, $key); $row++; } $table = $table->toHtml(); $form->addElement('label', get_lang('QuestionType'), $table); $form->addElement('checkbox', 'user_custom_score', null, get_lang('UseCustomScoreForAllQuestions'), array('id' => 'user_custom_score')); $form->addElement('html', '<div id="options" style="display:none">'); $form->addElement('text', 'correct_score', get_lang('CorrectScore')); $form->addElement('text', 'incorrect_score', get_lang('IncorrectScore')); $form->addElement('html', '</div>'); $form->addRule('user_upload_quiz', get_lang('ThisFieldIsRequired'), 'required'); $form->add_progress_bar(); $form->addButtonUpload(get_lang('Upload'), 'submit_upload_quiz'); // Display the upload field $form->display(); }
public function __construct() { parent::__construct('aicml_staff'); if ($this->loginError) { return; } echo '<h1>AICML Staff</h1>'; $table = new HTML_Table(array('class' => 'stats')); $table->addRow(array('Name', 'Start', 'End', 'Num Pubs', 'Pub Ids')); $table->setRowType(0, 'th'); //pdDb::debugOn(); $staff_list = pdAicmlStaffList::create($this->db); foreach ($staff_list as $staff_id => $author_id) { $staff = pdAicmlStaff::newFromDb($this->db, $staff_id, pdAicmlStaff::DB_LOAD_PUBS_MIN); $author = pdAuthor::newFromDb($this->db, $author_id, pdAuthor::DB_LOAD_MIN); //debugVar('staff', array($staff, $author)); $pub_links = array(); if (isset($staff->pub_ids)) { foreach ($staff->pub_ids as $pub_id) { $pub_links[] = '<a href="../view_publication.php?pub_id=' . $pub_id . '">' . $pub_id . '</a>'; } } $table->addRow(array($author->name, $staff->start_date, $staff->end_date, count($staff->pub_ids), implode(', ', $pub_links)), array('class' => 'stats_odd')); } echo $table->toHtml(); }
/** * Muestra el formulario para iniciar sesión. */ private function imprimirFormularioLogin() { imprimirTabulados(5); echo '<div class="tablaTituloBotones">'; imprimirTabulados(6); echo '<h2>Iniciar sesión</h2>'; imprimirTabulados(6); echo '<form action="index.php" method="post">'; imprimirTabulados(6); echo '<fieldset class="login">'; imprimirTabulados(6); $clase = array('class' => 'tablaCarga'); $tabla = new HTML_Table($clase); $tabla->setAutoGrow(true); $tabla->setHeaderContents(0, 0, 'Usuario'); $tabla->setCellContents(0, 1, '<input class="campoTexto campoTextoAlineado" type="text" name="username" value="" />'); $tabla->setHeaderContents(1, 0, 'Contraseña'); $tabla->setCellContents(1, 1, '<input class="campoTexto campoTextoAlineado" type="password" name="password" value="" />'); $tabla->setColAttributes(0, $clase); $tabla->setColAttributes(1, $clase); echo $tabla->toHtml(); imprimirTabulados(6); echo '<br /><input type="submit" name="botonIniciarSesion" value="Iniciar sesión" >'; imprimirTabulados(6); echo '</fieldset>'; imprimirTabulados(6); echo '</form>'; imprimirTabulados(5); echo '</div>'; }
public function imprimir() { // Implementada en la subclase $this->imprimirCabecera(); for ($index = 0; $index < count($this->horarios); $index++) { $horario = $this->horarios[$index]; // Implementada en la subclase $this->imprimirFila($horario, $index); } imprimirTabulados(6); echo $this->tabla->toHtml(); }
private function pubByYears() { $pub_years = pdPubList::create($this->db, array('year_list' => true)); if (empty($pub_years) || count($pub_years) == 0) { return; } $table = new HTML_Table(array('class' => 'nomargins', 'width' => '60%')); $text = ''; foreach (array_values($pub_years) as $item) { $text .= '<a href="list_publication.php?year=' . $item['year'] . '">' . $item['year'] . '</a> '; } $table->addRow(array($text)); echo '<h2>Publications by Year:</h2>', $table->toHtml(); }
public function __construct() { parent::__construct('auth_success', 'Authorization Success', 'Admin/auth_success.php'); if ($this->loginError) { return; } echo "<h2>Authorization Successful</h2>" . "\n<p>The following users have been granted access.</p>"; $table = new HTML_Table(array('class' => 'stats')); $table->addRow(array('Access Level', 'Login', 'Name', 'Conf. Email')); $table->setRowType(0, 'th'); foreach ($_SESSION['auth_success'] as $auth) { $table->addRow(array(AccessLevel::getAccessLevelStr($auth['user']->access_level), $auth['user']->login, $auth['user']->name, $auth['email']), array('class' => 'stats_odd')); } echo $table->toHtml(); }
public function show_html() { $sections = array('chamilo', 'php', 'database', 'webserver', 'paths'); $currentSection = isset($_GET['section']) ? $_GET['section'] : 'chamilo'; if (!in_array(trim($currentSection), $sections)) { $currentSection = 'chamilo'; } $html = '<div class="tabbable"><ul class="nav nav-tabs">'; foreach ($sections as $section) { if ($currentSection === $section) { $html .= '<li class="active">'; } else { $html .= '<li>'; } $params['section'] = $section; $html .= '<a href="system_status.php?section=' . $section . '">' . get_lang($section) . '</a></li>'; } $html .= '</ul><div class="tab-pane">'; $data = call_user_func(array($this, 'get_' . $currentSection . '_data')); echo $html; if ($currentSection != 'paths') { $table = new SortableTableFromArray($data, 1, 100); $table->set_header(0, '', false); $table->set_header(1, get_lang('Section'), false); $table->set_header(2, get_lang('Setting'), false); $table->set_header(3, get_lang('Current'), false); $table->set_header(4, get_lang('Expected'), false); $table->set_header(5, get_lang('Comment'), false); $table->display(); } else { $headers = $data['headers']; $results = $data['data']; $table = new HTML_Table(array('class' => 'data_table')); $column = 0; foreach ($headers as $header) { $table->setHeaderContents(0, $column, $header); $column++; } $row = 1; foreach ($results as $index => $rowData) { $table->setCellContents($row, 0, $rowData); $table->setCellContents($row, 1, $index); $row++; } echo $table->display(); } echo '</div></div>'; }
public function __construct() { parent::__construct('auth_error', 'Authorization Error', 'Admin/auth_error.php'); if ($this->loginError) { return; } echo "<h2>Invalid Access Level</h2>" . "\n<p>The following users have incorrect access level.</p>"; $table = new HTML_Table(array('class' => 'stats')); $table->addRow(array('Access Level', 'Login', 'Name')); $table->setRowType(0, 'th'); foreach ($_SESSION['auth_errors'] as $auth_err) { $table->addRow(array(AccessLevel::getAccessLevelStr($auth_err['access']), $auth_err['user']->login, $auth_err['user']->name), array('class' => 'stats_odd')); } echo $table->toHtml(); echo '<p><a href="authorize_new_users.php">Authorize new users</a></p>'; }
public function __construct() { parent::__construct('all_categories'); if ($this->loginError) { return; } $cat_list = pdCatList::create($this->db); echo '<h1>Publication Categories</h1>'; foreach (array_keys($cat_list) as $cat_id) { unset($fields); unset($cells); $category = new pdCategory(); $result = $category->dbLoad($this->db, $cat_id); assert('$result'); $table = new HTML_Table(array('class' => 'publist')); $table->setAutoGrow(true); $cells[] = '<b>' . $category->category . '</b><br/>'; if (count($category->info) > 0) { foreach ($category->info as $info_id => $name) { $fields[] = $name; } $cells[] = 'Fields: ' . implode(', ', $fields); } else { $cells[] = ''; } if ($this->access_level > 0) { $cells[] = $this->getCategoryIcons($category); } $table->addRow($cells); $table->updateColAttributes(0, array('class' => 'category'), NULL); $table->updateColAttributes(2, array('class' => 'icons'), NULL); echo $table->toHtml(); unset($table); } }
private function filaTablaHorasAsignadasEditar($horario, $fila) { // Debe sumarse uno a la fila porque la fila 0 es la cabecera $this->tabla->setCellContents($fila + 1, 0, $this->formulario . $horario->getArea()->getNombreArea()); $this->tabla->setCellContents($fila + 1, 1, '<input class="campoTexto campoTextoChico" type="text" name="cantidadHoras" size="4" value="' . $horario->getHorasAsignadas() . '" />'); $this->tabla->setCellContents($fila + 1, 2, $horario->getHorasActualmenteAsignadas()); $this->tabla->setCellContents($fila + 1, 3, $this->accionesFilaTablaHorasAsignadasEditar($horario->getArea()->getIdArea())); $this->tabla->setRowAttributes($fila + 1, $this->clase, false); }
public function __construct() { parent::__construct('all_authors'); if ($this->loginError) { return; } $this->loadHttpVars(true, false); if (!isset($this->tab)) { $this->tab = 'A'; } else { $tab = strtoupper($this->tab); if (strlen($tab) != 1 || ord($tab) < ord('A') || ord($tab) > ord('Z')) { $this->pageError = true; return; } } $auth_list = pdAuthorList::create($this->db, null, $this->tab); echo $this->alphaSelMenu($this->tab, get_class($this) . '.php'); echo "<h2>Authors</h2>"; if (empty($auth_list) || count($auth_list) == 0) { echo 'No authors with last name starting with ', $this->tab, '<br/>'; return; } foreach ($auth_list as $author_id => $name) { $author = new pdAuthor(); $author->dbLoad($this->db, $author_id, pdAuthor::DB_LOAD_BASIC | pdAuthor::DB_LOAD_PUBS_MIN); $name = '<span class="emph"><a href="view_author.php?author_id=' . $author_id . '">' . $name . '</a> '; $icons = $this->getAuthorIcons($author) . '</span>'; $info = array(); if ($author->title != '') { $info[] = '<span class="small">' . $author->title . '</span>'; } if ($author->organization != '') { $info[] = '<span class="small">' . $author->organization . '</span>'; } $info[] .= '<a href="list_publication.php?author_id=' . $author_id . '&menu=0"><span class="small" style="color:#000;font-weight:normal;">' . 'Publication entries in database: ' . $author->totalPublications . '</span>'; $table = new HTML_Table(array('class' => 'publist')); $table->addRow(array($name . '<br/>' . implode('<br/>', $info), $icons)); $table->updateColAttributes(1, array('class' => 'icons'), NULL); echo $table->toHtml(); unset($table); } }
public function __construct() { parent::__construct('delete_author', 'Delete Author', 'Admin/delete_author.php'); if ($this->loginError) { return; } $this->loadHttpVars(); if (!isset($this->author_id) || !is_numeric($this->author_id)) { $this->pageError = true; return; } $author = new pdAuthor(); $result = $author->dbLoad($this->db, $this->author_id); if (!$result) { $this->pageError = true; return; } $pub_list = pdPubList::create($this->db, array('author_id' => $this->author_id)); if (isset($pub_list) && count($pub_list) > 0) { echo 'Cannot delete Author <b>', $author->name, '</b>.<p/>', 'The author has the following publications in the database:', displayPubList($this->db, $pub_list, true, -1, null, null, '../'); return; } $form =& $this->confirmForm('deleter'); $form->addElement('hidden', 'author_id', $this->author_id); if ($form->validate()) { $values = $form->exportValues(); // This is where the actual deletion happens. $name = $author->name; $author->dbDelete($this->db); echo 'You have successfully removed the following author from the database:', '<p/><b>', $name, '</b>'; } else { if (!isset($this->author_id) || !is_numeric($this->author_id)) { $this->pageError = true; return; } $renderer = new HTML_QuickForm_Renderer_QuickHtml(); $form->accept($renderer); $table = new HTML_Table(array('width' => '100%', 'border' => '0', 'cellpadding' => '6', 'cellspacing' => '0')); $table->addRow(array('Name:', $author->name)); if (isset($author->title) && trim($author->title != '')) { $table->addRow(array('Title:', $author->title)); } $table->addRow(array('Email:', $author->email)); $table->addRow(array('Organization:', $author->organization)); $cell = ''; if (isset($author->webpage) && trim($author->webpage != '')) { $cell = '<a href="' . $author->webpage . '">' . $author->webpage . '</a>'; } else { $cell = "none"; } $table->addRow(array('Web page:', $cell)); $table->updateColAttributes(0, array('class' => 'emph', 'width' => '25%')); echo '<h3>Delete Author</h3><p/>Delete the following author?'; $this->form =& $form; $this->renderer =& $renderer; $this->table =& $table; } }
/** * addRow * * @param string $contents data to add to row * * @return void */ public function addRow($contents) { if ($this->rowcount % 2 == 0) { $class = "first"; } else { $class = "second"; } parent::addRow($contents, array("class" => $class)); $this->rowcount++; }
function __construct() { $lang = services::getService('lang'); // table-header parent::__construct(array("width" => "100%", "class" => "pools")); $this->setHeaderContents(0, 0, $lang->getMsg('tableheaders_name')); $this->setHeaderContents(0, 1, $lang->getMsg('tableheaders_area')); $this->setHeaderContents(0, 2, $lang->getMsg('tableheaders_adress')); $this->setHeaderContents(0, 3, $lang->getMsg('tableheaders_rescount')); $this->setRowAttributes(0, array("class" => "pools2")); }
/** * View list * * @author John.meng * @since version - Dec 23, 2005 * @param datatype paramname description * @return datatype description */ function viewList() { global $__Lang__, $UrlParameter, $FlushPHPObj, $table, $page_data, $all_data, $links, $form, $smarty; include_once PEAR_DIR . 'HTML/QuickForm.php'; include_once PEAR_DIR . "HTML/Table.php"; require_once PEAR_DIR . 'Pager/Pager.php'; $form = new HTML_QuickForm('viewList'); $renderer =& $form->defaultRenderer(); $renderer->setFormTemplate("\n<form{attributes}>\n<table border=\"0\" width=\"99%\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\">\n{content}\n</table>\n</form>"); $tableAttrs = array("class" => "grid_table"); $table = new HTML_Table($tableAttrs); $table->setAutoGrow(true); // $table->setAutoFill("n/a"); $hrAttrs = array("class" => "grid_table_head"); $table->setRowAttributes(0, $hrAttrs, true); $params = array('itemData' => $all_data, 'perPage' => 10, 'delta' => 3, 'append' => true, 'separator' => ' . ', 'clearIfVoid' => false, 'urlVar' => 'entrant', 'useSessions' => true, 'closeSession' => true, 'mode' => 'Jumping', 'prevImg' => $__Lang__['langPaginationPrev'], 'nextImg' => $__Lang__['langPaginationNext']); $pager =& Pager::factory($params); $page_data = $pager->getPageData(); $links = $pager->getLinks(); $selectBox = $pager->getPerPageSelectBox(); }
public function __construct() { parent::__construct('bibtex', null, false); if ($this->loginError) { return; } $this->loadHttpVars(); if (!isset($this->pub_ids)) { $this->pageError = true; return; } $pubs = explode(',', $this->pub_ids); if (!is_array($pubs) || count($pubs) == 0) { $this->pageError = true; return; } $pub_list = pdPubList::create($this->db, array('pub_ids' => $pubs)); if (!is_array($pub_list) || count($pub_list) == 0) { $this->pageError = true; return; } $table = new HTML_Table(array('width' => '100%', 'border' => '0', 'cellpadding' => '0', 'cellspacing' => '0')); $table->setAutoGrow(true); $pub_count = 0; foreach ($pub_list as $pub) { $pub_count++; $result = $pub->dbLoad($this->db, $pub->pub_id); if ($result === false) { $this->pageError = true; return; } $table->addRow(array('<pre>' . $pub->getBibtex() . '</pre>')); } // now assign table attributes including highlighting for even and odd // rows for ($i = 0; $i < $table->getRowCount(); $i++) { if ($i & 1) { $table->updateRowAttributes($i, array('class' => 'even'), true); } else { $table->updateRowAttributes($i, array('class' => 'odd'), true); } } $table->updateColAttributes(0, array('class' => 'publist'), true); echo $table->toHtml(); }
<?php $tbl = new HTML_Table('', 'table table-striped table-bordered'); $tbl->addRow(); $tbl->addCell('FY ID', '', 'header'); $tbl->addCell('FY Description', '', 'header'); $tbl->addCell('Start Date', '', 'header'); $tbl->addCell('End Date', '', 'header'); $tbl->addCell('Status', '', 'header'); $tbl->addCell('Actions', '', 'header'); ?> <?php $sql = 'SELECT * FROM ' . DB_PREFIX . $_SESSION['co_prefix'] . 'fiscal_years ORDER by fiscal_year_start_date'; $get_fy = DB::query($sql); foreach ($get_fy as $fy) { $tbl->addRow(); $tbl->addCell($fy['fiscal_year_id']); $tbl->addCell($fy['fiscal_year_desc']); $tbl->addCell(getDateTime($fy['fiscal_year_start_date'], "dLong")); $tbl->addCell(getDateTime($fy['fiscal_year_end_date'], "dLong")); $tbl->addCell($fy['fy_status']); $tbl->addCell("<a class='pull btn btn-danger btn-xs' href ='" . $_SERVER['PHP_SELF'] . "?route=modules/gl/setup/financial_periods/edit_fiscal_year&fisca_year_id=" . $fy['fiscal_year_id'] . "'>Edit Fiscal Year <span class='glyphicon glyphicon-edit'></span></a>\n\t\t\t "); } ?> <!-- Content Header (Page header) --> <section class="content-header"> <h1> Fiscal Years <small>Defined Fiscal Years for Company Accounts.</small> </h1>
/** * @param string $categorySource * * @return string */ function listCategories($categorySource) { $categorySource = isset($categorySource) ? $categorySource : null; $categories = self::getCategories($categorySource); if (count($categories) > 0) { $table = new HTML_Table(array('class' => 'data_table')); $column = 0; $row = 0; $headers = array(get_lang('Category'), get_lang('CategoriesNumber'), get_lang('Courses'), get_lang('Actions')); foreach ($headers as $header) { $table->setHeaderContents($row, $column, $header); $column++; } $row++; $mainUrl = api_get_path(WEB_CODE_PATH) . 'admin/course_category.php?category=' . $categorySource; $editIcon = Display::return_icon('edit.png', get_lang('EditNode'), null, ICON_SIZE_SMALL); $deleteIcon = Display::return_icon('delete.png', get_lang('DeleteNode'), null, ICON_SIZE_SMALL); $moveIcon = Display::return_icon('up.png', get_lang('UpInSameLevel'), null, ICON_SIZE_SMALL); foreach ($categories as $category) { $editUrl = $mainUrl . '&id=' . $category['code'] . '&action=edit'; $moveUrl = $mainUrl . '&id=' . $category['code'] . '&action=moveUp&tree_pos=' . $category['tree_pos']; $deleteUrl = $mainUrl . '&id=' . $category['code'] . '&action=delete'; $actions = Display::url($editIcon, $editUrl) . Display::url($moveIcon, $moveUrl) . Display::url($deleteIcon, $deleteUrl); $url = api_get_path(WEB_CODE_PATH) . 'admin/course_category.php?category=' . $category['code']; $title = Display::url(Display::return_icon('folder_document.gif', get_lang('OpenNode'), null, ICON_SIZE_SMALL) . ' ' . $category['name'], $url); $content = array($title, $category['children_count'], $category['nbr_courses'], $actions); $column = 0; foreach ($content as $value) { $table->setCellContents($row, $column, $value); $column++; } $row++; } return $table->toHtml(); } else { return Display::return_message(get_lang("NoCategories"), 'warning'); } }
<?php $sql = 'SELECT * FROM ' . DB_PREFIX . $_SESSION['co_prefix'] . 'journal_vouchers WHERE voucher_status="draft" ORDER by voucher_id DESC'; $draft_jvs = DB::query($sql); foreach ($draft_jvs as $draft_jv) { $tbl_draft->addRow(); $tbl_draft->addCell($draft_jv['voucher_id']); $tbl_draft->addCell(getDateTime($draft_jv['voucher_date'], "dShort")); $tbl_draft->addCell($draft_jv['voucher_ref_no']); $tbl_draft->addCell($draft_jv['voucher description']); $tbl_draft->addCell($draft_jv['debits_total']); $tbl_draft->addCell($draft_jv['credits_total']); $tbl_draft->addCell("More info here like created on, last modify etc"); $tbl_draft->addCell("<a class='pull btn btn-primary btn-xs' href ='" . SITE_ROOT . "?route=modules/gl/transactions/journal_vouchers/add_journal_voucher_detail&voucher_id=" . $draft_jv['voucher_id'] . "'>Edit <span class='glyphicon glyphicon-edit'></span></a> <a class='pull btn btn-danger btn-xs' href ='#'>Delete <span class='glyphicon glyphicon-trash'></span></a>"); } //Journal Vouchers Pending Approvel $tbl_pending = new HTML_Table('', 'table table-striped table-bordered'); $tbl_pending->addRow(); $tbl_pending->addCell('Voucher ID', '', 'header'); $tbl_pending->addCell('Ref #', '', 'header'); $tbl_pending->addCell('Voucher Description', '', 'header'); $tbl_pending->addCell('Total Amount', '', 'header'); $tbl_pending->addCell('Voucher Approved By', '', 'header'); $tbl_pending->addCell('Voucher Status', '', 'header'); $tbl_pending->addCell('Actions', '', 'header'); ?> <?php $sql = 'SELECT * FROM ' . DB_PREFIX . $_SESSION['co_prefix'] . 'journal_vouchers WHERE voucher_status = "pending" ORDER by voucher_id DESC'; $pending_jvs = DB::query($sql); foreach ($pending_jvs as $pending_jv) { $tbl_pending->addRow();
/** * Returns a category summary report * @params int exercise id * @params array pre filled array with the category_id, score, and weight * example: array(1 => array('score' => '10', 'total' => 20)); */ public static function get_stats_table_by_attempt($exercise_id, $category_list = array()) { if (empty($category_list)) { return null; } $category_name_list = TestCategory::getListOfCategoriesNameForTest($exercise_id); $table = new HTML_Table(array('class' => 'data_table')); $table->setHeaderContents(0, 0, get_lang('Categories')); $table->setHeaderContents(0, 1, get_lang('AbsoluteScore')); $table->setHeaderContents(0, 2, get_lang('RelativeScore')); $row = 1; $none_category = array(); if (isset($category_list['none'])) { $none_category = $category_list['none']; unset($category_list['none']); } $total = array(); if (isset($category_list['total'])) { $total = $category_list['total']; unset($category_list['total']); } if (count($category_list) > 1) { foreach ($category_list as $category_id => $category_item) { $table->setCellContents($row, 0, $category_name_list[$category_id]); $table->setCellContents($row, 1, ExerciseLib::show_score($category_item['score'], $category_item['total'], false)); $table->setCellContents($row, 2, ExerciseLib::show_score($category_item['score'], $category_item['total'], true, false, true)); $row++; } if (!empty($none_category)) { $table->setCellContents($row, 0, get_lang('None')); $table->setCellContents($row, 1, ExerciseLib::show_score($none_category['score'], $none_category['total'], false)); $table->setCellContents($row, 2, ExerciseLib::show_score($none_category['score'], $none_category['total'], true, false, true)); $row++; } if (!empty($total)) { $table->setCellContents($row, 0, get_lang('Total')); $table->setCellContents($row, 1, ExerciseLib::show_score($total['score'], $total['total'], false)); $table->setCellContents($row, 2, ExerciseLib::show_score($total['score'], $total['total'], true, false, true)); } return $table->toHtml(); } return null; }
/** * @param string $startDate in UTC time * @param string $endDate in UTC time * * @return string */ public function exportAttendanceLogin($startDate, $endDate) { $data = $this->getAttendanceLogin($startDate, $endDate); if (!$data) { return null; } $users = $data['users']; $results = $data['results']; $table = new HTML_Table(array('class' => 'data_table')); $table->setHeaderContents(0, 0, get_lang('User')); $table->setHeaderContents(0, 1, get_lang('Date')); $row = 1; foreach ($users as $user) { $table->setCellContents($row, 0, $user['lastname'] . ' ' . $user['firstname'] . ' (' . $user['username'] . ')'); $row++; } $table->setColAttributes(0, array('style' => 'width:28%')); $row = 1; foreach ($users as $user) { if (isset($results[$user['user_id']]) && !empty($results[$user['user_id']])) { $dates = implode(', ', array_keys($results[$user['user_id']])); $table->setCellContents($row, 1, $dates); } $row++; } //$tableToString = null; //$sessionInfo = api_get_session_info(api_get_session_id()); //if (!empty($sessionInfo)) { /*$tableToString .= '<strong>'.get_lang('PeriodToDisplay').'</strong>: '. sprintf(get_lang('FromDateXToDateY'), $startDate, $endDate);*/ //} $tableToString = $table->toHtml(); $params = array('filename' => get_lang('Attendance') . '_' . api_get_utc_datetime(), 'pdf_title' => get_lang('Attendance'), 'course_code' => api_get_course_id(), 'show_real_course_teachers' => true); $pdf = new PDF('A4', null, $params); $pdf->html_to_pdf_with_template($tableToString); }
/** * Muestra el formulario para dar de alta un nuevo usuario. */ private function imprimirFormularioNuevoUsuario() { imprimirTabulados(5); echo '<div class="tablaTituloBotones">'; imprimirTabulados(6); echo '<h1>Nuevo usuario</h1>'; imprimirTabulados(6); echo '<form action="usuario.php" method="post">'; imprimirTabulados(6); echo '<fieldset>'; imprimirTabulados(6); $clase = array('class' => 'tablaCarga'); $tabla = new HTML_Table($clase); $tabla->setAutoGrow(true); $tabla->setHeaderContents(0, 0, 'Tipo de documento'); $tabla->setCellContents(0, 1, '<select class="cuadroSeleccion cuadroSeleccionAlineado" name="tipoDocumento"><option>DNI</option><option>LE</option><option>LC</option></select>'); $tabla->setHeaderContents(1, 0, 'Número de documento *'); $tabla->setCellContents(1, 1, '<input class="campoTexto campoTextoAlineado" type="text" name="numeroDocumentoNuevo" value="" />'); $tabla->setHeaderContents(2, 0, 'Nombre *'); $tabla->setCellContents(2, 1, '<input class="campoTexto campoTextoAlineado" type="text" name="nombre" value="" />'); $tabla->setHeaderContents(3, 0, 'Segundo nombre'); $tabla->setCellContents(3, 1, '<input class="campoTexto campoTextoAlineado" type="text" name="segundoNombre" value="" />'); $tabla->setHeaderContents(4, 0, 'Apellido *'); $tabla->setCellContents(4, 1, '<input class="campoTexto campoTextoAlineado" type="text" name="apellido" value="" />'); $tabla->setHeaderContents(5, 0, 'Fecha de nacimiento *'); $tabla->setCellContents(5, 1, '<input class="campoTexto campoTextoAlineado" type="text" name="fechaNacimiento" value="DD-MM-AAAA" />'); $tabla->setHeaderContents(6, 0, 'Dirección *'); $tabla->setCellContents(6, 1, '<input class="campoTexto campoTextoAlineado" type="text" name="direccion" value="" />'); $tabla->setHeaderContents(7, 0, 'Teléfono fijo'); $tabla->setCellContents(7, 1, '<input class="campoTexto campoTextoAlineado" type="text" name="telefonoFijo" value="" />'); $tabla->setHeaderContents(8, 0, 'Teléfono celular'); $tabla->setCellContents(8, 1, '<input class="campoTexto campoTextoAlineado" type="text" name="telefonoCelular" value="" />'); $tabla->setHeaderContents(9, 0, 'E-mail *'); $tabla->setCellContents(9, 1, '<input class="campoTexto campoTextoAlineado" type="text" name="email" value="" />'); $tabla->setHeaderContents(10, 0, 'Legajo *'); $tabla->setCellContents(10, 1, '<input class="campoTexto campoTextoAlineado" type="text" name="legajo" value="" />'); $tabla->setHeaderContents(11, 0, 'Área *'); $tabla->setCellContents(11, 1, $this->mostrarAreasMultipleSeleccion()); $tabla->setHeaderContents(12, 0, 'Tipo de usuario'); $tabla->setCellContents(12, 1, $this->mostrarNiveles()); $tabla->setHeaderContents(13, 0, 'Activo'); $tabla->setCellContents(13, 1, '<select class="cuadroSeleccionAlineado" name="activo"><option value="1">Si</option><option value="0">No</option></select>'); $tabla->setHeaderContents(14, 0, 'Notas'); $tabla->setCellContents(14, 1, '<textarea class="areaTexto" name="notas" rows="4" cols="20"></textarea>'); $tabla->setColAttributes(0, $clase); $tabla->setColAttributes(1, $clase); echo $tabla->toHtml(); imprimirTabulados(6); echo '<br /><input type="submit" name="enviarNuevoUsuario" value="Enviar" >'; imprimirTabulados(6); echo '</fieldset>'; imprimirTabulados(6); echo '</form>'; imprimirTabulados(6); echo '<div class="notas">'; imprimirTabulados(7); echo '<p>(*) Campos obligatorios</p>'; imprimirTabulados(6); echo '</div>'; imprimirTabulados(5); echo '</div>'; }
$csvContent = array(); $table = new HTML_Table(array('class' => 'data_table')); $table->setHeaderContents(0, 0, get_lang('Information')); $csvContent[] = get_lang('Information'); $data = array(get_lang('Name') => $user['complete_name'], get_lang('Email') => $user['email'], get_lang('Phone') => $user['phone'], get_lang('OfficialCode') => $user['official_code'], get_lang('Online') => $user['user_is_online'] ? Display::return_icon('online.png') : Display::return_icon('offline.png'), get_lang('Status') => $user['status'] == 1 ? get_lang('Teacher') : get_lang('Student'), null => sprintf(get_lang('CreatedByXYOnZ'), 'user_information.php?user_id=' . $creatorId, $creatorInfo['username'], api_get_utc_datetime($registrationDate))); $row = 1; foreach ($data as $label => $item) { if (!empty($label)) { $label = $label . ': '; } $table->setCellContents($row, 0, $label . $item); $csvContent[] = array($label, strip_tags($item)); $row++; } $userInformation = $table->toHtml(); $table = new HTML_Table(array('class' => 'data_table')); $table->setHeaderContents(0, 0, get_lang('Tracking')); $csvContent[] = get_lang('Tracking'); $data = array(get_lang('FirstLogin') => Tracking::get_first_connection_date($user['user_id']), get_lang('LatestLogin') => Tracking::get_last_connection_date($user['user_id'], true)); $row = 1; foreach ($data as $label => $item) { if (!empty($label)) { $label = $label . ': '; } $table->setCellContents($row, 0, $label . $item); $csvContent[] = array($label, strip_tags($item)); $row++; } $trackingInformation = $table->toHtml(); $tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); $tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
public function pubSelect($viewCat = null) { assert('is_object($this->db)'); echo $this->pubSelMenu($viewCat), '<br/>'; $text = ''; switch ($viewCat) { case "year": $pub_years = pdPubList::create($this->db, array('year_list' => true)); echo '<h2>Publications by Year:</h2>'; if (count($pub_years) > 0) { $table = new HTML_Table(array('class' => 'nomargins', 'width' => '100%')); $table->addRow(array('Year', 'Num. Publications'), array('class' => 'emph')); foreach (array_values($pub_years) as $item) { $cells = array(); $cells[] = '<a href="list_publication.php?year=' . $item['year'] . '">' . $item['year'] . '</a>'; $cells[] = $item['count']; $table->addRow($cells); } echo $table->toHtml(); } else { echo 'No publication entries.'; } break; case 'author': echo '<h2>Publications by Author:</h2>'; $al = pdAuthorList::create($this->db); for ($c = 65; $c <= 90; ++$c) { $table = new HTML_Table(array('class' => 'publist')); $text = ''; foreach ($al as $auth_id => $name) { if (substr($name, 0, 1) == chr($c)) { $text .= '<a href="list_publication.php?author_id=' . $auth_id . '">' . $name . '</a> '; } } $table->addRow(array(chr($c), $text)); $table->updateColAttributes(0, array('class' => 'item'), NULL); echo $table->toHtml(); } break; case 'venue': // publications by keyword unset($table); $vl = pdVenueList::create($this->db); echo '<h2>Publications by Venue:</h2>'; for ($c = 65; $c <= 90; ++$c) { $table = new HTML_Table(array('class' => 'publist')); $text = ''; foreach ($vl as $vid => $v) { if (substr($v, 0, 1) == chr($c)) { $text .= '<a href="list_publication.php?venue_id=' . $vid . '">' . $v . '</a> '; } } $table->addRow(array(chr($c), $text)); $table->updateColAttributes(0, array('class' => 'item'), NULL); echo $table->toHtml(); } break; case 'category': $table = new HTML_Table(array('class' => 'nomargins', 'width' => '100%')); $cl = pdCatList::create($this->db); $table->addRow(array('Category', 'Num. Publications'), array('class' => 'emph')); foreach ($cl as $cat_id => $category) { $cells = array(); $cells[] = '<a href="list_publication.php?cat_id=' . $cat_id . '">' . $category . '</a><br/>'; $cells[] = pdCatList::catNumPubs($this->db, $cat_id); $table->addRow($cells); } echo '<h2>Publications by Category:</h2>', $table->toHtml(); break; case 'keywords': // publications by keyword unset($table); $kl = pdPubList::create($this->db, array('keywords_list' => true)); echo '<h2>Publications by Keyword:</h2>'; for ($c = 65; $c <= 90; ++$c) { $table = new HTML_Table(array('class' => 'publist')); $text = ''; foreach ($kl as $kw) { if (substr($kw, 0, 1) == chr($c)) { $text .= '<a href="list_publication.php?keyword=' . $kw . '">' . $kw . '</a> '; } } $table->addRow(array(chr($c), $text)); $table->updateColAttributes(0, array('class' => 'item'), NULL); echo $table->toHtml(); } break; default: $this->pageError = true; } }
<?php // Include the HTML_Table package require_once "HTML/Table.php"; // Connect to the MySQL database $mysqli = new mysqli("localhost", "websiteuser", "secret", "corporate"); // Create an array of table attributes $attributes = array('border' => '1'); // Create the table object $table = new HTML_Table($attributes); // Set the headers $table->setHeaderContents(0, 0, "Order ID"); $table->setHeaderContents(0, 1, "Client ID"); $table->setHeaderContents(0, 2, "Order Time"); $table->setHeaderContents(0, 3, "Sub Total"); $table->setHeaderContents(0, 4, "Shipping Cost"); $table->setHeaderContents(0, 5, "Total Cost"); // Cycle through the array to produce the table data // Create and execute the query $query = "SELECT id AS `Order ID`, client_id AS `Client ID`,\n order_time AS `Order Time`,\n CONCAT('\$', sub_total) AS `Sub Total`,\n CONCAT('\$', shipping_cost) AS `Shipping Cost`,\n CONCAT('\$', total_cost) AS `Total Cost`\n FROM sales ORDER BY id"; $stmt = $mysqli->prepare($query); $stmt->execute(); $stmt->bind_result($orderID, $clientID, $time, $subtotal, $shipping, $total); // Begin at row 1 so don't overwrite the header $rownum = 1; // Format each row while ($stmt->fetch()) { $table->setCellContents($rownum, 0, $orderID); $table->setCellContents($rownum, 1, $clientID); $table->setCellContents($rownum, 2, $time); $table->setCellContents($rownum, 3, $subtotal);
/** * @param FormValidator $form * @param array $extraData * @param string $form_name * @param bool $admin_permissions * @param int $user_id * @param array $extra * @param int $itemId * * @return array */ public function set_extra_fields_in_form($form, $extraData, $form_name, $admin_permissions = false, $user_id = null, $extra = array(), $itemId = null) { $user_id = intval($user_id); $type = $this->type; // User extra fields if ($type == 'user') { $extra = UserManager::get_extra_fields(0, 50, 5, 'ASC', true, null, true); } $jquery_ready_content = null; if (!empty($extra)) { foreach ($extra as $field_details) { // Getting default value id if is set $defaultValueId = null; if (isset($field_details['options']) && !empty($field_details['options'])) { $valueToFind = null; if (isset($field_details['field_default_value'])) { $valueToFind = $field_details['field_default_value']; } // If a value is found we override the default value if (isset($extraData['extra_' . $field_details['field_variable']])) { $valueToFind = $extraData['extra_' . $field_details['field_variable']]; } foreach ($field_details['options'] as $option) { if ($option['option_value'] == $valueToFind) { $defaultValueId = $option['id']; } } } if (!$admin_permissions) { if ($field_details['field_visible'] == 0) { continue; } } switch ($field_details['field_type']) { case ExtraField::FIELD_TYPE_TEXT: $form->addElement('text', 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], array('class' => 'span4')); $form->applyFilter('extra_' . $field_details['field_variable'], 'stripslashes'); $form->applyFilter('extra_' . $field_details['field_variable'], 'trim'); if (!$admin_permissions) { if ($field_details['field_visible'] == 0) { $form->freeze('extra_' . $field_details['field_variable']); } } break; case ExtraField::FIELD_TYPE_TEXTAREA: $form->add_html_editor('extra_' . $field_details['field_variable'], $field_details['field_display_text'], false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130')); $form->applyFilter('extra_' . $field_details['field_variable'], 'stripslashes'); $form->applyFilter('extra_' . $field_details['field_variable'], 'trim'); if (!$admin_permissions) { if ($field_details['field_visible'] == 0) { $form->freeze('extra_' . $field_details['field_variable']); } } break; case ExtraField::FIELD_TYPE_RADIO: $group = array(); if (isset($field_details['options']) && !empty($field_details['options'])) { foreach ($field_details['options'] as $option_details) { $options[$option_details['option_value']] = $option_details['option_display_text']; $group[] = $form->createElement('radio', 'extra_' . $field_details['field_variable'], $option_details['option_value'], $option_details['option_display_text'] . '<br />', $option_details['option_value']); } } $form->addGroup($group, 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], ''); if (!$admin_permissions) { if ($field_details['field_visible'] == 0) { $form->freeze('extra_' . $field_details['field_variable']); } } break; case ExtraField::FIELD_TYPE_CHECKBOX: $group = array(); if (isset($field_details['options']) && !empty($field_details['options'])) { foreach ($field_details['options'] as $option_details) { $options[$option_details['option_value']] = $option_details['option_display_text']; $group[] = $form->createElement('checkbox', 'extra_' . $field_details['field_variable'], $option_details['option_value'], $option_details['option_display_text'] . '<br />', $option_details['option_value']); } } else { // We assume that is a switch on/off with 1 and 0 as values $group[] = $form->createElement('checkbox', 'extra_' . $field_details['field_variable'], null, 'Yes <br />', null); } $form->addGroup($group, 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], ''); if (!$admin_permissions) { if ($field_details['field_visible'] == 0) { $form->freeze('extra_' . $field_details['field_variable']); } } break; case ExtraField::FIELD_TYPE_SELECT: $get_lang_variables = false; if (in_array($field_details['field_variable'], array('mail_notify_message', 'mail_notify_invitation', 'mail_notify_group_message'))) { $get_lang_variables = true; } // Get extra field workflow $userInfo = api_get_user_info(); $addOptions = array(); $optionsExists = Database::getManager()->getRepository('ChamiloCoreBundle:ExtraFieldOptionRelFieldOption')->findOneBy(array('fieldId' => $field_details['id'])); if ($optionsExists) { if (isset($userInfo['status']) && !empty($userInfo['status'])) { $fieldWorkFlow = Database::getManager()->getRepository('ChamiloCoreBundle:ExtraFieldOptionRelFieldOption')->findBy(array('fieldId' => $field_details['id'], 'relatedFieldOptionId' => $defaultValueId, 'roleId' => $userInfo['status'])); foreach ($fieldWorkFlow as $item) { $addOptions[] = $item->getFieldOptionId(); } } } $options = array(); if (empty($defaultValueId)) { $options[''] = get_lang('SelectAnOption'); } $optionList = array(); if (!empty($field_details['options'])) { foreach ($field_details['options'] as $option_details) { $optionList[$option_details['id']] = $option_details; if ($get_lang_variables) { $options[$option_details['option_value']] = get_lang($option_details['option_display_text']); } else { if ($optionsExists) { // Adding always the default value if ($option_details['id'] == $defaultValueId) { $options[$option_details['option_value']] = $option_details['option_display_text']; } else { if (isset($addOptions) && !empty($addOptions)) { // Parsing filters if (in_array($option_details['id'], $addOptions)) { $options[$option_details['option_value']] = $option_details['option_display_text']; } } } } else { // Normal behaviour $options[$option_details['option_value']] = $option_details['option_display_text']; } } } if (isset($optionList[$defaultValueId])) { if (isset($optionList[$defaultValueId]['option_value']) && $optionList[$defaultValueId]['option_value'] == 'aprobada') { if (api_is_question_manager() == false) { $form->freeze(); } } } // Setting priority message if (isset($optionList[$defaultValueId]) && isset($optionList[$defaultValueId]['priority'])) { if (!empty($optionList[$defaultValueId]['priority'])) { $priorityId = $optionList[$defaultValueId]['priority']; $option = new ExtraFieldOption($this->type); $messageType = $option->getPriorityMessageType($priorityId); $form->addElement('label', null, Display::return_message($optionList[$defaultValueId]['priority_message'], $messageType)); } } } if ($get_lang_variables) { $field_details['field_display_text'] = get_lang($field_details['field_display_text']); } // chzn-select doesn't work for sessions?? $form->addElement('select', 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], $options, array('id' => 'extra_' . $field_details['field_variable'])); if ($optionsExists && $field_details['field_loggeable'] && !empty($defaultValueId)) { $form->addElement('textarea', 'extra_' . $field_details['field_variable'] . '_comment', $field_details['field_display_text'] . ' ' . get_lang('Comment')); $em = Database::getManager(); $extraFieldValue = new ExtraFieldValue($this->type); $repo = $em->getRepository($extraFieldValue->entityName); $repoLog = $em->getRepository('Gedmo\\Loggable\\Entity\\LogEntry'); $newEntity = $repo->findOneBy(array($this->handlerEntityId => $itemId, 'fieldId' => $field_details['id'])); // @todo move this in a function inside the class if ($newEntity) { $logs = $repoLog->getLogEntries($newEntity); if (!empty($logs)) { $html = '<b>' . get_lang('LatestChanges') . '</b><br /><br />'; $table = new HTML_Table(array('class' => 'data_table')); $table->setHeaderContents(0, 0, get_lang('Value')); $table->setHeaderContents(0, 1, get_lang('Comment')); $table->setHeaderContents(0, 2, get_lang('ModifyDate')); $table->setHeaderContents(0, 3, get_lang('Username')); $row = 1; foreach ($logs as $log) { $column = 0; $data = $log->getData(); $fieldValue = isset($data['fieldValue']) ? $data['fieldValue'] : null; $comment = isset($data['comment']) ? $data['comment'] : null; $table->setCellContents($row, $column, $fieldValue); $column++; $table->setCellContents($row, $column, $comment); $column++; $table->setCellContents($row, $column, api_get_local_time($log->getLoggedAt()->format('Y-m-d H:i:s'))); $column++; $table->setCellContents($row, $column, $log->getUsername()); $row++; } $form->addElement('label', null, $html . $table->toHtml()); } } } if (!$admin_permissions) { if ($field_details['field_visible'] == 0) { $form->freeze('extra_' . $field_details['field_variable']); } } break; case ExtraField::FIELD_TYPE_SELECT_MULTIPLE: $options = array(); foreach ($field_details['options'] as $option_id => $option_details) { $options[$option_details['option_value']] = $option_details['option_display_text']; } $form->addElement('select', 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], $options, array('multiple' => 'multiple')); if (!$admin_permissions) { if ($field_details['field_visible'] == 0) { $form->freeze('extra_' . $field_details['field_variable']); } } break; case ExtraField::FIELD_TYPE_DATE: $form->addElement('datepickerdate', 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], array('form_name' => $form_name)); $form->_elements[$form->_elementIndex['extra_' . $field_details['field_variable']]]->setLocalOption('minYear', 1900); $defaults['extra_' . $field_details['field_variable']] = date('Y-m-d 12:00:00'); if (!isset($form->_defaultValues['extra_' . $field_details['field_variable']])) { $form->setDefaults($defaults); } if (!$admin_permissions) { if ($field_details['field_visible'] == 0) { $form->freeze('extra_' . $field_details['field_variable']); } } $form->applyFilter('theme', 'trim'); break; case ExtraField::FIELD_TYPE_DATETIME: $form->addElement('datepicker', 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], array('form_name' => $form_name)); $form->_elements[$form->_elementIndex['extra_' . $field_details['field_variable']]]->setLocalOption('minYear', 1900); $defaults['extra_' . $field_details['field_variable']] = date('Y-m-d 12:00:00'); if (!isset($form->_defaultValues['extra_' . $field_details['field_variable']])) { $form->setDefaults($defaults); } if (!$admin_permissions) { if ($field_details['field_visible'] == 0) { $form->freeze('extra_' . $field_details['field_variable']); } } $form->applyFilter('theme', 'trim'); break; case ExtraField::FIELD_TYPE_DOUBLE_SELECT: $first_select_id = 'first_extra_' . $field_details['field_variable']; $url = api_get_path(WEB_AJAX_PATH) . 'extra_field.ajax.php?1=1'; $jquery_ready_content .= ' $("#' . $first_select_id . '").on("change", function() { var id = $(this).val(); if (id) { $.ajax({ url: "' . $url . '&a=get_second_select_options", dataType: "json", data: "type=' . $type . '&field_id=' . $field_details['id'] . '&option_value_id="+id, success: function(data) { $("#second_extra_' . $field_details['field_variable'] . '").empty(); $.each(data, function(index, value) { $("#second_extra_' . $field_details['field_variable'] . '").append($("<option/>", { value: index, text: value })); }); }, }); } else { $("#second_extra_' . $field_details['field_variable'] . '").empty(); } });'; $first_id = null; $second_id = null; if (!empty($extraData)) { $first_id = $extraData['extra_' . $field_details['field_variable']]['extra_' . $field_details['field_variable']]; $second_id = $extraData['extra_' . $field_details['field_variable']]['extra_' . $field_details['field_variable'] . '_second']; } $options = ExtraField::extra_field_double_select_convert_array_to_ordered_array($field_details['options']); $values = array('' => get_lang('Select')); $second_values = array(); if (!empty($options)) { foreach ($options as $option) { foreach ($option as $sub_option) { if ($sub_option['option_value'] == '0') { $values[$sub_option['id']] = $sub_option['option_display_text']; } else { if ($first_id === $sub_option['option_value']) { $second_values[$sub_option['id']] = $sub_option['option_display_text']; } } } } } $group = array(); $group[] = $form->createElement('select', 'extra_' . $field_details['field_variable'], null, $values, array('id' => $first_select_id)); $group[] = $form->createElement('select', 'extra_' . $field_details['field_variable'] . '_second', null, $second_values, array('id' => 'second_extra_' . $field_details['field_variable'])); $form->addGroup($group, 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], ' '); if (!$admin_permissions) { if ($field_details['field_visible'] == 0) { $form->freeze('extra_' . $field_details['field_variable']); } } break; case ExtraField::FIELD_TYPE_DIVIDER: $form->addElement('static', $field_details['field_variable'], '<br /><strong>' . $field_details['field_display_text'] . '</strong>'); break; case ExtraField::FIELD_TYPE_TAG: $field_variable = $field_details['field_variable']; $field_id = $field_details['id']; if ($this->type == 'user') { // The magic should be here $user_tags = UserManager::get_user_tags($user_id, $field_details['id']); $tag_list = ''; if (is_array($user_tags) && count($user_tags) > 0) { foreach ($user_tags as $tag) { $tag_list .= '<option value="' . $tag['tag'] . '" class="selected">' . $tag['tag'] . '</option>'; } } $url = api_get_path(WEB_AJAX_PATH) . 'user_manager.ajax.php?'; } else { $extraFieldValue = new ExtraFieldValue($this->type); $tags = array(); if (!empty($itemId)) { $tags = $extraFieldValue->getAllValuesByItemAndField($itemId, $field_id); } $tag_list = ''; if (is_array($tags) && count($tags) > 0) { $extraFieldOption = new ExtraFieldOption($this->type); foreach ($tags as $tag) { $option = $extraFieldOption->get($tag['field_value']); $tag_list .= '<option value="' . $option['id'] . '" class="selected">' . $option['option_display_text'] . '</option>'; } } $url = api_get_path(WEB_AJAX_PATH) . 'extra_field.ajax.php'; } $form->addElement('hidden', 'extra_' . $field_details['field_variable'] . '__persist__', 1); $multiSelect = '<select id="extra_' . $field_details['field_variable'] . '" name="extra_' . $field_details['field_variable'] . '"> ' . $tag_list . ' </select>'; $form->addElement('label', $field_details['field_display_text'], $multiSelect); $complete_text = get_lang('StartToType'); //if cache is set to true the jquery will be called 1 time $jquery_ready_content .= <<<EOF \$("#extra_{$field_variable}").fcbkcomplete({ json_url: "{$url}?a=search_tags&field_id={$field_id}&type={$this->type}", cache: false, filter_case: true, filter_hide: true, complete_text:"{$complete_text}", firstselected: false, filter_selected: true, newel: true }); EOF; $jquery_ready_content = null; break; case ExtraField::FIELD_TYPE_TIMEZONE: $form->addElement('select', 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], api_get_timezones(), ''); if ($field_details['field_visible'] == 0) { $form->freeze('extra_' . $field_details['field_variable']); } break; case ExtraField::FIELD_TYPE_SOCIAL_PROFILE: // get the social network's favicon $icon_path = UserManager::get_favicon_from_url($extraData['extra_' . $field_details['field_variable']], $field_details['field_default_value']); // special hack for hi5 $leftpad = '1.7'; $top = '0.4'; $domain = parse_url($icon_path, PHP_URL_HOST); if ($domain == 'www.hi5.com' or $domain == 'hi5.com') { $leftpad = '3'; $top = '0'; } // print the input field $form->addElement('text', 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], array('size' => 60, 'style' => 'background-image: url(\'' . $icon_path . '\'); background-repeat: no-repeat; background-position: 0.4em ' . $top . 'em; padding-left: ' . $leftpad . 'em; ')); $form->applyFilter('extra_' . $field_details['field_variable'], 'stripslashes'); $form->applyFilter('extra_' . $field_details['field_variable'], 'trim'); if ($field_details['field_visible'] == 0) { $form->freeze('extra_' . $field_details['field_variable']); } break; } } } $return = array(); $return['jquery_ready_content'] = $jquery_ready_content; return $return; }
function manage_display($task) { global $cfg, $db, $cache; if ($task == '') { $task = 'status'; } // Verify that the user has management perms for the selected contest $res =& db_query('contest_by_id', $_GET['id']); $res->fetchInto($row); $res->free(); if ($_SESSION['user_id'] != $row['manager'] && !auth_user_in_group('Administrators')) { error("Access denied. You are not the contest-manager for this contest."); } switch ($task) { case 'status': $table = new HTML_Table(); // Re-use $row from above if ($row['show_future'] == 1) { $status = 'Hidden (not activated yet)'; } else { if ($row['begin_future'] == 1) { $status = 'Not started'; } else { if ($row['end_future'] == 1) { $status = 'Running'; } else { $status = 'Ended'; } } } $table->addRow(array('Contest status: ', $status), null, 'TH'); $table->addRow(array('Name: ', $row['name'])); $table->addRow(array('Description: ', $row['description'])); $table->addRow(array('Activation time: ', $row['show_time'])); $table->addRow(array('Begin time: ', $row['begin_time'])); $table->addRow(array('End time: ', $row['end_time'])); if ($row['team_size'] != 1) { $table->addRow(array('Max size of team: ', $row['team_size'])); $prefix = 'Teams'; } else { $table->addRow(array('Individual event: ', 'Yes')); $prefix = 'Participants'; } // No. of registered teams $res =& db_query('count_teams_by_contest_id', $_GET['id']); $res->fetchInto($row); $res->free(); $table->addRow(array($prefix . ' registered: ', $row['count'])); // No. of teams logged in $res =& db_query('count_last_teams_by_contest_id', $_GET['id']); $res->fetchInto($row); $res->free(); $table->addRow(array($prefix . ' seen in last 30 minutes: ', $row['count'])); $table->altRowAttributes(1, null, array("class" => "altrow")); echo '<div class="overflow">' . $table->toHtml() . '</div>'; break; case 'problems': // display problem info as table $table = new HTML_Table(); $res =& db_query('problems_by_contest_id', $_GET['id']); if (!$res->fetchInto($row)) { ?> <p>No problems added yet.</p> <?php } else { // extra attributes $row['content'] = null; $row['actions'] = null; $table->addRow(array_keys($row), null, 'TH'); while ($row) { $row['content'] = "<a href=\"index.php?view=manage&task=show_problem&id={$_GET['id']}&prob_id={$row['prob_id']}\">show</a>"; $row['actions'] = "<a href=\"index.php?view=manage&task=edit_problem&id={$_GET['id']}&prob_id={$row['prob_id']}\">edit</a>, " . "<a href=\"index.php?view=manage&task=del_problem&id={$_GET['id']}&prob_id={$row['prob_id']}\">delete</a>"; $table->addRow(array_values($row)); $res->fetchInto($row); } $res->free(); // display tables $table->altRowAttributes(1, null, array("class" => "altrow")); echo '<div class="overflow">' . $table->toHtml() . '</div>'; } echo "<hr />"; // form for adding a problem $form = new HTML_QuickForm('problemAddForm', 'post', selflink()); $form->addElement('header', null, 'Add a problem'); $form->addElement('text', 'prob_id', 'Name (one word ID): '); $form->addElement('text', 'summary', 'Summary: '); $form->addElement('text', 'weight', 'Points weightage: '); $form->addElement('text', 'time_limit', 'Time limit: '); $form->addElement('text', 'mem_limit', 'Memory limit: '); $elem =& $form->addElement('textarea', 'content', 'Problem content (XML): '); $elem->setRows(10); $elem->setCols(80); $form->addElement('submit', null, 'Submit'); $form->applyFilter('prob_id', 'trim'); $form->applyFilter('summary', 'trim'); $form->applyFilter('weight', 'trim'); $form->applyFilter('time_limit', 'trim'); $form->applyFilter('mem_limit', 'trim'); $form->addRule('prob_id', 'Problem ID is required', 'required', null, 'client'); $form->addRule('summary', 'Problem summary is required', 'required', null, 'client'); $form->addRule('weight', 'Points weightage is required', 'required', null, 'client'); $form->addRule('time_limit', 'Time limit is required', 'required', null, 'client'); $form->addRule('mem_limit', 'Memory limit is required', 'required', null, 'client'); $form->addRule('content', 'Problem content in XML is required', 'required', null, 'client'); if ($form->validate()) { $data = $form->getSubmitValues(); $errs = problem_check($data['content']); if ($errs == null) { $data['contest_id'] = $_GET['id']; $res =& $db->autoExecute('problems', $data, DB_AUTOQUERY_INSERT); if (PEAR::isError($res)) { error($res->toString()); } $cache->remove(problem_cache_id($_GET['id'], $data['prob_id']) . '.htm'); $cache->remove(problem_cache_id($_GET['id'], $data['prob_id']) . '.prob'); redirect('index.php?view=manage&task=problems&id=' . $_GET['id']); } else { ?> <p><b>Error:</b> The problem could not be added due to the following errors encountered while parsing the problem XML file. Please fix them and try submitting again.</p> <?php echo "<ol class=\"errors\">\n"; foreach ($errs as $line) { echo "<li>{$line}</li>\n"; } echo "</ol>\n<hr />\n"; } } $form->display(); break; case 'del_problem': db_query('del_problem_by_id', array($_GET['prob_id'], $_GET['id'])); redirect('index.php?view=manage&task=problems&id=' . $_GET['id']); break; case 'edit_problem': $res =& db_query('problem_by_id', array($_GET['prob_id'], $_GET['id'])); $res->fetchInto($row); $res->free(); // Get XML content too $res =& db_query('problem_content_by_id', array($_GET['prob_id'], $_GET['id'])); $res->fetchInto($row2); $res->free(); $row['content'] =& $row2['content']; // form for editing a problem $form = new HTML_QuickForm('problemAddForm', 'post', selflink()); $form->addElement('header', null, 'Edit a problem'); $form->addElement('text', 'prob_id', 'Name (one word ID): '); $form->addElement('text', 'summary', 'Summary: '); $form->addElement('text', 'weight', 'Points weightage: '); $form->addElement('text', 'time_limit', 'Time limit: '); $form->addElement('text', 'mem_limit', 'Memory limit: '); $elem =& $form->addElement('textarea', 'content', 'Problem content (XML): '); $elem->setRows(10); $elem->setCols(80); $form->addElement('submit', null, 'Submit'); $form->applyFilter('prob_id', 'trim'); $form->applyFilter('summary', 'trim'); $form->applyFilter('weight', 'trim'); $form->applyFilter('time_limit', 'trim'); $form->applyFilter('mem_limit', 'trim'); $form->addRule('prob_id', 'Problem ID is required', 'required', null, 'client'); $form->addRule('summary', 'Problem summary is required', 'required', null, 'client'); $form->addRule('weight', 'Points weightage is required', 'required', null, 'client'); $form->addRule('time_limit', 'Time limit is required', 'required', null, 'client'); $form->addRule('mem_limit', 'Memory limit is required', 'required', null, 'client'); $form->addRule('content', 'Problem content in XML is required', 'required', null, 'client'); $form->setDefaults($row); if ($form->validate()) { $data = $form->getSubmitValues(); $errs = problem_check($data['content']); if ($errs == null) { //$data['contest_id'] = $_GET['id']; $data['version'] = $row['version'] + 1; // increment version $res =& $db->autoExecute('problems', $data, DB_AUTOQUERY_UPDATE, 'contest_id=' . $_GET['id'] . " AND prob_id='" . $data['prob_id'] . "'"); if (PEAR::isError($res)) { error($res->toString()); } $cache->remove(problem_cache_id($_GET['id'], $data['prob_id']) . '.htm'); $cache->remove(problem_cache_id($_GET['id'], $data['prob_id']) . '.prob'); redirect('index.php?view=manage&task=problems&id=' . $_GET['id']); } else { ?> <p><b>Error:</b> The changes could not be saved due to the following errors encountered while parsing the problem XML file. Please fix them and try submitting again.</p> <?php echo "<ol class=\"errors\">\n"; foreach ($errs as $line) { echo "<li>{$line}</li>\n"; } echo "</ol>\n<hr />\n"; } } $form->display(); break; case 'show_problem': $res =& db_query('problem_by_id', array($_GET['prob_id'], $_GET['id'])); $res->fetchInto($problem); $res->free(); problem_display($problem); break; case 'settings': // Re-using $row from above // form for editing the contest $form = new HTML_QuickForm('contestEditForm', 'post', selflink()); $form->addElement('header', null, "Edit contest {$row['name']} (id: {$row['contest_id']})"); $form->addElement('text', 'name', 'Name: '); $form->addElement('text', 'description', 'Description: '); $elem =& $form->addElement('text', 'team_size', 'Size of team: '); $elem->setValue('1'); $date = getdate(); $form->addElement('date', 'show_time', 'Activation time: ', array('format' => 'dMY H:i', 'minYear' => $date['year'], 'maxYear' => $date['year'] + 5)); $form->addElement('date', 'begin_time', 'Begin time: ', array('format' => 'dMY H:i', 'minYear' => $date['year'], 'maxYear' => $date['year'] + 5)); $form->addElement('date', 'end_time', 'End time: ', array('format' => 'dMY H:i', 'minYear' => $date['year'], 'maxYear' => $date['year'] + 5)); $form->addElement('text', 'rules', 'Rules URL: '); $form->addElement('submit', null, 'Submit'); // convert date format and store default values $row['show_time'] = sql2form_datetime($row['show_time']); $row['begin_time'] = sql2form_datetime($row['begin_time']); $row['end_time'] = sql2form_datetime($row['end_time']); $form->setDefaults($row); $form->applyFilter('name', 'trim'); $form->applyFilter('description', 'trim'); $form->applyFilter('team_size', 'trim'); $form->addRule('name', 'Contest name is required.', 'required', null, 'client'); $form->addRule('team_size', 'Team size is required.', 'required', null, 'client'); // validate or display form if ($form->validate()) { $data = $form->getSubmitValues(); $data['show_time'] = form2sql_datetime($data['show_time']); $data['begin_time'] = form2sql_datetime($data['begin_time']); $data['end_time'] = form2sql_datetime($data['end_time']); $db->autoExecute('contests', $data, DB_AUTOQUERY_UPDATE, 'contest_id=' . $_GET['id']); if (PEAR::isError($res)) { error($db->toString()); } redirect('index.php?view=manage&id=' . $_GET['id']); } else { $form->display(); } break; case 'submissions': // Re-use $row from above if ($row['end_future'] != '1') { // Contest has ended, show system test button if ($row['tested'] != 1) { ?> <p>Contest has ended. <a class="button" href="index.php?view=manage&&task=test&updateratings=false&id=<?php echo $_GET['id']; ?> ">Test and grade all submissions.</a> <a class="button" href="index.php?view=manage&task=test&updateratings=true&id=<?php echo $_GET['id']; ?> ">Update Ratings</a> </p> <?php } else { ?> <p>Contest has ended and system tests are over. <a class="button" href="index.php?view=manage&task=test&id=<?php echo $_GET['id']; ?> ">Re-run system tests.</a> </p> <?php } } // Show table of all solutions in the contest $table = new HTML_Table(); $res =& db_query('solutions_by_contest_id', $_GET['id']); if (!$res->fetchInto($row)) { // If no solutions in yet ?> <p>Sorry, no solutions have been submitted yet.</p> <?php } else { $table->addRow(array_keys($row), null, 'TH'); if ($row['score'] == '') { $row['score'] = 'n/a'; } if ($row['passed'] == '') { $row['passed'] = 'n/a'; } $table->addRow(array_values($row)); while ($res->fetchInto($row)) { if ($row['score'] == '') { $row['score'] = 'n/a'; } if ($row['passed'] == '') { $row['passed'] = 'n/a'; } $table->addRow(array_values($row)); } $table->altRowAttributes(1, null, array("class" => "altrow")); echo '<div class="overflow">' . $table->toHtml() . '</div>'; } break; case 'test': require_once 'tester.php'; ob_end_clean(); html_reset(); html_header(null, $cfg["dir"]["themes"] . '/' . $_SESSION["theme"] . '.css', $cfg["dir"]["themes"] . '/' . $_SESSION["theme"] . '-ie.css', null, "submit_frame"); $contest_id = $_GET['id']; $update_ratings = $_GET['updateratings']; session_write_close(); test_contest($update_ratings, $contest_id); echo ' <a class="white" href="index.php?view=statistics&task=contest&id=' . $_GET['id'] . '">See the results.</a>'; html_footer(); exit; } }
} $interbreadcrumb[] = array('url' => '../group/group.php', 'name' => get_lang('Groups')); $interbreadcrumb[] = array('url' => '../group/group_space.php?gidReq=' . $group_id, 'name' => get_lang('GroupSpace') . ' ' . $group_properties['name']); } else { if (!api_is_allowed_to_edit(false, true)) { api_not_allowed(true); } } $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH) . 'work/work.php?' . api_get_cidreq(), 'name' => get_lang('StudentPublications')); $interbreadcrumb[] = array('url' => '#', 'name' => $userInfo['complete_name']); Display::display_header(null); echo '<div class="actions">'; echo '<a href="' . api_get_path(WEB_CODE_PATH) . 'work/work.php?' . api_get_cidreq() . '&origin=' . $origin . '&gradebook=' . $gradebook . '">' . Display::return_icon('back.png', get_lang('BackToWorksList'), '', ICON_SIZE_MEDIUM) . '</a>'; echo '</div>'; $workPerUser = getWorkPerUser($studentId); $table = new HTML_Table(array('class' => 'data_table')); $column = 0; $row = 0; $headers = array(get_lang('Title'), get_lang('HandedOutDate'), get_lang('HandOutDateLimit'), get_lang('Score'), get_lang('Actions')); foreach ($headers as $header) { $table->setHeaderContents($row, $column, $header); $column++; } $row++; $column = 0; foreach ($workPerUser as $work) { $work = $work['work']; $scoreWeight = intval($work->qualification) == 0 ? null : $work->qualification; $workId = $work->id; $workExtraData = get_work_assignment_by_id($workId); foreach ($work->user_results as $userResult) {
/** * Returns a category summary report * * @param int exercise id * @param array prefilled array with the category_id, score, and weight example: array(1 => array('score' => '10', 'total' => 20)); * @param bool $categoryMinusOne shows category - 1 see BT#6540 * @return string */ public static function get_stats_table_by_attempt($exercise_id, $category_list = array(), $categoryMinusOne = false) { if (empty($category_list)) { return null; } $category_name_list = Testcategory::getListOfCategoriesNameForTest($exercise_id, false); $table = new HTML_Table(array('class' => 'data_table')); $table->setHeaderContents(0, 0, get_lang('Categories')); $table->setHeaderContents(0, 1, get_lang('AbsoluteScore')); $table->setHeaderContents(0, 2, get_lang('RelativeScore')); $row = 1; $none_category = array(); if (isset($category_list['none'])) { $none_category = $category_list['none']; unset($category_list['none']); } $total = array(); if (isset($category_list['total'])) { $total = $category_list['total']; unset($category_list['total']); } $em = Database::getManager(); $repo = $em->getRepository('ChamiloCoreBundle:CQuizCategory'); $redefineCategoryList = array(); if (!empty($category_list) && count($category_list) > 1) { $globalCategoryScore = array(); foreach ($category_list as $category_id => $category_item) { $cat = $em->find('ChamiloCoreBundle:CQuizCategory', $category_id); $path = $repo->getPath($cat); $categoryName = $category_name_list[$category_id]; $index = 0; if ($categoryMinusOne) { $index = 1; } if (isset($path[$index])) { $category_id = $path[$index]->getIid(); $categoryName = $path[$index]->getTitle(); } if (!isset($globalCategoryScore[$category_id])) { $globalCategoryScore[$category_id] = array(); $globalCategoryScore[$category_id]['score'] = 0; $globalCategoryScore[$category_id]['total'] = 0; $globalCategoryScore[$category_id]['title'] = ''; } $globalCategoryScore[$category_id]['score'] += $category_item['score']; $globalCategoryScore[$category_id]['total'] += $category_item['total']; $globalCategoryScore[$category_id]['title'] = $categoryName; } foreach ($globalCategoryScore as $category_item) { $table->setCellContents($row, 0, $category_item['title']); $table->setCellContents($row, 1, ExerciseLib::show_score($category_item['score'], $category_item['total'], false)); $table->setCellContents($row, 2, ExerciseLib::show_score($category_item['score'], $category_item['total'], true, false, true)); $class = 'class="row_odd"'; if ($row % 2) { $class = 'class="row_even"'; } $table->setRowAttributes($row, $class, true); $row++; } if (!empty($none_category)) { $table->setCellContents($row, 0, get_lang('None')); $table->setCellContents($row, 1, ExerciseLib::show_score($none_category['score'], $none_category['total'], false)); $table->setCellContents($row, 2, ExerciseLib::show_score($none_category['score'], $none_category['total'], true, false, true)); $row++; } if (!empty($total)) { $table->setCellContents($row, 0, get_lang('Total')); $table->setCellContents($row, 1, ExerciseLib::show_score($total['score'], $total['total'], false)); $table->setCellContents($row, 2, ExerciseLib::show_score($total['score'], $total['total'], true, false, true)); $table->setRowAttributes($row, 'class="row_total"', true); } return $table->toHtml(); } return null; }
/** * Create a new SortableTable * @param string $table_name A name for the table (default = 'table') * @param string $get_total_number_function A user defined function to get * the total number of items in the table * @param string $get_data_function A function to get the data to display on * the current page * @param int $default_column The default column on which the data should be * sorted * @param int $default_items_per_page The default number of items to show * on one page * @param string $default_order_direction The default order direction; * either the constant 'ASC' or 'DESC' * @param string $table_id */ public function __construct($table_name = 'table', $get_total_number_function = null, $get_data_function = null, $default_column = 1, $default_items_per_page = 20, $default_order_direction = 'ASC', $table_id = null) { if (empty($table_id)) { $table_id = $table_name . uniqid(); } $this->table_id = $table_id; parent::__construct(array('id' => $table_id, 'class' => 'table table-striped table-hover table-bordered')); $this->table_name = $table_name; $this->additional_parameters = array(); $this->param_prefix = $table_name . '_'; $this->page_nr = isset($_SESSION[$this->param_prefix . 'page_nr']) ? intval($_SESSION[$this->param_prefix . 'page_nr']) : 1; $this->page_nr = isset($_GET[$this->param_prefix . 'page_nr']) ? intval($_GET[$this->param_prefix . 'page_nr']) : $this->page_nr; $this->column = isset($_SESSION[$this->param_prefix . 'column']) ? intval($_SESSION[$this->param_prefix . 'column']) : $default_column; $this->column = isset($_GET[$this->param_prefix . 'column']) ? intval($_GET[$this->param_prefix . 'column']) : $this->column; // Default direction if (in_array(strtoupper($default_order_direction), array('ASC', 'DESC'))) { $this->direction = $default_order_direction; } if (isset($_SESSION[$this->param_prefix . 'direction'])) { $my_session_direction = $_SESSION[$this->param_prefix . 'direction']; if (!in_array($my_session_direction, array('ASC', 'DESC'))) { $this->direction = 'ASC'; } else { if ($my_session_direction == 'ASC') { $this->direction = 'ASC'; } elseif ($my_session_direction == 'DESC') { $this->direction = 'DESC'; } } } if (isset($_GET[$this->param_prefix . 'direction'])) { $my_get_direction = $_GET[$this->param_prefix . 'direction']; if (!in_array($my_get_direction, array('ASC', 'DESC'))) { $this->direction = 'ASC'; } else { if ($my_get_direction == 'ASC') { $this->direction = 'ASC'; } elseif ($my_get_direction == 'DESC') { $this->direction = 'DESC'; } } } // Allow to change paginate in multiples tabs unset($_SESSION[$this->param_prefix . 'per_page']); $this->per_page = isset($_SESSION[$this->param_prefix . 'per_page']) ? intval($_SESSION[$this->param_prefix . 'per_page']) : $default_items_per_page; $this->per_page = isset($_GET[$this->param_prefix . 'per_page']) ? intval($_GET[$this->param_prefix . 'per_page']) : $this->per_page; $_SESSION[$this->param_prefix . 'per_page'] = $this->per_page; $_SESSION[$this->param_prefix . 'direction'] = $this->direction; $_SESSION[$this->param_prefix . 'page_nr'] = $this->page_nr; $_SESSION[$this->param_prefix . 'column'] = $this->column; $this->pager = null; $this->default_items_per_page = $default_items_per_page; $this->total_number_of_items = -1; $this->get_total_number_function = $get_total_number_function; $this->get_data_function = $get_data_function; $this->column_filters = array(); $this->form_actions = array(); $this->checkbox_name = null; $this->td_attributes = array(); $this->th_attributes = array(); $this->other_tables = array(); }