<html>
<head>
<link rel="stylesheet" type="text/css" href="styles.css">
<? $mandant=$_COOKIE["mandant"];
$username=$_COOKIE["username"];
require"kopf.php"; include"funktionen.php";
?>
<title>Anlage Personenkonten für Mandant <? echo$mandant; ?></title>
</head>
<body>
<a href="main.php?mandant=<? echo$mandant; ?>&username=<? echo$username; ?>">Zurück zum Hauptmenü</a>
<form type="POST" action="pk_erfassen.php?name1=<? echo$name1; ?>&name2=<? echo$name2; ?>&strasse=<? echo$strasse; ?>
&plz=<? echo$plz; ?>&ort=<? echo$ort; ?>&skonto=<? echo$skonto; ?>">
<br>Konto-Nummer:<br>
<?
global $gelesen;
if ($konto=="")
{
if($name1 == "")
{ echo("<input type=\"TEXT\" name=\"konto\" value=\"" . $konto . "\"><br><br>");
}
else
{ echo("<input type=\"TEXT\" name=\"konto\" value=\"" . $konto . "\" readonly>");
echo(" Für nächstes Konto unten klicken (Feld schreibgeschützt)<br><br>");
}
die("Bitte Kontonummer eingeben<br>");
}
if ($konto<10000 or $konto>99999)
{
if($name1 == "")
{ echo("<input type=\"TEXT\" name=\"konto\" value=\"" . $konto . "\"><br><br>");
}
else
{ echo("<input type=\"TEXT\" name=\"konto\" value=\"" . $konto . "\" readonly>");
echo(" Für nächstes Konto unten klicken (Feld schreibgeschützt)<br><br>");
}
die("Die eingegebene Kontonummer ist ungültig (10000-99999)<br>");
}
require"connect.php";
$query_pk="SELECT * FROM pkonto WHERE pkonto.pk_manr = " . $mandant;
$query_pk=$query_pk . " and pkonto.pk_nr = " . $konto . " ;";
$result_pk=mysql_query($query_pk);
if(mysql_num_rows($result_pk)==0)
{
$neuanlage=1;
echo("<input type=\"TEXT\" name=\"konto\" value=\"" . $konto . "\" readonly>");
echo(" Für nächstes Konto unten klicken (Feld schreibgeschützt)<br><br>");
# if($fehler<>1)
# {
# $name1="";
# $name2="";
# $strasse="";
# $plz="";
# $ort="";
# $land="";
# $skonto="";
# }
echo("Neuanlage: Bitte Adressdaten eingeben<br>");
}
else
{
if($name1 == "")
{ echo("<input type=\"TEXT\" name=\"konto\" value=\"" . $konto . "\"><br><br>");
}
else
{ echo("<input type=\"TEXT\" name=\"konto\" value=\"" . $konto . "\" readonly>");
echo(" Für nächstes Konto unten klicken (Feld schreibgeschützt)<br><br>");
}
$hilf[2]=$name1;
$hilf[3]=$name2;
$hilf[4]=$strasse;
$hilf[5]=$plz;
$hilf[6]=$ort;
$hilf[7]=$land;
$hilf[8]=$skonto;
$datensatz=mysql_fetch_row($result_pk);
$name1=$datensatz[2];
$name2=$datensatz[3];
$strasse=$datensatz[4];
$plz=$datensatz[5];
$ort=$datensatz[6];
$land=$datensatz[7];
$skonto=$datensatz[8];
$gelesen=1;
if($hilf[2]<>"" and $hilf[2]<>$datensatz[2]) { $name1=$hilf[2]; $geaendert=1; }
if($hilf[3]<>"" and $hilf[3]<>$datensatz[3]) { $name2=$hilf[3]; $geaendert=1; }
if($hilf[4]<>"" and $hilf[4]<>$datensatz[4]) { $strasse=$hilf[4]; $geaendert=1; }
if($hilf[5]<>"" and $hilf[5]<>$datensatz[5]) { $plz=$hilf[5]; $geaendert=1;}
if($hilf[6]<>"" and $hilf[6]<>$datensatz[6]) { $ort=$hilf[6]; $geaendert=1;}
if($hilf[7]<>"" and $hilf[7]<>$datensatz[7]) { $land=$hilf[7]; $geaendert=1;}
if($hilf[8]<>"" and $hilf[8]<>$datensatz[8]) echo("Das Hauptkonto darf nicht geändert werden!!");
}
# Prüfroutinen
$fehler=0;
if($name1==" " or $name1=="")
{
echo("Das Feld NAME1 muß gefüllt sein!<br>");
$fehler+=1;
}
if($strasse==" " or $strasse=="")
{
echo("Das Feld STRASSE muß gefüllt sein!<br>");
$fehler+=1;
}
if($plz==" " or $plz=="")
{
echo("Das Feld PLZ muß gefüllt sein!<br>");
$fehler+=1;
}
if($ort==" " or $ort=="")
{
echo("Das Feld ORT muß gefüllt sein!<br>");
$fehler+=1;
}
if($skonto==" " or $skonto=="")
{
echo("Das Feld SACHKONTO muß gefüllt sein!<br>");
$fehler+=1;
}
if($fehler==0 and $neuanlage==1)
{
#Inserts
$query_ipk="INSERT INTO pkonto SET pk_manr = " . $mandant . ", pk_nr = " . $konto;
$query_ipk=$query_ipk . ", pk_name1='" . $name1 . "', pk_name2='" . $name2;
$query_ipk=$query_ipk . "', pk_strasse='" . $strasse . "', pk_plz='" . $plz;
$query_ipk=$query_ipk . "', pk_ort='" . $ort . "', pk_land='" . $pk_land;
$query_ipk=$query_ipk . "', pk_skonto=" . $skonto . ";";
$query_isk="INSERT INTO konten SET kt_manr = " . $mandant . ", kt_konto = " . $konto;
$query_isk=$query_isk . ", kt_bezeichnung='" . $name1 . "', kt_art = 'P';";
$result_query_ipk=mysql_query($query_ipk);
$result_query_isk=mysql_query($query_isk);
#$name1="";
#$name2="";
#$strasse="";
#$plz="";
#$ort="";
#$land="";
#$skonto="";
}
if($fehler<>1 and $neuanlage<>1 and $geaendert=1)
{
#update
$query_upd="UPDATE pkonto SET pk_name1='" . $name1 . "', pk_name2='" . $name2 . "', pk_strasse = '";
$query_upd=$query_upd . $strasse . "', pk_plz='" . $plz . "', pk_ort='" . $ort . "', pk_land='";
$query_upd=$query_upd . $land . "', pk_skonto=" . $skonto . " WHERE pk_manr = " . $mandant;
$query_upd=$query_upd . " AND pk_nr = " . $konto . ";";
$result_query_upd=mysql_query($query_upd);
}
?>
<hr>
<table>
<tr><td width="200">Name1</td><td width="500">
<input type="TEXT" name="name1" value="<? echo$name1; ?>" size="50"></td></tr>
<tr><td>Name2</td><td>
<input type="TEXT" name="name2" value="<? echo$name2; ?>" size="50"></td></tr>
<tr><td>Straße</td><td>
<input type="TEXT" name="strasse" value="<? echo$strasse; ?>" size="50"></td></tr>
<tr><td>PLZ</td><td>
<input type="TEXT" name="plz" value="<? echo$plz; ?>" size="10"></td></tr>
<tr><td>Ort</td><td>
<input type="TEXT" name="ort" value="<? echo$ort; ?>" size="50"></td></tr>
<tr><td>Sachkonto</td><td>
<input type="TEXT" name="skonto" value="<? echo$skonto; ?>" size="4"></td></tr>
</table>
<hr>
<?
if($konto<60000) { echo("Debitor"); } else { echo("Kreditor"); }
?>
<br>
<hr>
<input type="SUBMIT" value="Speichern">
<a href="pk_erfassen.php?&konto=">Neues Konto anlegen</a>
</form>
</body>
</html>