This commit is contained in:
Rudolf Hangl
2007-07-09 14:04:41 +00:00
parent 600755b872
commit aa3d7c5127
2 changed files with 244 additions and 0 deletions
+5
View File
@@ -162,6 +162,11 @@
</table>
</td>
</tr>
<!--Zusammenlegen von Personen-->
<tr>
<td width="10" nowrap>&nbsp;</td>
<td nowrap><a class="MenuItem2" href="stammdaten/personen_wartung.php" target="main"><img src="../skin/images/menu_item.gif" width="7" height="9">&nbsp;Personen zusammenlegen</a></td>
</tr>
</table>
</td>
</tr>
+239
View File
@@ -0,0 +1,239 @@
<?php
// ***************************************************************
// * Script zum Zusammenlegen Doppelter Studenten
// * Es werden zwei Listen mit Studenten angezeigt
// * Links wird der Student markiert, der mit dem
// * rechts markierten zusammengelegt werden soll.
// * Der linke Student wird danach entfernt.
// ***************************************************************
//DB Verbindung herstellen
require_once('../config.inc.php');
require_once('../../include/person.class.php');
require_once('../../include/functions.inc.php');
if (!$conn = @pg_pconnect(CONN_STRING))
{
die('Es konnte keine Verbindung zum Server aufgebaut werden.');
}
$msg='';
$outp='';
if (isset($_GET['nn']) || isset($_POST['nn']))
{
$nn=(isset($_GET['nn'])?$_GET['nn']:$_POST['nn']);
}
else
{
$nn=NULL;
}
if (isset($_GET['vn']) || isset($_POST['vn']))
{
$vn=(isset($_GET['vn'])?$_GET['vn']:$_POST['vn']);
}
else
{
$vn=NULL;
}
if (isset($_GET['person_id']) || isset($_POST['person_id']))
{
$person_id=(isset($_GET['person_id'])?$_GET['person_id']:$_POST['person_id']);
}
else
{
$person_id=NULL;
}
if (isset($_GET['order_1']) || isset($_POST['order_1']))
{
$order_1=(isset($_GET['order_1'])?$_GET['order_1']:$_POST['order_1']);
}
else
{
$order_1='person_id';
}
if (isset($_GET['order_2']) || isset($_POST['order_2']))
{
$order_2=(isset($_GET['order_2'])?$_GET['order_2']:$_POST['order_2']);
}
else
{
$order_2='person_id';
}
if (isset($_GET['radio_1']) || isset($_POST['radio_1']))
{
$radio_1=(isset($_GET['radio_1'])?$_GET['radio_1']:$_POST['radio_1']);
}
else
{
$radio_1=-1;
}
if (isset($_GET['radio_2']) || isset($_POST['radio_2']))
{
$radio_2=(isset($_GET['radio_2'])?$_GET['radio_2']:$_POST['radio_2']);
}
else
{
$radio_2=-1;
}
function kuerze($string)
{
if(strlen($string)>40)
{
return substr($string,0,35)."...";
}
else
{
return $string;
}
}
if(isset($radio_1) && isset($radio_2) && $radio_1>=0 && $radio_2>=0)
{
if($radio_1==$radio_2)
{
$msg="Die Datensaetze duerfen nicht die gleiche ID haben";
}
else
{
$sql_query_upd1="BEGIN;";
$sql_query_upd1.="UPDATE public.tbl_benutzer SET person_id='$radio_2' WHERE person_id='$radio_1';";
$sql_query_upd1.="UPDATE public.tbl_konto SET person_id='$radio_2' WHERE person_id='$radio_1';";
$sql_query_upd1.="UPDATE public.tbl_prestudent SET person_id='$radio_2' WHERE person_id='$radio_1';";
$sql_query_upd1.="UPDATE sync.tbl_syncperson SET person_portal='$radio_2' WHERE person_portal='$radio_1';";
$sql_query_upd1.="DELETE FROM public.tbl_person WHERE person_id='$radio_1';";
/*wenn synchronisiert auch:
* tbl_abschlusspruefung(pruefer1 bis 3), tbl_projektbetreuer, tbl_adresse, tbl_akte, tbl_bankverbindung, tbl_kontakt
*/
$radio_1=0;
$radio_2=0;
if(pg_query($conn,$sql_query_upd1))
{
$msg = "Daten Erfolgreich gespeichert<br>";
pg_query($conn,"COMMIT;");
$msg .= "<br>".str_replace(';',';<br>',$sql_query_upd1)."COMMIT";
}
else
{
$msg = "Die Änderung konnte nicht durchgeführt werden!";
pg_query($conn,"ROLLBACK;");
$msg .= "<br>".str_replace(';',';<br><b>',$sql_query_upd1)."ROLLBACK</b>";
}
}
}
if((isset($radio_1) && !isset($radio_2))||(!isset($radio_1) && isset($radio_2)) || ($radio_1<0 || $radio_2<0))
{
$msg="Es muß je ein Radio-Button pro Tabelle angeklickt werden";
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../../skin/vilesci.css" rel="stylesheet" type="text/css">
<title>Personen-Zusammenlegung</title>
</head>
<body>
<H1>Zusammenlegen von Personendatensaetzen</H1>
<?php
echo $outp;
echo "<form name='suche' action='personen_wartung.php' method='POST'>";
echo "<table><tr>";
echo "<th>Nachname</th><th>Vorname</th><th>&nbsp;</th>";
echo "<tr>";
echo "<td><input name=\"nn\" type=\"text\" value=\"$nn\" size=\"64\" maxlength=\"64\"></td>";
echo "<td><input name='vn' type='text' value=\"$vn\" size='32' maxlength='32'></td>";
echo "<td><input type='submit' value=' suchen '></td></tr>";
echo "</table></form>";
//aufruf
?>
<br>
<center><h2><?php echo $msg; ?></h2></center>
<br>
<?php
//Tabellen anzeigen
echo "<form name='form_table' action='personen_wartung.php?uid=$person_id&order_1=$order_1&order_2=$order_2&nn=$nn&vn=$vn' method='POST'>";
echo "<table width='100%' border='0' cellspacing='0' cellpadding='0'>";
echo "<tr>";
echo "<td valign='top'>Der wird gelöscht:";
//Tabelle 1
echo "<table class='liste'><tr class='liste'>";
echo "<th><a href='personen_wartung.php?uid=$person_id&order_1=person_id&order_2=$order_2'>ID</a></th>";
echo "<th><a href='personen_wartung.php?uid=$person_id&order_1=nachname&order_2=$order_2'>Nachname</a></th>";
echo "<th>Vorname</th>";
echo "<th>Geburtsdatum</th>";
echo "<th><a href='personen_wartung.php?uid=$person_id&order_1=svnr&order_2=$order_2'>SVNr</a></th>";
echo "<th><a href='personen_wartung.php?uid=$person_id&order_1=ersatzkennzeichen&order_2=$order_2'>Ersatzkennz.</a></th>";
echo "<th>Ext-ID</th>";
echo "<th>&nbsp;</th></tr>";
$lf = new person($conn);
$lf->getTab($nn,$vn, $order_1);
$i=0;
foreach($lf->personen as $l)
{
echo "<tr class='liste".($i%2)."'>";
echo "<td>$l->person_id</td>";
echo "<td>$l->nachname</td>";
echo "<td>$l->vorname</td>";
echo "<td>$l->gebdatum</td>";
echo "<td>$l->svnr</td>";
echo "<td>$l->ersatzkennzeichen</td>";
echo "<td>$l->ext_id</td>";
echo "<td><input type='radio' name='radio_1' value='$l->person_id' ".((isset($radio_1) && $radio_1==$l->person_id)?'checked':'')."></td>";
echo "</tr>";
$i++;
}
echo "</table>";
echo "</td>";
echo "<td valign='top'><input type='submit' value=' -> '></td>";
echo "<td valign='top'>Der bleibt:";
//Tabelle 2
echo "<table class='liste'><tr class='liste'>";
echo "<th>&nbsp;</th>";
echo "<th><a href='personen_wartung.php?uid=$person_id&order_1=$order_1&order_2=person_id'>UID</a></th>";
echo "<th><a href='personen_wartung.php?uid=$person_id&order_1=$order_1&order_2=nachname'>Nachname</a></th>";
echo "<th>Vorname</th>";
echo "<th>Geburtsdatum</th>";
echo "<th><a href='personen_wartung.php?uid=$person_id&order_1=$order_1&order_2=svnr'>SVNr</a></th>";
echo "<th><a href='personen_wartung.php?uid=$person_id&order_1=$order_1&order_2=ersatzkennzeichen'>Ersatzkennz.</a></th>";
echo "<th>Ext-ID</th>";
echo "</tr>";
$lf = new person($conn);
$lf->getTab($nn, $vn, $order_2);
$i=0;
foreach($lf->personen as $l)
{
echo "<tr class='liste".($i%2)."'>";
echo "<td><input type='radio' name='radio_2' value='$l->person_id' ".((isset($radio_2) && $radio_2==$l->person_id)?'checked':'')."></td>";
echo "<td>$l->person_id</td>";
echo "<td>$l->nachname</td>";
echo "<td>$l->vorname</td>";
echo "<td>$l->gebdatum</td>";
echo "<td>$l->svnr</td>";
echo "<td>$l->ersatzkennzeichen</td>";
echo "<td>$l->ext_id</td>";
echo "</tr>";
$i++;
}
echo "</table>";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "</form>";
?>
</tr>
</table>
</body>
</html>