-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsange.php
413 lines (357 loc) · 18.7 KB
/
sange.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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
<?php
if (isset($_SESSION['logget_ind'])) {
$sTitle = isset($_POST['searchTitle']) ? $_POST['searchTitle'] : '';
$sText = isset($_POST['searchText']) ? $_POST['searchText'] : '';
$sAuthor = isset($_POST['searchAuthor']) ? $_POST['searchAuthor'] : '';
$sProTextOnly = isset($_POST['searchProTextOnly']) ? $_POST['searchProTextOnly'] : '';
if ($sTitle != "on" && $sText != "on" && $sAuthor != "on" && $sProTextOnly != "on") {
$sTitle = "on";
}
?>
<script>
function showall(nr)
{
shadowTable();
ajaxRequest('divSearchTable','Sange_ajax.php','showall='+nr);
}
function shadowTable()
{
if(document.getElementById('search_result_table_2') == null)
return;
var elm;
var target = document.getElementById('search_result_table_2');
try {
elm = document.createElement('<div id="divResultTableShadow" class="shadow" />');
}
catch (e) {
elm = document.createElement('div');
elm.setAttribute('id','divResultTableShadow');
elm.setAttribute('class', 'shadow');
}
elm.style.width = target.offsetWidth + 'px';
elm.style.height = target.offsetHeight + 'px';
elm.style.left = target.offsetLeft + 'px';
elm.style.top = target.offsetTop + 'px';
document.getElementById('divSearchTable').appendChild(elm);
elm.style.display = 'block';
}
function FavoriteSong(songid, mode)
{
ajaxRequest('favImg'+songid,'ajaxFunction.php', 'mode='+mode+'&sangid='+songid);
}
var t;
function findSong()
{
clearTimeout(t);
if(document.getElementById('textfield').value.length > 0)
t = setTimeout("findSongEx()",300);
else
document.getElementById('divSearchTable').innerHTML = "";
}
function findSongEx()
{
createShadow(document.getElementById('search_result_table_2'));
ajaxRequest('divSearchTable','Sange_ajax.php','textfield='+document.getElementById('textfield').value+
'&searchTitle='+(document.getElementById('searchTitle').checked == true?'on':'')+
'&searchText='+(document.getElementById('searchText').checked == true?'on':'')+
'&searchAuthor='+(document.getElementById('searchAuthor').checked == true?'on':'')+
'&searchProTextOnly='+(document.getElementById('searchProTextOnly').checked == true?'on':'')+
'&brugerid=<?php echo $_SESSION['brugerid']; ?>');
}
var divSetlist;
var divSetlistOpacity;
function addSong(sangid)
{
if(document.getElementById('setListId').value == "")
{
cancelHideSetlistMenu();
if(divSetlist == null)
divSetlist = document.getElementById('divSetlist');
divSetlist.style.left = (X+15) +'px';
divSetlist.style.top = Y + 'px';
if (divSetlist.addEventListener) {
divSetlist.addEventListener ("mouseout",hideSetlistMenuOut,false);
divSetlist.addEventListener ("mouseover",cancelHideSetlistMenu,false);
}
else if(divSetlist.attachEvent) {
divSetlist.attachEvent ("onmouseout",hideSetlistMenuOut);
divSetlist.attachEvent ("onmouseover",cancelHideSetlistMenu);
}
else {
divSetlist.onmouseout = hideSetlistMenuOut;
divSetlist.onmouseover = cancelHideSetlistMenu;
}
divSetlist.style.display = 'block';
createBackground(divSetlist);
ajaxRequest('divSetlist','program_ajax.php','sangid=' + sangid+'&mode=Setlist');
hideSetlistMenuOut();
}
else
ajaxRequest('addImg'+sangid,'program_ajax.php','sangid='+sangid+'&mode=add');
}
function removeSong(sangid)
{
ajaxRequest('addImg'+sangid,'program_ajax.php','sangid='+sangid+'&mode=remove');
}
function setSetlist(setlistid, sangid)
{
createShadow(divSetlist);
ajaxRequest('divSetListBar','program_ajax.php','setlist='+setlistid+'&sangid='+sangid);
}
function removeSetlist()
{
document.getElementById('setListId').value = "";
document.getElementById('divSetListBar').innerHTML = "";
ajaxRequest('','program_ajax.php','mode=removeSetlist');
}
function hideSetlistMenu()
{
divSetlist.style.display = 'none';
}
var timerSetlisteMenu
function hideSetlistMenuOut()
{
cancelHideSetlistMenu();
timerSetlisteMenu = setTimeout("hideSetlistMenu()",2000);
}
function cancelHideSetlistMenu()
{
clearTimeout(timerSetlisteMenu);
}
var X, Y;
function getMouseXY(e)
{
if (e.pageX || e.pageY) {
X = e.pageX;
Y = e.pageY;
}
else if (e.clientX || e.clientY) {
X = e.clientX + document.body.scrollLeft
+ document.documentElement.scrollLeft;
Y = e.clientY + document.body.scrollTop
+ document.documentElement.scrollTop;
}
}
if (document.addEventListener)
document.addEventListener ("mousemove",getMouseXY,false);
else if (document.attachEvent)
document.attachEvent ("onmousemove",getMouseXY);
else
document.onmouseout = getMouseXY;
</script>
<style type="text/css">
<!--
.style2 {font-style: italic}
.style3 {
font-size: 9px;
font-style: italic;
}
.divSetlist th
{
height: 21px;
text-align: center;
cursor: default;
}
.divSetlist td
{
cursor: pointer;
}
.divSetlist
{
width: 150px;
height: 150px;
position: absolute;
display: none;
border: 1px outset gray;
border-collapse: collapse;
}
.divSetlist table div
{
overflow-y: auto;
overflow-x: hidden;
height: 129px;
}
#divSetListStatusBar
{
height: 0px;
font-style: italic;
color: #666666;
font-size: 10px;
}
-->
</style>
<form id="form1" name="form1" method="post" action="main.php?page=sange&subpage=search">
<label>
<input name="textfield" id="textfield" type="text" class="textfield" value="<?php echo isset($_POST['textfield'])?$_POST['textfield']:""; ?>" onkeyup="findSong(this)" />
<script>document.getElementById('textfield').focus();</script>
</label>
<label>
<input class="submit_btn" type="submit" name="Submit" value="Søg" />
</label>
<br />
<span class="style2">
Søg i:
<input type="checkbox" name="searchTitle" id="searchTitle" onchange="findSong();" class="checkbox" <?php echo ($sTitle == "on" ? ' checked="true"' : ''); ?>>Titel
<input type="checkbox" name="searchAuthor" id="searchAuthor" onchange="findSong();" class="checkbox" <?php echo($sAuthor == "on" ? ' checked="true"' : ''); ?>>Forfatter
<input type="checkbox" name="searchText" id="searchText" onchange="findSong();" class="checkbox" <?php echo ($sText == "on" ? ' checked="true"' : ''); ?>>Tekst
<input type="checkbox" name="searchProTextOnly" id="searchProTextOnly" onchange="findSong();" class="checkbox" <?php echo ($sProTextOnly == "on" ? ' checked="true"' : ''); ?>>Søg kun i sange m. akkorder </span>
<p>
<table width="610px" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<button name="send" value="Vis alle sange" class="submit_btn4" onclick="showall(1);return false;"> Vis alle sange </button>
<button name="send" value="Vis alle sange m. akkorder" class="submit_btn5" onclick="showall(2);return false;"> Vis alle sange m. akkorder </button>
<button name="send" value="Vis mine favorit sange" class="submit_btn6" onclick="showall(4);return false;"> Vis mine favorit sange </button>
</td>
<td></td>
<td width="100" colspan="2">
<button name="send" onclick="var song_win=NewWindow('editSong.php?song=-1','song_win','yes');return false;" value="Tilføj ny sang" class="submit_btn7"> Tilføj ny sang </button>
</td>
</tr>
<tr>
<td>
<div id="divSetListBar">
<?php
if (isset($_SESSION['setlist']) && $_SESSION['setlist'] != NULL){
echo "Aktuel setliste: <a href=\"main.php?page=program&eventId=".$_SESSION['setlist']."\">".getProgramNavn($_SESSION['setlist'])."</a> <a href=\"javascript:removeSetlist();\">fjern</a>";
}
?>
</div>
<input id="setListId" type="hidden" value="<?php echo $_SESSION['setlist']?>" />
<div id="divSetListStatusBar"></div>
</td>
<td>
</td>
<td width="16">
<p><img src="img/important.png" alt="NB!" /> </p></td>
<td width="84" valign="middle"><span class="style3">Husk at sikre dig at sangen ikke allerede findes i systemet!</span></td>
</tr>
</table>
</p>
<p>
</p>
</form>
<div id="divSetlist" class="divSetlist"></div>
<div id="divSetlistOpacity" class="divSetlistOpacity"></div>
<div id="divSearchTable">
<?php
// If a search text has been entered then do a search
if (isset($_POST['textfield']) && $_POST['textfield'] != '' || isset($_GET['showall']) && $_GET['showall'] > 0) {
?>
<table id="search_result_table_2" cellspacing="0" cellpadding="3">
<tr>
<td height="15" background="img/tabletop_bg.gif"><div align="center"><strong>Titel</strong></div></td>
<td height="15" background="img/tabletop_bg.gif"><div align="center"><strong>Forfatter</strong></div></td>
<!--<td height="15" background="img/tabletop_bg.gif"><div align="center"><strong>Sprog</strong></div></td>-->
<td height="15" background="img/tabletop_bg.gif"><div align="center"><strong>Udgave</strong></div></td>
<td height="15" background="img/tabletop_bg.gif"><div align="center"></div></td>
<td width="80" height="15" background="img/tabletop_bg.gif"><div align="center"><strong>Sidst spillet d</strong></div></td>
<td height="15" background="img/tabletop_bg.gif"><div align="center"><strong>Favorit</strong></div></td>
<td height="15" background="img/tabletop_bg.gif"><div align="center"><strong>Lyt</strong></div></td>
<td height="15" background="img/tabletop_bg.gif"><div align="center"><strong>Tilføj</strong></div></td>
</tr>
<?php
// Show all songs, or do a search
if (isset($_GET['showall']) && $_GET['showall'] > 0) {
if ($_GET['showall'] == 2) {
$query = "SELECT DISTINCT Sang.SangId,Sang.Titel,Sang.Identifikation,Sang.Udgave, sb.BrugerId,Sang.Lydfil FROM (Sang LEFT OUTER JOIN Slide2 ON Sang.SangID = Slide2.SangID) LEFT JOIN (SELECT * FROM SangBruger WHERE BrugerId = ".$_SESSION['brugerid'].") sb ON sb.SangId = Sang.SangId WHERE " . CreateLikeClause("Sang.ProTekst", "]") . " ORDER BY Sang.Titel";
}
elseif ($_GET['showall'] == 3) {
$query = "SELECT TOP 10 Sang.SangId,Sang.Titel,Sang.Identifikation,Sang.Udgave, sb.BrugerId, Sang.Lydfil, Count(Sang.SangID) AS SongCount
FROM ((Sang
INNER JOIN ProgramPunkt ON Sang.SangId = ProgramPunkt.SangID)
INNER JOIN Program ON Program.ProgramID = ProgramPunkt.ProgramID)
LEFT JOIN (SELECT * FROM SangBruger WHERE BrugerId = ".$_SESSION['brugerid'].") sb ON sb.SangId = Sang.SangId
WHERE DateDiff('d', Program.Dato, '$curyear-$curmonth-$today') < 365
GROUP BY Sang.SangId,Sang.Titel,Sang.Identifikation,Sang.Udgave,Sang.Lydfil, sb.BrugerId
ORDER BY Count(Sang.SangID) DESC ";
}
elseif ($_GET['showall']==4) {
$query = "SELECT DISTINCT Sang.SangId,Sang.Titel,Sang.Identifikation,Sang.Udgave, sb.BrugerId,Sang.Lydfil FROM Sang INNER JOIN SangBruger sb ON sb.SangId = Sang.SangId WHERE sb.BrugerId = ".$_SESSION['brugerid']." ORDER BY Sang.Titel";
}
else {
$query = "SELECT DISTINCT Sang.SangId,Sang.Titel,Sang.Identifikation,Sang.Udgave,sb.BrugerId,Sang.Lydfil FROM (Sang LEFT OUTER JOIN Slide2 ON Sang.SangID = Slide2.SangID) LEFT JOIN (SELECT * FROM SangBruger WHERE BrugerId = ".$_SESSION['brugerid'].") sb ON sb.SangId = Sang.SangId ORDER BY Sang.Titel";
}
} else {
// Do the database search and list the result
$strSearchIn = "";
if ($sTitle == "on") {
$strSearchIn .= CreateLikeClause("Sang.Titel", $_POST['textfield']);
}
if ($sAuthor == "on") {
if ($strSearchIn != "") {
$strSearchIn .= " OR ";
}
$strSearchIn .= CreateLikeClause("Sang.Identifikation", $_POST['textfield']);
}
if ($sText == "on") {
if ($strSearchIn != "") {
$strSearchIn .= " OR ";
}
$strSearchIn .= CreateLikeClause("Sang.ProTekst", $_POST['textfield']);
$strSearchIn .= " OR ";
$strSearchIn .= CreateLikeClause("Slide2.Slidetekst", $_POST['textfield']);
}
if ($sProTextOnly == "on") {
if ($strSearchIn != "") {
$strSearchIn = "(".$strSearchIn .") AND ";
}
$strSearchIn .= CreateLikeClause("Sang.ProTekst", "]");
}
$query = "SELECT DISTINCT Sang.SangId,Sang.Titel,Sang.Identifikation,Sang.Udgave,sb.BrugerId,Sang.Lydfil FROM (Sang LEFT OUTER JOIN Slide2 ON Sang.SangID = Slide2.SangID) LEFT JOIN (SELECT * FROM SangBruger WHERE BrugerId = ".$_SESSION['brugerid'].") sb ON sb.SangId = Sang.SangId WHERE " . $strSearchIn . " ORDER BY Sang.Titel";
}
$result = doSQLQuery($query);
$colour = "";
while ($line = db_fetch_array($result)) {
$songid = stripslashes($line["SangId"]);
$title = $line["Titel"];
echo " <tr".$colour.">\n";
echo " <td><a href=\"editSong.php?song=".$songid."\" onclick=\"NewWindow(this.href,'song_win','yes');return false;\">".$title."</a></td>\n"; // Title
echo " <td align=\"center\">".stripslashes($line["Identifikation"])."</td>\n"; // Author
//echo " <td".$colour."><div align=\"center\"> </td>\n"; // Language
echo " <td align=\"center\">".stripslashes($line["Udgave"])."</td>\n"; // Edition
echo " <td align=\"center\"> </td>\n"; // Toneart
// Find the last date the song was used
$lastQuery = "SELECT Program.Dato FROM Program LEFT OUTER JOIN ProgramPunkt ON Program.ProgramID = ProgramPunkt.ProgramID WHERE ProgramPunkt.SangID =".$songid." ORDER BY Program.Dato DESC";
$lastResult = doSQLQuery($lastQuery);
if ($lastLine = db_fetch_array($lastResult)) {
$tmp = $lastLine["Dato"];
$date = substr($tmp,8,2)."/".substr($tmp,5,2)."/".substr($tmp,2,2);
} else {
$date = "";
}
echo " <td align=\"center\">".$date."</td>\n"; // Last played on
echo "<td align=\"center\" id=\"favImg".$songid."\"><img style=\"cursor: pointer;\" alt=\"Fjern favorit\" width=\"16\" height=\"16\"";
$fav = $line["BrugerId"];
if($fav != "")
echo " src=\"img/favorit_checked.png\" onclick=\"FavoriteSong(".$songid.",'removeFavorite');\" />";
else
echo " src=\"img/favorit_unchecked.png\" onclick=\"FavoriteSong(".$songid.",'addFavorite');\" />";
echo "</td>";
$audioFile = $line["Lydfil"];
if ($audioFile != '') {
echo " <td align=\"center\"><a href=\"".$audioFile."\" target=\"_blank\"><img src=\"img/mp3.gif\" alt=\"Lyt\" width=\"16\" height=\"16\" border=\"0\" /></a></div></td>\n"; // Link or audio file
} else {
echo " <td align=\"center\"> </td>\n"; // Link or audio file
}
// Tilføj sang til setlist
if (isset($_SESSION['setlist']) && isSongInProgram($songid, $_SESSION['setlist']))
echo " <td id=\"addImg".$songid."\" align=\"center\"><img src=\"img/list-minus.gif\" alt=\"Fjern sang\" width=\"14\" height=\"14\" border=\"0\" style=\"cursor: pointer;\" align=\"top\" onclick=\"removeSong(".$songid.")\" /></td>\n"; // Remove
else
echo " <td id=\"addImg".$songid."\" align=\"center\"><img src=\"img/list-add.gif\" alt=\"Tilføj sang\" width=\"14\" height=\"14\" border=\"0\" style=\"cursor: pointer;\" align=\"top\" onclick=\"addSong(".$songid.")\" /></td>\n"; // Add
echo " </tr>\n";
if ($colour == "") {
$colour = " bgcolor=\"#f2f2f2\"";
} else {
$colour = "";
}
}
?>
</table>
<p>
<?php
} // Search
echo "</div>";
} // Session
?>
</p>