-
Notifications
You must be signed in to change notification settings - Fork 2
/
enrolment.php
129 lines (104 loc) · 4.51 KB
/
enrolment.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
/*
Martial Arts Tournament System (MATS)
Copyright (C) 2015 David Ball (davidmichaelball @ gmail . com) and Ruth Schulz
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
require_once('../../tournament_settings.php');
require '../libs/Smarty.class.php';
$smarty = new Smarty;
require 'loginlogout.php';
require 'configDB.php';
require 'utility.php';
if (isset($_GET["SECTION"])) {
$section = $_GET["SECTION"];
if ($section == 0) {
$smarty->assign('SECTION', "All");
} else {
$sections = DB_DataObject::factory('sections');
$sections->tournament_id = $active_tournament->tournament_id;
$sections->section_id = $section;
$sections->find();
$sections->fetch();
$smarty->assign('SECTION', $sections->name);
}
} else {
$section = 0;
$smarty->assign('SECTION', "All");
}
$competitors = DB_DataObject::factory('competitors');
$competitors->whereAdd("tournament_id = ".$competitors->escape($active_tournament->tournament_id));
$represents = DB_DataObject::factory('represents');
$competitors->selectAs();
$competitors->joinAdd($represents, "INNER", 'represents', 'represents_id');
$competitors->selectAs($represents, 'represent_%s');
$ranks = DB_DataObject::factory('rank');
$competitors->joinAdd($ranks, "INNER", 'rank', 'rank_id');
$competitors->selectAs($ranks, 'rank_%s');
if (!isset($_SESSION['sort_direction'])) {
$_SESSION['sort_direction'] = "DESC";
}
$competitors->orderBy("last_name ASC");
$competitors->find();
while ($competitors->fetch()) {
// check if this competitor is in a division in this section
// not that unassigned competitors will not be shown unless section = 0
$competitor_in_section = 0;
if ($section != 0) {
$competitor_events = DB_DataObject::factory('competitor_events');
$competitor_events->competitor_id = $competitors->competitor_id;
$competitor_events->find();
while ($competitor_events->fetch() && !$competitor_in_section) {
$tournament_divisions = DB_DataObject::factory('divisions');
$tournament_divisions->tournament_id = $active_tournament->tournament_id;
$tournament_divisions->section_id = $section;
$tournament_divisions->division_id = $competitor_events->division_id;
if ($tournament_divisions->find()) {
$competitor_in_section = 1;
}
}
}
if ($competitor_in_section || $section == 0) {
$smarty->append('competitors', array(
'ID' => $competitors->competitor_id,
'TITLE' => $competitors->title,
'FIRST_NAME' => stripslashes($competitors->first_name),
'MIDDLE_NAME' => stripslashes($competitors->middle_name),
'LAST_NAME' => stripslashes($competitors->last_name),
'DOB' => $competitors->DOB,
'RANK' => $competitors->rank_name,
'REPRESENTS' => stripslashes($competitors->represent_name),
'WEIGHT' => $competitors->weight,
'HEIGHT' => $competitors->height,
'ADDRESS' => $competitors->address,
'PHONE' => $competitors->phone,
'GENDER' => $competitors->gender,
'COMMENTS' => $competitors->comments,
'RED_CARD' => $competitors->red_card,
'LAST_UPDATED' => $competitors->last_updated
));
$competitor_events = DB_DataObject::factory('competitor_events');
$competitor_events->competitor_id = $competitors->competitor_id;
$i = 0;
$events_array = array();
while (isset($active_tournament_events_id[$i])) {
$competitor_events_c = clone $competitor_events;
$competitor_events_c->whereAdd("competitor_events.event_id = ".$active_tournament_events_id[$i]);
$events_array[$i] = $competitor_events_c->find();
$i++;
}
$smarty->append('competitors_events', $events_array);
}
}
$smarty->assign('user_represents', $user_represents);
$smarty->display('enrolment.tpl');
?>