function generateConfirm($edit) { $dataInvalid = $this->isDataInvalid($edit); if ($this->formbuilder) { $this->formbuilder->bulk_set_answers($_POST[$this->event->formkey()]); $dataInvalid .= $this->formbuilder->answers_invalid(); } if ($dataInvalid) { error_exit($dataInvalid . '<br>Please use your back button to return to the form, fix these errors, and try again.'); } $output = para('Please confirm that this data is correct and click the submit button to proceed to the payment information page.'); $output .= form_hidden('edit[step]', 'submit'); $fields = array('Registration Status' => 'payment', 'Notes' => 'notes'); $rows = array(); foreach ($fields as $display => $column) { array_push($rows, array($display, form_hidden("edit[{$column}]", $edit[$column]) . check_form($edit[$column]))); } $output .= form_group('Registration details', "<div class='pairtable'>" . table(null, $rows) . '</div>'); if ($this->formbuilder) { $form = $this->formbuilder->render_viewable(); $form .= $this->formbuilder->render_hidden(); $output .= form_group('Registration answers', $form); } $output .= para(form_submit('submit')); return form($output); }
function process() { global $dbh; $this->title = 'Player Statistics'; $rows = array(); $sth = $dbh->prepare('SELECT status, COUNT(*) FROM person GROUP BY status'); $sth->execute(); $sub_table = array(); $sum = 0; while ($row = $sth->fetch(PDO::FETCH_NUM)) { $sub_table[] = $row; $sum += $row[1]; } $sub_table[] = array('Total', $sum); $rows[] = array('Players by account status:', table(null, $sub_table)); $sth = $dbh->prepare('SELECT class, COUNT(*) FROM person GROUP BY class'); $sth->execute(); $sub_table = $sth->fetchAll(PDO::FETCH_NUM); $rows[] = array('Players by account class:', table(null, $sub_table)); $sth = $dbh->prepare('SELECT gender, COUNT(*) FROM person GROUP BY gender'); $sth->execute(); $sub_table = $sth->fetchAll(PDO::FETCH_NUM); $rows[] = array('Players by gender:', table(null, $sub_table)); $sth = $dbh->prepare('SELECT FLOOR((YEAR(NOW()) - YEAR(birthdate)) / 5) * 5 as age_bucket, COUNT(*) AS count FROM person GROUP BY age_bucket'); $sth->execute(); $sub_table = array(); while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { $sub_table[] = array($row['age_bucket'] . ' to ' . ($row['age_bucket'] + 4), $row['count']); } $rows[] = array('Players by age:', table(null, $sub_table)); $sth = $dbh->prepare('SELECT addr_city, COUNT(*) AS num FROM person GROUP BY addr_city HAVING num > 2 ORDER BY num DESC'); $sth->execute(); $sub_table = $sth->fetchAll(PDO::FETCH_NUM); $rows[] = array('Players by city:', table(null, $sub_table)); $sth = $dbh->prepare('SELECT skill_level, COUNT(*) FROM person GROUP BY skill_level'); $sth->execute(); $sub_table = $sth->fetchAll(PDO::FETCH_NUM); $rows[] = array('Players by skill level:', table(null, $sub_table)); $sth = $dbh->prepare('SELECT year_started, COUNT(*) FROM person GROUP BY year_started'); $sth->execute(); $sub_table = $sth->fetchAll(PDO::FETCH_NUM); $rows[] = array('Players by starting year:', table(null, $sub_table)); if (variable_get('dog_questions', 1)) { $sth = $dbh->prepare("SELECT COUNT(*) FROM person where has_dog = 'Y'"); $sth->execute(); $rows[] = array('Players with dogs :', $sth->fetchColumn()); } $output = "<div class='pairtable'>" . table(null, $rows) . "</div>"; return form_group('Player Statistics', $output); }
function guifi_form_column_group($title, $form, $help) { return form_group($title, "\n<table>\r <tr>\r " . $form . " </tr>\r</table>\n", $help); }
function process() { global $dbh; $this->title = 'Team Statistics'; $rows = array(); $current_season = variable_get('current_season', 'Summer'); $sth = $dbh->prepare('SELECT COUNT(*) FROM team'); $sth->execute(); $rows[] = array("Number of teams (total):", $sth->fetchColumn()); $sth = $dbh->prepare('SELECT l.season, COUNT(*) FROM leagueteams t, league l WHERE t.league_id = l.league_id AND l.status = "open" GROUP BY l.season'); $sth->execute(); $sub_table = array(); while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { $sub_table[] = $row; } $rows[] = array("Teams by season:", table(null, $sub_table)); $sth = $dbh->prepare("SELECT t.team_id,t.name, COUNT(r.player_id) as size \n\t\tFROM teamroster r, league l, leagueteams lt\n\t\tLEFT JOIN team t ON (t.team_id = r.team_id) \n\t\tWHERE\n\t\t\tlt.team_id = r.team_id\n\t\t\tAND l.league_id = lt.league_id\n\t\t\t\t\tAND l.status = 'open'\n\t\t\tAND l.schedule_type != 'none'\n\t\t\t\t\tAND l.season = ?\n\t\t\tAND (r.status = 'player' OR r.status = 'captain' OR r.status = 'assistant')\n\t\tGROUP BY t.team_id\n\t\tHAVING size < 12\n\t\tORDER BY size desc, t.name"); $sth->execute(array($current_season)); $sub_table = array(); $sub_sth = $dbh->prepare("SELECT COUNT(*) FROM teamroster r WHERE r.team_id = ? AND r.status = 'substitute'"); while ($row = $sth->fetch()) { if ($row['size'] < 12) { $sub_sth->execute(array($row['team_id'])); $substitutes = $sub_sth->fetchColumn(); if ($row['size'] + floor($substitutes / 3) < 12) { $sub_table[] = array(l($row['name'], "team/view/" . $row['team_id']), $row['size'] + floor($substitutes / 3)); } } } $rows[] = array("{$current_season} teams with too few players:", table(null, $sub_table)); $sth = $dbh->prepare("SELECT t.team_id, t.name, t.rating\n\t\t\tFROM team t, league l, leagueteams lt\n\t\t\tWHERE\n\t\t\t\tlt.team_id = t.team_id\n\t\t\t\tAND l.league_id = lt.league_id\n\t\t\t\tAND l.status = 'open'\n\t\t\t\tAND l.schedule_type != 'none'\n\t\t\t\tAND l.season = ?\n\t\t\tORDER BY t.rating DESC LIMIT 10"); $sth->execute(array($current_season)); $sub_table = array(); while ($row = $sth->fetch()) { $sub_table[] = array(l($row['name'], "team/view/" . $row['team_id']), $row['rating']); } $rows[] = array("Top-rated {$current_season} teams:", table(null, $sub_table)); $sth = $dbh->prepare("SELECT t.team_id, t.name, t.rating\n\t\t\tFROM team t, league l, leagueteams lt\n\t\t\tWHERE\n\t\t\t\tlt.team_id = t.team_id\n\t\t\t\tAND l.league_id = lt.league_id\n\t\t\t\tAND l.status = 'open'\n\t\t\t\tAND l.schedule_type != 'none'\n\t\t\t\tAND l.season = ?\n\t\t\tORDER BY t.rating ASC LIMIT 10"); $sth->execute(array($current_season)); $sub_table = array(); while ($row = $sth->fetch()) { $sub_table[] = array(l($row['name'], "team/view/" . $row['team_id']), $row['rating']); } $rows[] = array("Lowest-rated {$current_season} teams:", table(null, $sub_table)); $sth = $dbh->prepare("SELECT COUNT(*) AS num,\n\t\t\t\tIF(s.status = 'home_default',s.home_team,s.away_team) AS team_id\n\t\t\tFROM schedule s, league l\n\t\t\tWHERE\n\t\t\t\ts.league_id = l.league_id\n\t\t\t\tAND l.status = 'open'\n\t\t\t\tAND l.season = ?\n\t\t\t\tAND (s.status = 'home_default' OR s.status = 'away_default')\n\t\t\tGROUP BY team_id ORDER BY num DESC"); $sth->execute(array($current_season)); $sub_table = array(); while ($row = $sth->fetch()) { $team = Team::load(array('team_id' => $row['team_id'])); $sub_table[] = array(l($team->name, "team/view/" . $row['team_id']), $row['num']); } $rows[] = array("Top defaulting {$current_season} teams:", table(null, $sub_table)); $sth = $dbh->prepare("SELECT COUNT(*) AS num,\n\t\t\t\tIF(s.approved_by = -3,s.home_team,s.away_team) AS team_id\n\t\t\tFROM schedule s, league l\n\t\t\tWHERE\n\t\t\t\ts.league_id = l.league_id\n\t\t\t\tAND l.status = 'open'\n\t\t\t\tAND l.season = ?\n\t\t\t\tAND (s.approved_by = -2 OR s.approved_by = -3)\n\t\t\tGROUP BY team_id ORDER BY num DESC"); $sth->execute(array($current_season)); $sub_table = array(); while ($row = $sth->fetch()) { $team = Team::load(array('team_id' => $row['team_id'])); $sub_table[] = array(l($team->name, "team/view/" . $row['team_id']), $row['num']); } $rows[] = array("Top non-score-submitting {$current_season} teams:", table(null, $sub_table)); $sotg_query = "SELECT\n\t\t\t\tROUND( AVG( s.score_entry_penalty + s.timeliness + s.rules_knowledge + s.sportsmanship + s.rating_overall ), 2) AS avgspirit,\n\t\t\t\ts.tid AS team_id\n\t\t\tFROM league l, leagueteams lt, spirit_entry s\n\t\t\tWHERE\n\t\t\t\tlt.league_id = l.league_id\n\t\t\t\tAND lt.team_id = s.tid\n\t\t\t\tAND l.status = 'open'\n\t\t\t\tAND l.season = ?\n\t\t\tGROUP BY team_id"; $sth = $dbh->prepare($sotg_query . " ORDER BY avgspirit DESC LIMIT 10"); $sth->execute(array($current_season)); $sub_table = array(); while ($row = $sth->fetch()) { $team = Team::load(array('team_id' => $row['team_id'])); $sub_table[] = array(l($team->name, "team/view/" . $row['team_id']), $row['avgspirit']); } $rows[] = array("Best spirited {$current_season} teams:", table(null, $sub_table)); $sth = $dbh->prepare($sotg_query . " ORDER BY avgspirit ASC LIMIT 10"); $sth->execute(array($current_season)); $sub_table = array(); while ($row = $sth->fetch()) { $team = Team::load(array('team_id' => $row['team_id'])); $sub_table[] = array(l($team->name, "team/view/" . $row['team_id']), $row['avgspirit']); } $rows[] = array("Lowest spirited {$current_season} teams:", table(null, $sub_table)); $output = "<div class='pairtable'>" . table(null, $rows) . "</div>"; return form_group("Team Statistics", $output); }
function selectType($edit) { $num_teams = count($this->league->teams); if (isset($edit['excludeTeamID'])) { $output = "<p><br>You will be excluding the following teams from the schedule: <br><b>"; $counter = 0; $excludes = ""; foreach ($edit['excludeTeamID'] as $teamid) { $excludes .= $this->league->teams[$teamid]->name . "<br>"; $output .= form_hidden("edit[excludeTeamID][{$counter}]", $teamid); $counter++; $num_teams--; } $output .= $excludes . "</b></p>"; if ($num_teams % 2) { error_exit("You marked " . count($edit['excludeTeamID']) . " teams to exclude, that leaves {$num_teams}. Cannot schedule games for an un-even number of teams!"); } } $this->loadTypes($num_teams); $output .= "<p>Please enter some information about the game(s) to create.</p>"; $output .= form_hidden('edit[step]', 'selectdate'); $group .= form_radiogroup('', 'edit[type]', 'single', $this->types, "Select the type of game or games to add. Note that for auto-generated round-robins, fields will be automatically allocated."); $group .= form_checkbox("Publish created games for player viewing?", 'edit[publish]', 'yes', true, "If this is checked, players will be able to view games immediately after creation. Uncheck it if you wish to make changes before players can view."); $output .= form_group("Create a ... ", $group); $output .= form_submit('Next step'); return form($output); }
function form_group_select($label, $field, $options, $prefill_value, $form_name, $parameters = array()) { $select_tag = "<select class=\"form-control selectpicker\"" . (is_empty($parameters["search"]) ? "" : " data-live-search=\"true\"") . (is_empty($parameters["multiple"]) ? "" : " multiple") . " title=\"\" id=\"" . $field . "\" name=\"" . $field . (is_empty($parameters["multiple"]) ? "" : "[]") . "\">"; foreach ($options as $value => $option_label) { if (is_array($option_label)) { $icon = $option_label["icon"]; $option_label = $option_label["label"]; } $select_tag .= "<option value=\"" . $value . "\"" . (in_array($value, $prefill_value) ? " selected=\"selected\"" : "") . (is_empty($icon) ? "" : " data-icon=\"fa fa-" . $icon . "\"") . ($field == "tags" ? " data-content=\"<span class='tag-in-form'>" . $option_label . "</span>\"" : "") . ">" . $option_label . "</option>"; } $select_tag .= "</select>"; return form_group($label, $field, $select_tag, $form_name); }
function generateConfirm($game, $edit) { if (!$this->can_edit) { error_exit("You do not have permission to edit this game"); } $dataInvalid = $this->isDataInvalid($edit); $s = new Spirit(); $home_spirit = $s->as_formbuilder(); $away_spirit = $s->as_formbuilder(); $win = variable_get('default_winning_score', 6); $lose = variable_get('default_losing_score', 0); switch ($edit['status']) { case 'home_default': $edit['home_score'] = "{$lose} (defaulted)"; $edit['away_score'] = $win; break; case 'away_default': $edit['home_score'] = $win; $edit['away_score'] = "{$lose} (defaulted)"; break; case 'forfeit': $edit['home_score'] = '0 (forfeit)'; $edit['away_score'] = '0 (forfeit)'; break; case 'normal': default: $home_spirit->bulk_set_answers($_POST['spirit_home']); $away_spirit->bulk_set_answers($_POST['spirit_away']); $dataInvalid .= $home_spirit->answers_invalid(); $dataInvalid .= $away_spirit->answers_invalid(); break; } if ($dataInvalid) { error_exit($dataInvalid . "<br>Please use your back button to return to the form, fix these errors, and try again"); } $output = para("You have made the changes below for the {$game->game_date} {$game->game_start} game between {$game->home_name} and {$game->away_name}. "); $output .= para("If this is correct, please click 'Submit' to continue. If not, use your back button to return to the previous page and correct the score."); $output .= form_hidden('edit[step]', 'perform'); $output .= form_hidden('edit[status]', $edit['status']); $output .= form_hidden('edit[home_score]', $edit['home_score']); $output .= form_hidden('edit[away_score]', $edit['away_score']); $score_group .= form_item("Home ({$game->home_name} [rated: {$game->rating_home}]) Score", $edit['home_score']); $score_group .= form_item("Away ({$game->away_name} [rated: {$game->rating_away}]) Score", $edit['away_score']); $output .= form_group("Scoring", $score_group); if ($edit['status'] == 'normal') { $output .= form_group("Spirit assigned to home ({$game->home_name})", $home_spirit->render_viewable()); $output .= $home_spirit->render_hidden('home'); $output .= form_group("Spirit assigned to away ({$game->away_name})", $away_spirit->render_viewable()); $output .= $away_spirit->render_hidden('away'); } $output .= para(form_submit('submit')); return form($output); }
/** * Render for maintenance of the form. */ function render_maintenance() { // Remember the last sort order found, new question defaults to one past $sorder = 0; $output = form_hidden('edit[step]', 'confirm'); while (list(, $q) = each($this->_questions)) { $output .= question_render_maintenance($q); $sorder = $q->sorder; // assume they're in order } // Add a form group for adding a new element $element = form_textfield('Element name', "data[_new][name]", '', 60, 60, 'If this is blank, no new element will be added'); $element .= form_textarea('Element text', "data[_new][question]", '', 60, 5); $element .= form_textfield('Sort order', "data[_new][sorder]", $sorder + 1, 10, 10); $element .= form_checkbox('Required', "data[_new][required]", 1, false, 'Does this element require an answer? (Ignored for checkboxes, labels and descriptions)'); $type = form_radio('Text field', 'data[_new][type]', 'textfield', true, 'A single line of text'); $type .= form_radio('Text area', 'data[_new][type]', 'freetext', false, 'A 60x5 text box'); $type .= form_radio('Multiple choice', 'data[_new][type]', 'multiplechoice', false, 'Multiple choice, answers can be defined later.'); $type .= form_radio('Checkbox', 'data[_new][type]', 'checkbox', false, 'A true/false checkbox.'); $type .= form_radio('Label', 'data[_new][type]', 'label', false, 'Not a question, used for inserting a label anywhere (e.g. before a checkbox group).'); $type .= form_radio('Description', 'data[_new][type]', 'description', false, 'Not a question, a block of descriptive text.'); $element .= form_item('Element type', $type); $output .= form_group("Add a new element", $element); $output .= form_submit('Submit'); $output .= form_reset('Reset'); return form($output); }
$out .= '</label>'; } $out .= '</div>'; return form_group($out, $name); }); Form::macro('radioStack', function ($name, $label = NULL, array $options, $checked = NULL, $attributes = []) { $out = $label ? '<label for="' . $name . '">' . $label . '</label>' : ''; $values = array_keys($options); foreach ($values as $value) { $out .= '<div class="radio">'; $out .= '<label>'; $out .= Form::radio($name, $value, $checked ? $checked == $value : old($name) == $value, $attributes) . $options[$value]; $out .= '</label>'; $out .= '</div>'; } return form_group($out, $name); }); Form::macro('checkboxField', function ($name, $label = NULL, $value = 1, $checked = NULL, $attributes = []) { $out = '<div class="checkbox'; $out .= field_error($name) . '">'; $out .= '<label>'; $out .= Form::checkbox($name, $value, $checked ? $checked : old($name), $attributes) . $label; $out .= '</div>'; return $out; }); Form::macro('delete', function ($route, $id, $text = '', $tooltip = false, $icon = true) { $model = explode('.', $route); $model = ucfirst(substr($model[1], 0, -1)); $tooltip = $tooltip ? $tooltip : 'Deletar ' . $model; $out = Form::open(['route' => [$route . '.destroy', $id], 'method' => 'DELETE', 'data-id' => $id, 'style' => 'display: inline-block']); $out .= '<button data-toggle="tooltip" data-placement="top" data-original-title="' . $tooltip . '" type="submit" data-id="' . $id . '" class="btn btn-danger btn-sm ' . ($icon ? 'btn-fw' : '') . '">';
function registration_settings() { $group = form_textfield('Order ID format string', 'edit[order_id_format]', variable_get('order_id_format', 'R%09d'), 60, 120, 'sprintf format string for the unique order ID.'); $group .= form_textarea('Text of refund policy', 'edit[refund_policy_text]', variable_get('refund_policy_text', ''), 70, 10, 'Customize the text of your refund policy, to be shown on registration pages and invoices.'); $offline = <<<END <ul> \t<li>Mail (or personally deliver) a cheque for the appropriate amount to the league office</li> \t<li>Ensure that you quote order #<b>%order_num</b> on the cheque in order for your payment to be properly credited.</li> \t<li>Also include a note indicating which registration the cheque is for, along with your full name.</li> \t<li>If you are paying for multiple registrations with a single cheque, be sure to list all applicable order numbers, registrations and member names.</li> </ul> <p>Please note that you will not be registered to the appropriate category that you are paying for until the cheque is received and processed (usually within 1-2 business days of receipt)</p> END; $group .= form_textarea('Text of offline payment directions', 'edit[offline_payment_text]', variable_get('offline_payment_text', $offline), 70, 10, 'Customize the text of your offline payment policy. Available variables are: %order_num'); $group .= form_textarea('Text for "Partner Info" section', 'edit[partner_info_text]', variable_get('partner_info_text', ''), 70, 10, 'Customize the text for the "Partner Info" section of the registration results.'); $output = form_group('Registration configuration', $group); return $output; }