<?php
require_once('checkuser.php');
require_once('dbconnect.php');
require_once('execute.php');
?>
<script type="text/javascript">
function setfocus(){
document.forms[0].Eingabe.focus();
}
function search(){
$sort = $(this).attr("var");
$order = $(this).attr("href");
var data = $("form").serialize();
$.ajax({
type: "POST",
url: "facharbeiten_edit.php?focus=1",
data: data,
success: function(data){
$("#content").html(data);
}
});
return false;
}
$("#sort a").click(function(){
$sort = $(this).attr("var");
$order = $(this).attr("href");
var data = $("form").serialize();
$.ajax({
type: "POST",
url: "facharbeiten_edit.php?sort=" + $sort +"&order="+ $order,
data: data,
success: function(data){
$("#content").html(data);
}
});
return false;
})
function request($Radio){
var data = $("form").serialize();
$.ajax({
type: "POST",
url: "facharbeiten_edit.php?Form=sent",
data: data,
success: function(data){
$("#content").html(data);
}
});
return false;
}
$("#form").click(function(){
$Radio = $("input:radio").serialize();
$catcheck = $("select").serialize();
var strFehler='';
switch($Radio){
case 'degree=praktikum':
if(document.forms[0].title_thema.value == ""){ document.forms[0].title_thema.focus(); strFehler += "Feld Titel des Themas ist leer\n";}
if(document.forms[0].title_cat.value == "" && $catcheck ==""){ document.forms[0].title_cat.focus(); strFehler += "Feld Kategorie ist leer\n";} break;
case 'degree=bachelor':
if(document.forms[0].title_thema.value == ""){ document.forms[0].title_thema.focus(); strFehler += "Feld Titel des Themas ist leer\n";}
if(document.forms[0].title_cat.value == "" && $catcheck ==""){ document.forms[0].title_cat.focus(); strFehler += "Feld Kategorie ist leer\n";} break;
case 'degree=master':
if(document.forms[0].title_thema.value == ""){ document.forms[0].title_thema.focus(); strFehler += "Feld Titel des Themas ist leer\n";}
if(document.forms[0].title_cat.value == "" && $catcheck ==""){ document.forms[0].title_cat.focus(); strFehler += "Feld Kategorie ist leer\n";} break;
case 'degree=diplom':
if(document.forms[0].title_thema.value == ""){ document.forms[0].title_thema.focus(); strFehler += "Feld Titel des Themas ist leer\n";}
if(document.forms[0].title_cat.value == "" && $catcheck ==""){ document.forms[0].title_cat.focus(); strFehler += "Feld Kategorie ist leer\n";} break;
}
if (strFehler.length>0) {
alert("Festgestellte Probleme: \n\n"+strFehler);
return(false);
}
else{
request($Radio);
}
return false;
});
</script>
<?php
$Form = $_GET['Form'];
$sort = $_GET['sort'];
$order = $_GET['order'];
$focus = $_GET['focus'];
if($focus == "1"){
echo "<script type=\"text/javascript\">setfocus();</script>";
}
if($sort ==""){$sort ="lastname";}
if($Form != "sent"){
?>
<form method="post" action="">
<b class="ueberschrift">Facharbeit auswählen</b>
<p class="rad" >
<input id="praktikum" type="radio" name="degree" checked="checked" value="praktikum">Praktikumsarbeit<br>
<input id="bachelor" type="radio" name="degree" value="bachelor">Bachelorarbeit<br>
<input id="master" type="radio" name="degree" value="master">Masterarbeit<br>
<input id="diplom" type="radio" name="degree" value="diplom">Diplomarbeit<br>
</p>
<table>
<b class="ueberschrift">Informationen zum Thema</b>
<tr>
<td class="formtext">Titel des Themas:* </td>
<td><input class ="forminput" type="text" name="title_thema" value= "<?php echo ($_POST['title_thema']);?>" ></td>
</tr>
<tr>
<td class="formtext">Metadaten: </td>
<td><input class ="forminput" type="text" name="meta_thema" value= "<?php echo ($_POST['meta_thema']);?>" ></td>
</tr>
<tr>
<td class="formtext">Preview:</td>
<td><input class ="forminput" type="text" name="prev_thema" value= "<?php echo ($_POST['prev_thema']);?>" ></td>
</tr>
<tr>
<td class="formtext">Auszug:</td>
<td><input class ="forminput" type="text" name="excerpt_thema" value= "<?php echo ($_POST['excerpt_thema']);?>" ></td>
</tr>
<tr>
<td class="formtext">Ausgabe der Arbeit:</td>
<td><input class ="forminput" type="text" name="start" value= "<?php echo ($_POST['start']);?>" ></td>
</tr>
<tr>
<td class="formtext">Abgabe der Arbeit:</td>
<td><input class ="forminput" type="text" name="end" value= "<?php echo ($_POST['end']);?>"></td>
</tr>
<tr>
<td class="formtext">Abgabeverlängerung:</td>
<td><input class ="forminput" type="text" name="extent" value= "<?php echo ($_POST['extent']);?>" ></td>
</tr>
<b class="ueberschrift">Kategorien*</b>
<tr>
<td class="formtext">Kategorien Auswahl: </td>
<td>
<?php
$sql="SELECT CAID,title FROM category";
$rs = $conn->Execute($sql);
print '<select class="formselect" name="category[]" size="6" multiple>';
if($rs===false) die(mysql_error());
while(!$rs->EOF){
print "<option ".($rs->fields[0] == $_POST["category"][0] ? 'selected="selected"' : "" )."value=".$rs->fields[0].">".$rs->fields[1]. "</option>";
$rs->MoveNext();
}
?>
</td>
</tr>
<tr>
<td class="formtext">Neue Kategorie:</td>
<td><input class ="forminput" type="text" name="title_cat" value= "<?php echo ($_POST['title_cat']);?>"></td>
</tr>
<b class="ueberschrift">Unternehmen</b>
<tr>
<td class="formtext">Unternehmen Auswahl: </td>
<td>
<?php
$sql="SELECT CMP_ID,name FROM company";
$rs = $conn->Execute($sql);
print '<select style="width:100%" name="company" size="6" >';
if($rs===false) die(mysql_error());
while(!$rs->EOF){
print "<option value=".$rs->fields[0].">".$rs->fields[1]. "</option>" ;
$rs->MoveNext();
}
?>
</td>
</tr>
<tr>
<td class="formtext">Neues Unternehmen: </td>
<td><input class ="forminput" type="text" name="name_com" value="<?php echo ($_POST['name_com']);?>" ></td>
</tr>
<tr>
<td class="formtext">Betreuer: </td>
<td><input class ="forminput" type="text" name="advisor" value= "<?php echo ($_POST['advisor']);?>" ></td>
</tr>
<tr>
<td class="formtext">Land: </td>
<td><input class ="forminput" type="text" name="country" value= "<?php echo ($_POST['country']);?>" ></td>
</tr>
<tr>
<td class="formtext">Adresse: </td>
<td><input class ="forminput" type="text" name="address_com" value= "<?php echo ($_POST['address_com']);?>" ></td>
</tr>
<tr>
<td class="formtext">Bundesland: </td>
<td><input class ="forminput" type="text" name="province" value= "<?php echo ($_POST['province']);?>" ></td>
</tr>
</tr>
<b class="ueberschrift">Studenten</b>
<?php if($order =="desc"){ ?>
<tr class="studsort" id="sort">Sortierung: aufsteigend <td><a var="lastname" href="asc"> Nachname </td><td><a var="firstname" href="asc">Vorname</td><td><a var="matricul" href="asc">Matr.Nr.</td></tr>
<?php } else { ?>
<tr class="studsort" id="sort">Sortierung: absteigend <td><a var="lastname" href="desc"> Nachname </td><td><a var="firstname" href="desc">Vorname</td><td><a var="matricul" href="desc">Matr.Nr.</td></tr>
<?php } ?>
<tr>
<td class="formtext">Studenten Auswahl: </td>
<td>
<?php
$sql="SELECT human.humid,firstname,lastname,matricul
FROM human INNER JOIN student
ON human.humid = student.humid
WHERE firstname LIKE \"%".trim($_POST['Eingabe'])."%\"
OR lastname LIKE \"%".trim($_POST['Eingabe'])."%\"
OR matricul LIKE \"%".trim($_POST['Eingabe'])."%\"
Order by $sort $order";
$rs = $conn->Execute($sql);
print '<select name="student" size="6" >';
if($rs===false) die(mysql_error());
while(!$rs->EOF){
print "<option value=".$rs->fields[0].">".$rs->fields[2]. " ".$rs->fields[1]. " Matr.: ".$rs->fields[3]. "</option>";
$rs->MoveNext();
}
?>
</td>
</tr>
<tr>
<td class="formtext">Studenten suche: </td>
<td><input class ="forminput" type="text" onkeyup="search()"name="Eingabe" value="<?php echo ($_POST['Eingabe']);?>"></td>
</tr>
<td class="formtext"colspan="2"><input id="form" var="edit" type="submit" value="Speichern">
<input type="reset" >
</td>
</table>
</form>
<?php
}
if ($Form == "sent"){
require_once('facharbeiten_editsql.php');
}
?>