mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-20 00:12:15 +00:00
Syncronisationsscript WaWi->FHComplete
für Aufteilung und Aufteilung_Default
This commit is contained in:
@@ -1585,6 +1585,8 @@ if(!@$db->db_query('SELECT * FROM wawi.tbl_konto LIMIT 1'))
|
||||
GRANT SELECT, UPDATE ON SEQUENCE public.tbl_kontakt_kontakt_id_seq TO wawi;
|
||||
GRANT SELECT, UPDATE ON SEQUENCE public.tbl_standort_standort_id_seq TO wawi;
|
||||
GRANT SELECT, UPDATE ON SEQUENCE public.tbl_personfunktionstandort_personfunktionstandort_id_seq TO wawi;
|
||||
GRANT SELECT, UPDATE ON SEQUENCE wawi.seq_aufteilung_default_aufteilung_id TO wawi;
|
||||
GRANT SELECT, UPDATE ON SEQUENCE wawi.seq_aufteilung_aufteilung_id TO wawi;
|
||||
|
||||
|
||||
-- INDEX
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010 FH Technikum Wien
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Authors: Christian Paminger <christian.paminger@technikum-wien.at>,
|
||||
* Andreas Oesterreicher <andreas.oesterreicher@technikum-wien.at> and
|
||||
* Karl Burkhart <karl.burkhart@technikum-wien.at>.
|
||||
*/
|
||||
/**
|
||||
* Syncronisiert die Aufteilung von WaWi DB in FHComplete DB
|
||||
*/
|
||||
require_once('../../config/wawi.config.inc.php');
|
||||
require_once('../../include/basis_db.class.php');
|
||||
require_once('../../include/mail.class.php');
|
||||
|
||||
if (!$db = new basis_db())
|
||||
die('Fehler beim Herstellen der Datenbankverbindung');
|
||||
|
||||
if (!$conn_wawi = pg_pconnect(CONN_STRING_WAWI))
|
||||
die('Es konnte keine Verbindung zum Server aufgebaut werden. *** File:='.__FILE__.' Line:='.__LINE__."\n");
|
||||
|
||||
$error_log='';
|
||||
$update_log='';
|
||||
$anzahl_aufteilungen=0;
|
||||
$anzahl_insert=0;
|
||||
$anzahl_update=0;
|
||||
$anzahl_delete=0;
|
||||
$anzahl_fehler=0;
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>Synchro - WaWi -> FAS - Aufteilung</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
$qry="
|
||||
SET CLIENT_ENCODING TO UNICODE;
|
||||
SELECT
|
||||
*, aufteilung.lupdate, aufteilung.cdate, bn_create.username_neu as insertvon, bn_update.username_neu as updatevon
|
||||
FROM
|
||||
aufteilung
|
||||
JOIN studiengang USING(studiengang_id)
|
||||
LEFT JOIN benutzer bn_update ON(aufteilung.luser=bn_update.user_id)
|
||||
LEFT JOIN benutzer bn_create ON(aufteilung.luser=bn_create.user_id)
|
||||
WHERE studiengang_id<>20
|
||||
ORDER BY aufteilung_id
|
||||
";
|
||||
if($result=pg_query($conn_wawi, $qry))
|
||||
{
|
||||
|
||||
$anzahl_aufteilungen=pg_num_rows($result);
|
||||
|
||||
while($row = pg_fetch_object($result))
|
||||
{
|
||||
//check, ob firma bereits übertragen
|
||||
$qry_check="SELECT * FROM wawi.tbl_aufteilung WHERE aufteilung_id='".addslashes($row->aufteilung_id)."'";
|
||||
if($result_check=$db->db_query($qry_check))
|
||||
{
|
||||
if($db->db_num_rows($result_check)>0)
|
||||
{
|
||||
$update = false;
|
||||
//Aufteilung vorhanden - Änderungen im WaWi?
|
||||
if($row_check = $db->db_fetch_object($result_check))
|
||||
{
|
||||
if($row_check->bestellung_id!=$row->bestellung_id)
|
||||
{
|
||||
$update = true;
|
||||
$update_log.="\nBestellung_id von $row_check->bestellung_id auf $row->bestellung_id geändert";
|
||||
}
|
||||
if($row_check->oe_kurzbz!=$row->oe_kurzbz)
|
||||
{
|
||||
$update=true;
|
||||
$update_log.="\nOrganisationseinheit von $row_check->oe_kurzbz auf $row->oe_kurzbz geändert";
|
||||
}
|
||||
if($row_check->anteil!=$row->anteil)
|
||||
{
|
||||
$update=true;
|
||||
$update_log.="\nAnteil von $row_check->anteil auf $row->anteil geändert";
|
||||
}
|
||||
if($row_check->updatevon!=$row->username_neu)
|
||||
{
|
||||
$update=true;
|
||||
$update_log.="\nUpdateVon von $row_check->updatevon auf $row->username_neu geändert";
|
||||
}
|
||||
|
||||
if($update)
|
||||
{
|
||||
$qry = "UPDATE wawi.tbl_aufteilung SET
|
||||
bestellung_id=".$db->addslashes($row->bestellung_id).",
|
||||
oe_kurzbz=".$db->addslashes($row->oe_kurzbz).",
|
||||
anteil=".$db->addslashes($row->anteil).",
|
||||
updatevon=".$db->addslashes($row->updatevon).",
|
||||
updateamum=".$db->addslashes($row->lupdate)."
|
||||
WHERE aufteilung_id='".addslashes($row->aufteilung_id)."'";
|
||||
if($db->db_query($qry))
|
||||
{
|
||||
$anzahl_update++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$error_log.="\nFehler beim Update: $qry";
|
||||
$anzahl_fehler++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Aufteilung nicht vorhanden
|
||||
$qry="INSERT INTO wawi.tbl_aufteilung(aufteilung_id, bestellung_id, oe_kurzbz, anteil,
|
||||
insertamum, insertvon, updateamum, updatevon) VALUES("
|
||||
.$db->addslashes($row->aufteilung_id).","
|
||||
.$db->addslashes($row->bestellung_id).","
|
||||
.$db->addslashes($row->oe_kurzbz).","
|
||||
.$db->addslashes($row->anteil).","
|
||||
.$db->addslashes($row->cdate).","
|
||||
.$db->addslashes($row->insertvon).","
|
||||
.$db->addslashes($row->lupdate).","
|
||||
.$db->addslashes($row->updatevon).");";
|
||||
if($db->db_query($qry))
|
||||
{
|
||||
$anzahl_insert++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$error_log.="\nFehler beim Insert: $qry";
|
||||
$anzahl_fehler++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error_log.="\nFehler bei Select: $qry_check";
|
||||
$anzahl_fehler++;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$db->db_query("SELECT setval('wawi.seq_aufteilung_aufteilung_id',(SELECT max(aufteilung_id) FROM wawi.tbl_aufteilung));"))
|
||||
{
|
||||
$error_log.="\nFehler beim Update der Sequence";
|
||||
$anzahl_fehler++;
|
||||
}
|
||||
//Mail versenden
|
||||
$statistik="Aufteilung Default Sync\n--------------\n";
|
||||
$statistik.="Beginn: ".date("d.m.Y H:i:s")." von ".DB_NAME." - Anzahl Einträge: ".$anzahl_aufteilungen."\n\n";
|
||||
$statistik.="\nEingefügte Datensätze: $anzahl_insert";
|
||||
$statistik.="\nGeänderte Datensätze: $anzahl_update";
|
||||
$statistik.="\nFehler: $anzahl_fehler\n";
|
||||
|
||||
$synced=$statistik.$error_log.$update_log;
|
||||
$mail = new mail(MAIL_ADMIN, "vilesci@".DOMAIN, "SYNC Aufteilung Default von ".DB_NAME, $synced);
|
||||
$mail->setReplyTo("vilesci@".DOMAIN);
|
||||
if(!$mail->send())
|
||||
{
|
||||
echo "<font color=\"#FF0000\">Fehler beim Versenden des Durchführungs-Mails!</font><br>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010 FH Technikum Wien
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Authors: Christian Paminger <christian.paminger@technikum-wien.at>,
|
||||
* Andreas Oesterreicher <andreas.oesterreicher@technikum-wien.at> and
|
||||
* Karl Burkhart <karl.burkhart@technikum-wien.at>.
|
||||
*/
|
||||
/**
|
||||
* Syncronisiert die Default Aufteilung von WaWi DB in FHComplete DB
|
||||
*/
|
||||
require_once('../../config/wawi.config.inc.php');
|
||||
require_once('../../include/basis_db.class.php');
|
||||
require_once('../../include/mail.class.php');
|
||||
|
||||
if (!$db = new basis_db())
|
||||
die('Fehler beim Herstellen der Datenbankverbindung');
|
||||
|
||||
if (!$conn_wawi = pg_pconnect(CONN_STRING_WAWI))
|
||||
die('Es konnte keine Verbindung zum Server aufgebaut werden. *** File:='.__FILE__.' Line:='.__LINE__."\n");
|
||||
|
||||
$error_log='';
|
||||
$update_log='';
|
||||
$anzahl_aufteilungen=0;
|
||||
$anzahl_insert=0;
|
||||
$anzahl_update=0;
|
||||
$anzahl_delete=0;
|
||||
$anzahl_fehler=0;
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>Synchro - WaWi -> FAS - Aufteilung Default</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
$qry="
|
||||
SET CLIENT_ENCODING TO UNICODE;
|
||||
SELECT
|
||||
*, aufteilung_default.lupdate
|
||||
FROM
|
||||
aufteilung_default
|
||||
JOIN studiengang USING(studiengang_id)
|
||||
LEFT JOIN benutzer ON(aufteilung_default.luser=user_id)
|
||||
WHERE studiengang_id<>20
|
||||
ORDER BY aufteilung_id
|
||||
";
|
||||
if($result=pg_query($conn_wawi, $qry))
|
||||
{
|
||||
|
||||
$anzahl_aufteilungen=pg_num_rows($result);
|
||||
|
||||
while($row = pg_fetch_object($result))
|
||||
{
|
||||
//check, ob firma bereits übertragen
|
||||
$qry_check="SELECT * FROM wawi.tbl_aufteilung_default WHERE aufteilung_id='".addslashes($row->aufteilung_id)."'";
|
||||
if($result_check=$db->db_query($qry_check))
|
||||
{
|
||||
if($db->db_num_rows($result_check)>0)
|
||||
{
|
||||
$update = false;
|
||||
//Aufteilung vorhanden - Änderungen im WaWi?
|
||||
if($row_check = $db->db_fetch_object($result_check))
|
||||
{
|
||||
if($row_check->kostenstelle_id!=$row->kostenstelle_id)
|
||||
{
|
||||
$update = true;
|
||||
$update_log.="\nKostenstelle_id von $row_check->kostenstelle auf $row->kostenstelle_id geändert";
|
||||
}
|
||||
if($row_check->oe_kurzbz!=$row->oe_kurzbz)
|
||||
{
|
||||
$update=true;
|
||||
$update_log.="\nOrganisationseinheit von $row_check->oe_kurzbz auf $row->oe_kurzbz geändert";
|
||||
}
|
||||
if($row_check->anteil!=$row->anteil)
|
||||
{
|
||||
$update=true;
|
||||
$update_log.="\nAnteil von $row_check->anteil auf $row->anteil geändert";
|
||||
}
|
||||
if($row_check->updatevon!=$row->username_neu)
|
||||
{
|
||||
$update=true;
|
||||
$update_log.="\nUpdateVon von $row_check->updatevon auf $row->username_neu geändert";
|
||||
}
|
||||
|
||||
if($update)
|
||||
{
|
||||
$qry = "UPDATE wawi.tbl_aufteilung_default SET
|
||||
kostenstelle_id=".$db->addslashes($row->kostenstelle_id).",
|
||||
oe_kurzbz=".$db->addslashes($row->oe_kurzbz).",
|
||||
anteil=".$db->addslashes($row->anteil).",
|
||||
updatevon=".$db->addslashes($row->username_neu).",
|
||||
updateamum=".$db->addslashes($row->lupdate)."
|
||||
WHERE aufteilung_id='".addslashes($row->aufteilung_id)."'";
|
||||
if($db->db_query($qry))
|
||||
{
|
||||
$anzahl_update++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$error_log.="\nFehler beim Update: $qry";
|
||||
$anzahl_fehler++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Aufteilung nicht vorhanden
|
||||
$qry="INSERT INTO wawi.tbl_aufteilung_default(aufteilung_id, kostenstelle_id, oe_kurzbz, anteil,
|
||||
insertamum, insertvon, updateamum, updatevon) VALUES("
|
||||
.$db->addslashes($row->aufteilung_id).","
|
||||
.$db->addslashes($row->kostenstelle_id).","
|
||||
.$db->addslashes($row->oe_kurzbz).","
|
||||
.$db->addslashes($row->anteil).","
|
||||
.$db->addslashes($row->lupdate).","
|
||||
.$db->addslashes($row->username_neu).","
|
||||
.$db->addslashes($row->lupdate).","
|
||||
.$db->addslashes($row->username_neu).");";
|
||||
if($db->db_query($qry))
|
||||
{
|
||||
$anzahl_insert++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$error_log.="\nFehler beim Insert: $qry";
|
||||
$anzahl_fehler++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error_log.="\nFehler bei Select: $qry_check";
|
||||
$anzahl_fehler++;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$db->db_query("SELECT setval('wawi.seq_aufteilung_default_aufteilung_id',(SELECT max(aufteilung_id) FROM wawi.tbl_aufteilung_default));"))
|
||||
{
|
||||
$error_log.="\nFehler beim Update der Sequence";
|
||||
$anzahl_fehler++;
|
||||
}
|
||||
|
||||
//Mail versenden
|
||||
$statistik="Aufteilung Default Sync\n--------------\n";
|
||||
$statistik.="Beginn: ".date("d.m.Y H:i:s")." von ".DB_NAME." - Anzahl Einträge: ".$anzahl_aufteilungen."\n\n";
|
||||
$statistik.="\nEingefügte Datensätze: $anzahl_insert";
|
||||
$statistik.="\nGeänderte Datensätze: $anzahl_update";
|
||||
$statistik.="\nFehler: $anzahl_fehler\n";
|
||||
|
||||
$synced=$statistik.$error_log.$update_log;
|
||||
$mail = new mail(MAIL_ADMIN, "vilesci@".DOMAIN, "SYNC Aufteilung Default von ".DB_NAME, $synced);
|
||||
$mail->setReplyTo("vilesci@".DOMAIN);
|
||||
if(!$mail->send())
|
||||
{
|
||||
echo "<font color=\"#FF0000\">Fehler beim Versenden des Durchführungs-Mails!</font><br>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user