/extremedating/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/extremedating/trunk
54 by Daniel Johansson
Forgot some stuffz
1
<?PHP
2
	$lunchSuggestionArray = $db->query("SELECT user2 from planLunch WHERE user1='$username'");
3
	$lunchSuggestionQuery = $lunchSuggestionArray->fetchAll();
4
	foreach ($lunchSuggestionQuery as $lunchSuggestion) {
5
		$userinfo = $db->query("SELECT firstName from Users WHERE loginName='$lunchSuggestion[0]'");
6
		$self = $userinfo->fetchAll();
7
		$firstName = $self [0]['firstName'];
8
		$userinfo = $db->query("SELECT surName from Users WHERE loginName='$lunchSuggestion[0]'");
9
		$self = $userinfo->fetchAll();
10
		$surName = $self [0]['surName'];
11
		
12
		$userinfo = $db->query("SELECT date from planLunch WHERE user1='$username' AND user2='$lunchSuggestion[0]'");
13
		$self = $userinfo->fetchAll();
14
		$datetime = $self [0]['date'];
15
		$userinfo = $db->query("SELECT message from planLunch WHERE user1='$username' AND user2='$lunchSuggestion[0]'");
16
		$self = $userinfo->fetchAll();
17
		$message = $self [0]['message'];
18
		$userinfo = $db->query("SELECT accepted from planLunch WHERE user1='$username' AND user2='$lunchSuggestion[0]'");
19
		$self = $userinfo->fetchAll();
20
		$accepted = $self [0]['accepted'];
21
		if ($accepted=='true') {
59.1.1 by Gustav Hatvigsson
cleaning up codeC
22
      ?>
23
			<div class="dinnerwraps">
24
			<p>Du har bokat lunch med <?php echo $firstName; ?> <?php echo $surName; ?> den <?php echo $datetime; ?> </p>
25
			<p> <?php echo $message; ?></p>
63 by Gustav Hatvigsson
made it posible to remove dates
26
      <form method="post" action="./removedate.php">
27
        <input type="hidden" name="user1remove" id="user1remove" value="<?php echo $lunchSuggestion[0]; ?>" />
65 by Gustav Hatvigsson
made it possible to decline and accept dates
28
        <input type="hidden" name="user2remove" id="user2remove" value="<?php echo $_SESSION['userName']; ?>" />
63 by Gustav Hatvigsson
made it posible to remove dates
29
        <button id="remove" name="remove" value="remove">remove</button>
30
      </form>
59.1.1 by Gustav Hatvigsson
cleaning up codeC
31
			</div>
32
      <?php
54 by Daniel Johansson
Forgot some stuffz
33
		} else {
59.1.1 by Gustav Hatvigsson
cleaning up codeC
34
      ?>
35
			<div class="dinnerwraps">
36
			<p>Du har föreslagit lunch med <?php echo $firstName; ?> <?php echo $surName; ?> den <?php echo $datetime; ?> </p>
37
			<p> <?php echo $message; ?></p>
63 by Gustav Hatvigsson
made it posible to remove dates
38
      <form method="post" action="./removedate.php">
39
        <input type="hidden" name="user1remove" id="user1remove" value="<?php echo $lunchSuggestion[0]; ?>" />
65 by Gustav Hatvigsson
made it possible to decline and accept dates
40
        <input type="hidden" name="user2remove" id="user2remove" value="<?php echo $_SESSION['userName'];  ?>" />
63 by Gustav Hatvigsson
made it posible to remove dates
41
        <button id="remove" name="remove" value="remove">remove</button>
42
      </form>
43
			</div>
59.1.1 by Gustav Hatvigsson
cleaning up codeC
44
      <?php
54 by Daniel Johansson
Forgot some stuffz
45
		}
46
	}
47
	$lunchAcceptionArray = $db->query("SELECT user1 from planLunch WHERE user2='$username'");
48
	$lunchAcceptionQuery = $lunchAcceptionArray->fetchAll();
