<?
if (!isset($frame)) {
if (isset($newrecord)) $newrecord = "&newrecord&performer=$performer&title=$title";
else $newrecord = '';
print "
<FRAMESET ROWS='55,*' BORDER=0>
<FRAME NAME=title SRC='nexus.php?frame=0&album_id=$album_id$newrecord'>
<FRAMESET COLS='*,320' BORDER=1>
<FRAME NAME=names SRC='nexus.php?frame=1&album_id=$album_id'>
<FRAME NAME=pickup SRC='nexus.php?frame=2&album_id=$album_id'>
</FRAMSET></FRAMSET>";
exit;
}
session_start();
require("common_funcs.php");
connectSQL();
# UPDATE or INSERT to nexus table
if (isset($BTN) and $BTN==1) {
$ALL_DATA = '';
query("SELECT album_id FROM nexus WHERE album_id=$album_id");
if ($nur) {
sqlcmd("DELETE FROM nexus WHERE album_id=$album_id");
}
for ($i=0;$i<count($musicans);$i++)
{
$musican = '';
$instrument = '';
$musicans[$i] = preg_replace("/\\\/","",$musicans[$i]);
if (trim($musicans[$i]) == '') continue;
query("SELECT musicans_id FROM musicans WHERE name='{$musicans[$i]}'");
if ($nur) {
$r = mysql_fetch_row($res);
$musican = $r[0];
} else {
sqlcmd("INSERT INTO musicans (musicans_id,name) VALUES ('','{$musicans[$i]}')");
#print "INSERT INTO musicans (musicans_id,name) VALUES ('','{$musicans[$i]}')<P>";
query("SELECT LAST_INSERT_ID()");
$r = mysql_fetch_row($res);
$musican = $r[0];
}
if (trim($instruments[$i])!='') {
$ins = preg_split("/,/",$instruments[$i],-1,PREG_SPLIT_NO_EMPTY);
for ($j=0;$j<count($ins);$j++)
{
if (trim($ins[$j]) == '') continue;
query("SELECT instruments_id FROM $instruments_table WHERE name='{$ins[$j]}'");
if ($nur) {
$r = mysql_fetch_row($res);
$instrument = $r[0];
} else {
sqlcmd("INSERT INTO $instruments_table (instruments_id,name) VALUES ('','{$ins[$j]}')");
#print "INSERT INTO $instruments_table (instruments_id,name) VALUES ('','{$ins[$j]}')<P>";
query("SELECT LAST_INSERT_ID()");
$r = mysql_fetch_row($res);
$instrument = $r[0];
}
sqlcmd("INSERT INTO nexus (album_id,musicans_id,instruments_id) VALUES ($album_id,$musican,$instrument)");
#print "INSERT INTO nexus (album_id,musicans_id,instruments_id) VALUES ($album_id,$musican,$instrument)<P>";
}
}
else {
sqlcmd("INSERT INTO nexus (album_id,musicans_id,instruments_id) VALUES ($album_id,$musican,'')");
#print "INSERT INTO nexus (album_id,musicans_id,instruments_id) VALUES ($album_id,$musican,'')<P>";
}
}
$ALL_DATA .= htmlentities($musicans[$i],ENT_QUOTES).":$instruments[$i];";
print "<SCRIPT>
parent.title.document.upform.pend.value = '$ALL_DATA';
parent.title.document.upform.submit();
</SCRIPT>";
}
if ($frame == 2) {
}
if ($frame == 1) {
}
# -- ALL FRAMES --
?>
<HTML>
<HEAD>
<TITLE>::: musicans database :::</TITLE>
<LINK REL='stylesheet' HREF='styles_alter.css' TYPE='text/css'>
<SCRIPT>
var global_ii = '';
var global_mi = '';
function IPickUp() {
var picked = '';
var pslices = parent.names.document.getElementById(parent.document.global_ii).value;
if (pslices != '') pslices += ','
var slices = parent.pickup.document.pickupform.instruments;
for (var i = 0; i < slices.length; i++) {
if (slices[i].selected) {
picked += slices[i].value;
if (i>1) picked += ',';
}
}
parent.names.document.getElementById(parent.document.global_ii).value = pslices + picked;
}
function MPickUp() {
var picked = '';
var slices = parent.pickup.document.pickupform.musicans;
for (var i = 0; i < slices.length; i++) {
if (slices[i].selected) {
picked = slices[i].value;
}
}
parent.names.document.getElementById(parent.document.global_mi).value = picked;
}
function OnReturn(ALL_DATA)
{
if (top.opener && !parent.top.opener.closed) {
top.opener.dialogWin.returnedValue = ALL_DATA;
}
top.opener.dialogWin.returnFunc();
top.window.close();
return false;
}
function select_row(mi,ii)
{
parent.names.document.getElementById(mi).style.background="#DEDEDE";
parent.names.document.getElementById(ii).style.background="#DEDEDE";
parent.document.global_ii = ii;
parent.document.global_mi = mi;
}
</SCRIPT>
</HEAD>
<BODY>
<?php
if ( $frame == 0 )
{
if (!isset($newrecord))
{
query("SELECT performer,title FROM album WHERE album_id=$album_id");
$r = next_row();
$performer = $r['performer'];
$title = $r['title'];
}
$performer = preg_replace("/\\\/","",$performer);
$title = preg_replace("/\\\/","",$title);
if (isset($pend))
{
$ACTION = "OnReturn(\"$pend\")";
$STYLE = "background:lightgray";
$TITLE = "Close";
}
else
{
$ACTION = "javascript:parent.names.document.setform.BTN.value=1;parent.names.document.setform.submit()";
$STYLE = "background:#FFEFA2";
$TITLE = "Edit";
}
print "<FORM NAME=upform STYLE='margin=0' METHOD=post>
<INPUT TYPE=hidden NAME=album_id VALUE=$album_id>
<INPUT TYPE=hidden NAME=pend VALUE=0>
<DIV STYLE='border-bottom: 2px solid black;margin-bottom:14px'>
<TABLE WIDTH=100% STYLE='padding:none;background:#D4DBD2;margin:none'>
<TR><TD STYLE='font-weight:bold;font-size:16px;'>$performer - $title</TD>
<TD ALIGN=right><INPUT TYPE=button NAME=send VALUE='$TITLE' OnClick='$ACTION'; STYLE='$STYLE' CLASS=button></TD>
</TABLE>
</DIV></FORM>";
}
elseif( $frame == 1 ) {
?>
<FORM METHOD=post NAME=setform>
<INPUT TYPE=hidden NAME=BTN>
<TABLE CELLPADDING=0 CELLSPACING=0>
<TR><TD VALIGN=top>
<TABLE CELLPADDING=0 CELLSPACING=1 BORDER=0>
<?php
if (!isset($_POST[musicans])) {
query("SELECT m.name AS musicans, i.name AS instrument
FROM nexus n
JOIN album a ON (a.album_id=n.album_id)
JOIN musicans m ON (m.musicans_id=n.musicans_id)
LEFT JOIN $instruments_table i ON (i.instruments_id=n.instruments_id)
WHERE a.album_id=$album_id AND (n.musicans_id = m.musicans_id OR i.instruments_id = n.instruments_id)
ORDER BY m.name ");
# ez mi?
if(!$nur)
query("SELECT n.musicans_id,m.name AS musicans
FROM musicans m,nexus n
WHERE n.album_id=$album_id AND m.musicans_id=n.musicans_id
ORDER BY m.name");
$n = -1;
while ($row = mysql_fetch_assoc($res))
{
$n++;
if (isset($row[instrument])) {
$ins = preg_split('/,/',$row[instrument]);
$iname = $ins[$LOCALE];
if ($iname == '') $iname = $ins[0];
}
$row[musicans] = preg_replace("/\\\/","",$row[musicans]);
print "
<TR><TD>
<INPUT TYPE=radio NAME=edit value=$n OnClick='select_row(\"im_$n\",\"is_$n\")'></TD>
<TD><INPUT ID='im_$n' TYPE=text NAME=musicans[] VALUE=\"{$row[musicans]}\" SIZE=30 STYLE='border:none'> ... </TD>
<TD><INPUT ID='is_$n' TYPE=text NAME=instruments[] VALUE=\"$iname\" SIZE=40 STYLE='border:none'></TD></TR>";
}
}
elseif (isset($_POST[musicans])) {
for ($i=0;$i<count($_POST[musicans]);$i++) {
$mmm = $_POST[musicans][$i];
$iii = $_POST[instruments][$i];
if ($mmm != '') {
$n++;
print "
<TR><TD>
<INPUT TYPE=radio NAME=edit value=$n OnClick='select_row(\"im_$n\",\"is_$n\")'></TD>
<TD><INPUT ID='im_$n' TYPE=text NAME=musicans[] VALUE=\"$mmm\" SIZE=30 STYLE='border:none'> ... </TD>
<TD><INPUT ID='is_$n' TYPE=text NAME=instruments[] VALUE=\"$iii\" SIZE=40 STYLE='border:none'></TD></TR>";
}
}
}
$n += 1;
?>
<TR><TD>
<INPUT TYPE=radio NAME=edit value=<? print $n; ?> OnClick='select_row("<? print 'im_'.$n; ?>","<? print 'is_'.$n; ?>")'> </TD>
<TD><INPUT ID='<? print 'im_'.$n; ?>' TYPE=text NAME=musicans[] SIZE=30 STYLE='border:none'> ... </TD>
<TD><INPUT ID='<? print 'is_'.$n; ?>' TYPE=text NAME=instruments[] SIZE=40 STYLE='border:none'></TD></TR>
<TR><TD COLSPAN=3><INPUT TYPE=submit NAME='plus' VALUE='+'></TD></TR>
</TABLE></FORM>
<?
// end of frame1
}
elseif ($frame == 2)
{
# hangszerek --
# zenészek --
query("SELECT instruments_id,name FROM $instruments_table ORDER BY name");
$ires = $res;
query("SELECT musicans_id,name FROM musicans ORDER BY name");
$mres = $res;
?>
<TD VALIGN=top STYLE='padding-left:10px'>
<FORM METHOD=post NAME=pickupform>
<TABLE CELLPADDING=0 CELLSPACING=0 border=0>
<TR><TD>
<SELECT NAME=instruments MULTIPLE SIZE=8 STYLE='border:1px solid gray;width:200px;background-color:#fffeee'>
<?
while ($row = mysql_fetch_assoc($ires)) {
print "<OPTION>{$row[name]}</OPTION>";
}
?>
</SELECT>
</TD><TD VALIGN=top STYLE='padding-left:4px'> <INPUT TYPE=button VALUE='set' CLASS=button OnClick='IPickUp()'></TD></TR>
<TR><TD COLSPAN=2><INPUT TYPE=text NAME=newinst STYLE='width:200px'> <INPUT TYPE=submit NAME=pushinst VALUE='push' CLASS=button></TD></TR>
</TABLE>
<P>
<TABLE CELLPADDING=0 CELLSPACING=0 border=0>
<TR><TD>
<SELECT NAME=musicans SIZE=8 STYLE='border:1px solid gray;width:200px;background-color:#fffeee'>
<?
while ($row = mysql_fetch_assoc($mres)) {
print "<OPTION>{$row[name]}</OPTION>";
}
?>
</SELECT>
</TD><TD VALIGN=top STYLE='padding-left:4px'> <INPUT TYPE=button VALUE='set' CLASS=button OnClick='MPickUp()'></TD></TR>
<TR><TD COLSPAN=2><INPUT TYPE=text NAME=newinst STYLE='width:200px'> <INPUT TYPE=submit NAME=pushmus VALUE='push' CLASS=button></TD></TR>
</TABLE>
</FORM>
<!-- nagy tábla vége -->
</TD></TR></TABLE>
<?
closeSQL();
} //frame 2
?>
</BODY>
</HTML>