-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreation-competition.php
More file actions
148 lines (103 loc) · 5.33 KB
/
Copy pathcreation-competition.php
File metadata and controls
148 lines (103 loc) · 5.33 KB
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
$title="Creazione Competizione";
include('header.php');
if($username!=null){
if($userAuth==1){
$name="";
$first_round=0;
$num_rounds=0;
if(isset($_POST['created']) && isset($_POST['users'])){
$users=$_POST['users'];
$rounds=null;
$name=$_POST['name'];
$first_round=$_POST['first_round'];
$num_rounds=$_POST['num_rounds'];
$type = $_POST['type'];
$arr_data = array("name" => $name , "first_round" => $first_round , "num_rounds" => $num_rounds , "type" => $type);
$params = array('postParams' => $arr_data);
$json=$apiAccess->accessApi("/competitions","POST",$params);
$id = null;
if($json["error"]==true){
var_dump($json);
}else{
$id = $json["data"];
var_dump($id);
}
if($id!=null && isset($_SESSION['rounds'])) {
$rounds=$_SESSION['rounds'];
$arr_data = array("id" => $id , "name" => $name , "first_round" => $first_round , "num_rounds" => $num_rounds ,"users" => $users , "rounds" => $rounds);
$params = array('postParams' => $arr_data);
$json=$apiAccess->accessApi("/competitions/$id","PUT",$params);
if($json["error"]==true){
var_dump($json);
}else{
var_dump($json);
}
unset($_SESSION['rounds']);
}
//header("Location:settings-competitions.php");
}else if(isset($_POST['name']) && isset($_POST['first_round']) && isset($_POST['num_rounds']) && isset($_POST['rounds'])){
$name=$_POST['name'];
$first_round=$_POST['first_round'];
$num_rounds=$_POST['num_rounds'];
//$id=$database->createCompetition($name,$first_round,$num_rounds);
$rounds=$_POST['rounds'];
$type = $_POST['type'];
//$database->setRoundsCompetition($id,$rounds);
$_SESSION['rounds']=$rounds;
$users = array();
$json=$apiAccess->accessApi("/users","GET");
if($json["error"]==true){
var_dump($json);
}else{
$users = $json["data"];
}
?>
<div class="main competition_creation">
<div class="half_size">
<h3>Partecipanti</h3>
<div id="number_users_selected">0</div>
</div>
<form class="half_size" action="creation-competition.php" method="post">
<input class="setting_item_input" type="hidden" name="name" class="market-select" <?php echo "value=\"".$name."\" "; ?> >
<input class="setting_item_input" type="hidden" name="first_round" class="market-select" <?php echo "value=\"".$first_round."\" "; ?> readonly="readonly">
<input class="setting_item_input" type="hidden" name="num_rounds" class="market-select" <?php echo "value=\"".$num_rounds."\" "; ?> readonly="readonly">
<input class="setting_item_input" type="hidden" name="type" class="market-select" <?php echo "value=\"".$type."\" "; ?> readonly="readonly">
<div id="users">
<div id="search_box">
<div id="search_element">
<input class="search" id="search-element" placeholder="Cerca">
</div>
</div>
<input type="button" id="select_all" value="Seleziona Tutti" />
<input type="button" id="deselect_all" value="Deseleziona Tutti" />
<ul class="list">
<?php foreach($users as $team){ ?>
<li class="squaredFour">
<input type="checkbox" class="select_teams" <?php echo "value=\"".$team["id"]."\""; ?> name="users[]">
<label for="squaredFour"></label>
<div class="user_name"><?php echo $team["name_team"]; ?></div>
</li>
<?php } ?>
</ul>
</div>
<input class="setting_item_input" name="created" type="submit" value="Crea" >
</form>
</div>
<?php
}else{
header("Location:settings-competitions.php");
}
}else{
$_SESSION['old_url']=$_SERVER['REQUEST_URI'];
header("Location:login.php");
} // FINE SE ADMIN
} // FINE USERNAME GET
?>
<script>
count_check();
$("body").on('change', 'input[type="checkbox"]', count_check);
$("body").on('click', '#select_all', select_all_teams);
$("body").on('click', '#deselect_all', deselect_all_teams);
</script>
<?php include('footer.php'); ?>