forked from svenMolhuijsen/EenmaalAndermaal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofiel.php
238 lines (207 loc) · 11.3 KB
/
profiel.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<?php
include("php/core.php");
include("php/layout/header.php");
$pagename = 'Profiel';
include("php/layout/breadcrumbs.php");
error_reporting(E_ERROR | E_PARSE);
$gebruiker = new User($_SESSION['gebruiker']);
$verlopenBiedingen = executeQuery("SELECT * from veiling v, biedingen b where gebruikersnaam = ? and v.veilingid = b.veilingid AND veilingGestopt = 0 AND biedingsBedrag NOT IN(SELECT MAX(biedingsBedrag) AS 'Hoogste bod' FROM biedingen GROUP BY veilingId)", [$gebruiker->getGebruikersnaam()]);
$lopendeBiedingen = executeQuery("SELECT * from veiling v, biedingen b where gebruikersnaam = ? and v.veilingid = b.veilingid AND veilingGestopt = 0 AND b.biedingsBedrag IN(SELECT MAX(biedingsBedrag) AS 'Hoogste bod' FROM biedingen GROUP BY veilingId)", [$gebruiker->getGebruikersnaam()]);
$gewonnenBiedingen = executeQuery("SELECT * from veiling v, biedingen b where gebruikersnaam = ? and v.veilingid = b.veilingid AND veilingGestopt = 1 AND b.biedingsBedrag IN(SELECT MAX(biedingsBedrag) AS 'Hoogste bod' FROM biedingen GROUP BY veilingId)", [$gebruiker->getGebruikersnaam()]);
$openVeilingen = executeQuery("SELECT * FROM veiling WHERE verkoperGebruikersnaam = ? AND veilingGestopt = 0", [$gebruiker->getGebruikersnaam()]);
$verlopenVeilingen = executeQuery("SELECT * from veiling where verkoperGebruikersnaam = ? AND veilingGestopt = 1", [$gebruiker->getGebruikersnaam()]);
function pasteStatus($typeStatus, $soort) {
if (count($typeStatus['data']) > 0) {
foreach ($typeStatus['data'] as $status) {
echo('
<div class="column"><hr></div>
<div class="columns small-3">
<img src="http://iproject34.icasites.nl/' . $status["thumbNail"] . '" alt="image">
</div>
<div class="columns small-5">
<p><strong>Titel: </strong>' . $status["titel"] . '</p>
');
if ($soort == 1) {
echo('<p><strong> Verkoper: </strong> ' . $status["verkoperGebruikersnaam"] . '</p >');
} elseif ($soort == 3) {
echo('<p><strong>Beëindigd op: </strong>'.$status["eindDatum"].'</p>');
}
echo('</div><div class="columns small-4">');
if ($soort == 1) {
echo('<p><strong>Bedrag: </strong>' . $status['biedingsBedrag'] . '</p>');
} elseif ($soort == 2) {
echo('<p><strong>Huidige bod: </strong>' . $status["startPrijs"] . '</p>');
} elseif ($soort == 3) {
echo('<p><strong>Verkocht voor: </strong>'.$status["verkoopPrijs"].'</p><p><strong>Gekocht door: </strong>'.$status["koperGebruikersnaam"].'</p>');
}
echo('</div>');
}
} else {
echo('<div class="column"><hr><p><strong>Niets gevonden</strong></p></div>');
}
}
if (!isset($_SESSION['gebruiker'])) {
include("php/layout/geentoegang.html");
} else {
?>
<main class="row profiel">
<ul class="tabs" id="profieltabs" data-tabs>
<li class="tabs-title is-active"><a href="#overzicht">Account instellingen</a></li>
<li class="tabs-title"><a href="#biedingen">Mijn biedingen</a></li>
<li class="tabs-title"><a href="#advertenties">Mijn advertenties</a></li>
</ul>
<div class="tabs-content" data-tabs-content="profieltabs" data-active-collapse="true">
<div class="tabs-panel" id="overzicht">
<form id="profielForm">
<div class="row small-up-1 large-up-2">
<div class="columns small-6">
<fieldset class="fieldset">
<legend><h5>Gebruikersnaam en wachtwoord</h5></legend>
<button id="showInlogGegevens" type="button" class="tiny button hollow">Edit</button>
<?php
echo('<p id="gebruikersnaam"><strong>Gebruikersnaam: </strong>' . $gebruiker->getGebruikersnaam() . '</p>');
?>
<p id="wachtwoord"><strong>Wachtwoord: </strong>********</p>
<div class="field editInlogGegevens">
<input id="oudWachtwoord" type="password" pattern="^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\s).*$" maxlength="255" placeholder="Old Password">
<input id="editWachtwoord" maxlength="255" pattern="^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\s).*$" type="password" placeholder="New Password">
</div>
</fieldset>
</div>
<div class="columns small-6">
<fieldset class="fieldset">
<legend><h5>Naam en geboortedatum</h5></legend>
<?php echo('<p id="Naam"><strong>Naam: </strong>' . $gebruiker->getVoornaam() . ' ' . $gebruiker->getAchternaam() . '</p>'); ?>
<?php echo('<p id="Geboortedatum"><strong>Geboortedatum: </strong>' . $gebruiker->getGeboortedatum() . '</p>'); ?>
</fieldset>
</div>
</div>
<div class="row small-up-1 large-up-2">
<div class="columns small-6">
<fieldset class="fieldset">
<legend><h5>Adres</h5></legend>
<button id="showAdres" type="button" class="button tiny hollow">Edit</button>
<?php
echo('<p id="Provincie"><strong>Provincie: </strong>' . $gebruiker->getProvincie() . '</p>');
echo('<p id="Plaats"><strong>Plaats: </strong>' . $gebruiker->getPlaatsnaam() . '</p>');
echo('<p id="Straat"><strong>Straat: </strong>' . $gebruiker->getStraatnaam() . '</p>');
echo('<p id="Huisnummer"><strong>Huisnummer: </strong>' . $gebruiker->getHuisnummer() . '</p>');
echo('<p id="Postcode"><strong>Postcode: </strong>' . $gebruiker->getPostcode() . '</p>');
?>
<div class="field editAdres">
<input rel="Provincie" maxlength="255" id="editProvincie" type="text" placeholder="Provincie" pattern="[A-Za-z-' ]+">
<input rel="Plaats" maxlength="255" id="editPlaats" type="text" placeholder="Plaats" pattern="[a-zA-Z-' ]+">
<input rel="Straat" maxlength="255" id="editStraat" type="text" placeholder="Straat" pattern="[A-Za-z-' ]+">
<input rel="Huisnummer" maxlength="20" id="editHuisnummer" type="text" placeholder="Huisnummer" pattern="[0-9a-z]+">
<input rel="Postcode" id="editPostcode" maxlength="10" type="text" placeholder="Postcode" pattern="^[1-9][0-9]*[a-zA-z- ]*"">
</div>
</fieldset>
</div>
<div class="columns small-6">
<fieldset class="fieldset">
<legend><h5>Jouw contactgegevens</h5></legend>
<button id="showContactgegevens" type="button" class="button hollow tiny">Edit</button>
<?php echo('<p id="Telefoonnummer"><strong>Telefoonnummer: </strong>' . $gebruiker->getTelefoonnmr() . '</p>'); ?>
<input rel="Telefoonnummer" maxlength="20" class="field editContactgegevens" id="editTelefoonnummer"
type="text" placeholder="Telefoonnmr" pattern="^\+?[0-9() ]+">
</fieldset>
</div>
</div>
<hr>
<input type="submit" id="submitChanges" value="Submit" class="button large">
</form>
</div>
<div class="tabs-panel" id="biedingen">
<div class="row column">
<h4>Lopende biedingen</h4>
</div>
<div class="noMarginRow row">
<?php pasteStatus($lopendeBiedingen, 1); ?>
</div>
<div class="row column">
<h4>Verlopen biedingen</h4>
</div>
<div class="row noMarginRow">
<?php pasteStatus($verlopenBiedingen, 1); ?>
</div>
<div class="row column">
<h4>Gewonnen biedingen</h4>
</div>
<div class="noMarginRow row">
<?php pasteStatus($gewonnenBiedingen, 1); ?>
</div>
</div>
<div class="tabs-panel" id="advertenties">
<div class="row column">
<h4>Actieve advertenties</h4>
</div>
<div class="noMarginRow row">
<?php pasteStatus($openVeilingen, 2); ?>
</div>
<div class="row column">
<h4>Inactieve advertenties</h4>
</div>
<div class="noMarginRow row">
<?php pasteStatus($verlopenVeilingen, 3) ?>
</div>
</div>
</div>
</main>
<?php
}
include("php/layout/footer.html");
?>
<script>
$(document).ready(function() {
var errorCSS = {
"font-size": "70%",
"margin-bottom": "0",
"bottom": "0",
"right": "0"
};
$('#profielForm').validate({
submitHandler: function(){submitChanges()},
errorPlacement: function(error, element) {
error.insertBefore(element);
error.addClass("hide-for-small show-for-large");
error.css(errorCSS);
}
});
$('#showInlogGegevens').click(function () {
$('.editInlogGegevens').toggle(300);
});
$('#showAdres').click(function () {
$('.editAdres').toggle(300);
});
$('#showContactgegevens').click(function () {
$('.editContactgegevens').toggle(300);
});
function submitChanges() {
var userInfo = {
OLDpassword: $('#oudWachtwoord').val(),
NEWpassword: $('#editWachtwoord').val(),
NEWprovincie: $('#editProvincie').val(),
NEWplaats: $('#editPlaats').val(),
NEWstraat: $('#editStraat').val(),
NEWhuisnummer: $('#editHuisnummer').val(),
NEWtelefoonnummer: $('#editTelefoonnummer').val(),
NEWpostcode: $('#editPostcode').val(),
};
$.ajax({
type: 'POST',
url: 'php/securedApi.php?action=aanpassenGegevens',
data: userInfo,
success: function () {
alert("Je gegevens zijn succesvol verandert");
$.each($('#overzicht').find('input'), function () {
if ($(this).val() != "") {
$('#overzicht').find('p[id="' + $(this).attr('rel') + '"]').html('<p><strong>' + $(this).attr('rel') + ': </strong>' + $(this).val() + '</p>');
}
});
}
});
}
});
</script>
</body>
</html>