Exemplo n.º 1
0
 function __construct($id)
 {
     $this->slot = GameSlot::load(array('slot_id' => $id));
     if (!$this->slot) {
         error_exit("That gameslot does not exist");
     }
 }
Exemplo n.º 2
0
 function process()
 {
     $this->template_name = 'pages/slot/day.tpl';
     list($year, $month, $day) = preg_split("/[\\/-]/", $_GET['date']);
     $today = getdate();
     $yyyy = is_numeric($year) ? $year : $today['year'];
     $mm = is_numeric($month) ? $month : $today['mon'];
     $dd = is_numeric($day) ? $day : $today['mday'];
     if (!validate_date_input($yyyy, $mm, $dd)) {
         error_exit('That date is not valid');
     }
     $this->smarty->assign('date', sprintf("%4d/%02d/%02d", $yyyy, $mm, $dd));
     $formattedDay = strftime('%A %B %d %Y', mktime(6, 0, 0, $mm, $dd, $yyyy));
     $this->title = "Field Availability Report » {$formattedDay}";
     $sth = GameSlot::query(array('game_date' => sprintf('%d-%d-%d', $year, $month, $day), '_order' => 'g.game_start, field_code, field_num'));
     $num_open = 0;
     $slots = array();
     while ($g = $sth->fetch()) {
         // load game info, if game scheduled
         if ($g['game_id']) {
             $g['game'] = Game::load(array('game_id' => $g['game_id']));
         } else {
             $num_open++;
         }
         $slots[] = $g;
     }
     $this->smarty->assign('slots', $slots);
     $this->smarty->assign('num_fields', count($slots));
     $this->smarty->assign('num_open', $num_open);
     return true;
 }
Exemplo n.º 3
0
 function perform($edit, $datestamp)
 {
     $dataInvalid = $this->isDataInvalid($edit);
     if ($dataInvalid) {
         error_exit($dataInvalid . "<br>Please use your back button to return to the form, fix these errors, and try again");
     }
     for ($i = 0; $i < $edit['repeat_for']; $i++) {
         $slot = new GameSlot();
         $slot->set('fid', $this->field->fid);
         $slot->set('game_date', strftime("%Y-%m-%d", $datestamp));
         $slot->set('game_start', $edit['start_time']);
         if ($edit['end_time'] != '---') {
             $slot->set('game_end', $edit['end_time']);
         }
         foreach ($edit['availability'] as $league_id) {
             $slot->add_league($league_id);
         }
         if (!$slot->save()) {
             // if we fail, bail
             return false;
         }
         $datestamp += 7 * 24 * 60 * 60;
         // advance by a week
     }
     return true;
 }
Exemplo n.º 4
0
 function process()
 {
     global $lr_session;
     $this->title = "{$this->field->fullname} &raquo; Bookings";
     $this->template_name = 'pages/field/bookings.tpl';
     if ($this->field->status != 'open') {
         error_exit("That field is closed");
     }
     $sth = GameSlot::query(array('fid' => $this->field->fid, '_extra' => 'DATE_SUB(CURDATE(), INTERVAL 1 YEAR) AND DATE_ADD(CURDATE(), INTERVAL 1 YEAR)', '_order' => 'g.game_date, g.game_start'));
     $slots = array();
     while ($slot = $sth->fetchObject('GameSlot')) {
         if ($slot->game_id) {
             $slot->game = Game::load(array('game_id' => $slot->game_id));
         }
         $slots[] = $slot;
     }
     $this->smarty->assign('slots', $slots);
     return true;
 }
Exemplo n.º 5
0
 function generateConfirm($edit)
 {
     global $dbh;
     $dataInvalid = $this->isDataInvalid($edit['games']);
     if ($dataInvalid) {
         error_exit($dataInvalid . "<br>Please use your back button to return to the form, fix these errors, and try again");
     }
     $gameslots = $this->league->get_gameslots($this->day_id);
     if (count($gameslots) <= 1) {
         error_exit("There are no fields assigned to this league!");
     }
     $output = para("Confirm that the changes below are correct, and click 'Submit' to proceed.");
     if ($edit['published'] == 'yes') {
         $output .= para("Games will be made available for player viewing.") . form_hidden('edit[published]', 'yes');
     } else {
         $output .= para("Games will be hidden from player view until you choose to publish them.") . form_hidden('edit[published]', 'no');
     }
     $output .= form_hidden('edit[step]', 'perform');
     $header = array("Game ID", "Round", "Game Slot", "Home", "Away");
     $rows = array();
     while (list($game_id, $game_info) = each($edit['games'])) {
         reset($game_info);
         $slot = GameSlot::load(array('slot_id' => $game_info['slot_id']));
         $team_sth = $dbh->prepare('SELECT name FROM team WHERE team_id = ?');
         $team_sth->execute(array($game_info['home_id']));
         $home_name = $team_sth->fetchColumn();
         $team_sth->execute(array($game_info['away_id']));
         $away_name = $team_sth->fetchColumn();
         $rows[] = array(form_hidden("edit[games][{$game_id}][game_id]", $game_id) . $game_id, form_hidden("edit[games][{$game_id}][round]", $game_info['round']) . $game_info['round'], form_hidden("edit[games][{$game_id}][slot_id]", $game_info['slot_id']) . $gameslots[$game_info['slot_id']], form_hidden("edit[games][{$game_id}][home_id]", $game_info['home_id']) . $home_name, form_hidden("edit[games][{$game_id}][away_id]", $game_info['away_id']) . $away_name);
     }
     $output .= "<div class='listtable'>" . table($header, $rows) . "</div>";
     $output .= para(form_submit('submit'));
     return form($output);
 }