-
Notifications
You must be signed in to change notification settings - Fork 0
/
players.php
127 lines (116 loc) · 2.91 KB
/
players.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
<?php
require_once("crud.php");
class PlayerCrud extends Crud {
/* Post header event. */
public function postHeaderEvent() {
createDocumentLink();
}
public function postLoadScriptEvent() {
?>
$("#dob").removeClass("datepicker");
<?php
}
public function postScriptEvent() {
?>
var agegroup = 0;
$(document).ready(
function() {
$("#editform #dob").unbind("focus");
callAjax(
"finddata.php",
{
sql: "SELECT age FROM <?php echo $_SESSION['DB_PREFIX'];?>teamagegroup WHERE id = <?php echo $_GET['id']; ?>"
},
function(data) {
if (data.length == 1) {
agegroup = data[0].age;
}
},
false
);
}
);
function validatePlayerForm() {
if (parseFloat($("#registrationnumber").val().substring(0, 2)) != agegroup) {
pwAlert("Registration number does match the age group of under " + agegroup + "'s");
return false;
}
}
function editDocuments(node) {
viewDocument(node, "addplayerdocument.php", node, "playerdocs", "playerid");
}
<?php
}
}
$agegroupid = $_GET['id'];
$crud = new PlayerCrud();
$crud->dialogwidth = 450;
$crud->title = "Players";
$crud->allowFilter = false;
$crud->allowAdd = isUserInRole("TEAM");
$crud->allowEdit = isUserInRole("TEAM");
$crud->allowRemove = isUserInRole("TEAM");
$crud->validateForm = "validatePlayerForm";
$crud->table = "{$_SESSION['DB_PREFIX']}player";
$crud->sql = "SELECT A.*, B.name AS teamname, C.name AS clubname
FROM {$_SESSION['DB_PREFIX']}player A
INNER JOIN {$_SESSION['DB_PREFIX']}teamagegroup B
ON B.id = A.agegroupid
INNER JOIN {$_SESSION['DB_PREFIX']}team C
ON C.id = B.teamid
WHERE A.agegroupid = $agegroupid
ORDER BY A.firstname, A.lastname";
$crud->columns = array(
array(
'name' => 'id',
'viewname' => 'uniqueid',
'length' => 6,
'showInView' => false,
'filter' => false,
'bind' => false,
'editable' => false,
'pk' => true,
'label' => 'ID'
),
array(
'name' => 'agegroupid',
'datatype' => 'integer',
'length' => 6,
'showInView' => false,
'filter' => false,
'editable' => false,
'default' => $agegroupid,
'label' => 'Team'
),
array(
'name' => 'clubname',
'length' => 28,
'editable' => false,
'bind' => false,
'label' => 'Club'
),
array(
'name' => 'teamname',
'length' => 28,
'editable' => false,
'bind' => false,
'label' => 'Team'
),
array(
'name' => 'firstname',
'length' => 15,
'label' => 'First Name'
),
array(
'name' => 'lastname',
'length' => 15,
'label' => 'Last Name'
),
array(
'name' => 'registrationnumber',
'length' => 30,
'label' => 'Registration Number'
)
);
$crud->run();
?>