49
	foreach ($lunchAcceptionQuery as $lunchAcception) {
50
		$userinfo = $db->query("SELECT firstName from Users WHERE loginName='$lunchAcception[0]'");
51
		$self = $userinfo->fetchAll();
52
		$firstName = $self [0]['firstName'];
53
		$userinfo = $db->query("SELECT surName from Users WHERE loginName='$lunchAcception[0]'");
54
		$self = $userinfo->fetchAll();
55
		$surName = $self [0]['surName'];
56
		
57
		$userinfo = $db->query("SELECT date from planLunch WHERE user2='$username' AND user1='$lunchAcception[0]'");
58
		$self = $userinfo->fetchAll();
59
		$datetime = $self [0]['date'];
60
		$userinfo = $db->query("SELECT message from planLunch WHERE user2='$username' AND user1='$lunchAcception[0]'");
61
		$self = $userinfo->fetchAll();
62
		$message = $self [0]['message'];
63
		$userinfo = $db->query("SELECT accepted from planLunch WHERE user2='$username' AND user1='$lunchAcception[0]'");
64
		$self = $userinfo->fetchAll();
65
		$accepted = $self [0]['accepted'];
66
		if ($accepted=='true') {
59.1.1 by Gustav Hatvigsson
cleaning up codeC
67
      ?>
68
			<div class="dinnerwraps">
69
			<p>Du har bokat lunch med ' <?php echo $firstName; ?>  <?php echo $surName; ?>  den <?php echo $datetime; ?> </p>
70
			<p><?php echo $message; ?>  </p>
65 by Gustav Hatvigsson
made it possible to decline and accept dates
71
      <table>
72
      <tr>
73
      <td>
74
      <form method="post" action="./removedate.php">
75
        <input type="hidden" name="user1remove" id="user1remove" value="<?php echo $lunchAcception[0]; ?>" />
76
        <input type="hidden" name="user2remove" id="user2remove" value="<?php echo $_SESSION['userName']; ?>" />
77
        <button id="remove" name="remove" value="remove">remove</button>
78
      </form>
79
      </td>
80
      <td>
81
			<form method="POST" action="./declinedate.php">
82
			<input type="hidden" name="otherUser" value="<?php echo $lunchAcception[0]; ?>"/>
83
			<input type="hidden" name="user" value="<?php echo $_SESSION['userName']; ?>"/>
84
      <input type="hidden" name="DeclineLunch" value="DeclineLunch" />
59.1.1 by Gustav Hatvigsson
cleaning up codeC
85
			<button type="Submit" name="AcceptLunch">Avboka</button>
65 by Gustav Hatvigsson
made it possible to decline and accept dates
86
			</form>
87
      </td>
88
      </tr>
89
      </table>
90
			</div>
59.1.1 by Gustav Hatvigsson
cleaning up codeC
91
			<?php
65 by Gustav Hatvigsson
made it possible to decline and accept dates
92
			/*if (isset($_POST['user1_2'])) {
54 by Daniel Johansson
Forgot some stuffz
93
				$luncharray = $db->query("SELECT accepted from planLunch WHERE(user2='$username' AND user1='{$_POST['user1_2']}')");
94
				$lunchinfo = $luncharray->fetchAll();
95
				$lunchquery = $lunchinfo[0];
96
				if($lunchquery[0] == 'true') {
97
					$db->exec("UPDATE planLunch SET accepted='false' WHERE(user2='$username' AND user1='{$_POST['user1_2']}')");
58 by Daniel Johansson
Beauty stuff
98
					header("Location:profile.php?uid=" . $_POST['user1_2']);
54 by Daniel Johansson
Forgot some stuffz
99
				}
65 by Gustav Hatvigsson
made it possible to decline and accept dates
100
			}*/
54 by Daniel Johansson
Forgot some stuffz
101
			
102
		} else {
59.1.1 by Gustav Hatvigsson
cleaning up codeC
103
      ?>
104
			<div class="dinnerwraps">
105
			<p> <?php echo $firstName; ?> <?php echo $surName; ?> har föreslagit lunch med dig den <?php echo $datetime; ?></p>
106
			<p> <?php $message ?> </p>
65 by Gustav Hatvigsson
made it possible to decline and accept dates
107
      <table>
108
      <tr>
109
      <td>
110
			<form method="POST" action="./acceptdate.php">
111
        <input type="hidden" name="AcceptLunch" value="AcceptLunch" />
112
			  <input type="hidden" name="user" value="<?php echo $_SESSION['userName']; ?>"/>
113
			  <input type="hidden" name="otherUser" value="<?php echo $lunchAcception[0]; ?>"/>
59.1.1 by Gustav Hatvigsson
cleaning up codeC
114
      <button type="Submit" name="AcceptLunch">Acceptera</button>
65 by Gustav Hatvigsson
made it possible to decline and accept dates
115
			</form>
116
      </td>
117
      <td>
118
      <form method="post" action="./removedate.php">
119
        <input type="hidden" name="user1remove" id="user1remove" value="<?php echo $_SESSION['userName']; ?>" />
120
        <input type="hidden" name="user2remove" id="user2remove" value="<?php echo $lunchAcception[0]; ?>" />
121
        <button id="remove" name="remove" value="remove">remove</button>
122
      </form>
123
      </td>
124
      </tr>
125
      </table>
126
			</div>
59.1.1 by Gustav Hatvigsson
cleaning up codeC
127
      <?php
54 by Daniel Johansson
Forgot some stuffz
128
		}
129
	}
59.1.1 by Gustav Hatvigsson
cleaning up codeC
130
?>