소스 검색

Update to orderpage, now allows people to attend events.

tags/rls1
kenn408k 6 년 전
부모
커밋
51b3676abb
4개의 변경된 파일101개의 추가작업 그리고 0개의 파일을 삭제
  1. 33
    0
      classes/alter.class.php
  2. 24
    0
      classes/get.class.php
  3. 2
    0
      content/eventadmin.php
  4. 42
    0
      content/order.php

+ 33
- 0
classes/alter.class.php 파일 보기

69
         die("Error, please enable browser redirects.");
69
         die("Error, please enable browser redirects.");
70
     }
70
     }
71
 
71
 
72
+    /* Attendee functions */
73
+
74
+    public static function attentAdd($user, $event) {
75
+        // Add user to an event. And sanitize as we only want numbers.
76
+
77
+
78
+        $event = filter_var(trim($event), FILTER_SANITIZE_NUMBER_INT);
79
+        if (Get::attentDouble($user, $event) != true) {
80
+            $db = new DBClass();
81
+            $time = new DateTime();
82
+            $sql = "INSERT INTO `attendees` (`id`, `eventid`, `userid`, `time`) VALUES (NULL, '$event', '$user', '" . $time->getTimestamp() . "');";
83
+            return $db->query($sql);
84
+        }
85
+        header('Location: ' . Config::$sys_url . '?page=order&error=1');
86
+        die("Error, please enable browser redirects.");
87
+    }
88
+    
89
+    public static function attentDel($user, $event) {
90
+        // Add user to an event. And sanitize as we only want numbers.
91
+
92
+
93
+        $event = filter_var(trim($event), FILTER_SANITIZE_NUMBER_INT);
94
+        if (Get::attentDouble($user, $event) != false) {
95
+            $db = new DBClass();
96
+            $sql = "DELETE FROM `attendees` WHERE `attendees`.`userid` = $user AND `eventid` = $event";
97
+            return $db->query($sql);
98
+        }
99
+        header('Location: ' . Config::$sys_url . '?page=order&error=2');
100
+        die("Error, please enable browser redirects.");
101
+    }
102
+
103
+    /* User functions */
104
+
72
     public static function addUser($username, $password, $realname, $mail, $level) {
105
     public static function addUser($username, $password, $realname, $mail, $level) {
73
         if (Get::checkExists($username)) { // check if user exists
106
         if (Get::checkExists($username)) { // check if user exists
74
             // ERROR USER EXISTS
107
             // ERROR USER EXISTS

+ 24
- 0
classes/get.class.php 파일 보기

91
         return $db->fetchAll($db->query($sql));
91
         return $db->fetchAll($db->query($sql));
92
     }
92
     }
93
     
93
     
94
+    /* Attend functions */
95
+
96
+    public static function attentEventList() {
97
+        // Get list of events that havent already started
98
+        $db = new DBClass();
99
+        $time = new DateTime();
100
+        $sql = "SELECT * FROM `events` WHERE `time` > ".$time->getTimestamp()." AND `type` = 1 ORDER BY `time` ASC";
101
+        return $db->fetchAll($db->query($sql));
102
+    }
103
+    
104
+    public static function attentDouble($user,$event) {
105
+        // Checks if username already is in db, if not return false, if it exists return true
106
+        $db = new DBClass();
107
+        $sql = "SELECT * FROM `attendees` WHERE `userid` = $user AND `eventid` = $event";
108
+        if ($db->numRows($db->query($sql)) != 1) { return false; } else { return true; }
109
+    }
110
+    
111
+    public static function attendees($event) {
112
+        // Checks if username already is in db, if not return false, if it exists return true
113
+        $db = new DBClass();
114
+        $sql = "SELECT * FROM `attendees` WHERE `eventid` = $event";
115
+        return $db->numRows($db->query($sql));
116
+    }
117
+    
94
     /* Login and user functions */
118
     /* Login and user functions */
95
 
119
 
96
     public static function checkExists($name) {
120
     public static function checkExists($name) {

+ 2
- 0
content/eventadmin.php 파일 보기

27
                 <th>ID</th>
27
                 <th>ID</th>
28
                 <th>Type</th>
28
                 <th>Type</th>
29
                 <th>Titel</th>
29
                 <th>Titel</th>
30
+                <th>Tilmeldte</th>
30
                 <th>Tidspunkt</th>
31
                 <th>Tidspunkt</th>
31
                 <th>Indstillinger</th>
32
                 <th>Indstillinger</th>
32
             </tr>
33
             </tr>
37
                     <td><?php echo $row['id']; ?></td>
38
                     <td><?php echo $row['id']; ?></td>
38
                     <td><?php if ($row['type'] == 1) {echo "Event";}else{echo "Aktivitet";} ?></td>
39
                     <td><?php if ($row['type'] == 1) {echo "Event";}else{echo "Aktivitet";} ?></td>
39
                     <td><?php echo $row['title']; ?></td>
40
                     <td><?php echo $row['title']; ?></td>
41
+                    <td><?php echo Get::attendees($row['id']); ?></td>
40
                     <td><?php echo date('H:i d/m-Y', $row['time']); ?></td>
42
                     <td><?php echo date('H:i d/m-Y', $row['time']); ?></td>
41
                     <td>
43
                     <td>
42
                         <a href="?page=editevent&id=<?php echo $row['id']; ?>"><button type="button" class="btn btn-primary"><i class="fa fa-pencil" title="Rediger artikel"></i></button></a>
44
                         <a href="?page=editevent&id=<?php echo $row['id']; ?>"><button type="button" class="btn btn-primary"><i class="fa fa-pencil" title="Rediger artikel"></i></button></a>

+ 42
- 0
content/order.php 파일 보기

5
 $setup['keywords'] = "bestil,bestilnu,betal,order";
5
 $setup['keywords'] = "bestil,bestilnu,betal,order";
6
 $setup['description'] = "Odense Track Bestillingsside";
6
 $setup['description'] = "Odense Track Bestillingsside";
7
 
7
 
8
+if (isset($_GET['rem'])) {
9
+    Alter::attentDel($_SESSION['user'],$_GET['rem']);
10
+    header('Location: '.Config::$sys_url.'?page=order&rel=success');
11
+    die();
12
+}
13
+
14
+if (isset($_GET['att'])) {
15
+    
16
+    Alter::attentAdd($_SESSION['user'],$_GET['att']);
17
+    
18
+    header('Location: '.Config::$sys_url.'?page=order&rel=success');
19
+    die();
20
+}
21
+
8
 Design::header($setup, 25);
22
 Design::header($setup, 25);
9
 ?>
23
 ?>
10
 
24
 
13
     <div class="border"></div>
27
     <div class="border"></div>
14
     <br />
28
     <br />
15
     <p>Bestil en billet til event.</p>
29
     <p>Bestil en billet til event.</p>
30
+    <?php
31
+    foreach (Get::attentEventList() as $row) {
32
+        ?>
33
+    
34
+        <div class="eventslice">
35
+        <div class="eventslice-top"><img src="<?php echo $row['img']; ?>" alt="" /></div>
36
+        <div class="eventslice-middle"><?php echo $row['title']; ?></div>
37
+        
38
+        <?php
39
+        if (Get::attentDouble($_SESSION['user'],$row['id']) == true){
40
+        ?>
41
+        <div class="eventslice-bottom"><a href="?page=order&rem=<?php echo $row['id']; ?>"><button>Afmeld</button></a></div>
42
+        <?php
43
+        } else {
44
+        ?>
45
+        <div class="eventslice-bottom"><a href="?page=order&att=<?php echo $row['id']; ?>"><button>Tilmeld</button></a></div>
46
+        <?php
47
+        }
48
+        ?>
49
+        
50
+        </div>
51
+        
52
+        
53
+        <?php
54
+    }
55
+    ?>
56
+    <div class="clear"></div>
57
+
16
 </div>
58
 </div>
17
 
59
 
18
 <?php
60
 <?php

Loading…
취소
저장