예제 #1
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;
 }
예제 #2
0
 function process()
 {
     $this->title = "{$this->field->fullname} Create Game Slot";
     if ($this->field->status != 'open') {
         error_exit("That field is closed");
     }
     $edit =& $_POST['edit'];
     if ($edit['date']) {
         list($year, $month, $day) = preg_split("/[\\/-]/", $edit['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');
         }
         $datestamp = mktime(6, 0, 0, $mm, $dd, $yyyy);
     }
     switch ($edit['step']) {
         case 'perform':
             if (!$this->perform($edit, $datestamp)) {
                 error_exit("Aieee!  Bad things happened in gameslot create");
             }
             local_redirect(url("field/view/{$this->field->fid}"));
             break;
         case 'confirm':
             $this->template_name = 'pages/slot/create/confirm.tpl';
             return $this->generateConfirm($edit, $datestamp);
             break;
         case 'details':
             $this->template_name = 'pages/slot/create/step2.tpl';
             return $this->generateForm($datestamp);
             break;
         default:
             $this->template_name = 'pages/slot/create/step1.tpl';
             return true;
     }
     error_exit("Error: This code should never be reached.");
 }
예제 #3
0
 function process()
 {
     $this->template_name = 'pages/fieldreport/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 Reports » {$formattedDay}";
     $sth = FieldReport::query(array('date_played' => sprintf('%d-%d-%d', $yyyy, $mm, $dd), '_order' => 'field_id ASC'));
     $reports = array();
     while ($r = $sth->fetchObject('FieldReport')) {
         $r->field = Field::load(array('fid' => $r->field_id));
         $reports[] = $r;
     }
     $this->smarty->assign('reports', $reports);
     return true;
 }
예제 #4
0
 function process()
 {
     $this->title = "Daily Schedule";
     list($year, $month, $day) = preg_split("/[\\/-]/", $_POST['edit']['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 .= " » {$formattedDay}";
     $this->template_name = 'pages/schedule/day.tpl';
     $sth = Game::query(array('game_date' => sprintf('%d-%d-%d', $yyyy, $mm, $dd), 'published' => true, '_order' => 'g.game_start, field_code'));
     while ($g = $sth->fetchObject('Game')) {
         if (!($g->published || $lr_session->has_permission('league', 'edit schedule', $this->league->league_id))) {
             continue;
         }
         $games[] = $g;
     }
     $this->smarty->assign('games', $games);
 }
예제 #5
0
function validate_yyyymmdd_input($date)
{
    list($year, $month, $day) = preg_split("/[\\/-]/", $date);
    return validate_date_input($year, $month, $day);
}
 function validate()
 {
     $errors = "";
     if (!validate_nonblank($this->payment_type)) {
         $errors .= "\n<li>Payment Type must be nonblank";
     }
     if (!validate_nonblank($this->payment_method)) {
         $errors .= "\n<li>Payment Method must be nonblank";
     }
     if (!preg_match("/^\\d+(?:\\.\\d\\d)?\$/", $this->payment_amount)) {
         $errors .= "\n<li>Amount must be nonblank and a valid dollar amount";
     }
     if (!validate_nonblank($this->date_paid)) {
         $errors .= "\n<li>Payment date must be nonblank";
     }
     list($yyyy, $mm, $dd) = preg_split("/[\\/-]/", $this->date_paid);
     if (!validate_date_input($yyyy, $mm, $dd)) {
         $errors .= "\n<li>Payment date must be valid";
     }
     return $errors;
 }
예제 #7
0
    function process()
    {
        global $dbh;
        $this->template_name = 'pages/league/slots.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 &raquo; {$this->league->fullname} &raquo; {$formattedDay}";
        $sth = $dbh->prepare('SELECT
			g.slot_id,
			COALESCE(f.code, pf.code) AS field_code,
			COALESCE(f.num, pf.num)   AS field_num,
			COALESCE(f.region, pf.region) AS field_region,
			g.fid,
			frh.rank AS home_site_rank,
			fra.rank AS away_site_rank,
			g.game_id

		FROM
			league_gameslot_availability l,
			gameslot g
				LEFT JOIN schedule s ON (g.game_id = s.game_id)
				LEFT JOIN team t ON (s.home_team = t.team_id)
				LEFT JOIN field_ranking_stats frh ON (s.game_id = frh.game_id AND frh.team_id = s.home_team)
				LEFT JOIN field_ranking_stats fra ON (s.game_id = fra.game_id AND fra.team_id = s.away_team),
			field f LEFT JOIN field pf ON (f.parent_fid = pf.fid)
		WHERE l.league_id = ?
			AND g.game_date = ?
			AND g.slot_id = l.slot_id
			AND f.fid = g.fid
			ORDER BY field_code, field_num');
        $sth->execute(array($this->league->league_id, sprintf('%d-%d-%d', $year, $month, $day)));
        $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;
        }
        $allDays = array('sunday' => 0, 'monday' => 1, 'tuesday' => 2, 'wednesday' => 3, 'thursday' => 4, 'friday' => 5, 'saturday' => 6);
        $day_indexes = array();
        $league_days = explode(',', $this->league->day);
        foreach ($league_days as $day) {
            $day_indexes[] = $allDays[strtolower($day)];
        }
        $this->smarty->assign('league_days', implode(',', $day_indexes));
        $this->smarty->assign('slots', $slots);
        $this->smarty->assign('num_fields', count($slots));
        $this->smarty->assign('num_open', $num_open);
        return true;
    }