diff --git a/.htaccess b/.htaccess new file mode 100644 index 000000000..e87393a7c --- /dev/null +++ b/.htaccess @@ -0,0 +1,36 @@ +AuthName "Technikum-Wien" +AuthType Basic +AuthLDAPURL ldap://pdc1.technikum-wien.at/ou=People,dc=technikum-wien,dc=at?uid?one?objectClass=posixAccount +require group cn=fhadmin,ou=Group,dc=technikum-wien,dc=at +require user trob +require user wahl +require user drabek +require user elgner +require user schaaf +require user kofler +require user esberger +require user kollmitz +require user schmoe +require user trattner +require user naglr +require user patai +require user tw01e061 +require user docsek +require user teschl +require user oesi +require user adams +require user weisss +require user moserp +require user moehring +require user skritek +require user kroesl +require user ffe +require user kindlm +require user schmuderm +require user sagmeister +require user masik +require user kubicka +require user lehner +require user schwarzl +require user horauer +require user me diff --git a/admin/sync/sync_fas_exstd.php b/admin/sync/sync_fas_exstd.php new file mode 100644 index 000000000..014ad8e5f --- /dev/null +++ b/admin/sync/sync_fas_exstd.php @@ -0,0 +1,85 @@ +"; + $result=pg_exec($conn, $sql_query); + $vilesci_anz_std=pg_fetch_result($result,0,'anz'); + + // Start Studenten Synchro + $sql_query="SELECT DISTINCT uid FROM fas_view_vilesci_abbrecher WHERE uid IS NOT NULL AND uid NOT LIKE '' ORDER BY uid"; // LIMIT 5"; + //echo $sql_query."
"; + flush(); + $result=pg_exec($conn_fas, $sql_query); + $num_rows=pg_numrows($result); + $text="Dies ist eine automatische eMail!\r\r"; + $text.="Es wurde eine Synchronisation mit FAS durchgeführt.\r"; + $text.="Anzahl der Ex-Studenten vom FAS-Import: $num_rows \r"; + $text.="Anzahl der Studenten in VILESCI: $vilesci_anz_std \r\r"; + echo $text.'
'; + flush(); + $update_error=0; + $anz_update=0; + for ($i=0;$i<$num_rows;$i++) + { + $row=pg_fetch_object($result,$i); + $uid=str_replace(' ','',$row->uid); + // SQL vorbereiten (jeden Studenten vom FAS im vilesci suchen + $sql_query="SELECT uid,titel,vornamen,nachname, semester FROM tbl_person NATURAL JOIN tbl_student WHERE uid LIKE '$uid'"; + //echo $sql_query; + $res_std=pg_query($conn, $sql_query); + $num_rows_std=pg_numrows($res_std); + // neue Studenten + if ($num_rows_std>=1) + { + $row_std=pg_fetch_object($res_std); + if ($row_std->semester!=10) + { + $text.="Der Student $row_std->vornamen $row_std->nachname ($row_std->uid) wird verschoben.\r"; + $sql_query="UPDATE tbl_student SET semester=10, updateamum=now(), updatevon='auto' WHERE uid LIKE '$uid'"; + echo $sql_query.'
'; + if(!$res_update=pg_query($conn, $sql_query)) + { + $text.=$sql_query; + $text.="\rFehler: ".pg_errormessage($conn)."\r"; + $update_error++; + } + else + $anz_update++; + } + } + } + $text.="$update_error Fehler bei Student-Update!\r"; + $text.="$anz_update Studenten wurden ins 10te Semester verschoben.\r"; + $text.="\rEND OF SYNCHRONISATION\r"; + if (mail($adress,"FAS Synchro mit VILESCI (Ex-Studenten)",$text,"From: vilesci@technikum-wien.at")) + $sendmail=true; + else + $sendmail=false; +?> + + + + FAS-Synchro mit VILESCI (Ex-Studenten) + + + + +'; +else + echo "Mail konnte nicht verschickt werden!
"; +echo $text; + +?> + + diff --git a/admin/sync/sync_fas_lkt.php b/admin/sync/sync_fas_lkt.php new file mode 100644 index 000000000..5bdbf2437 --- /dev/null +++ b/admin/sync/sync_fas_lkt.php @@ -0,0 +1,202 @@ + "ae", + "ö" => "oe", + "ü" => "ue", + "Ä" => "ae", + "Ö" => "oe", + "Ü" => "ue", + "á" => "a", + "à" => "a", + "é" => "e", + "è" => "e", + "ó" => "o", + "ò" => "o", + "í" => "i", + "ì" => "i", + "ú" => "u", + "ù" => "u", + "ß" => "ss", + "´" => "", + "`" => "", + ); + $string = strtr($string, $trans); + return $string; + } + + $adress='fas_sync@technikum-wien.at'; + //mail($adress,"FAS Synchro mit VILESCI (Lektoren)","BEGIN OF SYNCHRONISATION","From: vilesci@technikum-wien.at"); + $conn=pg_connect(CONN_STRING); + $conn_fas=pg_connect(CONN_STRING_FAS); + + // Anzahl der Mitarbeiter in VILESCI + $sql_query="SELECT count(*) AS anz FROM tbl_mitarbeiter WHERE uid NOT LIKE '\\\\_%'"; + //echo $sql_query."
"; + $result=pg_exec($conn, $sql_query); + $vil_anz_mta=pg_fetch_result($result,0,'anz'); + + // Start Studenten Synchro + $sql_query="SELECT * FROM vw_vilesci_mitarbeiter_aktiv WHERE uid IS NOT NULL AND uid NOT LIKE ''"; // LIMIT 5"; + //echo $sql_query."
"; + $result=pg_exec($conn_fas, $sql_query); + $num_rows=pg_numrows($result); + $text="Dies ist eine automatische eMail!\r\r"; + $text.="Es wurde eine Synchronisation mit FAS durchgeführt.\r"; + $text.="Anzahl der Mitarbeiter vom FAS-Import: $num_rows \r"; + $text.="Anzahl der Mitarbeiter in der VILESCI: $vil_anz_mta \r\r"; + $plausi_error=0; + $update_error=0; + $insert_error=0; + $double_error=0; + $anz_update=0; + $anz_insert=0; + for ($i=0;$i<$num_rows;$i++) + { + $row=pg_fetch_object($result,$i); + $row->gebort=substr($row->gebort,0,30); + //$row->titel=substr($row->titel,0,15); + $uid=str_replace(' ','',$row->uid); + // Plausibilitaetscheck + if (strlen($row->titel)>64) + $text.="Der Mitarbeiter $row->titel $row->vornamen $row->nachname ($row->uid) hat einen zu langen Titel.\r"; + if (strlen($row->titel)<=64) + { + // SQL vorbereiten (jeden Mitarbeiter vom FAS in VILESCI suchen + $sql_query="SELECT uid,titel,vornamen,nachname,gebdatum,gebort,"; + $sql_query.="personalnummer"; + $sql_query.=" FROM tbl_person NATURAL JOIN tbl_mitarbeiter WHERE uid LIKE '$uid'"; + //echo $sql_query; + $res_std=pg_exec($conn, $sql_query); + $num_rows_std=pg_numrows($res_std); + + // neue Lektoren + if ($num_rows_std==0) + { + $text.="Der Lektor $row->vornamen $row->nachname ($row->uid) wird neu angelegt.\r"; + // person + $qry="INSERT INTO tbl_person(uid,titel,vornamen, nachname, gebdatum, gebort) ". + "VALUES('$uid','$row->titel','$row->vornamen','$row->nachname','$row->gebdatum','$row->gebort')"; + echo $qry.'
'; + if(!$res_insert=pg_exec($conn, $qry)) + { + $text.=$qry; + $text.="\rFehler: ".pg_errormessage($conn)."\r"; + $insert_error++; + } + + //Alias erstellen + $vn = split('[- .,]',strtolower($row->vornamen)); + $vn = clean_string($vn[0]); + + $nn = split('[- .,]',strtolower($row->nachname)); + $nn = clean_string($nn[0]); + $alias = $vn.".".$nn; + $qry = "UPDATE tbl_person set alias='$alias' where uid='$uid'"; + if(!$res_insert=pg_exec($conn, $qry)) + { + $text.=$qry; + $text.="\rFehler: Alias existiert bereits: $alias"; + $insert_error++; + } + // lektor + $sql_query="INSERT INTO tbl_mitarbeiter (uid,personalnummer,kurzbz,lektor,telefonklappe,fixangestellt) ". + "VALUES('$row->uid','$row->persnr','$row->kurzbez',true,'$row->teltw',".($row->fixangestellt?'true':'false').")"; + echo $sql_query.'
'; + if(!$res_insert=pg_exec($conn, $sql_query)) + { + $text.=$sql_query; + $text.="\rFehler: ".pg_errormessage($conn)."\r"; + $insert_error++; + } + else + $anz_insert++; + } + // bestehende Lektoren + elseif ($num_rows_std==1) + { + $update=0; + $row_std=pg_fetch_object($res_std,0); + if ($row->gruppe==NULL) + $row->gruppe=1; + if ($row->titel!=$row_std->titel) + $update=1; + elseif ($row->vornamen!=$row_std->vornamen) + $update=2; + elseif ($row->nachname!=$row_std->nachname) + $update=3; + elseif ($row->gebdatum!=$row_std->gebdatum) + $update=4; + elseif ($row->gebort!=$row_std->gebort) + $update=5; + elseif ($row->persnr!=$row_std->personalnummer) + $update=6; + if ($update) + { + $text.="Der Lektor $row->vornamen $row->nachname ($row->uid) [$update] wird upgedatet.\r"; + // person + $sql_query="UPDATE tbl_person SET titel='$row->titel', vornamen='$row->vornamen', ". + " nachname='$row->nachname', gebdatum='$row->gebdatum', gebort='$row->gebort'". + " WHERE uid LIKE '$uid'"; + echo $sql_query.'
'; + if(!$res_update=pg_exec($conn, $sql_query)) + { + $text.=$sql_query; + $text.="\rFehler: ".pg_errormessage($conn)."\r"; + $update_error++; + } + + $sql_query="UPDATE tbl_mitarbeiter SET personalnummer='$row->persnr',fixangestellt=".($row->fixangestellt?'TRUE':'FALSE'); + $sql_query.=" WHERE uid LIKE '$uid'"; + echo $sql_query.'
'; // kurzbz='$row->kurzbez', + if(!$res_update=pg_exec($conn, $sql_query)) + { + $text.=$sql_query; + $text.="\rFehler: ".pg_errormessage($conn)."\r"; + $update_error++; + } + else + $anz_update++; + } + } + // Lektor kommt mehrmals vor ->Warnung + elseif ($num_rows_std>1) + { + $text.="\r!!! Der Lektor $row->vornamen $row->nachname ($row->uid) kommt mehrfach vor!\r"; + $double_error++; + } + } + else + $plausi_error++; + } + $text.="\r$plausi_error Fehler beim Plausibilitaetscheck!\r"; + $text.="$update_error Fehler bei Lektor-Update!\r"; + $text.="$insert_error Fehler bei Lektor-Insert!\r"; + $text.="$double_error Lektoren kommen in VileSci doppelt vor!\r\r"; + $text.="$anz_update Lektoren wurden upgedatet.\r"; + $text.="$anz_insert Lektoren wurden neu angelegt.\r\r"; + $text.="\rEND OF SYNCHRONISATION\r"; + if (mail($adress,"FAS Synchro mit VileSci (Lektoren)",$text,"From: vilesci@technikum-wien.at")) + $sendmail=true; + else + $sendmail=false; +?> + + + +FAS-Synchro mit VileSci (Lektoren) + + + +'; +else + echo "Mail konnte nicht verschickt werden!
"; +echo $text; + +?> + + diff --git a/admin/sync/sync_fas_lkt_fault.php b/admin/sync/sync_fas_lkt_fault.php new file mode 100644 index 000000000..1786ef507 --- /dev/null +++ b/admin/sync/sync_fas_lkt_fault.php @@ -0,0 +1,56 @@ +FAS-Synchro mit TEMPUS fehlende Lektoren'; + $text.=''; + + // Start Check + //Daten aus vilesci holen + $sql_query="SELECT tbl_person.*,tbl_mitarbeiter.personalnummer,tbl_mitarbeiter.kurzbz,tbl_mitarbeiter.fixangestellt FROM tbl_person join tbl_mitarbeiter using(uid) WHERE uid NOT LIKE '\\\\_%' ORDER BY nachname"; + //echo $sql_query."
"; + $result=pg_exec($conn, $sql_query); + $num_rows=pg_numrows($result); + // Daten aus dem FAS + $sql_query="SELECT * FROM fas_view_lektoren_vilesci"; + //echo $sql_query."
"; + $result_fas=pg_exec($conn_fas, $sql_query); + $fehlend=$num_rows-$num_rows_fas; + $num_rows_fas=pg_numrows($result_fas); + $text.="Dies ist eine automatische eMail!

"; + $text.="Es wurde eine Ueberpruefung der Daten in der FAS-View fuer Lektoren durchgeführt.
"; + $text.='Anzahl der fehlenden Daten: $fehlend

'; + $text.="Folgende Lektoren scheinen in der FAS-View nicht auf"; + $text.=''; + for ($i=0;$i<$num_rows;$i++) + { + $row=pg_fetch_object($result,$i); + $sql_query="SELECT uid FROM fas_view_lektoren_vilesci WHERE uid LIKE '$row->uid'"; + $result_fas=pg_exec($conn_fas, $sql_query); + if (pg_numrows($result_fas)!=1) + $text.='"; + } + $text.='
uidTitelVornamenNachname
$row->uid$row->titel$row->vornamen$row->nachname
'; + + echo $text; + + if (mail($adress,"FAS Synchro mit TEMPUS fehlende Lektoren",$text,$headers)) + echo 'Mail wurde verschickt an '.$adress.'!
'; + else + echo "Mail konnte nicht verschickt werden!
"; + +?> + + diff --git a/admin/sync/sync_fas_lva.php b/admin/sync/sync_fas_lva.php new file mode 100644 index 000000000..ed1ef081b --- /dev/null +++ b/admin/sync/sync_fas_lva.php @@ -0,0 +1,594 @@ +lvnr.' '.$row->bezeichnung; +} + +function getSemesterWhereClause() +{ + global $conn; + $qry="select * from tbl_studiensemester where ende>now()"; + $result=pg_exec($conn, $qry); + $where=''; + while ($row=pg_fetch_object($result)) + { + $where.= ((strlen($where)>0)?' or ':'')."studiensemester_kurzbz='".$row->studiensemester_kurzbz."' "; + } + if (strlen($where)>0) $where=" ($where) "; + return $where; +} + +function validate($row) +{ + global $error_log,$einheit,$missing_einheit,$missing_raumtyp,$missing_lehrform,$raumtyp,$lehrform; + $valid=true; + if ($row->raumtyp==null) + { + $error_log[$row->studiengang_kz][]=printLVA($row).': Raumtyp fehlt'; + $valid=false; + } + if ($row->semester>8 || $row->semester<1) + { + $error_log[$row->studiengang_kz][]=printLVA($row).': Semester bei '.$row->semester.$row->verband.$row->gruppe.' größer als 8'; + $valid=false; + } + if (!($row->verband==null || $row->verband=='' || $row->verband=='A' || $row->verband=='B' || $row->verband=='C' || $row->verband=='D')) + { + $error_log[$row->studiengang_kz][]=printLVA($row).': Verband bei '.$row->semester.$row->verband.$row->gruppe.' außerhalb des gültigen Bereichs (A bis D)'; + //print_r($row); + $valid=false; + } + if (!($row->gruppe==null || $row->gruppe=='' || $row->gruppe=='1' || $row->gruppe=='2' || $row->gruppe=='3' || $row->gruppe=='4')) + { + $error_log[$row->studiengang_kz][]=printLVA($row).': Gruppe bei '.$row->semester.$row->verband.$row->gruppe.' außerhalb des gültigen Bereichs (1 bis 4)'; + $valid=false; + } + if (!$row->stundenblockung>0) { + $error_log[$row->studiengang_kz][]=printLVA($row).': Stundenblockung ist nicht größer 0'; + $valid=false; + } + if (!$row->semesterstunden>0) { + $error_log[$row->studiengang_kz][]=printLVA($row).': Semesterstunden sind nicht größer 0'; + $valid=false; + } + if (!$row->wochenrythmus>0) + { + $error_log[$row->studiengang_kz][]=printLVA($row).': Wochenrythmus ist nicht größer 0'; + $valid=false; + } + if ($row->start_kw<=0 || $row->start_kw>53) + { + $error_log[$row->studiengang_kz][]=printLVA($row).': Start-KW außerhalb des gültigen Bereichs (1 bis 53)'; + $valid=false; + } + if (strlen($row->einheit_kurzbz)>0 && !isset($einheit[$row->einheit_kurzbz]) && !isset($missing_einheit[$row->einheit_kurzbz])) + { + $missing_einheit[$row->einheit_kurzbz]=1; + } + if (strlen($row->raumtyp)>0 && !isset($raumtyp[$row->raumtyp]) && !isset($missing_raumtyp[$row->raumtyp])) + { + $missing_raumtyp[$row->raumtyp]=1; + $valid=false; + } + if (strlen($row->raumtypalternativ)>0 && !isset($raumtyp[$row->raumtypalternativ]) && !isset($missing_raumtyp[$row->raumtypalternativ])) { + $missing_raumtyp[$row->raumtypalternativ]=1; + } + if (!ereg("^[A-Za-z]{1,5}[0-9]{0,1}$",$row->raumtyp)) + { + $error_log[$row->studiengang_kz][]=$row->raumtyp.': Raumtyp bei LVNR:'.$row->lvnr.' ist nicht plausibel.'; + $valid=false; + } + if (!ereg("^[A-Za-z]{1,5}[0-9]{0,1}$",$row->raumtypalternativ)) + { + $error_log[$row->studiengang_kz][]=$row->raumtypalternativ.': Raumtypalternative bei LVNR:'.$row->lvnr.' ist nicht plausibel.'; + $valid=false; + } + if (strlen($row->lehrform)>0 && !isset($lehrform[$row->lehrform]) && !isset($missing_lehrform[$row->lehrform])) { + $missing_lehrform[$row->lehrform]=1; + } + if (!ereg("^[A-Z]{1,5}[0-9]{0,1}$",$row->lehrfach_kurzbz)) + { + $error_log[$row->studiengang_kz][]=$row->lehrfach_kurzbz.'-'.$row->lehrform.'/'.$row->studiengang_kz.'-'.$row->semester.': Lehrfach-Kuerzel bei LVNR:'.$row->lvnr.' ist nicht plausibel.'; + $valid=false; + } + if (!ereg("^[A-Z]{1,3}$",$row->lehrform)) + { + $error_log[$row->studiengang_kz][]=$row->lehrfach_kurzbz.'-'.$row->lehrform.'/'.$row->studiengang_kz.'-'.$row->semester.': Lehrform bei LVNR:'.$row->lvnr.' ist nicht plausibel.'; + $valid=false; + } + return $valid; +} + +/** + * FAS-Lehrfach auf interne Lehrfach-Nr übersetzen + */ +function getLehrfachNr($kurzbz,$studiengang_kz,$semester,$lehrfach_bezeichnung, $fachbereich_id, $ects, $conn) +{ + global $lehrfach; + global $text; + + if (isset($lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['lehrfach_nr'])) + { + //echo 'Nummer:'.$lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['lehrfach_nr'].'Bez: '.$lehrfach_bezeichnung.'
'; + + // Nebenbei die Lehrfachbezeichnung kontrollieren + if ($lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['lehrfach_bezeichnung']!=$lehrfach_bezeichnung) + { + // Update + $qry="UPDATE tbl_lehrfach SET bezeichnung='$lehrfach_bezeichnung' WHERE lehrfach_nr=".$lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['lehrfach_nr']; + if (!$result=pg_query($conn, $qry)) + echo $qry.' fehlgeschlagen!
'; + else + { + echo 'Lehrfach '.$kurzbz.'/'.$studiengang_kz.'/'.$semester.' wurde von '.$lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['lehrfach_bezeichnung'].' auf '.$lehrfach_bezeichnung.' geaendert!
'; + $text.='Lehrfach '.$kurzbz.'/'.$studiengang_kz.'/'.$semester.' wurde von '.$lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['lehrfach_bezeichnung'].' auf '.$lehrfach_bezeichnung.' geaendert!\n'; + $lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['lehrfach_bezeichnung']=$lehrfach_bezeichnung; + } + } + + // Nebenbei die ECTS Punkte kontrollieren + if ($lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['ects']!=$ects) + { + if ($ects!='') //ereg("[0-9]{1,4}[\.|,][0-9]{0,2}$",$ects) + { + // Update + $qry="UPDATE tbl_lehrfach SET ects='$ects' WHERE lehrfach_nr=".$lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['lehrfach_nr']; + //echo $qry.'
'; + if (!$result=pg_query($conn, $qry)) + echo $qry.' fehlgeschlagen!
'; + else + { + echo ' Bei Lehrfach '.$kurzbz.'/'.$studiengang_kz.'/'.$semester.' wurden die ECTS-Punkte von '.$lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['ects'].' auf '.$ects.' geaendert!
'; + $text.='Bei Lehrfach '.$kurzbz.'/'.$studiengang_kz.'/'.$semester.' wurden die ECTS-Punkte von '.$lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['ects'].' auf '.$ects.' geaendert!\n'; + $lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['ects']=$ects; + } + } + else + { + echo 'Bei Lehrfach '.$kurzbz.'/'.$studiengang_kz.'/'.$semester.' sind die ECTS-Punkte von '.$ects.' nicht Plausibel!
'; + $text.='Bei Lehrfach '.$kurzbz.'/'.$studiengang_kz.'/'.$semester.' sind die ECTS-Punkte von '.$ects.' nicht Plausibel!\n'; + } + + } + + // Nebenbei die FachbereichID kontrollieren + if ($lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['fachbereich_id']!=$fachbereich_id) + { + // Update + $qry="UPDATE tbl_lehrfach SET fachbereich_id=$fachbereich_id WHERE lehrfach_nr=".$lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['lehrfach_nr']; + if (!$result=@pg_query($conn, $qry)) + echo $qry.' fehlgeschlagen!
'; + else + { + echo 'Bei Lehrfach '.$kurzbz.'/'.$studiengang_kz.'/'.$semester.' wurde die FachbereichID von '.$lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['fachbereich_id'].' auf '.$fachbereich_id.' geaendert!
'; + $text.='Bei Lehrfach '.$kurzbz.'/'.$studiengang_kz.'/'.$semester.' wurde die FachbereichID von '.$lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['fachbereich_id'].' auf '.$fachbereich_id.' geaendert!\n'; + $lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['fachbereich_id']=$fachbereich_id; + } + } + return $lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['lehrfach_nr']; + } + //echo 'missing getLehrfachNr: '.$kurzbz.'/'.$studiengang_kz.'/'.$semester.'
'; + return -1; +} + + +/************************* + * FAS-Synchronisation + */ + +// E-Mails der Studiengänge +$stg_mail=array(); +$qry="select studiengang_kz,email,kurzbz from tbl_studiengang"; +$result=pg_exec($conn, $qry); +while ($row=pg_fetch_object($result)) +{ + $stg_mail[$row->studiengang_kz] = $row->email; + $stg_kurzbz[$row->studiengang_kz]=$row->kurzbz; +} + +// Anzahl der LVA in VileSci +$sql_query="SELECT count(*) AS anz FROM tbl_lehrveranstaltung"; +//echo $sql_query."
"; +$result=pg_exec($conn, $sql_query); +$vil_anz_lva=pg_fetch_result($result,0,'anz'); + +// Lehrfächer holen und in Array speichern (Key ist kurzbz + '/' + lehform_kurzbz) +$sql_query="SELECT lehrfach_nr,kurzbz,studiengang_kz,semester, bezeichnung, fachbereich_id, ects FROM tbl_lehrfach"; +$result=pg_exec($conn, $sql_query); +while ($row=pg_fetch_object($result)) +{ + $lehrfach[$row->kurzbz.'/'.$row->studiengang_kz.'/'.$row->semester]['lehrfach_nr'] = $row->lehrfach_nr; + $lehrfach[$row->kurzbz.'/'.$row->studiengang_kz.'/'.$row->semester]['fachbereich_id'] = $row->fachbereich_id; + $lehrfach[$row->kurzbz.'/'.$row->studiengang_kz.'/'.$row->semester]['lehrfach_bezeichnung'] = $row->bezeichnung; + $lehrfach[$row->kurzbz.'/'.$row->studiengang_kz.'/'.$row->semester]['ects'] = $row->ects; +} +//print_r($lehrfach); +// Einheiten holen +$sql_query="SELECT einheit_kurzbz,bezeichnung FROM tbl_einheit"; +$result=pg_exec($conn, $sql_query); +while ($row=pg_fetch_object($result)) + $einheit[$row->einheit_kurzbz] = $row->bezeichnung; +// Raumtypen holen +$sql_query="SELECT raumtyp_kurzbz,beschreibung FROM tbl_raumtyp"; +$result=pg_exec($conn, $sql_query); +while ($row=pg_fetch_object($result)) + $raumtyp[$row->raumtyp_kurzbz] = $row->beschreibung; +// Lehformen holen +$sql_query="SELECT lehrform_kurzbz,bezeichnung FROM tbl_lehrform"; +$result=pg_exec($conn, $sql_query); +while ($row=pg_fetch_object($result)) + $lehrform[$row->lehrform_kurzbz] = $row->bezeichnung; +//print_r($lehrfach); +echo 'FAS-Datenbank wird abgefragt!
'; +flush(); + +// Start Lehrveranstaltungen Synchro +$sql_query="SELECT DISTINCT fas_id,trim(lvnr) AS lvnr,trim(unr)::int8 AS unr,einheit_kurzbz,lektor,trim(upper(lehrfach_kurzbz)) AS lehrfach_kurzbz, + trim(upper(lehrform)) AS lehrform, lehrfach_bezeichnung, + studiengang_kz,fachbereich_id,semester,verband,gruppe,raumtyp,raumtypalternativ, + round(semesterstunden) AS semesterstunden,stundenblockung,wochenrythmus,start_kw,anmerkung,studiensemester_kurzbz, ects + FROM fas_view_alle_lehreinheiten_vilesci ". + "where ".getSemesterWhereClause(); +//echo $sql_query."
"; +$result=pg_exec($conn_fas, $sql_query); +$num_rows=pg_numrows($result); +$text="Dies ist eine automatische eMail!\r\r"; +$text.="Es wurde eine Synchronisation mit FAS durchgeführt.\r"; +$text.="Anzahl der LVA vom FAS-Import: $num_rows \r"; +$text.="Anzahl der LVA in der VileSci: $vil_anz_lva \r\r"; +$plausi_error=0; +$update_error=0; +$insert_error=0; +$double_error=0; +$anz_update=0; +$anz_insert=0; +echo $num_rows.' Datensaetze
'; +for ($i=0;$i<$num_rows;$i++) +{ + if ($i%100==0) + { + echo '-'; + flush(); + } + $row=pg_fetch_object($result,$i); + // Kennzahl der Studiengangs bei ehemaligen bTec auf TW aendern. + if ($row->studiengang_kz==203) + $row->studiengang_kz=0; + // Lehrfach-Nr übersetzen (-1 wenn nicht vorhanden) + $row->lehrfach_nr=getLehrfachNr($row->lehrfach_kurzbz,$row->studiengang_kz,$row->semester, $row->lehrfach_bezeichnung, $row->fachbereich_id, $row->ects, $conn); + // Einheit vollstaendiger Name + if (count($row->einheit_kurzbz)>0) + $row->einheit_kurzbz=$stg_kurzbz[$row->studiengang_kz].'-'.$row->einheit_kurzbz; + + // Plausibilitaetscheck + //if ($row->gruppe==NULL) + // $row->gruppe='1'; + + // + if (!$row->stundenblockung>0) + $row->stundenblockung=1; + if (!$row->start_kw>0) + $row->start_kw=1; + if (!$row->wochenrythmus>0) + $row->wochenrythmus=1; + + if ($row->lehrfach_nr==-1) + { + //$error_log[$row->studiengang_kz][]=printLVA($row).': Lehrfach (Kurzbz='".$row->lehrfach_kurzbz."',Lehrform".$row->lehrform) existiert noch nicht. Stundenplanabteilung wurde benachrichtigt.'; + if (!isset($missing_lehrfaecher[$row->lehrfach_kurzbz.'/'.$row->studiengang_kz.'/'.$row->semester])) $missing_lehrfaecher[$row->lehrfach_kurzbz.'/'.$row->studiengang_kz.'/'.$row->semester]=1; + $valid=false; + } + + if (validate($row) && $row->lehrfach_nr>-1) + { + // SQL vorbereiten (jede LVA vom FAS im VileSci suchen) + $sql_query="SELECT * from tbl_lehrveranstaltung where fas_id=".$row->fas_id; + //echo $sql_query; + $res_lva=pg_query($conn, $sql_query); + $num_rows_lva=pg_numrows($res_lva); + + // neue LVA + if ($num_rows_lva==0) + { + $text.="Die LVA fas-id=$row->fas_id lvnr=$row->lvnr unr=$row->unr wird neu angelegt.\r"; + $sql_query="INSERT INTO tbl_lehrveranstaltung (lvnr,unr,einheit_kurzbz,lektor,lehrfach_nr,lehrform_kurzbz,"; + $sql_query.="studiengang_kz,fachbereich_id,semester,verband,gruppe,raumtyp,". + "raumtypalternativ,semesterstunden,stundenblockung,". + "wochenrythmus,start_kw,studiensemester_kurzbz,fas_id,anmerkung) ". + "VALUES('$row->lvnr'". + ",$row->unr,". + (strlen($row->einheit_kurzbz)>0?"'".$row->einheit_kurzbz."'":'NULL').",". + "'$row->lektor',". + "'$row->lehrfach_nr',". + "'$row->lehrform',". + "'$row->studiengang_kz',". + "$row->fachbereich_id,". + "$row->semester,"; + if ($row->verband==null) + $sql_query.='NULL,'; + else + $sql_query.="'$row->verband',"; + if ($row->gruppe==null) + $sql_query.='NULL,'; + else + $sql_query.="'$row->gruppe',"; + $sql_query.="'$row->raumtyp',". + "'$row->raumtypalternativ',". + "$row->semesterstunden,". + "$row->stundenblockung,". + "$row->wochenrythmus,". + "$row->start_kw,". + "'$row->studiensemester_kurzbz'," . + "$row->fas_id,'$row->anmerkung')"; + //echo $sql_query.'
'; + if(!$res_insert=@pg_exec($conn, $sql_query)) + { + $text.=$sql_query; + $text.="\nFehler: ".pg_errormessage($conn)."\n"; + $insert_error++; + } + else + $anz_insert++; + } + // bestehende LVA + elseif ($num_rows_lva==1) + { + $update_sql=''; + $row_lva=pg_fetch_object($res_lva,0); + //var_dump($row_lva); + //if ($row->gruppe==NULL) + // $row->gruppe=1; + //echo '-'.$row->lvnr.'-'.$row_lva->lvnr.'-
'; + if ($row->lvnr!=$row_lva->lvnr) + $update_sql.="lvnr='".$row->lvnr."'"; + elseif ($row->unr!=$row_lva->unr) + $update_sql.="unr=".$row->unr; + elseif ($row->einheit_kurzbz!=$row_lva->einheit_kurzbz) + $update_sql.=(strlen($update_sql)>0?',':'').'einheit_kurzbz='.(strlen($row->einheit_kurzbz)>0?"'".$row->einheit_kurzbz."'":'NULL'); + elseif ($row->lektor!=$row_lva->lektor) + $update_sql.=(strlen($update_sql)>0?',':'')."lektor='".$row->lektor."'"; + elseif ($row->lehrfach_nr!=$row_lva->lehrfach_nr) + $update_sql.=(strlen($update_sql)>0?',':'')."lehrfach_nr=".$row->lehrfach_nr; + elseif ($row->lehrform!=$row_lva->lehrform_kurzbz) + $update_sql.=(strlen($update_sql)>0?',':'')."lehrform_kurzbz='".$row->lehrform."'"; + elseif ($row->studiengang_kz!=$row_lva->studiengang_kz) + $update_sql.=(strlen($update_sql)>0?',':'')."studiengang_kz=".$row->studiengang_kz; + elseif ($row->fachbereich_id!=$row_lva->fachbereich_id) + $update_sql.=(strlen($update_sql)>0?',':'')."fachbereich_id=".$row->fachbereich_id; + elseif ($row->semester!=$row_lva->semester) + $update_sql.=(strlen($update_sql)>0?',':'')."semester=".$row->semester; + elseif ($row->verband!=$row_lva->verband) + $update_sql.=(strlen($update_sql)>0?',':'')."verband=".(strlen($row->verband)>0?"'".$row->verband."'":'NULL'); + elseif ($row->gruppe!=$row_lva->gruppe) + $update_sql.=(strlen($update_sql)>0?',':'')."gruppe=".(strlen($row->gruppe)>0?"'".$row->gruppe."'":'NULL'); + elseif ($row->raumtyp!=$row_lva->raumtyp) + $update_sql.=(strlen($update_sql)>0?',':'')."raumtyp='".$row->raumtyp."'"; + elseif ($row->raumtypalternativ!=$row_lva->raumtypalternativ) + $update_sql.=(strlen($update_sql)>0?',':'')."raumtypalternativ='".$row->raumtypalternativ."'"; + elseif ($row->semesterstunden!=$row_lva->semesterstunden) + $update_sql.=(strlen($update_sql)>0?',':'')."semesterstunden=".$row->semesterstunden; + elseif ($row->stundenblockung!=$row_lva->stundenblockung) + $update_sql.=(strlen($update_sql)>0?',':'')."stundenblockung=".$row->stundenblockung; + elseif ($row->wochenrythmus!=$row_lva->wochenrythmus) + $update_sql.=(strlen($update_sql)>0?',':'')."wochenrythmus=".$row->wochenrythmus; + elseif ($row->start_kw!=$row_lva->start_kw) + $update_sql.=(strlen($update_sql)>0?',':'')."start_kw=".(strlen($row->start_kw)>0?$row->start_kw:'NULL'); + elseif ($row->studiensemester_kurzbz!=$row_lva->studiensemester_kurzbz) + $update_sql.=(strlen($update_sql)>0?',':'')."studiensemester_kurzbz='".$row->studiensemester_kurzbz."'"; + elseif ($row->anmerkung!=$row_lva->anmerkung) + $update_sql.=(strlen($update_sql)>0?',':'')."anmerkung='".$row->anmerkung."'"; + + if (strlen($update_sql)>0) + { + $text.="Die LVA fas-id=$row->fas_id lvnr=$row->lvnr unr=$row->unr wird upgedatet.\r"; + $sql_query="UPDATE tbl_lehrveranstaltung SET ". + $update_sql. + " where fas_id=".$row->fas_id; + + //echo $sql_query.'
'; + if(!$res_update=@pg_query($conn, $sql_query)) + { + $text.=$sql_query; + $text.="\rFehler: ".pg_errormessage($conn)."\r"; + $update_error++; + } + else + $anz_update++; + + // **************** + // Auch in tbl_stundenplandev updaten + $sql_query="SELECT * FROM tbl_stundenplandev WHERE + lehrveranstaltung_id=$row_lva->lehrveranstaltung_id AND datum>=now()"; + //echo $sql_query.'
'; + if(!$res_upd_stpl=@pg_query($conn, $sql_query)) + { + $text.=$sql_query; + $text.="\rFehler: ".pg_errormessage($conn)."\r"; + } + else + { + if (!pg_query($conn,"BEGIN;")) + $text.="\rFehler: ".pg_errormessage($conn)."\r"; + $kollision=false; + while ($row_upd_stpl=pg_fetch_object($res_upd_stpl)) + { + // Lehrstunde auf Kollisionen checken + $lehrstunde=new lehrstunde($conn); + //echo '
STPL-ID:'.$row_upd_stpl->stundenplandev_id.'
'; + if (!$lehrstunde->load($row_upd_stpl->stundenplandev_id)) + echo $lehrstunde->errormsg; + $lehrstunde->lektor_uid=$row->lektor; + if (!$lehrstunde->kollision()) + { + if (!$lehrstunde->save('sync_fas_lva')) + echo $lehrstunde->errormsg; + } + else + { + $error_log[$row->studiengang_kz][]=$lehrstunde->errormsg; + $text.="\rKollision: ".$lehrstunde->errormsg."\r"; + $kollision=true; + echo "Kollision: ".$lehrstunde->errormsg."
"; + } + } + if ($kollision) + { + if (!pg_query($conn,"ROLLBACK;")) + $text.="\rFehler: ".pg_errormessage($conn)."\r"; + } + else + if (!pg_query($conn,"COMMIT;")) + $text.="\rFehler: ".pg_errormessage($conn)."\r"; + } + } + } + // LVA kommt mehrmals vor ->Warnung + elseif ($num_rows_lva>1) + { + $text.="\r!!! Die LVA fas_id=$row->fas_id kommt mehrfach vor!\r"; + $double_error++; + } + } + else + $plausi_error++; +} + + +// **************** +// Ueberfluessige Datensaetze loeschen +$whereClause=getSemesterWhereClause(); +$sql_query="DELETE FROM tbl_lehrveranstaltung WHERE fas_id NOT IN + (SELECT fas_id FROM vw_fas_lehrveranstaltung WHERE $whereClause) AND (fas_id!=0 OR fas_id IS NOT NULL) AND ($whereClause)"; +echo $sql_query.'
'; +if(!$res_delete=@pg_query($conn, $sql_query)) +{ + $text.='\n'.$sql_query; + $text.="\rFehler: ".pg_errormessage($conn)."\r"; + $text.="\rSolution: DELETE FROM tbl_stundenplandev WHERE lehrveranstaltung_id IN (SELECT lehrveranstaltung_id FROM tbl_lehrveranstaltung WHERE fas_id NOT IN (SELECT fas_id FROM vw_fas_lehrveranstaltung WHERE $whereClause) AND (fas_id!=0 OR fas_id IS NOT NULL) AND ($whereClause))\r"; +} +else +{ + $anz_delete=pg_numrows($res_delete); +} + +//Ausgabe Zusammenfassung +$text.="\n$anz_delete Lehrveranstaltungen wurden geloescht!\n"; +$text.="$plausi_error Fehler beim Plausibilitaetscheck!\n"; +$text.="$update_error Fehler bei LVA-Update!\n"; +$text.="$insert_error Fehler bei LVA-Insert!\n"; +$text.="$double_error LVA kommen in VileSci doppelt vor!\n\n"; +$text.="$anz_update LVA wurden upgedatet.\n"; +$text.="$anz_insert LVA wurden neu angelegt.\n\n"; +$text.="\nEND OF SYNCHRONISATION\n"; + +// Validation error hinzufügen +while(list($k,$v)=each($error_log)) +{ + $text.="\n\nStudiengang $k:\n"; + foreach($v as $txt) + $text.=" $txt\n"; +} +// fehlende lehrfächer +$text.="\n\nFehlende Lehrfächer: \n"; +while(list($k,$v)=each($missing_lehrfaecher)) +{ + $text.=" $k\n"; +} +// fehlende einheiten +$text.="\n\nFehlende Einheiten: \n"; +while(list($k,$v)=each($missing_einheit)) +{ + $text.=" $k\n"; +} +// fehlende raumtypen +$text.="\n\nFehlende Raumtypen: \n"; +while(list($k,$v)=each($missing_raumtyp)) +{ + $text.=" $k\n"; +} +// fehlende lehrformen +$text.="\n\nFehlende Lehrformen: \n"; +while(list($k,$v)=each($missing_lehrform)) +{ + $text.=" $k\n"; +} +if (mail($adress,"FAS Synchro mit VileSci (Lehrveranstaltungen)",$text,"From: vilesci@technikum-wien.at")) + $sendmail=true; +else + $sendmail=false; + +//print "debug: ";print_r($stg_mail); + +// Einzelnen Mails an Studiengänge verschicken +reset($error_log); +while(list($k,$v)=each($error_log)) +{ + echo "
Mail an Studiengang $k ".$stg_mail[$k].":
"; + $stg_text="Dies ist eine automatische Mail!\nFolgende Fehler sind bei der Synchronisation der Lehrveranstaltungen aufgetreten:\n\n"; + foreach($v as $txt) + $stg_text.="$txt\n"; + echo $stg_text.'
'; + // Studiengang + if (!mail($stg_mail[$k],"FAS Synchro mit VileSci (Lehrveranstaltungen) $k",$stg_text,"From: vilesci@technikum-wien.at")) + echo "Mail an '".$stg_mail[$k]."' konnte nicht verschickt werden!
"; + // Stundenplanstelle + echo "
Mail an Studiengang $k ($adress_stpl)
"; + if (!mail($adress_stpl,"FAS Synchro mit VileSci (Lehrveranstaltungen) $k",$stg_text,"From: vilesci@technikum-wien.at")) + echo 'Mail an "'.$adress_stpl.'" konnte nicht verschickt werden!
'; + +} + +// Doppelte IDs im FAS prüfen +$sql_query="SELECT count(*) AS anzahl, fas_id FROM fas_view_alle_lehreinheiten_vilesci + GROUP BY fas_id HAVING count(*)>1"; +//echo $sql_query."
"; +$result=pg_query($conn_fas, $sql_query); +$num_rows=pg_numrows($result); +$mail_text="Folgende $num_rows IDs kommen in der View fas_view_alle_lehreinheiten_vilesci (fas_id) mehrfach vor:\n\n"; +$mail_text_false=''; +if ($num_rows>0) + while ($row=pg_fetch_object($result)) + $mail_text_false.=$row->fas_id.'->'.$row->anzahl."x\n"; +$mail_text.=$mail_text_false."\n\nBitte überprüfen die Daten im FAS!!!"; +if ($mail_text_false!='') + if (!mail($adress_fas,"FAS Synchro mit VileSci (Lehrveranstaltungen)",$mail_text,"From: vilesci@technikum-wien.at")) + echo "Mail an '".$adress_fas."' konnte nicht verschickt werden!
"; + else + echo 'Mail wurde verschickt an '.$adress_fas.'!
'; +?> + + + +FAS-Synchro mit VileSci + + + +'; +else + echo "Mail konnte nicht verschickt werden!
"; +echo nl2br($text); + +?> + + diff --git a/admin/sync/sync_fas_std.php b/admin/sync/sync_fas_std.php new file mode 100644 index 000000000..6b0c2a635 --- /dev/null +++ b/admin/sync/sync_fas_std.php @@ -0,0 +1,233 @@ + "ae", + "ö" => "oe", + "ü" => "ue", + "Ä" => "ae", + "Ö" => "oe", + "Ü" => "ue", + "á" => "a", + "à" => "a", + "é" => "e", + "è" => "e", + "ó" => "o", + "ò" => "o", + "í" => "i", + "ì" => "i", + "ú" => "u", + "ù" => "u", + "ß" => "ss", + "´" => "", + "`" => "", + ); + $string = strtr($string, $trans); + return $string; + } + + //mail($adress,"FAS Synchro mit VileSci (Studenten)","BEGIN OF SYNCHRONISATION","From: vilesci@technikum-wien.at"); + $conn=pg_connect(CONN_STRING); + $conn_fas=pg_connect(CONN_STRING_FAS); + + // Anzahl der Studenten in VileSci + $sql_query="SELECT count(*) AS anz FROM tbl_student"; + //echo $sql_query."
"; + $result=pg_exec($conn, $sql_query); + $vilesci_anz_std=pg_fetch_result($result,0,'anz'); + + // Start Studenten Synchro + $sql_query="SELECT DISTINCT * FROM fas_view_student_vilesci WHERE semester >0 AND semester <9 AND"; + $sql_query.=" verband IS NOT NULL AND uid IS NOT NULL AND uid NOT LIKE ''"; // LIMIT 5"; + echo $sql_query."
"; + flush(); + $result=pg_exec($conn_fas, $sql_query); + $num_rows=pg_numrows($result); + $text="Dies ist eine automatische eMail!\r\r"; + $text.="Es wurde eine Synchronisation mit FAS durchgeführt.\r"; + $text.="Anzahl der Studenten vom FAS-Import: $num_rows \r"; + $text.="Anzahl der Studenten in VileSci: $vilesci_anz_std \r\r"; + echo $text.'
'; + flush(); + $plausi_error=0; + $update_error=0; + $insert_error=0; + $double_error=0; + $anz_update=0; + $anz_insert=0; + for ($i=0;$i<$num_rows;$i++) + { + $row=pg_fetch_object($result,$i); + $row->gebort=substr($row->gebort,0,30); + $row->titel=substr($row->titel,0,15); + $uid=str_replace(' ','',$row->uid); + // Plausibilitaetscheck + if ($row->gruppe==null) + $row->gruppe='1'; + if ($row->verband>='A' && $row->verband<='D' && $row->semester<=8 && $row->gruppe>'0' && $row->gruppe<='2') + { + // SQL vorbereiten (jeden Studenten vom FAS im VileSci suchen + $sql_query="SELECT uid,titel,vornamen,nachname,gebdatum,gebort,"; + $sql_query.="trim(both ' ' from matrikelnr) AS matrikelnr,"; + $sql_query.=" studiengang_kz,semester,verband,gruppe"; + $sql_query.=" FROM tbl_person NATURAL JOIN tbl_student WHERE uid LIKE '$uid'"; + // echo $sql_query; + $res_std=pg_exec($conn, $sql_query); + $num_rows_std=pg_numrows($res_std); + + // neue Studenten + if ($num_rows_std==0) + { + $text.="Der Student $row->vornamen $row->nachname ($row->uid) wird neu angelegt.\r"; + // tbl_person + $sql_query="INSERT INTO tbl_person(uid,titel,vornamen, nachname, gebdatum, gebort) ". + "VALUES('$row->uid','$row->titel','$row->vornamen','$row->nachname','$row->gebdatum','$row->gebort')"; + echo $sql_query.'
'; + flush(); + + //Alias erstellen + $vn = split('[- .,]',strtolower($row->vornamen)); + $vn = clean_string($vn[0]); + + $nn = split('[- .,]',strtolower($row->nachname)); + $nn = clean_string($nn[0]); + $alias = $vn.".".$nn; + $qry = "UPDATE tbl_person set alias='$alias' where uid='$row->uid'"; + if(!$res_insert=pg_exec($conn, $qry)) + { + $text.=$qry; + $text.="\rFehler: Alias existiert bereits: $alias"; + $insert_error++; + } + + // tbl_student + if(!$res_insert=pg_exec($conn, $sql_query)) + { + $text.=$qry; + $text.="\rFehler: ".pg_errormessage($conn)."\r"; + $insert_error++; + } + $sql_query="INSERT INTO tbl_student (uid,matrikelnr, studiengang_kz, semester, verband, gruppe) ". + "VALUES('$row->uid','$row->perskz',$row->kennzahl,$row->semester,'$row->verband','$row->gruppe')"; + echo $sql_query.'
'; + if(!$res_insert=pg_exec($conn, $sql_query)) + { + $text.=$sql_query; + $text.="\rFehler: ".pg_errormessage($conn)."\r"; + $insert_error++; + } + else + $anz_insert++; + } + // bestehende Studenten + elseif ($num_rows_std==1) + { + $update=0; + $row_std=pg_fetch_object($res_std,0); + if ($row->gruppe==NULL) + $row->gruppe=1; + if ($row->titel!=$row_std->titel) + $update=1; + elseif ($row->vornamen!=$row_std->vornamen) + $update=2; + elseif ($row->nachname!=$row_std->nachname) + $update=3; + elseif ($row->gebdatum!=$row_std->gebdatum) + $update=4; + elseif ($row->gebort!=$row_std->gebort) + $update=5; + elseif ($row->perskz!=$row_std->matrikelnr) + $update=6; + elseif ($row->semester!=$row_std->semester) + $update=7; + elseif ($row->verband!=$row_std->verband) + $update=8; + elseif ($row->gruppe!=$row_std->gruppe) + $update=9; + elseif ($row->kennzahl!=$row_std->studiengang_kz) + $update=10; + if ($update) + { + $text.="Der Student $row->vornamen $row->nachname ($row->uid) wird upgedatet.\r"; + // person + $sql_query="UPDATE tbl_person SET titel='$row->titel', vornamen='$row->vornamen', ". + " nachname='$row->nachname', gebdatum='$row->gebdatum', gebort='$row->gebort'". + " WHERE uid LIKE '$uid'"; + echo $sql_query.'
'; + if(!$res_update=pg_exec($conn, $sql_query)) + { + $text.=$sql_query; + $text.="\rFehler: ".pg_errormessage($conn)."\r"; + $update_error++; + } + // student + $sql_query="UPDATE tbl_student SET matrikelnr='$row->perskz', semester=$row->semester"; + if ($row->verband==NULL) + $sql_query.=", verband=NULL"; + else + $sql_query.=", verband='$row->verband'"; + if ($row->gruppe==NULL) + $sql_query.=", gruppe=NULL"; + else + $sql_query.=", gruppe='$row->gruppe'"; + $sql_query.=", studiengang_kz=".$row->kennzahl; + $sql_query.=", updateamum=now(), updatevon='auto' WHERE uid LIKE '$uid'"; + echo $sql_query.'
'; + if(!$res_update=pg_exec($conn, $sql_query)) + { + $text.=$sql_query; + $text.="\rFehler: ".pg_errormessage($conn)."\r"; + $update_error++; + } + else + $anz_update++; + } + } + // Student kommt mehrmals vor ->Warnung + elseif ($num_rows_std>1) + { + $text.="\r!!! Der Student $row->vornamen $row->nachname ($row->uid) kommt mehrfach vor!\r"; + $double_error++; + } + } + else + { + $plausi_error++; + $text.="\r!!! Der Student $row->vornamen $row->nachname ($row->uid) STG:$row->kennzahl S:$row->semester V:$row->verband G:$row->gruppe hat nicht plausible Daten!"; + } + } + $text.="\r$plausi_error Fehler beim Plausibilitaetscheck!\r"; + $text.="$update_error Fehler bei Student-Update!\r"; + $text.="$insert_error Fehler bei Student-Insert!\r"; + $text.="$double_error Studenten kommen in VileSci doppelt vor!\r\r"; + $text.="$anz_update Studenten wurden upgedatet.\r"; + $text.="$anz_insert Studenten wurden neu angelegt.\r\r"; + $text.="\rEND OF SYNCHRONISATION\r"; + if (mail($adress,"FAS Synchro mit VileSci (Studenten)",$text,"From: vilesci@technikum-wien.at")) + $sendmail=true; + else + $sendmail=false; +?> + + + + FAS-Synchro mit VileSci (Studenten) + + + +'; +else + echo "Mail konnte nicht verschickt werden!
"; +echo $text; + +?> + + diff --git a/admin/sync/sync_fas_std_fault.php b/admin/sync/sync_fas_std_fault.php new file mode 100644 index 000000000..8f206a23c --- /dev/null +++ b/admin/sync/sync_fas_std_fault.php @@ -0,0 +1,48 @@ +FAS-Synchro mit TEMPUS fehlerhafte Studenten'; + $text.=''; + // Start Check + $sql_query="SELECT * FROM fas_view_student_vilesci WHERE uid NOT IN "; + $sql_query.="(SELECT uid FROM fas_view_student_vilesci WHERE semester >0 AND semester <8 AND"; + $sql_query.=" verband IS NOT NULL AND uid IS NOT NULL AND uid NOT LIKE '') ORDER BY kennzahl,nachname"; // LIMIT 5"; + //echo $sql_query."
"; + $result=pg_exec($conn_fas, $sql_query); + $num_rows=pg_numrows($result); + $num_fields=pg_numfields($result); + $text.="Dies ist eine automatische eMail!

"; + $text.="Es wurde eine Ueberpruefung der Daten in der FAS-View fuer Studenten durchgeführt.
"; + $text.="Anzahl der fehlerhaften Daten: $num_rows

"; + $text.="Folgende Studenten haben fehlerhafte Daten im FAS

"; + $text.=''; + $text.=''; + for ($i=0;$i<$num_rows;$i++) + { + $row=pg_fetch_object($result,$i); + $text.='"; + $text.=""; + } + $text.='
STG_KZuidTitelVornamenNachnameMatrikelnrSemesterVerbandGruppe
$row->kennzahl$row->uid$row->titel$row->vornamen$row->nachname$row->perskz$row->semester$row->verband$row->gruppe
'; + + echo $text; + + if (mail($adress,"FAS Synchro mit TEMPUS fehlerhafte Studenten",$text,$headers)) + echo 'Mail wurde verschickt an '.$adress.'!
'; + else + echo "Mail konnte nicht verschickt werden!
"; + +?> diff --git a/admin/sync/sync_feedback.php b/admin/sync/sync_feedback.php new file mode 100644 index 000000000..eeb64e80a --- /dev/null +++ b/admin/sync/sync_feedback.php @@ -0,0 +1,77 @@ +0) + return true; + return false; + } + + $qry = "SELECT * from lehre.tbl_feedback_lehrfach"; + $result = pg_exec($conn,$qry); + + echo "Uebernahme von tbl_feedback_lehrfach"; + flush(); + while($row=pg_fetch_object($result)) + { + $sql_qry = "Select * from tbl_lehrfach where studiengang_kz =$row->studiengang_kz AND semester=$row->semester AND lehrevz=$lehrfachzuteilung_kurzbz"; + + $lf_result=pg_exec($conn,$sql_qry); + if($lf_row=pg_fetch_object($conn,$qry)) + { + if(!isInTab($row->datum,$row->betreff,$row->text,$row->uid)) + { + $insert = "INSERT INTO tbl_feedback(datum,betreff,text,lfnr,uid) VALUES('$row->datum','$row->betreff','$row->text',$lf_row->lehrfach_nr,'$row->uid')"; + pg_exec($conn,$insert); + echo "+"; + flush(); + } + } + else + { + echo "Lehrfachaufloesung nicht moeglich"; //Oder Formular ausgeben + } + } + + $qry = "SELECT * from lehre.tbl_feedback_lehrfach"; + $result = pg_exec($conn,$qry); + + echo "Uebernahme von tbl_feedback_freifach"; + flush(); + while($row=pg_fetch_object($result)) + { + $sql_qry = "Select * from tbl_lehrfach where lehrevz=$lehrfachzuteilung_kurzbz AND studiengang_kz=0 AND semester is null"; + + $lf_result=pg_exec($conn,$sql_qry); + if($lf_row=pg_fetch_object($conn,$qry)) + { + $insert = "INSERT INTO tbl_feedback(datum,betreff,text,lfnr,uid) VALUES('$row->datum','$row->betreff','$row->text',$lf_row->lehrfach_nr,'$row->uid')"; + pg_exec($conn,$insert); + echo "+"; + flush(); + } + else + { + echo "Lehrfachaufloesung nicht moeglich"; //Oder Formular ausgeben + } + } + + + + +?> \ No newline at end of file diff --git a/admin/sync/sync_stpldev_stpl.php b/admin/sync/sync_stpldev_stpl.php new file mode 100644 index 000000000..4ee89ec08 --- /dev/null +++ b/admin/sync/sync_stpldev_stpl.php @@ -0,0 +1,406 @@ + + + + Stundenplan-Synchro (stpldev-stpl) + + +=now() ORDER BY start;"; +//echo $sql_query.'
'; +if (!$result=pg_query($conn, $sql_query)) +{ + echo $sql_query.' fehlgeschlagen!
'.pg_last_error($conn); + $message_sync.=$sql_query.' fehlgeschlagen!
'.pg_last_error($conn); +} +else +{ + if ($row=pg_fetch_object($result)) + $datum_ende=$row->ende; + else + $message_sync.='Kein aktuelles Studiensemester gefunden! '.$sql_query.'
'; +} + + + +$message_begin='Dies ist eine automatische Mail!
Es haben sich folgende Aenderungen in Ihrem Stundenplan ergeben:
'; + + +/************************************************** + * Datensaetze holen die neu sind + */ +echo 'Neue Datensätze werden angelegt.
';flush(); +$sql_query="SELECT * FROM vw_stundenplandev WHERE datum>='$datum_begin' AND datum<='$datum_ende' AND + stundenplandev_id NOT IN + (SELECT stundenplan_id FROM tbl_stundenplan WHERE datum>='$datum_begin');"; +//echo $sql_query.'
'; +if (!$result=pg_query($conn, $sql_query)) +{ + echo $sql_query.' fehlgeschlagen!
'.pg_last_error($conn); + $message_sync.=$sql_query.' fehlgeschlagen!
'.pg_last_error($conn); +} +else +{ + flush(); + while ($row=pg_fetch_object($result)) + { + $sql_query='INSERT INTO tbl_stundenplan + (stundenplan_id,unr,uid,datum,stunde,ort_kurzbz,lehrfach_nr,lehrform_kurzbz,studiengang_kz,semester,verband,gruppe, + einheit_kurzbz,titel,anmerkung,fix,updateamum,updatevon,lehrveranstaltung_id) VALUES'; + $sql_query.="($row->stundenplandev_id,$row->unr,'$row->uid','$row->datum',$row->stunde,'$row->ort_kurzbz', + $row->lehrfach_nr,'$row->lehrform',$row->studiengang_kz,$row->semester"; + if ($row->verband==null) + $sql_query.=',NULL'; + else + $sql_query.=",'$row->verband'"; + if ($row->gruppe==null) + $sql_query.=',NULL'; + else + $sql_query.=",'$row->gruppe'"; + if ($row->einheit_kurzbz==null) + $sql_query.=',NULL'; + else + $sql_query.=",'$row->einheit_kurzbz'"; + $sql_query.=",'$row->titel','$row->anmerkung'"; + if ($row->fix=='t') + $sql_query.=',TRUE'; + else + $sql_query.=',FALSE'; + $sql_query.=",'$row->updateamum','$row->updatevon'"; + if ($row->lehrveranstaltung_id==null) + $sql_query.=',NULL'; + else + $sql_query.=",$row->lehrveranstaltung_id"; + $sql_query.=');'; + //echo $sql_query; + if (!$result_insert=pg_query($conn, $sql_query)) + { + echo $sql_query.' fehlgeschlagen!
'.pg_last_error($conn); + $message_sync.=$sql_query.' fehlgeschlagen!
'.pg_last_error($conn); + $count_err++; + } + else + { + $count_ins++; + if ($count_ins%10==0) + { + echo '-'; + flush(); + } + // Mails vorbereiten + // Lektoren + if (substr($row->uid,0,1)!='_') + { + if (!isset($message[$row->uid]->isneu)); + { + $message[$row->uid]->isneu=true; + $message[$row->uid]->mailadress=$row->uid.'@technikum-wien.at'; + $message[$row->uid]->message=$message_begin.'
Neue Stunden:
+ '; + } + $message[$row->uid]->message.=''; + $message[$row->uid]->message.=''; + $message[$row->uid]->message.=''; + $message[$row->uid]->message.=''; + $message[$row->uid]->message.=''; + } + // Verband + $verband=$row->stg_kurzbz.$row->semester.$row->verband.$row->gruppe; + $verband=trim($verband); + $verband=strtolower($verband); + if (!isset($message[$verband]->isneu)); + { + $message[$verband]->isneu=true; + $message[$verband]->mailadress=$verband.'@technikum-wien.at'; + $message[$verband]->message=$message_begin.'
Neue Stunden:
+
OrtVerbandLektorDatum/StdLehrfach
'.$row->ort_kurzbz.''.$row->stg_kurzbz.'-'.$row->semester.$row->verband.$row->gruppe.' '.$row->einheit_kurzbz.''.$row->lektor.''.$row->datum.'/'.$row->stunde.''.$row->lehrfach.'-'.$row->lehrform.' ('.$row->lehrfach_bez.')
'; + } + $message[$verband]->message.=''; + $message[$verband]->message.=''; + $message[$verband]->message.=''; + $message[$verband]->message.=''; + $message[$verband]->message.=''; + } + } + foreach($message as $msg) + if($msg->isneu) + $msg->message.='
OrtVerbandLektorDatum/StdLehrfach
'.$row->ort_kurzbz.''.$row->stg_kurzbz.'-'.$row->semester.$row->verband.$row->gruppe.' '.$row->einheit_kurzbz.''.$row->lektor.''.$row->datum.'/'.$row->stunde.''.$row->lehrfach.'-'.$row->lehrform.' ('.$row->lehrfach_bez.')
'; +} + +/************************************************** +* Datensaetze holen die alt sind +*/ + +echo '
Alte Datensätze werden gelöscht.
';flush(); +$sql_query="SELECT * FROM vw_stundenplan WHERE stundenplan_id NOT IN + (SELECT stundenplandev_id FROM tbl_stundenplandev WHERE datum>='$datum_begin') + AND datum>='$datum_begin';"; +if (!$result=pg_query($conn, $sql_query)) +{ + echo $sql_query.' fehlgeschlagen!
'.pg_last_error($conn); + $message_sync.=$sql_query.' fehlgeschlagen!
'.pg_last_error($conn); +} +while ($row=pg_fetch_object($result)) +{ + $sql_query='DELETE FROM tbl_stundenplan WHERE stundenplan_id='.$row->stundenplan_id; + //echo $sql_query.'
'; + if (!$result_delete=pg_query($conn, $sql_query)) + { + echo $sql_query.' fehlgeschlagen!
'.pg_last_error($conn); + $message_sync.=$sql_query.' fehlgeschlagen!
'.pg_last_error($conn); + $count_err++; + } + else + { + $count_del++; + if ($count_del%10==0) + { + echo '-'; + flush(); + } + // Mails vorbereiten + // Lektoren + if (substr($row->uid,0,1)!='_') + { + if (!isset($message[$row->uid]->isalt)); + { + $message[$row->uid]->isalt=true; + $message[$row->uid]->mailadress=$row->uid.'@technikum-wien.at'; + $message[$row->uid]->message.=$message_begin.'
Gelöeschte Stunden:
+ '; + } + $message[$row->uid]->message.=''; + $message[$row->uid]->message.=''; + $message[$row->uid]->message.=''; + $message[$row->uid]->message.=''; + $message[$row->uid]->message.=''; + } + // Verband + $verband=$row->stg_kurzbz.$row->semester.$row->verband.$row->gruppe; + $verband=trim($verband); + $verband=strtolower($verband); + if (!isset($message[$verband]->isalt)); + { + $message[$verband]->isalt=true; + $message[$verband]->mailadress=$verband.'@technikum-wien.at'; + $message[$verband]->message.=$message_begin.'
Geaenderte Stunden:
+
OrtVerbandLektorDatum/StdLehrfach
'.$row->ort_kurzbz.''.$row->stg_kurzbz.'-'.$row->semester.$row->verband.$row->gruppe.' '.$row->einheit_kurzbz.''.$row->lektor.''.$row->datum.'/'.$row->stunde.''.$row->lehrfach.'-'.$row->lehrform.' ('.$row->lehrfach_bez.')
'; + } + $message[$verband]->message.=''; + $message[$verband]->message.=''; + $message[$verband]->message.=''; + $message[$verband]->message.=''; + $message[$verband]->message.=''; + } + foreach($message as $msg) + if($msg->isalt) + $msg->message.='
OrtVerbandLektorDatum/StdLehrfach
'.$row->ort_kurzbz.''.$row->stg_kurzbz.'-'.$row->semester.$row->verband.$row->gruppe.' '.$row->einheit_kurzbz.''.$row->lektor.''.$row->datum.'/'.$row->stunde.''.$row->lehrfach.'-'.$row->lehrform.' ('.$row->lehrfach_bez.')
'; +} + + +/************************************************** + * Datensaetze holen die anders sind + */ + +echo '
Datensätze werden geändert.
';flush(); +$sql_query="SELECT vw_stundenplandev.*, vw_stundenplan.datum AS old_datum, vw_stundenplan.stunde AS old_stunde, + vw_stundenplan.ort_kurzbz AS old_ort_kurzbz, vw_stundenplan.lektor AS old_lektor + FROM vw_stundenplandev, vw_stundenplan + WHERE vw_stundenplan.stundenplan_id=vw_stundenplandev.stundenplandev_id AND ( + vw_stundenplandev.unr!=vw_stundenplan.unr OR + vw_stundenplandev.uid!=vw_stundenplan.uid OR + vw_stundenplandev.datum!=vw_stundenplan.datum OR + vw_stundenplandev.stunde!=vw_stundenplan.stunde OR + vw_stundenplandev.ort_kurzbz!=vw_stundenplan.ort_kurzbz OR + vw_stundenplandev.lehrfach_nr!=vw_stundenplan.lehrfach_nr OR + vw_stundenplandev.lehrform!=vw_stundenplan.lehrform OR + vw_stundenplandev.studiengang_kz!=vw_stundenplan.studiengang_kz OR + vw_stundenplandev.semester!=vw_stundenplan.semester OR + vw_stundenplandev.verband!=vw_stundenplan.verband OR + vw_stundenplandev.gruppe!=vw_stundenplan.gruppe OR + vw_stundenplandev.einheit_kurzbz!=vw_stundenplan.einheit_kurzbz OR + vw_stundenplandev.titel!=vw_stundenplan.titel OR + vw_stundenplandev.anmerkung!=vw_stundenplan.anmerkung OR + vw_stundenplandev.fix!=vw_stundenplan.fix OR + vw_stundenplandev.lehrveranstaltung_id!=vw_stundenplan.lehrveranstaltung_id ) + AND vw_stundenplandev.datum>='$datum_begin';"; +//echo $sql_query.'
'; +if (!$result=pg_query($conn, $sql_query)) +{ + echo $sql_query.' fehlgeschlagen!
'.pg_last_error($conn); + $message_sync.=$sql_query.' fehlgeschlagen!
'.pg_last_error($conn); +} +while ($row=pg_fetch_object($result)) +{ + // Alten Eintrag aus tbl_stundenplan holen + $sql_query="SELECT * FROM tbl_stundenplandev WHERE stundenplandev_id=$row->stundenplandev_id;"; + if (!$result_old=pg_query($conn, $sql_query)) + { + echo $sql_query.' fehlgeschlagen!
'.pg_last_error($conn); + $message_sync.=$sql_query.' fehlgeschlagen!
'.pg_last_error($conn); + } + else + $row_old=pg_fetch_object($result_old); + + // Datensaetze aendern + $sql_query="UPDATE tbl_stundenplan SET + unr=$row->unr,uid='$row->uid',datum='$row->datum',stunde=$row->stunde, + ort_kurzbz='$row->ort_kurzbz',lehrfach_nr=$row->lehrfach_nr, lehrform_kurzbz='$row->lehrform', + studiengang_kz=$row->studiengang_kz,semester=$row->semester"; + if ($row->verband==null) + $sql_query.=',verband=NULL'; + else + $sql_query.=",verband='$row->verband'"; + if ($row->gruppe==null) + $sql_query.=',gruppe=NULL'; + else + $sql_query.=",gruppe='$row->gruppe'"; + if ($row->einheit_kurzbz==null) + $sql_query.=',einheit_kurzbz=NULL'; + else + $sql_query.=",einheit_kurzbz='$row->einheit_kurzbz'"; + $sql_query.=",titel='$row->titel',anmerkung='$row->anmerkung'"; + if ($row->fix=='t') + $sql_query.=',fix=TRUE'; + else + $sql_query.=',fix=FALSE'; + $sql_query.=",updateamum='$row->updateamum',updatevon='$row->updatevon'"; + if ($row->lehrveranstaltung_id==null) + $sql_query.=',lehrveranstaltung_id=NULL'; + else + $sql_query.=",lehrveranstaltung_id=$row->lehrveranstaltung_id"; + $sql_query.=" WHERE stundenplan_id=$row->stundenplandev_id;"; + echo $sql_query.'
'; + if (!$result_update=pg_query($conn, $sql_query)) + { + echo $sql_query.' fehlgeschlagen!
'.pg_last_error($conn); + $message_sync.=$sql_query.' fehlgeschlagen!
'.pg_last_error($conn); + $count_err++; + } + else + { + $count_upd++; + if ($count_upd%10==0) + { + echo '-'; + flush(); + } + // Mails vorbereiten + // Lektoren + if (substr($row->uid,0,1)!='_') + { + if (!isset($message[$row->uid]->isset)); + { + $message[$row->uid]->isset=true; + $message[$row->uid]->mailadress=$row->uid.'@technikum-wien.at'; + $message[$row->uid]->message.=$message_begin.'
Geänderte Stunden:
+ '; + } + $message[$row->uid]->message.=''; + $message[$row->uid]->message.=''; + $message[$row->uid]->message.=''; + $message[$row->uid]->message.=''; + $message[$row->uid]->message.=''; + + $message[$row->uid]->message.=''; + $message[$row->uid]->message.=''; + $message[$row->uid]->message.=''; + $message[$row->uid]->message.=''; + $message[$row->uid]->message.=''; + } + // Verband + $verband=$row->stg_kurzbz.$row->semester.$row->verband.$row->gruppe; + $verband=trim($verband); + $verband=strtolower($verband); + if (!isset($message[$verband]->isset)); + { + $message[$verband]->isset=true; + $message[$verband]->mailadress=$verband.'@technikum-wien.at'; + $message[$verband]->message.=$message_begin.'
Geänderte Stunden:
+
StatusOrtVerbandLektorDatum/StdLehrfach
Vorher: '.$row->old_ort_kurzbz.''.$row->stg_kurzbz.'-'.$row->semester.$row->verband.$row->gruppe.' '.$row->einheit_kurzbz.''.$row->old_lektor.''.$row->old_datum.'/'.$row->old_stunde.''.$row->lehrfach.'-'.$row->lehrform.' ('.$row->lehrfach_bez.')
Jetzt: '.$row->ort_kurzbz.''.$row->stg_kurzbz.'-'.$row->semester.$row->verband.$row->gruppe.' '.$row->einheit_kurzbz.''.$row->lektor.''.$row->datum.'/'.$row->stunde.''.$row->lehrfach.'-'.$row->lehrform.' ('.$row->lehrfach_bez.')
'; + } + $message[$verband]->message.=''; + $message[$verband]->message.=''; + $message[$verband]->message.=''; + $message[$verband]->message.=''; + $message[$verband]->message.=''; + + $message[$verband]->message.=''; + $message[$verband]->message.=''; + $message[$verband]->message.=''; + $message[$verband]->message.=''; + $message[$verband]->message.=''; + } + foreach($message as $msg) + if($msg->isset) + $msg->message.='
StatusOrtVerbandLektorDatum/StdLehrfach
Vorher: '.$row->old_ort_kurzbz.''.$row->stg_kurzbz.'-'.$row->semester.$row->verband.$row->gruppe.' '.$row->einheit_kurzbz.''.$row->old_lektor.''.$row->old_datum.'/'.$row->old_stunde.''.$row->lehrfach.'-'.$row->lehrform.' ('.$row->lehrfach_bez.')
Jetzt: '.$row->ort_kurzbz.''.$row->stg_kurzbz.'-'.$row->semester.$row->verband.$row->gruppe.' '.$row->einheit_kurzbz.''.$row->lektor.''.$row->datum.'/'.$row->stunde.''.$row->lehrfach.'-'.$row->lehrform.' ('.$row->lehrfach_bez.')
'; +} + +/************************************************** + * Mails an Lektoren und Verbaende schicken + */ +if ($sendmail) + foreach ($message as $msg) + //if (mail('pam@technikum-wien.at',"Stundenplan update",$msg->message,$headers."From: stpl@technikum-wien.at")) + if (mail($msg->mailadress,"Stundenplan update",$msg->message,$headers."From: stpl@technikum-wien.at")) + { + echo 'Mail an '.$msg->mailadress.' wurde verschickt!
'; + $message_stpl.='Mail an '.$msg->mailadress.' wurde verschickt!
'; + } + else + { + echo 'Mail an '.$msg->mailadress.' konnte nicht verschickt werden!
'; + $message_sync.='Mail an '.$msg->mailadress.' konnte ***nicht*** verschickt werden!
'; + } +// Mail an Admin +$message_tmp=$count_upd.' Datensätze wurden geändert.
+ '.$count_ins.' Datensätze wurden hinzugefügt.
+ '.$count_del.' Datensätze wurden gelöscht.
+ '.$count_err.' Fehler sind dabei aufgetreten!

'; +echo '
'.$message_tmp; +$message_sync=''.$message_tmp.$message_sync.$message_stpl.''; +mail('pam@technikum-wien.at',"Stundenplan update",$message_sync,$headers."From: stpl@technikum-wien.at"); +$message_stpl=''.$message_tmp.$message_stpl.''; +mail('stpl@technikum-wien.at',"Stundenplan update",$message_stpl,$headers."From: stpl@technikum-wien.at"); +?> + + diff --git a/admin/sync/sync_vilesci_stg.php b/admin/sync/sync_vilesci_stg.php new file mode 100644 index 000000000..ed1ef081b --- /dev/null +++ b/admin/sync/sync_vilesci_stg.php @@ -0,0 +1,594 @@ +lvnr.' '.$row->bezeichnung; +} + +function getSemesterWhereClause() +{ + global $conn; + $qry="select * from tbl_studiensemester where ende>now()"; + $result=pg_exec($conn, $qry); + $where=''; + while ($row=pg_fetch_object($result)) + { + $where.= ((strlen($where)>0)?' or ':'')."studiensemester_kurzbz='".$row->studiensemester_kurzbz."' "; + } + if (strlen($where)>0) $where=" ($where) "; + return $where; +} + +function validate($row) +{ + global $error_log,$einheit,$missing_einheit,$missing_raumtyp,$missing_lehrform,$raumtyp,$lehrform; + $valid=true; + if ($row->raumtyp==null) + { + $error_log[$row->studiengang_kz][]=printLVA($row).': Raumtyp fehlt'; + $valid=false; + } + if ($row->semester>8 || $row->semester<1) + { + $error_log[$row->studiengang_kz][]=printLVA($row).': Semester bei '.$row->semester.$row->verband.$row->gruppe.' größer als 8'; + $valid=false; + } + if (!($row->verband==null || $row->verband=='' || $row->verband=='A' || $row->verband=='B' || $row->verband=='C' || $row->verband=='D')) + { + $error_log[$row->studiengang_kz][]=printLVA($row).': Verband bei '.$row->semester.$row->verband.$row->gruppe.' außerhalb des gültigen Bereichs (A bis D)'; + //print_r($row); + $valid=false; + } + if (!($row->gruppe==null || $row->gruppe=='' || $row->gruppe=='1' || $row->gruppe=='2' || $row->gruppe=='3' || $row->gruppe=='4')) + { + $error_log[$row->studiengang_kz][]=printLVA($row).': Gruppe bei '.$row->semester.$row->verband.$row->gruppe.' außerhalb des gültigen Bereichs (1 bis 4)'; + $valid=false; + } + if (!$row->stundenblockung>0) { + $error_log[$row->studiengang_kz][]=printLVA($row).': Stundenblockung ist nicht größer 0'; + $valid=false; + } + if (!$row->semesterstunden>0) { + $error_log[$row->studiengang_kz][]=printLVA($row).': Semesterstunden sind nicht größer 0'; + $valid=false; + } + if (!$row->wochenrythmus>0) + { + $error_log[$row->studiengang_kz][]=printLVA($row).': Wochenrythmus ist nicht größer 0'; + $valid=false; + } + if ($row->start_kw<=0 || $row->start_kw>53) + { + $error_log[$row->studiengang_kz][]=printLVA($row).': Start-KW außerhalb des gültigen Bereichs (1 bis 53)'; + $valid=false; + } + if (strlen($row->einheit_kurzbz)>0 && !isset($einheit[$row->einheit_kurzbz]) && !isset($missing_einheit[$row->einheit_kurzbz])) + { + $missing_einheit[$row->einheit_kurzbz]=1; + } + if (strlen($row->raumtyp)>0 && !isset($raumtyp[$row->raumtyp]) && !isset($missing_raumtyp[$row->raumtyp])) + { + $missing_raumtyp[$row->raumtyp]=1; + $valid=false; + } + if (strlen($row->raumtypalternativ)>0 && !isset($raumtyp[$row->raumtypalternativ]) && !isset($missing_raumtyp[$row->raumtypalternativ])) { + $missing_raumtyp[$row->raumtypalternativ]=1; + } + if (!ereg("^[A-Za-z]{1,5}[0-9]{0,1}$",$row->raumtyp)) + { + $error_log[$row->studiengang_kz][]=$row->raumtyp.': Raumtyp bei LVNR:'.$row->lvnr.' ist nicht plausibel.'; + $valid=false; + } + if (!ereg("^[A-Za-z]{1,5}[0-9]{0,1}$",$row->raumtypalternativ)) + { + $error_log[$row->studiengang_kz][]=$row->raumtypalternativ.': Raumtypalternative bei LVNR:'.$row->lvnr.' ist nicht plausibel.'; + $valid=false; + } + if (strlen($row->lehrform)>0 && !isset($lehrform[$row->lehrform]) && !isset($missing_lehrform[$row->lehrform])) { + $missing_lehrform[$row->lehrform]=1; + } + if (!ereg("^[A-Z]{1,5}[0-9]{0,1}$",$row->lehrfach_kurzbz)) + { + $error_log[$row->studiengang_kz][]=$row->lehrfach_kurzbz.'-'.$row->lehrform.'/'.$row->studiengang_kz.'-'.$row->semester.': Lehrfach-Kuerzel bei LVNR:'.$row->lvnr.' ist nicht plausibel.'; + $valid=false; + } + if (!ereg("^[A-Z]{1,3}$",$row->lehrform)) + { + $error_log[$row->studiengang_kz][]=$row->lehrfach_kurzbz.'-'.$row->lehrform.'/'.$row->studiengang_kz.'-'.$row->semester.': Lehrform bei LVNR:'.$row->lvnr.' ist nicht plausibel.'; + $valid=false; + } + return $valid; +} + +/** + * FAS-Lehrfach auf interne Lehrfach-Nr übersetzen + */ +function getLehrfachNr($kurzbz,$studiengang_kz,$semester,$lehrfach_bezeichnung, $fachbereich_id, $ects, $conn) +{ + global $lehrfach; + global $text; + + if (isset($lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['lehrfach_nr'])) + { + //echo 'Nummer:'.$lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['lehrfach_nr'].'Bez: '.$lehrfach_bezeichnung.'
'; + + // Nebenbei die Lehrfachbezeichnung kontrollieren + if ($lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['lehrfach_bezeichnung']!=$lehrfach_bezeichnung) + { + // Update + $qry="UPDATE tbl_lehrfach SET bezeichnung='$lehrfach_bezeichnung' WHERE lehrfach_nr=".$lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['lehrfach_nr']; + if (!$result=pg_query($conn, $qry)) + echo $qry.' fehlgeschlagen!
'; + else + { + echo 'Lehrfach '.$kurzbz.'/'.$studiengang_kz.'/'.$semester.' wurde von '.$lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['lehrfach_bezeichnung'].' auf '.$lehrfach_bezeichnung.' geaendert!
'; + $text.='Lehrfach '.$kurzbz.'/'.$studiengang_kz.'/'.$semester.' wurde von '.$lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['lehrfach_bezeichnung'].' auf '.$lehrfach_bezeichnung.' geaendert!\n'; + $lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['lehrfach_bezeichnung']=$lehrfach_bezeichnung; + } + } + + // Nebenbei die ECTS Punkte kontrollieren + if ($lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['ects']!=$ects) + { + if ($ects!='') //ereg("[0-9]{1,4}[\.|,][0-9]{0,2}$",$ects) + { + // Update + $qry="UPDATE tbl_lehrfach SET ects='$ects' WHERE lehrfach_nr=".$lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['lehrfach_nr']; + //echo $qry.'
'; + if (!$result=pg_query($conn, $qry)) + echo $qry.' fehlgeschlagen!
'; + else + { + echo ' Bei Lehrfach '.$kurzbz.'/'.$studiengang_kz.'/'.$semester.' wurden die ECTS-Punkte von '.$lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['ects'].' auf '.$ects.' geaendert!
'; + $text.='Bei Lehrfach '.$kurzbz.'/'.$studiengang_kz.'/'.$semester.' wurden die ECTS-Punkte von '.$lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['ects'].' auf '.$ects.' geaendert!\n'; + $lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['ects']=$ects; + } + } + else + { + echo 'Bei Lehrfach '.$kurzbz.'/'.$studiengang_kz.'/'.$semester.' sind die ECTS-Punkte von '.$ects.' nicht Plausibel!
'; + $text.='Bei Lehrfach '.$kurzbz.'/'.$studiengang_kz.'/'.$semester.' sind die ECTS-Punkte von '.$ects.' nicht Plausibel!\n'; + } + + } + + // Nebenbei die FachbereichID kontrollieren + if ($lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['fachbereich_id']!=$fachbereich_id) + { + // Update + $qry="UPDATE tbl_lehrfach SET fachbereich_id=$fachbereich_id WHERE lehrfach_nr=".$lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['lehrfach_nr']; + if (!$result=@pg_query($conn, $qry)) + echo $qry.' fehlgeschlagen!
'; + else + { + echo 'Bei Lehrfach '.$kurzbz.'/'.$studiengang_kz.'/'.$semester.' wurde die FachbereichID von '.$lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['fachbereich_id'].' auf '.$fachbereich_id.' geaendert!
'; + $text.='Bei Lehrfach '.$kurzbz.'/'.$studiengang_kz.'/'.$semester.' wurde die FachbereichID von '.$lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['fachbereich_id'].' auf '.$fachbereich_id.' geaendert!\n'; + $lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['fachbereich_id']=$fachbereich_id; + } + } + return $lehrfach[$kurzbz.'/'.$studiengang_kz.'/'.$semester]['lehrfach_nr']; + } + //echo 'missing getLehrfachNr: '.$kurzbz.'/'.$studiengang_kz.'/'.$semester.'
'; + return -1; +} + + +/************************* + * FAS-Synchronisation + */ + +// E-Mails der Studiengänge +$stg_mail=array(); +$qry="select studiengang_kz,email,kurzbz from tbl_studiengang"; +$result=pg_exec($conn, $qry); +while ($row=pg_fetch_object($result)) +{ + $stg_mail[$row->studiengang_kz] = $row->email; + $stg_kurzbz[$row->studiengang_kz]=$row->kurzbz; +} + +// Anzahl der LVA in VileSci +$sql_query="SELECT count(*) AS anz FROM tbl_lehrveranstaltung"; +//echo $sql_query."
"; +$result=pg_exec($conn, $sql_query); +$vil_anz_lva=pg_fetch_result($result,0,'anz'); + +// Lehrfächer holen und in Array speichern (Key ist kurzbz + '/' + lehform_kurzbz) +$sql_query="SELECT lehrfach_nr,kurzbz,studiengang_kz,semester, bezeichnung, fachbereich_id, ects FROM tbl_lehrfach"; +$result=pg_exec($conn, $sql_query); +while ($row=pg_fetch_object($result)) +{ + $lehrfach[$row->kurzbz.'/'.$row->studiengang_kz.'/'.$row->semester]['lehrfach_nr'] = $row->lehrfach_nr; + $lehrfach[$row->kurzbz.'/'.$row->studiengang_kz.'/'.$row->semester]['fachbereich_id'] = $row->fachbereich_id; + $lehrfach[$row->kurzbz.'/'.$row->studiengang_kz.'/'.$row->semester]['lehrfach_bezeichnung'] = $row->bezeichnung; + $lehrfach[$row->kurzbz.'/'.$row->studiengang_kz.'/'.$row->semester]['ects'] = $row->ects; +} +//print_r($lehrfach); +// Einheiten holen +$sql_query="SELECT einheit_kurzbz,bezeichnung FROM tbl_einheit"; +$result=pg_exec($conn, $sql_query); +while ($row=pg_fetch_object($result)) + $einheit[$row->einheit_kurzbz] = $row->bezeichnung; +// Raumtypen holen +$sql_query="SELECT raumtyp_kurzbz,beschreibung FROM tbl_raumtyp"; +$result=pg_exec($conn, $sql_query); +while ($row=pg_fetch_object($result)) + $raumtyp[$row->raumtyp_kurzbz] = $row->beschreibung; +// Lehformen holen +$sql_query="SELECT lehrform_kurzbz,bezeichnung FROM tbl_lehrform"; +$result=pg_exec($conn, $sql_query); +while ($row=pg_fetch_object($result)) + $lehrform[$row->lehrform_kurzbz] = $row->bezeichnung; +//print_r($lehrfach); +echo 'FAS-Datenbank wird abgefragt!
'; +flush(); + +// Start Lehrveranstaltungen Synchro +$sql_query="SELECT DISTINCT fas_id,trim(lvnr) AS lvnr,trim(unr)::int8 AS unr,einheit_kurzbz,lektor,trim(upper(lehrfach_kurzbz)) AS lehrfach_kurzbz, + trim(upper(lehrform)) AS lehrform, lehrfach_bezeichnung, + studiengang_kz,fachbereich_id,semester,verband,gruppe,raumtyp,raumtypalternativ, + round(semesterstunden) AS semesterstunden,stundenblockung,wochenrythmus,start_kw,anmerkung,studiensemester_kurzbz, ects + FROM fas_view_alle_lehreinheiten_vilesci ". + "where ".getSemesterWhereClause(); +//echo $sql_query."
"; +$result=pg_exec($conn_fas, $sql_query); +$num_rows=pg_numrows($result); +$text="Dies ist eine automatische eMail!\r\r"; +$text.="Es wurde eine Synchronisation mit FAS durchgeführt.\r"; +$text.="Anzahl der LVA vom FAS-Import: $num_rows \r"; +$text.="Anzahl der LVA in der VileSci: $vil_anz_lva \r\r"; +$plausi_error=0; +$update_error=0; +$insert_error=0; +$double_error=0; +$anz_update=0; +$anz_insert=0; +echo $num_rows.' Datensaetze
'; +for ($i=0;$i<$num_rows;$i++) +{ + if ($i%100==0) + { + echo '-'; + flush(); + } + $row=pg_fetch_object($result,$i); + // Kennzahl der Studiengangs bei ehemaligen bTec auf TW aendern. + if ($row->studiengang_kz==203) + $row->studiengang_kz=0; + // Lehrfach-Nr übersetzen (-1 wenn nicht vorhanden) + $row->lehrfach_nr=getLehrfachNr($row->lehrfach_kurzbz,$row->studiengang_kz,$row->semester, $row->lehrfach_bezeichnung, $row->fachbereich_id, $row->ects, $conn); + // Einheit vollstaendiger Name + if (count($row->einheit_kurzbz)>0) + $row->einheit_kurzbz=$stg_kurzbz[$row->studiengang_kz].'-'.$row->einheit_kurzbz; + + // Plausibilitaetscheck + //if ($row->gruppe==NULL) + // $row->gruppe='1'; + + // + if (!$row->stundenblockung>0) + $row->stundenblockung=1; + if (!$row->start_kw>0) + $row->start_kw=1; + if (!$row->wochenrythmus>0) + $row->wochenrythmus=1; + + if ($row->lehrfach_nr==-1) + { + //$error_log[$row->studiengang_kz][]=printLVA($row).': Lehrfach (Kurzbz='".$row->lehrfach_kurzbz."',Lehrform".$row->lehrform) existiert noch nicht. Stundenplanabteilung wurde benachrichtigt.'; + if (!isset($missing_lehrfaecher[$row->lehrfach_kurzbz.'/'.$row->studiengang_kz.'/'.$row->semester])) $missing_lehrfaecher[$row->lehrfach_kurzbz.'/'.$row->studiengang_kz.'/'.$row->semester]=1; + $valid=false; + } + + if (validate($row) && $row->lehrfach_nr>-1) + { + // SQL vorbereiten (jede LVA vom FAS im VileSci suchen) + $sql_query="SELECT * from tbl_lehrveranstaltung where fas_id=".$row->fas_id; + //echo $sql_query; + $res_lva=pg_query($conn, $sql_query); + $num_rows_lva=pg_numrows($res_lva); + + // neue LVA + if ($num_rows_lva==0) + { + $text.="Die LVA fas-id=$row->fas_id lvnr=$row->lvnr unr=$row->unr wird neu angelegt.\r"; + $sql_query="INSERT INTO tbl_lehrveranstaltung (lvnr,unr,einheit_kurzbz,lektor,lehrfach_nr,lehrform_kurzbz,"; + $sql_query.="studiengang_kz,fachbereich_id,semester,verband,gruppe,raumtyp,". + "raumtypalternativ,semesterstunden,stundenblockung,". + "wochenrythmus,start_kw,studiensemester_kurzbz,fas_id,anmerkung) ". + "VALUES('$row->lvnr'". + ",$row->unr,". + (strlen($row->einheit_kurzbz)>0?"'".$row->einheit_kurzbz."'":'NULL').",". + "'$row->lektor',". + "'$row->lehrfach_nr',". + "'$row->lehrform',". + "'$row->studiengang_kz',". + "$row->fachbereich_id,". + "$row->semester,"; + if ($row->verband==null) + $sql_query.='NULL,'; + else + $sql_query.="'$row->verband',"; + if ($row->gruppe==null) + $sql_query.='NULL,'; + else + $sql_query.="'$row->gruppe',"; + $sql_query.="'$row->raumtyp',". + "'$row->raumtypalternativ',". + "$row->semesterstunden,". + "$row->stundenblockung,". + "$row->wochenrythmus,". + "$row->start_kw,". + "'$row->studiensemester_kurzbz'," . + "$row->fas_id,'$row->anmerkung')"; + //echo $sql_query.'
'; + if(!$res_insert=@pg_exec($conn, $sql_query)) + { + $text.=$sql_query; + $text.="\nFehler: ".pg_errormessage($conn)."\n"; + $insert_error++; + } + else + $anz_insert++; + } + // bestehende LVA + elseif ($num_rows_lva==1) + { + $update_sql=''; + $row_lva=pg_fetch_object($res_lva,0); + //var_dump($row_lva); + //if ($row->gruppe==NULL) + // $row->gruppe=1; + //echo '-'.$row->lvnr.'-'.$row_lva->lvnr.'-
'; + if ($row->lvnr!=$row_lva->lvnr) + $update_sql.="lvnr='".$row->lvnr."'"; + elseif ($row->unr!=$row_lva->unr) + $update_sql.="unr=".$row->unr; + elseif ($row->einheit_kurzbz!=$row_lva->einheit_kurzbz) + $update_sql.=(strlen($update_sql)>0?',':'').'einheit_kurzbz='.(strlen($row->einheit_kurzbz)>0?"'".$row->einheit_kurzbz."'":'NULL'); + elseif ($row->lektor!=$row_lva->lektor) + $update_sql.=(strlen($update_sql)>0?',':'')."lektor='".$row->lektor."'"; + elseif ($row->lehrfach_nr!=$row_lva->lehrfach_nr) + $update_sql.=(strlen($update_sql)>0?',':'')."lehrfach_nr=".$row->lehrfach_nr; + elseif ($row->lehrform!=$row_lva->lehrform_kurzbz) + $update_sql.=(strlen($update_sql)>0?',':'')."lehrform_kurzbz='".$row->lehrform."'"; + elseif ($row->studiengang_kz!=$row_lva->studiengang_kz) + $update_sql.=(strlen($update_sql)>0?',':'')."studiengang_kz=".$row->studiengang_kz; + elseif ($row->fachbereich_id!=$row_lva->fachbereich_id) + $update_sql.=(strlen($update_sql)>0?',':'')."fachbereich_id=".$row->fachbereich_id; + elseif ($row->semester!=$row_lva->semester) + $update_sql.=(strlen($update_sql)>0?',':'')."semester=".$row->semester; + elseif ($row->verband!=$row_lva->verband) + $update_sql.=(strlen($update_sql)>0?',':'')."verband=".(strlen($row->verband)>0?"'".$row->verband."'":'NULL'); + elseif ($row->gruppe!=$row_lva->gruppe) + $update_sql.=(strlen($update_sql)>0?',':'')."gruppe=".(strlen($row->gruppe)>0?"'".$row->gruppe."'":'NULL'); + elseif ($row->raumtyp!=$row_lva->raumtyp) + $update_sql.=(strlen($update_sql)>0?',':'')."raumtyp='".$row->raumtyp."'"; + elseif ($row->raumtypalternativ!=$row_lva->raumtypalternativ) + $update_sql.=(strlen($update_sql)>0?',':'')."raumtypalternativ='".$row->raumtypalternativ."'"; + elseif ($row->semesterstunden!=$row_lva->semesterstunden) + $update_sql.=(strlen($update_sql)>0?',':'')."semesterstunden=".$row->semesterstunden; + elseif ($row->stundenblockung!=$row_lva->stundenblockung) + $update_sql.=(strlen($update_sql)>0?',':'')."stundenblockung=".$row->stundenblockung; + elseif ($row->wochenrythmus!=$row_lva->wochenrythmus) + $update_sql.=(strlen($update_sql)>0?',':'')."wochenrythmus=".$row->wochenrythmus; + elseif ($row->start_kw!=$row_lva->start_kw) + $update_sql.=(strlen($update_sql)>0?',':'')."start_kw=".(strlen($row->start_kw)>0?$row->start_kw:'NULL'); + elseif ($row->studiensemester_kurzbz!=$row_lva->studiensemester_kurzbz) + $update_sql.=(strlen($update_sql)>0?',':'')."studiensemester_kurzbz='".$row->studiensemester_kurzbz."'"; + elseif ($row->anmerkung!=$row_lva->anmerkung) + $update_sql.=(strlen($update_sql)>0?',':'')."anmerkung='".$row->anmerkung."'"; + + if (strlen($update_sql)>0) + { + $text.="Die LVA fas-id=$row->fas_id lvnr=$row->lvnr unr=$row->unr wird upgedatet.\r"; + $sql_query="UPDATE tbl_lehrveranstaltung SET ". + $update_sql. + " where fas_id=".$row->fas_id; + + //echo $sql_query.'
'; + if(!$res_update=@pg_query($conn, $sql_query)) + { + $text.=$sql_query; + $text.="\rFehler: ".pg_errormessage($conn)."\r"; + $update_error++; + } + else + $anz_update++; + + // **************** + // Auch in tbl_stundenplandev updaten + $sql_query="SELECT * FROM tbl_stundenplandev WHERE + lehrveranstaltung_id=$row_lva->lehrveranstaltung_id AND datum>=now()"; + //echo $sql_query.'
'; + if(!$res_upd_stpl=@pg_query($conn, $sql_query)) + { + $text.=$sql_query; + $text.="\rFehler: ".pg_errormessage($conn)."\r"; + } + else + { + if (!pg_query($conn,"BEGIN;")) + $text.="\rFehler: ".pg_errormessage($conn)."\r"; + $kollision=false; + while ($row_upd_stpl=pg_fetch_object($res_upd_stpl)) + { + // Lehrstunde auf Kollisionen checken + $lehrstunde=new lehrstunde($conn); + //echo '
STPL-ID:'.$row_upd_stpl->stundenplandev_id.'
'; + if (!$lehrstunde->load($row_upd_stpl->stundenplandev_id)) + echo $lehrstunde->errormsg; + $lehrstunde->lektor_uid=$row->lektor; + if (!$lehrstunde->kollision()) + { + if (!$lehrstunde->save('sync_fas_lva')) + echo $lehrstunde->errormsg; + } + else + { + $error_log[$row->studiengang_kz][]=$lehrstunde->errormsg; + $text.="\rKollision: ".$lehrstunde->errormsg."\r"; + $kollision=true; + echo "Kollision: ".$lehrstunde->errormsg."
"; + } + } + if ($kollision) + { + if (!pg_query($conn,"ROLLBACK;")) + $text.="\rFehler: ".pg_errormessage($conn)."\r"; + } + else + if (!pg_query($conn,"COMMIT;")) + $text.="\rFehler: ".pg_errormessage($conn)."\r"; + } + } + } + // LVA kommt mehrmals vor ->Warnung + elseif ($num_rows_lva>1) + { + $text.="\r!!! Die LVA fas_id=$row->fas_id kommt mehrfach vor!\r"; + $double_error++; + } + } + else + $plausi_error++; +} + + +// **************** +// Ueberfluessige Datensaetze loeschen +$whereClause=getSemesterWhereClause(); +$sql_query="DELETE FROM tbl_lehrveranstaltung WHERE fas_id NOT IN + (SELECT fas_id FROM vw_fas_lehrveranstaltung WHERE $whereClause) AND (fas_id!=0 OR fas_id IS NOT NULL) AND ($whereClause)"; +echo $sql_query.'
'; +if(!$res_delete=@pg_query($conn, $sql_query)) +{ + $text.='\n'.$sql_query; + $text.="\rFehler: ".pg_errormessage($conn)."\r"; + $text.="\rSolution: DELETE FROM tbl_stundenplandev WHERE lehrveranstaltung_id IN (SELECT lehrveranstaltung_id FROM tbl_lehrveranstaltung WHERE fas_id NOT IN (SELECT fas_id FROM vw_fas_lehrveranstaltung WHERE $whereClause) AND (fas_id!=0 OR fas_id IS NOT NULL) AND ($whereClause))\r"; +} +else +{ + $anz_delete=pg_numrows($res_delete); +} + +//Ausgabe Zusammenfassung +$text.="\n$anz_delete Lehrveranstaltungen wurden geloescht!\n"; +$text.="$plausi_error Fehler beim Plausibilitaetscheck!\n"; +$text.="$update_error Fehler bei LVA-Update!\n"; +$text.="$insert_error Fehler bei LVA-Insert!\n"; +$text.="$double_error LVA kommen in VileSci doppelt vor!\n\n"; +$text.="$anz_update LVA wurden upgedatet.\n"; +$text.="$anz_insert LVA wurden neu angelegt.\n\n"; +$text.="\nEND OF SYNCHRONISATION\n"; + +// Validation error hinzufügen +while(list($k,$v)=each($error_log)) +{ + $text.="\n\nStudiengang $k:\n"; + foreach($v as $txt) + $text.=" $txt\n"; +} +// fehlende lehrfächer +$text.="\n\nFehlende Lehrfächer: \n"; +while(list($k,$v)=each($missing_lehrfaecher)) +{ + $text.=" $k\n"; +} +// fehlende einheiten +$text.="\n\nFehlende Einheiten: \n"; +while(list($k,$v)=each($missing_einheit)) +{ + $text.=" $k\n"; +} +// fehlende raumtypen +$text.="\n\nFehlende Raumtypen: \n"; +while(list($k,$v)=each($missing_raumtyp)) +{ + $text.=" $k\n"; +} +// fehlende lehrformen +$text.="\n\nFehlende Lehrformen: \n"; +while(list($k,$v)=each($missing_lehrform)) +{ + $text.=" $k\n"; +} +if (mail($adress,"FAS Synchro mit VileSci (Lehrveranstaltungen)",$text,"From: vilesci@technikum-wien.at")) + $sendmail=true; +else + $sendmail=false; + +//print "debug: ";print_r($stg_mail); + +// Einzelnen Mails an Studiengänge verschicken +reset($error_log); +while(list($k,$v)=each($error_log)) +{ + echo "
Mail an Studiengang $k ".$stg_mail[$k].":
"; + $stg_text="Dies ist eine automatische Mail!\nFolgende Fehler sind bei der Synchronisation der Lehrveranstaltungen aufgetreten:\n\n"; + foreach($v as $txt) + $stg_text.="$txt\n"; + echo $stg_text.'
'; + // Studiengang + if (!mail($stg_mail[$k],"FAS Synchro mit VileSci (Lehrveranstaltungen) $k",$stg_text,"From: vilesci@technikum-wien.at")) + echo "Mail an '".$stg_mail[$k]."' konnte nicht verschickt werden!
"; + // Stundenplanstelle + echo "
Mail an Studiengang $k ($adress_stpl)
"; + if (!mail($adress_stpl,"FAS Synchro mit VileSci (Lehrveranstaltungen) $k",$stg_text,"From: vilesci@technikum-wien.at")) + echo 'Mail an "'.$adress_stpl.'" konnte nicht verschickt werden!
'; + +} + +// Doppelte IDs im FAS prüfen +$sql_query="SELECT count(*) AS anzahl, fas_id FROM fas_view_alle_lehreinheiten_vilesci + GROUP BY fas_id HAVING count(*)>1"; +//echo $sql_query."
"; +$result=pg_query($conn_fas, $sql_query); +$num_rows=pg_numrows($result); +$mail_text="Folgende $num_rows IDs kommen in der View fas_view_alle_lehreinheiten_vilesci (fas_id) mehrfach vor:\n\n"; +$mail_text_false=''; +if ($num_rows>0) + while ($row=pg_fetch_object($result)) + $mail_text_false.=$row->fas_id.'->'.$row->anzahl."x\n"; +$mail_text.=$mail_text_false."\n\nBitte überprüfen die Daten im FAS!!!"; +if ($mail_text_false!='') + if (!mail($adress_fas,"FAS Synchro mit VileSci (Lehrveranstaltungen)",$mail_text,"From: vilesci@technikum-wien.at")) + echo "Mail an '".$adress_fas."' konnte nicht verschickt werden!
"; + else + echo 'Mail wurde verschickt an '.$adress_fas.'!
'; +?> + + + +FAS-Synchro mit VileSci + + + +'; +else + echo "Mail konnte nicht verschickt werden!
"; +echo nl2br($text); + +?> + + diff --git a/content/DragAndDrop.js b/content/DragAndDrop.js new file mode 100644 index 000000000..2cf4fc3ca --- /dev/null +++ b/content/DragAndDrop.js @@ -0,0 +1,360 @@ +/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Ben Goodger (Original Author) + * Pierre Chanial + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +//////////////////////////////////////////////////////////////////////////// +// XXX - WARNING - DRAG AND DROP API CHANGE ALERT - XXX +// This file has been extensively modified in a checkin planned for Mozilla +// 0.8, and the API has been modified. DO NOT MODIFY THIS FILE without +// approval from ben@netscape.com, otherwise your changes will be lost. + +/** + * XXX - until load is supported in chrome, you also need to include + * these files: + * chrome://global/content/nsTransferable.js + **/ + + + +/** + * nsDragAndDrop - a convenience wrapper for nsTransferable, nsITransferable + * and nsIDragService/nsIDragSession. + * + * USAGE INFORMATION: see 'README-nsDragAndDrop.html' in the same source directory + * as this file (typically xpfe/global/resources/content) + */ + +var nsDragAndDrop = +{ + _mDS: null, + get mDragService() + { + if (!this._mDS) + { + const kDSContractID = "@mozilla.org/widget/dragservice;1"; + const kDSIID = Components.interfaces.nsIDragService; + this._mDS = Components.classes[kDSContractID].getService(kDSIID); + } + return this._mDS; + }, + + /** + * void startDrag (DOMEvent aEvent, Object aDragDropObserver) ; + * + * called when a drag on an element is started. + * + * @param DOMEvent aEvent + * the DOM event fired by the drag init + * @param Object aDragDropObserver + * javascript object of format described above that specifies + * the way in which the element responds to drag events. + **/ + startDrag: function (aEvent, aDragDropObserver) + { + try + { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + } catch (e) { alert(e); } + if (!("onDragStart" in aDragDropObserver)) + return; + + const kDSIID = Components.interfaces.nsIDragService; + var dragAction = + { + action: kDSIID.DRAGDROP_ACTION_COPY + kDSIID.DRAGDROP_ACTION_MOVE + kDSIID.DRAGDROP_ACTION_LINK + }; + + var transferData = + { + data: null + }; + try + { + aDragDropObserver.onDragStart(aEvent, transferData, dragAction); + } + catch (e) + { + return; // not a draggable item, bail! + } + + if (!transferData.data) + return; + transferData = transferData.data; + + var transArray = Components.classes["@mozilla.org/supports-array;1"] + .createInstance(Components.interfaces.nsISupportsArray); + + var region = null; + if (aEvent.originalTarget.localName == "treechildren") + { + // let's build the drag region + var tree = aEvent.originalTarget.parentNode; + try + { + region = Components.classes["@mozilla.org/gfx/region;1"].createInstance(Components.interfaces.nsIScriptableRegion); + region.init(); + var obo = tree.treeBoxObject; + var bo = obo.treeBody.boxObject; + var obosel= obo.selection; + var rowX = bo.x; + var rowY = bo.y; + var rowHeight = obo.rowHeight; + var rowWidth = bo.width; + + //add a rectangle for each visible selected row + for (var i = obo.getFirstVisibleRow(); i <= obo.getLastVisibleRow(); i ++) + { + if (obosel.isSelected(i)) + region.unionRect(rowX, rowY, rowWidth, rowHeight); + rowY = rowY + rowHeight; + } + + //and finally, clip the result to be sure we don't spill over... + region.intersectRect(bo.x, bo.y, bo.width, bo.height); + } + catch(ex) + { + dump("Error while building selection region: " + ex + "\n"); + region = null; + } + } + + var count = 0; + do + { + var trans = nsTransferable.set(transferData._XferID == "TransferData" + ? transferData : transferData.dataList[count++]); + transArray.AppendElement(trans.QueryInterface(Components.interfaces.nsISupports)); + } + while (transferData._XferID == "TransferDataSet" && count < transferData.dataList.length); + + try + { + this.mDragService.invokeDragSession(aEvent.target, transArray, region, dragAction.action); + } + catch(ex) + { + // this could be because the user pressed escape to + // cancel the drag. even if it's not, there's not much + // we can do, so be silent. + } + aEvent.preventBubble(); + }, + + /** + * void dragOver (DOMEvent aEvent, Object aDragDropObserver) ; + * + * called when a drag passes over this element + * + * @param DOMEvent aEvent + * the DOM event fired by passing over the element + * @param Object aDragDropObserver + * javascript object of format described above that specifies + * the way in which the element responds to drag events. + **/ + dragOver: function (aEvent, aDragDropObserver) + { + try + { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + } catch (e) { alert(e); } + if (!("onDragOver" in aDragDropObserver)) + return; + if (!this.checkCanDrop(aEvent, aDragDropObserver)) + return; + var flavourSet = aDragDropObserver.getSupportedFlavours(); + for (var flavour in flavourSet.flavourTable) + { + if (this.mDragSession.isDataFlavorSupported(flavour)) + { + aDragDropObserver.onDragOver(aEvent, + flavourSet.flavourTable[flavour], + this.mDragSession); + aEvent.preventBubble(); + break; + } + } + }, + + mDragSession: null, + + /** + * void drop (DOMEvent aEvent, Object aDragDropObserver) ; + * + * called when the user drops on the element + * + * @param DOMEvent aEvent + * the DOM event fired by the drop + * @param Object aDragDropObserver + * javascript object of format described above that specifies + * the way in which the element responds to drag events. + **/ + drop: function (aEvent, aDragDropObserver) + { + try + { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + } catch (e) { alert(e); } + + if (!("onDrop" in aDragDropObserver)) + return; + if (!this.checkCanDrop(aEvent, aDragDropObserver)) + return; + if (this.mDragSession.canDrop) { + var flavourSet = aDragDropObserver.getSupportedFlavours(); + var transferData = nsTransferable.get(flavourSet, this.getDragData, true); + // hand over to the client to respond to dropped data + var multiple = "canHandleMultipleItems" in aDragDropObserver && aDragDropObserver.canHandleMultipleItems; + var dropData = multiple ? transferData : transferData.first.first; + aDragDropObserver.onDrop(aEvent, dropData, this.mDragSession); + } + aEvent.preventBubble(); + }, + + /** + * void dragExit (DOMEvent aEvent, Object aDragDropObserver) ; + * + * called when a drag leaves this element + * + * @param DOMEvent aEvent + * the DOM event fired by leaving the element + * @param Object aDragDropObserver + * javascript object of format described above that specifies + * the way in which the element responds to drag events. + **/ + dragExit: function (aEvent, aDragDropObserver) + { + try + { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + } catch (e) { alert(e); } + + if (!this.checkCanDrop(aEvent, aDragDropObserver)) + return; + if ("onDragExit" in aDragDropObserver) + aDragDropObserver.onDragExit(aEvent, this.mDragSession); + }, + + /** + * void dragEnter (DOMEvent aEvent, Object aDragDropObserver) ; + * + * called when a drag enters in this element + * + * @param DOMEvent aEvent + * the DOM event fired by entering in the element + * @param Object aDragDropObserver + * javascript object of format described above that specifies + * the way in which the element responds to drag events. + **/ + dragEnter: function (aEvent, aDragDropObserver) + { + try + { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + } catch (e) { alert(e); } + + if (!this.checkCanDrop(aEvent, aDragDropObserver)) + return; + if ("onDragEnter" in aDragDropObserver) + aDragDropObserver.onDragEnter(aEvent, this.mDragSession); + }, + + /** + * nsISupportsArray getDragData (Object aFlavourList) + * + * Creates a nsISupportsArray of all droppable items for the given + * set of supported flavours. + * + * @param FlavourSet aFlavourSet + * formatted flavour list. + **/ + getDragData: function (aFlavourSet) + { + try + { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + } + catch (e) + { + alert(e); + } + + var supportsArray = Components.classes["@mozilla.org/supports-array;1"] + .createInstance(Components.interfaces.nsISupportsArray); + + for (var i = 0; i < nsDragAndDrop.mDragSession.numDropItems; ++i) + { + var trans = nsTransferable.createTransferable(); + for (var j = 0; j < aFlavourSet.flavours.length; ++j) + trans.addDataFlavor(aFlavourSet.flavours[j].contentType); + nsDragAndDrop.mDragSession.getData(trans, i); + supportsArray.AppendElement(trans); + } + return supportsArray; + }, + + /** + * Boolean checkCanDrop (DOMEvent aEvent, Object aDragDropObserver) ; + * + * Sets the canDrop attribute for the drag session. + * returns false if there is no current drag session. + * + * @param DOMEvent aEvent + * the DOM event fired by the drop + * @param Object aDragDropObserver + * javascript object of format described above that specifies + * the way in which the element responds to drag events. + **/ + checkCanDrop: function (aEvent, aDragDropObserver) + { + try + { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + } catch (e) { alert(e); } + + if (!this.mDragSession) + this.mDragSession = this.mDragService.getCurrentSession(); + if (!this.mDragSession) + return false; + this.mDragSession.canDrop = this.mDragSession.sourceNode != aEvent.target; + if ("canDrop" in aDragDropObserver) + this.mDragSession.canDrop &= aDragDropObserver.canDrop(aEvent, this.mDragSession); + return true; + } +}; + diff --git a/content/Ideen.php b/content/Ideen.php new file mode 100644 index 000000000..06b3a7488 --- /dev/null +++ b/content/Ideen.php @@ -0,0 +1,111 @@ +/************************************************************************** + * @brief Funktion draw_week_rdf Stundenplan im RDF-Format + * + * @param datum Datum eines Tages in der angeforderten Woche + * + * @return true oder false + * + */ + function draw_week_rdf() + { + // Stundentafel abfragen + $sql_query="SELECT * FROM tbl_stunde ORDER BY stunde"; + if(!$result_stunde=pg_exec($this->conn, $sql_query)) + die(pg_last_error($this->conn)); + $num_rows_stunde=pg_numrows($result_stunde); + + //echo $this->datum; + + $rdf_url='http://www.technikum-wien.at/tempus/lehrstunde/'; + //RDF Kopf + echo ''; + + // Von Montag bis Samstag + for ($i=1; $i<7; $i++) + { + for ($k=0; $k<$num_rows_stunde; $k++) + { + $j=pg_result($result_stunde,$k,'"stunde"'); + if (isset($this->std_plan[$i][$j][0]->lehrfach)) + { + // Daten aufbereiten + $kollision=-1; + unset($a_unr); + foreach ($this->std_plan[$i][$j] as $lehrstunde) + $a_unr[]=$lehrstunde->unr; + + // Unterrichtsnummer (Kollision?) + $unr=array_unique($a_unr); + $kollision+=count($unr); + foreach ($a_unr as $unr) + foreach ($this->std_plan[$i][$j] as $lehrstunde) + if ($lehrstunde->unr==$unr) + { + // Ausgabe + $lvb=$lehrstunde->stg.'-'.$lehrstunde->sem; + if ($lehrstunde->ver!=null && $lehrstunde->ver!='0' && $lehrstunde->ver!='') + { + $lvb.=$lehrstunde->ver; + if ($lehrstunde->grp!=null && $lehrstunde->grp!='0' && $lehrstunde->grp!='') + $lvb.=$lehrstunde->grp; + } + echo ' + '.$lehrstunde->stundenplan_id.' + '.$lvb.' + '.$lehrstunde->stg_kz.' + '.$lehrstunde->stg.' + '.$lehrstunde->sem.' + '.$lehrstunde->ver.' + '.$lehrstunde->grp.' + '.$lehrstunde->einheit_kurzbz.' + '.$lehrstunde->datum.' + '.$lehrstunde->stunde.' + '.$i.' + + '.($kollision ? 'true':'false').' + + '; + } + } + } + } + + // Sequenz Von Montag bis Samstag + echo ''; + for ($i=1; $i<7; $i++) + { + for ($k=0; $k<$num_rows_stunde; $k++) + { + $j=pg_result($result_stunde,$k,'"stunde"'); + if (isset($this->std_plan[$i][$j][0]->lehrfach)) + { + // Daten aufbereiten + unset($a_unr); + foreach ($this->std_plan[$i][$j] as $lehrstunde) + $a_unr[]=$lehrstunde->unr; + + // Unterrichtsnummern + $unr=array_unique($a_unr); + foreach ($a_unr as $unr) + { + echo ' + + '; + foreach ($this->std_plan[$i][$j] as $lehrstunde) + if ($lehrstunde->unr==$unr) + { + // Ausgabe + echo ''; + } + echo ' + '; + } + } + } + } + echo ''; + echo ''; + } + \ No newline at end of file diff --git a/content/dragboard.js b/content/dragboard.js new file mode 100644 index 000000000..489514b3d --- /dev/null +++ b/content/dragboard.js @@ -0,0 +1,57 @@ +function lehrstunde(type,stg_kz,sem,ver,grp) +{ + this.type=type; + this.stg_kz=stg_kz; + this.sem=sem; + this.ver=ver; + this.grp=grp; +} + +var listObserver= +{ + onDragStart: function (evt,transferData,action) + { + var elemID=evt.target.getAttribute("elem"); + var paramList=evt.target.getAttribute("paramList"); + var transferObjekt=new lehrstunde(elemID,paramList,elemID,elemID,elemID); + transferData.data=new TransferData(); + //transferData.data.addDataForFlavour("text/unicode",transferObjekt); + transferData.data.addDataForFlavour("text/unicode",paramList); + } +}; + +var boardObserver= +{ + /*canHandleMultipleItems : function() + { + var canHandleMultipleItems=false; + },*/ + getSupportedFlavours : function () + { + var flavours = new FlavourSet(); + flavours.appendFlavour("text/unicode"); + return flavours; + }, + onDragOver: function (evt,flavour,session) + { + }, + onDrop: function (evt,dropdata,session) + { + if (dropdata.data!="") + { + var dragElement=document.getElementById(dropdata.data); + var contentFrame=document.getElementById('iframeTimeTableWeek'); + var stunde=evt.target.getAttribute("stunde"); + var datum=evt.target.getAttribute("datum"); + /*//var elem=document.createElement("label");*/ + /*evt.target.appendChild(elem); */ + var paramList=dragElement.getAttribute("paramList"); + /*elem.setAttribute("value",dropdata.data + paramList); */ + var url=location.href;//contentFrame.getAttribute('src'); + url+=paramList+"&new_stunde="+stunde+"&new_datum="+datum+'&aktion=stplverschieben'; + //contentFrame.setAttribute('src', url); + location.href=url; + } + } +}; + diff --git a/content/dragboard.js.php b/content/dragboard.js.php new file mode 100644 index 000000000..eee577a9b --- /dev/null +++ b/content/dragboard.js.php @@ -0,0 +1,173 @@ + +function lehrstunde(id,idList) +{ + this.id=id; + this.idList=idList; +} +var lehrstunden=new Array(); + +/***** Drag Observer fuer Lehrveranstaltungen *****/ +var lvaObserver= +{ + onDragStart: function (evt,transferData,action) + { + var idList=evt.target.getAttribute("idList"); + var aktion=evt.target.getAttribute("aktion"); + aktion+="_set"; + var paramList="?aktion="+aktion+"&lva_ids="+idList; + transferData.data=new TransferData(); + transferData.data.addDataForFlavour("application/tempus-lehrveranstaltung",paramList); + //alert("test"); + } +}; + +/***** Drag Observer fuer STPL-Verschiebung *****/ +var listObserver= +{ + onDragStart: function (evt,transferData,action) + { + var type=evt.target.getAttribute("stpltype"); + var dragdatum=evt.target.getAttribute("datum"); + var pers_uid=evt.target.getAttribute("pers_uid"); + var idList=evt.target.getAttribute("idList"); + var stg_kz=evt.target.getAttribute("stg_kz"); + var sem=evt.target.getAttribute("sem"); + var ver=evt.target.getAttribute("ver"); + var grp=evt.target.getAttribute("grp"); + var einheit=evt.target.getAttribute("einheit"); + var old_ort=evt.target.getAttribute("ort"); + var aktion=evt.target.getAttribute("aktion"); + aktion+="_set"; + var paramList="?dragtype="+type+"&dragdatum="+dragdatum+"&pers_uid="+pers_uid+"&stg_kz="+stg_kz+"&sem="+sem+"&ver="+ver+"&grp="+grp+"&einheit="+einheit+"&old_ort="+old_ort+idList+"&aktion="+aktion; + //var transferObjekt=new lehrstunde(type,dragdatum,pers_uid,stg_kz,sem,ver,grp,einheit,old_ort,idList); + transferData.data=new TransferData(); + transferData.data.addDataForFlavour("application/tempus-lehrstunde",paramList); + + var styleOrig=evt.target.getAttribute("styleOrig"); + evt.target.setAttribute("style",styleOrig+"color:red;font-style:italic;"); + } +}; + +/***** Board Observer fuer STPL- und LVA-Verschiebung *****/ +var boardObserver= +{ + /*canHandleMultipleItems : function() + { + var canHandleMultipleItems=false; + },*/ + getSupportedFlavours : function () + { + var flavours = new FlavourSet(); + flavours.appendFlavour("application/tempus-lehrveranstaltung"); + flavours.appendFlavour("application/tempus-lehrstunde"); + return flavours; + }, + onDragEnter: function (evt,flavour,session) + { + var styleNow=evt.target.getAttribute("style"); + if (evt.target.tagName=="label") + evt.target.setAttribute("style","background-color:#AAFFAA;"); + else + evt.target.setAttribute("style",styleNow+"border:1px dashed black;"); + + }, + onDragExit: function (evt,flavour,session) + { + var styleNow=evt.target.getAttribute("style"); + if (evt.target.tagName=="label") + evt.target.setAttribute("style",""); + else + evt.target.setAttribute("style",styleNow+"border:1px solid black;"); + }, + onDragOver: function(evt,flavour,session) + { + // Mehrfachauswahl von Lehrstunden mit CTRL bzw. ALT-Taste + if ((evt.ctrlKey || evt.altKey) && flavour.contentType=="application/tempus-lehrstunde" && evt.target.tagName=="button") + { + var idList=evt.target.getAttribute("idList"); + var id=evt.target.getAttribute("id"); + var styleOrig=evt.target.getAttribute("styleOrig"); + // Ist Element schon vorhanden und an welcher stelle im Array? + var gesetzt=null; + for (var i=0;i'; +// DAO +include('../vilesci/config.inc.php'); +include_once('../include/einheit.class.php'); + +// Datenbank Verbindung +if (!$conn = @pg_pconnect(CONN_STRING)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + + +// Einheiten holen +$einheitenDAO=new einheit($conn); +$einheiten=$einheitenDAO->getAll(); + + + +$rdf_url='http://www.technikum-wien.at/tempus/einheiten'; + +?> + + + + + + + + + + kurzbz ?> + stg_kz ?> + stg_kurzbz ?> + bezeichnung ?> + semester ?> + typ ?> + + + + + + + + \ No newline at end of file diff --git a/content/excel.php b/content/excel.php new file mode 100644 index 000000000..aee708e92 --- /dev/null +++ b/content/excel.php @@ -0,0 +1,160 @@ + + * date: 2006-04-22 +*/ + +//error_reporting(E_ALL); +//ini_set('display_errors','1'); + + +include('../vilesci/config.inc.php'); +include_once('../include/fas/functions.inc.php'); +include_once('../include/fas/person.class.php'); +include_once('../include/fas/mitarbeiter.class.php'); +include_once('../include/Excel/PEAR.php'); +include_once('../include/Excel/BIFFwriter.php'); +include_once('../include/Excel/Workbook.php'); +include_once('../include/Excel/Format.php'); +include_once('../include/Excel/Worksheet.php'); +include_once('../include/Excel/Parser.php'); +include_once('../include/Excel/OLE.php'); +include_once('../include/Excel/PPS.php'); +include_once('../include/Excel/Root.php'); +include_once('../include/Excel/File.php'); +include_once('../include/Excel/Writer.php'); + + +// Datenbank Verbindung +if (!$conn = @pg_pconnect(CONN_STRING_FAS)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + +//Parameter holen +if (isset($_GET['mitarbeiter_id'])) + $mitarbeiter_id = $_GET['mitarbeiter_id']; +else + $mitarbeiter_id=null; + +if (isset($_GET['fix'])) + $fix = $_GET['fix']; +else + $fix=null; + +if (isset($_GET['stgl'])) + $stgl = $_GET['stgl']; +else + $stgl=null; + +if (isset($_GET['fbl'])) + $fbl = $_GET['fbl']; +else + $fbl=null; + +if (isset($_GET['aktiv'])) + $aktiv = $_GET['aktiv']; +else + $aktiv=null; + +if (isset($_GET['karenziert'])) + $karenziert = $_GET['karenziert']; +else + $karenziert=null; + +if (isset($_GET['ausgeschieden'])) + $ausgeschieden = $_GET['ausgeschieden']; +else + $ausgeschieden=null; + +if (isset($_GET['zustelladresse'])) + $zustelladresse = $_GET['zustelladresse']; +else + $zustelladresse = null; + +//Spalten +$anzSpalten=0; +$varname='spalte'.(string)$anzSpalten; +while (isset($_GET[$varname])) +{ + $spalte[$anzSpalten]=$_GET[$varname]; + //echo $spalte[$anzSpalten]; + $anzSpalten++; + $varname='spalte'.(string)$anzSpalten; +} +$zustelladresse=true; + +// Mitarbeiter holen +$mitarbeiterDAO=new mitarbeiter($conn); +$mitarbeiterDAO->getMitarbeiter($mitarbeiter_id, $fix, $stgl, $fbl, $aktiv, $karenziert, $ausgeschieden, $zustelladresse,getStudiensemesterIdFromName($conn, $benutzer->variable->semester_aktuell)); + + /* + * Create Excel File with Content from Students Examples solved + */ + + // Creating a workbook + $workbook = new Spreadsheet_Excel_Writer(); + + // sending HTTP headers + $workbook->send("Mitarbeiter". "_" . date("d_m_Y") . ".xls"); + + // Creating a worksheet + $worksheet =& $workbook->addWorksheet("Mitarbeiter"); + + $format_bold =& $workbook->addFormat(); + $format_bold->setBold(); + + $format_title =& $workbook->addFormat(); + $format_title->setBold(); +// $format_title->setColor('yellow'); +// $format_title->setPattern(1); +// $format_title->setFgColor('blue'); + // let's merge + $format_title->setAlign('merge'); + + for ($i=0;$i<$anzSpalten;$i++) + $worksheet->write(0,$i,strtoupper(str_replace('_bezeichnung','',$spalte[$i])), $format_bold); + $worksheet->write(0,$i,"STRASSE", $format_bold); + $worksheet->write(0,$i+1,"PLZ", $format_bold); + $worksheet->write(0,$i+2,"ORT", $format_bold); + + // set width of columns + + //$worksheet->setColumn(1,4,20); // ersten 3 Spalten auf width=17 + //$worksheet->setColumn(0,0,22); + + $j=1; + $maxlength = array(); + for ($i=0;$i<$anzSpalten;$i++) + $maxlength[$i]=strlen(str_replace('_bezeichnung','',$spalte[$i])); + $maxlength[$i]=strlen('STRASSE'); + $maxlength[$i+1]=strlen('PLZ'); + $maxlength[$i+2]=strlen('ORT'); + + foreach ($mitarbeiterDAO->result as $mitarbeiter) + { + for ($i=0;$i<$anzSpalten;$i++) + { + if(strlen($mitarbeiter->$spalte[$i])>$maxlength[$i]) + $maxlength[$i] = strlen($mitarbeiter->$spalte[$i]); + $worksheet->write($j,$i, utf8_decode($mitarbeiter->$spalte[$i])); + } + if(strlen($mitarbeiter->zustelladresse_strasse)>$maxlength[$i]) + $maxlength[$i]=strlen($mitarbeiter->zustelladresse_strasse); + $worksheet->write($j,$i, utf8_decode($mitarbeiter->zustelladresse_strasse)); + if(strlen($mitarbeiter->zustelladresse_plz)>$maxlength[$i+1]) + $maxlength[$i+1]=strlen($mitarbeiter->zustelladresse_plz); + $worksheet->write($j,$i+1, utf8_decode($mitarbeiter->zustelladresse_plz)); + if(strlen($mitarbeiter->zustelladresse_ort)>$maxlength[$i+2]) + $maxlength[$i+2]=strlen($mitarbeiter->zustelladresse_ort); + $worksheet->write($j,$i+2, utf8_decode($mitarbeiter->zustelladresse_ort)); + $j++; + } + + for ($i=0;$i<$anzSpalten;$i++) + $worksheet->setColumn($i, $i, $maxlength[$i]+2); + $worksheet->setColumn($i, $i, $maxlength[$i]+2); + $worksheet->setColumn($i+1, $i+1, $maxlength[$i+1]+2); + $worksheet->setColumn($i+2, $i+2, $maxlength[$i+2]+2); + + $workbook->close(); + +?> diff --git a/content/fachbereich.rdf.php b/content/fachbereich.rdf.php new file mode 100644 index 000000000..79f692e9c --- /dev/null +++ b/content/fachbereich.rdf.php @@ -0,0 +1,83 @@ +'; +// DAO +include('../vilesci/config.inc.php'); +include_once('../include/fachbereich.class.php'); + +// Datenbank Verbindung +if (!$conn = @pg_pconnect(CONN_STRING)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + + +// test + +$einheit_kurzbz=''; +$grp='1'; +//$ver='A'; +$sem=5; +$stg_kz=145; + + +/* +$einheit_kurzbz=''; +$grp=$_GET['grp']; +$ver=$_GET['ver']; +$sem=$_GET['sem']; +$stg_kz=$_GET['stg_kz']; */ + +// fachbereiche holen +$fachbereichDAO=new fachbereich($conn); +$fachbereiche=$fachbereichDAO->getAll(); + + + +$rdf_url='http://www.technikum-wien.at/tempus/fachbereich'; + +?> + + + + + + + + + id ?> + kurzbz ?> + bezeichnung ?> + farbe ?> + studiengang_kz ?> + studiengang_kurzbz ?> + + + + + + + \ No newline at end of file diff --git a/content/fas.js.php b/content/fas.js.php new file mode 100644 index 000000000..bd691c3b0 --- /dev/null +++ b/content/fas.js.php @@ -0,0 +1,144 @@ + + +/** + * Wenn einer der Tabs angeklickt wird wird der zugehoerige Tab + * im anderen Overlay auch geaendert + */ +function tabchange(select) +{ + if(select=='lehreinheiten') //Auswahl des Lehreinheiten Tabs + { + document.getElementById('tab-mitarbeiter').selected=false; + document.getElementById('tab-mitarbeiter1').selected=false; + document.getElementById('tab-lehreinheiten').selected=true; + document.getElementById('tab-verband').selected=true; + document.getElementById('tabpanels-main').selectedIndex=1; + document.getElementById('tabpanels-left').selectedIndex=1; + + } + else if(select=='mitarbeiter') //Auswahl des Mitarbeiter Tabs + { + document.getElementById('tab-lehreinheiten').selected=false; + document.getElementById('tab-verband').selected=false; + document.getElementById('tab-mitarbeiter').selected=true; + document.getElementById('tab-mitarbeiter1').selected=true; + document.getElementById('tabpanels-main').selectedIndex=0; + document.getElementById('tabpanels-left').selectedIndex=0; + } +} + +/** + * Beim schliessen des Fensters wird ueberprueft ob Daten geaendert und noch + * nicht gespeichert wurden. + */ +function closeWindow() +{ + //Wenn Daten geaendert wurden + if(treeMitarbeiterDetailChanged) + { + if(confirm("Wollen Sie die geänderten Daten speichern?")) + if(!saveMitarbeiter()) + { + //Falls beim Speichern ein Fehler auftritt bleibt das Fenster offen! + return false; + } + else + window.close(); + else + window.close(); + } + else + window.close(); +} + +/** + * Wenn das Fenster Fertig geladen ist + */ +function onLoad() +{ + //rebuild Listener setzen + document.getElementById('tree-liste-mitarbeiter').builder.addListener(treemenurebuildobserve); + + //Eingabefelder deaktivieren + SetMitarbeiterDetailAktiv(false); + + //studiengangsleiter als Default setzen + document.getElementById('tree-menu-mitarbeiter1').view.selection.select(6); +} + +/** + * Aenderung des Studiensemesters + */ +function studiensemesterChange() +{ + var items = document.getElementsByTagName('menuitem'); + var stsem=''; + //Markiertes Studiensemester holen + for(i in items) + { + if(items[i].id=='menu-properies-studiensemester-name' && items[i].getAttribute("checked")=='true') + stsem = items[i].label; + } + + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + + // Request absetzen + var httpRequest = new XMLHttpRequest(); + var url = "rdf/fas/db_dml.rdf.php"; + + httpRequest.open("POST", url, false, '',''); + httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); + + var param = "type=variablechange"; + param = param + "&stsem="+stsem; + + //Parameter schicken + httpRequest.send(param); + + // Bei status 4 ist sendung Ok + switch(httpRequest.readyState) + { + case 1,2,3: alert('Bad Ready State: '+httpRequest.status); + return false; + break; + + case 4: if(httpRequest.status !=200) + { + alert('The server respond with a bad status code: '+httpRequest.status); + return false; + } + else + { + var response = httpRequest.responseText; + } + break; + } + + // Returnwerte aus RDF abfragen + var dsource=parseRDFString(response, 'http://www.technikum-wien.at/dbdml'); + + var rdfService = Components.classes["@mozilla.org/rdf/rdf-service;1"]. + getService(Components.interfaces.nsIRDFService); + var subject = rdfService.GetResource("http://www.technikum-wien.at/dbdml/0"); + + var predicateNS = "http://www.technikum-wien.at/dbdml/rdf"; + + var dbdml_return = getTargetHelper(dsource, subject, rdfService.GetResource( predicateNS + "#return" )); + var dbdml_errormsg = getTargetHelper(dsource, subject, rdfService.GetResource( predicateNS + "#errormsg" )); + + if(dbdml_return=='true') + { + //Statusbar setzen + setStatusBarText("Studiensemester erfolgreich geändert"); + document.getElementById("tree-liste-funktionen").builder.refresh(); + document.getElementById("statusbarpanel-semester").label = stsem; + MitarbeiterDetailStudiensemester_id = dbdml_errormsg; + } + else + { + alert("Fehler beim Speichern der Daten: "+dbdml_errormsg); + } + return true; +} diff --git a/content/fas.xul.php b/content/fas.xul.php new file mode 100644 index 000000000..3bc6fc017 --- /dev/null +++ b/content/fas.xul.php @@ -0,0 +1,170 @@ +'; +include('../vilesci/config.inc.php'); +include('../include/functions.inc.php'); +include('../include/fas/benutzer.class.php'); + +// Testumgebung +//if (!isset($REMOTE_USER)) +// $REMOTE_USER='pam'; +//$uid=$REMOTE_USER; +$user = get_uid(); + +$error_msg=''; + +//Variablen laden +if (!$conn = @pg_pconnect(CONN_STRING)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + +$benutzer = new benutzer($conn); +if(!$benutzer->loadVariables($user)) + $error_msg = $benutzer->errormsg; + + +/*echo '';*/ +echo ''; +echo ''; +?> + + + + + + + \ No newline at end of file diff --git a/content/xxxstpl-lehrstunde.rdf.php b/content/xxxstpl-lehrstunde.rdf.php new file mode 100644 index 000000000..6bd82aa5c --- /dev/null +++ b/content/xxxstpl-lehrstunde.rdf.php @@ -0,0 +1,101 @@ +'; +//echo ''; +include('../vilesci/config.inc.php'); +include('../include/functions.inc.php'); +include('../include/lehrstunde.class.php'); +include('../include/stundenplan.class.php'); + +// Testumgebung +if (!isset($REMOTE_USER)) + $REMOTE_USER='pam'; + +$uid=$REMOTE_USER; + +// Variablen uebernehmen +if (isset($_GET[aktion])) + $aktion=$_GET[aktion]; +if (isset($_GET[new_stunde])) + $new_stunde=$_GET[new_stunde]; +if (isset($_GET[new_datum])) + $new_datum=$_GET[new_datum]; +if (isset($_GET[type])) + $type=$_GET[type]; +if (isset($_GET[ort_kurzbz])) + $ort_kurzbz=$_GET[ort_kurzbz]; +else + $ort_kurzbz='EDV6.08'; +$i=0; +$name_stpl_id='stundenplan_id'.$i; +while ($i<100 && isset($_GET[$name_stpl_id])) +{ + $stpl_id[]=$_GET[$name_stpl_id]; + //echo $stpl_id[$i]; + $name_stpl_id='stundenplan_id'.++$i; + +} + + +if (!$conn = @pg_pconnect(CONN_STRING)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; +$error_msg.=loadVariables($conn,$REMOTE_USER); + +// Authentifizierung +if ($uid=check_student($REMOTE_USER, $conn)) + $user='student'; +elseif ($uid=check_lektor($REMOTE_USER, $conn)) + $user='lektor'; +else + die("Cannot set usertype!"); + + // User bestimmen +if (!isset($type)) + $type=$user; +if (!isset($pers_uid)) + $pers_uid=$uid; + + // Datums Format +$erg_std=pg_query($conn, "SET datestyle TO ISO;") + or die(pg_last_error($conn)); + + +// Aktionen durchfuehren +if ($aktion=='stplverschieben') +{ + foreach ($stpl_id as $stundenplan_id) + { + $lehrstunde=new lehrstunde($conn); + $lehrstunde->load($stundenplan_id,$db_stpl_table); + $lehrstunde->datum=$new_datum; + $lehrstunde->stunde=$new_stunde; + $lehrstunde->save($db_stpl_table); + } +} +// Stundenplan abfragen +$stdplan=new stundenplan($type,$conn); +if (!isset($datum)) + $datum=mktime(); + +// Benutzergruppe +$stdplan->user=$user; +// aktueller Benutzer +$stdplan->user_uid=$uid; + +// Zusaetzliche Daten laden +if (! $stdplan->load_data($type,$pers_uid,$ort_kurzbz,$stg_kz,$sem,$ver,$grp,$einheit_kurzbz,$db_table) ) + die($stdplan->errormsg); +// Stundenplan einer Woche laden +if (! $stdplan->load_week($datum,$db_stpl_table)) + die($stdplan->errormsg); +// Kopfbereich drucken + +// Stundenplan der Woche in RDF drucken +$stdplan->draw_week_rdf(); +?> \ No newline at end of file diff --git a/favicon.ico b/favicon.ico new file mode 100644 index 000000000..ab891453d Binary files /dev/null and b/favicon.ico differ diff --git a/include/Authorization.class.php b/include/Authorization.class.php new file mode 100644 index 000000000..f15ac49ce --- /dev/null +++ b/include/Authorization.class.php @@ -0,0 +1,123 @@ + + * date: + * title: Authorization.class.php + * manual: $auth = new Authorization($uid, $course_id, $semester, $lesson); + * + * Tries to login a user as a student, if fails, it tries + * to login as a teacher. + * returns 0 for student + * 1 for teacher + * -1 on error + * holt den firstname, lastname, uid und id des Benutzers + */ +class Authorization +{ + var $firstname; + var $lastname; + var $id; + var $uid; + var $stg_id; + var $semester; + var $verband; + var $gruppe; + var $isLector; + var $module; + var $lehrfach; + var $date; + var $session; + var $birthday; + + function Authorization($uid ="", $course_id = 0, $semester = 0, $lesson = "",$conn="") + { + $this->isLector = -1; + $this->module = 0; + + if ($uid == "oesi" || $uid == "kates") + { + $this->uid = $uid; + $this->stg_id = $course_id; + $this->lehrfach = $lesson; + $this->semester = $semester; + $this->isLector = 1; + return $this->isLector; + } + + // try to looon as a student + $sql = "SELECT * ". + "FROM tbl_student JOIN tbl_person USING (uid) WHERE + uid = '$uid' AND studiengang_kz = $course_id + AND semester >= $semester"; + + $rs = new pgRS($conn,$sql); + + if ($rs->num > 0) + { + $this->firstname = $rs->arr[0]["vornamen"]; + $this->lastname = $rs->arr[0]["nachname"]; + //$this->id = $rs->arr[0]["id"]; + $this->uid = $uid; + $this->stg_id = $rs->arr[0]["studiengang_kz"]; + $this->semester = $rs->arr[0]["semester"]; + $this->verband = $rs->arr[0]["verband"]; + $this->gruppe = $rs->arr[0]["gruppe"]; + $this->birthday = $rs->arr[0]["gebdatum"]; + $this->isLector = 0; + } + else + { + /* oesi 17-01-2005 + $sql = "SELECT * FROM lehre.tbl_lehrfachzuteilung JOIN tbl_person ON + (lektor_uid = uid) WHERE lektor_uid = '$uid' AND + lehrfachzuteilung_kurzbz = '$lesson' AND + semester = $semester AND studiengang_kz = $course_id LIMIT 1"; + */ + $sql = "SELECT * FROM tbl_lehrveranstaltung, tbl_lehrfach, tbl_person WHERE + tbl_lehrveranstaltung.lehrfach_nr=tbl_lehrfach.lehrfach_nr AND + tbl_person.uid=lektor AND lektor='$uid' AND + tbl_lehrfach.studiengang_kz=$course_id AND + tbl_lehrfach.semester=$semester AND lehrevz='$lesson' LIMIT 1"; + + $rs = new pgRS($conn,$sql); + if ($rs->num > 0) + { + $this->firstname = $rs->arr[0]["vornamen"]; + $this->lastname = $rs->arr[0]["nachname"]; + $this->birthday = $rs->arr[0]["gebdatum"]; + $this->uid = $uid; + $this->stg_id = $course_id; + $this->lehrfach = $lesson; + $this->semester = $semester; + $this->isLector = 1; + } + else + { + //$sql = "SELECT DISTINCT tbl_person.uid FROM public.tbl_person, lehre.tbl_lehrfachzuteilung WHERE tbl_person.uid='$uid' AND tbl_lehrfachzuteilung.lektor_uid=tbl_person.uid AND studiengang_kz='$course_id' UNION SELECT DISTINCT tbl_person.uid FROM public.tbl_person, public.tbl_personfunktion WHERE tbl_person.uid='$uid' AND tbl_personfunktion.uid=tbl_person.uid AND studiengang_kz='$course_id' LIMIT 1"; + $sql = "SELECT vornamen, nachname, gebdatum FROM public.tbl_person, tbl_lehrveranstaltung + WHERE tbl_person.uid='$uid' AND tbl_lehrveranstaltung.lektor=tbl_person.uid AND + studiengang_kz='$course_id' + UNION + SELECT vornamen, nachname, gebdatum FROM public.tbl_person, public.tbl_personfunktion + WHERE tbl_person.uid='$uid' AND tbl_personfunktion.uid=tbl_person.uid AND + studiengang_kz='$course_id' LIMIT 1"; + + $rs = new pgRS($conn,$sql); + + if ($rs->num > 0) + { + $this->firstname = $rs->arr[0]["vornamen"]; + $this->lastname = $rs->arr[0]["nachname"]; + $this->birthday = $rs->arr[0]["gebdatum"]; + $this->uid = $uid; + $this->stg_id = $course_id; + $this->lehrfach = $lesson; + $this->semester = $semester; + $this->isLector = 1; + } + } + } + return $this->isLector; + } +} +?> diff --git a/include/Excel/BIFFwriter.php b/include/Excel/BIFFwriter.php new file mode 100644 index 000000000..c8fbb1bd1 --- /dev/null +++ b/include/Excel/BIFFwriter.php @@ -0,0 +1,237 @@ + +* +* The majority of this is _NOT_ my code. I simply ported it from the +* PERL Spreadsheet::WriteExcel module. +* +* The author of the Spreadsheet::WriteExcel module is John McNamara +* +* +* I _DO_ maintain this code, and John McNamara has nothing to do with the +* porting of this code to PHP. Any questions directly related to this +* class library should be directed to me. +* +* License Information: +* +* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets +* Copyright (c) 2002-2003 Xavier Noguer xnoguer@php.net +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + + +/** +* Class for writing Excel BIFF records. +* +* From "MICROSOFT EXCEL BINARY FILE FORMAT" by Mark O'Brien (Microsoft Corporation): +* +* BIFF (BInary File Format) is the file format in which Excel documents are +* saved on disk. A BIFF file is a complete description of an Excel document. +* BIFF files consist of sequences of variable-length records. There are many +* different types of BIFF records. For example, one record type describes a +* formula entered into a cell; one describes the size and location of a +* window into a document; another describes a picture format. +* +* @author Xavier Noguer +* @category FileFormats +* @package Spreadsheet_Excel_Writer +*/ + +class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR +{ + /** + * The BIFF/Excel version (5). + * @var integer + */ + var $_BIFF_version = 0x0500; + + /** + * The byte order of this architecture. 0 => little endian, 1 => big endian + * @var integer + */ + var $_byte_order; + + /** + * The string containing the data of the BIFF stream + * @var string + */ + var $_data; + + /** + * The size of the data in bytes. Should be the same as strlen($this->_data) + * @var integer + */ + var $_datasize; + + /** + * The maximun length for a BIFF record. See _addContinue() + * @var integer + * @see _addContinue() + */ + var $_limit; + + /** + * Constructor + * + * @access public + */ + function Spreadsheet_Excel_Writer_BIFFwriter() + { + $this->_byte_order = ''; + $this->_data = ''; + $this->_datasize = 0; + $this->_limit = 2080; + // Set the byte order + $this->_setByteOrder(); + } + + /** + * Determine the byte order and store it as class data to avoid + * recalculating it for each call to new(). + * + * @access private + */ + function _setByteOrder() + { + // Check if "pack" gives the required IEEE 64bit float + $teststr = pack("d", 1.2345); + $number = pack("C8", 0x8D, 0x97, 0x6E, 0x12, 0x83, 0xC0, 0xF3, 0x3F); + if ($number == $teststr) { + $byte_order = 0; // Little Endian + } elseif ($number == strrev($teststr)){ + $byte_order = 1; // Big Endian + } else { + // Give up. I'll fix this in a later version. + return $this->raiseError("Required floating point format ". + "not supported on this platform."); + } + $this->_byte_order = $byte_order; + } + + /** + * General storage function + * + * @param string $data binary data to prepend + * @access private + */ + function _prepend($data) + { + if (strlen($data) > $this->_limit) { + $data = $this->_addContinue($data); + } + $this->_data = $data.$this->_data; + $this->_datasize += strlen($data); + } + + /** + * General storage function + * + * @param string $data binary data to append + * @access private + */ + function _append($data) + { + if (strlen($data) > $this->_limit) { + $data = $this->_addContinue($data); + } + $this->_data = $this->_data.$data; + $this->_datasize += strlen($data); + } + + /** + * Writes Excel BOF record to indicate the beginning of a stream or + * sub-stream in the BIFF file. + * + * @param integer $type Type of BIFF file to write: 0x0005 Workbook, + * 0x0010 Worksheet. + * @access private + */ + function _storeBof($type) + { + $record = 0x0809; // Record identifier + + // According to the SDK $build and $year should be set to zero. + // However, this throws a warning in Excel 5. So, use magic numbers. + if ($this->_BIFF_version == 0x0500) { + $length = 0x0008; + $unknown = ''; + $build = 0x096C; + $year = 0x07C9; + } elseif ($this->_BIFF_version == 0x0600) { + $length = 0x0010; + $unknown = pack("VV", 0x00000041, 0x00000006); //unknown last 8 bytes for BIFF8 + $build = 0x0DBB; + $year = 0x07CC; + } + $version = $this->_BIFF_version; + + $header = pack("vv", $record, $length); + $data = pack("vvvv", $version, $type, $build, $year); + $this->_prepend($header . $data . $unknown); + } + + /** + * Writes Excel EOF record to indicate the end of a BIFF stream. + * + * @access private + */ + function _storeEof() + { + $record = 0x000A; // Record identifier + $length = 0x0000; // Number of bytes to follow + $header = pack("vv", $record, $length); + $this->_append($header); + } + + /** + * Excel limits the size of BIFF records. In Excel 5 the limit is 2084 bytes. In + * Excel 97 the limit is 8228 bytes. Records that are longer than these limits + * must be split up into CONTINUE blocks. + * + * This function takes a long BIFF record and inserts CONTINUE records as + * necessary. + * + * @param string $data The original binary data to be written + * @return string A very convenient string of continue blocks + * @access private + */ + function _addContinue($data) + { + $limit = $this->_limit; + $record = 0x003C; // Record identifier + + // The first 2080/8224 bytes remain intact. However, we have to change + // the length field of the record. + $tmp = substr($data, 0, 2).pack("v", $limit-4).substr($data, 4, $limit - 4); + + $header = pack("vv", $record, $limit); // Headers for continue records + + // Retrieve chunks of 2080/8224 bytes +4 for the header. + $data_length = strlen($data); + for ($i = $limit; $i < ($data_length - $limit); $i += $limit) { + $tmp .= $header; + $tmp .= substr($data, $i, $limit); + } + + // Retrieve the last chunk of data + $header = pack("vv", $record, strlen($data) - $i); + $tmp .= $header; + $tmp .= substr($data, $i, strlen($data) - $i); + + return $tmp; + } +} +?> diff --git a/include/Excel/File.php b/include/Excel/File.php new file mode 100644 index 000000000..ec2c8376e --- /dev/null +++ b/include/Excel/File.php @@ -0,0 +1,113 @@ + | +// | Based on OLE::Storage_Lite by Kawai, Takanori | +// +----------------------------------------------------------------------+ +// +// $Id: File.php,v 1.8 2003/12/12 21:10:10 xnoguer Exp $ + + + +/** +* Class for creating File PPS's for OLE containers +* +* @author Xavier Noguer +* @category Structures +* @package OLE +*/ +class OLE_PPS_File extends OLE_PPS +{ + /** + * The temporary dir for storing the OLE file + * @var string + */ + var $_tmp_dir; + + /** + * The constructor + * + * @access public + * @param string $name The name of the file (in Unicode) + * @see OLE::Asc2Ucs() + */ + function OLE_PPS_File($name) + { + $this->_tmp_dir = ''; + $this->OLE_PPS( + null, + $name, + OLE_PPS_TYPE_FILE, + null, + null, + null, + null, + null, + '', + array()); + } + + /** + * Sets the temp dir used for storing the OLE file + * + * @access public + * @param string $dir The dir to be used as temp dir + * @return true if given dir is valid, false otherwise + */ + function setTempDir($dir) + { + if (is_dir($dir)) { + $this->_tmp_dir = $dir; + return true; + } + return false; + } + + /** + * Initialization method. Has to be called right after OLE_PPS_File(). + * + * @access public + * @return mixed true on success. PEAR_Error on failure + */ + function init() + { + $this->_tmp_filename = tempnam($this->_tmp_dir, "OLE_PPS_File"); + $fh = @fopen($this->_tmp_filename, "w+b"); + if ($fh == false) { + return $this->raiseError("Can't create temporary file"); + } + $this->_PPS_FILE = $fh; + if ($this->_PPS_FILE) { + fseek($this->_PPS_FILE, 0); + } + } + + /** + * Append data to PPS + * + * @access public + * @param string $data The data to append + */ + function append($data) + { + if ($this->_PPS_FILE) { + fwrite($this->_PPS_FILE, $data); + } + else { + $this->_data .= $data; + } + } +} +?> diff --git a/include/Excel/Format.php b/include/Excel/Format.php new file mode 100644 index 000000000..7eca2c6f1 --- /dev/null +++ b/include/Excel/Format.php @@ -0,0 +1,1101 @@ + +* +* The majority of this is _NOT_ my code. I simply ported it from the +* PERL Spreadsheet::WriteExcel module. +* +* The author of the Spreadsheet::WriteExcel module is John McNamara +* +* +* I _DO_ maintain this code, and John McNamara has nothing to do with the +* porting of this code to PHP. Any questions directly related to this +* class library should be directed to me. +* +* License Information: +* +* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets +* Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + + +/** +* Class for generating Excel XF records (formats) +* +* @author Xavier Noguer +* @category FileFormats +* @package Spreadsheet_Excel_Writer +*/ + +class Spreadsheet_Excel_Writer_Format extends PEAR +{ + /** + * The index given by the workbook when creating a new format. + * @var integer + */ + var $_xf_index; + + /** + * Index to the FONT record. + * @var integer + */ + var $font_index; + + /** + * The font name (ASCII). + * @var string + */ + var $_font_name; + + /** + * Height of font (1/20 of a point) + * @var integer + */ + var $_size; + + /** + * Bold style + * @var integer + */ + var $_bold; + + /** + * Bit specifiying if the font is italic. + * @var integer + */ + var $_italic; + + /** + * Index to the cell's color + * @var integer + */ + var $_color; + + /** + * The text underline property + * @var integer + */ + var $_underline; + + /** + * Bit specifiying if the font has strikeout. + * @var integer + */ + var $_font_strikeout; + + /** + * Bit specifiying if the font has outline. + * @var integer + */ + var $_font_outline; + + /** + * Bit specifiying if the font has shadow. + * @var integer + */ + var $_font_shadow; + + /** + * 2 bytes specifiying the script type for the font. + * @var integer + */ + var $_font_script; + + /** + * Byte specifiying the font family. + * @var integer + */ + var $_font_family; + + /** + * Byte specifiying the font charset. + * @var integer + */ + var $_font_charset; + + /** + * An index (2 bytes) to a FORMAT record (number format). + * @var integer + */ + var $_num_format; + + /** + * Bit specifying if formulas are hidden. + * @var integer + */ + var $_hidden; + + /** + * Bit specifying if the cell is locked. + * @var integer + */ + var $_locked; + + /** + * The three bits specifying the text horizontal alignment. + * @var integer + */ + var $_text_h_align; + + /** + * Bit specifying if the text is wrapped at the right border. + * @var integer + */ + var $_text_wrap; + + /** + * The three bits specifying the text vertical alignment. + * @var integer + */ + var $_text_v_align; + + /** + * 1 bit, apparently not used. + * @var integer + */ + var $_text_justlast; + + /** + * The two bits specifying the text rotation. + * @var integer + */ + var $_rotation; + + /** + * The cell's foreground color. + * @var integer + */ + var $_fg_color; + + /** + * The cell's background color. + * @var integer + */ + var $_bg_color; + + /** + * The cell's background fill pattern. + * @var integer + */ + var $_pattern; + + /** + * Style of the bottom border of the cell + * @var integer + */ + var $_bottom; + + /** + * Color of the bottom border of the cell. + * @var integer + */ + var $_bottom_color; + + /** + * Style of the top border of the cell + * @var integer + */ + var $_top; + + /** + * Color of the top border of the cell. + * @var integer + */ + var $_top_color; + + /** + * Style of the left border of the cell + * @var integer + */ + var $_left; + + /** + * Color of the left border of the cell. + * @var integer + */ + var $_left_color; + + /** + * Style of the right border of the cell + * @var integer + */ + var $_right; + + /** + * Color of the right border of the cell. + * @var integer + */ + var $_right_color; + + /** + * Constructor + * + * @access private + * @param integer $index the XF index for the format. + * @param array $properties array with properties to be set on initialization. + */ + function Spreadsheet_Excel_Writer_Format($BIFF_version, $index = 0, $properties = array()) + { + $this->_xf_index = $index; + $this->_BIFF_version = $BIFF_version; + $this->font_index = 0; + $this->_font_name = 'Arial'; + $this->_size = 10; + $this->_bold = 0x0190; + $this->_italic = 0; + $this->_color = 0x7FFF; + $this->_underline = 0; + $this->_font_strikeout = 0; + $this->_font_outline = 0; + $this->_font_shadow = 0; + $this->_font_script = 0; + $this->_font_family = 0; + $this->_font_charset = 0; + + $this->_num_format = 0; + + $this->_hidden = 0; + $this->_locked = 0; + + $this->_text_h_align = 0; + $this->_text_wrap = 0; + $this->_text_v_align = 2; + $this->_text_justlast = 0; + $this->_rotation = 0; + + $this->_fg_color = 0x40; + $this->_bg_color = 0x41; + + $this->_pattern = 0; + + $this->_bottom = 0; + $this->_top = 0; + $this->_left = 0; + $this->_right = 0; + $this->_diag = 0; + + $this->_bottom_color = 0x40; + $this->_top_color = 0x40; + $this->_left_color = 0x40; + $this->_right_color = 0x40; + $this->_diag_color = 0x40; + + // Set properties passed to Spreadsheet_Excel_Writer_Workbook::addFormat() + foreach ($properties as $property => $value) + { + if (method_exists($this, 'set'.ucwords($property))) { + $method_name = 'set'.ucwords($property); + $this->$method_name($value); + } + } + } + + + /** + * Generate an Excel BIFF XF record (style or cell). + * + * @param string $style The type of the XF record ('style' or 'cell'). + * @return string The XF record + */ + function getXf($style) + { + // Set the type of the XF record and some of the attributes. + if ($style == 'style') { + $style = 0xFFF5; + } else { + $style = $this->_locked; + $style |= $this->_hidden << 1; + } + + // Flags to indicate if attributes have been set. + $atr_num = ($this->_num_format != 0)?1:0; + $atr_fnt = ($this->font_index != 0)?1:0; + $atr_alc = ($this->_text_wrap)?1:0; + $atr_bdr = ($this->_bottom || + $this->_top || + $this->_left || + $this->_right)?1:0; + $atr_pat = (($this->_fg_color != 0x40) || + ($this->_bg_color != 0x41) || + $this->_pattern)?1:0; + $atr_prot = $this->_locked | $this->_hidden; + + // Zero the default border colour if the border has not been set. + if ($this->_bottom == 0) { + $this->_bottom_color = 0; + } + if ($this->_top == 0) { + $this->_top_color = 0; + } + if ($this->_right == 0) { + $this->_right_color = 0; + } + if ($this->_left == 0) { + $this->_left_color = 0; + } + if ($this->_diag == 0) { + $this->_diag_color = 0; + } + + $record = 0x00E0; // Record identifier + if ($this->_BIFF_version == 0x0500) { + $length = 0x0010; // Number of bytes to follow + } + if ($this->_BIFF_version == 0x0600) { + $length = 0x0014; + } + + $ifnt = $this->font_index; // Index to FONT record + $ifmt = $this->_num_format; // Index to FORMAT record + if ($this->_BIFF_version == 0x0500) { + $align = $this->_text_h_align; // Alignment + $align |= $this->_text_wrap << 3; + $align |= $this->_text_v_align << 4; + $align |= $this->_text_justlast << 7; + $align |= $this->_rotation << 8; + $align |= $atr_num << 10; + $align |= $atr_fnt << 11; + $align |= $atr_alc << 12; + $align |= $atr_bdr << 13; + $align |= $atr_pat << 14; + $align |= $atr_prot << 15; + + $icv = $this->_fg_color; // fg and bg pattern colors + $icv |= $this->_bg_color << 7; + + $fill = $this->_pattern; // Fill and border line style + $fill |= $this->_bottom << 6; + $fill |= $this->_bottom_color << 9; + + $border1 = $this->_top; // Border line style and color + $border1 |= $this->_left << 3; + $border1 |= $this->_right << 6; + $border1 |= $this->_top_color << 9; + + $border2 = $this->_left_color; // Border color + $border2 |= $this->_right_color << 7; + + $header = pack("vv", $record, $length); + $data = pack("vvvvvvvv", $ifnt, $ifmt, $style, $align, + $icv, $fill, + $border1, $border2); + } elseif ($this->_BIFF_version == 0x0600) { + $align = $this->_text_h_align; // Alignment + $align |= $this->_text_wrap << 3; + $align |= $this->_text_v_align << 4; + $align |= $this->_text_justlast << 7; + + $used_attrib = $atr_num << 2; + $used_attrib |= $atr_fnt << 3; + $used_attrib |= $atr_alc << 4; + $used_attrib |= $atr_bdr << 5; + $used_attrib |= $atr_pat << 6; + $used_attrib |= $atr_prot << 7; + + $icv = $this->_fg_color; // fg and bg pattern colors + $icv |= $this->_bg_color << 7; + + $border1 = $this->_left; // Border line style and color + $border1 |= $this->_right << 4; + $border1 |= $this->_top << 8; + $border1 |= $this->_bottom << 12; + $border1 |= $this->_left_color << 16; + $border1 |= $this->_right_color << 23; + $diag_tl_to_rb = 0; // FIXME: add method + $diag_tr_to_lb = 0; // FIXME: add method + $border1 |= $diag_tl_to_rb << 30; + $border1 |= $diag_tr_to_lb << 31; + + $border2 = $this->_top_color; // Border color + $border2 |= $this->_bottom_color << 7; + $border2 |= $this->_diag_color << 14; + $border2 |= $this->_diag << 21; + $border2 |= $this->_pattern << 26; + + $header = pack("vv", $record, $length); + + $rotation = 0x00; + $biff8_options = 0x00; + $data = pack("vvvC", $ifnt, $ifmt, $style, $align); + $data .= pack("CCC", $rotation, $biff8_options, $used_attrib); + $data .= pack("VVv", $border1, $border2, $icv); + } + + return($header . $data); + } + + /** + * Generate an Excel BIFF FONT record. + * + * @return string The FONT record + */ + function getFont() + { + $dyHeight = $this->_size * 20; // Height of font (1/20 of a point) + $icv = $this->_color; // Index to color palette + $bls = $this->_bold; // Bold style + $sss = $this->_font_script; // Superscript/subscript + $uls = $this->_underline; // Underline + $bFamily = $this->_font_family; // Font family + $bCharSet = $this->_font_charset; // Character set + $encoding = 0; // TODO: Unicode support + + $cch = strlen($this->_font_name); // Length of font name + $record = 0x31; // Record identifier + if ($this->_BIFF_version == 0x0500) { + $length = 0x0F + $cch; // Record length + } elseif ($this->_BIFF_version == 0x0600) { + $length = 0x10 + $cch; + } + $reserved = 0x00; // Reserved + $grbit = 0x00; // Font attributes + if ($this->_italic) { + $grbit |= 0x02; + } + if ($this->_font_strikeout) { + $grbit |= 0x08; + } + if ($this->_font_outline) { + $grbit |= 0x10; + } + if ($this->_font_shadow) { + $grbit |= 0x20; + } + + $header = pack("vv", $record, $length); + if ($this->_BIFF_version == 0x0500) { + $data = pack("vvvvvCCCCC", $dyHeight, $grbit, $icv, $bls, + $sss, $uls, $bFamily, + $bCharSet, $reserved, $cch); + } elseif ($this->_BIFF_version == 0x0600) { + $data = pack("vvvvvCCCCCC", $dyHeight, $grbit, $icv, $bls, + $sss, $uls, $bFamily, + $bCharSet, $reserved, $cch, $encoding); + } + return($header . $data . $this->_font_name); + } + + /** + * Returns a unique hash key for a font. + * Used by Spreadsheet_Excel_Writer_Workbook::_storeAllFonts() + * + * The elements that form the key are arranged to increase the probability of + * generating a unique key. Elements that hold a large range of numbers + * (eg. _color) are placed between two binary elements such as _italic + * + * @return string A key for this font + */ + function getFontKey() + { + $key = "$this->_font_name$this->_size"; + $key .= "$this->_font_script$this->_underline"; + $key .= "$this->_font_strikeout$this->_bold$this->_font_outline"; + $key .= "$this->_font_family$this->_font_charset"; + $key .= "$this->_font_shadow$this->_color$this->_italic"; + $key = str_replace(' ', '_', $key); + return ($key); + } + + /** + * Returns the index used by Spreadsheet_Excel_Writer_Worksheet::_XF() + * + * @return integer The index for the XF record + */ + function getXfIndex() + { + return($this->_xf_index); + } + + /** + * Used in conjunction with the set_xxx_color methods to convert a color + * string into a number. Color range is 0..63 but we will restrict it + * to 8..63 to comply with Gnumeric. Colors 0..7 are repeated in 8..15. + * + * @access private + * @param string $name_color name of the color (i.e.: 'blue', 'red', etc..). Optional. + * @return integer The color index + */ + function _getColor($name_color = '') + { + $colors = array( + 'aqua' => 0x0F, + 'cyan' => 0x0F, + 'black' => 0x08, + 'blue' => 0x0C, + 'brown' => 0x10, + 'magenta' => 0x0E, + 'fuchsia' => 0x0E, + 'gray' => 0x17, + 'grey' => 0x17, + 'green' => 0x11, + 'lime' => 0x0B, + 'navy' => 0x12, + 'orange' => 0x35, + 'purple' => 0x14, + 'red' => 0x0A, + 'silver' => 0x16, + 'white' => 0x09, + 'yellow' => 0x0D + ); + + // Return the default color, 0x7FFF, if undef, + if ($name_color == '') { + return(0x7FFF); + } + + // or the color string converted to an integer, + if (isset($colors[$name_color])) { + return($colors[$name_color]); + } + + // or the default color if string is unrecognised, + if (preg_match("/\D/",$name_color)) { + return(0x7FFF); + } + + // or an index < 8 mapped into the correct range, + if ($name_color < 8) { + return($name_color + 8); + } + + // or the default color if arg is outside range, + if ($name_color > 63) { + return(0x7FFF); + } + + // or an integer in the valid range + return($name_color); + } + + /** + * Set cell alignment. + * + * @access public + * @param string $location alignment for the cell ('left', 'right', etc...). + */ + function setAlign($location) + { + if (preg_match("/\d/",$location)) { + return; // Ignore numbers + } + + $location = strtolower($location); + + if ($location == 'left') { + $this->_text_h_align = 1; + } + if ($location == 'centre') { + $this->_text_h_align = 2; + } + if ($location == 'center') { + $this->_text_h_align = 2; + } + if ($location == 'right') { + $this->_text_h_align = 3; + } + if ($location == 'fill') { + $this->_text_h_align = 4; + } + if ($location == 'justify') { + $this->_text_h_align = 5; + } + if ($location == 'merge') { + $this->_text_h_align = 6; + } + if ($location == 'equal_space') { // For T.K. + $this->_text_h_align = 7; + } + if ($location == 'top') { + $this->_text_v_align = 0; + } + if ($location == 'vcentre') { + $this->_text_v_align = 1; + } + if ($location == 'vcenter') { + $this->_text_v_align = 1; + } + if ($location == 'bottom') { + $this->_text_v_align = 2; + } + if ($location == 'vjustify') { + $this->_text_v_align = 3; + } + if ($location == 'vequal_space') { // For T.K. + $this->_text_v_align = 4; + } + } + + /** + * Set cell horizontal alignment. + * + * @access public + * @param string $location alignment for the cell ('left', 'right', etc...). + */ + function setHAlign($location) + { + if (preg_match("/\d/",$location)) { + return; // Ignore numbers + } + + $location = strtolower($location); + + if ($location == 'left') { + $this->_text_h_align = 1; + } + if ($location == 'centre') { + $this->_text_h_align = 2; + } + if ($location == 'center') { + $this->_text_h_align = 2; + } + if ($location == 'right') { + $this->_text_h_align = 3; + } + if ($location == 'fill') { + $this->_text_h_align = 4; + } + if ($location == 'justify') { + $this->_text_h_align = 5; + } + if ($location == 'merge') { + $this->_text_h_align = 6; + } + if ($location == 'equal_space') { // For T.K. + $this->_text_h_align = 7; + } + } + + /** + * Set cell vertical alignment. + * + * @access public + * @param string $location alignment for the cell ('top', 'vleft', 'vright', etc...). + */ + function setVAlign($location) + { + if (preg_match("/\d/",$location)) { + return; // Ignore numbers + } + + $location = strtolower($location); + + if ($location == 'top') { + $this->_text_v_align = 0; + } + if ($location == 'vcentre') { + $this->_text_v_align = 1; + } + if ($location == 'vcenter') { + $this->_text_v_align = 1; + } + if ($location == 'bottom') { + $this->_text_v_align = 2; + } + if ($location == 'vjustify') { + $this->_text_v_align = 3; + } + if ($location == 'vequal_space') { // For T.K. + $this->_text_v_align = 4; + } + } + + /** + * This is an alias for the unintuitive setAlign('merge') + * + * @access public + */ + function setMerge() + { + $this->setAlign('merge'); + } + + /** + * Sets the boldness of the text. + * Bold has a range 100..1000. + * 0 (400) is normal. 1 (700) is bold. + * + * @access public + * @param integer $weight Weight for the text, 0 maps to 400 (normal text), + 1 maps to 700 (bold text). Valid range is: 100-1000. + It's Optional, default is 1 (bold). + */ + function setBold($weight = 1) + { + if ($weight == 1) { + $weight = 0x2BC; // Bold text + } + if ($weight == 0) { + $weight = 0x190; // Normal text + } + if ($weight < 0x064) { + $weight = 0x190; // Lower bound + } + if ($weight > 0x3E8) { + $weight = 0x190; // Upper bound + } + $this->_bold = $weight; + } + + + /************************************ + * FUNCTIONS FOR SETTING CELLS BORDERS + */ + + /** + * Sets the width for the bottom border of the cell + * + * @access public + * @param integer $style style of the cell border. 1 => thin, 2 => thick. + */ + function setBottom($style) + { + $this->_bottom = $style; + } + + /** + * Sets the width for the top border of the cell + * + * @access public + * @param integer $style style of the cell top border. 1 => thin, 2 => thick. + */ + function setTop($style) + { + $this->_top = $style; + } + + /** + * Sets the width for the left border of the cell + * + * @access public + * @param integer $style style of the cell left border. 1 => thin, 2 => thick. + */ + function setLeft($style) + { + $this->_left = $style; + } + + /** + * Sets the width for the right border of the cell + * + * @access public + * @param integer $style style of the cell right border. 1 => thin, 2 => thick. + */ + function setRight($style) + { + $this->_right = $style; + } + + + /** + * Set cells borders to the same style + * + * @access public + * @param integer $style style to apply for all cell borders. 1 => thin, 2 => thick. + */ + function setBorder($style) + { + $this->setBottom($style); + $this->setTop($style); + $this->setLeft($style); + $this->setRight($style); + } + + + /******************************************* + * FUNCTIONS FOR SETTING CELLS BORDERS COLORS + */ + + /** + * Sets all the cell's borders to the same color + * + * @access public + * @param mixed $color The color we are setting. Either a string (like 'blue'), + * or an integer (range is [8...63]). + */ + function setBorderColor($color) + { + $this->setBottomColor($color); + $this->setTopColor($color); + $this->setLeftColor($color); + $this->setRightColor($color); + } + + /** + * Sets the cell's bottom border color + * + * @access public + * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). + */ + function setBottomColor($color) + { + $value = $this->_getColor($color); + $this->_bottom_color = $value; + } + + /** + * Sets the cell's top border color + * + * @access public + * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). + */ + function setTopColor($color) + { + $value = $this->_getColor($color); + $this->_top_color = $value; + } + + /** + * Sets the cell's left border color + * + * @access public + * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). + */ + function setLeftColor($color) + { + $value = $this->_getColor($color); + $this->_left_color = $value; + } + + /** + * Sets the cell's right border color + * + * @access public + * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). + */ + function setRightColor($color) + { + $value = $this->_getColor($color); + $this->_right_color = $value; + } + + + /** + * Sets the cell's foreground color + * + * @access public + * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). + */ + function setFgColor($color) + { + $value = $this->_getColor($color); + $this->_fg_color = $value; + if ($this->_pattern == 0) { // force color to be seen + $this->_pattern = 1; + } + } + + /** + * Sets the cell's background color + * + * @access public + * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). + */ + function setBgColor($color) + { + $value = $this->_getColor($color); + $this->_bg_color = $value; + if ($this->_pattern == 0) { // force color to be seen + $this->_pattern = 1; + } + } + + /** + * Sets the cell's color + * + * @access public + * @param mixed $color either a string (like 'blue'), or an integer (range is [8...63]). + */ + function setColor($color) + { + $value = $this->_getColor($color); + $this->_color = $value; + } + + /** + * Sets the fill pattern attribute of a cell + * + * @access public + * @param integer $arg Optional. Defaults to 1. Meaningful values are: 0-18, + * 0 meaning no background. + */ + function setPattern($arg = 1) + { + $this->_pattern = $arg; + } + + /** + * Sets the underline of the text + * + * @access public + * @param integer $underline The value for underline. Possible values are: + * 1 => underline, 2 => double underline. + */ + function setUnderline($underline) + { + $this->_underline = $underline; + } + + /** + * Sets the font style as italic + * + * @access public + */ + function setItalic() + { + $this->_italic = 1; + } + + /** + * Sets the font size + * + * @access public + * @param integer $size The font size (in pixels I think). + */ + function setSize($size) + { + $this->_size = $size; + } + + /** + * Sets text wrapping + * + * @access public + */ + function setTextWrap() + { + $this->_text_wrap = 1; + } + + /** + * Sets the orientation of the text + * + * @access public + * @param integer $angle The rotation angle for the text (clockwise). Possible + values are: 0, 90, 270 and -1 for stacking top-to-bottom. + */ + function setTextRotation($angle) + { + switch ($angle) + { + case 0: + $this->_rotation = 0; + break; + case 90: + $this->_rotation = 3; + break; + case 270: + $this->_rotation = 2; + break; + case -1: + $this->_rotation = 1; + break; + default : + return $this->raiseError("Invalid value for angle.". + " Possible values are: 0, 90, 270 and -1 ". + "for stacking top-to-bottom."); + $this->_rotation = 0; + break; + } + } + + /** + * Sets the numeric format. + * It can be date, time, currency, etc... + * + * @access public + * @param integer $num_format The numeric format. + */ + function setNumFormat($num_format) + { + $this->_num_format = $num_format; + } + + /** + * Sets font as strikeout. + * + * @access public + */ + function setStrikeOut() + { + $this->_font_strikeout = 1; + } + + /** + * Sets outlining for a font. + * + * @access public + */ + function setOutLine() + { + $this->_font_outline = 1; + } + + /** + * Sets font as shadow. + * + * @access public + */ + function setShadow() + { + $this->_font_shadow = 1; + } + + /** + * Sets the script type of the text + * + * @access public + * @param integer $script The value for script type. Possible values are: + * 1 => superscript, 2 => subscript. + */ + function setScript($script) + { + $this->_font_script = $script; + } + + /** + * Locks a cell. + * + * @access public + */ + function setLocked() + { + $this->_locked = 1; + } + + /** + * Unlocks a cell. Useful for unprotecting particular cells of a protected sheet. + * + * @access public + */ + function setUnLocked() + { + $this->_locked = 0; + } + + /** + * Sets the font family name. + * + * @access public + * @param string $fontfamily The font family name. Possible values are: + * 'Times New Roman', 'Arial', 'Courier'. + */ + function setFontFamily($font_family) + { + $this->_font_name = $font_family; + } +} +?> diff --git a/include/Excel/OLE.php b/include/Excel/OLE.php new file mode 100644 index 000000000..40efcf1cf --- /dev/null +++ b/include/Excel/OLE.php @@ -0,0 +1,408 @@ + | +// | Based on OLE::Storage_Lite by Kawai, Takanori | +// +----------------------------------------------------------------------+ +// +// $Id: OLE.php,v 1.7 2003/08/21 15:15:40 xnoguer Exp $ + + +/** +* Constants for OLE package +*/ +define('OLE_PPS_TYPE_ROOT', 5); +define('OLE_PPS_TYPE_DIR', 1); +define('OLE_PPS_TYPE_FILE', 2); +define('OLE_DATA_SIZE_SMALL', 0x1000); +define('OLE_LONG_INT_SIZE', 4); +define('OLE_PPS_SIZE', 0x80); + + +/** +* OLE package base class. +* +* @author Xavier Noguer +* @category Structures +* @package OLE +*/ +class OLE extends PEAR +{ + /** + * The file handle for reading an OLE container + * @var resource + */ + var $_file_handle; + + /** + * Array of PPS's found on the OLE container + * @var array + */ + var $_list; + + /** + * Creates a new OLE object + * Remember to use ampersand when creating an OLE object ($my_ole =& new OLE();) + * @access public + */ + function OLE() + { + $this->_list = array(); + } + + /** + * Reads an OLE container from the contents of the file given. + * + * @acces public + * @param string $file + * @return mixed true on success, PEAR_Error on failure + */ + function read($file) + { + /* consider storing offsets as constants */ + $big_block_size_offset = 30; + $iBdbCnt_offset = 44; + $bd_start_offset = 68; + + $fh = @fopen($file, "r"); + if ($fh == false) { + return $this->raiseError("Can't open file $file"); + } + $this->_file_handle = $fh; + + /* begin reading OLE attributes */ + fseek($fh, 0); + $signature = fread($fh, 8); + if ("\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1" != $signature) { + return $this->raiseError("File doesn't seem to be an OLE container."); + } + fseek($fh, $big_block_size_offset); + $packed_array = unpack("v", fread($fh, 2)); + $big_block_size = pow(2, $packed_array['']); + + $packed_array = unpack("v", fread($fh, 2)); + $small_block_size = pow(2, $packed_array['']); + $i1stBdL = ($big_block_size - 0x4C) / OLE_LONG_INT_SIZE; + + fseek($fh, $iBdbCnt_offset); + $packed_array = unpack("V", fread($fh, 4)); + $iBdbCnt = $packed_array['']; + + $packed_array = unpack("V", fread($fh, 4)); + $pps_wk_start = $packed_array['']; + + fseek($fh, $bd_start_offset); + $packed_array = unpack("V", fread($fh, 4)); + $bd_start = $packed_array['']; + $packed_array = unpack("V", fread($fh, 4)); + $bd_count = $packed_array['']; + $packed_array = unpack("V", fread($fh, 4)); + $iAll = $packed_array['']; // this may be wrong + /* create OLE_PPS objects from */ + $ret = $this->_readPpsWks($pps_wk_start, $big_block_size); + if (PEAR::isError($ret)) { + return $ret; + } + return true; + } + + /** + * Destructor (using PEAR) + * Just closes the file handle on the OLE file. + * + * @access private + */ + function _OLE() + { + fclose($this->_file_handle); + } + + /** + * Gets information about all PPS's on the OLE container from the PPS WK's + * creates an OLE_PPS object for each one. + * + * @access private + * @param integer $pps_wk_start Position inside the OLE file where PPS WK's start + * @param integer $big_block_size Size of big blobks in the OLE file + * @return mixed true on success, PEAR_Error on failure + */ + function _readPpsWks($pps_wk_start, $big_block_size) + { + $pointer = ($pps_wk_start + 1) * $big_block_size; + while (1) + { + fseek($this->_file_handle, $pointer); + $pps_wk = fread($this->_file_handle, OLE_PPS_SIZE); + if (strlen($pps_wk) != OLE_PPS_SIZE) { + break; // Excel likes to add a trailing byte sometimes + //return $this->raiseError("PPS at $pointer seems too short: ".strlen($pps_wk)); + } + $name_length = unpack("c", substr($pps_wk, 64, 2)); // FIXME (2 bytes??) + $name_length = $name_length[''] - 2; + $name = substr($pps_wk, 0, $name_length); + $type = unpack("c", substr($pps_wk, 66, 1)); + if (($type[''] != OLE_PPS_TYPE_ROOT) and + ($type[''] != OLE_PPS_TYPE_DIR) and + ($type[''] != OLE_PPS_TYPE_FILE)) + { + return $this->raiseError("PPS at $pointer has unknown type: {$type['']}"); + } + $prev = unpack("V", substr($pps_wk, 68, 4)); + $next = unpack("V", substr($pps_wk, 72, 4)); + $dir = unpack("V", substr($pps_wk, 76, 4)); + // there is no magic number, it can take different values. + //$magic = unpack("V", strrev(substr($pps_wk, 92, 4))); + $time_1st = substr($pps_wk, 100, 8); + $time_2nd = substr($pps_wk, 108, 8); + $start_block = unpack("V", substr($pps_wk, 116, 4)); + $size = unpack("V", substr($pps_wk, 120, 4)); + // _data member will point to position in file!! + // OLE_PPS object is created with an empty children array!! + $this->_list[] = new OLE_PPS(null, '', $type[''], $prev[''], $next[''], + $dir[''], OLE::OLE2LocalDate($time_1st), + OLE::OLE2LocalDate($time_2nd), + ($start_block[''] + 1) * $big_block_size, array()); + // give it a size + $this->_list[count($this->_list) - 1]->Size = $size['']; + // check if the PPS tree (starting from root) is complete + if ($this->_ppsTreeComplete(0)) { + break; + } + $pointer += OLE_PPS_SIZE; + } + } + + /** + * It checks whether the PPS tree is complete (all PPS's read) + * starting with the given PPS (not necessarily root) + * + * @access private + * @param integer $index The index of the PPS from which we are checking + * @return boolean Whether the PPS tree for the given PPS is complete + */ + function _ppsTreeComplete($index) + { + if ($this->_list[$index]->NextPps != -1) { + if (!isset($this->_list[$this->_list[$index]->NextPps])) { + return false; + } + else { + return $this->_ppsTreeComplete($this->_list[$index]->NextPps); + } + } + if ($this->_list[$index]->DirPps != -1) { + if (!isset($this->_list[$this->_list[$index]->DirPps])) { + return false; + } + else { + return $this->_ppsTreeComplete($this->_list[$index]->DirPps); + } + } + return true; + } + + /** + * Checks whether a PPS is a File PPS or not. + * If there is no PPS for the index given, it will return false. + * + * @access public + * @param integer $index The index for the PPS + * @return bool true if it's a File PPS, false otherwise + */ + function isFile($index) + { + if (isset($this->_list[$index])) { + return ($this->_list[$index]->Type == OLE_PPS_TYPE_FILE); + } + return false; + } + + /** + * Checks whether a PPS is a Root PPS or not. + * If there is no PPS for the index given, it will return false. + * + * @access public + * @param integer $index The index for the PPS. + * @return bool true if it's a Root PPS, false otherwise + */ + function isRoot($index) + { + if (isset($this->_list[$index])) { + return ($this->_list[$index]->Type == OLE_PPS_TYPE_ROOT); + } + return false; + } + + /** + * Gives the total number of PPS's found in the OLE container. + * + * @access public + * @return integer The total number of PPS's found in the OLE container + */ + function ppsTotal() + { + return count($this->_list); + } + + /** + * Gets data from a PPS + * If there is no PPS for the index given, it will return an empty string. + * + * @access public + * @param integer $index The index for the PPS + * @param integer $position The position from which to start reading + * (relative to the PPS) + * @param integer $length The amount of bytes to read (at most) + * @return string The binary string containing the data requested + */ + function getData($index, $position, $length) + { + // if position is not valid return empty string + if (!isset($this->_list[$index]) or ($position >= $this->_list[$index]->Size) or ($position < 0)) { + return ''; + } + // Beware!!! _data member is actually a position + fseek($this->_file_handle, $this->_list[$index]->_data + $position); + return fread($this->_file_handle, $length); + } + + /** + * Gets the data length from a PPS + * If there is no PPS for the index given, it will return 0. + * + * @access public + * @param integer $index The index for the PPS + * @return integer The amount of bytes in data the PPS has + */ + function getDataLength($index) + { + if (isset($this->_list[$index])) { + return $this->_list[$index]->Size; + } + return 0; + } + + /** + * Utility function to transform ASCII text to Unicode + * + * @access public + * @static + * @param string $ascii The ASCII string to transform + * @return string The string in Unicode + */ + function Asc2Ucs($ascii) + { + $rawname = ''; + for ($i = 0; $i < strlen($ascii); $i++) { + $rawname .= $ascii{$i}."\x00"; + } + return $rawname; + } + + /** + * Utility function + * Returns a string for the OLE container with the date given + * + * @access public + * @static + * @param integer $date A timestamp + * @return string The string for the OLE container + */ + function LocalDate2OLE($date = null) + { + if (!isset($date)) { + return "\x00\x00\x00\x00\x00\x00\x00\x00"; + } + + // factor used for separating numbers into 4 bytes parts + $factor = pow(2,32); + + // days from 1-1-1601 until the beggining of UNIX era + $days = 134774; + // calculate seconds + $big_date = $days*24*3600 + gmmktime(date("H",$date),date("i",$date),date("s",$date), + date("m",$date),date("d",$date),date("Y",$date)); + // multiply just to make MS happy + $big_date *= 10000000; + + $high_part = floor($big_date/$factor); + // lower 4 bytes + $low_part = floor((($big_date/$factor) - $high_part)*$factor); + + // Make HEX string + $res = ''; + + for ($i=0; $i<4; $i++) + { + $hex = $low_part % 0x100; + $res .= pack('c', $hex); + $low_part /= 0x100; + } + for ($i=0; $i<4; $i++) + { + $hex = $high_part % 0x100; + $res .= pack('c', $hex); + $high_part /= 0x100; + } + return $res; + } + + /** + * Returns a timestamp from an OLE container's date + * + * @access public + * @static + * @param integer $string A binary string with the encoded date + * @return string The timestamp corresponding to the string + */ + function OLE2LocalDate($string) + { + if (strlen($string) != 8) { + return new PEAR_Error("Expecting 8 byte string"); + } + + // factor used for separating numbers into 4 bytes parts + $factor = pow(2,32); + $high_part = 0; + for ($i=0; $i<4; $i++) + { + $al = unpack('C', $string{(7 - $i)}); + $high_part += $al['']; + if ($i < 3) { + $high_part *= 0x100; + } + } + $low_part = 0; + for ($i=4; $i<8; $i++) + { + $al = unpack('C', $string{(7 - $i)}); + $low_part += $al['']; + if ($i < 7) { + $low_part *= 0x100; + } + } + $big_date = ($high_part*$factor) + $low_part; + // translate to seconds + $big_date /= 10000000; + + // days from 1-1-1601 until the beggining of UNIX era + $days = 134774; + + // translate to seconds from beggining of UNIX era + $big_date -= $days*24*3600; + return floor($big_date); + } +} +?> diff --git a/include/Excel/PEAR.php b/include/Excel/PEAR.php new file mode 100644 index 000000000..7e60a9e4e --- /dev/null +++ b/include/Excel/PEAR.php @@ -0,0 +1,1095 @@ + + * @author Stig Bakken + * @author Tomas V.V.Cox + * @author Greg Beaver + * @copyright 1997-2006 The PHP Group + * @license http://www.php.net/license/3_0.txt PHP License 3.0 + * @version CVS: $Id: PEAR.php,v 1.97 2006/01/06 04:47:36 cellog Exp $ + * @link http://pear.php.net/package/PEAR + * @since File available since Release 0.1 + */ + +/**#@+ + * ERROR constants + */ +define('PEAR_ERROR_RETURN', 1); +define('PEAR_ERROR_PRINT', 2); +define('PEAR_ERROR_TRIGGER', 4); +define('PEAR_ERROR_DIE', 8); +define('PEAR_ERROR_CALLBACK', 16); +/** + * WARNING: obsolete + * @deprecated + */ +define('PEAR_ERROR_EXCEPTION', 32); +/**#@-*/ +define('PEAR_ZE2', (function_exists('version_compare') && + version_compare(zend_version(), "2-dev", "ge"))); + +if (substr(PHP_OS, 0, 3) == 'WIN') { + define('OS_WINDOWS', true); + define('OS_UNIX', false); + define('PEAR_OS', 'Windows'); +} else { + define('OS_WINDOWS', false); + define('OS_UNIX', true); + define('PEAR_OS', 'Unix'); // blatant assumption +} + +// instant backwards compatibility +if (!defined('PATH_SEPARATOR')) { + if (OS_WINDOWS) { + define('PATH_SEPARATOR', ';'); + } else { + define('PATH_SEPARATOR', ':'); + } +} + +$GLOBALS['_PEAR_default_error_mode'] = PEAR_ERROR_RETURN; +$GLOBALS['_PEAR_default_error_options'] = E_USER_NOTICE; +$GLOBALS['_PEAR_destructor_object_list'] = array(); +$GLOBALS['_PEAR_shutdown_funcs'] = array(); +$GLOBALS['_PEAR_error_handler_stack'] = array(); + +@ini_set('track_errors', true); + +/** + * Base class for other PEAR classes. Provides rudimentary + * emulation of destructors. + * + * If you want a destructor in your class, inherit PEAR and make a + * destructor method called _yourclassname (same name as the + * constructor, but with a "_" prefix). Also, in your constructor you + * have to call the PEAR constructor: $this->PEAR();. + * The destructor method will be called without parameters. Note that + * at in some SAPI implementations (such as Apache), any output during + * the request shutdown (in which destructors are called) seems to be + * discarded. If you need to get any debug information from your + * destructor, use error_log(), syslog() or something similar. + * + * IMPORTANT! To use the emulated destructors you need to create the + * objects by reference: $obj =& new PEAR_child; + * + * @category pear + * @package PEAR + * @author Stig Bakken + * @author Tomas V.V. Cox + * @author Greg Beaver + * @copyright 1997-2006 The PHP Group + * @license http://www.php.net/license/3_0.txt PHP License 3.0 + * @version Release: 1.4.6 + * @link http://pear.php.net/package/PEAR + * @see PEAR_Error + * @since Class available since PHP 4.0.2 + * @link http://pear.php.net/manual/en/core.pear.php#core.pear.pear + */ +class PEAR +{ + // {{{ properties + + /** + * Whether to enable internal debug messages. + * + * @var bool + * @access private + */ + var $_debug = false; + + /** + * Default error mode for this object. + * + * @var int + * @access private + */ + var $_default_error_mode = null; + + /** + * Default error options used for this object when error mode + * is PEAR_ERROR_TRIGGER. + * + * @var int + * @access private + */ + var $_default_error_options = null; + + /** + * Default error handler (callback) for this object, if error mode is + * PEAR_ERROR_CALLBACK. + * + * @var string + * @access private + */ + var $_default_error_handler = ''; + + /** + * Which class to use for error objects. + * + * @var string + * @access private + */ + var $_error_class = 'PEAR_Error'; + + /** + * An array of expected errors. + * + * @var array + * @access private + */ + var $_expected_errors = array(); + + // }}} + + // {{{ constructor + + /** + * Constructor. Registers this object in + * $_PEAR_destructor_object_list for destructor emulation if a + * destructor object exists. + * + * @param string $error_class (optional) which class to use for + * error objects, defaults to PEAR_Error. + * @access public + * @return void + */ + function PEAR($error_class = null) + { + $classname = strtolower(get_class($this)); + if ($this->_debug) { + print "PEAR constructor called, class=$classname\n"; + } + if ($error_class !== null) { + $this->_error_class = $error_class; + } + while ($classname && strcasecmp($classname, "pear")) { + $destructor = "_$classname"; + if (method_exists($this, $destructor)) { + global $_PEAR_destructor_object_list; + $_PEAR_destructor_object_list[] = &$this; + if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) { + register_shutdown_function("_PEAR_call_destructors"); + $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true; + } + break; + } else { + $classname = get_parent_class($classname); + } + } + } + + // }}} + // {{{ destructor + + /** + * Destructor (the emulated type of...). Does nothing right now, + * but is included for forward compatibility, so subclass + * destructors should always call it. + * + * See the note in the class desciption about output from + * destructors. + * + * @access public + * @return void + */ + function _PEAR() { + if ($this->_debug) { + printf("PEAR destructor called, class=%s\n", strtolower(get_class($this))); + } + } + + // }}} + // {{{ getStaticProperty() + + /** + * If you have a class that's mostly/entirely static, and you need static + * properties, you can use this method to simulate them. Eg. in your method(s) + * do this: $myVar = &PEAR::getStaticProperty('myclass', 'myVar'); + * You MUST use a reference, or they will not persist! + * + * @access public + * @param string $class The calling classname, to prevent clashes + * @param string $var The variable to retrieve. + * @return mixed A reference to the variable. If not set it will be + * auto initialised to NULL. + */ + function &getStaticProperty($class, $var) + { + static $properties; + return $properties[$class][$var]; + } + + // }}} + // {{{ registerShutdownFunc() + + /** + * Use this function to register a shutdown method for static + * classes. + * + * @access public + * @param mixed $func The function name (or array of class/method) to call + * @param mixed $args The arguments to pass to the function + * @return void + */ + function registerShutdownFunc($func, $args = array()) + { + $GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args); + } + + // }}} + // {{{ isError() + + /** + * Tell whether a value is a PEAR error. + * + * @param mixed $data the value to test + * @param int $code if $data is an error object, return true + * only if $code is a string and + * $obj->getMessage() == $code or + * $code is an integer and $obj->getCode() == $code + * @access public + * @return bool true if parameter is an error + */ + function isError($data, $code = null) + { + if (is_a($data, 'PEAR_Error')) { + if (is_null($code)) { + return true; + } elseif (is_string($code)) { + return $data->getMessage() == $code; + } else { + return $data->getCode() == $code; + } + } + return false; + } + + // }}} + // {{{ setErrorHandling() + + /** + * Sets how errors generated by this object should be handled. + * Can be invoked both in objects and statically. If called + * statically, setErrorHandling sets the default behaviour for all + * PEAR objects. If called in an object, setErrorHandling sets + * the default behaviour for that object. + * + * @param int $mode + * One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, + * PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE, + * PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION. + * + * @param mixed $options + * When $mode is PEAR_ERROR_TRIGGER, this is the error level (one + * of E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR). + * + * When $mode is PEAR_ERROR_CALLBACK, this parameter is expected + * to be the callback function or method. A callback + * function is a string with the name of the function, a + * callback method is an array of two elements: the element + * at index 0 is the object, and the element at index 1 is + * the name of the method to call in the object. + * + * When $mode is PEAR_ERROR_PRINT or PEAR_ERROR_DIE, this is + * a printf format string used when printing the error + * message. + * + * @access public + * @return void + * @see PEAR_ERROR_RETURN + * @see PEAR_ERROR_PRINT + * @see PEAR_ERROR_TRIGGER + * @see PEAR_ERROR_DIE + * @see PEAR_ERROR_CALLBACK + * @see PEAR_ERROR_EXCEPTION + * + * @since PHP 4.0.5 + */ + + function setErrorHandling($mode = null, $options = null) + { + if (isset($this) && is_a($this, 'PEAR')) { + $setmode = &$this->_default_error_mode; + $setoptions = &$this->_default_error_options; + } else { + $setmode = &$GLOBALS['_PEAR_default_error_mode']; + $setoptions = &$GLOBALS['_PEAR_default_error_options']; + } + + switch ($mode) { + case PEAR_ERROR_EXCEPTION: + case PEAR_ERROR_RETURN: + case PEAR_ERROR_PRINT: + case PEAR_ERROR_TRIGGER: + case PEAR_ERROR_DIE: + case null: + $setmode = $mode; + $setoptions = $options; + break; + + case PEAR_ERROR_CALLBACK: + $setmode = $mode; + // class/object method callback + if (is_callable($options)) { + $setoptions = $options; + } else { + trigger_error("invalid error callback", E_USER_WARNING); + } + break; + + default: + trigger_error("invalid error mode", E_USER_WARNING); + break; + } + } + + // }}} + // {{{ expectError() + + /** + * This method is used to tell which errors you expect to get. + * Expected errors are always returned with error mode + * PEAR_ERROR_RETURN. Expected error codes are stored in a stack, + * and this method pushes a new element onto it. The list of + * expected errors are in effect until they are popped off the + * stack with the popExpect() method. + * + * Note that this method can not be called statically + * + * @param mixed $code a single error code or an array of error codes to expect + * + * @return int the new depth of the "expected errors" stack + * @access public + */ + function expectError($code = '*') + { + if (is_array($code)) { + array_push($this->_expected_errors, $code); + } else { + array_push($this->_expected_errors, array($code)); + } + return sizeof($this->_expected_errors); + } + + // }}} + // {{{ popExpect() + + /** + * This method pops one element off the expected error codes + * stack. + * + * @return array the list of error codes that were popped + */ + function popExpect() + { + return array_pop($this->_expected_errors); + } + + // }}} + // {{{ _checkDelExpect() + + /** + * This method checks unsets an error code if available + * + * @param mixed error code + * @return bool true if the error code was unset, false otherwise + * @access private + * @since PHP 4.3.0 + */ + function _checkDelExpect($error_code) + { + $deleted = false; + + foreach ($this->_expected_errors AS $key => $error_array) { + if (in_array($error_code, $error_array)) { + unset($this->_expected_errors[$key][array_search($error_code, $error_array)]); + $deleted = true; + } + + // clean up empty arrays + if (0 == count($this->_expected_errors[$key])) { + unset($this->_expected_errors[$key]); + } + } + return $deleted; + } + + // }}} + // {{{ delExpect() + + /** + * This method deletes all occurences of the specified element from + * the expected error codes stack. + * + * @param mixed $error_code error code that should be deleted + * @return mixed list of error codes that were deleted or error + * @access public + * @since PHP 4.3.0 + */ + function delExpect($error_code) + { + $deleted = false; + + if ((is_array($error_code) && (0 != count($error_code)))) { + // $error_code is a non-empty array here; + // we walk through it trying to unset all + // values + foreach($error_code as $key => $error) { + if ($this->_checkDelExpect($error)) { + $deleted = true; + } else { + $deleted = false; + } + } + return $deleted ? true : PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME + } elseif (!empty($error_code)) { + // $error_code comes alone, trying to unset it + if ($this->_checkDelExpect($error_code)) { + return true; + } else { + return PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME + } + } else { + // $error_code is empty + return PEAR::raiseError("The expected error you submitted is empty"); // IMPROVE ME + } + } + + // }}} + // {{{ raiseError() + + /** + * This method is a wrapper that returns an instance of the + * configured error class with this object's default error + * handling applied. If the $mode and $options parameters are not + * specified, the object's defaults are used. + * + * @param mixed $message a text error message or a PEAR error object + * + * @param int $code a numeric error code (it is up to your class + * to define these if you want to use codes) + * + * @param int $mode One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, + * PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE, + * PEAR_ERROR_CALLBACK, PEAR_ERROR_EXCEPTION. + * + * @param mixed $options If $mode is PEAR_ERROR_TRIGGER, this parameter + * specifies the PHP-internal error level (one of + * E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR). + * If $mode is PEAR_ERROR_CALLBACK, this + * parameter specifies the callback function or + * method. In other error modes this parameter + * is ignored. + * + * @param string $userinfo If you need to pass along for example debug + * information, this parameter is meant for that. + * + * @param string $error_class The returned error object will be + * instantiated from this class, if specified. + * + * @param bool $skipmsg If true, raiseError will only pass error codes, + * the error message parameter will be dropped. + * + * @access public + * @return object a PEAR error object + * @see PEAR::setErrorHandling + * @since PHP 4.0.5 + */ + function &raiseError($message = null, + $code = null, + $mode = null, + $options = null, + $userinfo = null, + $error_class = null, + $skipmsg = false) + { + // The error is yet a PEAR error object + if (is_object($message)) { + $code = $message->getCode(); + $userinfo = $message->getUserInfo(); + $error_class = $message->getType(); + $message->error_message_prefix = ''; + $message = $message->getMessage(); + } + + if (isset($this) && isset($this->_expected_errors) && sizeof($this->_expected_errors) > 0 && sizeof($exp = end($this->_expected_errors))) { + if ($exp[0] == "*" || + (is_int(reset($exp)) && in_array($code, $exp)) || + (is_string(reset($exp)) && in_array($message, $exp))) { + $mode = PEAR_ERROR_RETURN; + } + } + // No mode given, try global ones + if ($mode === null) { + // Class error handler + if (isset($this) && isset($this->_default_error_mode)) { + $mode = $this->_default_error_mode; + $options = $this->_default_error_options; + // Global error handler + } elseif (isset($GLOBALS['_PEAR_default_error_mode'])) { + $mode = $GLOBALS['_PEAR_default_error_mode']; + $options = $GLOBALS['_PEAR_default_error_options']; + } + } + + if ($error_class !== null) { + $ec = $error_class; + } elseif (isset($this) && isset($this->_error_class)) { + $ec = $this->_error_class; + } else { + $ec = 'PEAR_Error'; + } + if ($skipmsg) { + $a = &new $ec($code, $mode, $options, $userinfo); + return $a; + } else { + $a = &new $ec($message, $code, $mode, $options, $userinfo); + return $a; + } + } + + // }}} + // {{{ throwError() + + /** + * Simpler form of raiseError with fewer options. In most cases + * message, code and userinfo are enough. + * + * @param string $message + * + */ + function &throwError($message = null, + $code = null, + $userinfo = null) + { + if (isset($this) && is_a($this, 'PEAR')) { + $a = &$this->raiseError($message, $code, null, null, $userinfo); + return $a; + } else { + $a = &PEAR::raiseError($message, $code, null, null, $userinfo); + return $a; + } + } + + // }}} + function staticPushErrorHandling($mode, $options = null) + { + $stack = &$GLOBALS['_PEAR_error_handler_stack']; + $def_mode = &$GLOBALS['_PEAR_default_error_mode']; + $def_options = &$GLOBALS['_PEAR_default_error_options']; + $stack[] = array($def_mode, $def_options); + switch ($mode) { + case PEAR_ERROR_EXCEPTION: + case PEAR_ERROR_RETURN: + case PEAR_ERROR_PRINT: + case PEAR_ERROR_TRIGGER: + case PEAR_ERROR_DIE: + case null: + $def_mode = $mode; + $def_options = $options; + break; + + case PEAR_ERROR_CALLBACK: + $def_mode = $mode; + // class/object method callback + if (is_callable($options)) { + $def_options = $options; + } else { + trigger_error("invalid error callback", E_USER_WARNING); + } + break; + + default: + trigger_error("invalid error mode", E_USER_WARNING); + break; + } + $stack[] = array($mode, $options); + return true; + } + + function staticPopErrorHandling() + { + $stack = &$GLOBALS['_PEAR_error_handler_stack']; + $setmode = &$GLOBALS['_PEAR_default_error_mode']; + $setoptions = &$GLOBALS['_PEAR_default_error_options']; + array_pop($stack); + list($mode, $options) = $stack[sizeof($stack) - 1]; + array_pop($stack); + switch ($mode) { + case PEAR_ERROR_EXCEPTION: + case PEAR_ERROR_RETURN: + case PEAR_ERROR_PRINT: + case PEAR_ERROR_TRIGGER: + case PEAR_ERROR_DIE: + case null: + $setmode = $mode; + $setoptions = $options; + break; + + case PEAR_ERROR_CALLBACK: + $setmode = $mode; + // class/object method callback + if (is_callable($options)) { + $setoptions = $options; + } else { + trigger_error("invalid error callback", E_USER_WARNING); + } + break; + + default: + trigger_error("invalid error mode", E_USER_WARNING); + break; + } + return true; + } + + // {{{ pushErrorHandling() + + /** + * Push a new error handler on top of the error handler options stack. With this + * you can easily override the actual error handler for some code and restore + * it later with popErrorHandling. + * + * @param mixed $mode (same as setErrorHandling) + * @param mixed $options (same as setErrorHandling) + * + * @return bool Always true + * + * @see PEAR::setErrorHandling + */ + function pushErrorHandling($mode, $options = null) + { + $stack = &$GLOBALS['_PEAR_error_handler_stack']; + if (isset($this) && is_a($this, 'PEAR')) { + $def_mode = &$this->_default_error_mode; + $def_options = &$this->_default_error_options; + } else { + $def_mode = &$GLOBALS['_PEAR_default_error_mode']; + $def_options = &$GLOBALS['_PEAR_default_error_options']; + } + $stack[] = array($def_mode, $def_options); + + if (isset($this) && is_a($this, 'PEAR')) { + $this->setErrorHandling($mode, $options); + } else { + PEAR::setErrorHandling($mode, $options); + } + $stack[] = array($mode, $options); + return true; + } + + // }}} + // {{{ popErrorHandling() + + /** + * Pop the last error handler used + * + * @return bool Always true + * + * @see PEAR::pushErrorHandling + */ + function popErrorHandling() + { + $stack = &$GLOBALS['_PEAR_error_handler_stack']; + array_pop($stack); + list($mode, $options) = $stack[sizeof($stack) - 1]; + array_pop($stack); + if (isset($this) && is_a($this, 'PEAR')) { + $this->setErrorHandling($mode, $options); + } else { + PEAR::setErrorHandling($mode, $options); + } + return true; + } + + // }}} + // {{{ loadExtension() + + /** + * OS independant PHP extension load. Remember to take care + * on the correct extension name for case sensitive OSes. + * + * @param string $ext The extension name + * @return bool Success or not on the dl() call + */ + function loadExtension($ext) + { + if (!extension_loaded($ext)) { + // if either returns true dl() will produce a FATAL error, stop that + if ((ini_get('enable_dl') != 1) || (ini_get('safe_mode') == 1)) { + return false; + } + if (OS_WINDOWS) { + $suffix = '.dll'; + } elseif (PHP_OS == 'HP-UX') { + $suffix = '.sl'; + } elseif (PHP_OS == 'AIX') { + $suffix = '.a'; + } elseif (PHP_OS == 'OSX') { + $suffix = '.bundle'; + } else { + $suffix = '.so'; + } + return @dl('php_'.$ext.$suffix) || @dl($ext.$suffix); + } + return true; + } + + // }}} +} + +// {{{ _PEAR_call_destructors() + +function _PEAR_call_destructors() +{ + global $_PEAR_destructor_object_list; + if (is_array($_PEAR_destructor_object_list) && + sizeof($_PEAR_destructor_object_list)) + { + reset($_PEAR_destructor_object_list); + if (@PEAR::getStaticProperty('PEAR', 'destructlifo')) { + $_PEAR_destructor_object_list = array_reverse($_PEAR_destructor_object_list); + } + while (list($k, $objref) = each($_PEAR_destructor_object_list)) { + $classname = get_class($objref); + while ($classname) { + $destructor = "_$classname"; + if (method_exists($objref, $destructor)) { + $objref->$destructor(); + break; + } else { + $classname = get_parent_class($classname); + } + } + } + // Empty the object list to ensure that destructors are + // not called more than once. + $_PEAR_destructor_object_list = array(); + } + + // Now call the shutdown functions + if (is_array($GLOBALS['_PEAR_shutdown_funcs']) AND !empty($GLOBALS['_PEAR_shutdown_funcs'])) { + foreach ($GLOBALS['_PEAR_shutdown_funcs'] as $value) { + call_user_func_array($value[0], $value[1]); + } + } +} + +// }}} +/** + * Standard PEAR error class for PHP 4 + * + * This class is supserseded by {@link PEAR_Exception} in PHP 5 + * + * @category pear + * @package PEAR + * @author Stig Bakken + * @author Tomas V.V. Cox + * @author Gregory Beaver + * @copyright 1997-2006 The PHP Group + * @license http://www.php.net/license/3_0.txt PHP License 3.0 + * @version Release: 1.4.6 + * @link http://pear.php.net/manual/en/core.pear.pear-error.php + * @see PEAR::raiseError(), PEAR::throwError() + * @since Class available since PHP 4.0.2 + */ +class PEAR_Error +{ + // {{{ properties + + var $error_message_prefix = ''; + var $mode = PEAR_ERROR_RETURN; + var $level = E_USER_NOTICE; + var $code = -1; + var $message = ''; + var $userinfo = ''; + var $backtrace = null; + + // }}} + // {{{ constructor + + /** + * PEAR_Error constructor + * + * @param string $message message + * + * @param int $code (optional) error code + * + * @param int $mode (optional) error mode, one of: PEAR_ERROR_RETURN, + * PEAR_ERROR_PRINT, PEAR_ERROR_DIE, PEAR_ERROR_TRIGGER, + * PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION + * + * @param mixed $options (optional) error level, _OR_ in the case of + * PEAR_ERROR_CALLBACK, the callback function or object/method + * tuple. + * + * @param string $userinfo (optional) additional user/debug info + * + * @access public + * + */ + function PEAR_Error($message = 'unknown error', $code = null, + $mode = null, $options = null, $userinfo = null) + { + if ($mode === null) { + $mode = PEAR_ERROR_RETURN; + } + $this->message = $message; + $this->code = $code; + $this->mode = $mode; + $this->userinfo = $userinfo; + if (function_exists("debug_backtrace")) { + if (@!PEAR::getStaticProperty('PEAR_Error', 'skiptrace')) { + $this->backtrace = debug_backtrace(); + } + } + if ($mode & PEAR_ERROR_CALLBACK) { + $this->level = E_USER_NOTICE; + $this->callback = $options; + } else { + if ($options === null) { + $options = E_USER_NOTICE; + } + $this->level = $options; + $this->callback = null; + } + if ($this->mode & PEAR_ERROR_PRINT) { + if (is_null($options) || is_int($options)) { + $format = "%s"; + } else { + $format = $options; + } + printf($format, $this->getMessage()); + } + if ($this->mode & PEAR_ERROR_TRIGGER) { + trigger_error($this->getMessage(), $this->level); + } + if ($this->mode & PEAR_ERROR_DIE) { + $msg = $this->getMessage(); + if (is_null($options) || is_int($options)) { + $format = "%s"; + if (substr($msg, -1) != "\n") { + $msg .= "\n"; + } + } else { + $format = $options; + } + die(sprintf($format, $msg)); + } + if ($this->mode & PEAR_ERROR_CALLBACK) { + if (is_callable($this->callback)) { + call_user_func($this->callback, $this); + } + } + if ($this->mode & PEAR_ERROR_EXCEPTION) { + trigger_error("PEAR_ERROR_EXCEPTION is obsolete, use class PEAR_Exception for exceptions", E_USER_WARNING); + eval('$e = new Exception($this->message, $this->code);throw($e);'); + } + } + + // }}} + // {{{ getMode() + + /** + * Get the error mode from an error object. + * + * @return int error mode + * @access public + */ + function getMode() { + return $this->mode; + } + + // }}} + // {{{ getCallback() + + /** + * Get the callback function/method from an error object. + * + * @return mixed callback function or object/method array + * @access public + */ + function getCallback() { + return $this->callback; + } + + // }}} + // {{{ getMessage() + + + /** + * Get the error message from an error object. + * + * @return string full error message + * @access public + */ + function getMessage() + { + return ($this->error_message_prefix . $this->message); + } + + + // }}} + // {{{ getCode() + + /** + * Get error code from an error object + * + * @return int error code + * @access public + */ + function getCode() + { + return $this->code; + } + + // }}} + // {{{ getType() + + /** + * Get the name of this error/exception. + * + * @return string error/exception name (type) + * @access public + */ + function getType() + { + return get_class($this); + } + + // }}} + // {{{ getUserInfo() + + /** + * Get additional user-supplied information. + * + * @return string user-supplied information + * @access public + */ + function getUserInfo() + { + return $this->userinfo; + } + + // }}} + // {{{ getDebugInfo() + + /** + * Get additional debug information supplied by the application. + * + * @return string debug information + * @access public + */ + function getDebugInfo() + { + return $this->getUserInfo(); + } + + // }}} + // {{{ getBacktrace() + + /** + * Get the call backtrace from where the error was generated. + * Supported with PHP 4.3.0 or newer. + * + * @param int $frame (optional) what frame to fetch + * @return array Backtrace, or NULL if not available. + * @access public + */ + function getBacktrace($frame = null) + { + if (defined('PEAR_IGNORE_BACKTRACE')) { + return null; + } + if ($frame === null) { + return $this->backtrace; + } + return $this->backtrace[$frame]; + } + + // }}} + // {{{ addUserInfo() + + function addUserInfo($info) + { + if (empty($this->userinfo)) { + $this->userinfo = $info; + } else { + $this->userinfo .= " ** $info"; + } + } + + // }}} + // {{{ toString() + + /** + * Make a string representation of this object. + * + * @return string a string with an object summary + * @access public + */ + function toString() { + $modes = array(); + $levels = array(E_USER_NOTICE => 'notice', + E_USER_WARNING => 'warning', + E_USER_ERROR => 'error'); + if ($this->mode & PEAR_ERROR_CALLBACK) { + if (is_array($this->callback)) { + $callback = (is_object($this->callback[0]) ? + strtolower(get_class($this->callback[0])) : + $this->callback[0]) . '::' . + $this->callback[1]; + } else { + $callback = $this->callback; + } + return sprintf('[%s: message="%s" code=%d mode=callback '. + 'callback=%s prefix="%s" info="%s"]', + strtolower(get_class($this)), $this->message, $this->code, + $callback, $this->error_message_prefix, + $this->userinfo); + } + if ($this->mode & PEAR_ERROR_PRINT) { + $modes[] = 'print'; + } + if ($this->mode & PEAR_ERROR_TRIGGER) { + $modes[] = 'trigger'; + } + if ($this->mode & PEAR_ERROR_DIE) { + $modes[] = 'die'; + } + if ($this->mode & PEAR_ERROR_RETURN) { + $modes[] = 'return'; + } + return sprintf('[%s: message="%s" code=%d mode=%s level=%s '. + 'prefix="%s" info="%s"]', + strtolower(get_class($this)), $this->message, $this->code, + implode("|", $modes), $levels[$this->level], + $this->error_message_prefix, + $this->userinfo); + } + + // }}} +} + +/* + * Local Variables: + * mode: php + * tab-width: 4 + * c-basic-offset: 4 + * End: + */ +?> diff --git a/include/Excel/PPS.php b/include/Excel/PPS.php new file mode 100644 index 000000000..38ddbf926 --- /dev/null +++ b/include/Excel/PPS.php @@ -0,0 +1,217 @@ + | +// | Based on OLE::Storage_Lite by Kawai, Takanori | +// +----------------------------------------------------------------------+ +// +// $Id: PPS.php,v 1.5 2003/12/14 18:12:28 xnoguer Exp $ + + + +/** +* Class for creating PPS's for OLE containers +* +* @author Xavier Noguer +* @category Structures +* @package OLE +*/ +class OLE_PPS extends PEAR +{ + /** + * The PPS index + * @var integer + */ + var $No; + + /** + * The PPS name (in Unicode) + * @var string + */ + var $Name; + + /** + * The PPS type. Dir, Root or File + * @var integer + */ + var $Type; + + /** + * The index of the previous PPS + * @var integer + */ + var $PrevPps; + + /** + * The index of the next PPS + * @var integer + */ + var $NextPps; + + /** + * The index of it's first child if this is a Dir or Root PPS + * @var integer + */ + var $DirPps; + + /** + * A timestamp + * @var integer + */ + var $Time1st; + + /** + * A timestamp + * @var integer + */ + var $Time2nd; + + /** + * Starting block (small or big) for this PPS's data inside the container + * @var integer + */ + var $_StartBlock; + + /** + * The size of the PPS's data (in bytes) + * @var integer + */ + var $Size; + + /** + * The PPS's data (only used if it's not using a temporary file) + * @var string + */ + var $_data; + + /** + * Array of child PPS's (only used by Root and Dir PPS's) + * @var array + */ + var $children = array(); + + /** + * The constructor + * + * @access public + * @param integer $No The PPS index + * @param string $name The PPS name (in Unicode) + * @param integer $type The PPS type. Dir, Root or File + * @param integer $prev The index of the previous PPS + * @param integer $next The index of the next PPS + * @param integer $dir The index of it's first child if this is a Dir or Root PPS + * @param integer $time_1st A timestamp + * @param integer $time_2nd A timestamp + * @param array $children Array containing children PPS for this PPS + */ + function OLE_PPS($No, $name, $type, $prev, $next, $dir, $time_1st, $time_2nd, $data, $children) + { + $this->No = $No; + $this->Name = $name; + $this->Type = $type; + $this->PrevPps = $prev; + $this->NextPps = $next; + $this->DirPps = $dir; + $this->Time1st = $time_1st; + $this->Time2nd = $time_2nd; + $this->_data = $data; + $this->children = $children; + if ($data != '') { + $this->Size = strlen($data); + } + else { + $this->Size = 0; + } + } + + /** + * Returns the amount of data saved for this PPS + * + * @access private + * @return integer The amount of data (in bytes) + */ + function _DataLen() + { + if (!isset($this->_data)) { + return 0; + } + if (isset($this->_PPS_FILE)) + { + fseek($this->_PPS_FILE, 0); + $stats = fstat($this->_PPS_FILE); + return $stats[7]; + } + else { + return strlen($this->_data); + } + } + + /** + * Returns a string with the PPS's WK (What is a WK?) + * + * @access private + * @return string The binary string + */ + function _getPpsWk() + { + $ret = $this->Name; + for ($i = 0; $i < (64 - strlen($this->Name)); $i++) { + $ret .= "\x00"; + } + $ret .= pack("v", strlen($this->Name) + 2) // 66 + . pack("c", $this->Type) // 67 + . pack("c", 0x00) //UK // 68 + . pack("V", $this->PrevPps) //Prev // 72 + . pack("V", $this->NextPps) //Next // 76 + . pack("V", $this->DirPps) //Dir // 80 + . "\x00\x09\x02\x00" // 84 + . "\x00\x00\x00\x00" // 88 + . "\xc0\x00\x00\x00" // 92 + . "\x00\x00\x00\x46" // 96 // Seems to be ok only for Root + . "\x00\x00\x00\x00" // 100 + . OLE::LocalDate2OLE($this->Time1st) // 108 + . OLE::LocalDate2OLE($this->Time2nd) // 116 + . pack("V", isset($this->_StartBlock)? + $this->_StartBlock:0) // 120 + . pack("V", $this->Size) // 124 + . pack("V", 0); // 128 + return $ret; + } + + /** + * Updates index and pointers to previous, next and children PPS's for this + * PPS. I don't think it'll work with Dir PPS's. + * + * @access private + * @param array &$pps_array Reference to the array of PPS's for the whole OLE + * container + * @return integer The index for this PPS + */ + function _savePpsSetPnt(&$pps_array) + { + $pps_array[count($pps_array)] = &$this; + $this->No = count($pps_array) - 1; + $this->PrevPps = 0xFFFFFFFF; + $this->NextPps = 0xFFFFFFFF; + if (count($this->children) > 0) { + $this->DirPps = $this->children[0]->_savePpsSetPnt($pps_array); + } + else { + $this->DirPps = 0xFFFFFFFF; + } + return $this->No; + } +} +?> diff --git a/include/Excel/Parser.php b/include/Excel/Parser.php new file mode 100644 index 000000000..eb300ce22 --- /dev/null +++ b/include/Excel/Parser.php @@ -0,0 +1,1688 @@ +" +*/ +define('SPREADSHEET_EXCEL_WRITER_GT', ">"); + +/** +* @const SPREADSHEET_EXCEL_WRITER_LT token identifier for character "<" +*/ +define('SPREADSHEET_EXCEL_WRITER_LT', "<"); + +/** +* @const SPREADSHEET_EXCEL_WRITER_LE token identifier for character "<=" +*/ +define('SPREADSHEET_EXCEL_WRITER_LE', "<="); + +/** +* @const SPREADSHEET_EXCEL_WRITER_GE token identifier for character ">=" +*/ +define('SPREADSHEET_EXCEL_WRITER_GE', ">="); + +/** +* @const SPREADSHEET_EXCEL_WRITER_EQ token identifier for character "=" +*/ +define('SPREADSHEET_EXCEL_WRITER_EQ', "="); + +/** +* @const SPREADSHEET_EXCEL_WRITER_NE token identifier for character "<>" +*/ +define('SPREADSHEET_EXCEL_WRITER_NE', "<>"); + + + +/** +* Class for parsing Excel formulas +* +* @author Xavier Noguer +* @category FileFormats +* @package Spreadsheet_Excel_Writer +*/ + +class Spreadsheet_Excel_Writer_Parser extends PEAR +{ + /** + * The index of the character we are currently looking at + * @var integer + */ + var $_current_char; + + /** + * The token we are working on. + * @var string + */ + var $_current_token; + + /** + * The formula to parse + * @var string + */ + var $_formula; + + /** + * The character ahead of the current char + * @var string + */ + var $_lookahead; + + /** + * The parse tree to be generated + * @var string + */ + var $_parse_tree; + + /** + * The byte order. 1 => big endian, 0 => little endian. + * @var integer + */ + var $_byte_order; + + /** + * Array of external sheets + * @var array + */ + var $_ext_sheets; + + /** + * Array of sheet references in the form of REF structures + * @var array + */ + var $_references; + + /** + * The BIFF version for the workbook + * @var integer + */ + var $_BIFF_version; + + /** + * The class constructor + * + * @param integer $byte_order The byte order (Little endian or Big endian) of the architecture + (optional). 1 => big endian, 0 (default) little endian. + */ + function Spreadsheet_Excel_Writer_Parser($byte_order, $biff_version) + { + $this->_current_char = 0; + $this->_BIFF_version = $biff_version; + $this->_current_token = ''; // The token we are working on. + $this->_formula = ''; // The formula to parse. + $this->_lookahead = ''; // The character ahead of the current char. + $this->_parse_tree = ''; // The parse tree to be generated. + $this->_initializeHashes(); // Initialize the hashes: ptg's and function's ptg's + $this->_byte_order = $byte_order; // Little Endian or Big Endian + $this->_ext_sheets = array(); + $this->_references = array(); + } + + /** + * Initialize the ptg and function hashes. + * + * @access private + */ + function _initializeHashes() + { + // The Excel ptg indices + $this->ptg = array( + 'ptgExp' => 0x01, + 'ptgTbl' => 0x02, + 'ptgAdd' => 0x03, + 'ptgSub' => 0x04, + 'ptgMul' => 0x05, + 'ptgDiv' => 0x06, + 'ptgPower' => 0x07, + 'ptgConcat' => 0x08, + 'ptgLT' => 0x09, + 'ptgLE' => 0x0A, + 'ptgEQ' => 0x0B, + 'ptgGE' => 0x0C, + 'ptgGT' => 0x0D, + 'ptgNE' => 0x0E, + 'ptgIsect' => 0x0F, + 'ptgUnion' => 0x10, + 'ptgRange' => 0x11, + 'ptgUplus' => 0x12, + 'ptgUminus' => 0x13, + 'ptgPercent' => 0x14, + 'ptgParen' => 0x15, + 'ptgMissArg' => 0x16, + 'ptgStr' => 0x17, + 'ptgAttr' => 0x19, + 'ptgSheet' => 0x1A, + 'ptgEndSheet' => 0x1B, + 'ptgErr' => 0x1C, + 'ptgBool' => 0x1D, + 'ptgInt' => 0x1E, + 'ptgNum' => 0x1F, + 'ptgArray' => 0x20, + 'ptgFunc' => 0x21, + 'ptgFuncVar' => 0x22, + 'ptgName' => 0x23, + 'ptgRef' => 0x24, + 'ptgArea' => 0x25, + 'ptgMemArea' => 0x26, + 'ptgMemErr' => 0x27, + 'ptgMemNoMem' => 0x28, + 'ptgMemFunc' => 0x29, + 'ptgRefErr' => 0x2A, + 'ptgAreaErr' => 0x2B, + 'ptgRefN' => 0x2C, + 'ptgAreaN' => 0x2D, + 'ptgMemAreaN' => 0x2E, + 'ptgMemNoMemN' => 0x2F, + 'ptgNameX' => 0x39, + 'ptgRef3d' => 0x3A, + 'ptgArea3d' => 0x3B, + 'ptgRefErr3d' => 0x3C, + 'ptgAreaErr3d' => 0x3D, + 'ptgArrayV' => 0x40, + 'ptgFuncV' => 0x41, + 'ptgFuncVarV' => 0x42, + 'ptgNameV' => 0x43, + 'ptgRefV' => 0x44, + 'ptgAreaV' => 0x45, + 'ptgMemAreaV' => 0x46, + 'ptgMemErrV' => 0x47, + 'ptgMemNoMemV' => 0x48, + 'ptgMemFuncV' => 0x49, + 'ptgRefErrV' => 0x4A, + 'ptgAreaErrV' => 0x4B, + 'ptgRefNV' => 0x4C, + 'ptgAreaNV' => 0x4D, + 'ptgMemAreaNV' => 0x4E, + 'ptgMemNoMemN' => 0x4F, + 'ptgFuncCEV' => 0x58, + 'ptgNameXV' => 0x59, + 'ptgRef3dV' => 0x5A, + 'ptgArea3dV' => 0x5B, + 'ptgRefErr3dV' => 0x5C, + 'ptgAreaErr3d' => 0x5D, + 'ptgArrayA' => 0x60, + 'ptgFuncA' => 0x61, + 'ptgFuncVarA' => 0x62, + 'ptgNameA' => 0x63, + 'ptgRefA' => 0x64, + 'ptgAreaA' => 0x65, + 'ptgMemAreaA' => 0x66, + 'ptgMemErrA' => 0x67, + 'ptgMemNoMemA' => 0x68, + 'ptgMemFuncA' => 0x69, + 'ptgRefErrA' => 0x6A, + 'ptgAreaErrA' => 0x6B, + 'ptgRefNA' => 0x6C, + 'ptgAreaNA' => 0x6D, + 'ptgMemAreaNA' => 0x6E, + 'ptgMemNoMemN' => 0x6F, + 'ptgFuncCEA' => 0x78, + 'ptgNameXA' => 0x79, + 'ptgRef3dA' => 0x7A, + 'ptgArea3dA' => 0x7B, + 'ptgRefErr3dA' => 0x7C, + 'ptgAreaErr3d' => 0x7D + ); + + // Thanks to Michael Meeks and Gnumeric for the initial arg values. + // + // The following hash was generated by "function_locale.pl" in the distro. + // Refer to function_locale.pl for non-English function names. + // + // The array elements are as follow: + // ptg: The Excel function ptg code. + // args: The number of arguments that the function takes: + // >=0 is a fixed number of arguments. + // -1 is a variable number of arguments. + // class: The reference, value or array class of the function args. + // vol: The function is volatile. + // + $this->_functions = array( + // function ptg args class vol + 'COUNT' => array( 0, -1, 0, 0 ), + 'IF' => array( 1, -1, 1, 0 ), + 'ISNA' => array( 2, 1, 1, 0 ), + 'ISERROR' => array( 3, 1, 1, 0 ), + 'SUM' => array( 4, -1, 0, 0 ), + 'AVERAGE' => array( 5, -1, 0, 0 ), + 'MIN' => array( 6, -1, 0, 0 ), + 'MAX' => array( 7, -1, 0, 0 ), + 'ROW' => array( 8, -1, 0, 0 ), + 'COLUMN' => array( 9, -1, 0, 0 ), + 'NA' => array( 10, 0, 0, 0 ), + 'NPV' => array( 11, -1, 1, 0 ), + 'STDEV' => array( 12, -1, 0, 0 ), + 'DOLLAR' => array( 13, -1, 1, 0 ), + 'FIXED' => array( 14, -1, 1, 0 ), + 'SIN' => array( 15, 1, 1, 0 ), + 'COS' => array( 16, 1, 1, 0 ), + 'TAN' => array( 17, 1, 1, 0 ), + 'ATAN' => array( 18, 1, 1, 0 ), + 'PI' => array( 19, 0, 1, 0 ), + 'SQRT' => array( 20, 1, 1, 0 ), + 'EXP' => array( 21, 1, 1, 0 ), + 'LN' => array( 22, 1, 1, 0 ), + 'LOG10' => array( 23, 1, 1, 0 ), + 'ABS' => array( 24, 1, 1, 0 ), + 'INT' => array( 25, 1, 1, 0 ), + 'SIGN' => array( 26, 1, 1, 0 ), + 'ROUND' => array( 27, 2, 1, 0 ), + 'LOOKUP' => array( 28, -1, 0, 0 ), + 'INDEX' => array( 29, -1, 0, 1 ), + 'REPT' => array( 30, 2, 1, 0 ), + 'MID' => array( 31, 3, 1, 0 ), + 'LEN' => array( 32, 1, 1, 0 ), + 'VALUE' => array( 33, 1, 1, 0 ), + 'TRUE' => array( 34, 0, 1, 0 ), + 'FALSE' => array( 35, 0, 1, 0 ), + 'AND' => array( 36, -1, 0, 0 ), + 'OR' => array( 37, -1, 0, 0 ), + 'NOT' => array( 38, 1, 1, 0 ), + 'MOD' => array( 39, 2, 1, 0 ), + 'DCOUNT' => array( 40, 3, 0, 0 ), + 'DSUM' => array( 41, 3, 0, 0 ), + 'DAVERAGE' => array( 42, 3, 0, 0 ), + 'DMIN' => array( 43, 3, 0, 0 ), + 'DMAX' => array( 44, 3, 0, 0 ), + 'DSTDEV' => array( 45, 3, 0, 0 ), + 'VAR' => array( 46, -1, 0, 0 ), + 'DVAR' => array( 47, 3, 0, 0 ), + 'TEXT' => array( 48, 2, 1, 0 ), + 'LINEST' => array( 49, -1, 0, 0 ), + 'TREND' => array( 50, -1, 0, 0 ), + 'LOGEST' => array( 51, -1, 0, 0 ), + 'GROWTH' => array( 52, -1, 0, 0 ), + 'PV' => array( 56, -1, 1, 0 ), + 'FV' => array( 57, -1, 1, 0 ), + 'NPER' => array( 58, -1, 1, 0 ), + 'PMT' => array( 59, -1, 1, 0 ), + 'RATE' => array( 60, -1, 1, 0 ), + 'MIRR' => array( 61, 3, 0, 0 ), + 'IRR' => array( 62, -1, 0, 0 ), + 'RAND' => array( 63, 0, 1, 1 ), + 'MATCH' => array( 64, -1, 0, 0 ), + 'DATE' => array( 65, 3, 1, 0 ), + 'TIME' => array( 66, 3, 1, 0 ), + 'DAY' => array( 67, 1, 1, 0 ), + 'MONTH' => array( 68, 1, 1, 0 ), + 'YEAR' => array( 69, 1, 1, 0 ), + 'WEEKDAY' => array( 70, -1, 1, 0 ), + 'HOUR' => array( 71, 1, 1, 0 ), + 'MINUTE' => array( 72, 1, 1, 0 ), + 'SECOND' => array( 73, 1, 1, 0 ), + 'NOW' => array( 74, 0, 1, 1 ), + 'AREAS' => array( 75, 1, 0, 1 ), + 'ROWS' => array( 76, 1, 0, 1 ), + 'COLUMNS' => array( 77, 1, 0, 1 ), + 'OFFSET' => array( 78, -1, 0, 1 ), + 'SEARCH' => array( 82, -1, 1, 0 ), + 'TRANSPOSE' => array( 83, 1, 1, 0 ), + 'TYPE' => array( 86, 1, 1, 0 ), + 'ATAN2' => array( 97, 2, 1, 0 ), + 'ASIN' => array( 98, 1, 1, 0 ), + 'ACOS' => array( 99, 1, 1, 0 ), + 'CHOOSE' => array( 100, -1, 1, 0 ), + 'HLOOKUP' => array( 101, -1, 0, 0 ), + 'VLOOKUP' => array( 102, -1, 0, 0 ), + 'ISREF' => array( 105, 1, 0, 0 ), + 'LOG' => array( 109, -1, 1, 0 ), + 'CHAR' => array( 111, 1, 1, 0 ), + 'LOWER' => array( 112, 1, 1, 0 ), + 'UPPER' => array( 113, 1, 1, 0 ), + 'PROPER' => array( 114, 1, 1, 0 ), + 'LEFT' => array( 115, -1, 1, 0 ), + 'RIGHT' => array( 116, -1, 1, 0 ), + 'EXACT' => array( 117, 2, 1, 0 ), + 'TRIM' => array( 118, 1, 1, 0 ), + 'REPLACE' => array( 119, 4, 1, 0 ), + 'SUBSTITUTE' => array( 120, -1, 1, 0 ), + 'CODE' => array( 121, 1, 1, 0 ), + 'FIND' => array( 124, -1, 1, 0 ), + 'CELL' => array( 125, -1, 0, 1 ), + 'ISERR' => array( 126, 1, 1, 0 ), + 'ISTEXT' => array( 127, 1, 1, 0 ), + 'ISNUMBER' => array( 128, 1, 1, 0 ), + 'ISBLANK' => array( 129, 1, 1, 0 ), + 'T' => array( 130, 1, 0, 0 ), + 'N' => array( 131, 1, 0, 0 ), + 'DATEVALUE' => array( 140, 1, 1, 0 ), + 'TIMEVALUE' => array( 141, 1, 1, 0 ), + 'SLN' => array( 142, 3, 1, 0 ), + 'SYD' => array( 143, 4, 1, 0 ), + 'DDB' => array( 144, -1, 1, 0 ), + 'INDIRECT' => array( 148, -1, 1, 1 ), + 'CALL' => array( 150, -1, 1, 0 ), + 'CLEAN' => array( 162, 1, 1, 0 ), + 'MDETERM' => array( 163, 1, 2, 0 ), + 'MINVERSE' => array( 164, 1, 2, 0 ), + 'MMULT' => array( 165, 2, 2, 0 ), + 'IPMT' => array( 167, -1, 1, 0 ), + 'PPMT' => array( 168, -1, 1, 0 ), + 'COUNTA' => array( 169, -1, 0, 0 ), + 'PRODUCT' => array( 183, -1, 0, 0 ), + 'FACT' => array( 184, 1, 1, 0 ), + 'DPRODUCT' => array( 189, 3, 0, 0 ), + 'ISNONTEXT' => array( 190, 1, 1, 0 ), + 'STDEVP' => array( 193, -1, 0, 0 ), + 'VARP' => array( 194, -1, 0, 0 ), + 'DSTDEVP' => array( 195, 3, 0, 0 ), + 'DVARP' => array( 196, 3, 0, 0 ), + 'TRUNC' => array( 197, -1, 1, 0 ), + 'ISLOGICAL' => array( 198, 1, 1, 0 ), + 'DCOUNTA' => array( 199, 3, 0, 0 ), + 'ROUNDUP' => array( 212, 2, 1, 0 ), + 'ROUNDDOWN' => array( 213, 2, 1, 0 ), + 'RANK' => array( 216, -1, 0, 0 ), + 'ADDRESS' => array( 219, -1, 1, 0 ), + 'DAYS360' => array( 220, -1, 1, 0 ), + 'TODAY' => array( 221, 0, 1, 1 ), + 'VDB' => array( 222, -1, 1, 0 ), + 'MEDIAN' => array( 227, -1, 0, 0 ), + 'SUMPRODUCT' => array( 228, -1, 2, 0 ), + 'SINH' => array( 229, 1, 1, 0 ), + 'COSH' => array( 230, 1, 1, 0 ), + 'TANH' => array( 231, 1, 1, 0 ), + 'ASINH' => array( 232, 1, 1, 0 ), + 'ACOSH' => array( 233, 1, 1, 0 ), + 'ATANH' => array( 234, 1, 1, 0 ), + 'DGET' => array( 235, 3, 0, 0 ), + 'INFO' => array( 244, 1, 1, 1 ), + 'DB' => array( 247, -1, 1, 0 ), + 'FREQUENCY' => array( 252, 2, 0, 0 ), + 'ERROR.TYPE' => array( 261, 1, 1, 0 ), + 'REGISTER.ID' => array( 267, -1, 1, 0 ), + 'AVEDEV' => array( 269, -1, 0, 0 ), + 'BETADIST' => array( 270, -1, 1, 0 ), + 'GAMMALN' => array( 271, 1, 1, 0 ), + 'BETAINV' => array( 272, -1, 1, 0 ), + 'BINOMDIST' => array( 273, 4, 1, 0 ), + 'CHIDIST' => array( 274, 2, 1, 0 ), + 'CHIINV' => array( 275, 2, 1, 0 ), + 'COMBIN' => array( 276, 2, 1, 0 ), + 'CONFIDENCE' => array( 277, 3, 1, 0 ), + 'CRITBINOM' => array( 278, 3, 1, 0 ), + 'EVEN' => array( 279, 1, 1, 0 ), + 'EXPONDIST' => array( 280, 3, 1, 0 ), + 'FDIST' => array( 281, 3, 1, 0 ), + 'FINV' => array( 282, 3, 1, 0 ), + 'FISHER' => array( 283, 1, 1, 0 ), + 'FISHERINV' => array( 284, 1, 1, 0 ), + 'FLOOR' => array( 285, 2, 1, 0 ), + 'GAMMADIST' => array( 286, 4, 1, 0 ), + 'GAMMAINV' => array( 287, 3, 1, 0 ), + 'CEILING' => array( 288, 2, 1, 0 ), + 'HYPGEOMDIST' => array( 289, 4, 1, 0 ), + 'LOGNORMDIST' => array( 290, 3, 1, 0 ), + 'LOGINV' => array( 291, 3, 1, 0 ), + 'NEGBINOMDIST' => array( 292, 3, 1, 0 ), + 'NORMDIST' => array( 293, 4, 1, 0 ), + 'NORMSDIST' => array( 294, 1, 1, 0 ), + 'NORMINV' => array( 295, 3, 1, 0 ), + 'NORMSINV' => array( 296, 1, 1, 0 ), + 'STANDARDIZE' => array( 297, 3, 1, 0 ), + 'ODD' => array( 298, 1, 1, 0 ), + 'PERMUT' => array( 299, 2, 1, 0 ), + 'POISSON' => array( 300, 3, 1, 0 ), + 'TDIST' => array( 301, 3, 1, 0 ), + 'WEIBULL' => array( 302, 4, 1, 0 ), + 'SUMXMY2' => array( 303, 2, 2, 0 ), + 'SUMX2MY2' => array( 304, 2, 2, 0 ), + 'SUMX2PY2' => array( 305, 2, 2, 0 ), + 'CHITEST' => array( 306, 2, 2, 0 ), + 'CORREL' => array( 307, 2, 2, 0 ), + 'COVAR' => array( 308, 2, 2, 0 ), + 'FORECAST' => array( 309, 3, 2, 0 ), + 'FTEST' => array( 310, 2, 2, 0 ), + 'INTERCEPT' => array( 311, 2, 2, 0 ), + 'PEARSON' => array( 312, 2, 2, 0 ), + 'RSQ' => array( 313, 2, 2, 0 ), + 'STEYX' => array( 314, 2, 2, 0 ), + 'SLOPE' => array( 315, 2, 2, 0 ), + 'TTEST' => array( 316, 4, 2, 0 ), + 'PROB' => array( 317, -1, 2, 0 ), + 'DEVSQ' => array( 318, -1, 0, 0 ), + 'GEOMEAN' => array( 319, -1, 0, 0 ), + 'HARMEAN' => array( 320, -1, 0, 0 ), + 'SUMSQ' => array( 321, -1, 0, 0 ), + 'KURT' => array( 322, -1, 0, 0 ), + 'SKEW' => array( 323, -1, 0, 0 ), + 'ZTEST' => array( 324, -1, 0, 0 ), + 'LARGE' => array( 325, 2, 0, 0 ), + 'SMALL' => array( 326, 2, 0, 0 ), + 'QUARTILE' => array( 327, 2, 0, 0 ), + 'PERCENTILE' => array( 328, 2, 0, 0 ), + 'PERCENTRANK' => array( 329, -1, 0, 0 ), + 'MODE' => array( 330, -1, 2, 0 ), + 'TRIMMEAN' => array( 331, 2, 0, 0 ), + 'TINV' => array( 332, 2, 1, 0 ), + 'CONCATENATE' => array( 336, -1, 1, 0 ), + 'POWER' => array( 337, 2, 1, 0 ), + 'RADIANS' => array( 342, 1, 1, 0 ), + 'DEGREES' => array( 343, 1, 1, 0 ), + 'SUBTOTAL' => array( 344, -1, 0, 0 ), + 'SUMIF' => array( 345, -1, 0, 0 ), + 'COUNTIF' => array( 346, 2, 0, 0 ), + 'COUNTBLANK' => array( 347, 1, 0, 0 ), + 'ROMAN' => array( 354, -1, 1, 0 ) + ); + } + + /** + * Convert a token to the proper ptg value. + * + * @access private + * @param mixed $token The token to convert. + * @return mixed the converted token on success. PEAR_Error if the token + * is not recognized + */ + function _convert($token) + { + if (preg_match("/^\"[^\"]{0,255}\"$/", $token)) { + return $this->_convertString($token); + + } elseif (is_numeric($token)) { + return $this->_convertNumber($token); + + // match references like A1 or $A$1 + } elseif (preg_match('/^\$?([A-Ia-i]?[A-Za-z])\$?(\d+)$/',$token)) { + return $this->_convertRef2d($token); + + // match external references like Sheet1!A1 or Sheet1:Sheet2!A1 + } elseif (preg_match("/^\w+(\:\w+)?\![A-Ia-i]?[A-Za-z](\d+)$/u",$token)) { + return $this->_convertRef3d($token); + + // match external references like 'Sheet1'!A1 or 'Sheet1:Sheet2'!A1 + } elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\![A-Ia-i]?[A-Za-z](\d+)$/u",$token)) { + return $this->_convertRef3d($token); + + // match ranges like A1:B2 + } elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)\:(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)$/",$token)) { + return $this->_convertRange2d($token); + + // match ranges like A1..B2 + } elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)$/",$token)) { + return $this->_convertRange2d($token); + + // match external ranges like Sheet1!A1 or Sheet1:Sheet2!A1:B2 + } elseif (preg_match("/^\w+(\:\w+)?\!([A-Ia-i]?[A-Za-z])?(\d+)\:([A-Ia-i]?[A-Za-z])?(\d+)$/u",$token)) { + return $this->_convertRange3d($token); + + // match external ranges like 'Sheet1'!A1 or 'Sheet1:Sheet2'!A1:B2 + } elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\!([A-Ia-i]?[A-Za-z])?(\d+)\:([A-Ia-i]?[A-Za-z])?(\d+)$/u",$token)) { + return $this->_convertRange3d($token); + + // operators (including parentheses) + } elseif (isset($this->ptg[$token])) { + return pack("C", $this->ptg[$token]); + + // commented so argument number can be processed correctly. See toReversePolish(). + /*elseif (preg_match("/[A-Z0-9\xc0-\xdc\.]+/",$token)) + { + return($this->_convertFunction($token,$this->_func_args)); + }*/ + + // if it's an argument, ignore the token (the argument remains) + } elseif ($token == 'arg') { + return ''; + } + // TODO: use real error codes + return $this->raiseError("Unknown token $token"); + } + + /** + * Convert a number token to ptgInt or ptgNum + * + * @access private + * @param mixed $num an integer or double for conversion to its ptg value + */ + function _convertNumber($num) + { + // Integer in the range 0..2**16-1 + if ((preg_match("/^\d+$/", $num)) and ($num <= 65535)) { + return pack("Cv", $this->ptg['ptgInt'], $num); + } else { // A float + if ($this->_byte_order) { // if it's Big Endian + $num = strrev($num); + } + return pack("Cd", $this->ptg['ptgNum'], $num); + } + } + + /** + * Convert a string token to ptgStr + * + * @access private + * @param string $string A string for conversion to its ptg value. + * @return mixed the converted token on success. PEAR_Error if the string + * is longer than 255 characters. + */ + function _convertString($string) + { + // chop away beggining and ending quotes + $string = substr($string, 1, strlen($string) - 2); + if (strlen($string) > 255) { + return $this->raiseError("String is too long"); + } + + if ($this->_BIFF_version == 0x0500) { + return pack("CC", $this->ptg['ptgStr'], strlen($string)).$string; + } elseif ($this->_BIFF_version == 0x0600) { + $encoding = 0; // TODO: Unicode support + return pack("CCC", $this->ptg['ptgStr'], strlen($string), $encoding).$string; + } + } + + /** + * Convert a function to a ptgFunc or ptgFuncVarV depending on the number of + * args that it takes. + * + * @access private + * @param string $token The name of the function for convertion to ptg value. + * @param integer $num_args The number of arguments the function receives. + * @return string The packed ptg for the function + */ + function _convertFunction($token, $num_args) + { + $args = $this->_functions[$token][1]; + $volatile = $this->_functions[$token][3]; + + // Fixed number of args eg. TIME($i,$j,$k). + if ($args >= 0) { + return pack("Cv", $this->ptg['ptgFuncV'], $this->_functions[$token][0]); + } + // Variable number of args eg. SUM($i,$j,$k, ..). + if ($args == -1) { + return pack("CCv", $this->ptg['ptgFuncVarV'], $num_args, $this->_functions[$token][0]); + } + } + + /** + * Convert an Excel range such as A1:D4 to a ptgRefV. + * + * @access private + * @param string $range An Excel range in the A1:A2 or A1..A2 format. + */ + function _convertRange2d($range) + { + $class = 2; // as far as I know, this is magick. + + // Split the range into 2 cell refs + if (preg_match("/^([A-Ia-i]?[A-Za-z])(\d+)\:([A-Ia-i]?[A-Za-z])(\d+)$/", $range)) { + list($cell1, $cell2) = split(':', $range); + } elseif (preg_match("/^([A-Ia-i]?[A-Za-z])(\d+)\.\.([A-Ia-i]?[A-Za-z])(\d+)$/", $range)) { + list($cell1, $cell2) = split('\.\.', $range); + + } else { + // TODO: use real error codes + return $this->raiseError("Unknown range separator", 0, PEAR_ERROR_DIE); + } + + // Convert the cell references + $cell_array1 = $this->_cellToPackedRowcol($cell1); + if (PEAR::isError($cell_array1)) { + return $cell_array1; + } + list($row1, $col1) = $cell_array1; + $cell_array2 = $this->_cellToPackedRowcol($cell2); + if (PEAR::isError($cell_array2)) { + return $cell_array2; + } + list($row2, $col2) = $cell_array2; + + // The ptg value depends on the class of the ptg. + if ($class == 0) { + $ptgArea = pack("C", $this->ptg['ptgArea']); + } elseif ($class == 1) { + $ptgArea = pack("C", $this->ptg['ptgAreaV']); + } elseif ($class == 2) { + $ptgArea = pack("C", $this->ptg['ptgAreaA']); + } else { + // TODO: use real error codes + return $this->raiseError("Unknown class $class", 0, PEAR_ERROR_DIE); + } + return $ptgArea . $row1 . $row2 . $col1. $col2; + } + + /** + * Convert an Excel 3d range such as "Sheet1!A1:D4" or "Sheet1:Sheet2!A1:D4" to + * a ptgArea3d. + * + * @access private + * @param string $token An Excel range in the Sheet1!A1:A2 format. + * @return mixed The packed ptgArea3d token on success, PEAR_Error on failure. + */ + function _convertRange3d($token) + { + $class = 2; // as far as I know, this is magick. + + // Split the ref at the ! symbol + list($ext_ref, $range) = split('!', $token); + + // Convert the external reference part (different for BIFF8) + if ($this->_BIFF_version == 0x0500) { + $ext_ref = $this->_packExtRef($ext_ref); + if (PEAR::isError($ext_ref)) { + return $ext_ref; + } + } elseif ($this->_BIFF_version == 0x0600) { + $ext_ref = $this->_getRefIndex($ext_ref); + if (PEAR::isError($ext_ref)) { + return $ext_ref; + } + } + + // Split the range into 2 cell refs + list($cell1, $cell2) = split(':', $range); + + // Convert the cell references + if (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)$/", $cell1)) { + $cell_array1 = $this->_cellToPackedRowcol($cell1); + if (PEAR::isError($cell_array1)) { + return $cell_array1; + } + list($row1, $col1) = $cell_array1; + $cell_array2 = $this->_cellToPackedRowcol($cell2); + if (PEAR::isError($cell_array2)) { + return $cell_array2; + } + list($row2, $col2) = $cell_array2; + } else { // It's a rows range (like 26:27) + $cells_array = $this->_rangeToPackedRange($cell1.':'.$cell2); + if (PEAR::isError($cells_array)) { + return $cells_array; + } + list($row1, $col1, $row2, $col2) = $cells_array; + } + + // The ptg value depends on the class of the ptg. + if ($class == 0) { + $ptgArea = pack("C", $this->ptg['ptgArea3d']); + } elseif ($class == 1) { + $ptgArea = pack("C", $this->ptg['ptgArea3dV']); + } elseif ($class == 2) { + $ptgArea = pack("C", $this->ptg['ptgArea3dA']); + } else { + return $this->raiseError("Unknown class $class", 0, PEAR_ERROR_DIE); + } + + return $ptgArea . $ext_ref . $row1 . $row2 . $col1. $col2; + } + + /** + * Convert an Excel reference such as A1, $B2, C$3 or $D$4 to a ptgRefV. + * + * @access private + * @param string $cell An Excel cell reference + * @return string The cell in packed() format with the corresponding ptg + */ + function _convertRef2d($cell) + { + $class = 2; // as far as I know, this is magick. + + // Convert the cell reference + $cell_array = $this->_cellToPackedRowcol($cell); + if (PEAR::isError($cell_array)) { + return $cell_array; + } + list($row, $col) = $cell_array; + + // The ptg value depends on the class of the ptg. + if ($class == 0) { + $ptgRef = pack("C", $this->ptg['ptgRef']); + } elseif ($class == 1) { + $ptgRef = pack("C", $this->ptg['ptgRefV']); + } elseif ($class == 2) { + $ptgRef = pack("C", $this->ptg['ptgRefA']); + } else { + // TODO: use real error codes + return $this->raiseError("Unknown class $class"); + } + return $ptgRef.$row.$col; + } + + /** + * Convert an Excel 3d reference such as "Sheet1!A1" or "Sheet1:Sheet2!A1" to a + * ptgRef3d. + * + * @access private + * @param string $cell An Excel cell reference + * @return mixed The packed ptgRef3d token on success, PEAR_Error on failure. + */ + function _convertRef3d($cell) + { + $class = 2; // as far as I know, this is magick. + + // Split the ref at the ! symbol + list($ext_ref, $cell) = split('!', $cell); + + // Convert the external reference part (different for BIFF8) + if ($this->_BIFF_version == 0x0500) { + $ext_ref = $this->_packExtRef($ext_ref); + if (PEAR::isError($ext_ref)) { + return $ext_ref; + } + } elseif ($this->_BIFF_version == 0x0600) { + $ext_ref = $this->_getRefIndex($ext_ref); + if (PEAR::isError($ext_ref)) { + return $ext_ref; + } + } + + // Convert the cell reference part + list($row, $col) = $this->_cellToPackedRowcol($cell); + + // The ptg value depends on the class of the ptg. + if ($class == 0) { + $ptgRef = pack("C", $this->ptg['ptgRef3d']); + } elseif ($class == 1) { + $ptgRef = pack("C", $this->ptg['ptgRef3dV']); + } elseif ($class == 2) { + $ptgRef = pack("C", $this->ptg['ptgRef3dA']); + } else { + return $this->raiseError("Unknown class $class", 0, PEAR_ERROR_DIE); + } + + return $ptgRef . $ext_ref. $row . $col; + } + + /** + * Convert the sheet name part of an external reference, for example "Sheet1" or + * "Sheet1:Sheet2", to a packed structure. + * + * @access private + * @param string $ext_ref The name of the external reference + * @return string The reference index in packed() format + */ + function _packExtRef($ext_ref) + { + $ext_ref = preg_replace("/^'/", '', $ext_ref); // Remove leading ' if any. + $ext_ref = preg_replace("/'$/", '', $ext_ref); // Remove trailing ' if any. + + // Check if there is a sheet range eg., Sheet1:Sheet2. + if (preg_match("/:/", $ext_ref)) { + list($sheet_name1, $sheet_name2) = split(':', $ext_ref); + + $sheet1 = $this->_getSheetIndex($sheet_name1); + if ($sheet1 == -1) { + return $this->raiseError("Unknown sheet name $sheet_name1 in formula"); + } + $sheet2 = $this->_getSheetIndex($sheet_name2); + if ($sheet2 == -1) { + return $this->raiseError("Unknown sheet name $sheet_name2 in formula"); + } + + // Reverse max and min sheet numbers if necessary + if ($sheet1 > $sheet2) { + list($sheet1, $sheet2) = array($sheet2, $sheet1); + } + } else { // Single sheet name only. + $sheet1 = $this->_getSheetIndex($ext_ref); + if ($sheet1 == -1) { + return $this->raiseError("Unknown sheet name $ext_ref in formula"); + } + $sheet2 = $sheet1; + } + + // References are stored relative to 0xFFFF. + $offset = -1 - $sheet1; + + return pack('vdvv', $offset, 0x00, $sheet1, $sheet2); + } + + /** + * Look up the REF index that corresponds to an external sheet name + * (or range). If it doesn't exist yet add it to the workbook's references + * array. It assumes all sheet names given must exist. + * + * @access private + * @param string $ext_ref The name of the external reference + * @return mixed The reference index in packed() format on success, + * PEAR_Error on failure + */ + function _getRefIndex($ext_ref) + { + $ext_ref = preg_replace("/^'/", '', $ext_ref); // Remove leading ' if any. + $ext_ref = preg_replace("/'$/", '', $ext_ref); // Remove trailing ' if any. + + // Check if there is a sheet range eg., Sheet1:Sheet2. + if (preg_match("/:/", $ext_ref)) { + list($sheet_name1, $sheet_name2) = split(':', $ext_ref); + + $sheet1 = $this->_getSheetIndex($sheet_name1); + if ($sheet1 == -1) { + return $this->raiseError("Unknown sheet name $sheet_name1 in formula"); + } + $sheet2 = $this->_getSheetIndex($sheet_name2); + if ($sheet2 == -1) { + return $this->raiseError("Unknown sheet name $sheet_name2 in formula"); + } + + // Reverse max and min sheet numbers if necessary + if ($sheet1 > $sheet2) { + list($sheet1, $sheet2) = array($sheet2, $sheet1); + } + } else { // Single sheet name only. + $sheet1 = $this->_getSheetIndex($ext_ref); + if ($sheet1 == -1) { + return $this->raiseError("Unknown sheet name $ext_ref in formula"); + } + $sheet2 = $sheet1; + } + + // assume all references belong to this document + $supbook_index = 0x00; + $ref = pack('vvv', $supbook_index, $sheet1, $sheet2); + $total_references = count($this->_references); + $index = -1; + for ($i = 0; $i < $total_references; $i++) { + if ($ref == $this->_references[$i]) { + $index = $i; + break; + } + } + // if REF was not found add it to references array + if ($index == -1) { + $this->_references[$total_references] = $ref; + $index = $total_references; + } + + return pack('v', $index); + } + + /** + * Look up the index that corresponds to an external sheet name. The hash of + * sheet names is updated by the addworksheet() method of the + * Spreadsheet_Excel_Writer_Workbook class. + * + * @access private + * @return integer The sheet index, -1 if the sheet was not found + */ + function _getSheetIndex($sheet_name) + { + if (!isset($this->_ext_sheets[$sheet_name])) { + return -1; + } else { + return $this->_ext_sheets[$sheet_name]; + } + } + + /** + * This method is used to update the array of sheet names. It is + * called by the addWorksheet() method of the + * Spreadsheet_Excel_Writer_Workbook class. + * + * @access public + * @see Spreadsheet_Excel_Writer_Workbook::addWorksheet() + * @param string $name The name of the worksheet being added + * @param integer $index The index of the worksheet being added + */ + function setExtSheet($name, $index) + { + $this->_ext_sheets[$name] = $index; + } + + /** + * pack() row and column into the required 3 or 4 byte format. + * + * @access private + * @param string $cell The Excel cell reference to be packed + * @return array Array containing the row and column in packed() format + */ + function _cellToPackedRowcol($cell) + { + $cell = strtoupper($cell); + list($row, $col, $row_rel, $col_rel) = $this->_cellToRowcol($cell); + if ($col >= 256) { + return $this->raiseError("Column in: $cell greater than 255"); + } + // FIXME: change for BIFF8 + if ($row >= 16384) { + return $this->raiseError("Row in: $cell greater than 16384 "); + } + + // Set the high bits to indicate if row or col are relative. + if ($this->_BIFF_version == 0x0500) { + $row |= $col_rel << 14; + $row |= $row_rel << 15; + $col = pack('C', $col); + } elseif ($this->_BIFF_version == 0x0600) { + $col |= $col_rel << 14; + $col |= $row_rel << 15; + $col = pack('v', $col); + } + $row = pack('v', $row); + + return array($row, $col); + } + + /** + * pack() row range into the required 3 or 4 byte format. + * Just using maximum col/rows, which is probably not the correct solution + * + * @access private + * @param string $range The Excel range to be packed + * @return array Array containing (row1,col1,row2,col2) in packed() format + */ + function _rangeToPackedRange($range) + { + preg_match('/(\$)?(\d+)\:(\$)?(\d+)/', $range, $match); + // return absolute rows if there is a $ in the ref + $row1_rel = empty($match[1]) ? 1 : 0; + $row1 = $match[2]; + $row2_rel = empty($match[3]) ? 1 : 0; + $row2 = $match[4]; + // Convert 1-index to zero-index + $row1--; + $row2--; + // Trick poor inocent Excel + $col1 = 0; + $col2 = 16383; // FIXME: maximum possible value for Excel 5 (change this!!!) + + // FIXME: this changes for BIFF8 + if (($row1 >= 16384) or ($row2 >= 16384)) { + return $this->raiseError("Row in: $range greater than 16384 "); + } + + // Set the high bits to indicate if rows are relative. + if ($this->_BIFF_version == 0x0500) { + $row1 |= $row1_rel << 14; // FIXME: probably a bug + $row2 |= $row2_rel << 15; + $col1 = pack('C', $col1); + $col2 = pack('C', $col2); + } elseif ($this->_BIFF_version == 0x0600) { + $col1 |= $row1_rel << 15; + $col2 |= $row2_rel << 15; + $col1 = pack('v', $col1); + $col2 = pack('v', $col2); + } + $row1 = pack('v', $row1); + $row2 = pack('v', $row2); + + return array($row1, $col1, $row2, $col2); + } + + /** + * Convert an Excel cell reference such as A1 or $B2 or C$3 or $D$4 to a zero + * indexed row and column number. Also returns two (0,1) values to indicate + * whether the row or column are relative references. + * + * @access private + * @param string $cell The Excel cell reference in A1 format. + * @return array + */ + function _cellToRowcol($cell) + { + preg_match('/(\$)?([A-I]?[A-Z])(\$)?(\d+)/',$cell,$match); + // return absolute column if there is a $ in the ref + $col_rel = empty($match[1]) ? 1 : 0; + $col_ref = $match[2]; + $row_rel = empty($match[3]) ? 1 : 0; + $row = $match[4]; + + // Convert base26 column string to a number. + $expn = strlen($col_ref) - 1; + $col = 0; + $col_ref_length = strlen($col_ref); + for ($i = 0; $i < $col_ref_length; $i++) { + $col += (ord($col_ref{$i}) - ord('A') + 1) * pow(26, $expn); + $expn--; + } + + // Convert 1-index to zero-index + $row--; + $col--; + + return array($row, $col, $row_rel, $col_rel); + } + + /** + * Advance to the next valid token. + * + * @access private + */ + function _advance() + { + $i = $this->_current_char; + $formula_length = strlen($this->_formula); + // eat up white spaces + if ($i < $formula_length) { + while ($this->_formula{$i} == " ") { + $i++; + } + + if ($i < ($formula_length - 1)) { + $this->_lookahead = $this->_formula{$i+1}; + } + $token = ''; + } + + while ($i < $formula_length) { + $token .= $this->_formula{$i}; + if ($i < ($formula_length - 1)) { + $this->_lookahead = $this->_formula{$i+1}; + } else { + $this->_lookahead = ''; + } + + if ($this->_match($token) != '') { + //if ($i < strlen($this->_formula) - 1) { + // $this->_lookahead = $this->_formula{$i+1}; + //} + $this->_current_char = $i + 1; + $this->_current_token = $token; + return 1; + } + + if ($i < ($formula_length - 2)) { + $this->_lookahead = $this->_formula{$i+2}; + } else { // if we run out of characters _lookahead becomes empty + $this->_lookahead = ''; + } + $i++; + } + //die("Lexical error ".$this->_current_char); + } + + /** + * Checks if it's a valid token. + * + * @access private + * @param mixed $token The token to check. + * @return mixed The checked token or false on failure + */ + function _match($token) + { + switch($token) { + case SPREADSHEET_EXCEL_WRITER_ADD: + return $token; + break; + case SPREADSHEET_EXCEL_WRITER_SUB: + return $token; + break; + case SPREADSHEET_EXCEL_WRITER_MUL: + return $token; + break; + case SPREADSHEET_EXCEL_WRITER_DIV: + return $token; + break; + case SPREADSHEET_EXCEL_WRITER_OPEN: + return $token; + break; + case SPREADSHEET_EXCEL_WRITER_CLOSE: + return $token; + break; + case SPREADSHEET_EXCEL_WRITER_COMA: + return $token; + break; + case SPREADSHEET_EXCEL_WRITER_SEMICOLON: + return $token; + break; + case SPREADSHEET_EXCEL_WRITER_GT: + if ($this->_lookahead == '=') { // it's a GE token + break; + } + return $token; + break; + case SPREADSHEET_EXCEL_WRITER_LT: + // it's a LE or a NE token + if (($this->_lookahead == '=') or ($this->_lookahead == '>')) { + break; + } + return $token; + break; + case SPREADSHEET_EXCEL_WRITER_GE: + return $token; + break; + case SPREADSHEET_EXCEL_WRITER_LE: + return $token; + break; + case SPREADSHEET_EXCEL_WRITER_EQ: + return $token; + break; + case SPREADSHEET_EXCEL_WRITER_NE: + return $token; + break; + default: + // if it's a reference + if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/',$token) and + !ereg("[0-9]",$this->_lookahead) and + ($this->_lookahead != ':') and ($this->_lookahead != '.') and + ($this->_lookahead != '!')) + { + return $token; + } + // If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1) + elseif (preg_match("/^\w+(\:\w+)?\![A-Ia-i]?[A-Za-z][0-9]+$/u",$token) and + !ereg("[0-9]",$this->_lookahead) and + ($this->_lookahead != ':') and ($this->_lookahead != '.')) + { + return $token; + } + // If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1) + elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\![A-Ia-i]?[A-Za-z][0-9]+$/u",$token) and + !ereg("[0-9]",$this->_lookahead) and + ($this->_lookahead != ':') and ($this->_lookahead != '.')) + { + return $token; + } + // if it's a range (A1:A2) + elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$token) and + !ereg("[0-9]",$this->_lookahead)) + { + return $token; + } + // if it's a range (A1..A2) + elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$token) and + !ereg("[0-9]",$this->_lookahead)) + { + return $token; + } + // If it's an external range like Sheet1!A1 or Sheet1:Sheet2!A1:B2 + elseif (preg_match("/^\w+(\:\w+)?\!([A-Ia-i]?[A-Za-z])?[0-9]+:([A-Ia-i]?[A-Za-z])?[0-9]+$/u",$token) and + !ereg("[0-9]",$this->_lookahead)) + { + return $token; + } + // If it's an external range like 'Sheet1'!A1 or 'Sheet1:Sheet2'!A1:B2 + elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\!([A-Ia-i]?[A-Za-z])?[0-9]+:([A-Ia-i]?[A-Za-z])?[0-9]+$/u",$token) and + !ereg("[0-9]",$this->_lookahead)) + { + return $token; + } + // If it's a number (check that it's not a sheet name or range) + elseif (is_numeric($token) and + (!is_numeric($token.$this->_lookahead) or ($this->_lookahead == '')) and + ($this->_lookahead != '!') and ($this->_lookahead != ':')) + { + return $token; + } + // If it's a string (of maximum 255 characters) + elseif (ereg("^\"[^\"]{0,255}\"$",$token)) + { + return $token; + } + // if it's a function call + elseif (eregi("^[A-Z0-9\xc0-\xdc\.]+$",$token) and ($this->_lookahead == "(")) + { + return $token; + } + return ''; + } + } + + /** + * The parsing method. It parses a formula. + * + * @access public + * @param string $formula The formula to parse, without the initial equal + * sign (=). + * @return mixed true on success, PEAR_Error on failure + */ + function parse($formula) + { + $this->_current_char = 0; + $this->_formula = $formula; + $this->_lookahead = $formula{1}; + $this->_advance(); + $this->_parse_tree = $this->_condition(); + if (PEAR::isError($this->_parse_tree)) { + return $this->_parse_tree; + } + return true; + } + + /** + * It parses a condition. It assumes the following rule: + * Cond -> Expr [(">" | "<") Expr] + * + * @access private + * @return mixed The parsed ptg'd tree on success, PEAR_Error on failure + */ + function _condition() + { + $result = $this->_expression(); + if (PEAR::isError($result)) { + return $result; + } + if ($this->_current_token == SPREADSHEET_EXCEL_WRITER_LT) { + $this->_advance(); + $result2 = $this->_expression(); + if (PEAR::isError($result2)) { + return $result2; + } + $result = $this->_createTree('ptgLT', $result, $result2); + } elseif ($this->_current_token == SPREADSHEET_EXCEL_WRITER_GT) { + $this->_advance(); + $result2 = $this->_expression(); + if (PEAR::isError($result2)) { + return $result2; + } + $result = $this->_createTree('ptgGT', $result, $result2); + } elseif ($this->_current_token == SPREADSHEET_EXCEL_WRITER_LE) { + $this->_advance(); + $result2 = $this->_expression(); + if (PEAR::isError($result2)) { + return $result2; + } + $result = $this->_createTree('ptgLE', $result, $result2); + } elseif ($this->_current_token == SPREADSHEET_EXCEL_WRITER_GE) { + $this->_advance(); + $result2 = $this->_expression(); + if (PEAR::isError($result2)) { + return $result2; + } + $result = $this->_createTree('ptgGE', $result, $result2); + } elseif ($this->_current_token == SPREADSHEET_EXCEL_WRITER_EQ) { + $this->_advance(); + $result2 = $this->_expression(); + if (PEAR::isError($result2)) { + return $result2; + } + $result = $this->_createTree('ptgEQ', $result, $result2); + } elseif ($this->_current_token == SPREADSHEET_EXCEL_WRITER_NE) { + $this->_advance(); + $result2 = $this->_expression(); + if (PEAR::isError($result2)) { + return $result2; + } + $result = $this->_createTree('ptgNE', $result, $result2); + } + return $result; + } + + /** + * It parses a expression. It assumes the following rule: + * Expr -> Term [("+" | "-") Term] + * -> "string" + * -> "-" Term + * + * @access private + * @return mixed The parsed ptg'd tree on success, PEAR_Error on failure + */ + function _expression() + { + // If it's a string return a string node + if (ereg("^\"[^\"]{0,255}\"$", $this->_current_token)) { + $result = $this->_createTree($this->_current_token, '', ''); + $this->_advance(); + return $result; + } elseif ($this->_current_token == SPREADSHEET_EXCEL_WRITER_SUB) { + // catch "-" Term + $this->_advance(); + $result2 = $this->_expression(); + $result = $this->_createTree('ptgUminus', $result2, ''); + return $result; + } + $result = $this->_term(); + if (PEAR::isError($result)) { + return $result; + } + while (($this->_current_token == SPREADSHEET_EXCEL_WRITER_ADD) or + ($this->_current_token == SPREADSHEET_EXCEL_WRITER_SUB)) { + /**/ + if ($this->_current_token == SPREADSHEET_EXCEL_WRITER_ADD) { + $this->_advance(); + $result2 = $this->_term(); + if (PEAR::isError($result2)) { + return $result2; + } + $result = $this->_createTree('ptgAdd', $result, $result2); + } else { + $this->_advance(); + $result2 = $this->_term(); + if (PEAR::isError($result2)) { + return $result2; + } + $result = $this->_createTree('ptgSub', $result, $result2); + } + } + return $result; + } + + /** + * This function just introduces a ptgParen element in the tree, so that Excel + * doesn't get confused when working with a parenthesized formula afterwards. + * + * @access private + * @see _fact() + * @return array The parsed ptg'd tree + */ + function _parenthesizedExpression() + { + $result = $this->_createTree('ptgParen', $this->_expression(), ''); + return $result; + } + + /** + * It parses a term. It assumes the following rule: + * Term -> Fact [("*" | "/") Fact] + * + * @access private + * @return mixed The parsed ptg'd tree on success, PEAR_Error on failure + */ + function _term() + { + $result = $this->_fact(); + if (PEAR::isError($result)) { + return $result; + } + while (($this->_current_token == SPREADSHEET_EXCEL_WRITER_MUL) or + ($this->_current_token == SPREADSHEET_EXCEL_WRITER_DIV)) { + /**/ + if ($this->_current_token == SPREADSHEET_EXCEL_WRITER_MUL) { + $this->_advance(); + $result2 = $this->_fact(); + if (PEAR::isError($result2)) { + return $result2; + } + $result = $this->_createTree('ptgMul', $result, $result2); + } else { + $this->_advance(); + $result2 = $this->_fact(); + if (PEAR::isError($result2)) { + return $result2; + } + $result = $this->_createTree('ptgDiv', $result, $result2); + } + } + return $result; + } + + /** + * It parses a factor. It assumes the following rule: + * Fact -> ( Expr ) + * | CellRef + * | CellRange + * | Number + * | Function + * + * @access private + * @return mixed The parsed ptg'd tree on success, PEAR_Error on failure + */ + function _fact() + { + if ($this->_current_token == SPREADSHEET_EXCEL_WRITER_OPEN) { + $this->_advance(); // eat the "(" + $result = $this->_parenthesizedExpression(); + if ($this->_current_token != SPREADSHEET_EXCEL_WRITER_CLOSE) { + return $this->raiseError("')' token expected."); + } + $this->_advance(); // eat the ")" + return $result; + } + // if it's a reference + if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/',$this->_current_token)) + { + $result = $this->_createTree($this->_current_token, '', ''); + $this->_advance(); + return $result; + } + // If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1) + elseif (preg_match("/^\w+(\:\w+)?\![A-Ia-i]?[A-Za-z][0-9]+$/u",$this->_current_token)) + { + $result = $this->_createTree($this->_current_token, '', ''); + $this->_advance(); + return $result; + } + // If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1) + elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\![A-Ia-i]?[A-Za-z][0-9]+$/u",$this->_current_token)) + { + $result = $this->_createTree($this->_current_token, '', ''); + $this->_advance(); + return $result; + } + // if it's a range + elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$this->_current_token) or + preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$this->_current_token)) + { + $result = $this->_current_token; + $this->_advance(); + return $result; + } + // If it's an external range (Sheet1!A1 or Sheet1!A1:B2) + elseif (preg_match("/^\w+(\:\w+)?\!([A-Ia-i]?[A-Za-z])?[0-9]+:([A-Ia-i]?[A-Za-z])?[0-9]+$/u",$this->_current_token)) + { + $result = $this->_current_token; + $this->_advance(); + return $result; + } + // If it's an external range ('Sheet1'!A1 or 'Sheet1'!A1:B2) + elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\!([A-Ia-i]?[A-Za-z])?[0-9]+:([A-Ia-i]?[A-Za-z])?[0-9]+$/u",$this->_current_token)) + { + $result = $this->_current_token; + $this->_advance(); + return $result; + } + elseif (is_numeric($this->_current_token)) + { + $result = $this->_createTree($this->_current_token, '', ''); + $this->_advance(); + return $result; + } + // if it's a function call + elseif (eregi("^[A-Z0-9\xc0-\xdc\.]+$",$this->_current_token)) + { + $result = $this->_func(); + return $result; + } + return $this->raiseError("Syntax error: ".$this->_current_token. + ", lookahead: ".$this->_lookahead. + ", current char: ".$this->_current_char); + } + + /** + * It parses a function call. It assumes the following rule: + * Func -> ( Expr [,Expr]* ) + * + * @access private + * @return mixed The parsed ptg'd tree on success, PEAR_Error on failure + */ + function _func() + { + $num_args = 0; // number of arguments received + $function = strtoupper($this->_current_token); + $result = ''; // initialize result + $this->_advance(); + $this->_advance(); // eat the "(" + while ($this->_current_token != ')') { + /**/ + if ($num_args > 0) { + if ($this->_current_token == SPREADSHEET_EXCEL_WRITER_COMA or + $this->_current_token == SPREADSHEET_EXCEL_WRITER_SEMICOLON) + { + $this->_advance(); // eat the "," or ";" + } else { + return $this->raiseError("Syntax error: comma expected in ". + "function $function, arg #{$num_args}"); + } + $result2 = $this->_condition(); + if (PEAR::isError($result2)) { + return $result2; + } + $result = $this->_createTree('arg', $result, $result2); + } else { // first argument + $result2 = $this->_condition(); + if (PEAR::isError($result2)) { + return $result2; + } + $result = $this->_createTree('arg', '', $result2); + } + $num_args++; + } + if (!isset($this->_functions[$function])) { + return $this->raiseError("Function $function() doesn't exist"); + } + $args = $this->_functions[$function][1]; + // If fixed number of args eg. TIME($i,$j,$k). Check that the number of args is valid. + if (($args >= 0) and ($args != $num_args)) { + return $this->raiseError("Incorrect number of arguments in function $function() "); + } + + $result = $this->_createTree($function, $result, $num_args); + $this->_advance(); // eat the ")" + return $result; + } + + /** + * Creates a tree. In fact an array which may have one or two arrays (sub-trees) + * as elements. + * + * @access private + * @param mixed $value The value of this node. + * @param mixed $left The left array (sub-tree) or a final node. + * @param mixed $right The right array (sub-tree) or a final node. + * @return array A tree + */ + function _createTree($value, $left, $right) + { + return array('value' => $value, 'left' => $left, 'right' => $right); + } + + /** + * Builds a string containing the tree in reverse polish notation (What you + * would use in a HP calculator stack). + * The following tree: + * + * + + * / \ + * 2 3 + * + * produces: "23+" + * + * The following tree: + * + * + + * / \ + * 3 * + * / \ + * 6 A1 + * + * produces: "36A1*+" + * + * In fact all operands, functions, references, etc... are written as ptg's + * + * @access public + * @param array $tree The optional tree to convert. + * @return string The tree in reverse polish notation + */ + function toReversePolish($tree = array()) + { + $polish = ""; // the string we are going to return + if (empty($tree)) { // If it's the first call use _parse_tree + $tree = $this->_parse_tree; + } + if (is_array($tree['left'])) { + $converted_tree = $this->toReversePolish($tree['left']); + if (PEAR::isError($converted_tree)) { + return $converted_tree; + } + $polish .= $converted_tree; + } elseif ($tree['left'] != '') { // It's a final node + $converted_tree = $this->_convert($tree['left']); + if (PEAR::isError($converted_tree)) { + return $converted_tree; + } + $polish .= $converted_tree; + } + if (is_array($tree['right'])) { + $converted_tree = $this->toReversePolish($tree['right']); + if (PEAR::isError($converted_tree)) { + return $converted_tree; + } + $polish .= $converted_tree; + } elseif ($tree['right'] != '') { // It's a final node + $converted_tree = $this->_convert($tree['right']); + if (PEAR::isError($converted_tree)) { + return $converted_tree; + } + $polish .= $converted_tree; + } + // if it's a function convert it here (so we can set it's arguments) + if (preg_match("/^[A-Z0-9\xc0-\xdc\.]+$/",$tree['value']) and + !preg_match('/^([A-Ia-i]?[A-Za-z])(\d+)$/',$tree['value']) and + !preg_match("/^[A-Ia-i]?[A-Za-z](\d+)\.\.[A-Ia-i]?[A-Za-z](\d+)$/",$tree['value']) and + !is_numeric($tree['value']) and + !isset($this->ptg[$tree['value']])) + { + // left subtree for a function is always an array. + if ($tree['left'] != '') { + $left_tree = $this->toReversePolish($tree['left']); + } else { + $left_tree = ''; + } + if (PEAR::isError($left_tree)) { + return $left_tree; + } + // add it's left subtree and return. + return $left_tree.$this->_convertFunction($tree['value'], $tree['right']); + } else { + $converted_tree = $this->_convert($tree['value']); + if (PEAR::isError($converted_tree)) { + return $converted_tree; + } + } + $polish .= $converted_tree; + return $polish; + } +} +?> diff --git a/include/Excel/Root.php b/include/Excel/Root.php new file mode 100644 index 000000000..78936604d --- /dev/null +++ b/include/Excel/Root.php @@ -0,0 +1,518 @@ + | +// | Based on OLE::Storage_Lite by Kawai, Takanori | +// +----------------------------------------------------------------------+ +// +// $Id: Root.php,v 1.7 2003/12/12 21:10:10 xnoguer Exp $ + + + +/** +* Class for creating Root PPS's for OLE containers +* +* @author Xavier Noguer +* @category Structures +* @package OLE +*/ +class OLE_PPS_Root extends OLE_PPS +{ + /** + * The temporary dir for storing the OLE file + * @var string + */ + var $_tmp_dir; + + /** + * Constructor + * + * @access public + * @param integer $time_1st A timestamp + * @param integer $time_2nd A timestamp + */ + function OLE_PPS_Root($time_1st, $time_2nd, $raChild) + { + $this->_tmp_dir = ''; + $this->OLE_PPS( + null, + OLE::Asc2Ucs('Root Entry'), + OLE_PPS_TYPE_ROOT, + null, + null, + null, + $time_1st, + $time_2nd, + null, + $raChild); + } + + /** + * Sets the temp dir used for storing the OLE file + * + * @access public + * @param string $dir The dir to be used as temp dir + * @return true if given dir is valid, false otherwise + */ + function setTempDir($dir) + { + if (is_dir($dir)) { + $this->_tmp_dir = $dir; + return true; + } + return false; + } + + /** + * Method for saving the whole OLE container (including files). + * In fact, if called with an empty argument (or '-'), it saves to a + * temporary file and then outputs it's contents to stdout. + * + * @param string $filename The name of the file where to save the OLE container + * @access public + * @return mixed true on success, PEAR_Error on failure + */ + function save($filename) + { + // Initial Setting for saving + $this->_BIG_BLOCK_SIZE = pow(2, + ((isset($this->_BIG_BLOCK_SIZE))? $this->_adjust2($this->_BIG_BLOCK_SIZE) : 9)); + $this->_SMALL_BLOCK_SIZE= pow(2, + ((isset($this->_SMALL_BLOCK_SIZE))? $this->_adjust2($this->_SMALL_BLOCK_SIZE): 6)); + + // Open temp file if we are sending output to stdout + if (($filename == '-') or ($filename == '')) + { + $this->_tmp_filename = tempnam($this->_tmp_dir, "OLE_PPS_Root"); + $this->_FILEH_ = @fopen($this->_tmp_filename,"w+b"); + if ($this->_FILEH_ == false) { + return $this->raiseError("Can't create temporary file."); + } + } + else + { + $this->_FILEH_ = @fopen($filename, "wb"); + if ($this->_FILEH_ == false) { + return $this->raiseError("Can't open $filename. It may be in use or protected."); + } + } + // Make an array of PPS's (for Save) + $aList = array(); + $this->_savePpsSetPnt($aList); + // calculate values for header + list($iSBDcnt, $iBBcnt, $iPPScnt) = $this->_calcSize($aList); //, $rhInfo); + // Save Header + $this->_saveHeader($iSBDcnt, $iBBcnt, $iPPScnt); + + // Make Small Data string (write SBD) + $this->_data = $this->_makeSmallData($aList); + + // Write BB + $this->_saveBigData($iSBDcnt, $aList); + // Write PPS + $this->_savePps($aList); + // Write Big Block Depot and BDList and Adding Header informations + $this->_saveBbd($iSBDcnt, $iBBcnt, $iPPScnt); + // Close File, send it to stdout if necessary + if(($filename == '-') or ($filename == '')) + { + fseek($this->_FILEH_, 0); + fpassthru($this->_FILEH_); + @fclose($this->_FILEH_); + // Delete the temporary file. + @unlink($this->_tmp_filename); + } + else { + @fclose($this->_FILEH_); + } + return true; + } + + /** + * Calculate some numbers + * + * @access private + * @param array $raList Reference to an array of PPS's + * @return array The array of numbers + */ + function _calcSize(&$raList) + { + // Calculate Basic Setting + list($iSBDcnt, $iBBcnt, $iPPScnt) = array(0,0,0); + $iSmallLen = 0; + $iSBcnt = 0; + for ($i = 0; $i < count($raList); $i++) { + if($raList[$i]->Type == OLE_PPS_TYPE_FILE) { + $raList[$i]->Size = $raList[$i]->_DataLen(); + if($raList[$i]->Size < OLE_DATA_SIZE_SMALL) { + $iSBcnt += floor($raList[$i]->Size / $this->_SMALL_BLOCK_SIZE) + + (($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE)? 1: 0); + } + else { + $iBBcnt += (floor($raList[$i]->Size / $this->_BIG_BLOCK_SIZE) + + (($raList[$i]->Size % $this->_BIG_BLOCK_SIZE)? 1: 0)); + } + } + } + $iSmallLen = $iSBcnt * $this->_SMALL_BLOCK_SIZE; + $iSlCnt = floor($this->_BIG_BLOCK_SIZE / OLE_LONG_INT_SIZE); + $iSBDcnt = floor($iSBcnt / $iSlCnt) + (($iSBcnt % $iSlCnt)? 1:0); + $iBBcnt += (floor($iSmallLen / $this->_BIG_BLOCK_SIZE) + + (( $iSmallLen % $this->_BIG_BLOCK_SIZE)? 1: 0)); + $iCnt = count($raList); + $iBdCnt = $this->_BIG_BLOCK_SIZE / OLE_PPS_SIZE; + $iPPScnt = (floor($iCnt/$iBdCnt) + (($iCnt % $iBdCnt)? 1: 0)); + + return array($iSBDcnt, $iBBcnt, $iPPScnt); + } + + /** + * Helper function for caculating a magic value for block sizes + * + * @access private + * @param integer $i2 The argument + * @see save() + * @return integer + */ + function _adjust2($i2) + { + $iWk = log($i2)/log(2); + return ($iWk > floor($iWk))? floor($iWk)+1:$iWk; + } + + /** + * Save OLE header + * + * @access private + * @param integer $iSBDcnt + * @param integer $iBBcnt + * @param integer $iPPScnt + */ + function _saveHeader($iSBDcnt, $iBBcnt, $iPPScnt) + { + $FILE = $this->_FILEH_; + + // Calculate Basic Setting + $iBlCnt = $this->_BIG_BLOCK_SIZE / OLE_LONG_INT_SIZE; + $i1stBdL = ($this->_BIG_BLOCK_SIZE - 0x4C) / OLE_LONG_INT_SIZE; + + $iBdExL = 0; + $iAll = $iBBcnt + $iPPScnt + $iSBDcnt; + $iAllW = $iAll; + $iBdCntW = floor($iAllW / $iBlCnt) + (($iAllW % $iBlCnt)? 1: 0); + $iBdCnt = floor(($iAll + $iBdCntW) / $iBlCnt) + ((($iAllW+$iBdCntW) % $iBlCnt)? 1: 0); + + // Calculate BD count + if ($iBdCnt >$i1stBdL) + { + while (1) + { + $iBdExL++; + $iAllW++; + $iBdCntW = floor($iAllW / $iBlCnt) + (($iAllW % $iBlCnt)? 1: 0); + $iBdCnt = floor(($iAllW + $iBdCntW) / $iBlCnt) + ((($iAllW+$iBdCntW) % $iBlCnt)? 1: 0); + if ($iBdCnt <= ($iBdExL*$iBlCnt+ $i1stBdL)) { + break; + } + } + } + + // Save Header + fwrite($FILE, + "\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1" + . "\x00\x00\x00\x00" + . "\x00\x00\x00\x00" + . "\x00\x00\x00\x00" + . "\x00\x00\x00\x00" + . pack("v", 0x3b) + . pack("v", 0x03) + . pack("v", -2) + . pack("v", 9) + . pack("v", 6) + . pack("v", 0) + . "\x00\x00\x00\x00" + . "\x00\x00\x00\x00" + . pack("V", $iBdCnt) + . pack("V", $iBBcnt+$iSBDcnt) //ROOT START + . pack("V", 0) + . pack("V", 0x1000) + . pack("V", 0) //Small Block Depot + . pack("V", 1) + ); + // Extra BDList Start, Count + if ($iBdCnt < $i1stBdL) + { + fwrite($FILE, + pack("V", -2). // Extra BDList Start + pack("V", 0) // Extra BDList Count + ); + } + else + { + fwrite($FILE, pack("V", $iAll+$iBdCnt) . pack("V", $iBdExL)); + } + + // BDList + for ($i=0; $i<$i1stBdL and $i < $iBdCnt; $i++) { + fwrite($FILE, pack("V", $iAll+$i)); + } + if ($i < $i1stBdL) + { + for ($j = 0; $j < ($i1stBdL-$i); $j++) { + fwrite($FILE, (pack("V", -1))); + } + } + } + + /** + * Saving big data (PPS's with data bigger than OLE_DATA_SIZE_SMALL) + * + * @access private + * @param integer $iStBlk + * @param array &$raList Reference to array of PPS's + */ + function _saveBigData($iStBlk, &$raList) + { + $FILE = $this->_FILEH_; + + // cycle through PPS's + for ($i = 0; $i < count($raList); $i++) + { + if($raList[$i]->Type != OLE_PPS_TYPE_DIR) + { + $raList[$i]->Size = $raList[$i]->_DataLen(); + if(($raList[$i]->Size >= OLE_DATA_SIZE_SMALL) or + (($raList[$i]->Type == OLE_PPS_TYPE_ROOT) and isset($raList[$i]->_data))) + { + // Write Data + if(isset($raList[$i]->_PPS_FILE)) + { + $iLen = 0; + fseek($raList[$i]->_PPS_FILE, 0); // To The Top + while($sBuff = fread($raList[$i]->_PPS_FILE, 4096)) + { + $iLen += strlen($sBuff); + fwrite($FILE, $sBuff); + } + } + else { + fwrite($FILE, $raList[$i]->_data); + } + + if ($raList[$i]->Size % $this->_BIG_BLOCK_SIZE) + { + for ($j = 0; $j < ($this->_BIG_BLOCK_SIZE - ($raList[$i]->Size % $this->_BIG_BLOCK_SIZE)); $j++) { + fwrite($FILE, "\x00"); + } + } + // Set For PPS + $raList[$i]->_StartBlock = $iStBlk; + $iStBlk += + (floor($raList[$i]->Size / $this->_BIG_BLOCK_SIZE) + + (($raList[$i]->Size % $this->_BIG_BLOCK_SIZE)? 1: 0)); + } + // Close file for each PPS, and unlink it + if (isset($raList[$i]->_PPS_FILE)) + { + @fclose($raList[$i]->_PPS_FILE); + $raList[$i]->_PPS_FILE = null; + @unlink($raList[$i]->_tmp_filename); + } + } + } + } + + /** + * get small data (PPS's with data smaller than OLE_DATA_SIZE_SMALL) + * + * @access private + * @param array &$raList Reference to array of PPS's + */ + function _makeSmallData(&$raList) + { + $sRes = ''; + $FILE = $this->_FILEH_; + $iSmBlk = 0; + + for ($i = 0; $i < count($raList); $i++) + { + // Make SBD, small data string + if ($raList[$i]->Type == OLE_PPS_TYPE_FILE) + { + if ($raList[$i]->Size <= 0) { + continue; + } + if ($raList[$i]->Size < OLE_DATA_SIZE_SMALL) + { + $iSmbCnt = floor($raList[$i]->Size / $this->_SMALL_BLOCK_SIZE) + + (($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE)? 1: 0); + // Add to SBD + for ($j = 0; $j < ($iSmbCnt-1); $j++) { + fwrite($FILE, pack("V", $j+$iSmBlk+1)); + } + fwrite($FILE, pack("V", -2)); + + // Add to Data String(this will be written for RootEntry) + if ($raList[$i]->_PPS_FILE) + { + fseek($raList[$i]->_PPS_FILE, 0); // To The Top + while ($sBuff = fread($raList[$i]->_PPS_FILE, 4096)) { + $sRes .= $sBuff; + } + } + else { + $sRes .= $raList[$i]->_data; + } + if($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE) + { + for ($j = 0; $j < ($this->_SMALL_BLOCK_SIZE - ($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE)); $j++) { + $sRes .= "\x00"; + } + } + // Set for PPS + $raList[$i]->_StartBlock = $iSmBlk; + $iSmBlk += $iSmbCnt; + } + } + } + $iSbCnt = floor($this->_BIG_BLOCK_SIZE / OLE_LONG_INT_SIZE); + if($iSmBlk % $iSbCnt) + { + for ($i = 0; $i < ($iSbCnt - ($iSmBlk % $iSbCnt)); $i++) { + fwrite($FILE, pack("V", -1)); + } + } + return $sRes; + } + + /** + * Saves all the PPS's WKs + * + * @access private + * @param array $raList Reference to an array with all PPS's + */ + function _savePps(&$raList) + { + // Save each PPS WK + for ($i = 0; $i < count($raList); $i++) { + fwrite($this->_FILEH_, $raList[$i]->_getPpsWk()); + } + // Adjust for Block + $iCnt = count($raList); + $iBCnt = $this->_BIG_BLOCK_SIZE / OLE_PPS_SIZE; + if ($iCnt % $iBCnt) + { + for ($i = 0; $i < (($iBCnt - ($iCnt % $iBCnt)) * OLE_PPS_SIZE); $i++) { + fwrite($this->_FILEH_, "\x00"); + } + } + } + + /** + * Saving Big Block Depot + * + * @access private + * @param integer $iSbdSize + * @param integer $iBsize + * @param integer $iPpsCnt + */ + function _saveBbd($iSbdSize, $iBsize, $iPpsCnt) + { + $FILE = $this->_FILEH_; + // Calculate Basic Setting + $iBbCnt = $this->_BIG_BLOCK_SIZE / OLE_LONG_INT_SIZE; + $i1stBdL = ($this->_BIG_BLOCK_SIZE - 0x4C) / OLE_LONG_INT_SIZE; + + $iBdExL = 0; + $iAll = $iBsize + $iPpsCnt + $iSbdSize; + $iAllW = $iAll; + $iBdCntW = floor($iAllW / $iBbCnt) + (($iAllW % $iBbCnt)? 1: 0); + $iBdCnt = floor(($iAll + $iBdCntW) / $iBbCnt) + ((($iAllW+$iBdCntW) % $iBbCnt)? 1: 0); + // Calculate BD count + if ($iBdCnt >$i1stBdL) + { + while (1) + { + $iBdExL++; + $iAllW++; + $iBdCntW = floor($iAllW / $iBbCnt) + (($iAllW % $iBbCnt)? 1: 0); + $iBdCnt = floor(($iAllW + $iBdCntW) / $iBbCnt) + ((($iAllW+$iBdCntW) % $iBbCnt)? 1: 0); + if ($iBdCnt <= ($iBdExL*$iBbCnt+ $i1stBdL)) { + break; + } + } + } + + // Making BD + // Set for SBD + if ($iSbdSize > 0) + { + for ($i = 0; $i<($iSbdSize-1); $i++) { + fwrite($FILE, pack("V", $i+1)); + } + fwrite($FILE, pack("V", -2)); + } + // Set for B + for ($i = 0; $i<($iBsize-1); $i++) { + fwrite($FILE, pack("V", $i+$iSbdSize+1)); + } + fwrite($FILE, pack("V", -2)); + + // Set for PPS + for ($i = 0; $i<($iPpsCnt-1); $i++) { + fwrite($FILE, pack("V", $i+$iSbdSize+$iBsize+1)); + } + fwrite($FILE, pack("V", -2)); + // Set for BBD itself ( 0xFFFFFFFD : BBD) + for ($i=0; $i<$iBdCnt;$i++) { + fwrite($FILE, pack("V", 0xFFFFFFFD)); + } + // Set for ExtraBDList + for ($i=0; $i<$iBdExL;$i++) { + fwrite($FILE, pack("V", 0xFFFFFFFC)); + } + // Adjust for Block + if (($iAllW + $iBdCnt) % $iBbCnt) + { + for ($i = 0; $i < ($iBbCnt - (($iAllW + $iBdCnt) % $iBbCnt)); $i++) { + fwrite($FILE, pack("V", -1)); + } + } + // Extra BDList + if ($iBdCnt > $i1stBdL) + { + $iN=0; + $iNb=0; + for ($i=$i1stBdL;$i<$iBdCnt; $i++, $iN++) + { + if ($iN>=($iBbCnt-1)) + { + $iN = 0; + $iNb++; + fwrite($FILE, pack("V", $iAll+$iBdCnt+$iNb)); + } + fwrite($FILE, pack("V", $iBsize+$iSbdSize+$iPpsCnt+$i)); + } + if (($iBdCnt-$i1stBdL) % ($iBbCnt-1)) + { + for ($i = 0; $i < (($iBbCnt-1) - (($iBdCnt-$i1stBdL) % ($iBbCnt-1))); $i++) { + fwrite($FILE, pack("V", -1)); + } + } + fwrite($FILE, pack("V", -2)); + } + } +} +?> diff --git a/include/Excel/Validator.php b/include/Excel/Validator.php new file mode 100644 index 000000000..9a776c6c3 --- /dev/null +++ b/include/Excel/Validator.php @@ -0,0 +1,229 @@ + +* +* License Information: +* +* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets +* Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + + +// Possible operator types + +/* +FIXME: change prefixes +*/ +define("OP_BETWEEN", 0x00); +define("OP_NOTBETWEEN", 0x01); +define("OP_EQUAL", 0x02); +define("OP_NOTEQUAL", 0x03); +define("OP_GT", 0x04); +define("OP_LT", 0x05); +define("OP_GTE", 0x06); +define("OP_LTE", 0x07); + +/** +* Baseclass for generating Excel DV records (validations) +* +* @author Herman Kuiper +* @category FileFormats +* @package Spreadsheet_Excel_Writer +*/ +class Spreadsheet_Excel_Writer_Validator +{ + var $_type; + var $_style; + var $_fixedList; + var $_blank; + var $_incell; + var $_showprompt; + var $_showerror; + var $_title_prompt; + var $_descr_prompt; + var $_title_error; + var $_descr_error; + var $_operator; + var $_formula1; + var $_formula2; + /** + * The parser from the workbook. Used to parse validation formulas also + * @var Spreadsheet_Excel_Writer_Parser + */ + var $_parser; + + function Spreadsheet_Excel_Writer_Validator(&$parser) + { + $this->_parser = $parser; + $this->_type = 0x01; // FIXME: add method for setting datatype + $this->_style = 0x00; + $this->_fixedList = false; + $this->_blank = false; + $this->_incell = false; + $this->_showprompt = false; + $this->_showerror = true; + $this->_title_prompt = "\x00"; + $this->_descr_prompt = "\x00"; + $this->_title_error = "\x00"; + $this->_descr_error = "\x00"; + $this->_operator = 0x00; // default is equal + $this->_formula1 = ''; + $this->_formula2 = ''; + } + + function setPrompt($promptTitle = "\x00", $promptDescription = "\x00", $showPrompt = true) + { + $this->_showprompt = $showPrompt; + $this->_title_prompt = $promptTitle; + $this->_descr_prompt = $promptDescription; + } + + function setError($errorTitle = "\x00", $errorDescription = "\x00", $showError = true) + { + $this->_showerror = $showError; + $this->_title_error = $errorTitle; + $this->_descr_error = $errorDescription; + } + + function allowBlank() + { + $this->_blank = true; + } + + function onInvalidStop() + { + $this->_style = 0x00; + } + + function onInvalidWarn() + { + $this->_style = 0x01; + } + + function onInvalidInfo() + { + $this->_style = 0x02; + } + + function setFormula1($formula) + { + // Parse the formula using the parser in Parser.php + $error = $this->_parser->parse($formula); + if (PEAR::isError($error)) { + return $this->_formula1; + } + + $this->_formula1 = $this->_parser->toReversePolish(); + if (PEAR::isError($this->_formula1)) { + return $this->_formula1; + } + return true; + } + + function setFormula2($formula) + { + // Parse the formula using the parser in Parser.php + $error = $this->_parser->parse($formula); + if (PEAR::isError($error)) { + return $this->_formula2; + } + + $this->_formula2 = $this->_parser->toReversePolish(); + if (PEAR::isError($this->_formula2)) { + return $this->_formula2; + } + return true; + } + + function _getOptions() + { + $options = $this->_type; + $options |= $this->_style << 3; + if ($this->_fixedList) { + $options |= 0x80; + } + if ($this->_blank) { + $options |= 0x100; + } + if (!$this->_incell) { + $options |= 0x200; + } + if ($this->_showprompt) { + $options |= 0x40000; + } + if ($this->_showerror) { + $options |= 0x80000; + } + $options |= $this->_operator << 20; + + return $options; + } + + function _getData() + { + $title_prompt_len = strlen($this->_title_prompt); + $descr_prompt_len = strlen($this->_descr_prompt); + $title_error_len = strlen($this->_title_error); + $descr_error_len = strlen($this->_descr_error); + + $formula1_size = strlen($this->_formula1); + $formula2_size = strlen($this->_formula2); + + $data = pack("V", $this->_getOptions()); + $data .= pack("vC", $title_prompt_len, 0x00) . $this->_title_prompt; + $data .= pack("vC", $title_error_len, 0x00) . $this->_title_error; + $data .= pack("vC", $descr_prompt_len, 0x00) . $this->_descr_prompt; + $data .= pack("vC", $descr_error_len, 0x00) . $this->_descr_error; + + $data .= pack("vv", $formula1_size, 0x0000) . $this->_formula1; + $data .= pack("vv", $formula2_size, 0x0000) . $this->_formula2; + + return $data; + } +} + +/*class Spreadsheet_Excel_Writer_Validation_List extends Spreadsheet_Excel_Writer_Validation +{ + function Spreadsheet_Excel_Writer_Validation_list() + { + parent::Spreadsheet_Excel_Writer_Validation(); + $this->_type = 0x03; + } + + function setList($source, $incell = true) + { + $this->_incell = $incell; + $this->_fixedList = true; + + $source = implode("\x00", $source); + $this->_formula1 = pack("CCC", 0x17, strlen($source), 0x0c) . $source; + } + + function setRow($row, $col1, $col2, $incell = true) + { + $this->_incell = $incell; + //$this->_formula1 = ...; + } + + function setCol($col, $row1, $row2, $incell = true) + { + $this->_incell = $incell; + //$this->_formula1 = ...; + } +}*/ + +?> diff --git a/include/Excel/Workbook.php b/include/Excel/Workbook.php new file mode 100644 index 000000000..2bcc369bc --- /dev/null +++ b/include/Excel/Workbook.php @@ -0,0 +1,1523 @@ + +* +* The majority of this is _NOT_ my code. I simply ported it from the +* PERL Spreadsheet::WriteExcel module. +* +* The author of the Spreadsheet::WriteExcel module is John McNamara +* +* +* I _DO_ maintain this code, and John McNamara has nothing to do with the +* porting of this code to PHP. Any questions directly related to this +* class library should be directed to me. +* +* License Information: +* +* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets +* Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + + + +/** +* Class for generating Excel Spreadsheets +* +* @author Xavier Noguer +* @category FileFormats +* @package Spreadsheet_Excel_Writer +*/ + +class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwriter +{ + /** + * Filename for the Workbook + * @var string + */ + var $_filename; + + /** + * Formula parser + * @var object Parser + */ + var $_parser; + + /** + * Flag for 1904 date system (0 => base date is 1900, 1 => base date is 1904) + * @var integer + */ + var $_1904; + + /** + * The active worksheet of the workbook (0 indexed) + * @var integer + */ + var $_activesheet; + + /** + * 1st displayed worksheet in the workbook (0 indexed) + * @var integer + */ + var $_firstsheet; + + /** + * Number of workbook tabs selected + * @var integer + */ + var $_selected; + + /** + * Index for creating adding new formats to the workbook + * @var integer + */ + var $_xf_index; + + /** + * Flag for preventing close from being called twice. + * @var integer + * @see close() + */ + var $_fileclosed; + + /** + * The BIFF file size for the workbook. + * @var integer + * @see _calcSheetOffsets() + */ + var $_biffsize; + + /** + * The default sheetname for all sheets created. + * @var string + */ + var $_sheetname; + + /** + * The default XF format. + * @var object Format + */ + var $_tmp_format; + + /** + * Array containing references to all of this workbook's worksheets + * @var array + */ + var $_worksheets; + + /** + * Array of sheetnames for creating the EXTERNSHEET records + * @var array + */ + var $_sheetnames; + + /** + * Array containing references to all of this workbook's formats + * @var array + */ + var $_formats; + + /** + * Array containing the colour palette + * @var array + */ + var $_palette; + + /** + * The default format for URLs. + * @var object Format + */ + var $_url_format; + + /** + * The codepage indicates the text encoding used for strings + * @var integer + */ + var $_codepage; + + /** + * The country code used for localization + * @var integer + */ + var $_country_code; + + /** + * The temporary dir for storing the OLE file + * @var string + */ + var $_tmp_dir; + + /** + * number of bytes for sizeinfo of strings + * @var integer + */ + var $_string_sizeinfo_size; + + /** + * Class constructor + * + * @param string filename for storing the workbook. "-" for writing to stdout. + * @access public + */ + function Spreadsheet_Excel_Writer_Workbook($filename) + { + // It needs to call its parent's constructor explicitly + $this->Spreadsheet_Excel_Writer_BIFFwriter(); + + $this->_filename = $filename; + $this->_parser =& new Spreadsheet_Excel_Writer_Parser($this->_byte_order, $this->_BIFF_version); + $this->_1904 = 0; + $this->_activesheet = 0; + $this->_firstsheet = 0; + $this->_selected = 0; + $this->_xf_index = 16; // 15 style XF's and 1 cell XF. + $this->_fileclosed = 0; + $this->_biffsize = 0; + $this->_sheetname = 'Sheet'; + $this->_tmp_format =& new Spreadsheet_Excel_Writer_Format($this->_BIFF_version); + $this->_worksheets = array(); + $this->_sheetnames = array(); + $this->_formats = array(); + $this->_palette = array(); + $this->_codepage = 0x04E4; // FIXME: should change for BIFF8 + $this->_country_code = -1; + $this->_string_sizeinfo = 3; + + // Add the default format for hyperlinks + $this->_url_format =& $this->addFormat(array('color' => 'blue', 'underline' => 1)); + $this->_str_total = 0; + $this->_str_unique = 0; + $this->_str_table = array(); + $this->_setPaletteXl97(); + $this->_tmp_dir = ''; + } + + /** + * Calls finalization methods. + * This method should always be the last one to be called on every workbook + * + * @access public + * @return mixed true on success. PEAR_Error on failure + */ + function close() + { + if ($this->_fileclosed) { // Prevent close() from being called twice. + return true; + } + $res = $this->_storeWorkbook(); + if ($this->isError($res)) { + return $this->raiseError($res->getMessage()); + } + $this->_fileclosed = 1; + return true; + } + + /** + * An accessor for the _worksheets[] array + * Returns an array of the worksheet objects in a workbook + * It actually calls to worksheets() + * + * @access public + * @see worksheets() + * @return array + */ + function sheets() + { + return $this->worksheets(); + } + + /** + * An accessor for the _worksheets[] array. + * Returns an array of the worksheet objects in a workbook + * + * @access public + * @return array + */ + function worksheets() + { + return $this->_worksheets; + } + + /** + * Sets the BIFF version. + * This method exists just to access experimental functionality + * from BIFF8. It will be deprecated ! + * Only possible value is 8 (Excel 97/2000). + * For any other value it fails silently. + * + * @access public + * @param integer $version The BIFF version + */ + function setVersion($version) + { + if ($version == 8) { // only accept version 8 + $version = 0x0600; + $this->_BIFF_version = $version; + // change BIFFwriter limit for CONTINUE records + $this->_limit = 8228; + $this->_tmp_format->_BIFF_version = $version; + $this->_url_format->_BIFF_version = $version; + $this->_parser->_BIFF_version = $version; + + $total_worksheets = count($this->_worksheets); + // change version for all worksheets too + for ($i = 0; $i < $total_worksheets; $i++) { + $this->_worksheets[$i]->_BIFF_version = $version; + } + + $total_formats = count($this->_formats); + // change version for all formats too + for ($i = 0; $i < $total_formats; $i++) { + $this->_formats[$i]->_BIFF_version = $version; + } + } + } + + /** + * Set the country identifier for the workbook + * + * @access public + * @param integer $code Is the international calling country code for the + * chosen country. + */ + function setCountry($code) + { + $this->_country_code = $code; + } + + /** + * Add a new worksheet to the Excel workbook. + * If no name is given the name of the worksheet will be Sheeti$i, with + * $i in [1..]. + * + * @access public + * @param string $name the optional name of the worksheet + * @return mixed reference to a worksheet object on success, PEAR_Error + * on failure + */ + function &addWorksheet($name = '') + { + $index = count($this->_worksheets); + $sheetname = $this->_sheetname; + + if ($name == '') { + $name = $sheetname.($index+1); + } + + // Check that sheetname is <= 31 chars (Excel limit before BIFF8). + if ($this->_BIFF_version != 0x0600) + { + if (strlen($name) > 31) { + return $this->raiseError("Sheetname $name must be <= 31 chars"); + } + } + + // Check that the worksheet name doesn't already exist: a fatal Excel error. + $total_worksheets = count($this->_worksheets); + for ($i = 0; $i < $total_worksheets; $i++) { + if ($this->_worksheets[$i]->getName() == $name) { + return $this->raiseError("Worksheet '$name' already exists"); + } + } + + $worksheet = new Spreadsheet_Excel_Writer_Worksheet($this->_BIFF_version, + $name, $index, + $this->_activesheet, $this->_firstsheet, + $this->_str_total, $this->_str_unique, + $this->_str_table, $this->_url_format, + $this->_parser); + + $this->_worksheets[$index] = &$worksheet; // Store ref for iterator + $this->_sheetnames[$index] = $name; // Store EXTERNSHEET names + $this->_parser->setExtSheet($name, $index); // Register worksheet name with parser + return $worksheet; + } + + /** + * Add a new format to the Excel workbook. + * Also, pass any properties to the Format constructor. + * + * @access public + * @param array $properties array with properties for initializing the format. + * @return &Spreadsheet_Excel_Writer_Format reference to an Excel Format + */ + function &addFormat($properties = array()) + { + $format = new Spreadsheet_Excel_Writer_Format($this->_BIFF_version, $this->_xf_index, $properties); + $this->_xf_index += 1; + $this->_formats[] = &$format; + return $format; + } + + /** + * Create new validator. + * + * @access public + * @return &Spreadsheet_Excel_Writer_Validator reference to a Validator + */ + function &addValidator() + { + include_once 'Spreadsheet/Excel/Writer/Validator.php'; + /* FIXME: check for successful inclusion*/ + $valid = new Spreadsheet_Excel_Writer_Validator($this->_parser); + return $valid; + } + + /** + * Change the RGB components of the elements in the colour palette. + * + * @access public + * @param integer $index colour index + * @param integer $red red RGB value [0-255] + * @param integer $green green RGB value [0-255] + * @param integer $blue blue RGB value [0-255] + * @return integer The palette index for the custom color + */ + function setCustomColor($index, $red, $green, $blue) + { + // Match a HTML #xxyyzz style parameter + /*if (defined $_[1] and $_[1] =~ /^#(\w\w)(\w\w)(\w\w)/ ) { + @_ = ($_[0], hex $1, hex $2, hex $3); + }*/ + + // Check that the colour index is the right range + if ($index < 8 or $index > 64) { + // TODO: assign real error codes + return $this->raiseError("Color index $index outside range: 8 <= index <= 64"); + } + + // Check that the colour components are in the right range + if (($red < 0 or $red > 255) || + ($green < 0 or $green > 255) || + ($blue < 0 or $blue > 255)) + { + return $this->raiseError("Color component outside range: 0 <= color <= 255"); + } + + $index -= 8; // Adjust colour index (wingless dragonfly) + + // Set the RGB value + $this->_palette[$index] = array($red, $green, $blue, 0); + return($index + 8); + } + + /** + * Sets the colour palette to the Excel 97+ default. + * + * @access private + */ + function _setPaletteXl97() + { + $this->_palette = array( + array(0x00, 0x00, 0x00, 0x00), // 8 + array(0xff, 0xff, 0xff, 0x00), // 9 + array(0xff, 0x00, 0x00, 0x00), // 10 + array(0x00, 0xff, 0x00, 0x00), // 11 + array(0x00, 0x00, 0xff, 0x00), // 12 + array(0xff, 0xff, 0x00, 0x00), // 13 + array(0xff, 0x00, 0xff, 0x00), // 14 + array(0x00, 0xff, 0xff, 0x00), // 15 + array(0x80, 0x00, 0x00, 0x00), // 16 + array(0x00, 0x80, 0x00, 0x00), // 17 + array(0x00, 0x00, 0x80, 0x00), // 18 + array(0x80, 0x80, 0x00, 0x00), // 19 + array(0x80, 0x00, 0x80, 0x00), // 20 + array(0x00, 0x80, 0x80, 0x00), // 21 + array(0xc0, 0xc0, 0xc0, 0x00), // 22 + array(0x80, 0x80, 0x80, 0x00), // 23 + array(0x99, 0x99, 0xff, 0x00), // 24 + array(0x99, 0x33, 0x66, 0x00), // 25 + array(0xff, 0xff, 0xcc, 0x00), // 26 + array(0xcc, 0xff, 0xff, 0x00), // 27 + array(0x66, 0x00, 0x66, 0x00), // 28 + array(0xff, 0x80, 0x80, 0x00), // 29 + array(0x00, 0x66, 0xcc, 0x00), // 30 + array(0xcc, 0xcc, 0xff, 0x00), // 31 + array(0x00, 0x00, 0x80, 0x00), // 32 + array(0xff, 0x00, 0xff, 0x00), // 33 + array(0xff, 0xff, 0x00, 0x00), // 34 + array(0x00, 0xff, 0xff, 0x00), // 35 + array(0x80, 0x00, 0x80, 0x00), // 36 + array(0x80, 0x00, 0x00, 0x00), // 37 + array(0x00, 0x80, 0x80, 0x00), // 38 + array(0x00, 0x00, 0xff, 0x00), // 39 + array(0x00, 0xcc, 0xff, 0x00), // 40 + array(0xcc, 0xff, 0xff, 0x00), // 41 + array(0xcc, 0xff, 0xcc, 0x00), // 42 + array(0xff, 0xff, 0x99, 0x00), // 43 + array(0x99, 0xcc, 0xff, 0x00), // 44 + array(0xff, 0x99, 0xcc, 0x00), // 45 + array(0xcc, 0x99, 0xff, 0x00), // 46 + array(0xff, 0xcc, 0x99, 0x00), // 47 + array(0x33, 0x66, 0xff, 0x00), // 48 + array(0x33, 0xcc, 0xcc, 0x00), // 49 + array(0x99, 0xcc, 0x00, 0x00), // 50 + array(0xff, 0xcc, 0x00, 0x00), // 51 + array(0xff, 0x99, 0x00, 0x00), // 52 + array(0xff, 0x66, 0x00, 0x00), // 53 + array(0x66, 0x66, 0x99, 0x00), // 54 + array(0x96, 0x96, 0x96, 0x00), // 55 + array(0x00, 0x33, 0x66, 0x00), // 56 + array(0x33, 0x99, 0x66, 0x00), // 57 + array(0x00, 0x33, 0x00, 0x00), // 58 + array(0x33, 0x33, 0x00, 0x00), // 59 + array(0x99, 0x33, 0x00, 0x00), // 60 + array(0x99, 0x33, 0x66, 0x00), // 61 + array(0x33, 0x33, 0x99, 0x00), // 62 + array(0x33, 0x33, 0x33, 0x00), // 63 + ); + } + + /** + * Assemble worksheets into a workbook and send the BIFF data to an OLE + * storage. + * + * @access private + * @return mixed true on success. PEAR_Error on failure + */ + function _storeWorkbook() + { + // Ensure that at least one worksheet has been selected. + if ($this->_activesheet == 0) { + $this->_worksheets[0]->selected = 1; + } + + // Calculate the number of selected worksheet tabs and call the finalization + // methods for each worksheet + $total_worksheets = count($this->_worksheets); + for ($i = 0; $i < $total_worksheets; $i++) { + if ($this->_worksheets[$i]->selected) { + $this->_selected++; + } + $this->_worksheets[$i]->close($this->_sheetnames); + } + + // Add Workbook globals + $this->_storeBof(0x0005); + $this->_storeCodepage(); + if ($this->_BIFF_version == 0x0600) { + $this->_storeWindow1(); + } + if ($this->_BIFF_version == 0x0500) { + $this->_storeExterns(); // For print area and repeat rows + } + $this->_storeNames(); // For print area and repeat rows + if ($this->_BIFF_version == 0x0500) { + $this->_storeWindow1(); + } + $this->_storeDatemode(); + $this->_storeAllFonts(); + $this->_storeAllNumFormats(); + $this->_storeAllXfs(); + $this->_storeAllStyles(); + $this->_storePalette(); + $this->_calcSheetOffsets(); + + // Add BOUNDSHEET records + for ($i = 0; $i < $total_worksheets; $i++) { + $this->_storeBoundsheet($this->_worksheets[$i]->name,$this->_worksheets[$i]->offset); + } + + if ($this->_country_code != -1) { + $this->_storeCountry(); + } + + if ($this->_BIFF_version == 0x0600) { + //$this->_storeSupbookInternal(); + /* TODO: store external SUPBOOK records and XCT and CRN records + in case of external references for BIFF8 */ + //$this->_storeExternsheetBiff8(); + $this->_storeSharedStringsTable(); + } + + // End Workbook globals + $this->_storeEof(); + + // Store the workbook in an OLE container + $res = $this->_storeOLEFile(); + if ($this->isError($res)) { + return $this->raiseError($res->getMessage()); + } + return true; + } + + /** + * Sets the temp dir used for storing the OLE file + * + * @access public + * @param string $dir The dir to be used as temp dir + * @return true if given dir is valid, false otherwise + */ + function setTempDir($dir) + { + if (is_dir($dir)) { + $this->_tmp_dir = $dir; + return true; + } + return false; + } + + /** + * Store the workbook in an OLE container + * + * @access private + * @return mixed true on success. PEAR_Error on failure + */ + function _storeOLEFile() + { + $OLE = new OLE_PPS_File(OLE::Asc2Ucs('Book')); + if ($this->_tmp_dir != '') { + $OLE->setTempDir($this->_tmp_dir); + } + $res = $OLE->init(); + if ($this->isError($res)) { + return $this->raiseError("OLE Error: ".$res->getMessage()); + } + $OLE->append($this->_data); + + $total_worksheets = count($this->_worksheets); + for ($i = 0; $i < $total_worksheets; $i++) { + while ($tmp = $this->_worksheets[$i]->getData()) { + $OLE->append($tmp); + } + } + + $root = new OLE_PPS_Root(time(), time(), array($OLE)); + if ($this->_tmp_dir != '') { + $root->setTempDir($this->_tmp_dir); + } + + $res = $root->save($this->_filename); + if ($this->isError($res)) { + return $this->raiseError("OLE Error: ".$res->getMessage()); + } + return true; + } + + /** + * Calculate offsets for Worksheet BOF records. + * + * @access private + */ + function _calcSheetOffsets() + { + if ($this->_BIFF_version == 0x0600) { + $boundsheet_length = 12; // fixed length for a BOUNDSHEET record + } else { + $boundsheet_length = 11; + } + $EOF = 4; + $offset = $this->_datasize; + + if ($this->_BIFF_version == 0x0600) { + // add the length of the SST + /* TODO: check this works for a lot of strings (> 8224 bytes) */ + $offset += $this->_calculateSharedStringsSizes(); + if ($this->_country_code != -1) { + $offset += 8; // adding COUNTRY record + } + // add the lenght of SUPBOOK, EXTERNSHEET and NAME records + //$offset += 8; // FIXME: calculate real value when storing the records + } + $total_worksheets = count($this->_worksheets); + // add the length of the BOUNDSHEET records + for ($i = 0; $i < $total_worksheets; $i++) { + $offset += $boundsheet_length + strlen($this->_worksheets[$i]->name); + } + $offset += $EOF; + + for ($i = 0; $i < $total_worksheets; $i++) { + $this->_worksheets[$i]->offset = $offset; + $offset += $this->_worksheets[$i]->_datasize; + } + $this->_biffsize = $offset; + } + + /** + * Store the Excel FONT records. + * + * @access private + */ + function _storeAllFonts() + { + // tmp_format is added by the constructor. We use this to write the default XF's + $format = $this->_tmp_format; + $font = $format->getFont(); + + // Note: Fonts are 0-indexed. According to the SDK there is no index 4, + // so the following fonts are 0, 1, 2, 3, 5 + // + for ($i = 1; $i <= 5; $i++){ + $this->_append($font); + } + + // Iterate through the XF objects and write a FONT record if it isn't the + // same as the default FONT and if it hasn't already been used. + // + $fonts = array(); + $index = 6; // The first user defined FONT + + $key = $format->getFontKey(); // The default font from _tmp_format + $fonts[$key] = 0; // Index of the default font + + $total_formats = count($this->_formats); + for ($i = 0; $i < $total_formats; $i++) { + $key = $this->_formats[$i]->getFontKey(); + if (isset($fonts[$key])) { + // FONT has already been used + $this->_formats[$i]->font_index = $fonts[$key]; + } else { + // Add a new FONT record + $fonts[$key] = $index; + $this->_formats[$i]->font_index = $index; + $index++; + $font = $this->_formats[$i]->getFont(); + $this->_append($font); + } + } + } + + /** + * Store user defined numerical formats i.e. FORMAT records + * + * @access private + */ + function _storeAllNumFormats() + { + // Leaning num_format syndrome + $hash_num_formats = array(); + $num_formats = array(); + $index = 164; + + // Iterate through the XF objects and write a FORMAT record if it isn't a + // built-in format type and if the FORMAT string hasn't already been used. + $total_formats = count($this->_formats); + for ($i = 0; $i < $total_formats; $i++) { + $num_format = $this->_formats[$i]->_num_format; + + // Check if $num_format is an index to a built-in format. + // Also check for a string of zeros, which is a valid format string + // but would evaluate to zero. + // + if (!preg_match("/^0+\d/", $num_format)) { + if (preg_match("/^\d+$/", $num_format)) { // built-in format + continue; + } + } + + if (isset($hash_num_formats[$num_format])) { + // FORMAT has already been used + $this->_formats[$i]->_num_format = $hash_num_formats[$num_format]; + } else{ + // Add a new FORMAT + $hash_num_formats[$num_format] = $index; + $this->_formats[$i]->_num_format = $index; + array_push($num_formats,$num_format); + $index++; + } + } + + // Write the new FORMAT records starting from 0xA4 + $index = 164; + foreach ($num_formats as $num_format) { + $this->_storeNumFormat($num_format,$index); + $index++; + } + } + + /** + * Write all XF records. + * + * @access private + */ + function _storeAllXfs() + { + // _tmp_format is added by the constructor. We use this to write the default XF's + // The default font index is 0 + // + $format = $this->_tmp_format; + for ($i = 0; $i <= 14; $i++) { + $xf = $format->getXf('style'); // Style XF + $this->_append($xf); + } + + $xf = $format->getXf('cell'); // Cell XF + $this->_append($xf); + + // User defined XFs + $total_formats = count($this->_formats); + for ($i = 0; $i < $total_formats; $i++) { + $xf = $this->_formats[$i]->getXf('cell'); + $this->_append($xf); + } + } + + /** + * Write all STYLE records. + * + * @access private + */ + function _storeAllStyles() + { + $this->_storeStyle(); + } + + /** + * Write the EXTERNCOUNT and EXTERNSHEET records. These are used as indexes for + * the NAME records. + * + * @access private + */ + function _storeExterns() + { + // Create EXTERNCOUNT with number of worksheets + $this->_storeExterncount(count($this->_worksheets)); + + // Create EXTERNSHEET for each worksheet + foreach ($this->_sheetnames as $sheetname) { + $this->_storeExternsheet($sheetname); + } + } + + /** + * Write the NAME record to define the print area and the repeat rows and cols. + * + * @access private + */ + function _storeNames() + { + // Create the print area NAME records + $total_worksheets = count($this->_worksheets); + for ($i = 0; $i < $total_worksheets; $i++) { + // Write a Name record if the print area has been defined + if (isset($this->_worksheets[$i]->print_rowmin)) { + $this->_storeNameShort( + $this->_worksheets[$i]->index, + 0x06, // NAME type + $this->_worksheets[$i]->print_rowmin, + $this->_worksheets[$i]->print_rowmax, + $this->_worksheets[$i]->print_colmin, + $this->_worksheets[$i]->print_colmax + ); + } + } + + // Create the print title NAME records + $total_worksheets = count($this->_worksheets); + for ($i = 0; $i < $total_worksheets; $i++) { + $rowmin = $this->_worksheets[$i]->title_rowmin; + $rowmax = $this->_worksheets[$i]->title_rowmax; + $colmin = $this->_worksheets[$i]->title_colmin; + $colmax = $this->_worksheets[$i]->title_colmax; + + // Determine if row + col, row, col or nothing has been defined + // and write the appropriate record + // + if (isset($rowmin) && isset($colmin)) { + // Row and column titles have been defined. + // Row title has been defined. + $this->_storeNameLong( + $this->_worksheets[$i]->index, + 0x07, // NAME type + $rowmin, + $rowmax, + $colmin, + $colmax + ); + } elseif (isset($rowmin)) { + // Row title has been defined. + $this->_storeNameShort( + $this->_worksheets[$i]->index, + 0x07, // NAME type + $rowmin, + $rowmax, + 0x00, + 0xff + ); + } elseif (isset($colmin)) { + // Column title has been defined. + $this->_storeNameShort( + $this->_worksheets[$i]->index, + 0x07, // NAME type + 0x0000, + 0x3fff, + $colmin, + $colmax + ); + } else { + // Print title hasn't been defined. + } + } + } + + + + + /****************************************************************************** + * + * BIFF RECORDS + * + */ + + /** + * Stores the CODEPAGE biff record. + * + * @access private + */ + function _storeCodepage() + { + $record = 0x0042; // Record identifier + $length = 0x0002; // Number of bytes to follow + $cv = $this->_codepage; // The code page + + $header = pack('vv', $record, $length); + $data = pack('v', $cv); + + $this->_append($header . $data); + } + + /** + * Write Excel BIFF WINDOW1 record. + * + * @access private + */ + function _storeWindow1() + { + $record = 0x003D; // Record identifier + $length = 0x0012; // Number of bytes to follow + + $xWn = 0x0000; // Horizontal position of window + $yWn = 0x0000; // Vertical position of window + $dxWn = 0x25BC; // Width of window + $dyWn = 0x1572; // Height of window + + $grbit = 0x0038; // Option flags + $ctabsel = $this->_selected; // Number of workbook tabs selected + $wTabRatio = 0x0258; // Tab to scrollbar ratio + + $itabFirst = $this->_firstsheet; // 1st displayed worksheet + $itabCur = $this->_activesheet; // Active worksheet + + $header = pack("vv", $record, $length); + $data = pack("vvvvvvvvv", $xWn, $yWn, $dxWn, $dyWn, + $grbit, + $itabCur, $itabFirst, + $ctabsel, $wTabRatio); + $this->_append($header . $data); + } + + /** + * Writes Excel BIFF BOUNDSHEET record. + * FIXME: inconsistent with BIFF documentation + * + * @param string $sheetname Worksheet name + * @param integer $offset Location of worksheet BOF + * @access private + */ + function _storeBoundsheet($sheetname,$offset) + { + $record = 0x0085; // Record identifier + if ($this->_BIFF_version == 0x0600) { + $length = 0x08 + strlen($sheetname); // Number of bytes to follow + } else { + $length = 0x07 + strlen($sheetname); // Number of bytes to follow + } + + $grbit = 0x0000; // Visibility and sheet type + $cch = strlen($sheetname); // Length of sheet name + + $header = pack("vv", $record, $length); + if ($this->_BIFF_version == 0x0600) { + $data = pack("Vvv", $offset, $grbit, $cch); + } else { + $data = pack("VvC", $offset, $grbit, $cch); + } + $this->_append($header.$data.$sheetname); + } + + /** + * Write Internal SUPBOOK record + * + * @access private + */ + function _storeSupbookInternal() + { + $record = 0x01AE; // Record identifier + $length = 0x0004; // Bytes to follow + + $header = pack("vv", $record, $length); + $data = pack("vv", count($this->_worksheets), 0x0104); + $this->_append($header . $data); + } + + /** + * Writes the Excel BIFF EXTERNSHEET record. These references are used by + * formulas. + * + * @param string $sheetname Worksheet name + * @access private + */ + function _storeExternsheetBiff8() + { + $total_references = count($this->_parser->_references); + $record = 0x0017; // Record identifier + $length = 2 + 6 * $total_references; // Number of bytes to follow + + $supbook_index = 0; // FIXME: only using internal SUPBOOK record + $header = pack("vv", $record, $length); + $data = pack('v', $total_references); + for ($i = 0; $i < $total_references; $i++) { + $data .= $this->_parser->_references[$i]; + } + $this->_append($header . $data); + } + + /** + * Write Excel BIFF STYLE records. + * + * @access private + */ + function _storeStyle() + { + $record = 0x0293; // Record identifier + $length = 0x0004; // Bytes to follow + + $ixfe = 0x8000; // Index to style XF + $BuiltIn = 0x00; // Built-in style + $iLevel = 0xff; // Outline style level + + $header = pack("vv", $record, $length); + $data = pack("vCC", $ixfe, $BuiltIn, $iLevel); + $this->_append($header . $data); + } + + + /** + * Writes Excel FORMAT record for non "built-in" numerical formats. + * + * @param string $format Custom format string + * @param integer $ifmt Format index code + * @access private + */ + function _storeNumFormat($format, $ifmt) + { + $record = 0x041E; // Record identifier + + if ($this->_BIFF_version == 0x0600) { + $length = 5 + strlen($format); // Number of bytes to follow + $encoding = 0x0; + } elseif ($this->_BIFF_version == 0x0500) { + $length = 3 + strlen($format); // Number of bytes to follow + } + + $cch = strlen($format); // Length of format string + + $header = pack("vv", $record, $length); + if ($this->_BIFF_version == 0x0600) { + $data = pack("vvC", $ifmt, $cch, $encoding); + } elseif ($this->_BIFF_version == 0x0500) { + $data = pack("vC", $ifmt, $cch); + } + $this->_append($header . $data . $format); + } + + /** + * Write DATEMODE record to indicate the date system in use (1904 or 1900). + * + * @access private + */ + function _storeDatemode() + { + $record = 0x0022; // Record identifier + $length = 0x0002; // Bytes to follow + + $f1904 = $this->_1904; // Flag for 1904 date system + + $header = pack("vv", $record, $length); + $data = pack("v", $f1904); + $this->_append($header . $data); + } + + + /** + * Write BIFF record EXTERNCOUNT to indicate the number of external sheet + * references in the workbook. + * + * Excel only stores references to external sheets that are used in NAME. + * The workbook NAME record is required to define the print area and the repeat + * rows and columns. + * + * A similar method is used in Worksheet.php for a slightly different purpose. + * + * @param integer $cxals Number of external references + * @access private + */ + function _storeExterncount($cxals) + { + $record = 0x0016; // Record identifier + $length = 0x0002; // Number of bytes to follow + + $header = pack("vv", $record, $length); + $data = pack("v", $cxals); + $this->_append($header . $data); + } + + + /** + * Writes the Excel BIFF EXTERNSHEET record. These references are used by + * formulas. NAME record is required to define the print area and the repeat + * rows and columns. + * + * A similar method is used in Worksheet.php for a slightly different purpose. + * + * @param string $sheetname Worksheet name + * @access private + */ + function _storeExternsheet($sheetname) + { + $record = 0x0017; // Record identifier + $length = 0x02 + strlen($sheetname); // Number of bytes to follow + + $cch = strlen($sheetname); // Length of sheet name + $rgch = 0x03; // Filename encoding + + $header = pack("vv", $record, $length); + $data = pack("CC", $cch, $rgch); + $this->_append($header . $data . $sheetname); + } + + + /** + * Store the NAME record in the short format that is used for storing the print + * area, repeat rows only and repeat columns only. + * + * @param integer $index Sheet index + * @param integer $type Built-in name type + * @param integer $rowmin Start row + * @param integer $rowmax End row + * @param integer $colmin Start colum + * @param integer $colmax End column + * @access private + */ + function _storeNameShort($index, $type, $rowmin, $rowmax, $colmin, $colmax) + { + $record = 0x0018; // Record identifier + $length = 0x0024; // Number of bytes to follow + + $grbit = 0x0020; // Option flags + $chKey = 0x00; // Keyboard shortcut + $cch = 0x01; // Length of text name + $cce = 0x0015; // Length of text definition + $ixals = $index + 1; // Sheet index + $itab = $ixals; // Equal to ixals + $cchCustMenu = 0x00; // Length of cust menu text + $cchDescription = 0x00; // Length of description text + $cchHelptopic = 0x00; // Length of help topic text + $cchStatustext = 0x00; // Length of status bar text + $rgch = $type; // Built-in name type + + $unknown03 = 0x3b; + $unknown04 = 0xffff-$index; + $unknown05 = 0x0000; + $unknown06 = 0x0000; + $unknown07 = 0x1087; + $unknown08 = 0x8005; + + $header = pack("vv", $record, $length); + $data = pack("v", $grbit); + $data .= pack("C", $chKey); + $data .= pack("C", $cch); + $data .= pack("v", $cce); + $data .= pack("v", $ixals); + $data .= pack("v", $itab); + $data .= pack("C", $cchCustMenu); + $data .= pack("C", $cchDescription); + $data .= pack("C", $cchHelptopic); + $data .= pack("C", $cchStatustext); + $data .= pack("C", $rgch); + $data .= pack("C", $unknown03); + $data .= pack("v", $unknown04); + $data .= pack("v", $unknown05); + $data .= pack("v", $unknown06); + $data .= pack("v", $unknown07); + $data .= pack("v", $unknown08); + $data .= pack("v", $index); + $data .= pack("v", $index); + $data .= pack("v", $rowmin); + $data .= pack("v", $rowmax); + $data .= pack("C", $colmin); + $data .= pack("C", $colmax); + $this->_append($header . $data); + } + + + /** + * Store the NAME record in the long format that is used for storing the repeat + * rows and columns when both are specified. This shares a lot of code with + * _storeNameShort() but we use a separate method to keep the code clean. + * Code abstraction for reuse can be carried too far, and I should know. ;-) + * + * @param integer $index Sheet index + * @param integer $type Built-in name type + * @param integer $rowmin Start row + * @param integer $rowmax End row + * @param integer $colmin Start colum + * @param integer $colmax End column + * @access private + */ + function _storeNameLong($index, $type, $rowmin, $rowmax, $colmin, $colmax) + { + $record = 0x0018; // Record identifier + $length = 0x003d; // Number of bytes to follow + $grbit = 0x0020; // Option flags + $chKey = 0x00; // Keyboard shortcut + $cch = 0x01; // Length of text name + $cce = 0x002e; // Length of text definition + $ixals = $index + 1; // Sheet index + $itab = $ixals; // Equal to ixals + $cchCustMenu = 0x00; // Length of cust menu text + $cchDescription = 0x00; // Length of description text + $cchHelptopic = 0x00; // Length of help topic text + $cchStatustext = 0x00; // Length of status bar text + $rgch = $type; // Built-in name type + + $unknown01 = 0x29; + $unknown02 = 0x002b; + $unknown03 = 0x3b; + $unknown04 = 0xffff-$index; + $unknown05 = 0x0000; + $unknown06 = 0x0000; + $unknown07 = 0x1087; + $unknown08 = 0x8008; + + $header = pack("vv", $record, $length); + $data = pack("v", $grbit); + $data .= pack("C", $chKey); + $data .= pack("C", $cch); + $data .= pack("v", $cce); + $data .= pack("v", $ixals); + $data .= pack("v", $itab); + $data .= pack("C", $cchCustMenu); + $data .= pack("C", $cchDescription); + $data .= pack("C", $cchHelptopic); + $data .= pack("C", $cchStatustext); + $data .= pack("C", $rgch); + $data .= pack("C", $unknown01); + $data .= pack("v", $unknown02); + // Column definition + $data .= pack("C", $unknown03); + $data .= pack("v", $unknown04); + $data .= pack("v", $unknown05); + $data .= pack("v", $unknown06); + $data .= pack("v", $unknown07); + $data .= pack("v", $unknown08); + $data .= pack("v", $index); + $data .= pack("v", $index); + $data .= pack("v", 0x0000); + $data .= pack("v", 0x3fff); + $data .= pack("C", $colmin); + $data .= pack("C", $colmax); + // Row definition + $data .= pack("C", $unknown03); + $data .= pack("v", $unknown04); + $data .= pack("v", $unknown05); + $data .= pack("v", $unknown06); + $data .= pack("v", $unknown07); + $data .= pack("v", $unknown08); + $data .= pack("v", $index); + $data .= pack("v", $index); + $data .= pack("v", $rowmin); + $data .= pack("v", $rowmax); + $data .= pack("C", 0x00); + $data .= pack("C", 0xff); + // End of data + $data .= pack("C", 0x10); + $this->_append($header . $data); + } + + /** + * Stores the COUNTRY record for localization + * + * @access private + */ + function _storeCountry() + { + $record = 0x008C; // Record identifier + $length = 4; // Number of bytes to follow + + $header = pack('vv', $record, $length); + /* using the same country code always for simplicity */ + $data = pack('vv', $this->_country_code, $this->_country_code); + $this->_append($header . $data); + } + + /** + * Stores the PALETTE biff record. + * + * @access private + */ + function _storePalette() + { + $aref = $this->_palette; + + $record = 0x0092; // Record identifier + $length = 2 + 4 * count($aref); // Number of bytes to follow + $ccv = count($aref); // Number of RGB values to follow + $data = ''; // The RGB data + + // Pack the RGB data + foreach ($aref as $color) { + foreach ($color as $byte) { + $data .= pack("C",$byte); + } + } + + $header = pack("vvv", $record, $length, $ccv); + $this->_append($header . $data); + } + + /** + * Calculate + * Handling of the SST continue blocks is complicated by the need to include an + * additional continuation byte depending on whether the string is split between + * blocks or whether it starts at the beginning of the block. (There are also + * additional complications that will arise later when/if Rich Strings are + * supported). + * + * @access private + */ + function _calculateSharedStringsSizes() + { + /* Iterate through the strings to calculate the CONTINUE block sizes. + For simplicity we use the same size for the SST and CONTINUE records: + 8228 : Maximum Excel97 block size + -4 : Length of block header + -8 : Length of additional SST header information + = 8216 + */ + $continue_limit = 8216; + $block_length = 0; + $written = 0; + $this->_block_sizes = array(); + $continue = 0; + + foreach (array_keys($this->_str_table) as $string) { + $string_length = strlen($string); + + // Block length is the total length of the strings that will be + // written out in a single SST or CONTINUE block. + $block_length += $string_length; + + // We can write the string if it doesn't cross a CONTINUE boundary + if ($block_length < $continue_limit) { + $written += $string_length; + continue; + } + + // Deal with the cases where the next string to be written will exceed + // the CONTINUE boundary. If the string is very long it may need to be + // written in more than one CONTINUE record. + while ($block_length >= $continue_limit) { + + // We need to avoid the case where a string is continued in the first + // n bytes that contain the string header information. + $header_length = 3; // Min string + header size -1 + $space_remaining = $continue_limit - $written - $continue; + + + /* TODO: Unicode data should only be split on char (2 byte) + boundaries. Therefore, in some cases we need to reduce the + amount of available + */ + + if ($space_remaining > $header_length) { + // Write as much as possible of the string in the current block + $written += $space_remaining; + + // Reduce the current block length by the amount written + $block_length -= $continue_limit - $continue; + + // Store the max size for this block + $this->_block_sizes[] = $continue_limit; + + // If the current string was split then the next CONTINUE block + // should have the string continue flag (grbit) set unless the + // split string fits exactly into the remaining space. + if ($block_length > 0) { + $continue = 1; + } else { + $continue = 0; + } + } else { + // Store the max size for this block + $this->_block_sizes[] = $written + $continue; + + // Not enough space to start the string in the current block + $block_length -= $continue_limit - $space_remaining - $continue; + $continue = 0; + + } + + // If the string (or substr) is small enough we can write it in the + // new CONTINUE block. Else, go through the loop again to write it in + // one or more CONTINUE blocks + if ($block_length < $continue_limit) { + $written = $block_length; + } else { + $written = 0; + } + } + } + + // Store the max size for the last block unless it is empty + if ($written + $continue) { + $this->_block_sizes[] = $written + $continue; + } + + + /* Calculate the total length of the SST and associated CONTINUEs (if any). + The SST record will have a length even if it contains no strings. + This length is required to set the offsets in the BOUNDSHEET records since + they must be written before the SST records + */ + $total_offset = array_sum($this->_block_sizes); + // SST information + $total_offset += 8; + if (!empty($this->_block_sizes)) { + $total_offset += (count($this->_block_sizes)) * 4; // add CONTINUE headers + } + return $total_offset; + } + + /** + * Write all of the workbooks strings into an indexed array. + * See the comments in _calculate_shared_string_sizes() for more information. + * + * The Excel documentation says that the SST record should be followed by an + * EXTSST record. The EXTSST record is a hash table that is used to optimise + * access to SST. However, despite the documentation it doesn't seem to be + * required so we will ignore it. + * + * @access private + */ + function _storeSharedStringsTable() + { + $record = 0x00fc; // Record identifier + // sizes are upside down + $this->_block_sizes = array_reverse($this->_block_sizes); + $length = array_pop($this->_block_sizes) + 8; // First block size plus SST information + + // Write the SST block header information + $header = pack("vv", $record, $length); + $data = pack("VV", $this->_str_total, $this->_str_unique); + $this->_append($header . $data); + + + // Iterate through the strings to calculate the CONTINUE block sizes + $continue_limit = 8216; + $block_length = 0; + $written = 0; + $continue = 0; + + + /* TODO: not good for performance */ + foreach (array_keys($this->_str_table) as $string) { + + $string_length = strlen($string); + $encoding = 0; // assume there are no Unicode strings + $split_string = 0; + + // Block length is the total length of the strings that will be + // written out in a single SST or CONTINUE block. + // + $block_length += $string_length; + + + // We can write the string if it doesn't cross a CONTINUE boundary + if ($block_length < $continue_limit) { + $this->_append($string); + $written += $string_length; + continue; + } + + // Deal with the cases where the next string to be written will exceed + // the CONTINUE boundary. If the string is very long it may need to be + // written in more than one CONTINUE record. + // + while ($block_length >= $continue_limit) { + + // We need to avoid the case where a string is continued in the first + // n bytes that contain the string header information. + // + $header_length = 3; // Min string + header size -1 + $space_remaining = $continue_limit - $written - $continue; + + + // Unicode data should only be split on char (2 byte) boundaries. + // Therefore, in some cases we need to reduce the amount of available + + if ($space_remaining > $header_length) { + // Write as much as possible of the string in the current block + $tmp = substr($string, 0, $space_remaining); + $this->_append($tmp); + + // The remainder will be written in the next block(s) + $string = substr($string, $space_remaining); + + // Reduce the current block length by the amount written + $block_length -= $continue_limit - $continue; + + // If the current string was split then the next CONTINUE block + // should have the string continue flag (grbit) set unless the + // split string fits exactly into the remaining space. + // + if ($block_length > 0) { + $continue = 1; + } else { + $continue = 0; + } + } else { + // Not enough space to start the string in the current block + $block_length -= $continue_limit - $space_remaining - $continue; + $continue = 0; + } + + // Write the CONTINUE block header + if (!empty($this->_block_sizes)) { + $record = 0x003C; + $length = array_pop($this->_block_sizes); + $header = pack('vv', $record, $length); + if ($continue) { + $header .= pack('C', $encoding); + } + $this->_append($header); + } + + // If the string (or substr) is small enough we can write it in the + // new CONTINUE block. Else, go through the loop again to write it in + // one or more CONTINUE blocks + // + if ($block_length < $continue_limit) { + $this->_append($string); + $written = $block_length; + } else { + $written = 0; + } + } + } + } +} +?> diff --git a/include/Excel/Worksheet.php b/include/Excel/Worksheet.php new file mode 100644 index 000000000..0c61425c2 --- /dev/null +++ b/include/Excel/Worksheet.php @@ -0,0 +1,3500 @@ + +* +* The majority of this is _NOT_ my code. I simply ported it from the +* PERL Spreadsheet::WriteExcel module. +* +* The author of the Spreadsheet::WriteExcel module is John McNamara +* +* +* I _DO_ maintain this code, and John McNamara has nothing to do with the +* porting of this code to PHP. Any questions directly related to this +* class library should be directed to me. +* +* License Information: +* +* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets +* Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + + +/** +* Class for generating Excel Spreadsheets +* +* @author Xavier Noguer +* @category FileFormats +* @package Spreadsheet_Excel_Writer +*/ + +class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwriter +{ + /** + * Name of the Worksheet + * @var string + */ + var $name; + + /** + * Index for the Worksheet + * @var integer + */ + var $index; + + /** + * Reference to the (default) Format object for URLs + * @var object Format + */ + var $_url_format; + + /** + * Reference to the parser used for parsing formulas + * @var object Format + */ + var $_parser; + + /** + * Filehandle to the temporary file for storing data + * @var resource + */ + var $_filehandle; + + /** + * Boolean indicating if we are using a temporary file for storing data + * @var bool + */ + var $_using_tmpfile; + + /** + * Maximum number of rows for an Excel spreadsheet (BIFF5) + * @var integer + */ + var $_xls_rowmax; + + /** + * Maximum number of columns for an Excel spreadsheet (BIFF5) + * @var integer + */ + var $_xls_colmax; + + /** + * Maximum number of characters for a string (LABEL record in BIFF5) + * @var integer + */ + var $_xls_strmax; + + /** + * First row for the DIMENSIONS record + * @var integer + * @see _storeDimensions() + */ + var $_dim_rowmin; + + /** + * Last row for the DIMENSIONS record + * @var integer + * @see _storeDimensions() + */ + var $_dim_rowmax; + + /** + * First column for the DIMENSIONS record + * @var integer + * @see _storeDimensions() + */ + var $_dim_colmin; + + /** + * Last column for the DIMENSIONS record + * @var integer + * @see _storeDimensions() + */ + var $_dim_colmax; + + /** + * Array containing format information for columns + * @var array + */ + var $_colinfo; + + /** + * Array containing the selected area for the worksheet + * @var array + */ + var $_selection; + + /** + * Array containing the panes for the worksheet + * @var array + */ + var $_panes; + + /** + * The active pane for the worksheet + * @var integer + */ + var $_active_pane; + + /** + * Bit specifying if panes are frozen + * @var integer + */ + var $_frozen; + + /** + * Bit specifying if the worksheet is selected + * @var integer + */ + var $selected; + + /** + * The paper size (for printing) (DOCUMENT!!!) + * @var integer + */ + var $_paper_size; + + /** + * Bit specifying paper orientation (for printing). 0 => landscape, 1 => portrait + * @var integer + */ + var $_orientation; + + /** + * The page header caption + * @var string + */ + var $_header; + + /** + * The page footer caption + * @var string + */ + var $_footer; + + /** + * The horizontal centering value for the page + * @var integer + */ + var $_hcenter; + + /** + * The vertical centering value for the page + * @var integer + */ + var $_vcenter; + + /** + * The margin for the header + * @var float + */ + var $_margin_head; + + /** + * The margin for the footer + * @var float + */ + var $_margin_foot; + + /** + * The left margin for the worksheet in inches + * @var float + */ + var $_margin_left; + + /** + * The right margin for the worksheet in inches + * @var float + */ + var $_margin_right; + + /** + * The top margin for the worksheet in inches + * @var float + */ + var $_margin_top; + + /** + * The bottom margin for the worksheet in inches + * @var float + */ + var $_margin_bottom; + + /** + * First row to reapeat on each printed page + * @var integer + */ + var $title_rowmin; + + /** + * Last row to reapeat on each printed page + * @var integer + */ + var $title_rowmax; + + /** + * First column to reapeat on each printed page + * @var integer + */ + var $title_colmin; + + /** + * First row of the area to print + * @var integer + */ + var $print_rowmin; + + /** + * Last row to of the area to print + * @var integer + */ + var $print_rowmax; + + /** + * First column of the area to print + * @var integer + */ + var $print_colmin; + + /** + * Last column of the area to print + * @var integer + */ + var $print_colmax; + + /** + * Whether to use outline. + * @var integer + */ + var $_outline_on; + + /** + * Auto outline styles. + * @var bool + */ + var $_outline_style; + + /** + * Whether to have outline summary below. + * @var bool + */ + var $_outline_below; + + /** + * Whether to have outline summary at the right. + * @var bool + */ + var $_outline_right; + + /** + * Outline row level. + * @var integer + */ + var $_outline_row_level; + + /** + * Whether to fit to page when printing or not. + * @var bool + */ + var $_fit_page; + + /** + * Number of pages to fit wide + * @var integer + */ + var $_fit_width; + + /** + * Number of pages to fit high + * @var integer + */ + var $_fit_height; + + /** + * Reference to the total number of strings in the workbook + * @var integer + */ + var $_str_total; + + /** + * Reference to the number of unique strings in the workbook + * @var integer + */ + var $_str_unique; + + /** + * Reference to the array containing all the unique strings in the workbook + * @var array + */ + var $_str_table; + + /** + * Merged cell ranges + * @var array + */ + var $_merged_ranges; + + /** + * Charset encoding currently used when calling writeString() + * @var string + */ + var $_input_encoding; + + /** + * Constructor + * + * @param string $name The name of the new worksheet + * @param integer $index The index of the new worksheet + * @param mixed &$activesheet The current activesheet of the workbook we belong to + * @param mixed &$firstsheet The first worksheet in the workbook we belong to + * @param mixed &$url_format The default format for hyperlinks + * @param mixed &$parser The formula parser created for the Workbook + * @access private + */ + function Spreadsheet_Excel_Writer_Worksheet($BIFF_version, $name, + $index, &$activesheet, + &$firstsheet, &$str_total, + &$str_unique, &$str_table, + &$url_format, &$parser) + { + // It needs to call its parent's constructor explicitly + $this->Spreadsheet_Excel_Writer_BIFFwriter(); + $this->_BIFF_version = $BIFF_version; + $rowmax = 65536; // 16384 in Excel 5 + $colmax = 256; + + $this->name = $name; + $this->index = $index; + $this->activesheet = &$activesheet; + $this->firstsheet = &$firstsheet; + $this->_str_total = &$str_total; + $this->_str_unique = &$str_unique; + $this->_str_table = &$str_table; + $this->_url_format = &$url_format; + $this->_parser = &$parser; + + //$this->ext_sheets = array(); + $this->_filehandle = ''; + $this->_using_tmpfile = true; + //$this->fileclosed = 0; + //$this->offset = 0; + $this->_xls_rowmax = $rowmax; + $this->_xls_colmax = $colmax; + $this->_xls_strmax = 255; + $this->_dim_rowmin = $rowmax + 1; + $this->_dim_rowmax = 0; + $this->_dim_colmin = $colmax + 1; + $this->_dim_colmax = 0; + $this->_colinfo = array(); + $this->_selection = array(0,0,0,0); + $this->_panes = array(); + $this->_active_pane = 3; + $this->_frozen = 0; + $this->selected = 0; + + $this->_paper_size = 0x0; + $this->_orientation = 0x1; + $this->_header = ''; + $this->_footer = ''; + $this->_hcenter = 0; + $this->_vcenter = 0; + $this->_margin_head = 0.50; + $this->_margin_foot = 0.50; + $this->_margin_left = 0.75; + $this->_margin_right = 0.75; + $this->_margin_top = 1.00; + $this->_margin_bottom = 1.00; + + $this->title_rowmin = null; + $this->title_rowmax = null; + $this->title_colmin = null; + $this->title_colmax = null; + $this->print_rowmin = null; + $this->print_rowmax = null; + $this->print_colmin = null; + $this->print_colmax = null; + + $this->_print_gridlines = 1; + $this->_screen_gridlines = 1; + $this->_print_headers = 0; + + $this->_fit_page = 0; + $this->_fit_width = 0; + $this->_fit_height = 0; + + $this->_hbreaks = array(); + $this->_vbreaks = array(); + + $this->_protect = 0; + $this->_password = null; + + $this->col_sizes = array(); + $this->_row_sizes = array(); + + $this->_zoom = 100; + $this->_print_scale = 100; + + $this->_outline_row_level = 0; + $this->_outline_style = 0; + $this->_outline_below = 1; + $this->_outline_right = 1; + $this->_outline_on = 1; + + $this->_merged_ranges = array(); + + $this->_input_encoding = ''; + + $this->_dv = array(); + + $this->_initialize(); + } + + /** + * Open a tmp file to store the majority of the Worksheet data. If this fails, + * for example due to write permissions, store the data in memory. This can be + * slow for large files. + * + * @access private + */ + function _initialize() + { + // Open tmp file for storing Worksheet data + $fh = tmpfile(); + if ($fh) { + // Store filehandle + $this->_filehandle = $fh; + } else { + // If tmpfile() fails store data in memory + $this->_using_tmpfile = false; + } + } + + /** + * Add data to the beginning of the workbook (note the reverse order) + * and to the end of the workbook. + * + * @access public + * @see Spreadsheet_Excel_Writer_Workbook::storeWorkbook() + * @param array $sheetnames The array of sheetnames from the Workbook this + * worksheet belongs to + */ + function close($sheetnames) + { + $num_sheets = count($sheetnames); + + /*********************************************** + * Prepend in reverse order!! + */ + + // Prepend the sheet dimensions + $this->_storeDimensions(); + + // Prepend the sheet password + $this->_storePassword(); + + // Prepend the sheet protection + $this->_storeProtect(); + + // Prepend the page setup + $this->_storeSetup(); + + /* FIXME: margins are actually appended */ + // Prepend the bottom margin + $this->_storeMarginBottom(); + + // Prepend the top margin + $this->_storeMarginTop(); + + // Prepend the right margin + $this->_storeMarginRight(); + + // Prepend the left margin + $this->_storeMarginLeft(); + + // Prepend the page vertical centering + $this->_storeVcenter(); + + // Prepend the page horizontal centering + $this->_storeHcenter(); + + // Prepend the page footer + $this->_storeFooter(); + + // Prepend the page header + $this->_storeHeader(); + + // Prepend the vertical page breaks + $this->_storeVbreak(); + + // Prepend the horizontal page breaks + $this->_storeHbreak(); + + // Prepend WSBOOL + $this->_storeWsbool(); + + // Prepend GRIDSET + $this->_storeGridset(); + + // Prepend GUTS + if ($this->_BIFF_version == 0x0500) { + $this->_storeGuts(); + } + + // Prepend PRINTGRIDLINES + $this->_storePrintGridlines(); + + // Prepend PRINTHEADERS + $this->_storePrintHeaders(); + + // Prepend EXTERNSHEET references + if ($this->_BIFF_version == 0x0500) { + for ($i = $num_sheets; $i > 0; $i--) { + $sheetname = $sheetnames[$i-1]; + $this->_storeExternsheet($sheetname); + } + } + + // Prepend the EXTERNCOUNT of external references. + if ($this->_BIFF_version == 0x0500) { + $this->_storeExterncount($num_sheets); + } + + // Prepend the COLINFO records if they exist + if (!empty($this->_colinfo)) { + $colcount = count($this->_colinfo); + for ($i = 0; $i < $colcount; $i++) { + $this->_storeColinfo($this->_colinfo[$i]); + } + $this->_storeDefcol(); + } + + // Prepend the BOF record + $this->_storeBof(0x0010); + + /* + * End of prepend. Read upwards from here. + ***********************************************/ + + // Append + $this->_storeWindow2(); + $this->_storeZoom(); + if (!empty($this->_panes)) { + $this->_storePanes($this->_panes); + } + $this->_storeSelection($this->_selection); + $this->_storeMergedCells(); + /* TODO: add data validity */ + /*if ($this->_BIFF_version == 0x0600) { + $this->_storeDataValidity(); + }*/ + $this->_storeEof(); + } + + /** + * Retrieve the worksheet name. + * This is usefull when creating worksheets without a name. + * + * @access public + * @return string The worksheet's name + */ + function getName() + { + return $this->name; + } + + /** + * Retrieves data from memory in one chunk, or from disk in $buffer + * sized chunks. + * + * @return string The data + */ + function getData() + { + $buffer = 4096; + + // Return data stored in memory + if (isset($this->_data)) { + $tmp = $this->_data; + unset($this->_data); + $fh = $this->_filehandle; + if ($this->_using_tmpfile) { + fseek($fh, 0); + } + return $tmp; + } + // Return data stored on disk + if ($this->_using_tmpfile) { + if ($tmp = fread($this->_filehandle, $buffer)) { + return $tmp; + } + } + + // No data to return + return ''; + } + + /** + * Sets a merged cell range + * + * @access public + * @param integer $first_row First row of the area to merge + * @param integer $first_col First column of the area to merge + * @param integer $last_row Last row of the area to merge + * @param integer $last_col Last column of the area to merge + */ + function setMerge($first_row, $first_col, $last_row, $last_col) + { + if (($last_row < $first_row) || ($last_col < $first_col)) { + return; + } + // don't check rowmin, rowmax, etc... because we don't know when this + // is going to be called + $this->_merged_ranges[] = array($first_row, $first_col, $last_row, $last_col); + } + + /** + * Set this worksheet as a selected worksheet, + * i.e. the worksheet has its tab highlighted. + * + * @access public + */ + function select() + { + $this->selected = 1; + } + + /** + * Set this worksheet as the active worksheet, + * i.e. the worksheet that is displayed when the workbook is opened. + * Also set it as selected. + * + * @access public + */ + function activate() + { + $this->selected = 1; + $this->activesheet = $this->index; + } + + /** + * Set this worksheet as the first visible sheet. + * This is necessary when there are a large number of worksheets and the + * activated worksheet is not visible on the screen. + * + * @access public + */ + function setFirstSheet() + { + $this->firstsheet = $this->index; + } + + /** + * Set the worksheet protection flag + * to prevent accidental modification and to + * hide formulas if the locked and hidden format properties have been set. + * + * @access public + * @param string $password The password to use for protecting the sheet. + */ + function protect($password) + { + $this->_protect = 1; + $this->_password = $this->_encodePassword($password); + } + + /** + * Set the width of a single column or a range of columns. + * + * @access public + * @param integer $firstcol first column on the range + * @param integer $lastcol last column on the range + * @param integer $width width to set + * @param mixed $format The optional XF format to apply to the columns + * @param integer $hidden The optional hidden atribute + * @param integer $level The optional outline level + */ + function setColumn($firstcol, $lastcol, $width, $format = 0, $hidden = 0, $level = 0) + { + $this->_colinfo[] = array($firstcol, $lastcol, $width, &$format, $hidden, $level); + + // Set width to zero if column is hidden + $width = ($hidden) ? 0 : $width; + + for ($col = $firstcol; $col <= $lastcol; $col++) { + $this->col_sizes[$col] = $width; + } + } + + /** + * Set which cell or cells are selected in a worksheet + * + * @access public + * @param integer $first_row first row in the selected quadrant + * @param integer $first_column first column in the selected quadrant + * @param integer $last_row last row in the selected quadrant + * @param integer $last_column last column in the selected quadrant + */ + function setSelection($first_row,$first_column,$last_row,$last_column) + { + $this->_selection = array($first_row,$first_column,$last_row,$last_column); + } + + /** + * Set panes and mark them as frozen. + * + * @access public + * @param array $panes This is the only parameter received and is composed of the following: + * 0 => Vertical split position, + * 1 => Horizontal split position + * 2 => Top row visible + * 3 => Leftmost column visible + * 4 => Active pane + */ + function freezePanes($panes) + { + $this->_frozen = 1; + $this->_panes = $panes; + } + + /** + * Set panes and mark them as unfrozen. + * + * @access public + * @param array $panes This is the only parameter received and is composed of the following: + * 0 => Vertical split position, + * 1 => Horizontal split position + * 2 => Top row visible + * 3 => Leftmost column visible + * 4 => Active pane + */ + function thawPanes($panes) + { + $this->_frozen = 0; + $this->_panes = $panes; + } + + /** + * Set the page orientation as portrait. + * + * @access public + */ + function setPortrait() + { + $this->_orientation = 1; + } + + /** + * Set the page orientation as landscape. + * + * @access public + */ + function setLandscape() + { + $this->_orientation = 0; + } + + /** + * Set the paper type. Ex. 1 = US Letter, 9 = A4 + * + * @access public + * @param integer $size The type of paper size to use + */ + function setPaper($size = 0) + { + $this->_paper_size = $size; + } + + + /** + * Set the page header caption and optional margin. + * + * @access public + * @param string $string The header text + * @param float $margin optional head margin in inches. + */ + function setHeader($string,$margin = 0.50) + { + if (strlen($string) >= 255) { + //carp 'Header string must be less than 255 characters'; + return; + } + $this->_header = $string; + $this->_margin_head = $margin; + } + + /** + * Set the page footer caption and optional margin. + * + * @access public + * @param string $string The footer text + * @param float $margin optional foot margin in inches. + */ + function setFooter($string,$margin = 0.50) + { + if (strlen($string) >= 255) { + //carp 'Footer string must be less than 255 characters'; + return; + } + $this->_footer = $string; + $this->_margin_foot = $margin; + } + + /** + * Center the page horinzontally. + * + * @access public + * @param integer $center the optional value for centering. Defaults to 1 (center). + */ + function centerHorizontally($center = 1) + { + $this->_hcenter = $center; + } + + /** + * Center the page vertically. + * + * @access public + * @param integer $center the optional value for centering. Defaults to 1 (center). + */ + function centerVertically($center = 1) + { + $this->_vcenter = $center; + } + + /** + * Set all the page margins to the same value in inches. + * + * @access public + * @param float $margin The margin to set in inches + */ + function setMargins($margin) + { + $this->setMarginLeft($margin); + $this->setMarginRight($margin); + $this->setMarginTop($margin); + $this->setMarginBottom($margin); + } + + /** + * Set the left and right margins to the same value in inches. + * + * @access public + * @param float $margin The margin to set in inches + */ + function setMargins_LR($margin) + { + $this->setMarginLeft($margin); + $this->setMarginRight($margin); + } + + /** + * Set the top and bottom margins to the same value in inches. + * + * @access public + * @param float $margin The margin to set in inches + */ + function setMargins_TB($margin) + { + $this->setMarginTop($margin); + $this->setMarginBottom($margin); + } + + /** + * Set the left margin in inches. + * + * @access public + * @param float $margin The margin to set in inches + */ + function setMarginLeft($margin = 0.75) + { + $this->_margin_left = $margin; + } + + /** + * Set the right margin in inches. + * + * @access public + * @param float $margin The margin to set in inches + */ + function setMarginRight($margin = 0.75) + { + $this->_margin_right = $margin; + } + + /** + * Set the top margin in inches. + * + * @access public + * @param float $margin The margin to set in inches + */ + function setMarginTop($margin = 1.00) + { + $this->_margin_top = $margin; + } + + /** + * Set the bottom margin in inches. + * + * @access public + * @param float $margin The margin to set in inches + */ + function setMarginBottom($margin = 1.00) + { + $this->_margin_bottom = $margin; + } + + /** + * Set the rows to repeat at the top of each printed page. + * + * @access public + * @param integer $first_row First row to repeat + * @param integer $last_row Last row to repeat. Optional. + */ + function repeatRows($first_row, $last_row = null) + { + $this->title_rowmin = $first_row; + if (isset($last_row)) { //Second row is optional + $this->title_rowmax = $last_row; + } else { + $this->title_rowmax = $first_row; + } + } + + /** + * Set the columns to repeat at the left hand side of each printed page. + * + * @access public + * @param integer $first_col First column to repeat + * @param integer $last_col Last column to repeat. Optional. + */ + function repeatColumns($first_col, $last_col = null) + { + $this->title_colmin = $first_col; + if (isset($last_col)) { // Second col is optional + $this->title_colmax = $last_col; + } else { + $this->title_colmax = $first_col; + } + } + + /** + * Set the area of each worksheet that will be printed. + * + * @access public + * @param integer $first_row First row of the area to print + * @param integer $first_col First column of the area to print + * @param integer $last_row Last row of the area to print + * @param integer $last_col Last column of the area to print + */ + function printArea($first_row, $first_col, $last_row, $last_col) + { + $this->print_rowmin = $first_row; + $this->print_colmin = $first_col; + $this->print_rowmax = $last_row; + $this->print_colmax = $last_col; + } + + + /** + * Set the option to hide gridlines on the printed page. + * + * @access public + */ + function hideGridlines() + { + $this->_print_gridlines = 0; + } + + /** + * Set the option to hide gridlines on the worksheet (as seen on the screen). + * + * @access public + */ + function hideScreenGridlines() + { + $this->_screen_gridlines = 0; + } + + /** + * Set the option to print the row and column headers on the printed page. + * + * @access public + * @param integer $print Whether to print the headers or not. Defaults to 1 (print). + */ + function printRowColHeaders($print = 1) + { + $this->_print_headers = $print; + } + + /** + * Set the vertical and horizontal number of pages that will define the maximum area printed. + * It doesn't seem to work with OpenOffice. + * + * @access public + * @param integer $width Maximun width of printed area in pages + * @param integer $height Maximun heigth of printed area in pages + * @see setPrintScale() + */ + function fitToPages($width, $height) + { + $this->_fit_page = 1; + $this->_fit_width = $width; + $this->_fit_height = $height; + } + + /** + * Store the horizontal page breaks on a worksheet (for printing). + * The breaks represent the row after which the break is inserted. + * + * @access public + * @param array $breaks Array containing the horizontal page breaks + */ + function setHPagebreaks($breaks) + { + foreach ($breaks as $break) { + array_push($this->_hbreaks, $break); + } + } + + /** + * Store the vertical page breaks on a worksheet (for printing). + * The breaks represent the column after which the break is inserted. + * + * @access public + * @param array $breaks Array containing the vertical page breaks + */ + function setVPagebreaks($breaks) + { + foreach ($breaks as $break) { + array_push($this->_vbreaks, $break); + } + } + + + /** + * Set the worksheet zoom factor. + * + * @access public + * @param integer $scale The zoom factor + */ + function setZoom($scale = 100) + { + // Confine the scale to Excel's range + if ($scale < 10 || $scale > 400) { + $this->raiseError("Zoom factor $scale outside range: 10 <= zoom <= 400"); + $scale = 100; + } + + $this->_zoom = floor($scale); + } + + /** + * Set the scale factor for the printed page. + * It turns off the "fit to page" option + * + * @access public + * @param integer $scale The optional scale factor. Defaults to 100 + */ + function setPrintScale($scale = 100) + { + // Confine the scale to Excel's range + if ($scale < 10 || $scale > 400) { + $this->raiseError("Print scale $scale outside range: 10 <= zoom <= 400"); + $scale = 100; + } + + // Turn off "fit to page" option + $this->_fit_page = 0; + + $this->_print_scale = floor($scale); + } + + /** + * Map to the appropriate write method acording to the token recieved. + * + * @access public + * @param integer $row The row of the cell we are writing to + * @param integer $col The column of the cell we are writing to + * @param mixed $token What we are writing + * @param mixed $format The optional format to apply to the cell + */ + function write($row, $col, $token, $format = 0) + { + // Check for a cell reference in A1 notation and substitute row and column + /*if ($_[0] =~ /^\D/) { + @_ = $this->_substituteCellref(@_); + }*/ + + if (preg_match("/^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/", $token)) { + // Match number + return $this->writeNumber($row, $col, $token, $format); + } elseif (preg_match("/^[fh]tt?p:\/\//", $token)) { + // Match http or ftp URL + return $this->writeUrl($row, $col, $token, '', $format); + } elseif (preg_match("/^mailto:/", $token)) { + // Match mailto: + return $this->writeUrl($row, $col, $token, '', $format); + } elseif (preg_match("/^(?:in|ex)ternal:/", $token)) { + // Match internal or external sheet link + return $this->writeUrl($row, $col, $token, '', $format); + } elseif (preg_match("/^=/", $token)) { + // Match formula + return $this->writeFormula($row, $col, $token, $format); + } elseif (preg_match("/^@/", $token)) { + // Match formula + return $this->writeFormula($row, $col, $token, $format); + } elseif ($token == '') { + // Match blank + return $this->writeBlank($row, $col, $format); + } else { + // Default: match string + return $this->writeString($row, $col, $token, $format); + } + } + + /** + * Write an array of values as a row + * + * @access public + * @param integer $row The row we are writing to + * @param integer $col The first col (leftmost col) we are writing to + * @param array $val The array of values to write + * @param mixed $format The optional format to apply to the cell + * @return mixed PEAR_Error on failure + */ + + function writeRow($row, $col, $val, $format = 0) + { + $retval = ''; + if (is_array($val)) { + foreach ($val as $v) { + if (is_array($v)) { + $this->writeCol($row, $col, $v, $format); + } else { + $this->write($row, $col, $v, $format); + } + $col++; + } + } else { + $retval = new PEAR_Error('$val needs to be an array'); + } + return($retval); + } + + /** + * Write an array of values as a column + * + * @access public + * @param integer $row The first row (uppermost row) we are writing to + * @param integer $col The col we are writing to + * @param array $val The array of values to write + * @param mixed $format The optional format to apply to the cell + * @return mixed PEAR_Error on failure + */ + + function writeCol($row, $col, $val, $format=0) + { + $retval = ''; + if (is_array($val)) { + foreach ($val as $v) { + $this->write($row, $col, $v, $format); + $row++; + } + } else { + $retval = new PEAR_Error('$val needs to be an array'); + } + return($retval); + } + + /** + * Returns an index to the XF record in the workbook + * + * @access private + * @param mixed &$format The optional XF format + * @return integer The XF record index + */ + function _XF(&$format) + { + if ($format != 0) { + return($format->getXfIndex()); + } else { + return(0x0F); + } + } + + + /****************************************************************************** + ******************************************************************************* + * + * Internal methods + */ + + + /** + * Store Worksheet data in memory using the parent's class append() or to a + * temporary file, the default. + * + * @access private + * @param string $data The binary data to append + */ + function _append($data) + { + if ($this->_using_tmpfile) { + // Add CONTINUE records if necessary + if (strlen($data) > $this->_limit) { + $data = $this->_addContinue($data); + } + fwrite($this->_filehandle, $data); + $this->_datasize += strlen($data); + } else { + parent::_append($data); + } + } + + /** + * Substitute an Excel cell reference in A1 notation for zero based row and + * column values in an argument list. + * + * Ex: ("A4", "Hello") is converted to (3, 0, "Hello"). + * + * @access private + * @param string $cell The cell reference. Or range of cells. + * @return array + */ + function _substituteCellref($cell) + { + $cell = strtoupper($cell); + + // Convert a column range: 'A:A' or 'B:G' + if (preg_match("/([A-I]?[A-Z]):([A-I]?[A-Z])/", $cell, $match)) { + list($no_use, $col1) = $this->_cellToRowcol($match[1] .'1'); // Add a dummy row + list($no_use, $col2) = $this->_cellToRowcol($match[2] .'1'); // Add a dummy row + return(array($col1, $col2)); + } + + // Convert a cell range: 'A1:B7' + if (preg_match("/\$?([A-I]?[A-Z]\$?\d+):\$?([A-I]?[A-Z]\$?\d+)/", $cell, $match)) { + list($row1, $col1) = $this->_cellToRowcol($match[1]); + list($row2, $col2) = $this->_cellToRowcol($match[2]); + return(array($row1, $col1, $row2, $col2)); + } + + // Convert a cell reference: 'A1' or 'AD2000' + if (preg_match("/\$?([A-I]?[A-Z]\$?\d+)/", $cell)) { + list($row1, $col1) = $this->_cellToRowcol($match[1]); + return(array($row1, $col1)); + } + + // TODO use real error codes + $this->raiseError("Unknown cell reference $cell", 0, PEAR_ERROR_DIE); + } + + /** + * Convert an Excel cell reference in A1 notation to a zero based row and column + * reference; converts C1 to (0, 2). + * + * @access private + * @param string $cell The cell reference. + * @return array containing (row, column) + */ + function _cellToRowcol($cell) + { + preg_match("/\$?([A-I]?[A-Z])\$?(\d+)/",$cell,$match); + $col = $match[1]; + $row = $match[2]; + + // Convert base26 column string to number + $chars = split('', $col); + $expn = 0; + $col = 0; + + while ($chars) { + $char = array_pop($chars); // LS char first + $col += (ord($char) -ord('A') +1) * pow(26,$expn); + $expn++; + } + + // Convert 1-index to zero-index + $row--; + $col--; + + return(array($row, $col)); + } + + /** + * Based on the algorithm provided by Daniel Rentz of OpenOffice. + * + * @access private + * @param string $plaintext The password to be encoded in plaintext. + * @return string The encoded password + */ + function _encodePassword($plaintext) + { + $password = 0x0000; + $i = 1; // char position + + // split the plain text password in its component characters + $chars = preg_split('//', $plaintext, -1, PREG_SPLIT_NO_EMPTY); + foreach ($chars as $char) { + $value = ord($char) << $i; // shifted ASCII value + $rotated_bits = $value >> 15; // rotated bits beyond bit 15 + $value &= 0x7fff; // first 15 bits + $password ^= ($value | $rotated_bits); + $i++; + } + + $password ^= strlen($plaintext); + $password ^= 0xCE4B; + + return($password); + } + + /** + * This method sets the properties for outlining and grouping. The defaults + * correspond to Excel's defaults. + * + * @param bool $visible + * @param bool $symbols_below + * @param bool $symbols_right + * @param bool $auto_style + */ + function setOutline($visible = true, $symbols_below = true, $symbols_right = true, $auto_style = false) + { + $this->_outline_on = $visible; + $this->_outline_below = $symbols_below; + $this->_outline_right = $symbols_right; + $this->_outline_style = $auto_style; + + // Ensure this is a boolean vale for Window2 + if ($this->_outline_on) { + $this->_outline_on = 1; + } + } + + /****************************************************************************** + ******************************************************************************* + * + * BIFF RECORDS + */ + + + /** + * Write a double to the specified row and column (zero indexed). + * An integer can be written as a double. Excel will display an + * integer. $format is optional. + * + * Returns 0 : normal termination + * -2 : row or column out of range + * + * @access public + * @param integer $row Zero indexed row + * @param integer $col Zero indexed column + * @param float $num The number to write + * @param mixed $format The optional XF format + * @return integer + */ + function writeNumber($row, $col, $num, $format = 0) + { + $record = 0x0203; // Record identifier + $length = 0x000E; // Number of bytes to follow + + $xf = $this->_XF($format); // The cell format + + // Check that row and col are valid and store max and min values + if ($row >= $this->_xls_rowmax) { + return(-2); + } + if ($col >= $this->_xls_colmax) { + return(-2); + } + if ($row < $this->_dim_rowmin) { + $this->_dim_rowmin = $row; + } + if ($row > $this->_dim_rowmax) { + $this->_dim_rowmax = $row; + } + if ($col < $this->_dim_colmin) { + $this->_dim_colmin = $col; + } + if ($col > $this->_dim_colmax) { + $this->_dim_colmax = $col; + } + + $header = pack("vv", $record, $length); + $data = pack("vvv", $row, $col, $xf); + $xl_double = pack("d", $num); + if ($this->_byte_order) { // if it's Big Endian + $xl_double = strrev($xl_double); + } + + $this->_append($header.$data.$xl_double); + return(0); + } + + /** + * Write a string to the specified row and column (zero indexed). + * NOTE: there is an Excel 5 defined limit of 255 characters. + * $format is optional. + * Returns 0 : normal termination + * -2 : row or column out of range + * -3 : long string truncated to 255 chars + * + * @access public + * @param integer $row Zero indexed row + * @param integer $col Zero indexed column + * @param string $str The string to write + * @param mixed $format The XF format for the cell + * @return integer + */ + function writeString($row, $col, $str, $format = 0) + { + if ($this->_BIFF_version == 0x0600) { + return $this->writeStringBIFF8($row, $col, $str, $format); + } + $strlen = strlen($str); + $record = 0x0204; // Record identifier + $length = 0x0008 + $strlen; // Bytes to follow + $xf = $this->_XF($format); // The cell format + + $str_error = 0; + + // Check that row and col are valid and store max and min values + if ($row >= $this->_xls_rowmax) { + return(-2); + } + if ($col >= $this->_xls_colmax) { + return(-2); + } + if ($row < $this->_dim_rowmin) { + $this->_dim_rowmin = $row; + } + if ($row > $this->_dim_rowmax) { + $this->_dim_rowmax = $row; + } + if ($col < $this->_dim_colmin) { + $this->_dim_colmin = $col; + } + if ($col > $this->_dim_colmax) { + $this->_dim_colmax = $col; + } + + if ($strlen > $this->_xls_strmax) { // LABEL must be < 255 chars + $str = substr($str, 0, $this->_xls_strmax); + $length = 0x0008 + $this->_xls_strmax; + $strlen = $this->_xls_strmax; + $str_error = -3; + } + + $header = pack("vv", $record, $length); + $data = pack("vvvv", $row, $col, $xf, $strlen); + $this->_append($header . $data . $str); + return($str_error); + } + + /** + * Sets Input Encoding for writing strings + * + * @access public + * @param string $encoding The encoding. Ex: 'UTF-16LE', 'utf-8', 'ISO-859-7' + */ + function setInputEncoding($encoding) + { + if ($encoding != 'UTF-16LE' && !function_exists('iconv')) { + $this->raiseError("Using an input encoding other than UTF-16LE requires PHP support for iconv"); + } + $this->_input_encoding = $encoding; + } + + /** + * Write a string to the specified row and column (zero indexed). + * This is the BIFF8 version (no 255 chars limit). + * $format is optional. + * Returns 0 : normal termination + * -2 : row or column out of range + * -3 : long string truncated to 255 chars + * + * @access public + * @param integer $row Zero indexed row + * @param integer $col Zero indexed column + * @param string $str The string to write + * @param mixed $format The XF format for the cell + * @return integer + */ + function writeStringBIFF8($row, $col, $str, $format = 0) + { + if ($this->_input_encoding == 'UTF-16LE') + { + $strlen = function_exists('mb_strlen') ? mb_strlen($str, 'UTF-16LE') : (strlen($str) / 2); + $encoding = 0x1; + } + elseif ($this->_input_encoding != '') + { + $str = iconv($this->_input_encoding, 'UTF-16LE', $str); + $strlen = function_exists('mb_strlen') ? mb_strlen($str, 'UTF-16LE') : (strlen($str) / 2); + $encoding = 0x1; + } + else + { + $strlen = strlen($str); + $encoding = 0x0; + } + $record = 0x00FD; // Record identifier + $length = 0x000A; // Bytes to follow + $xf = $this->_XF($format); // The cell format + + $str_error = 0; + + // Check that row and col are valid and store max and min values + if ($this->_checkRowCol($row, $col) == false) { + return -2; + } + + $str = pack('vC', $strlen, $encoding).$str; + + /* check if string is already present */ + if (!isset($this->_str_table[$str])) { + $this->_str_table[$str] = $this->_str_unique++; + } + $this->_str_total++; + + $header = pack('vv', $record, $length); + $data = pack('vvvV', $row, $col, $xf, $this->_str_table[$str]); + $this->_append($header.$data); + return $str_error; + } + + /** + * Check row and col before writing to a cell, and update the sheet's + * dimensions accordingly + * + * @access private + * @param integer $row Zero indexed row + * @param integer $col Zero indexed column + * @return boolean true for success, false if row and/or col are grester + * then maximums allowed. + */ + function _checkRowCol($row, $col) + { + if ($row >= $this->_xls_rowmax) { + return false; + } + if ($col >= $this->_xls_colmax) { + return false; + } + if ($row < $this->_dim_rowmin) { + $this->_dim_rowmin = $row; + } + if ($row > $this->_dim_rowmax) { + $this->_dim_rowmax = $row; + } + if ($col < $this->_dim_colmin) { + $this->_dim_colmin = $col; + } + if ($col > $this->_dim_colmax) { + $this->_dim_colmax = $col; + } + return true; + } + + /** + * Writes a note associated with the cell given by the row and column. + * NOTE records don't have a length limit. + * + * @access public + * @param integer $row Zero indexed row + * @param integer $col Zero indexed column + * @param string $note The note to write + */ + function writeNote($row, $col, $note) + { + $note_length = strlen($note); + $record = 0x001C; // Record identifier + $max_length = 2048; // Maximun length for a NOTE record + //$length = 0x0006 + $note_length; // Bytes to follow + + // Check that row and col are valid and store max and min values + if ($row >= $this->_xls_rowmax) { + return(-2); + } + if ($col >= $this->_xls_colmax) { + return(-2); + } + if ($row < $this->_dim_rowmin) { + $this->_dim_rowmin = $row; + } + if ($row > $this->_dim_rowmax) { + $this->_dim_rowmax = $row; + } + if ($col < $this->_dim_colmin) { + $this->_dim_colmin = $col; + } + if ($col > $this->_dim_colmax) { + $this->_dim_colmax = $col; + } + + // Length for this record is no more than 2048 + 6 + $length = 0x0006 + min($note_length, 2048); + $header = pack("vv", $record, $length); + $data = pack("vvv", $row, $col, $note_length); + $this->_append($header . $data . substr($note, 0, 2048)); + + for ($i = $max_length; $i < $note_length; $i += $max_length) { + $chunk = substr($note, $i, $max_length); + $length = 0x0006 + strlen($chunk); + $header = pack("vv", $record, $length); + $data = pack("vvv", -1, 0, strlen($chunk)); + $this->_append($header.$data.$chunk); + } + return(0); + } + + /** + * Write a blank cell to the specified row and column (zero indexed). + * A blank cell is used to specify formatting without adding a string + * or a number. + * + * A blank cell without a format serves no purpose. Therefore, we don't write + * a BLANK record unless a format is specified. + * + * Returns 0 : normal termination (including no format) + * -1 : insufficient number of arguments + * -2 : row or column out of range + * + * @access public + * @param integer $row Zero indexed row + * @param integer $col Zero indexed column + * @param mixed $format The XF format + */ + function writeBlank($row, $col, $format) + { + // Don't write a blank cell unless it has a format + if ($format == 0) { + return(0); + } + + $record = 0x0201; // Record identifier + $length = 0x0006; // Number of bytes to follow + $xf = $this->_XF($format); // The cell format + + // Check that row and col are valid and store max and min values + if ($row >= $this->_xls_rowmax) { + return(-2); + } + if ($col >= $this->_xls_colmax) { + return(-2); + } + if ($row < $this->_dim_rowmin) { + $this->_dim_rowmin = $row; + } + if ($row > $this->_dim_rowmax) { + $this->_dim_rowmax = $row; + } + if ($col < $this->_dim_colmin) { + $this->_dim_colmin = $col; + } + if ($col > $this->_dim_colmax) { + $this->_dim_colmax = $col; + } + + $header = pack("vv", $record, $length); + $data = pack("vvv", $row, $col, $xf); + $this->_append($header . $data); + return 0; + } + + /** + * Write a formula to the specified row and column (zero indexed). + * The textual representation of the formula is passed to the parser in + * Parser.php which returns a packed binary string. + * + * Returns 0 : normal termination + * -1 : formula errors (bad formula) + * -2 : row or column out of range + * + * @access public + * @param integer $row Zero indexed row + * @param integer $col Zero indexed column + * @param string $formula The formula text string + * @param mixed $format The optional XF format + * @return integer + */ + function writeFormula($row, $col, $formula, $format = 0) + { + $record = 0x0006; // Record identifier + + // Excel normally stores the last calculated value of the formula in $num. + // Clearly we are not in a position to calculate this a priori. Instead + // we set $num to zero and set the option flags in $grbit to ensure + // automatic calculation of the formula when the file is opened. + // + $xf = $this->_XF($format); // The cell format + $num = 0x00; // Current value of formula + $grbit = 0x03; // Option flags + $unknown = 0x0000; // Must be zero + + + // Check that row and col are valid and store max and min values + if ($this->_checkRowCol($row, $col) == false) { + return -2; + } + + // Strip the '=' or '@' sign at the beginning of the formula string + if (preg_match("/^=/", $formula)) { + $formula = preg_replace("/(^=)/", "", $formula); + } elseif (preg_match("/^@/", $formula)) { + $formula = preg_replace("/(^@)/", "", $formula); + } else { + // Error handling + $this->writeString($row, $col, 'Unrecognised character for formula'); + return -1; + } + + // Parse the formula using the parser in Parser.php + $error = $this->_parser->parse($formula); + if ($this->isError($error)) { + $this->writeString($row, $col, $error->getMessage()); + return -1; + } + + $formula = $this->_parser->toReversePolish(); + if ($this->isError($formula)) { + $this->writeString($row, $col, $formula->getMessage()); + return -1; + } + + $formlen = strlen($formula); // Length of the binary string + $length = 0x16 + $formlen; // Length of the record data + + $header = pack("vv", $record, $length); + $data = pack("vvvdvVv", $row, $col, $xf, $num, + $grbit, $unknown, $formlen); + + $this->_append($header . $data . $formula); + return 0; + } + + /** + * Write a hyperlink. + * This is comprised of two elements: the visible label and + * the invisible link. The visible label is the same as the link unless an + * alternative string is specified. The label is written using the + * writeString() method. Therefore the 255 characters string limit applies. + * $string and $format are optional. + * + * The hyperlink can be to a http, ftp, mail, internal sheet (not yet), or external + * directory url. + * + * Returns 0 : normal termination + * -2 : row or column out of range + * -3 : long string truncated to 255 chars + * + * @access public + * @param integer $row Row + * @param integer $col Column + * @param string $url URL string + * @param string $string Alternative label + * @param mixed $format The cell format + * @return integer + */ + function writeUrl($row, $col, $url, $string = '', $format = 0) + { + // Add start row and col to arg list + return($this->_writeUrlRange($row, $col, $row, $col, $url, $string, $format)); + } + + /** + * This is the more general form of writeUrl(). It allows a hyperlink to be + * written to a range of cells. This function also decides the type of hyperlink + * to be written. These are either, Web (http, ftp, mailto), Internal + * (Sheet1!A1) or external ('c:\temp\foo.xls#Sheet1!A1'). + * + * @access private + * @see writeUrl() + * @param integer $row1 Start row + * @param integer $col1 Start column + * @param integer $row2 End row + * @param integer $col2 End column + * @param string $url URL string + * @param string $string Alternative label + * @param mixed $format The cell format + * @return integer + */ + + function _writeUrlRange($row1, $col1, $row2, $col2, $url, $string = '', $format = 0) + { + + // Check for internal/external sheet links or default to web link + if (preg_match('[^internal:]', $url)) { + return($this->_writeUrlInternal($row1, $col1, $row2, $col2, $url, $string, $format)); + } + if (preg_match('[^external:]', $url)) { + return($this->_writeUrlExternal($row1, $col1, $row2, $col2, $url, $string, $format)); + } + return($this->_writeUrlWeb($row1, $col1, $row2, $col2, $url, $string, $format)); + } + + + /** + * Used to write http, ftp and mailto hyperlinks. + * The link type ($options) is 0x03 is the same as absolute dir ref without + * sheet. However it is differentiated by the $unknown2 data stream. + * + * @access private + * @see writeUrl() + * @param integer $row1 Start row + * @param integer $col1 Start column + * @param integer $row2 End row + * @param integer $col2 End column + * @param string $url URL string + * @param string $str Alternative label + * @param mixed $format The cell format + * @return integer + */ + function _writeUrlWeb($row1, $col1, $row2, $col2, $url, $str, $format = 0) + { + $record = 0x01B8; // Record identifier + $length = 0x00000; // Bytes to follow + + if ($format == 0) { + $format = $this->_url_format; + } + + // Write the visible label using the writeString() method. + if ($str == '') { + $str = $url; + } + $str_error = $this->writeString($row1, $col1, $str, $format); + if (($str_error == -2) || ($str_error == -3)) { + return $str_error; + } + + // Pack the undocumented parts of the hyperlink stream + $unknown1 = pack("H*", "D0C9EA79F9BACE118C8200AA004BA90B02000000"); + $unknown2 = pack("H*", "E0C9EA79F9BACE118C8200AA004BA90B"); + + // Pack the option flags + $options = pack("V", 0x03); + + // Convert URL to a null terminated wchar string + $url = join("\0", preg_split("''", $url, -1, PREG_SPLIT_NO_EMPTY)); + $url = $url . "\0\0\0"; + + // Pack the length of the URL + $url_len = pack("V", strlen($url)); + + // Calculate the data length + $length = 0x34 + strlen($url); + + // Pack the header data + $header = pack("vv", $record, $length); + $data = pack("vvvv", $row1, $row2, $col1, $col2); + + // Write the packed data + $this->_append($header . $data . + $unknown1 . $options . + $unknown2 . $url_len . $url); + return($str_error); + } + + /** + * Used to write internal reference hyperlinks such as "Sheet1!A1". + * + * @access private + * @see writeUrl() + * @param integer $row1 Start row + * @param integer $col1 Start column + * @param integer $row2 End row + * @param integer $col2 End column + * @param string $url URL string + * @param string $str Alternative label + * @param mixed $format The cell format + * @return integer + */ + function _writeUrlInternal($row1, $col1, $row2, $col2, $url, $str, $format = 0) + { + $record = 0x01B8; // Record identifier + $length = 0x00000; // Bytes to follow + + if ($format == 0) { + $format = $this->_url_format; + } + + // Strip URL type + $url = preg_replace('/^internal:/', '', $url); + + // Write the visible label + if ($str == '') { + $str = $url; + } + $str_error = $this->writeString($row1, $col1, $str, $format); + if (($str_error == -2) || ($str_error == -3)) { + return $str_error; + } + + // Pack the undocumented parts of the hyperlink stream + $unknown1 = pack("H*", "D0C9EA79F9BACE118C8200AA004BA90B02000000"); + + // Pack the option flags + $options = pack("V", 0x08); + + // Convert the URL type and to a null terminated wchar string + $url = join("\0", preg_split("''", $url, -1, PREG_SPLIT_NO_EMPTY)); + $url = $url . "\0\0\0"; + + // Pack the length of the URL as chars (not wchars) + $url_len = pack("V", floor(strlen($url)/2)); + + // Calculate the data length + $length = 0x24 + strlen($url); + + // Pack the header data + $header = pack("vv", $record, $length); + $data = pack("vvvv", $row1, $row2, $col1, $col2); + + // Write the packed data + $this->_append($header . $data . + $unknown1 . $options . + $url_len . $url); + return($str_error); + } + + /** + * Write links to external directory names such as 'c:\foo.xls', + * c:\foo.xls#Sheet1!A1', '../../foo.xls'. and '../../foo.xls#Sheet1!A1'. + * + * Note: Excel writes some relative links with the $dir_long string. We ignore + * these cases for the sake of simpler code. + * + * @access private + * @see writeUrl() + * @param integer $row1 Start row + * @param integer $col1 Start column + * @param integer $row2 End row + * @param integer $col2 End column + * @param string $url URL string + * @param string $str Alternative label + * @param mixed $format The cell format + * @return integer + */ + function _writeUrlExternal($row1, $col1, $row2, $col2, $url, $str, $format = 0) + { + // Network drives are different. We will handle them separately + // MS/Novell network drives and shares start with \\ + if (preg_match('[^external:\\\\]', $url)) { + return; //($this->_writeUrlExternal_net($row1, $col1, $row2, $col2, $url, $str, $format)); + } + + $record = 0x01B8; // Record identifier + $length = 0x00000; // Bytes to follow + + if ($format == 0) { + $format = $this->_url_format; + } + + // Strip URL type and change Unix dir separator to Dos style (if needed) + // + $url = preg_replace('/^external:/', '', $url); + $url = preg_replace('/\//', "\\", $url); + + // Write the visible label + if ($str == '') { + $str = preg_replace('/\#/', ' - ', $url); + } + $str_error = $this->writeString($row1, $col1, $str, $format); + if (($str_error == -2) or ($str_error == -3)) { + return $str_error; + } + + // Determine if the link is relative or absolute: + // relative if link contains no dir separator, "somefile.xls" + // relative if link starts with up-dir, "..\..\somefile.xls" + // otherwise, absolute + + $absolute = 0x02; // Bit mask + if (!preg_match("/\\\/", $url)) { + $absolute = 0x00; + } + if (preg_match("/^\.\.\\\/", $url)) { + $absolute = 0x00; + } + $link_type = 0x01 | $absolute; + + // Determine if the link contains a sheet reference and change some of the + // parameters accordingly. + // Split the dir name and sheet name (if it exists) + /*if (preg_match("/\#/", $url)) { + list($dir_long, $sheet) = split("\#", $url); + } else { + $dir_long = $url; + } + + if (isset($sheet)) { + $link_type |= 0x08; + $sheet_len = pack("V", strlen($sheet) + 0x01); + $sheet = join("\0", split('', $sheet)); + $sheet .= "\0\0\0"; + } else { + $sheet_len = ''; + $sheet = ''; + }*/ + $dir_long = $url; + if (preg_match("/\#/", $url)) { + $link_type |= 0x08; + } + + + + // Pack the link type + $link_type = pack("V", $link_type); + + // Calculate the up-level dir count e.g.. (..\..\..\ == 3) + $up_count = preg_match_all("/\.\.\\\/", $dir_long, $useless); + $up_count = pack("v", $up_count); + + // Store the short dos dir name (null terminated) + $dir_short = preg_replace("/\.\.\\\/", '', $dir_long) . "\0"; + + // Store the long dir name as a wchar string (non-null terminated) + //$dir_long = join("\0", split('', $dir_long)); + $dir_long = $dir_long . "\0"; + + // Pack the lengths of the dir strings + $dir_short_len = pack("V", strlen($dir_short) ); + $dir_long_len = pack("V", strlen($dir_long) ); + $stream_len = pack("V", 0);//strlen($dir_long) + 0x06); + + // Pack the undocumented parts of the hyperlink stream + $unknown1 = pack("H*",'D0C9EA79F9BACE118C8200AA004BA90B02000000' ); + $unknown2 = pack("H*",'0303000000000000C000000000000046' ); + $unknown3 = pack("H*",'FFFFADDE000000000000000000000000000000000000000'); + $unknown4 = pack("v", 0x03 ); + + // Pack the main data stream + $data = pack("vvvv", $row1, $row2, $col1, $col2) . + $unknown1 . + $link_type . + $unknown2 . + $up_count . + $dir_short_len. + $dir_short . + $unknown3 . + $stream_len ;/*. + $dir_long_len . + $unknown4 . + $dir_long . + $sheet_len . + $sheet ;*/ + + // Pack the header data + $length = strlen($data); + $header = pack("vv", $record, $length); + + // Write the packed data + $this->_append($header. $data); + return($str_error); + } + + + /** + * This method is used to set the height and format for a row. + * + * @access public + * @param integer $row The row to set + * @param integer $height Height we are giving to the row. + * Use null to set XF without setting height + * @param mixed $format XF format we are giving to the row + * @param bool $hidden The optional hidden attribute + * @param integer $level The optional outline level for row, in range [0,7] + */ + function setRow($row, $height, $format = 0, $hidden = false, $level = 0) + { + $record = 0x0208; // Record identifier + $length = 0x0010; // Number of bytes to follow + + $colMic = 0x0000; // First defined column + $colMac = 0x0000; // Last defined column + $irwMac = 0x0000; // Used by Excel to optimise loading + $reserved = 0x0000; // Reserved + $grbit = 0x0000; // Option flags + $ixfe = $this->_XF($format); // XF index + + // set _row_sizes so _sizeRow() can use it + $this->_row_sizes[$row] = $height; + + // Use setRow($row, null, $XF) to set XF format without setting height + if ($height != null) { + $miyRw = $height * 20; // row height + } else { + $miyRw = 0xff; // default row height is 256 + } + + $level = max(0, min($level, 7)); // level should be between 0 and 7 + $this->_outline_row_level = max($level, $this->_outline_row_level); + + + // Set the options flags. fUnsynced is used to show that the font and row + // heights are not compatible. This is usually the case for WriteExcel. + // The collapsed flag 0x10 doesn't seem to be used to indicate that a row + // is collapsed. Instead it is used to indicate that the previous row is + // collapsed. The zero height flag, 0x20, is used to collapse a row. + + $grbit |= $level; + if ($hidden) { + $grbit |= 0x0020; + } + $grbit |= 0x0040; // fUnsynced + if ($format) { + $grbit |= 0x0080; + } + $grbit |= 0x0100; + + $header = pack("vv", $record, $length); + $data = pack("vvvvvvvv", $row, $colMic, $colMac, $miyRw, + $irwMac,$reserved, $grbit, $ixfe); + $this->_append($header.$data); + } + + /** + * Writes Excel DIMENSIONS to define the area in which there is data. + * + * @access private + */ + function _storeDimensions() + { + $record = 0x0200; // Record identifier + $row_min = $this->_dim_rowmin; // First row + $row_max = $this->_dim_rowmax + 1; // Last row plus 1 + $col_min = $this->_dim_colmin; // First column + $col_max = $this->_dim_colmax + 1; // Last column plus 1 + $reserved = 0x0000; // Reserved by Excel + + if ($this->_BIFF_version == 0x0500) { + $length = 0x000A; // Number of bytes to follow + $data = pack("vvvvv", $row_min, $row_max, + $col_min, $col_max, $reserved); + } elseif ($this->_BIFF_version == 0x0600) { + $length = 0x000E; + $data = pack("VVvvv", $row_min, $row_max, + $col_min, $col_max, $reserved); + } + $header = pack("vv", $record, $length); + $this->_prepend($header.$data); + } + + /** + * Write BIFF record Window2. + * + * @access private + */ + function _storeWindow2() + { + $record = 0x023E; // Record identifier + if ($this->_BIFF_version == 0x0500) { + $length = 0x000A; // Number of bytes to follow + } elseif ($this->_BIFF_version == 0x0600) { + $length = 0x0012; + } + + $grbit = 0x00B6; // Option flags + $rwTop = 0x0000; // Top row visible in window + $colLeft = 0x0000; // Leftmost column visible in window + + + // The options flags that comprise $grbit + $fDspFmla = 0; // 0 - bit + $fDspGrid = $this->_screen_gridlines; // 1 + $fDspRwCol = 1; // 2 + $fFrozen = $this->_frozen; // 3 + $fDspZeros = 1; // 4 + $fDefaultHdr = 1; // 5 + $fArabic = 0; // 6 + $fDspGuts = $this->_outline_on; // 7 + $fFrozenNoSplit = 0; // 0 - bit + $fSelected = $this->selected; // 1 + $fPaged = 1; // 2 + + $grbit = $fDspFmla; + $grbit |= $fDspGrid << 1; + $grbit |= $fDspRwCol << 2; + $grbit |= $fFrozen << 3; + $grbit |= $fDspZeros << 4; + $grbit |= $fDefaultHdr << 5; + $grbit |= $fArabic << 6; + $grbit |= $fDspGuts << 7; + $grbit |= $fFrozenNoSplit << 8; + $grbit |= $fSelected << 9; + $grbit |= $fPaged << 10; + + $header = pack("vv", $record, $length); + $data = pack("vvv", $grbit, $rwTop, $colLeft); + // FIXME !!! + if ($this->_BIFF_version == 0x0500) { + $rgbHdr = 0x00000000; // Row/column heading and gridline color + $data .= pack("V", $rgbHdr); + } elseif ($this->_BIFF_version == 0x0600) { + $rgbHdr = 0x0040; // Row/column heading and gridline color index + $zoom_factor_page_break = 0x0000; + $zoom_factor_normal = 0x0000; + $data .= pack("vvvvV", $rgbHdr, 0x0000, $zoom_factor_page_break, $zoom_factor_normal, 0x00000000); + } + $this->_append($header.$data); + } + + /** + * Write BIFF record DEFCOLWIDTH if COLINFO records are in use. + * + * @access private + */ + function _storeDefcol() + { + $record = 0x0055; // Record identifier + $length = 0x0002; // Number of bytes to follow + $colwidth = 0x0008; // Default column width + + $header = pack("vv", $record, $length); + $data = pack("v", $colwidth); + $this->_prepend($header . $data); + } + + /** + * Write BIFF record COLINFO to define column widths + * + * Note: The SDK says the record length is 0x0B but Excel writes a 0x0C + * length record. + * + * @access private + * @param array $col_array This is the only parameter received and is composed of the following: + * 0 => First formatted column, + * 1 => Last formatted column, + * 2 => Col width (8.43 is Excel default), + * 3 => The optional XF format of the column, + * 4 => Option flags. + * 5 => Optional outline level + */ + function _storeColinfo($col_array) + { + if (isset($col_array[0])) { + $colFirst = $col_array[0]; + } + if (isset($col_array[1])) { + $colLast = $col_array[1]; + } + if (isset($col_array[2])) { + $coldx = $col_array[2]; + } else { + $coldx = 8.43; + } + if (isset($col_array[3])) { + $format = $col_array[3]; + } else { + $format = 0; + } + if (isset($col_array[4])) { + $grbit = $col_array[4]; + } else { + $grbit = 0; + } + if (isset($col_array[5])) { + $level = $col_array[5]; + } else { + $level = 0; + } + $record = 0x007D; // Record identifier + $length = 0x000B; // Number of bytes to follow + + $coldx += 0.72; // Fudge. Excel subtracts 0.72 !? + $coldx *= 256; // Convert to units of 1/256 of a char + + $ixfe = $this->_XF($format); + $reserved = 0x00; // Reserved + + $level = max(0, min($level, 7)); + $grbit |= $level << 8; + + $header = pack("vv", $record, $length); + $data = pack("vvvvvC", $colFirst, $colLast, $coldx, + $ixfe, $grbit, $reserved); + $this->_prepend($header.$data); + } + + /** + * Write BIFF record SELECTION. + * + * @access private + * @param array $array array containing ($rwFirst,$colFirst,$rwLast,$colLast) + * @see setSelection() + */ + function _storeSelection($array) + { + list($rwFirst,$colFirst,$rwLast,$colLast) = $array; + $record = 0x001D; // Record identifier + $length = 0x000F; // Number of bytes to follow + + $pnn = $this->_active_pane; // Pane position + $rwAct = $rwFirst; // Active row + $colAct = $colFirst; // Active column + $irefAct = 0; // Active cell ref + $cref = 1; // Number of refs + + if (!isset($rwLast)) { + $rwLast = $rwFirst; // Last row in reference + } + if (!isset($colLast)) { + $colLast = $colFirst; // Last col in reference + } + + // Swap last row/col for first row/col as necessary + if ($rwFirst > $rwLast) { + list($rwFirst, $rwLast) = array($rwLast, $rwFirst); + } + + if ($colFirst > $colLast) { + list($colFirst, $colLast) = array($colLast, $colFirst); + } + + $header = pack("vv", $record, $length); + $data = pack("CvvvvvvCC", $pnn, $rwAct, $colAct, + $irefAct, $cref, + $rwFirst, $rwLast, + $colFirst, $colLast); + $this->_append($header . $data); + } + + /** + * Store the MERGEDCELLS record for all ranges of merged cells + * + * @access private + */ + function _storeMergedCells() + { + // if there are no merged cell ranges set, return + if (count($this->_merged_ranges) == 0) { + return; + } + $record = 0x00E5; + $length = 2 + count($this->_merged_ranges) * 8; + + $header = pack('vv', $record, $length); + $data = pack('v', count($this->_merged_ranges)); + foreach ($this->_merged_ranges as $range) { + $data .= pack('vvvv', $range[0], $range[2], $range[1], $range[3]); + } + $this->_append($header . $data); + } + + /** + * Write BIFF record EXTERNCOUNT to indicate the number of external sheet + * references in a worksheet. + * + * Excel only stores references to external sheets that are used in formulas. + * For simplicity we store references to all the sheets in the workbook + * regardless of whether they are used or not. This reduces the overall + * complexity and eliminates the need for a two way dialogue between the formula + * parser the worksheet objects. + * + * @access private + * @param integer $count The number of external sheet references in this worksheet + */ + function _storeExterncount($count) + { + $record = 0x0016; // Record identifier + $length = 0x0002; // Number of bytes to follow + + $header = pack("vv", $record, $length); + $data = pack("v", $count); + $this->_prepend($header . $data); + } + + /** + * Writes the Excel BIFF EXTERNSHEET record. These references are used by + * formulas. A formula references a sheet name via an index. Since we store a + * reference to all of the external worksheets the EXTERNSHEET index is the same + * as the worksheet index. + * + * @access private + * @param string $sheetname The name of a external worksheet + */ + function _storeExternsheet($sheetname) + { + $record = 0x0017; // Record identifier + + // References to the current sheet are encoded differently to references to + // external sheets. + // + if ($this->name == $sheetname) { + $sheetname = ''; + $length = 0x02; // The following 2 bytes + $cch = 1; // The following byte + $rgch = 0x02; // Self reference + } else { + $length = 0x02 + strlen($sheetname); + $cch = strlen($sheetname); + $rgch = 0x03; // Reference to a sheet in the current workbook + } + + $header = pack("vv", $record, $length); + $data = pack("CC", $cch, $rgch); + $this->_prepend($header . $data . $sheetname); + } + + /** + * Writes the Excel BIFF PANE record. + * The panes can either be frozen or thawed (unfrozen). + * Frozen panes are specified in terms of an integer number of rows and columns. + * Thawed panes are specified in terms of Excel's units for rows and columns. + * + * @access private + * @param array $panes This is the only parameter received and is composed of the following: + * 0 => Vertical split position, + * 1 => Horizontal split position + * 2 => Top row visible + * 3 => Leftmost column visible + * 4 => Active pane + */ + function _storePanes($panes) + { + $y = $panes[0]; + $x = $panes[1]; + $rwTop = $panes[2]; + $colLeft = $panes[3]; + if (count($panes) > 4) { // if Active pane was received + $pnnAct = $panes[4]; + } else { + $pnnAct = null; + } + $record = 0x0041; // Record identifier + $length = 0x000A; // Number of bytes to follow + + // Code specific to frozen or thawed panes. + if ($this->_frozen) { + // Set default values for $rwTop and $colLeft + if (!isset($rwTop)) { + $rwTop = $y; + } + if (!isset($colLeft)) { + $colLeft = $x; + } + } else { + // Set default values for $rwTop and $colLeft + if (!isset($rwTop)) { + $rwTop = 0; + } + if (!isset($colLeft)) { + $colLeft = 0; + } + + // Convert Excel's row and column units to the internal units. + // The default row height is 12.75 + // The default column width is 8.43 + // The following slope and intersection values were interpolated. + // + $y = 20*$y + 255; + $x = 113.879*$x + 390; + } + + + // Determine which pane should be active. There is also the undocumented + // option to override this should it be necessary: may be removed later. + // + if (!isset($pnnAct)) { + if ($x != 0 && $y != 0) { + $pnnAct = 0; // Bottom right + } + if ($x != 0 && $y == 0) { + $pnnAct = 1; // Top right + } + if ($x == 0 && $y != 0) { + $pnnAct = 2; // Bottom left + } + if ($x == 0 && $y == 0) { + $pnnAct = 3; // Top left + } + } + + $this->_active_pane = $pnnAct; // Used in _storeSelection + + $header = pack("vv", $record, $length); + $data = pack("vvvvv", $x, $y, $rwTop, $colLeft, $pnnAct); + $this->_append($header . $data); + } + + /** + * Store the page setup SETUP BIFF record. + * + * @access private + */ + function _storeSetup() + { + $record = 0x00A1; // Record identifier + $length = 0x0022; // Number of bytes to follow + + $iPaperSize = $this->_paper_size; // Paper size + $iScale = $this->_print_scale; // Print scaling factor + $iPageStart = 0x01; // Starting page number + $iFitWidth = $this->_fit_width; // Fit to number of pages wide + $iFitHeight = $this->_fit_height; // Fit to number of pages high + $grbit = 0x00; // Option flags + $iRes = 0x0258; // Print resolution + $iVRes = 0x0258; // Vertical print resolution + $numHdr = $this->_margin_head; // Header Margin + $numFtr = $this->_margin_foot; // Footer Margin + $iCopies = 0x01; // Number of copies + + $fLeftToRight = 0x0; // Print over then down + $fLandscape = $this->_orientation; // Page orientation + $fNoPls = 0x0; // Setup not read from printer + $fNoColor = 0x0; // Print black and white + $fDraft = 0x0; // Print draft quality + $fNotes = 0x0; // Print notes + $fNoOrient = 0x0; // Orientation not set + $fUsePage = 0x0; // Use custom starting page + + $grbit = $fLeftToRight; + $grbit |= $fLandscape << 1; + $grbit |= $fNoPls << 2; + $grbit |= $fNoColor << 3; + $grbit |= $fDraft << 4; + $grbit |= $fNotes << 5; + $grbit |= $fNoOrient << 6; + $grbit |= $fUsePage << 7; + + $numHdr = pack("d", $numHdr); + $numFtr = pack("d", $numFtr); + if ($this->_byte_order) { // if it's Big Endian + $numHdr = strrev($numHdr); + $numFtr = strrev($numFtr); + } + + $header = pack("vv", $record, $length); + $data1 = pack("vvvvvvvv", $iPaperSize, + $iScale, + $iPageStart, + $iFitWidth, + $iFitHeight, + $grbit, + $iRes, + $iVRes); + $data2 = $numHdr.$numFtr; + $data3 = pack("v", $iCopies); + $this->_prepend($header . $data1 . $data2 . $data3); + } + + /** + * Store the header caption BIFF record. + * + * @access private + */ + function _storeHeader() + { + $record = 0x0014; // Record identifier + + $str = $this->_header; // header string + $cch = strlen($str); // Length of header string + if ($this->_BIFF_version == 0x0600) { + $encoding = 0x0; // TODO: Unicode support + $length = 3 + $cch; // Bytes to follow + } else { + $length = 1 + $cch; // Bytes to follow + } + + $header = pack("vv", $record, $length); + if ($this->_BIFF_version == 0x0600) { + $data = pack("vC", $cch, $encoding); + } else { + $data = pack("C", $cch); + } + + $this->_prepend($header.$data.$str); + } + + /** + * Store the footer caption BIFF record. + * + * @access private + */ + function _storeFooter() + { + $record = 0x0015; // Record identifier + + $str = $this->_footer; // Footer string + $cch = strlen($str); // Length of footer string + if ($this->_BIFF_version == 0x0600) { + $encoding = 0x0; // TODO: Unicode support + $length = 3 + $cch; // Bytes to follow + } else { + $length = 1 + $cch; + } + + $header = pack("vv", $record, $length); + if ($this->_BIFF_version == 0x0600) { + $data = pack("vC", $cch, $encoding); + } else { + $data = pack("C", $cch); + } + + $this->_prepend($header . $data . $str); + } + + /** + * Store the horizontal centering HCENTER BIFF record. + * + * @access private + */ + function _storeHcenter() + { + $record = 0x0083; // Record identifier + $length = 0x0002; // Bytes to follow + + $fHCenter = $this->_hcenter; // Horizontal centering + + $header = pack("vv", $record, $length); + $data = pack("v", $fHCenter); + + $this->_prepend($header.$data); + } + + /** + * Store the vertical centering VCENTER BIFF record. + * + * @access private + */ + function _storeVcenter() + { + $record = 0x0084; // Record identifier + $length = 0x0002; // Bytes to follow + + $fVCenter = $this->_vcenter; // Horizontal centering + + $header = pack("vv", $record, $length); + $data = pack("v", $fVCenter); + $this->_prepend($header . $data); + } + + /** + * Store the LEFTMARGIN BIFF record. + * + * @access private + */ + function _storeMarginLeft() + { + $record = 0x0026; // Record identifier + $length = 0x0008; // Bytes to follow + + $margin = $this->_margin_left; // Margin in inches + + $header = pack("vv", $record, $length); + $data = pack("d", $margin); + if ($this->_byte_order) { // if it's Big Endian + $data = strrev($data); + } + + $this->_prepend($header . $data); + } + + /** + * Store the RIGHTMARGIN BIFF record. + * + * @access private + */ + function _storeMarginRight() + { + $record = 0x0027; // Record identifier + $length = 0x0008; // Bytes to follow + + $margin = $this->_margin_right; // Margin in inches + + $header = pack("vv", $record, $length); + $data = pack("d", $margin); + if ($this->_byte_order) { // if it's Big Endian + $data = strrev($data); + } + + $this->_prepend($header . $data); + } + + /** + * Store the TOPMARGIN BIFF record. + * + * @access private + */ + function _storeMarginTop() + { + $record = 0x0028; // Record identifier + $length = 0x0008; // Bytes to follow + + $margin = $this->_margin_top; // Margin in inches + + $header = pack("vv", $record, $length); + $data = pack("d", $margin); + if ($this->_byte_order) { // if it's Big Endian + $data = strrev($data); + } + + $this->_prepend($header . $data); + } + + /** + * Store the BOTTOMMARGIN BIFF record. + * + * @access private + */ + function _storeMarginBottom() + { + $record = 0x0029; // Record identifier + $length = 0x0008; // Bytes to follow + + $margin = $this->_margin_bottom; // Margin in inches + + $header = pack("vv", $record, $length); + $data = pack("d", $margin); + if ($this->_byte_order) { // if it's Big Endian + $data = strrev($data); + } + + $this->_prepend($header . $data); + } + + /** + * Merges the area given by its arguments. + * This is an Excel97/2000 method. It is required to perform more complicated + * merging than the normal setAlign('merge'). + * + * @access public + * @param integer $first_row First row of the area to merge + * @param integer $first_col First column of the area to merge + * @param integer $last_row Last row of the area to merge + * @param integer $last_col Last column of the area to merge + */ + function mergeCells($first_row, $first_col, $last_row, $last_col) + { + $record = 0x00E5; // Record identifier + $length = 0x000A; // Bytes to follow + $cref = 1; // Number of refs + + // Swap last row/col for first row/col as necessary + if ($first_row > $last_row) { + list($first_row, $last_row) = array($last_row, $first_row); + } + + if ($first_col > $last_col) { + list($first_col, $last_col) = array($last_col, $first_col); + } + + $header = pack("vv", $record, $length); + $data = pack("vvvvv", $cref, $first_row, $last_row, + $first_col, $last_col); + + $this->_append($header.$data); + } + + /** + * Write the PRINTHEADERS BIFF record. + * + * @access private + */ + function _storePrintHeaders() + { + $record = 0x002a; // Record identifier + $length = 0x0002; // Bytes to follow + + $fPrintRwCol = $this->_print_headers; // Boolean flag + + $header = pack("vv", $record, $length); + $data = pack("v", $fPrintRwCol); + $this->_prepend($header . $data); + } + + /** + * Write the PRINTGRIDLINES BIFF record. Must be used in conjunction with the + * GRIDSET record. + * + * @access private + */ + function _storePrintGridlines() + { + $record = 0x002b; // Record identifier + $length = 0x0002; // Bytes to follow + + $fPrintGrid = $this->_print_gridlines; // Boolean flag + + $header = pack("vv", $record, $length); + $data = pack("v", $fPrintGrid); + $this->_prepend($header . $data); + } + + /** + * Write the GRIDSET BIFF record. Must be used in conjunction with the + * PRINTGRIDLINES record. + * + * @access private + */ + function _storeGridset() + { + $record = 0x0082; // Record identifier + $length = 0x0002; // Bytes to follow + + $fGridSet = !($this->_print_gridlines); // Boolean flag + + $header = pack("vv", $record, $length); + $data = pack("v", $fGridSet); + $this->_prepend($header . $data); + } + + /** + * Write the GUTS BIFF record. This is used to configure the gutter margins + * where Excel outline symbols are displayed. The visibility of the gutters is + * controlled by a flag in WSBOOL. + * + * @see _storeWsbool() + * @access private + */ + function _storeGuts() + { + $record = 0x0080; // Record identifier + $length = 0x0008; // Bytes to follow + + $dxRwGut = 0x0000; // Size of row gutter + $dxColGut = 0x0000; // Size of col gutter + + $row_level = $this->_outline_row_level; + $col_level = 0; + + // Calculate the maximum column outline level. The equivalent calculation + // for the row outline level is carried out in setRow(). + $colcount = count($this->_colinfo); + for ($i = 0; $i < $colcount; $i++) { + // Skip cols without outline level info. + if (count($col_level) >= 6) { + $col_level = max($this->_colinfo[$i][5], $col_level); + } + } + + // Set the limits for the outline levels (0 <= x <= 7). + $col_level = max(0, min($col_level, 7)); + + // The displayed level is one greater than the max outline levels + if ($row_level) { + $row_level++; + } + if ($col_level) { + $col_level++; + } + + $header = pack("vv", $record, $length); + $data = pack("vvvv", $dxRwGut, $dxColGut, $row_level, $col_level); + + $this->_prepend($header.$data); + } + + + /** + * Write the WSBOOL BIFF record, mainly for fit-to-page. Used in conjunction + * with the SETUP record. + * + * @access private + */ + function _storeWsbool() + { + $record = 0x0081; // Record identifier + $length = 0x0002; // Bytes to follow + $grbit = 0x0000; + + // The only option that is of interest is the flag for fit to page. So we + // set all the options in one go. + // + /*if ($this->_fit_page) { + $grbit = 0x05c1; + } else { + $grbit = 0x04c1; + }*/ + // Set the option flags + $grbit |= 0x0001; // Auto page breaks visible + if ($this->_outline_style) { + $grbit |= 0x0020; // Auto outline styles + } + if ($this->_outline_below) { + $grbit |= 0x0040; // Outline summary below + } + if ($this->_outline_right) { + $grbit |= 0x0080; // Outline summary right + } + if ($this->_fit_page) { + $grbit |= 0x0100; // Page setup fit to page + } + if ($this->_outline_on) { + $grbit |= 0x0400; // Outline symbols displayed + } + + $header = pack("vv", $record, $length); + $data = pack("v", $grbit); + $this->_prepend($header . $data); + } + + /** + * Write the HORIZONTALPAGEBREAKS BIFF record. + * + * @access private + */ + function _storeHbreak() + { + // Return if the user hasn't specified pagebreaks + if (empty($this->_hbreaks)) { + return; + } + + // Sort and filter array of page breaks + $breaks = $this->_hbreaks; + sort($breaks, SORT_NUMERIC); + if ($breaks[0] == 0) { // don't use first break if it's 0 + array_shift($breaks); + } + + $record = 0x001b; // Record identifier + $cbrk = count($breaks); // Number of page breaks + if ($this->_BIFF_version == 0x0600) { + $length = 2 + 6*$cbrk; // Bytes to follow + } else { + $length = 2 + 2*$cbrk; // Bytes to follow + } + + $header = pack("vv", $record, $length); + $data = pack("v", $cbrk); + + // Append each page break + foreach ($breaks as $break) { + if ($this->_BIFF_version == 0x0600) { + $data .= pack("vvv", $break, 0x0000, 0x00ff); + } else { + $data .= pack("v", $break); + } + } + + $this->_prepend($header.$data); + } + + + /** + * Write the VERTICALPAGEBREAKS BIFF record. + * + * @access private + */ + function _storeVbreak() + { + // Return if the user hasn't specified pagebreaks + if (empty($this->_vbreaks)) { + return; + } + + // 1000 vertical pagebreaks appears to be an internal Excel 5 limit. + // It is slightly higher in Excel 97/200, approx. 1026 + $breaks = array_slice($this->_vbreaks,0,1000); + + // Sort and filter array of page breaks + sort($breaks, SORT_NUMERIC); + if ($breaks[0] == 0) { // don't use first break if it's 0 + array_shift($breaks); + } + + $record = 0x001a; // Record identifier + $cbrk = count($breaks); // Number of page breaks + if ($this->_BIFF_version == 0x0600) { + $length = 2 + 6*$cbrk; // Bytes to follow + } else { + $length = 2 + 2*$cbrk; // Bytes to follow + } + + $header = pack("vv", $record, $length); + $data = pack("v", $cbrk); + + // Append each page break + foreach ($breaks as $break) { + if ($this->_BIFF_version == 0x0600) { + $data .= pack("vvv", $break, 0x0000, 0xffff); + } else { + $data .= pack("v", $break); + } + } + + $this->_prepend($header . $data); + } + + /** + * Set the Biff PROTECT record to indicate that the worksheet is protected. + * + * @access private + */ + function _storeProtect() + { + // Exit unless sheet protection has been specified + if ($this->_protect == 0) { + return; + } + + $record = 0x0012; // Record identifier + $length = 0x0002; // Bytes to follow + + $fLock = $this->_protect; // Worksheet is protected + + $header = pack("vv", $record, $length); + $data = pack("v", $fLock); + + $this->_prepend($header.$data); + } + + /** + * Write the worksheet PASSWORD record. + * + * @access private + */ + function _storePassword() + { + // Exit unless sheet protection and password have been specified + if (($this->_protect == 0) || (!isset($this->_password))) { + return; + } + + $record = 0x0013; // Record identifier + $length = 0x0002; // Bytes to follow + + $wPassword = $this->_password; // Encoded password + + $header = pack("vv", $record, $length); + $data = pack("v", $wPassword); + + $this->_prepend($header . $data); + } + + + /** + * Insert a 24bit bitmap image in a worksheet. + * + * @access public + * @param integer $row The row we are going to insert the bitmap into + * @param integer $col The column we are going to insert the bitmap into + * @param string $bitmap The bitmap filename + * @param integer $x The horizontal position (offset) of the image inside the cell. + * @param integer $y The vertical position (offset) of the image inside the cell. + * @param integer $scale_x The horizontal scale + * @param integer $scale_y The vertical scale + */ + function insertBitmap($row, $col, $bitmap, $x = 0, $y = 0, $scale_x = 1, $scale_y = 1) + { + $bitmap_array = $this->_processBitmap($bitmap); + if ($this->isError($bitmap_array)) { + $this->writeString($row, $col, $bitmap_array->getMessage()); + return; + } + list($width, $height, $size, $data) = $bitmap_array; //$this->_processBitmap($bitmap); + + // Scale the frame of the image. + $width *= $scale_x; + $height *= $scale_y; + + // Calculate the vertices of the image and write the OBJ record + $this->_positionImage($col, $row, $x, $y, $width, $height); + + // Write the IMDATA record to store the bitmap data + $record = 0x007f; + $length = 8 + $size; + $cf = 0x09; + $env = 0x01; + $lcb = $size; + + $header = pack("vvvvV", $record, $length, $cf, $env, $lcb); + $this->_append($header.$data); + } + + /** + * Calculate the vertices that define the position of the image as required by + * the OBJ record. + * + * +------------+------------+ + * | A | B | + * +-----+------------+------------+ + * | |(x1,y1) | | + * | 1 |(A1)._______|______ | + * | | | | | + * | | | | | + * +-----+----| BITMAP |-----+ + * | | | | | + * | 2 | |______________. | + * | | | (B2)| + * | | | (x2,y2)| + * +---- +------------+------------+ + * + * Example of a bitmap that covers some of the area from cell A1 to cell B2. + * + * Based on the width and height of the bitmap we need to calculate 8 vars: + * $col_start, $row_start, $col_end, $row_end, $x1, $y1, $x2, $y2. + * The width and height of the cells are also variable and have to be taken into + * account. + * The values of $col_start and $row_start are passed in from the calling + * function. The values of $col_end and $row_end are calculated by subtracting + * the width and height of the bitmap from the width and height of the + * underlying cells. + * The vertices are expressed as a percentage of the underlying cell width as + * follows (rhs values are in pixels): + * + * x1 = X / W *1024 + * y1 = Y / H *256 + * x2 = (X-1) / W *1024 + * y2 = (Y-1) / H *256 + * + * Where: X is distance from the left side of the underlying cell + * Y is distance from the top of the underlying cell + * W is the width of the cell + * H is the height of the cell + * + * @access private + * @note the SDK incorrectly states that the height should be expressed as a + * percentage of 1024. + * @param integer $col_start Col containing upper left corner of object + * @param integer $row_start Row containing top left corner of object + * @param integer $x1 Distance to left side of object + * @param integer $y1 Distance to top of object + * @param integer $width Width of image frame + * @param integer $height Height of image frame + */ + function _positionImage($col_start, $row_start, $x1, $y1, $width, $height) + { + // Initialise end cell to the same as the start cell + $col_end = $col_start; // Col containing lower right corner of object + $row_end = $row_start; // Row containing bottom right corner of object + + // Zero the specified offset if greater than the cell dimensions + if ($x1 >= $this->_sizeCol($col_start)) { + $x1 = 0; + } + if ($y1 >= $this->_sizeRow($row_start)) { + $y1 = 0; + } + + $width = $width + $x1 -1; + $height = $height + $y1 -1; + + // Subtract the underlying cell widths to find the end cell of the image + while ($width >= $this->_sizeCol($col_end)) { + $width -= $this->_sizeCol($col_end); + $col_end++; + } + + // Subtract the underlying cell heights to find the end cell of the image + while ($height >= $this->_sizeRow($row_end)) { + $height -= $this->_sizeRow($row_end); + $row_end++; + } + + // Bitmap isn't allowed to start or finish in a hidden cell, i.e. a cell + // with zero eight or width. + // + if ($this->_sizeCol($col_start) == 0) { + return; + } + if ($this->_sizeCol($col_end) == 0) { + return; + } + if ($this->_sizeRow($row_start) == 0) { + return; + } + if ($this->_sizeRow($row_end) == 0) { + return; + } + + // Convert the pixel values to the percentage value expected by Excel + $x1 = $x1 / $this->_sizeCol($col_start) * 1024; + $y1 = $y1 / $this->_sizeRow($row_start) * 256; + $x2 = $width / $this->_sizeCol($col_end) * 1024; // Distance to right side of object + $y2 = $height / $this->_sizeRow($row_end) * 256; // Distance to bottom of object + + $this->_storeObjPicture($col_start, $x1, + $row_start, $y1, + $col_end, $x2, + $row_end, $y2); + } + + /** + * Convert the width of a cell from user's units to pixels. By interpolation + * the relationship is: y = 7x +5. If the width hasn't been set by the user we + * use the default value. If the col is hidden we use a value of zero. + * + * @access private + * @param integer $col The column + * @return integer The width in pixels + */ + function _sizeCol($col) + { + // Look up the cell value to see if it has been changed + if (isset($this->col_sizes[$col])) { + if ($this->col_sizes[$col] == 0) { + return(0); + } else { + return(floor(7 * $this->col_sizes[$col] + 5)); + } + } else { + return(64); + } + } + + /** + * Convert the height of a cell from user's units to pixels. By interpolation + * the relationship is: y = 4/3x. If the height hasn't been set by the user we + * use the default value. If the row is hidden we use a value of zero. (Not + * possible to hide row yet). + * + * @access private + * @param integer $row The row + * @return integer The width in pixels + */ + function _sizeRow($row) + { + // Look up the cell value to see if it has been changed + if (isset($this->_row_sizes[$row])) { + if ($this->_row_sizes[$row] == 0) { + return(0); + } else { + return(floor(4/3 * $this->_row_sizes[$row])); + } + } else { + return(17); + } + } + + /** + * Store the OBJ record that precedes an IMDATA record. This could be generalise + * to support other Excel objects. + * + * @access private + * @param integer $colL Column containing upper left corner of object + * @param integer $dxL Distance from left side of cell + * @param integer $rwT Row containing top left corner of object + * @param integer $dyT Distance from top of cell + * @param integer $colR Column containing lower right corner of object + * @param integer $dxR Distance from right of cell + * @param integer $rwB Row containing bottom right corner of object + * @param integer $dyB Distance from bottom of cell + */ + function _storeObjPicture($colL,$dxL,$rwT,$dyT,$colR,$dxR,$rwB,$dyB) + { + $record = 0x005d; // Record identifier + $length = 0x003c; // Bytes to follow + + $cObj = 0x0001; // Count of objects in file (set to 1) + $OT = 0x0008; // Object type. 8 = Picture + $id = 0x0001; // Object ID + $grbit = 0x0614; // Option flags + + $cbMacro = 0x0000; // Length of FMLA structure + $Reserved1 = 0x0000; // Reserved + $Reserved2 = 0x0000; // Reserved + + $icvBack = 0x09; // Background colour + $icvFore = 0x09; // Foreground colour + $fls = 0x00; // Fill pattern + $fAuto = 0x00; // Automatic fill + $icv = 0x08; // Line colour + $lns = 0xff; // Line style + $lnw = 0x01; // Line weight + $fAutoB = 0x00; // Automatic border + $frs = 0x0000; // Frame style + $cf = 0x0009; // Image format, 9 = bitmap + $Reserved3 = 0x0000; // Reserved + $cbPictFmla = 0x0000; // Length of FMLA structure + $Reserved4 = 0x0000; // Reserved + $grbit2 = 0x0001; // Option flags + $Reserved5 = 0x0000; // Reserved + + + $header = pack("vv", $record, $length); + $data = pack("V", $cObj); + $data .= pack("v", $OT); + $data .= pack("v", $id); + $data .= pack("v", $grbit); + $data .= pack("v", $colL); + $data .= pack("v", $dxL); + $data .= pack("v", $rwT); + $data .= pack("v", $dyT); + $data .= pack("v", $colR); + $data .= pack("v", $dxR); + $data .= pack("v", $rwB); + $data .= pack("v", $dyB); + $data .= pack("v", $cbMacro); + $data .= pack("V", $Reserved1); + $data .= pack("v", $Reserved2); + $data .= pack("C", $icvBack); + $data .= pack("C", $icvFore); + $data .= pack("C", $fls); + $data .= pack("C", $fAuto); + $data .= pack("C", $icv); + $data .= pack("C", $lns); + $data .= pack("C", $lnw); + $data .= pack("C", $fAutoB); + $data .= pack("v", $frs); + $data .= pack("V", $cf); + $data .= pack("v", $Reserved3); + $data .= pack("v", $cbPictFmla); + $data .= pack("v", $Reserved4); + $data .= pack("v", $grbit2); + $data .= pack("V", $Reserved5); + + $this->_append($header . $data); + } + + /** + * Convert a 24 bit bitmap into the modified internal format used by Windows. + * This is described in BITMAPCOREHEADER and BITMAPCOREINFO structures in the + * MSDN library. + * + * @access private + * @param string $bitmap The bitmap to process + * @return array Array with data and properties of the bitmap + */ + function _processBitmap($bitmap) + { + // Open file. + $bmp_fd = @fopen($bitmap,"rb"); + if (!$bmp_fd) { + $this->raiseError("Couldn't import $bitmap"); + } + + // Slurp the file into a string. + $data = fread($bmp_fd, filesize($bitmap)); + + // Check that the file is big enough to be a bitmap. + if (strlen($data) <= 0x36) { + $this->raiseError("$bitmap doesn't contain enough data.\n"); + } + + // The first 2 bytes are used to identify the bitmap. + $identity = unpack("A2ident", $data); + if ($identity['ident'] != "BM") { + $this->raiseError("$bitmap doesn't appear to be a valid bitmap image.\n"); + } + + // Remove bitmap data: ID. + $data = substr($data, 2); + + // Read and remove the bitmap size. This is more reliable than reading + // the data size at offset 0x22. + // + $size_array = unpack("Vsa", substr($data, 0, 4)); + $size = $size_array['sa']; + $data = substr($data, 4); + $size -= 0x36; // Subtract size of bitmap header. + $size += 0x0C; // Add size of BIFF header. + + // Remove bitmap data: reserved, offset, header length. + $data = substr($data, 12); + + // Read and remove the bitmap width and height. Verify the sizes. + $width_and_height = unpack("V2", substr($data, 0, 8)); + $width = $width_and_height[1]; + $height = $width_and_height[2]; + $data = substr($data, 8); + if ($width > 0xFFFF) { + $this->raiseError("$bitmap: largest image width supported is 65k.\n"); + } + if ($height > 0xFFFF) { + $this->raiseError("$bitmap: largest image height supported is 65k.\n"); + } + + // Read and remove the bitmap planes and bpp data. Verify them. + $planes_and_bitcount = unpack("v2", substr($data, 0, 4)); + $data = substr($data, 4); + if ($planes_and_bitcount[2] != 24) { // Bitcount + $this->raiseError("$bitmap isn't a 24bit true color bitmap.\n"); + } + if ($planes_and_bitcount[1] != 1) { + $this->raiseError("$bitmap: only 1 plane supported in bitmap image.\n"); + } + + // Read and remove the bitmap compression. Verify compression. + $compression = unpack("Vcomp", substr($data, 0, 4)); + $data = substr($data, 4); + + //$compression = 0; + if ($compression['comp'] != 0) { + $this->raiseError("$bitmap: compression not supported in bitmap image.\n"); + } + + // Remove bitmap data: data size, hres, vres, colours, imp. colours. + $data = substr($data, 20); + + // Add the BITMAPCOREHEADER data + $header = pack("Vvvvv", 0x000c, $width, $height, 0x01, 0x18); + $data = $header . $data; + + return (array($width, $height, $size, $data)); + } + + /** + * Store the window zoom factor. This should be a reduced fraction but for + * simplicity we will store all fractions with a numerator of 100. + * + * @access private + */ + function _storeZoom() + { + // If scale is 100 we don't need to write a record + if ($this->_zoom == 100) { + return; + } + + $record = 0x00A0; // Record identifier + $length = 0x0004; // Bytes to follow + + $header = pack("vv", $record, $length); + $data = pack("vv", $this->_zoom, 100); + $this->_append($header . $data); + } + + /** + * FIXME: add comments + */ + function setValidation($row1, $col1, $row2, $col2, &$validator) + { + $this->_dv[] = $validator->_getData() . + pack("vvvvv", 1, $row1, $row2, $col1, $col2); + } + + /** + * Store the DVAL and DV records. + * + * @access private + */ + function _storeDataValidity() + { + $record = 0x01b2; // Record identifier + $length = 0x0012; // Bytes to follow + + $grbit = 0x0002; // Prompt box at cell, no cached validity data at DV records + $horPos = 0x00000000; // Horizontal position of prompt box, if fixed position + $verPos = 0x00000000; // Vertical position of prompt box, if fixed position + $objId = 0xffffffff; // Object identifier of drop down arrow object, or -1 if not visible + + $header = pack('vv', $record, $length); + $data = pack('vVVVV', $grbit, $horPos, $verPos, $objId, + count($this->_dv)); + $this->_append($header.$data); + + $record = 0x01be; // Record identifier + foreach ($this->_dv as $dv) { + $length = strlen($dv); // Bytes to follow + $header = pack("vv", $record, $length); + $this->_append($header . $dv); + } + } +} +?> diff --git a/include/Excel/Writer.php b/include/Excel/Writer.php new file mode 100644 index 000000000..4ae1e04d2 --- /dev/null +++ b/include/Excel/Writer.php @@ -0,0 +1,103 @@ + +* +* PERL Spreadsheet::WriteExcel module. +* +* The author of the Spreadsheet::WriteExcel module is John McNamara +* +* +* I _DO_ maintain this code, and John McNamara has nothing to do with the +* porting of this code to PHP. Any questions directly related to this +* class library should be directed to me. +* +* License Information: +* +* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets +* Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library 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 +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + + + +/** +* Class for writing Excel Spreadsheets. This class should change COMPLETELY. +* +* @author Xavier Noguer +* @category FileFormats +* @package Spreadsheet_Excel_Writer +*/ + +class Spreadsheet_Excel_Writer extends Spreadsheet_Excel_Writer_Workbook +{ + /** + * The constructor. It just creates a Workbook + * + * @param string $filename The optional filename for the Workbook. + * @return Spreadsheet_Excel_Writer_Workbook The Workbook created + */ + function Spreadsheet_Excel_Writer($filename = '') + { + $this->_filename = $filename; + $this->Spreadsheet_Excel_Writer_Workbook($filename); + } + + /** + * Send HTTP headers for the Excel file. + * + * @param string $filename The filename to use for HTTP headers + * @access public + */ + function send($filename) + { + header("Content-type: application/vnd.ms-excel"); + header("Content-Disposition: attachment; filename=\"$filename\""); + header("Expires: 0"); + header("Cache-Control: must-revalidate, post-check=0,pre-check=0"); + header("Pragma: public"); + } + + /** + * Utility function for writing formulas + * Converts a cell's coordinates to the A1 format. + * + * @access public + * @static + * @param integer $row Row for the cell to convert (0-indexed). + * @param integer $col Column for the cell to convert (0-indexed). + * @return string The cell identifier in A1 format + */ + function rowcolToCell($row, $col) + { + if ($col > 255) { //maximum column value exceeded + return new PEAR_Error("Maximum column value exceeded: $col"); + } + + $int = (int)($col / 26); + $frac = $col % 26; + $chr1 = ''; + + if ($int > 0) { + $chr1 = chr(ord('A') + $int - 1); + } + + $chr2 = chr(ord('A') + $frac); + $row++; + + return $chr1 . $chr2 . $row; + } +} +?> diff --git a/include/berechtigung.class.php b/include/berechtigung.class.php new file mode 100644 index 000000000..0be0e732d --- /dev/null +++ b/include/berechtigung.class.php @@ -0,0 +1,321 @@ +conn=$conn; + $this->new=true; + } + + + /** + * Ladet die Attribute der Berechtigung aus der Datenbank. Bei Fehler ist der + * Rueckgabewert 'false' und die Fehlermeldung steht in 'errormsg'. + * @return boolean true=ok, false=fehler + */ + function load($id) + { + // Berechtigung holen + $sql_query="SELECT * FROM tbl_userberechtigung WHERE userberechtigung_id=$id"; + //echo $sql_query; + if(!($erg=pg_exec($this->conn, $sql_query))) + { + $this->errormsg=pg_errormessage($this->conn); + return false; + } + $num_rows=pg_numrows($erg); + if($num_rows!=1) + { + $this->errormsg="Zuwenige oder zuviele Ergebnisse (Anzahl: $num_rows)!"; + return false; + } + $row=pg_fetch_object($erg,0); + + $this->userberechtigung_id=$row->userberechtigung_id; + $this->studiengang_kz=$row->studiengang_kz; + $this->fachbereich_id=$row->fachbereich_id; + $this->berechtigung_kurzbz=$row->berechtigung_kurzbz; + $this->uid=$row->uid; + $this->studiensemester_kurzbz=$row->studiensemester_kurzbz; + $this->start=$row->start; + $this->ende=$row->ende; + $this->art=$row->art; + $this->new=false; + return true; + } + + /** + * @return boolean true=ok, false=fehler + */ + function save() + { + // Connection holen + if (is_null($conn=$this->getConnection())) + { + return false; + } + // Daten zur Person speichern + + if (!person::save()) { + $this->errormsg.="Daten zur LVA konnten nicht gespeichert werden."; + return false; + } + if ($this->new) { + $qry="INSERT INTO tbl_lehrveranstaltung(lvnr,unr,einheit_kurzbz,". + "lektor,lehrfach_nr,studiengang_kz,fachbereich_id,semester,verband,". + "gruppe,raumtyp,raumtypalternativ,semesterstunden,stundenblockung,". + "wochenrythmus,start_kw,anmerkung)". + "values(". + "'".$this->lvnr."',". + "'".$this->unr."',". + "'".$this->einheit_kurzbz."',". + "'".$this->lektor."',". + (strlen($this->lehrfach_nr)>0?$this->lehrfach_nr:NULL).",". + (strlen($this->studiengang_kz)>0?$this->studiengang_kz:NULL).",". + (strlen($this->fachbereich_id)>0?$this->fachbereich_id:NULL).",". + (strlen($this->semester)>0?$this->semester:NULL).",". + "'".$this->verband."',". + "'".$this->gruppe."',". + (strlen($this->raumtyp)>0?"'".$this->raumtyp."'":NULL).",". + (strlen($this->raumtypalternativ)>0?"'".$this->raumtypalternativ."'":NULL).",". + (strlen($this->semesterstunden)>0?$this->semesterstunden:NULL).",". + (strlen($this->stundenblockung)>0?$this->stundenblockung:NULL).",". + (strlen($this->wochenrythmus)>0?$this->wochenrythmus:NULL).",". + (strlen($this->start_kw)>0?$this->start_kw:NULL).",". + (strlen($this->anmerkung)>0?"'".$this->anmerkung."'":NULL).",". + ")"; + } else + { + $qry="UPDATE tbl_lehrveranstaltung ". + "SET lvnr='".$this->lvnr."',". + "unr='".$this->unr."',". + "einheit_kurzbz='".$this->einheit_kurzbz."',". + "lektor='".$this->lehrfach_nr."',". + "lehrfach_nr=".(strlen($this->lehrfach_nr)>0?$this->lehrfach_nr:NULL).",". + "studiengang_kz=".(strlen($this->studiengang_kz)>0?$this->studiengang_kz:NULL).",". + "fachbereich_id=".(strlen($this->fachbereich_id)>0?$this->fachbereich_id:NULL).",". + "semester=".(strlen($this->semester)>0?$this->semester:NULL).",". + "verband='".$this->verband."',". + "gruppe='".$this->gruppe."',". + "raumtyp=".(strlen($this->raumtyp)>0?"'".$this->raumtyp."'":NULL).",". + "raumtypalternativ=".(strlen($this->raumtypalternativ)>0?"'".$this->raumtypalternativ."'":NULL).",". + "semesterstunden=".(strlen($this->semesterstunden)>0?$this->semesterstunden:NULL).",". + "stundenblockung=".(strlen($this->stundenblockung)>0?$this->stundenblockung:NULL).",". + "wochenrythmus=".(strlen($this->wochenrythmus)>0?$this->wochenrythmus:NULL).",". + "start_kw=".(strlen($this->start_kw)>0?$this->start_kw:NULL).",". + "anmerkung=".(strlen($this->anmerkung)>0?"'".$this->anmerkung."'":NULL). + " WHERE lehrveranstaltung_id='".$this->lehrveranstaltung_id."'"; + } + //echo "
".$qry; + if(!@pg_query($conn, $qry)) + { + $this->errormsg=pg_errormessage($conn); + return false; + } + return true; + } + + + /** + * Rueckgabewert ist ein Array mit den Ergebnissen. Bei Fehler false und die + * Fehlermeldung liegt in errormsg. + * Wenn der Parameter stg_kz NULL ist tritt einheit_kurzbzb in Kraft. + * @param string $uid UserID + * @return variabel Array mit LVA; false bei Fehler + */ + function getBerechtigungen($uid) + { + // Berechtigungen holen + $sql_query="SELECT * FROM tbl_userberechtigung WHERE uid='$uid' AND (startnow() OR ende IS NULL)"; + //echo $sql_query; + if(!$erg=@pg_query($this->conn, $sql_query)) + { + $this->errormsg=pg_errormessage($this->conn); + return false; + } + //$num_rows=pg_numrows($erg); + while($row=pg_fetch_object($erg)) + { + $b=new berechtigung($this->conn); + $b->userberechtigung_id=$row->userberechtigung_id; + $b->studiengang_kz=$row->studiengang_kz; + $b->fachbereich_id=$row->fachbereich_id; + $b->berechtigung_kurzbz=$row->berechtigung_kurzbz; + $b->uid=$row->uid; + $b->studiensemester_kurzbz=$row->studiensemester_kurzbz; + $b->start=$row->start; + if ($row->start!=null) + $b->starttimestamp=mktime(0,0,0,substr($row->start,5,2),substr($row->start,8),substr($row->start,0,4)); + else + $b->starttimestamp=null; + $b->ende=$row->ende; + if ($row->ende!=null) + $b->endetimestamp=mktime(23,59,59,substr($row->ende,5,2),substr($row->ende,8),substr($row->ende,0,4)); + else + $b->endetimestamp=null; + $b->art=$row->art; + $this->berechtigungen[]=$b; + } + return true; + } + + function isBerechtigt($berechtigung,$studiengang_kz=null,$art=null, $fachbereich_id=null) + { + $timestamp=time(); + foreach ($this->berechtigungen as $b) + { + //Fachbereichsberechtigung + if($fachbereich_id!=null) + { + //Wenn Fachbereichs oder Adminberechtigung + if(($berechtigung == $b->berechtigung_kurzbz || $b->berechtigung_kurzbz == 'admin') && ($b->fachbereich_id==$fachbereich_id || $b->fachbereich_id=='0')) + { + if ($b->starttimestamp!=null && $b->endetimestamp!=null) + { + if ($timestamp>$b->starttimestamp && $timestamp<$b->endetimestamp) + return true; + } + else + return true; + } + } + + //Wenn Berechtigung fuer Bestimmte Klasse vorhanden ist + if($berechtigung == $b->berechtigung_kurzbz && $studiengang_kz==null && $art==null && $fachbereich_id==null) + if ($b->starttimestamp!=null && $b->endetimestamp!=null) + { + if ($timestamp>$b->starttimestamp && $timestamp<$b->endetimestamp) + return true; + } + else + return true; + //Wenn Berechtigung fuer Bestimmten Studiengang vorhanden ist + if ($berechtigung==$b->berechtigung_kurzbz + && ($studiengang_kz==$b->studiengang_kz || $b->studiengang_kz==0) && $art==null && $b->fachbereich_id==null) + if ($b->starttimestamp!=null && $b->endetimestamp!=null) + { + if ($timestamp>$b->starttimestamp && $timestamp<$b->endetimestamp) + return true; + } + else + return true; + //Wenn Berechtigung mit Studiengang und der richtigen BerechtigungsArt (suid) vorhanden ist + if ($berechtigung==$b->berechtigung_kurzbz + && ($studiengang_kz==$b->studiengang_kz || $b->studiengang_kz==0) + && strstr($b->art,$art)) + if ($b->starttimestamp!=null && $b->endetimestamp!=null) + { + if ($timestamp>$b->starttimestamp && $timestamp<$b->endetimestamp) + return true; + } + else + return true; + } + return false; + } + + /** + * Gibt Array mit Kennzahlen der Studiengaenge sortiert zurueck. + * Optional wird auf Berechtigung eingeschraenkt. + * Wenn Berechtigung ueber alle Studiengaenge steht im ersten Feld 0. + */ + function getStgKz($berechtigung=null) + { + $studiengang_kz=array(); + $timestamp=time(); + + foreach ($this->berechtigungen as $b) + if ($berechtigung==$b->berechtigung_kurzbz || $berechtigung==null) + if($b->fachbereich_id==null) + $studiengang_kz[]=$b->studiengang_kz; + $studiengang_kz=array_unique($studiengang_kz); + sort($studiengang_kz); + return $studiengang_kz; + } + + function getFbKz($berechtigung=null) + { + $fachbereichs_kz=array(); + $timestamp=time(); + + foreach($this->berechtigungen as $b) + { + if(($berechtigung==$b->berechtigung_kurzbz || $berechtigung==null) + && (($timestamp>$b->starttimestamp && $timestamp<$b->endetimestamp) || ($b->starttimestamp==null && $b->endetimestamp==null))) + { + if($b->fachbereich_id!='' && !in_array($b->fachbereich_id,$fachbereichs_kz)) + $fachbereichs_kz[] = $b->fachbereich_id; + } + } + sort($fachbereichs_kz); + return $fachbereichs_kz; + } +} +?> \ No newline at end of file diff --git a/include/cis_functions.inc.php b/include/cis_functions.inc.php new file mode 100644 index 000000000..beb74e1d7 --- /dev/null +++ b/include/cis_functions.inc.php @@ -0,0 +1,515 @@ +stg_id; + $term_id = $auth->semester; + + $sql = "SELECT distinct verband, gruppe FROM tbl_student WHERE (studiengang_kz = $course_id) AND (semester = $term_id) ORDER BY verband,gruppe"; + $rs = new pgRS($sql); + $count_verband = $rs->num; + $verbands = $rs->arr; + for ($rt = $count_verband-1; $rt >= 0; $rt--) { + $verband = $verbands[$rt]["verband"] . $verbands[$rt]["gruppe"]; + if ($verbands[$rt]["verband"] == $auth->verband && + $verbands[$rt]["gruppe"] == $auth->gruppe) + return pow(2,$rt); + } + return 0; + } // eof function get_active_status + + //get_lf_bezeichnung holt die Studiengang Bezeichnung und die Lehrfach + // bezeichnung für das aktuelle Lehrfach. + function get_lf_bezeichnung($course_id, $term_id, $lesson) + { + $sql = "SELECT lf.bezeichnung, kurzbzlang FROM lehre.tbl_lehrfachzuteilung lf + JOIN tbl_studiengang USING(studiengang_kz) WHERE lf.studiengang_kz = $course_id + AND lf.lehrfachzuteilung_kurzbz = '$lesson' AND lf.semester = $term_id LIMIT 1"; + $rs = new pgRS($sql); + $ret[0] = $rs->arr[0]["kurzbzlang"]; + $ret[1] = $rs->arr[0]["bezeichnung"]; + + return $ret; + } + + // Die Freigabe für die Verbände für den Studienbrief berechnen + // Um die Freigeschaltenen Studienbriefe zu berechnen. + function sum($points = array()) { + $p = 0; + for ($i = 0; $i < count($points); $i++) + { + $p+= $points[$i]; + } + return $p; + } /* eof sum() */ + + // erstellen des aktuellen studienjahres + function get_studienjahr($i = -1) { + if ($i != -1) { + $stj = date("Y")+$i; + $stj .= "/"; + $stj .= sprintf("%02d", date("y")+$i+1); + } else if ( date("n") >= 7) + $stj = date("Y") . "/" . date("y", mktime(0,0,0,1,1,date("Y")+1)); + else + $stj = date("Y")-1 . "/" . date("y"); + return $stj; + } + + function get_needed_term_id($term_id = 0, $stj = "") { + if ($stj == "") + $stj = get_studienjahr(); + $needed_term_id = $term_id + ((date("Y") - substr($stj,0,4))*2); + + if ((date("n") >= 8 || date("n") < 3)) + if ($term_id%2==0) + $needed_term_id--; + else + $needed_term_id++; + + if ((date("n") < 8 || date("n") >= 3)) + if ($term_id%2!= 0) + $needed_term_id--; + return $needed_term_id; + } + + + // berechnet die notwendige Semester_ID zum Anzeigen der + // Studenten im Kreuzerltool + function get_needed_term_id2($term_id = 0, $stj = "") { + // im WS sollen noch Studenten vom letzten SS sichtbar sein + if ((date("n") >= 8 || date("n") < 2)) { + if ($term_id%2==0) + $term_id++; + } + // im SS sollen noch die Studenten vom WS sichtbar sein + else { + if ($term_id%2==1) { + $term_id++; + } + } + return $term_id; + } + + + // zurückrechnen auf die studenten im jetzigen semester + // studienpunkte sind nur für die eigene person sichtbar + function get_old_studienjahr() { + if (date("n") >= 7 && $term_id%2 == 1) { + $studienjahr = date("Y") - intval(($auth->semester - $term_id)/2); + } + else if (date("n") >= 7 && $term_id%2 == 0) { + $studienjahr = date("Y") - intval(($auth->semester - $term_id)/2)-1; + } + else if (date("n") < 7 && $term_id%2 == 1) { + $studienjahr = date("Y") - intval(($auth->semester - $term_id)/2); + } + else { + $studienjahr = date("Y") - intval(($auth->semester - $term_id)/2); + } + + $studienjahr .= "/" . date("y", mktime(0,0,0,1,1,$studienjahr+1)); + } + // write out the menu for kreuzerltool (campus/lehre/effort + function write_menu($menu, $course_id, $lesson, $term_id, $module = "", $stj = 0) { + if ($stj == 0) + $stj = get_studienjahr(); + print " +
+ + + +
+ + + + + + + + + + + + + + + + + +
+
  • Kreuzerlliste Statistik
  • +
    +
  • Anwesenheits- + und
       Übersichtstabelle
  • +
  • Kreuzerllisten anlegen
       und verwalten
  • +
  • Studentenpunkte
        verwalten
  •  
      + $menuStudienjahr:
     
    + +
    + +EOF; + } + + + + /** + * @params inputString - the String to be formatted + * @return the formatted String + */ + function format($inputString) { + $inputString = stripslashes($inputString); + return str_replace("\n", "
    ",$inputString); + } + + + function get_lectors($course_id, $term_id, $short) { + if ($course_id && $term_id && $short) { + $sql = "SELECT DISTINCT on (bezeichnung,nachname) bezeichnung, studiengang_kz, semester, vornamen, nachname, email, uid FROM lehre.tbl_lehrfachzuteilung JOIN tbl_person ON uid = lektor_uid WHERE studiengang_kz='$course_id' AND semester='$term_id' AND lehrfachzuteilung_kurzbz = '$short' AND tbl_person.aktiv=TRUE ORDER BY bezeichnung, nachname"; + //$sql_query = "SELECT DISTINCT ON(uid), vornamen, nachname, + // titel FROM lehre.tbl_lehrfachzuteilung, tbl_person, + //tbl_mitarbeiter WHERE tbl_person.uid = + //lehre.tbl_lehrfachzuteilung.lektor_uid AND + //lehre.tbl_lehrfachzuteilung.studiengang_kz='$course_id' + //AND lehre.tbl_lehrfachzuteilung.semester='$term_id' + //AND LOWER(lehre.tbl_lehrfachzuteilung.lehrfachzuteilung_kurzbz)='$short' + //AND lehre.tbl_lehrfachzuteilung.aktiv = true + //ORDER BY nachname"; + + $result_lectors = new pgRS($sql); + } + $num_rows_lectors = $result_lectors->num; + $row_email = array(); + $row_vornamen = array(); + $row_nachname = array(); + $row_titel = array(); + for($i = 0; $i < $num_rows_lectors; $i++) + { + $row_email[] = $result_lectors->arr[$i]["emailtw"]; + $row_vornamen[] = $result_lectors->arr[$i]["vornamen"]; + $row_nachname[] = $result_lectors->arr[$i]["nachname"]; + $row_titel[] = $result_lectors->arr[$i]["titel"]; + + } + $ret = ""; + for ($i = 0; $i < count($row_email); $i++) + { + $ret .= "$row_titel[$i] $row_vornamen[$i] $row_nachname[$i]"; + if ($i < count($row_email)-1) + $ret .= ", "; + } + return $ret; + } + + function get_person($bezeichnung, $course_id) { + $sql = "SELECT titel, vornamen, nachname, bezeichnung FROM tbl_funktion, public.tbl_person JOIN tbl_personfunktion ON (tbl_personfunktion.uid = tbl_person.uid) WHERE tbl_personfunktion.funktion_kurzbz = tbl_funktion.funktion_kurzbz AND bezeichnung='$bezeichnung' AND tbl_personfunktion.studiengang_kz='$course_id'"; + $rs = new pgRS($sql); + $arr = $rs->arr[0]; + $ret = $arr["titel"]." " . $arr["vornamen"]." " . $arr["nachname"]; + return $ret; + } + function create_version($user, $info_data) { + $id = 0; + $info_id = 0; + $version_id = 0; + + $ects_points = $info_data["ects_credits"]; + $learning_language = $info_data["sprache"]; + $wochenstunden = $info_data["hours"]; + $course_id = $info_data["course_id"]; + $term_id = $info_data["term_id"]; + $short = $info_data["short"]; + $studienjahr = $info_data["studienjahr"]; + $fachbereich = $info_data["fachbereich"]; + $fachbereichsleiter = $info_data["fachbereichsleiter"]; + $fachbereichskoordinator = $info_data["fachbereichskoordinator"]; + $lehrender = $info_data["lehrender"]; + + $sql = "INSERT INTO lv_infos (ects_credits, + sprache, hours, studienjahr, fachbereich, + fachbereichsleiter, fachbereichskoordinator, lehrender) VALUES + ($ects_points, $learning_language, + $wochenstunden, '$studienjahr', + '$fachbereich', '$fachbereichsleiter', + '$fachbereichskoordinator', '$lehrender')"; + $rs = new myRS($sql); + $info_id = $rs->iid; + if ($info_id) { + $sql = "SELECT max(version) as version FROM lv_versions + WHERE studiengang_kz = $course_id AND + short = '$short' AND term_id = $term_id"; + $rs = new myRS($sql); + $max_version = $rs->arr[0]["version"]; + $sql ="INSERT INTO lv_versions (studiengang_kz, term_id, + short, lector_uid, version, + status, info_id, date_created, date_modified) + VALUES ($course_id, $term_id, '$short', + '$user', " . ($max_version +1).", 0,$info_id," .time() .", " . time().")"; + $rs = new myRS($sql); + $version_id = $rs->iid; + } + return array($version_id, $info_id); + } // eof create_version + + function get_version($version_id) { + $sql = "SELECT * FROM lv_versions v, lv_infos i + WHERE v.id = $version_id AND v.info_id = i.id"; + $rs = new myRS($sql); + return array( + $rs->arr[0]["ects_credits"]/10, + $rs->arr[0]["sprache"], + $rs->arr[0]["hours"]/10, + $rs->arr[0]["info_id"], + $rs->arr[0]["content_de_id"], + $rs->arr[0]["content_en_id"], + $rs->arr[0]["date_created"], + $rs->arr[0]["date_modified"], + $rs->arr[0]["studienjahr"], + $rs->arr[0]["fachbereich"], + $rs->arr[0]["fachbereichsleiter"], + $rs->arr[0]["fachbereichskoordinator"], + $rs->arr[0]["lehrender"], + $rs->arr[0]["studiengang_kz"], + $rs->arr[0]["term_id"], + $rs->arr[0]["short"] + ); + + } // eof get_version + + + // updates the record with info_id in lv_infos + function update_version($user, $info_data) { + $id = 0; + $version_id = 0; + $ects_points = $info_data["ects_credits"]; + $learning_language = $info_data["sprache"]; + $wochenstunden = $info_data["hours"]; + $info_id = $info_data["info_id"]; + $studienjahr = $info_data["studienjahr"]; + $fachbereich = $info_data["fachbereich"]; + $fachbereichsleiter = $info_data["fachbereichsleiter"]; + $fachbereichskoordinator = $info_data["fachbereichskoordinator"]; + $lehrender = $info_data["lehrender"]; + $version_id = $info_data["version_id"]; + + $sql = "UPDATE lv_infos SET ects_credits = $ects_points, + sprache = $learning_language, + hours = $wochenstunden, + studienjahr = '$studienjahr', + fachbereich = '$fachbereich', + fachbereichsleiter = '$fachbereichsleiter', + fachbereichskoordinator = '$fachbereichskoordinator', + lehrender = '$lehrender' + WHERE id = $info_id"; + $rs = new myRS($sql); + $sql = "UPDATE lv_versions SET date_modified = " .time() . + " WHERE id = $version_id"; + $rs = new myRS($sql); + } // eof update_version + + + // saves a version to be displayed in LV infos freigeben + function save_version($version_id) { + $sql = "UPDATE lv_versions SET status = 1 WHERE id = $version_id"; + $rs = new myRS($sql); + } + + // inserts a record into lv_content_$lang and + // update lv_versions.content_$lang_id + function create_content($lang, $version_id, $info_data) { + $arr_values = array_values($info_data); + $keys = join(", ", array_keys($info_data)); + + for ($i = 0; $i < count($arr_values)-1;$i++) { + $values .= "'" . $arr_values[$i] . "', "; + } + $values .= "'" . $arr_values[count($arr_values)-1] ."'"; + $sql = "INSERT INTO lv_content_$lang ($keys) VALUES ($values)"; + $rs = new myRS($sql); + $content_id = $rs->iid; + + $sql = "UPDATE lv_versions SET content_" . $lang . "_id = + $content_id WHERE id = $version_id"; + $rs = new myRS($sql); + + return $content_id; + } // eof create_content + + // update_content updates the table lv_content_$lang + function update_content($lang, $id, $info_data) { + $sql = "UPDATE lv_content_$lang SET "; + + $keys = array_keys($info_data); + $values = array_values($info_data); + + for ($i = 0; $i < count($values); $i++) { + $sql .= $keys[$i] ." = '" . $values[$i] . "'"; + if ($i < count($values)-1) $sql .= ", "; + } + $sql .= " WHERE id = $id"; + $rs = new myRS($sql); + } // eof update_content + function get_content($lang, $content_id, $fields) { + $sql = "SELECT " . join (", ", $fields) . " FROM + lv_content_$lang WHERE id = $content_id"; + $rs = new myRS($sql); + return $rs->arr[0]; + } // eof get_content + + function write_log($lektor_uid, $action) { + $sql = "INSERT INTO lv_log (lektor_uid, action, datum)" . + " VALUES ('$lektor_uid', '$action', " . time() .")"; + $rs = new myRS($sql); + return 1; + } + + +/***************************************************************************** +* function write_ects_menu($menu = 0, $course_id, $term_id, $short, $lang) { +* +* if ($menu == 1) $menu_name = "LV-Infos anzeigen"; +* +* print << + + + + + + + + + + + + + + + + + +
     
  • LV-Infos - anzeigen + +
  • LV-Infos - erstellen / bearbeiten + +
  • LV-Infos - freigeben
  • LV-Infos - Feedback
  •     
    + + +EOF; + + if ($menu_name) { + print << + + + + + + + +*
    + $menu_name + +Lehrfach: '; + if ($menu != 2) { + if ($lang == "" || $lang!="en") { +* echo "[Deutsch]"; +* } else { +* echo "[Deutsch]"; +* } +* if ($lang == "en") { +* echo "[English]"; +* } else { +* echo "[English]"; +* } +* } // eof menu=2 +* echo '
    +* '; +* } +* echo ' +*  '; +* } +***************************************************************************/ + + + // write a menu for a quicker navigation in the ects - course contents program + function write_ects_quick_menu($course_id, $term_id, $short, $p, $version_id = 0, $info_id = 0, $content_de_id = 0, $content_en_id = 0) { + if ($p > 0) { + print ''; + ?> + +'; + echo ''; + echo ''; + echo ''; + echo ''; + echo '
    Schnellnavigation
    +'; + static $headlines = array("", "Allgemeine Infos", "Inhalte DE", "Prüfung DE", "Inhalte EN", "Prüfung EN", "Beenden"); + for ($i = 1; $i < count($headlines); $i++) { + echo " + $i "; + if ($i==$p) echo ""; + echo $headlines[$i]; + if ($i==$p) echo ""; + echo "
    "; + } + } + } + + + + // this function returns the dictionary entry for the keyword in the + // given language + function dict($lang = "de", $key = "") { + static $dictionary = array ( + "back" => array("de" => "Zurück", "en" => "Back"), + "LVInfos" => array("de" => "LV - Informationen", "en" => "Course Description"), + "allCourses" => array("de" => "Alle Studiengänge", "en" => "All Courses"), + "availCourses" => array("de" => "Vorhandene Lehrfächer in ", "en" => "Available Courses in "), + "term" => array("de" => "Semester", "en" => "term"), + "noinfo" => array("de" => "Keine Informationenen verfügbar", "en" => "No course information available") + + ); + + return $dictionary[$key][$lang]; + } +?> diff --git a/include/ects_sync.class.php b/include/ects_sync.class.php new file mode 100644 index 000000000..f59427f95 --- /dev/null +++ b/include/ects_sync.class.php @@ -0,0 +1,110 @@ +connection=$conn; + } + + /******************************************************************** + * @brief Überprüft ob der Fachbereich existiert + * + * @param $fachb Fachbereichsbezeichnung + ********************************************************************/ + function check_fachbereich($fachb) + { + $sql_query = "SELECT * FROM tbl_fachbereich where bezeichnung='$fachb' OR kurzbz='$fachb'"; + + $result = pg_exec($this->connection, $sql_query); + + if($row=pg_fetch_object($result)) + $this->erg = $row->fachbereich_id; + else + return false; + + return true; + } + + /******************************************************************** + * @brief Überprüft ob der Studiengang existiert + * + * @param $stg Studiengangs Kurzzeichen + ********************************************************************/ + function check_studiengang($stg) + { + $sql_query = "SELECT * FROM tbl_studiengang where studiengang_kz = $stg"; + + $result = pg_exec($this->connection, $sql_query); + + if(pg_numrows($result)>0) + $this->erg = $stg; + else + return false; + + return true; + } + /******************************************************************** + * @brief Überprüft ob das Lehrfach existiert + * + * @param $lehrf LehrfachsKurzbz + * $stg Studiengang + * $sem Semester + ********************************************************************/ + function check_lehrfach($lehrf, $stg, $sem) + { + $sql_query = "SELECT * FROM tbl_lehrfach where kurzbz = upper('$lehrf') AND studiengang_kz=$stg AND semester=$sem"; + + $result = pg_exec($this->connection, $sql_query); + + if($row=pg_fetch_object($result)) + $this->erg = $row->lehrfach_nr; + else + return false; + + return true; + } + + /******************************************************************** + * @brief Überprüft das Semester + * + * @param $sem Semster + ********************************************************************/ + function check_semester($sem) + { + if(is_numeric($sem) AND $sem<10) + $this->erg = $sem; + else + return false; + + return true; + } +} +?> \ No newline at end of file diff --git a/include/einheit.class.php b/include/einheit.class.php new file mode 100644 index 000000000..77f137b02 --- /dev/null +++ b/include/einheit.class.php @@ -0,0 +1,315 @@ +conn = $conn; + + if (strlen($kurzbz)>0) + { + $this->kurzbz=$kurzbz; + $this->load(); + + } + } + + + /** + * Speichert die Einheit in der Datenbank. Bei Fehler ist der Rueckgabewert + * 'false' und die Fehlermeldung steht in 'errormsg'. INSERT oder DELETE wird + * durch 'new' bestimmt. + * @param string $kurzbz_new Kurzbezeichnung ist optional + * @return boolean true=ok, false=fehler + */ + function save($kurzbz_new='') + { + if (is_null($this->conn)) + { + return false; + } + + if (strlen($this->kurzbz)==0) + { + $this->errormsg="kurzbz nicht gesetzt"; + return false; + } + + if ($this->new) + { + if (is_numeric($this->semester)) $semester=$this->semester; + else $semester='NULL'; + if (is_numeric($this->typ)) $typ=$this->typ; + else $typ='NULL'; + if(!strlen($this->mailgrp_kurzbz)>0) + $this->mailgrp_kurzbz='NULL'; + $qry="insert into tbl_einheit(einheit_kurzbz,studiengang_kz,bezeichnung,semester,typ,mailgrp_kurzbz) ". + "values('".$this->kurzbz."','".$this->stg_kz."','".$this->bezeichnung."',$semester,$typ,$this->mailgrp_kurzbz)"; + } else + { + if (is_numeric($this->semester)) $semester='semester='.$this->semester; + else $semester='semester=NULL'; + if (is_numeric($this->typ)) $typ='typ='.$this->typ; + else $typ='NULL'; + if(!strlen($this->mailgrp_kurzbz)>0) + $this->mailgrp_kurzbz='mailgrp_kurzbz=NULL'; + else + $this->mailgrp_kurzbz="mailgrp_kurzbz='$this->mailgrp_kurzbz'"; + + $qry="update tbl_einheit set studiengang_kz=".$this->stg_kz.",bezeichnung='".$this->bezeichnung."',". + "$semester,$typ,".$this->mailgrp_kurzbz.",einheit_kurzbz='".(strlen($kurzbz_new)>0?$kurzbz_new:$this->kurzbz)."' ". + "where einheit_kurzbz='".$this->kurzbz."'"; + + } + //echo $qry; + if(!($erg=pg_exec($this->conn, $qry))) + { + $this->errormsg=pg_errormessage($this->conn); + return false; + } + return true; + + } + + /** + * @return boolean true=ok, false=fehler + */ + function load($kurzbz='') + { + // optional: kurzbz setzen + if (strlen($uid)>0) + $this->kurzbz=$kurzbz; + // uid vorhanden? + if (strlen($this->kurzbz)==0) { + $this->errormsg='einheit_kurzbz nicht gesetzt'; + return false; + } + if (is_null($this->conn)) { + return false; + } + $qry="select einheit_kurzbz,studiengang_kz,bezeichnung,semester,typ, mailgrp_kurzbz ". + "from tbl_einheit ". + "where einheit_kurzbz='".$this->kurzbz."'"; + + if(!($erg=pg_exec($this->conn, $qry))) { + $this->errormsg=pg_errormessage($this->conn); + return false; + } + $num_rows=pg_numrows($erg); + if($num_rows!=1) { + $this->errormsg="Zuwenige oder zuviele Ergebnisse (Anzahl: $num_rows)!"; + return false; + } + $row=pg_fetch_object($erg,0); + + $this->stg_kz=$row->studiengang_kz; + $this->bezeichnung=$row->bezeichnung; + $this->semester=$row->semester; + $this->typ=$row->typ; + $this->mailgrp_kurzbz=$row->mailgrp_kurzbz; + + return true; + + } + + /** + * Loescht die Funktion aus der Datenbank. Bei Fehler ist der Rueckgabewert + * 'false' und die Fehlermeldung steht in 'errormsg'. + * @return boolean true=ok, false=fehler + */ + function delete() + { + if (is_null($this->conn)) { + return false; + } + $qry="delete from tbl_einheit where einheit_kurzbz='".$this->kurzbz."'"; + + if(!($erg=pg_exec($this->conn, $qry))) { + $this->errormsg=pg_errormessage($this->conn); + return false; + } + return true; + } + + function addStudent($uid) { + if (is_null($this->conn)) { + return false; + } + $qry="insert into tbl_einheitstudent(einheit_kurzbz,uid,updateamum,updatevon) ". + "values('".$this->kurzbz."','".$uid."',now(),'".$_SERVER['PHP_AUTH_USER']."')"; + + if(!($erg=pg_exec($this->conn, $qry))) { + $this->errormsg=pg_errormessage($this->conn); + return false; + } + return true; + } + + function deleteStudent($uid) { + if (is_null($this->conn)) { + return false; + } + $qry="delete from tbl_einheitstudent ". + "where einheit_kurzbz='".$this->kurzbz."' and uid='$uid'"; + + if(!($erg=pg_exec($this->conn, $qry))) { + $this->errormsg=pg_errormessage($this->conn); + return false; + } + return true; + } + + + /** + * Alle Einheiten zurueckgeben + * @return array Array der einheiten + */ + function getAll($studiengang_kz='') + { + if (is_null($this->conn)) { + return false; + } + if (strlen($studiengang_kz)>0) + { + $where=" where tbl_einheit.studiengang_kz='".$studiengang_kz."' "; + } else + { + $where=""; + } + $qry="select tbl_einheit.*,tbl_studiengang.kurzbz from tbl_einheit join tbl_studiengang using(studiengang_kz) ". + "$where order by einheit_kurzbz;"; + if(!($erg=pg_exec($this->conn, $qry))) { + $this->errormsg=pg_errormessage($this->conn); + return false; + } + $num_rows=pg_numrows($erg); + $result=array(); + for($i=0;$i<$num_rows;$i++) + { + $row=pg_fetch_object($erg,$i); + $l=new einheit($this->conn); + $l->kurzbz=$row->einheit_kurzbz; + $l->stg_kz=$row->studiengang_kz; + $l->stg_kurzbz=$row->kurzbz; + $l->bezeichnung=$row->bezeichnung; + $l->semester=$row->semester; + $l->typ=$row->typ; + $l->mailgrp_kurzbz=$row->mailgrp_kurzbz; + $result[]=$l; + } + return $result; + } + + /** + * Liste aller Studenten zurueckgeben + * @param string $studiengang_kz optional + * @return array Array mit allen Studenten, false bei fehler + */ + function getStudenten($studiengang_kz='') + { + if (is_null($this->conn)) { + return false; + } + if (strlen($studiengang_kz)>0) + { + $where=" and tbl_einheit.studiengang_kz='".$studiengang_kz."' "; + } else + { + $where=""; + } + $qry="select einheit_kurzbz,uid ". + "from tbl_einheitstudent join tbl_student using(uid) join tbl_person using(uid) ". + " join tbl_einheit using (einheit_kurzbz) ". + "where einheit_kurzbz='".$this->kurzbz."' $where ". + "order by upper(tbl_person.nachname),upper(tbl_person.vornamen)"; + + if(!($erg=pg_exec($this->conn, $qry))) { + $this->errormsg=pg_errormessage($this->conn); + return false; + } + $num_rows=pg_numrows($erg); + $result=array(); + for($i=0;$i<$num_rows;$i++) + { + $row=pg_fetch_object($erg,$i); + $l=new student($this->conn,$row->uid); + $result[]=$l; + } + return $result; + } + + /** + * Liefert die Anzahl der Studenten in einer Einheit + * @param string kurzbzlang + * @return anzahl der Studenten + */ + function countStudenten($einheit_kurzbz) + { + $qry = "Select count(*) as anzahl from tbl_einheitstudent where einheit_kurzbz='$einheit_kurzbz'"; + if($result=pg_query($this->conn,$qry)) + { + if($row=pg_fetch_object($result)) + return $row->anzahl; + else + { + $this->errormsg = pg_errormessage($this->conn); + return false; + } + } + else + { + $this->errormsg = pg_errormessage($this->conn); + return false; + } + } + +} +?> \ No newline at end of file diff --git a/include/fachbereich.class.php b/include/fachbereich.class.php new file mode 100644 index 000000000..2c8da72dc --- /dev/null +++ b/include/fachbereich.class.php @@ -0,0 +1,92 @@ +conn = $conn; + } + + + /** + * Alle Fachbereiche zurückgeben + * @return array mit Fachbereichen oder false=fehler + */ + function getAll() + { + if (is_null($this->conn)) + { + return false; + } + $qry = "select fachbereich_id,tbl_fachbereich.kurzbz,tbl_fachbereich.bezeichnung,tbl_fachbereich.farbe,tbl_fachbereich.studiengang_kz,". + "tbl_studiengang.kurzbz as studiengang_kurzbz ". + "from tbl_fachbereich join tbl_studiengang using(studiengang_kz) ". + "order by tbl_Fachbereich.kurzbz"; + //echo $qry; + if (!($erg = pg_exec($this->conn, $qry))) + { + $this->errormsg = pg_errormessage($this->conn); + return false; + } + $result = array(); + $num_rows = pg_numrows($erg); + for ($i = 0; $i < $num_rows; $i ++) + { + // Record holen + $row = pg_fetch_object($erg, $i); + // Instanz erzeugen + $fb = new fachbereich($this->conn); + $fb->id = $row->fachbereich_id; + $fb->kurzbz = $row->kurzbz; + $fb->bezeichnung = $row->bezeichnung; + $fb->farbe = $row->farbe; + $fb->studiengang_kz = $row->studiengang_kz; + $fb->studiengang_kurzbz = $row->studiengang_kurzbz; + // in array speichern + $result[] = $fb; + } + return $result; + } + +} +?> \ No newline at end of file diff --git a/include/fas/adresse.class.php b/include/fas/adresse.class.php new file mode 100644 index 000000000..a1df7eff2 --- /dev/null +++ b/include/fas/adresse.class.php @@ -0,0 +1,355 @@ +conn = $conn; + $qry = "SET CLIENT_ENCODING TO 'UNICODE';"; + if(!pg_query($conn,$qry)) + { + $this->errormsg = "Encoding konnte nicht gesetzt werden"; + return false; + } + if($adress_id != null) + $this->load($adress_id); + } + + /** + * Laedt die Funktion mit der ID $adress_id + * @param $adress_id ID der zu ladenden Funktion + * @return true wenn ok, false im Fehlerfall + */ + function load($adress_id) + { + + //Pruefen ob adress_id eine gueltige Zahl ist + if(!is_numeric($adress_id) || $adress_id == '') + { + $this->errormsg = 'Adress_id muss eine Zahl sein'; + return false; + } + + //Daten aus der Datenbank lesen + $qry = "SELECT * FROM adresse WHERE adresse_pk=$adress_id"; + + if(!$res = pg_query($this->conn,$qry)) + { + $this->errormsg = 'Fehler bei einer Datenbankabfrage'; + return false; + } + + if($row = pg_fetch_object($res)) + { + $this->adresse_id = $row->adresse_pk; + $this->bismeldeadresse = ($row->bismeldeadresse=='J'?true:false); + $this->gemeinde = $row->gemeinde; + $this->name = $row->name; + $this->nation = $row->nation; + $this->ort = $row->ort; + $this->person_id = $row->person_fk; + $this->plz = $row->plz; + $this->strasse = $row->strasse; + $this->typ = $row->typ; + $this->updateamum = $row->creationdate; + $this->updatevon = $row->creationuser; + $this->zustelladresse = ($row->zustelladresse=='J'?true:false); + } + else + { + $this->errormsg = 'Es ist kein Datensatz mit dieser ID vorhanden'; + return false; + } + + return true; + } + + /** + * Laedt alle adressen zu der Person die uebergeben wird + * @param $pers_id ID der Person zu der die Adressen geladen werden sollen + * @return true wenn ok, false im Fehlerfall + */ + function load_pers($pers_id) + { + //Pruefen ob pers_id eine gueltige Zahl ist + if(!is_numeric($pers_id) || $pers_id == '') + { + $this->errormsg = 'person_id muss eine gueltige Zahl sein'; + return false; + } + + //Lesen der Daten aus der Datenbank + $qry = "SELECT * FROM adresse WHERE person_fk=$pers_id"; + + if(!$res = pg_query($this->conn,$qry)) + { + $this->errormsg = 'Fehler bei einer Datenbankabfrage'; + return false; + } + + while($row = pg_fetch_object($res)) + { + $adr_obj = new adresse($this->conn); + + $adr_obj->adresse_id = $row->adresse_pk; + $adr_obj->bismeldeadresse = ($row->bismeldeadresse=='J'?true:false); + $adr_obj->gemeinde = $row->gemeinde; + $adr_obj->name = $row->name; + $adr_obj->nation = $row->nation; + $adr_obj->ort = $row->ort; + $adr_obj->person_id = $row->person_fk; + $adr_obj->plz = $row->plz; + $adr_obj->strasse = $row->strasse; + $adr_obj->typ = $row->typ; + $adr_obj->updateamum = $row->creationdate; + $adr_obj->updatevon = $row->creationuser; + $adr_obj->zustelladresse = ($row->zustelladresse=='J'?true:false); + + $this->result[] = $adr_obj; + } + return true; + } + + /** + * Laedt alle Adressen aus der Datenbank + * @return true wenn ok, false im Fehlerfall + */ + function getAll() + { + $qry = "SELECT * FROM adresse"; + + if(!$res = pg_query($this->conn,$qry)) + { + $this->errormsg = 'Fehler bei einer Datenbankabfrage'; + return false; + } + + while($row = pg_fetch_object($res)) + { + $adr_obj = new adresse($this->conn); + + $adr_obj->adresse_id = $row->adresse_pk; + $adr_obj->bismeldeadresse = ($row->bismeldeadresse=='J'?true:false); + $adr_obj->gemeinde = $row->gemeinde; + $adr_obj->name = $row->name; + $adr_obj->nation = $row->nation; + $adr_obj->ort = $row->ort; + $adr_obj->person_id = $row->person_fk; + $adr_obj->plz = $row->plz; + $adr_obj->strasse = $row->strasse; + $adr_obj->typ = $row->typ; + $adr_obj->updateamum = $row->creationdate; + $adr_obj->updatevon = $row->creationuser; + $adr_obj->zustelladresse = ($row->zustelladresse=='J'?true:false); + + $this->result[] = $adr_obj; + } + + return true; + } + + /** + * Prueft die Variablen auf gueltigkeit + * @return true wenn ok, false im Fehlerfall + */ + function checkvars() + { + //Zahlenfelder pruefen + $this->errormsg='Ein Zahlenfeld enthaelt ungueltige Zeichen'; + if(!is_numeric($this->person_id)) + { + $this->errormsg='Person_id enthaelt ungueltige Zeichen:'.$this->person_id; + return false; + } + if(!is_numeric($this->typ)) + { + $this->errormsg='Typ enthaelt ungueltige Zeichen'; + return false; + } + + //Gesamtlaenge pruefen + $this->errormsg='Eine der Gesamtlaengen wurde ueberschritten'; + if(strlen($this->name)>255) + { + $this->errormsg = 'Name darf nicht länger als 255 Zeichen sein'; + return false; + } + if(strlen($this->strasse)>255) + { + $this->errormsg = 'Strasse darf nicht länger als 255 Zeichen sein'; + return false; + } + if(strlen($this->plz)>10) + { + $this->errormsg = 'Plz darf nicht länger als 10 Zeichen sein'; + return false; + } + if(strlen($this->ort)>255) + { + $this->errormsg = 'Ort darf nicht länger als 255 Zeichen sein'; + return false; + } + if(strlen($this->nation)>3) + { + $this->errormsg = 'Nation darf nicht länger als 3 Zeichen sein'; + return false; + } + if(strlen($this->gemeinde)>255) + { + $this->errormsg = 'Gemeinde darf nicht länger als 255 Zeichen sein'; + return false; + } + + $this->errormsg = ''; + return true; + } + + /** + * Speichert den aktuellen Datensatz in die Datenbank + * Wenn $neu auf true gesetzt ist wird ein neuer Datensatz angelegt + * andernfalls wird der Datensatz mit der ID in $adresse_id aktualisiert + * @return true wenn ok, false im Fehlerfall + */ + function save() + { + //Variablen pruefen + if(!$this->checkvars()) + return false; + + if($this->new) + { + //Neuen Datensatz einfuegen + + //naechste ID aus der Sequence holen + $qry="SELECT nextval('adresse_seq') as id;"; + if(!$row = pg_fetch_object(pg_query($this->conn,$qry))) + { + $this->errormsg = 'Fehler beim auslesen der Sequence'; + return false; + } + $this->adresse_id = $row->id; + + $qry="INSERT INTO adresse (adresse_pk, person_fk, name, strasse, plz, typ, ort, nation, creationdate, creationuser,". + " gemeinde, bismeldeadresse, zustelladresse) VALUES(". + " $this->adresse_id, $this->person_id, '$this->name', '$this->strasse', '$this->plz', $this->typ, '$this->ort',". + " '$this->nation', now(), $this->updatevon, '$this->gemeinde', '".($this->bismeldeadresse?'J':'N')."',". + " '".($this->zustelladresse?'J':'N')."');"; + } + else + { + //Updaten des bestehenden Datensatzes + + //Pruefen ob adresse_id eine gueltige Zahl ist + if(!is_numeric($this->adresse_id)) + { + $this->errormsg = 'adresse_id muss eine gueltige Zahl sein'; + return false; + } + + $qry="UPDATE adresse SET person_fk='$this->person_id', name='$this->name', strasse='$this->strasse', plz='$this->plz',". + " typ='$this->typ', ort='$this->ort', nation='$this->nation', gemeinde='$this->gemeinde',". + " bismeldeadresse='".($this->bismeldeadresse?'J':'N')."', zustelladresse='".($this->zustelladresse?'J':'N')."'". + " WHERE adresse_pk='$this->adresse_id'"; + } + + if(pg_query($this->conn,$qry)) + { + //Log schreiben + $sql = $qry; + $qry = "SELECT nextval('log_seq') as id;"; + if(!$row = pg_fetch_object(pg_query($this->conn, $qry))) + { + $this->errormsg = 'Fehler beim Auslesen der Log-Sequence'; + return false; + } + + $qry = "INSERT INTO log(log_pk, creationdate, creationuser, sql) VALUES('$row->id', now(), '$this->updatevon', '".addslashes($sql)."')"; + if(pg_query($this->conn, $qry)) + return true; + else + { + $this->errormsg = 'Fehler beim Speichern des Log-Eintrages'; + return false; + } + } + else + { + $this->errormsg = 'Fehler beim Speichern der Daten'; + return false; + } + } + + /** + * Loescht den Datenensatz mit der ID die uebergeben wird + * @param $adress_id ID die geloescht werden soll + * @return true wenn ok, false im Fehlerfall + */ + function delete($adress_id) + { + //Pruefen ob adresse_id eine gueltige Zahl ist + if(!is_numeric($adress_id) || $adress_id == '') + { + $this->errormsg = 'adresse_id muss eine gueltige Zahl sein'; + return false; + } + + //loeschen des Datensatzes + $qry="DELETE FROM adresse WHERE adresse_pk=$adress_id;"; + + if(pg_query($this->conn,$qry)) + { + //Log schreiben + $sql = $qry; + $qry = "SELECT nextval('log_seq') as id;"; + if(!$row = pg_fetch_object(pg_query($this->conn, $qry))) + { + $this->errormsg = 'Fehler beim Auslesen der Log-Sequence'; + return false; + } + + $qry = "INSERT INTO log(log_pk, creationdate, creationuser, sql) VALUES('$row->id', now(), '$this->updatevon', '".addslashes($sql)."')"; + if(pg_query($this->conn, $qry)) + return true; + else + { + $this->errormsg = 'Fehler beim Speichern des Log-Eintrages'; + return false; + } + } + else + { + $this->errormsg = 'Fehler beim loeschen der Daten'; + return false; + } + } +} +?> \ No newline at end of file diff --git a/include/fas/ausbildungssemester.class.php b/include/fas/ausbildungssemester.class.php new file mode 100644 index 000000000..dc94d4414 --- /dev/null +++ b/include/fas/ausbildungssemester.class.php @@ -0,0 +1,182 @@ +conn = $conn; + $qry = "SET CLIENT_ENCODING TO 'UNICODE';"; + if(!pg_query($conn,$qry)) + { + $this->errormsg = "Encoding konnte nicht gesetzt werden"; + return false; + } + if($ausbildungssemester_id != null) + $this->load($ausbildungssemester_id); + } + + /** + * Laedt einen Datensatz aus der Datenbank + * @param $ausbildungssemester_id ID des zu ladenden Datensatzes + * @return true wenn ok, false im Fehlerfall + */ + function load($ausbildungssemester_id) + { + if(!is_numeric($ausbildungssemester_id) || $ausbildungssemester_id == '') + { + $this->errormsg = 'ausbildungssemester_id muss eine gueltige Zahl sein'; + return false; + } + + $qry = "SELECT * FROM ausbildungssemester WHERE ausbildungssemester_pk = '$ausbildungssemester_id';"; + + if(!$res = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Fehler beim laden des Datensatzes'; + return false; + } + + if($row=pg_fetch_object($res)) + { + $this->ausbildungssemester_id = $row->ausbildungssemester_pk; + $this->studiengang_id = $row->studiengang_fk; + $this->semester = $row->semester; + $this->name = $row->name; + $this->personenstatus = $row->personenstatus; + $this->updateamum = $row->creationdate; + $this->updatevon = $row->creationuser; + } + else + { + $this->errormsg = 'Fehler beim laden des Datensatzes'; + return false; + } + + return true; + } + + /** + * Liefert alle ausbildungssemester zu einem Studiengang + * @param $studiengang_id Studiengang_id des Ausbildungssemesters + * @return true wenn ok, false im Fehlerfall + */ + function load_stg($studiengang_id) + { + if(!is_numeric($studiengang_id) || $studiengang_id == '') + { + $this->errormsg = 'studiengang_id muss eine gueltige Zahl sein'; + return false; + } + + $qry = "SELECT * FROM ausbildungssemester WHERE studiengang_fk = '$studiengang_id' order by semester"; + + if(!$res = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Fehler beim laden des Datensatzes'; + return false; + } + + while($row = pg_fetch_object($res)) + { + $ausb_obj = new ausbildungssemester($this->conn); + + $ausb_obj->ausbildungssemester_id = $row->ausbildungssemester_pk; + $ausb_obj->studiengang_id = $row->studiengang_fk; + $ausb_obj->semester = $row->semester; + $ausb_obj->name = $row->name; + $ausb_obj->personenstatus = $row->personenstatus; + $ausb_obj->updateamum = $row->creationdate; + $ausb_obj->updatevon = $row->creationuser; + + $this->result[] = $ausb_obj; + } + return true; + } + + /** + * Liefert alle Ausbildungssemester + * @return true wenn ok, false im Fehlerfall + */ + function getAll() + { + $qry = "SELECT * FROM ausbildungssemester;"; + + if(!$res = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Fehler beim laden des Datensatzes'; + return false; + } + + while($row = pg_fetch_object($res)) + { + $ausb_obj = new ausbildungssemester($this->conn); + + $ausb_obj->ausbildungssemester_id = $row->ausbildungssemester_pk; + $ausb_obj->studiengang_id = $row->studiengang_fk; + $ausb_obj->semester = $row->semester; + $ausb_obj->name = $row->name; + $ausb_obj->personenstatus = $row->personenstatus; + $ausb_obj->updateamum = $row->creationdate; + $ausb_obj->updatevon = $row->creationuser; + + $this->result[] = $ausb_obj; + } + return true; + } + + /** + * Checkt die Variablen vor dem Speichern + * @return true wenn ok, false im Fehlerfall + */ + function checkvars() + { + $this->errormsg = 'Noch nicht implementiert'; + return false; + } + + /** + * Speichert den aktuellen Datensatz + * @return true wenn ok, false im Fehlerfall + */ + function save() + { + if(!checkvars()) + return false; + + $this->errormsg = 'Noch nicht implementiert'; + return false; + } + + /** + * Loescht den Datensatz mit der ID die uebergeben wurde + * @param $ausbildungssemester_id ID des zu loeschenden Datensatzes + * @return true wenn ok, false im Fehlerfall + */ + function delete($ausbildungssemester_id) + { + $this->errormsg = 'Noch nicht implementiert'; + return false; + } +} +?> \ No newline at end of file diff --git a/include/fas/bankverbindung.class.php b/include/fas/bankverbindung.class.php new file mode 100644 index 000000000..62630d19e --- /dev/null +++ b/include/fas/bankverbindung.class.php @@ -0,0 +1,340 @@ +conn = $conn; + $qry = "SET CLIENT_ENCODING TO 'UNICODE';"; + if(!pg_query($conn,$qry)) + { + $this->errormsg = "Encoding konnte nicht gesetzt werden"; + return false; + } + if($bank_id != null) + $this->load($bank_id); + } + + /** + * Prueft die gueltigkeit der Variablen + * @return true wenn ok, false im Fehlerfall + */ + function checkvars() + { + //Gesamtlaenge pruefen + $this->errormsg = 'Eine der Maximiallaengen wurde ueberschritten'; + if(strlen($this->name)>255) + { + $this->errormsg = 'Name darf nicht länger als 255 Zeichen sein'; + return false; + } + if(strlen($this->anschrift)>255) + { + $this->errormsg = 'Anschrift darf nicht länger als 255 Zeichen sein'; + return false; + } + if(strlen($this->blz)>15) + { + $this->errormsg = 'BLZ darf nicht länger als 15 Zeichen sein'; + return false; + } + if(strlen($this->bic)>15) + { + $this->errormsg = 'BIC darf nicht länger als 15 Zeichen sein'; + return false; + } + if(strlen($this->kontonr)>25) + { + $this->errormsg = 'KontoNr darf nicht länger als 25 Zeichen sein'; + return false; + } + if(strlen($this->iban)>25) + { + $this->errormsg = 'IBAN darf nicht länger als 25 Zeichen sein'; + return false; + } + + //Zahlenwerte ueberpruefen + $this->errormsg = 'Ein Zahlenfeld enthaelt ungueltige Zeichen'; + if(!is_numeric($this->person_id)) return false; + if(!is_numeric($this->typ)) return false; + + $this->errormsg = ''; + return true; + } + + + /** + * Speichert den aktuellen Datensatz + * Wenn $neu auf true gesetzt ist wird ein neuer Datensatz angelegt + * andernfalls wird der Datensatz mit der ID in $bankverbindung_id aktualisiert + * @return true wenn ok, false im Fehlerfall + */ + function save() + { + //Gueltigkeit der Variablen pruefen + if(!$this->checkvars()) + return false; + + if($this->new) + { + //Neuen Datensatz einfuegen + + //Naechste ID aus der Sequence holen + $qry = "SELECT nextval('bankverbindung_seq') as id;"; + if(!$row = pg_fetch_object(pg_query($this->conn, $qry))) + { + $this->errormsg = 'Fehler beim auslesen der Sequence'; + return false; + } + $this->bankverbindung_id = $row->id; + + $qry = "INSERT INTO bankverbindung (bankverbindung_pk, person_fk, name, anschrift, blz, bic,". + " kontonr, iban, typ, creationdate, creationuser) VALUES(". + " '$this->bankverbindung_id', '$this->person_id', '$this->name', '$this->anschrift',". + " '$this->blz', '$this->bic', '$this->kontonr', '$this->iban', '$this->typ', now(), $this->updatevon);"; + } + else + { + //Datensatz Updaten + + //ID pruefen + if(!is_numeric($this->bankverbindung_id)) + { + $this->errormsg = 'bankverbindung_id muss eine Zahl sein'; + return false; + } + + $qry="UPDATE bankverbindung SET person_fk='$this->person_id', name='$this->name',". + " anschrift='$this->anschrift', blz='$this->blz', bic='$this->bic',". + " kontonr='$this->kontonr', iban='$this->iban', typ='$this->typ'". + " WHERE bankverbindung_pk=$this->bankverbindung_id"; + } + + if(pg_query($this->conn, $qry)) + { + //Log schreiben + $sql = $qry; + $qry = "SELECT nextval('log_seq') as id;"; + if(!$row = pg_fetch_object(pg_query($this->conn, $qry))) + { + $this->errormsg = 'Fehler beim Auslesen der Log-Sequence'; + return false; + } + + $qry = "INSERT INTO log(log_pk, creationdate, creationuser, sql) VALUES('$row->id', now(), '$this->updatevon', '".addslashes($sql)."')"; + if(pg_query($this->conn, $qry)) + return true; + else + { + $this->errormsg = 'Fehler beim Speichern des Log-Eintrages'; + return false; + } + } + else + { + $this->errormsg = 'Fehler beim Speichern der Daten'; + return false; + } + } + + /** + * Loescht den Datensatz mit der uebergebenen ID + * @param $bank_id ID des zu loeschenden Datensatzes + * @return true wenn ok, false im Fehlerfall + */ + function delete($bank_id) + { + if(!is_numeric($bank_id) || $bank_id == '') + { + $this->errormsg = 'bank_id muss eine Zahl sein'; + return false; + } + + $qry="DELETE FROM bankverbindung WHERE bankverbindung_pk=$bank_id"; + + if(!pg_query($this->conn, $qry)) + { + $this->errormsg = 'Fehler beim loeschen der Daten'; + return false; + } + else + { + //Log schreiben + $sql = $qry; + $qry = "SELECT nextval('log_seq') as id;"; + if(!$row = pg_fetch_object(pg_query($this->conn, $qry))) + { + $this->errormsg = 'Fehler beim Auslesen der Log-Sequence'; + return false; + } + + $qry = "INSERT INTO log(log_pk, creationdate, creationuser, sql) VALUES('$row->id', now(), '$this->updatevon', '".addslashes($sql)."')"; + if(pg_query($this->conn, $qry)) + return true; + else + { + $this->errormsg = 'Fehler beim Speichern des Log-Eintrages'; + return false; + } + } + } + + /** + * Liefert die Bankverbindung mit der uebergebenen ID + * @param $bank_id ID der bankverbindung + * @return true wenn ok, false im Fehlerfall + */ + function load($bank_id) + { + if(!is_numeric($bank_id) || $bank_id == '') + { + $this->errormsg = 'bank_id muss eine gueltige Zahl sein'; + return false; + } + + $qry = "SELECT * FROM bankverbindung WHERE bankverbindung_pk=$bank_id"; + + if(!$res = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Fehler bei einer Datenbankabfrage'; + return false; + } + + if($row = pg_fetch_object($res)) + { + $this->bankverbindung_id = $row->bankverbindung_pk; + $this->person_id = $row->person_fk; + $this->name = $row->name; + $this->anschrift = $row->anschrift; + $this->blz = $row->blz; + $this->bic = $row->bic; + $this->kontonr = $row->kontonr; + $this->iban = $row->iban; + $this->typ = $row->typ; + $this->updateamum = $row->creationdate; + $this->updatevon = $row->creationuser; + } + else + { + $this->errormsg = 'Es ist kein Datensatz mit dieser ID vorhanden'; + return false; + } + + return true; + } + + /** + * Liefert alle Bankverbindungen der Person die uebergeben wird + * @param $pers_id ID der Person + * @return true wenn ok, false im Fehlerfall + */ + function load_pers($pers_id) + { + if(!is_numeric($pers_id) || $pers_id == '') + { + $this->errormsg = 'pers_id muss eine gueltige Zahl sein'; + return false; + } + + $qry = "SELECT * FROM bankverbindung WHERE person_fk=$pers_id"; + + if(!$res = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Fehler bei einer Datenbankabfrage'; + return false; + } + + while($row = pg_fetch_object($res)) + { + $bank_obj = new bankverbindung($this->conn); + + $bank_obj->bankverbindung_id = $row->bankverbindung_pk; + $bank_obj->person_id = $row->person_fk; + $bank_obj->name = $row->name; + $bank_obj->anschrift = $row->anschrift; + $bank_obj->blz = $row->blz; + $bank_obj->bic = $row->bic; + $bank_obj->kontonr = $row->kontonr; + $bank_obj->iban = $row->iban; + $bank_obj->typ = $row->typ; + $bank_obj->updateamum = $row->creationdate; + $bank_obj->updatevon = $row->creationuser; + + $this->result[] = $bank_obj; + } + return true; + } + + /** + * Liefert alle Bankverbindungen + * @return true wenn ok, false im Fehlerfall + */ + function getAll() + { + $qry = "SELECT * FROM bankverbindung"; + + if(!$res = pg_query($this->conn,$qry)) + { + $this->errormsg = 'Fehler bei einer Datenbankabfrage'; + return false; + } + + while($row = pg_fetch_object($res)) + { + $bank_obj = new bankverbindung($this->conn); + + $bank_obj->bankverbindung_id = $row->bankverbindung_pk; + $bank_obj->person_id = $row->person_fk; + $bank_obj->name = $row->name; + $bank_obj->anschrift = $row->anschrift; + $bank_obj->blz = $row->blz; + $bank_obj->bic = $row->bic; + $bank_obj->kontonr = $row->kontonr; + $bank_obj->iban = $row->iban; + $bank_obj->typ = $row->typ; + $bank_obj->updateamum = $row->creationdate; + $bank_obj->updatevon = $row->creationuser; + + $this->result[] = $bank_obj; + } + return true; + } + + function getTypBezeichnung($id) + { + switch($id) + { + case 1: return 'Privatkonto'; + case 2: return 'Firmenkonto'; + default: return ''; + } + } +} +?> \ No newline at end of file diff --git a/include/fas/benutzer.class.php b/include/fas/benutzer.class.php new file mode 100644 index 000000000..31f9ac952 --- /dev/null +++ b/include/fas/benutzer.class.php @@ -0,0 +1,386 @@ +conn=$conn; + $this->new=true; + } + + + /** + * Ladet die Attribute der Berechtigung aus der Datenbank. Bei Fehler ist der + * Rueckgabewert 'false' und die Fehlermeldung steht in 'errormsg'. + * @return boolean true=ok, false=fehler + */ + function load($id) + { + // Berechtigung holen + $sql_query="SELECT * FROM tbl_userberechtigung WHERE userberechtigung_id=$id"; + //echo $sql_query; + if(!($erg=pg_exec($this->conn, $sql_query))) + { + $this->errormsg=pg_errormessage($this->conn); + return false; + } + $num_rows=pg_numrows($erg); + if($num_rows!=1) + { + $this->errormsg="Zuwenige oder zuviele Ergebnisse (Anzahl: $num_rows)!"; + return false; + } + $row=pg_fetch_object($erg,0); + + $this->userberechtigung_id=$row->userberechtigung_id; + $this->studiengang_kz=$row->studiengang_kz; + $this->fachbereich_id=$row->fachbereich_id; + $this->berechtigung_kurzbz=$row->berechtigung_kurzbz; + $this->uid=$row->uid; + $this->studiensemester_kurzbz=$row->studiensemester_kurzbz; + $this->start=$row->start; + $this->ende=$row->ende; + $this->art=$row->art; + $this->new=false; + + return true; + } + + /** + * @return boolean true=ok, false=fehler + */ + function save() + { + /* + // Connection holen + if (is_null($conn=$this->getConnection())) + { + return false; + } + // Daten zur Person speichern + + if (!person::save()) { + $this->errormsg.="Daten zur LVA konnten nicht gespeichert werden."; + return false; + } + if ($this->new) { + $qry="INSERT INTO tbl_lehrveranstaltung(lvnr,unr,einheit_kurzbz,". + "lektor,lehrfach_nr,studiengang_kz,fachbereich_id,semester,verband,". + "gruppe,raumtyp,raumtypalternativ,semesterstunden,stundenblockung,". + "wochenrythmus,start_kw,anmerkung)". + "values(". + "'".$this->lvnr."',". + "'".$this->unr."',". + "'".$this->einheit_kurzbz."',". + "'".$this->lektor."',". + (strlen($this->lehrfach_nr)>0?$this->lehrfach_nr:NULL).",". + (strlen($this->studiengang_kz)>0?$this->studiengang_kz:NULL).",". + (strlen($this->fachbereich_id)>0?$this->fachbereich_id:NULL).",". + (strlen($this->semester)>0?$this->semester:NULL).",". + "'".$this->verband."',". + "'".$this->gruppe."',". + (strlen($this->raumtyp)>0?"'".$this->raumtyp."'":NULL).",". + (strlen($this->raumtypalternativ)>0?"'".$this->raumtypalternativ."'":NULL).",". + (strlen($this->semesterstunden)>0?$this->semesterstunden:NULL).",". + (strlen($this->stundenblockung)>0?$this->stundenblockung:NULL).",". + (strlen($this->wochenrythmus)>0?$this->wochenrythmus:NULL).",". + (strlen($this->start_kw)>0?$this->start_kw:NULL).",". + (strlen($this->anmerkung)>0?"'".$this->anmerkung."'":NULL).",". + ")"; + } else + { + $qry="UPDATE tbl_lehrveranstaltung ". + "SET lvnr='".$this->lvnr."',". + "unr='".$this->unr."',". + "einheit_kurzbz='".$this->einheit_kurzbz."',". + "lektor='".$this->lehrfach_nr."',". + "lehrfach_nr=".(strlen($this->lehrfach_nr)>0?$this->lehrfach_nr:NULL).",". + "studiengang_kz=".(strlen($this->studiengang_kz)>0?$this->studiengang_kz:NULL).",". + "fachbereich_id=".(strlen($this->fachbereich_id)>0?$this->fachbereich_id:NULL).",". + "semester=".(strlen($this->semester)>0?$this->semester:NULL).",". + "verband='".$this->verband."',". + "gruppe='".$this->gruppe."',". + "raumtyp=".(strlen($this->raumtyp)>0?"'".$this->raumtyp."'":NULL).",". + "raumtypalternativ=".(strlen($this->raumtypalternativ)>0?"'".$this->raumtypalternativ."'":NULL).",". + "semesterstunden=".(strlen($this->semesterstunden)>0?$this->semesterstunden:NULL).",". + "stundenblockung=".(strlen($this->stundenblockung)>0?$this->stundenblockung:NULL).",". + "wochenrythmus=".(strlen($this->wochenrythmus)>0?$this->wochenrythmus:NULL).",". + "start_kw=".(strlen($this->start_kw)>0?$this->start_kw:NULL).",". + "anmerkung=".(strlen($this->anmerkung)>0?"'".$this->anmerkung."'":NULL). + " WHERE lehrveranstaltung_id='".$this->lehrveranstaltung_id."'"; + } + //echo "
    ".$qry; + if(!@pg_query($conn, $qry)) + { + $this->errormsg=pg_errormessage($conn); + return false; + } + return true; + */ + } + + + /** + * Rueckgabewert ist ein Array mit den Ergebnissen. Bei Fehler false und die + * Fehlermeldung liegt in errormsg. + * Wenn der Parameter stg_kz NULL ist tritt einheit_kurzbzb in Kraft. + * @param string $uid UserID + * @return variabel Array mit LVA; false bei Fehler + */ + function getBerechtigungen($uid) + { + // Berechtigungen holen + $sql_query="SELECT * FROM tbl_userberechtigung WHERE uid='$uid' AND (startnow() OR ende IS NULL)"; + //echo $sql_query; + if(!$erg=@pg_query($this->conn, $sql_query)) + { + $this->errormsg=pg_errormessage($this->conn); + return false; + } + //$num_rows=pg_numrows($erg); + while($row=pg_fetch_object($erg)) + { + $b=new berechtigung($this->conn); + $b->userberechtigung_id=$row->userberechtigung_id; + $b->studiengang_kz=$row->studiengang_kz; + $b->fachbereich_id=$row->fachbereich_id; + $b->berechtigung_kurzbz=$row->berechtigung_kurzbz; + $b->uid=$row->uid; + $b->studiensemester_kurzbz=$row->studiensemester_kurzbz; + $b->start=$row->start; + if ($row->start!=null) + $b->starttimestamp=mktime(0,0,0,substr($row->start,5,2),substr($row->start,8),substr($row->start,0,4)); + else + $b->starttimestamp=null; + $b->ende=$row->ende; + if ($row->ende!=null) + $b->endetimestamp=mktime(23,59,59,substr($row->ende,5,2),substr($row->ende,8),substr($row->ende,0,4)); + else + $b->endetimestamp=null; + $b->art=$row->art; + $this->berechtigungen[]=$b; + } + return true; + } + + + function isBerechtigt($berechtigung,$studiengang_kz=null,$art=null) + { + $timestamp=time(); + foreach ($this->berechtigungen as $b) + { + if($berechtigung == $b->berechtigung_kurzbz && $studiengang_kz==null && $art==null) + if ($b->starttimestamp!=null && $b->endetimestamp!=null) + { + if ($timestamp>$b->starttimestamp && $timestamp<$b->endetimestamp) + return true; + } + else + return true; + + if ($berechtigung==$b->berechtigung_kurzbz + && ($studiengang_kz==$b->studiengang_kz || $b->studiengang_kz==0) && $art==null) + if ($b->starttimestamp!=null && $b->endetimestamp!=null) + { + if ($timestamp>$b->starttimestamp && $timestamp<$b->endetimestamp) + return true; + } + else + return true; + + if ($berechtigung==$b->berechtigung_kurzbz + && ($studiengang_kz==$b->studiengang_kz || $b->studiengang_kz==0) + && strstr($b->art,$art)) + if ($b->starttimestamp!=null && $b->endetimestamp!=null) + { + if ($timestamp>$b->starttimestamp && $timestamp<$b->endetimestamp) + return true; + } + else + return true; + } + return false; + } + + /** + * Gibt Array mit Kennzahlen der Studiengaenge sortiert zurueck. + * Optional wird auf Berechtigung eingeschraenkt. + * Wenn Berechtigung ueber alle Studiengaenge steht im ersten Feld 0. + */ + function getStgKz($berechtigung=null) + { + $studiengang_kz=array(); + $timestamp=time(); + + foreach ($this->berechtigungen as $b) + if ($berechtigung==$b->berechtigung_kurzbz || $berechtigung==null) + $studiengang_kz[]=$b->studiengang_kz; + $studiengang_kz=array_unique($studiengang_kz); + sort($studiengang_kz); + return $studiengang_kz; + } + + /** + * Setzt die Studiensemester Variable + */ + function setVariableStudiensemester($user,$stsem) + { + //Vorhandende Variable aendern + $qry = "Update tbl_variable SET wert='$stsem' WHERE uid='$user' AND name='semester_aktuell'"; + if($result = pg_query($this->conn,$qry)) + { + if(pg_affected_rows($result)==0) + { + //Falls Variable nicht vorhanden ist eine neue anlegen + $qry = "INSERT INTO tbl_variable(uid, name, wert) values('$user', 'semester_aktuell', '$stsem')"; + if(pg_query($this->conn,$qry)) + return true; + else + { + $this->errormsg.=pg_errormessage($this->conn); + return false; + } + } + else + return true; + } + else + { + $this->errormsg.=pg_errormessage($this->conn); + return false; + } + } + + function getpossibilities($variable) + { + $ret = array(); + + switch($variable) + { + case 'semester_aktuell': + $qry = "Select * from tbl_studiensemester order by start"; + if($result = pg_query($this->conn,$qry)) + { + while($row=pg_fetch_object($result)) + $ret[] = $row->studiensemester_kurzbz; + } + break; + } + return $ret; + } + + function loadVariables($user) + { + if(!($result=@pg_query($this->conn, "SELECT * FROM tbl_variable WHERE uid='$user'"))) + { + $this->errormsg.=pg_errormessage($this->conn); + return false; + } + else + $num_rows=@pg_numrows($result); + + while($row=pg_fetch_object($result)) + { + $this->variable->{$row->name}=$row->wert; + } + + if (!isset($this->variable->semester_aktuell)) + { + if(!($result=@pg_query($this->conn, 'SELECT * FROM tbl_studiensemester WHERE ende>now() ORDER BY start LIMIT 1'))) + { + $this->errormsg.=pg_errormessage($this->conn); + return false; + } + else + { + $num_rows=@pg_numrows($result); + if ($num_rows>0) + { + $row=pg_fetch_object($result); + $this->variable->semester_aktuell=$row->studiensemester_kurzbz; + } + } + } + + if (!isset($this->variable->db_stpl_table)) + $this->variable->db_stpl_table='stundenplan'; + + if (!isset($this->variable->fas_id)) + $this->variable->fas_id=0; + + if (!isset($this->variable->sleep_time)) + $this->variable->sleep_time=300; + + return true; + } +} +?> \ No newline at end of file diff --git a/include/fas/email.class.php b/include/fas/email.class.php new file mode 100644 index 000000000..399e84d99 --- /dev/null +++ b/include/fas/email.class.php @@ -0,0 +1,310 @@ +conn = $conn; + $qry = "SET CLIENT_ENCODING TO 'UNICODE';"; + if(!pg_query($conn,$qry)) + { + $this->errormsg = "Encoding konnte nicht gesetzt werden"; + return false; + } + if($mail_id != null) + $this->load($mail_id); + } + + /** + * Laedt einen Datensatz + * @param mail_id ID des zu ladenden Datensatzes + */ + function load($mail_id) + { + //mail_id auf gueltigkeit pruefen + if(!is_numeric($mail_id) || $mail_id == '') + { + $this->errormsg = 'mail_id muss eine gueltige Zahl sein'; + return false; + } + + //laden des Datensatzes + $qry = "SELECT * FROM email WHERE email_pk='$mail_id';"; + + if(!$res = pg_query($this->conn,$qry)) + { + $this->errormsg = 'Fehler bei der Datenbankabfrage'; + return false; + } + + if($row=pg_fetch_object($res)) + { + $this->email_id = $row->email_pk; + $this->person_id = $row->person_fk; + $this->email = $row->email; + $this->name = $row->name; + $this->typ = $row->typ; + $this->zustelladresse = ($row->zustelladresse=='J'?true:false); + $this->updateamum = $row->creationdate; + $this->updatevon = $row->creationuser; + } + else + { + $this->errormsg = 'Fehler bei der Datenbankabfrage'; + return false; + } + + return true; + } + + /** + * Laedt alle Datensaetze + * @return true wenn ok, false im Fehlerfall + */ + function getAll() + { + /* Frisst zu viel Speicher und wird beendet + + $qry = "SELECT * FROM email;"; + + if(!$res = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Fehler bei einer Datenbankabfrage'; + return false; + } + + while($row = pg_fetch_object($res)) + { + $mail_obj = new email($this->conn); + + $mail_obj->email_id = $row->email_pk; + $mail_obj->person_id = $row->person_fk; + $mail_obj->email = $row->email; + $mail_obj->name = $row->name; + $mail_obj->typ = $row->typ; + $mail_obj->zustelladresse = ($row->zustelladresse=='J'?true:false); + $mail_obj->updateamum = $row->creationdate; + $mail_obj->updatevon = $row->creationuser; + + $this->result[] = $mail_obj; + } + + return true; + */ + return false; + } + + /** + * Laedt alle Datensaetze zu einer person + * @param pers_id ID der Person zu der die Mails geladen werden sollen + * @return true wenn ok, false im Fehlerfall + */ + function load_pers($pers_id) + { + //pers_id auf gueltigkeit pruefen + if(!is_numeric($pers_id) || $pers_id == '') + { + $this->errormsg = 'pers_id muss eine gueltige Zahl sein'; + return false; + } + + //Datensaetze laden + $qry = "SELECT * FROM email WHERE person_fk='$pers_id';"; + + if(!$result = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Fehler bei einer Datenbankabfrage'; + return false; + } + + while($row = pg_fetch_object($result)) + { + $mail_obj = new email($this->conn); + + $mail_obj->email_id = $row->email_pk; + $mail_obj->person_id = $row->person_fk; + $mail_obj->email = $row->email; + $mail_obj->name = $row->name; + $mail_obj->typ = $row->typ; + $mail_obj->zustelladresse = ($row->zustelladresse=='J'?true:false); + $mail_obj->updateamum = $row->creationdate; + $mail_obj->updatevon = $row->creationuser; + + $this->result[] = $mail_obj; + } + + return true; + } + + /** + * Loescht einen Datensatz + * @param mail_id ID des zu leoschenden Datensatzes + * @return true wenn ok, false im Fehlerfall + */ + function delete($mail_id) + { + //mail_id auf gueltigkeit pruefen + if(!is_numeric($mail_id) || $mail_id == '') + { + $this->errormsg = 'mail_id muss eine gueltige Zahl sein'; + return false; + } + + $qry = "DELETE FROM email WHERE email_pk = '$mail_id';"; + + if(pg_query($this->conn,$qry)) + { + //Log schreiben + $sql = $qry; + $qry = "SELECT nextval('log_seq') as id;"; + if(!$row = pg_fetch_object(pg_query($this->conn, $qry))) + { + $this->errormsg = 'Fehler beim Auslesen der Log-Sequence'; + return false; + } + + $qry = "INSERT INTO log(log_pk, creationdate, creationuser, sql) VALUES('$row->id', now(), '$this->updatevon', '".addslashes($sql)."')"; + if(pg_query($this->conn, $qry)) + return true; + else + { + $this->errormsg = 'Fehler beim Speichern des Log-Eintrages'; + return false; + } + } + else + { + $this->errormsg = 'Fehler beim loeschen'; + return false; + } + } + + /** + * Prueft die variablen auf gueltigkeit + * @return true wenn ok, false im Fehlerfall + */ + function checkvars() + { + //Gesamtlaenge pruefen + if(strlen($this->name)>255) + { + $this->errormsg = 'Name darf nicht mehr als 255 Zeichen lang sein'; + return false; + } + if(strlen($this->email)>255) + { + $this->errormsg = 'EMail darf nicht mehr als 255 Zeichen lang sein'; + return false; + } + + //Zahlenfelder pruefen + if(!is_numeric($this->person_id)) + { + $this->errormsg = 'Person_id muss eine gueltige Zahl sein'; + return false; + } + if(!is_numeric($this->typ)) + { + $this->errormsg = 'Typ muss eine gueltige Zahl sein'; + return false; + } + + $this->errormsg = ''; + return true; + } + + /** + * Speichert den aktuellen Datensatz + * Wenn $neu auf true gesetzt ist wird ein neuer Datensatz angelegt + * andernfalls wird der Datensatz mit der ID in $email_id aktualisiert + * @return true wenn ok, false im Fehlerfall + */ + function save() + { + if(!$this->checkvars()) + return false; + + if($this->new) + { + //Neuen Datensatz anlegen + + //Naechste ID aus Sequence holen + $qry = "SELECT nextval('email_seq') as id;"; + if(!$row=pg_fetch_object(pg_query($this->conn, $qry))) + { + $this->errormsg = 'Fehler beim auslesen der ID aus der Sequence'; + return false; + } + $this->email_id = $row->id; + + $qry = "INSERT INTO email (email_pk, person_fk, name, email, typ, creationdate, creationuser, zustelladresse)". + " VALUES ('$this->email_id', '$this->person_id', '$this->name', '$this->email', '$this->typ', now(),". + " $this->updatevon, '".($this->zustelladresse?'J':'N')."');"; + } + else + { + //Bestehenden Datensatz aktualisieren + + //email_id auf gueltigkeit pruefen + if(!is_numeric($this->email_id) || $this->email_id == '') + { + $this->errormsg = 'email_id muss eine gueltige Zahl sein'; + return false; + } + + $qry = "UPDATE email SET person_fk = '$this->person_id', name = '$this->name', email = '$this->email',". + " typ = '$this->typ', zustelladresse = '".($this->zustelladresse?'J':'N')."' WHERE email_pk = '$this->email_id';"; + } + + if(pg_query($this->conn, $qry)) + { + //Log schreiben + $sql = $qry; + $qry = "SELECT nextval('log_seq') as id;"; + if(!$row = pg_fetch_object(pg_query($this->conn, $qry))) + { + $this->errormsg = 'Fehler beim Auslesen der Log-Sequence'; + return false; + } + + $qry = "INSERT INTO log(log_pk, creationdate, creationuser, sql) VALUES('$row->id', now(), '$this->updatevon', '".addslashes($sql)."')"; + if(pg_query($this->conn, $qry)) + return true; + else + { + $this->errormsg = 'Fehler beim Speichern des Log-Eintrages'; + return false; + } + } + else + { + $this->errormsg = 'Fehler beim speichern des Datensatzes'; + return false; + } + } +} +?> \ No newline at end of file diff --git a/include/fas/fachbereich.class.php b/include/fas/fachbereich.class.php new file mode 100644 index 000000000..95f93716b --- /dev/null +++ b/include/fas/fachbereich.class.php @@ -0,0 +1,127 @@ +conn = $conn; + $qry = "SET CLIENT_ENCODING TO 'UNICODE';"; + if(!pg_query($conn,$qry)) + { + $this->errormsg = "Encoding konnte nicht gesetzt werden"; + return false; + } + if($fachb_id != null) + $this->load($fachb_id); + } + + /** + * Laedt alle verfuegbaren Fachbereiche + * @return true wenn ok, false im Fehlerfall + */ + function getAll() + { + $qry = 'SELECT * FROM fachbereich order by name;'; + + if(!$res = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Fehler beim laden der Datensaetze'; + return false; + } + + while($row = pg_fetch_object($res)) + { + $fachb_obj = new fachbereich($this->conn); + + $fachb_obj->fachbereich_id = $row->fachbereich_pk; + $fachb_obj->erhalter_id = $row->erhalter_fk; + $fachb_obj->name = $row->name; + $fachb_obj->updateamum = $row->creationdate; + $fachb_obj->updatevon = $row->creationuser; + + $this->result[] = $fachb_obj; + } + return true; + } + + /** + * Laedt einen Fachbereich + * @param $fachb_id ID des zu ladenden Fachbereiches + * @return true wenn ok, false im Fehlerfall + */ + function load($fachb_id) + { + if(!is_numeric($fachb_id) || $fachb_id == '') + { + $this->errormsg = 'fachb_id muss eine gueltige Zahl sein'; + return false; + } + + $qry = "SELECT * FROM fachbereich WHERE fachbereich_pk = '$fachb_id';"; + + if(!$res = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Fehler beim laden des Datensatzes'; + return false; + } + + if($row=pg_fetch_object($res)) + { + $this->fachbereich_id = $row->fachbereich_pk; + $this->erhalter_id = $row->erhalter_fk; + $this->name = $row->name; + $this->updateamum = $row->creationdate; + $this->updatevon = $row->creationuser; + } + else + { + $this->errormsg = 'Es ist kein Datensatz mit dieser ID vorhanden'; + return false; + } + + return true; + } + + /** + * Loescht einen Datensatz + * @param $fachb_id id des Datensatzes der geloescht werden soll + * @return true wenn ok, false im Fehlerfall + */ + function delete($fachb_id) + { + $this->errormsg = 'Noch nicht implementiert'; + return false; + } + + /** + * Speichert den aktuellen Datensatz + * @return true wenn ok, false im Fehlerfall + */ + function save() + { + $this->errormsg = 'Noch nicht implementiert'; + return false; + } +} +?> \ No newline at end of file diff --git a/include/fas/functions.inc.php b/include/fas/functions.inc.php new file mode 100644 index 000000000..8149dc00a --- /dev/null +++ b/include/fas/functions.inc.php @@ -0,0 +1,29 @@ +studiensemester_pk; + else + echo pg_last_error($conn_fas); + return $stsem_id; +} + + +?> \ No newline at end of file diff --git a/include/fas/funktion.class.php b/include/fas/funktion.class.php new file mode 100644 index 000000000..bd274e06e --- /dev/null +++ b/include/fas/funktion.class.php @@ -0,0 +1,691 @@ +conn = $conn; + $qry = "SET CLIENT_ENCODING TO 'UNICODE';"; + if(!pg_query($conn,$qry)) + { + $this->errormsg = "Encoding konnte nicht gesetzt werden"; + return false; + } + if($fkt_id != null) + $this->load($fkt_id); + } + + /** + * loescht die Funktion mit der uebergebenen ID + * @param $funktion_id ID des zu loeschenden Datensatzes + * @return true wenn ok, false im Fehlerfall + */ + function delete($funktion_id) + { + //Pruefen ob funktion_id gueltig ist + if(is_numeric($funktion_id) && $funktion_id != '') + { + //Person ermitteln + $person_id=0; + $mitarbeiter_id=0; + $qry = "Select person_fk, mitarbeiter_pk from mitarbeiter join funktion on(mitarbeiter_pk=mitarbeiter_fk) where funktion_pk = $funktion_id"; + if($row=pg_fetch_object(pg_query($this->conn,$qry))) + { + $person_id = $row->person_fk; + $mitarbeiter_id = $row->mitarbeiter_pk; + } + else + { + $this->errormsg = 'Fehler beim ermitteln der Person'; + return false; + } + + $qry = "DELETE FROM funktion WHERE funktion_pk=$funktion_id;"; + $sql = $qry; + if(pg_query($this->conn,$qry)) + { + //Neuen aktstatus ermitteln + $qry = "Select aktstatus from person where person_pk=$person_id"; + if($row=pg_fetch_object(pg_query($this->conn,$qry))) + { + $aktstatus = $row->aktstatus; + if($aktstatus!=150) //wenn er nicht ausgeschieden ist + { + //Funktionen holen + $qry = "Select funktion from funktion where ". + "studiensemester_fk = (Select studiensemester_pk from studiensemester where aktuell='J')". + " AND mitarbeiter_fk = '$mitarbeiter_id'"; + if($result = pg_query($this->conn, $qry)) + { + $fkt=array(); + $i=0; + while($row=pg_fetch_object($result)) + { + $fkt[$i]=$row->funktion; + $i++; + } + + //Aktstatus ermitteln + if(in_array(5,$fkt)) //STGL + $aktstatus = 104; + elseif(in_array(6,$fkt)) //FBL + $aktstatus = 103; + elseif(in_array(2,$fkt)) //FBK + $aktstatus = 102; + elseif(in_array(1,$fkt)) //LKT + $aktstatus = 101; + else + $aktstatus = 100; //Mitarbeiter + + $this->status = $aktstatus; + //neuen akstatus setzen + $qry = "Update person set aktstatus = $aktstatus where person_pk = $person_id"; + if(pg_query($qry)) + { + //Log schreiben + $sql .= $qry; + $qry = "SELECT nextval('log_seq') as id;"; + if(!$row = pg_fetch_object(pg_query($this->conn, $qry))) + { + $this->errormsg = 'Fehler beim Auslesen der Log-Sequence'; + return false; + } + + $qry = "INSERT INTO log(log_pk, creationdate, creationuser, sql) VALUES('$row->id', now(), '$this->updatevon', '".addslashes($sql)."')"; + if(pg_query($this->conn, $qry)) + return true; + else + { + $this->errormsg = 'Fehler beim Speichern des Log-Eintrages'; + return false; + } + } + else + { + $this->errormsg = 'Fehler beim setzen des Aktstatus'; + return false; + } + } + } + else + return true; + + } + else + { + $this->errormsg = 'Fehler beim Laden des aktuellen Status'; + return false; + } + } + else + { + $this->errormsg = 'Beim loeschen ist ein Fehler aufgetreten'; + return false; + } + } + else + { + $this->errormsg = 'funktion_id muss eine gueltige Zahl sein'; + return false; + } + } + + + /** + * Prueft die Variablen auf Gueltigkeit + * @return true wenn ok, false im Fehlerfall + */ + function checkvars() + { + //Hochkomma und HTML Tags ersetzen + //$this->name = htmlentities($this->name, ENT_QUOTES); + + //Maximallaenge pruefen + $this->errormsg = 'Die Maximallaenge eines Feldes wurde ueberschritten'; + if(strlen($this->name)>255) return false; + + //Zahlenwerte ueberpruefen + /* + $this->errormsg = 'Ein Zahlenfeld enthaelt ungueltige Zeichen'; + + if(!is_numeric($this->funktion)) return false; + if(!is_numeric($this->beschart1)) return false; + if(!is_numeric($this->beschart2)) return false; + if(!is_numeric($this->verwendung)) return false; + if(!is_numeric($this->hauptberuf)) return false; + if(!is_numeric($this->sws)) $this->sws=0; + if(!is_numeric($this->ausmass)) return false; + if(!is_numeric($this->mitarbeiter_id)) return false; + if(!is_numeric($this->erhalter_id)) return false; + if(!is_numeric($this->studiengang_id)) return false; + if(!is_numeric($this->fachbereich_id)) return false; + if(!is_numeric($this->studiensemester_id)) return false; + if(!is_numeric($this->besonderequalifikation)) return false; + */ + $this->errormsg = ''; + return true; + } + + /** + * Speichert die Daten in die Datenbank + * @return true wenn OK, false im Fehlerfall + */ + function save() + { + if(!$this->checkvars()) + return false; + + //neuen aktstatus ermitteln + if($status=$this->getaktstatus()) + $statusqry = "Update person SET aktstatus=$status where person_pk = (Select person_fk from mitarbeiter where mitarbeiter_pk='$this->mitarbeiter_id');"; + else + $statusqry = ""; + + if($this->new) + { + //Naechste ID aus der Sequence holen + $qry = "SELECT nextval('funktion_seq') as id;"; + if(!$row = pg_fetch_object(pg_query($this->conn,$qry))) + { + $this->errormsg = 'Sequence konnte nicht ausgelesen werden'; + return false; + } + $this->funktion_id = $row->id; + + $qry= $statusqry."INSERT INTO funktion (funktion_pk, mitarbeiter_fk, studiensemester_fk, erhalter_fk, studiengang_fk,". + " fachbereich_fk, name, funktion, creationdate, creationuser, beschart1, beschart2, verwendung,". + " hauptberuflich, hauptberuf, entwicklungsteam, besonderequalifikation, sws, ausmass) VALUES(". + " '$this->funktion_id','$this->mitarbeiter_id', '$this->studiensemester_id', '$this->erhalter_id',". + ($this->studiengang_id!=''?" '$this->studiengang_id'":'null').",". + ($this->fachbereich_id!=''?" '$this->fachbereich_id'":'null').",". + ($this->name!=''?" '$this->name'":'null').",". + ($this->funktion!=''?" '$this->funktion'":'null').", now(), $this->updatevon,". + ($this->beschart1!=''?" '$this->beschart1'":'null').",". + ($this->beschart2!=''?" '$this->beschart2'":'null').",". + ($this->verwendung!=''?" '$this->verwendung'":'null').", '".($this->hauptberuflich?'J':'N')."',". + ($this->hauptberuf!=''?" '$this->hauptberuf'":'null').", '".($this->entwicklungsteam?'J':'N')."',". + ($this->besonderequalifikation!=''?" '$this->besonderequalifikation'":'null').", null,". + ($this->ausmass!=''?" '$this->ausmass'":'null').")"; + + } + else + { + if(!is_numeric($this->mitarbeiter_id) && !is_numeric($this->funktion_id)) + { + $this->errormsg = 'mitarbeiter_id und funktion_id muessen eine gueltige Zahl sein'; + return false; + } + + $qry= $statusqry. "UPDATE funktion SET ". + " studiensemester_fk=".($this->studiensemester_id!=''?"'$this->studiensemester_id'":'null').",". + " erhalter_fk=".($this->erhalter_id!=''?"'$this->erhalter_id'":'null').",". + " studiengang_fk=".($this->studiengang_id!=''?"'$this->studiengang_id'":'null').",". + " fachbereich_fk=".($this->fachbereich_id!=''?"'$this->fachbereich_id'":'null').",". + " name=".($this->name!=''?"'$this->name'":'null').",". + " funktion=".($this->funktion!=''?"'$this->funktion'":'null').",". + " beschart1=".($this->beschart1!=''?"'$this->beschart1'":'null').",". + " beschart2=".($this->beschart2!=''?"'$this->beschart2'":'null').",". + " verwendung=".($this->verwendung!=''?"'$this->verwendung'":'null').",". + " hauptberuflich='".($this->hauptberuflich?'J':'N')."',". + " hauptberuf=".($this->hauptberuf!=''?"'$this->hauptberuf'":'null').",". + " entwicklungsteam='".($this->entwicklungsteam?'J':'N')."',". + " besonderequalifikation=".($this->besonderequalifikation!=''?"'$this->besonderequalifikation'":'null').",". + " sws=".($this->sws!=''?"'$this->sws'":'null').",". + " ausmass=".($this->ausmass!=''?"'$this->ausmass'":'null'). + " WHERE funktion_pk=$this->funktion_id"; // AND mitarbeiter_fk=$this->mitarbeiter_id"; + } + + if(pg_query($this->conn,$qry)) + { + $qry = "UPDATE funktion SET hauptberuflich='".($this->hauptberuflich?'J':'N')."', hauptberuf=".($this->hauptberuf!=''?"'$this->hauptberuf'":'null')." WHERE mitarbeiter_fk ='$this->mitarbeiter_id' AND studiensemester_fk='$this->studiensemester_id'"; + if(!pg_query($this->conn,$qry)) + { + $this->errormsg = 'Fehler beim Updaten der Funktionen'; + return false; + } + //Log schreiben + $sql = $qry; + $qry = "SELECT nextval('log_seq') as id;"; + if(!$row = pg_fetch_object(pg_query($this->conn, $qry))) + { + $this->errormsg = 'Fehler beim Auslesen der Log-Sequence'; + return false; + } + + $qry = "INSERT INTO log(log_pk, creationdate, creationuser, sql) VALUES('$row->id', now(), '$this->updatevon', '".addslashes($sql)."')"; + if(pg_query($this->conn, $qry)) + return true; + else + { + $this->errormsg = 'Fehler beim Speichern des Log-Eintrages'; + return false; + } + } + else + { + $this->errormsg = 'Fehler beim Speichern der Daten'.$qry; + return false; + } + } + + /** + * Ermittelt den neuen aktstatus einer Person + */ + function getaktstatus() + { + $aktstatus=100; + //Aktuellen Status holen + $qry = "Select aktstatus from person join mitarbeiter on(person_fk=person_pk) where mitarbeiter_pk='".$this->mitarbeiter_id."'"; + if($result = pg_query($this->conn,$qry)) + { + if($row = pg_fetch_object($result)) + $aktstatus = $row->aktstatus; + else + { + $this->errormsg = 'Fehler beim Laden des aktuellen Status'; + return false; + } + } + else + { + $this->errormsg = 'Fehler beim Laden des aktuellen Status'; + return false; + } + + /* + //Wenn die Funktion das aktuelle Studiensemester betrifft + $qry = "Select studiensemester_pk from studiensemester where aktuell='J'"; + if($result = pg_query($this->conn,$qry)) + { + if($row=pg_fetch_object($result)) + { + if($row->studiensemester_pk == $this->studiensemester_id) + { + */ + //Neuen Status setzen + if($this->funktion == 1 && $aktstatus < 101) //Lektor + $aktstatus = 101; + elseif($this->funktion == 2 && $aktstatus < 102) //Fachbereichskoordinator + $aktstatus = 102; + elseif($this->funktion == 6 && $aktstatus < 103) //Fachbereichsleiter + $aktstatus = 103; + elseif($this->funktion == 5 && $aktstatus < 104) //Studiengangsleiter + $aktstatus = 104; + /* } + } + else + { + $this->errormsg = 'Fehler beim Laden des aktuellen Studiensemesters'; + return false; + } + } + else + { + $this->errormsg = 'Fehler beim Laden des aktuellen Studiensemesters'; + return false; + }*/ + $this->status = $aktstatus; + return $aktstatus; + } + + /** + * Laedt eine Funktion aus der DB + * @param $fkt_id ID der zu ladenden Funktion + * @return true wenn erfolgreich geladen, false im Fehlerfall + */ + function load($fkt_id) + { + //Pruefen ob fkt_id gueltig ist + if(!is_numeric($fkt_id)) + { + $this->errormsg = 'funktion_id muss eine Zahl sein'; + return false; + } + + $qry = "SELECT * FROM funktion WHERE funktion_pk=$fkt_id"; + + if(!$res = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Fehler bei einer Datenbankabfrage'; + return false; + } + + if($row = pg_fetch_object($res)) + { + $this->funktion_id = $row->funktion_pk; + $this->mitarbeiter_id = $row->mitarbeiter_fk; + $this->studiensemester_id = $row->studiensemester_fk; + $this->erhalter_id = $row->erhalter_fk; + $this->studiengang_id = $row->studiengang_fk; + $this->fachbereich_id = $row->fachbereich_fk; + $this->name = $row->name; + $this->funktion = $row->funktion; + $this->updateamum = $row->creationdate; + $this->updatevon = $row->creationuser; + $this->beschart1 = $row->beschart1; + $this->beschart2 = $row->beschart2; + $this->verwendung = $row->verwendung; + $this->hauptberuflich = ($row->hauptberuflich=='J'?true:false); + $this->hauptberuf = $row->hauptberuf; + $this->entwicklungsteam = ($row->entwicklungsteam=='J'?true:false); + $this->besonderequalifikation = $row->besonderequalifikation; + $this->sws = $row->sws; + $this->ausmass = $row->ausmass; + } + else + { + $this->errormsg = 'Es ist kein Datensatz mit dieser ID vorhanden'; + return false; + } + + return true; + } + + /** + * Laedt die Funktion(en) eines Mitarbeiters + * @param $ma_id ID des zu ladenden Mitarbeiters + * @return true wenn erfolgreich geladen, false im Fehlerfall + */ + function load_pers($ma_id, $stsem='') + { + //pruefen ob ma_id gueltig ist + if(!is_numeric($ma_id)) + { + $this->errormsg = 'mitarbeiter_id muss eine Zahl sein'; + return false; + } + + $qry="SELECT * FROM funktion WHERE mitarbeiter_fk=$ma_id"; + if($stsem!='') + $qry.= " AND studiensemester_fk='$stsem'"; + $qry.=" ORDER BY studiensemester_fk DESC, funktion_pk"; + if(!$res = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Fehler bei einer Datenbankabfrage'; + return false; + } + + while($row = pg_fetch_object($res)) + { + $fkt_obj = new funktion($this->conn); + + $fkt_obj->funktion_id = $row->funktion_pk; + $fkt_obj->mitarbeiter_id = $row->mitarbeiter_fk; + $fkt_obj->studiensemester_id = $row->studiensemester_fk; + $fkt_obj->erhalter_id = $row->erhalter_fk; + $fkt_obj->studiengang_id = $row->studiengang_fk; + $fkt_obj->fachbereich_id = $row->fachbereich_fk; + $fkt_obj->name = $row->name; + $fkt_obj->funktion = $row->funktion; + $fkt_obj->updateamum = $row->creationdate; + $fkt_obj->updatevon = $row->creationuser; + $fkt_obj->beschart1 = $row->beschart1; + $fkt_obj->beschart2 = $row->beschart2; + $fkt_obj->verwendung = $row->verwendung; + $fkt_obj->hauptberuflich = ($row->hauptberuflich=='J'?true:false); + $fkt_obj->hauptberuf = $row->hauptberuf; + $fkt_obj->entwicklungsteam = ($row->entwicklungsteam=='J'?true:false); + $fkt_obj->besonderequalifikation = $row->besonderequalifikation; + $fkt_obj->sws = $row->sws; + $fkt_obj->ausmass = $row->ausmass; + + $this->result[] = $fkt_obj; + } + + return true; + } + + function getMitarbeiter($stg,$fb,$funktion,$stsem=null) + { + $qry = "SELECT + mitarbeiter_fk + FROM + funktion + WHERE + studiengang_fk='$stg' AND + fachbereich_fk='$fb' + GROUP BY mitarbeiter_fk"; + if($result = pg_query($this->conn,$qry)) + { + while($row = pg_fetch_object($result)) + { + $fkt = new funktion($this->conn); + $fkt->mitarbeiter_id = $row->mitarbeiter_fk; + $this->result[] = $fkt; + } + return true; + } + else + { + $this->errormsg = 'Fehler beim laden der Mitarbeiter'; + return false; + } + } + + /** + * Laedt alle Funktionen + * @return true wenn erfolgreich geladen, false im Fehlerfall + */ + function getAll() + { + /*Eventuell Speicherprobleme + + $qry = "SELECT * FROM funktion"; + + if(!$res = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Fehler bei einer Datenbankabfrage'; + return false; + } + + while($row=pg_fetch_object($res)) + { + $fkt_obj = new funktion($this->conn); + + $fkt_obj->funktion_id = $row->funktion_pk; + $fkt_obj->mitarbeiter_id = $row->mitarbeiter_fk; + $fkt_obj->studiensemester_id = $row->studiensemester_fk; + $fkt_obj->erhalter_id = $row->erhalter_fk; + $fkt_obj->studiengang_id = $row->studiengang_fk; + $fkt_obj->fachbereich_id = $row->fachbereich_fk; + $fkt_obj->name = $row->name; + $fkt_obj->funktion = $row->funktion; + $fkt_obj->updateamum = $row->creationdate; + $fkt_obj->updatevon = $row->creationuser; + $fkt_obj->beschart1 = $row->beschart1; + $fkt_obj->beschart2 = $row->beschart2; + $fkt_obj->verwendung = $row->verwendung; + $fkt_obj->hauptberuflich = ($row->hauptberuflich=='J'?true:false); + $fkt_obj->hauptberuf = $row->hauptberuf; + $fkt_obj->entwicklungsteam = ($row->entwicklungsteam=='J'?true:false); + $fkt_obj->besonderequalifikation = $row->besonderequalifikation; + $fkt_obj->sws = $row->sws; + $fkt_obj->ausmass = $row->ausmass; + + $this->result[] = $fkt_obj; + } + return true; + */ + return false; + } + + function FunktionExists($mitarbeiter_id, $studiengang_id, $fachbereich_id, $studiensemester_id, $funktion) + { + $qry = "SELECT + count(*) as anzahl + FROM + funktion + WHERE + mitarbeiter_fk='$mitarbeiter_id' AND + studiengang_fk='$studiengang_id' AND + fachbereich_fk='$fachbereich_id' AND + studiensemester_fk = '$studiensemester_id' AND + funktion='$funktion'"; + if($result = pg_query($this->conn, $qry)) + { + if($row = pg_fetch_object($result)) + { + if($row->anzahl>0) + return true; + else + { + return false; + } + } + else + { + return false; + $this->errormsg = 'Fehler beim auslesen der Funktionen'; + } + } + else + { + return false; + $this->errormsg = 'Fehler beim auslesen der Funktionen'; + } + } + + function getNameFunktion($id) + { + switch($id) + { + case 0: return 'Mitarbeiter'; + case 1: return 'Lektor'; + case 2: return 'Fachbereichskoordinatior'; + case 3: return 'Assistenz'; + case 4: return 'Rektor'; + case 5: return 'Studiengangsleiter'; + case 6: return 'Fachbereichsleiter'; + default: return ''; + } + } + + function getNameBeschart1($id) + { + switch($id) + { + case 1: return 'Dienstverhältnis zum Bund'; + case 2: return 'Dienstverhältnis zu einer anderen Gebietskörperschaft'; + case 3: return 'Echter Dienstvertrag'; + case 4: return 'Freier Dienstvertrag'; + case 5: return 'Lehr- oder Ausbildungsverhältnis'; + case 6: return 'Sonstiges Beschäftigungsverhältnis'; + default: return ''; + } + } + + function getNameBeschart2($id) + { + switch($id) + { + case 1: return 'befristet'; + case 2: return 'unbefristet'; + default: return ''; + } + } + + function getNameVerwendung($id) + { + switch($id) + { + case 1: return 'Lehr- und Forschungspersonal'; + case 2: return 'Lehr- und Forschungshilfspersonal'; + case 3: return 'Akademische dienste für Studierende'; + case 4: return 'Soziale Dienste und Gesundheitsdienste'; + case 5: return 'Studiengangsleiter/in'; + case 6: return 'Leiter/in FH-Kollegium'; + case 7: return 'Management'; + case 8: return 'Verwaltung'; + case 9: return 'Hauspersonal, Gebäude-/Haustechnik'; + default: return ''; + } + + } + + function getNameHauptberuf($id) + { + switch($id) + { + case '': return ''; + case 0: return 'Universität'; + case 1: return 'Fachhochschule'; + case 2: return 'Andere postsekundäre Bildungseinrichtung'; + case 3: return 'Allgemeinbildende höhere Schule'; + case 4: return 'Berufsbildende höhere Schule'; + case 5: return 'Andere Schule'; + case 6: return 'Öffentlicher Sektor'; + case 7: return 'Unternehmenssektor'; + case 8: return 'Freiberuflich tätig'; + case 9: return 'Privater gemeinnütziger Sektor'; + case 10: return 'Ausserhochschulische Forschungseinrichtung'; + case 11: return 'Internationale Organisation'; + case 12: return 'Sonstiges'; + default: return ''; + } + } + + function getNameBesonderequalifikation($id) + { + switch($id) + { + case 0: return 'keine'; + case 1: return 'Habilitation'; + case 2: return 'der Habilitation gleichwertige Qualifikation'; + case 3: return 'berufliche Tätigkeit'; + default: return ''; + } + } + + function getNameAusmass($id) + { + switch($id) + { + case 1: return 'Vollzeit'; + case 2: return '<= 15 Wochenstunden'; + case 3: return '16 - 25 Wochenstunden'; + case 4: return '26 - 35 Wochenstunden'; + case 5: return 'Karenz'; + default: return ''; + } + } +} +?> \ No newline at end of file diff --git a/include/fas/gruppe.class.php b/include/fas/gruppe.class.php new file mode 100644 index 000000000..c9f49216e --- /dev/null +++ b/include/fas/gruppe.class.php @@ -0,0 +1,202 @@ +conn = $conn; + $qry = "SET CLIENT_ENCODING TO 'UNICODE';"; + if(!pg_query($conn,$qry)) + { + $this->errormsg = "Encoding konnte nicht gesetzt werden"; + return false; + } + if($gruppe_id != null) + $this->load($gruppe_id); + } + + /** + * Laedt eine Gruppe + * @param gruppe_id ID der Gruppe + * @return true wenn ok, false im Fehlerfall + */ + function load($gruppe_id) + { + //gruppe_id auf gueltigkeit pruefen + if(!is_numeric($gruppe_id) || $gruppe_id =='') + { + $this->errormsg = 'gruppe_id muss eine gueltige Zahl sein'; + return false; + } + + $qry = "SELECT * FROM gruppe WHERE gruppe_pk='$gruppe_id';"; + + if(!$res = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Datensatz konnte nicht geladen werden'; + return false; + } + + if($row = pg_fetch_object($res)) + { + $this->ausbildungssemester_id = $row->ausbildungssemester_fk; + $this->gruppe_id = $row->gruppe_pk; + $this->name = $row->name; + $this->nummerintern = $row->nummerintern; + $this->obergruppe_id = $row->obergruppe_fk; + $this->ordnung = $row->ordnung; + $this->studiengang_id = $row->studiengang_fk; + $this->typ = $row->typ; + $this->updateamum = $row->creationdate; + $this->updatevon = $row->creationuser; + + $this->fullname = $this->getFullName($row->gruppe_pk); + } + else + { + $this->errormsg = 'Datensatz konnte nicht geladen werden'; + return false; + } + + return true; + } + + /** + * Liefert den vollen namen einer Gruppe + * @param $gruppe_id + * @return voller name, false im Fehlerfall + */ + function getFullName($gruppe_id) + { + //gruppe_id auf gueltigkeit pruefen + if(!is_numeric($gruppe_id) || $gruppe_id == '') + { + $this->errormsg = 'gruppe_id muss eine gueltige Zahl sein'; + return false; + } + + //gesamten gruppennamen ermitteln + $qry = "SELECT fas_function_get_fullname_from_gruppe($gruppe_id) as fullname;"; + + if(!$row = pg_fetch_object(pg_query($this->conn, $qry))) + { + $this->errormsg = 'Gruppenname konnte nicht ermittelt werden'; + return false; + } + + return $row->fullname; + } + + /** + * Laedt alle Gruppen eines Studienganges/studiensemesters/ausbildungssemesters + * @param studiengang_id ID des studienganges + * studiensemester_id ID des Studiensemesters (optional) + * ausbildungssemester_id ID des Ausbildungssemesters (optional) + * @return true wenn ok, false im Fehlerfall + */ + function load_gruppen($studiengang_id, $studiensemester_id=null, $ausbildungssemester_id=null) + { + //Pruefen ob gueltige Werte uebergeben wurden + if(!is_numeric($studiengang_id) || $studiengang_id == '') + { + $this->errormsg = 'studiengang_id muss eine gueltige Zahl sein'; + return false; + } + + if($studiensemester_id!=null && (!is_numeric($studiensemester_id) || $studiensemester_id == '')) + { + $this->errormsg = 'studiensemester_id muss eine gueltige Zahl sein'; + return false; + } + + if($ausbildungssemester_id!=null && (!is_numeric($ausbildungssemester_id) || $ausbildungssemester_id == '')) + { + $this->errormsg = 'ausbildungssemester_id muss eine gueltige Zahl sein'; + return false; + } + + //Befehl zusammenbauen + $qry = "SELECT * FROM gruppe WHERE studiengang_fk='$studiengang_id' "; + + if($ausbildungssemester_id!=null) + $qry .= "AND ausbildungssemester_fk='$ausbildungssemester_id' "; + + if($studiensemester_id != null) + $qry .= "AND studiensemester_fk='$studiensemester_id' "; + + if(!$res = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Datensatz konnte nicht geladen werden'; + return false; + } + //Daten laden + while($row = pg_fetch_object($res)) + { + $grp_obj = new gruppe($this->conn); + + $grp_obj->ausbildungssemester_id = $row->ausbildungssemester_fk; + $grp_obj->gruppe_id = $row->gruppe_pk; + $grp_obj->name = $row->name; + $grp_obj->nummerintern = $row->nummerintern; + $grp_obj->obergruppe_id = $row->obergruppe_fk; + $grp_obj->ordnung = $row->ordnung; + $grp_obj->studiengang_id = $row->studiengang_fk; + $grp_obj->typ = $row->typ; + $grp_obj->updateamum = $row->creationdate; + $grp_obj->updatevon = $row->creationuser; + + $grp_obj->fullname = $this->getFullName($row->gruppe_pk); + + $this->result[] = $grp_obj; + } + + return true; + } + + /** + * Speichert den aktuellen Datensatz in die DB + * @return true wenn ok, false im Fehlerfall + */ + function save() + { + $this->errormsg = 'Noch nicht implementiert'; + return false; + } + + /** + * Loescht einen Datensatz + * @param $gruppe_id ID des zu loeschenden Datensatzes + * @return true wenn ok, false im Fehlerfall + */ + function delete($gruppe_id) + { + $this->errormsg = 'Noch nicht implementiert'; + return false; + } +} +?> \ No newline at end of file diff --git a/include/fas/lehreinheit.class.php b/include/fas/lehreinheit.class.php new file mode 100644 index 000000000..b7077575a --- /dev/null +++ b/include/fas/lehreinheit.class.php @@ -0,0 +1,1588 @@ +conn = $conn; + $qry = "SET CLIENT_ENCODING TO 'UNICODE';"; + if(!pg_query($conn,$qry)) + { + $this->errormsg = "Encoding konnte nicht gesetzt werden"; + return false; + } + if($lehreinheit_id != null) + $this->load($lehreinheit_id); + } + + /** + * Laedt einen Datensatz + * @param $lehreinheit_id ID des zu ladenden Datensatzes + * @return true wenn ok, false im Fehlerfall + */ + function load($lehreinheit_id) + { + if(!is_numeric($lehreinheit_id) || $lehreinheit_id == '') + { + $this->errormsg = 'lehreinheit_id muss eine gueltige Zahl sein'; + return false; + } + + $qry = "SELECT * FROM lehreinheit WHERE lehreinheit_pk = '$lehreinheit_id'"; + + if(!$res = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Datensatz konnte nicht geladen werden'; + return false; + } + + if($row = pg_fetch_object($res)) + { + $this->lehreinheit_id = $row->lehreinheit_pk; + $this->studiengang_id = $row->studiengang_fk; + $this->studiensemester_id = $row->studiensemester_fk; + $this->ausbildungssemester_id = $row->ausbildungssemester_fk; + $this->fachbereich_id = $row->fachbereich_fk; + $this->gruppe_id = $row->gruppe_fk; + $this->koordinator_id = $row->bivar1; + $this->lehrform_id = $row->lehrform_fk; + $this->lehrveranstaltung_id = $row->lehrveranstaltung_fk; + $this->raumtyp_id = $row->raumtyp_fk; + $this->raumtypalternativ_id = $row->alternativraumtyp_fk; + $this->bemerkungen = $row->bemerkungen; + $this->bezeichnung = $row->bezeichnung; + $this->gesamtstunden = $row->gesamtstunden; + $this->kurzbezeichnung = $row->kurzbezeichnung; + $this->nummer = $row->nummer; + $this->planfaktor = $row->planfaktor; + $this->plankostenprolektor = $row->plankostenprolektor; + $this->planlektoren = $row->planlektoren; + $this->semesterwochenstunden = $row->semesterwochenstunden; + $this->start_kw = $row->ivar2; + $this->stundenblockung = $row->ivar3; + $this->updateamum = $row->creationdate; + $this->updatevon = $row->creationuser; + $this->wochenrythmus = $row->ivar1; + } + else + { + $this->errormsg = 'Datensatz konnte nicht geladen werden'; + return false; + } + return true; + } + + /** + * Laedt eine / mehrere Lehreinheit(en) + * @param $studiengang_id ID des zu ladenden Studienganges + * $studiensemester_id ID des zu ladenden Studiensemesters (optional) + * $ausbildungssemester_id ID des zu ladenden Ausbildungssemesters (optional) + * $lehrform_id ID der zu ladenden Lehrform (optional) + * @return true wenn ok, false im Fehlerfall + */ + function load_einheit($studiengang_id, $studiensemester_id=null, $ausbildungssemester_id=null, $lehrform_id=null) + { + //Gueltigkeit der Parameter pruefen + if(!is_numeric($studiengang_id) || $studiengang_id == '') + { + $this->errormsg = 'studiengang_id muss eine gueltige Zahl sein'; + return false; + } + if($studiensemester_id!=null && (!is_numeric($studiensemester_id) || $studiensemester_id == '')) + { + $this->errormsg = 'studiensemester_id muss eine gueltige Zahl oder null sein'; + return false; + } + if($ausbildungssemester_id!=null && (!is_numeric($ausbildungssemester_id) || $ausbildungssemester_id == '')) + { + $this->errormsg = 'ausbildungssemester_id muss eine gueltige Zahl oder null sein'; + return false; + } + if($lehrform_id!=null && (!is_numeric($lehrform_id) || $lehrform_id == '')) + { + $this->errormsg = 'lehrform_id muss eine gueltige Zahl oder null sein'; + return false; + } + + //Select Befehl zusammenbauen + $qry = "SELECT * FROM lehreinheit WHERE studiengang_fk = '$studiengang_id'"; + + if($studiensemester_id != null) + $qry .= " AND studiensemester_fk = '$studiensemester_id'"; + + if($ausbildungssemester_id != null) + $qry .= " AND ausbildungssemester_fk = '$ausbildungssemester_id'"; + + if($lehrform_id != null) + $qry .= " AND lehrform_fk = '$lehrform_id'"; + + //Daten auslesen + if(!$res = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Datensatz konnte nicht geladen werden'; + return false; + } + + while($row = pg_fetch_object($res)) + { + $einh_obj = new lehreinheit($this->conn); + + $einh_obj->lehreinheit_id = $row->lehreinheit_pk; + $einh_obj->studiengang_id = $row->studiengang_fk; + $einh_obj->studiensemester_id = $row->studiensemester_fk; + $einh_obj->ausbildungssemester_id = $row->ausbildungssemester_fk; + $einh_obj->fachbereich_id = $row->fachbereich_fk; + $einh_obj->gruppe_id = $row->gruppe_fk; + $einh_obj->koordinator_id = $row->bivar1; + $einh_obj->lehrform_id = $row->lehrform_fk; + $einh_obj->lehrveranstaltung_id = $row->lehrveranstaltung_fk; + $einh_obj->raumtyp_id = $row->raumtyp_fk; + $einh_obj->raumtypalternativ_id = $row->alternativraumtyp_fk; + $einh_obj->bemerkungen = $row->bemerkungen; + $einh_obj->bezeichnung = $row->bezeichnung; + $einh_obj->gesamtstunden = $row->gesamtstunden; + $einh_obj->kurzbezeichnung = $row->kurzbezeichnung; + $einh_obj->nummer = $row->nummer; + $einh_obj->planfaktor = $row->planfaktor; + $einh_obj->plankostenprolektor = $row->plankostenprolektor; + $einh_obj->planlektoren = $row->planlektoren; + $einh_obj->semesterwochenstunden = $row->semesterwochenstunden; + $einh_obj->start_kw = $row->ivar2; + $einh_obj->stundenblockung = $row->ivar3; + $einh_obj->updateamum = $row->creationdate; + $einh_obj->updatevon = $row->creationuser; + $einh_obj->wochenrythmus = $row->ivar1; + + $this->result[] = $einh_obj; + } + return true; + } + + /** + * Prueft die Variablen auf Gueltigkeit + * Hochkomma und HTML Tags werden ersetzt + * @return true wenn ok, false im Fehlerfall + */ + function checkvars() + { + + //Hochkomma und HTML Tags codieren + $this->nummer = str_replace("'","`",$this->nummer); + $this->bezeichnung = str_replace("'","`",$this->bezeichnung); + $this->kurzbezeichnung = str_replace("'","`",$this->kurzbezeichnung); + $this->bemerkungen = str_replace("'","`",$this->bemerkungen); + + if(ereg("[^a-zA-Z0-9]", $this->kurzbezeichnung)) + { + $this->errormsg = "Die Kurzbezeichnung darf keine Umlaute oder Sonderzeichen enthalten"; + return false; + } + + //Gesamtlaenge pruefen + if(strlen($this->nummer)>20) + { + $this->errormsg = 'Nummer darf nicht laenger als 20 Zeichen sein'; + return false; + } + if(strlen($this->bezeichnung)>255) + { + $this->errormsg = 'Bezeichnung darf nicht laenger als 255 Zeichen sein'; + return false; + } + if(strlen($this->kurzbezeichnung)>5) + { + $this->errormsg = 'Kurzbezeichnung darf nicht laenger als 5 Zeichen sein'; + return false; + } + if(strlen($this->bemerkungen)>255) + { + $this->errormsg = 'Bemerkung darf nicht laenger als 255 Zeichen sein'; + return false; + } + + //Zahlenfelder pruefen + if(!is_numeric($this->studiengang_id)) + { + $this->errormsg = 'Studiengang ist ungueltig'; + return false; + } + if(!is_numeric($this->studiensemester_id)) + { + $this->errormsg = 'Studiensemester ist ungueltig'; + return false; + } + if($this->lehrveranstaltung_id!='' && !is_numeric($this->lehrveranstaltung_id)) + { + $this->errormsg = 'Lehrveranstaltung_id ist ungueltig'; + return false; + } + if($this->fachbereich_id!='' && !is_numeric($this->fachbereich_id)) + { + $this->errormsg = 'Fachbereich_id ist ungueltig'; + return false; + } + if($this->ausbildungssemester_id !='' && !is_numeric($this->ausbildungssemester_id)) + { + $this->errormsg = 'Ausbildungssemester_id ist ungueltig'; + return false; + } + if($this->lehrform_id!='' && !is_numeric($this->lehrform_id)) + { + $this->errormsg = 'Lehrform_id ist ungueltig'; + return false; + } + if($this->lehreinheit_fk!='' && !is_numeric($this->lehreinheit_fk)) + { + $this->errormsg = 'Lehreinheit_fk ist ungueltig'; + return false; + } + if($this->gruppe_id!='' && !is_numeric($this->gruppe_id)) + { + $this->errormsg = 'Gruppe ist ungueltig'; + return false; + } + if($this->semesterwochenstunden!='' && !is_numeric($this->semesterwochenstunden)) + { + $this->errormsg = 'Semesterwochenstunden muessen eine gueltige Zahl sein'; + return false; + } + if($this->gesamtstunden!='' && !is_numeric($this->gesamtstunden)) + { + $this->errormsg = 'Gesamtstunden muessen eine gueltige Zahl sein'; + return false; + } + if($this->plankostenprolektor!='' && !is_numeric($this->plankostenprolektor)) + { + $this->errormsg = 'Kosten pro Lektor muss eine gueltige Zahl sein'; + return false; + } + if($this->planfaktor!='' && !is_numeric($this->planfaktor)) + { + $this->errormsg = 'Geplanter Faktor muss eine gueltige Zahl sein'; + return false; + } + if($this->planlektoren!='' && !is_numeric($this->planlektoren)) + { + $this->errormsg = 'Anzahl der Lektoren muss eine gueltige Zahl sein'; + return false; + } + if($this->raumtyp_id!='' && !is_numeric($this->raumtyp_id)) + { + $this->errormsg = 'Raumtyp ist ungueltig'; + return false; + } + if($this->raumtypalternativ_id!='' && !is_numeric($this->raumtypalternativ_id)) + { + $this->errormsg = 'Alternativraumtyp ist ungueltig'; + return false; + } + if($this->wochenrythmus!='' && !is_numeric($this->wochenrythmus)) + { + $this->errormsg = 'Wochenrythmus muss eine gueltige Zahl sein'; + return false; + } + if($this->start_kw!='' && !is_numeric($this->start_kw)) + { + $this->errormsg = 'Kalenderwoche muss eine gueltige Zahl sein'; + return false; + } + if($this->stundenblockung!='' && !is_numeric($this->stundenblockung)) + { + $this->errormsg = 'Stundenblockung muss eine gueltige Zahl sein'; + return false; + } + if($this->koordinator_id!='' && !is_numeric($this->koordinator_id)) + { + $this->errormsg = 'Koordinator ist ungueltig'; + return false; + } + + $this->errormsg = ''; + return true; + } + + /** + * Speichert den aktuellen Datensatz + * Wenn new auf true gesetzt ist wird ein neuer Datensatz angelegt + * ansonsten wird der datensatz mit der ID lehreinheit_id aktualisiert + * @return true wenn ok, false im Fehlerfall + */ + function save() + { + //Variablen pruefen + if(!$this->checkvars()) + return false; + + if($this->new) + { + //Neuen Datensatz anlegen + + //naechste ID aus Sequence holen + $qry = "SELECT nextval('lehreinheit_seq') as id;"; + if(!$row = pg_fetch_object(pg_query($this->conn, $qry))) + { + $this->errormsg = 'Fehler beim auslesen der Sequence'; + return false; + } + $this->lehreinheit_id = $row->id; + + //Insert Befehl zusammenbauen + $qry = "INSERT INTO lehreinheit (lehreinheit_pk, studiengang_fk, studiensemester_fk, lehrveranstaltung_fk,". + " fachbereich_fk, ausbildungssemester_fk, lehreinheit_fk, lehrform_fk, gruppe_fk, nummer, bezeichnung,". + " kurzbezeichnung, semesterwochenstunden, gesamtstunden, plankostenprolektor, planfaktor, planlektoren,". + " raumtyp_fk, alternativraumtyp_fk, bemerkungen, ivar1, ivar2, ivar3, bivar1, creationdate, creationuser)". + " VALUES('$this->lehreinheit_id', '$this->studiengang_id', '$this->studiensemester_id',". + ($this->lehrveranstaltung_id!=''?" '$this->lehrveranstaltung_id'":" null").",". + ($this->fachbereich_id!=''?" '$this->fachbereich_id'":" null").",". + ($this->ausbildungssemester_id!=''?" '$this->ausbildungssemester_id'":" null").",". + ($this->lehreinheit_fk!=''?" '$this->lehreinheit_fk'":" null").",". + ($this->lehrform_id!=''?" '$this->lehrform_id'":" null").",". + ($this->gruppe_id!=''?" '$this->gruppe_id'":" null").",". + ($this->nummer!=''?" '$this->nummer'":" null").",". + ($this->bezeichnung!=''?" '$this->bezeichnung'":" null").",". + ($this->kurzbezeichnung!=''?" '$this->kurzbezeichnung'":" null").",". + ($this->semesterwochenstunden!=''?" '$this->semesterwochenstunden'":" null").",". + ($this->gesamtstunden!=''?" '$this->gesamtstunden'":" null").",". + ($this->plankostenprolektor!=''?" '$this->plankostenprolektor'":" null").",". + ($this->planfaktor!=''?" '$this->planfaktor'":" null").",". + ($this->planlektoren!=''?" '$this->planlektoren'":" null").",". + ($this->raumtyp_id!=''?" '$this->raumtyp_id'":" null").",". + ($this->raumtypalternativ_id!=''?" '$this->raumtypalternativ_id'":" null").",". + ($this->bemerkungen!=''?" '$this->bemerkungen'":" null").",". + ($this->wochenrythmus!=''?" '$this->wochenrythmus'":" null").",". + ($this->start_kw!=''?" '$this->start_kw'":" null").",". + ($this->stundenblockung!=''?" '$this->stundenblockung'":" null").",". + ($this->koordinator_id!=''?" '$this->koordinator_id'":" null").", now(),$this->updatevon);"; + } + else + { + //lehreinheit_id auf gueltigkeit pruefen + if(!is_numeric($this->lehreinheit_id) || $this->lehreinheit_id == '') + { + $this->errormsg = 'lehreinheit_id muss eine gueltige Zahl sein'; + return false; + } + + //Update Befehl zusammenbauen + $qry = "UPDATE lehreinheit SET". + " studiengang_fk = '$this->studiengang_id',". + " studiensemester_fk = '$this->studiensemester_id',". + " lehrveranstaltung_fk = '$this->lehrveranstaltung_id',". + " fachbereich_fk = ".($this->fachbereich_id!=''?"'$this->fachbereich_id'":"null").",". + " ausbildungssemester_fk = ".($this->ausbildungssemester_id!=''?"'$this->ausbildungssemester_id'":"null").",". + " lehreinheit_fk = ".($this->lehreinheit_fk!=''?"'$this->lehreinheit_fk'":"null").",". + " lehrform_fk = ".($this->lehrform_id!=''?"'$this->lehrform_id'":"null").",". + " gruppe_fk = ".($this->gruppe_id!=''?"'$this->gruppe_id'":"null").",". + " nummer = '$this->nummer',". + " bezeichnung = '$this->bezeichnung',". + " kurzbezeichnung = '$this->kurzbezeichnung',". + " semesterwochenstunden = ".($this->semesterwochenstunden!=''?"'$this->semesterwochenstunden'":"null").",". + " gesamtstunden = ".($this->gesamtstunden!=''?"'$this->gesamtstunden'":"null").",". + " plankostenprolektor = ".($this->plankostenprolektor!=''?"'$this->plankostenprolektor'":"null").",". + " planfaktor = ".($this->planfaktor!=''?"'$this->planfaktor'":"null").",". + " planlektoren = ".($this->planlektoren!=''?"'$this->planlektoren'":"null").",". + " raumtyp_fk = ".($this->raumtyp_id!=''?"'$this->raumtyp_id'":"null").",". + " alternativraumtyp_fk = ".($this->raumtypalternativ_id!=''?"'$this->raumtypalternativ_id'":"null").",". + " bemerkungen = '$this->bemerkungen',". + " ivar1 = ".($this->wochenrythmus!=''?"'$this->wochenrythmus'":"null").",". + " ivar2 = ".($this->start_kw!=''?"'$this->start_kw'":"null").",". + " ivar3 = ".($this->stundenblockung!=''?"'$this->stundenblockung'":"null").",". + " bivar1= ".($this->koordinator_id!=''?"'$this->koordinator_id'":"null"). + " WHERE lehreinheit_pk = '$this->lehreinheit_id';"; + } + + if(pg_query($this->conn, $qry)) + { + //Log schreiben + $sql = $qry; + $qry = "SELECT nextval('log_seq') as id;"; + if(!$row = pg_fetch_object(pg_query($this->conn, $qry))) + { + $this->errormsg = 'Fehler beim Auslesen der Log-Sequence'; + return false; + } + + $qry = "INSERT INTO log(log_pk, creationdate, creationuser, sql) VALUES('$row->id', now(), '$this->updatevon', '".addslashes($sql)."')"; + if(pg_query($this->conn, $qry)) + return true; + else + { + $this->errormsg = 'Fehler beim Speichern des Log-Eintrages'; + return false; + } + } + else + { + $this->errormsg = 'Fehler beim Speichern des Datensatzes'.$qry.' '.pg_errormessage($this->conn); + return false; + } + } + + /** + * Loescht einen Datensatz + * @param $lehreinheit_id ID des zu leoschenden DS + * @return true wenn ok, false im Fehlerfall + */ + function delete($lehreinheit_id) + { + if(!is_numeric($lehreinheit_id) || $lehreinheit_id == '') + { + $this->errormsg = 'lehreinheit_id muss eine gueltige Zahl sein'; + return false; + } + //Pruefen ob diese Lehreinheit Partizipierte Lehreinheiten hat + $qry = "SELECT count(*) as anz FROM lehreinheit where lehreinheit_fk='$lehreinheit_id'"; + if(!$result = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Fehler beim Auslesen der partizipierenden Lehreinheiten'; + return false; + } + else + { + if(!$row=pg_fetch_object($result) || $row->anz>0) + { + $this->errormsg = 'Sie können diese Lehreinheit nicht löschen da noch partizipierende Lehreinheiten vorhanden sind.'.$qry; + return false; + } + } + + $qry = "DELETE FROM lehreinheit where lehreinheit_pk = '$lehreinheit_id'"; + + if(!pg_query($this->conn, $qry)) + { + $this->errormsg = 'Fehler beim loeschen des Datensatzes'; + return false; + } + else + { + //Log schreiben + $sql = $qry; + $qry = "SELECT nextval('log_seq') as id;"; + if(!$row = pg_fetch_object(pg_query($this->conn, $qry))) + { + $this->errormsg = 'Fehler beim Auslesen der Log-Sequence'; + return false; + } + + $qry = "INSERT INTO log(log_pk, creationdate, creationuser, sql) VALUES('$row->id', now(), '$this->updatevon', '".addslashes($sql)."')"; + if(pg_query($this->conn, $qry)) + return true; + else + { + $this->errormsg = 'Fehler beim Speichern des Log-Eintrages'; + return false; + } + } + } + + + + + /** + * Laedt alle/id des uebergebenen Mitarbeiter die zu einer Lehreinheit gehoeren + * @param $lehreinheit_id ID der Lehreinheit + * $mitarbeiter_id ID des Mitarbeiters (optional) + * @return true wenn ok, false im Fehlerfall + */ + function load_zuteilung($lehreinheit_id, $mitarbeiter_id=null) + { + //Variablen pruefen + if(!is_numeric($lehreinheit_id) || $lehreinheit_id == '') + { + $this->errormsg = 'lehreinheit_id muss eine gueltige Zahl sein'; + return false; + } + if($mitarbeiter_id != null && (!is_numeric($mitarbeiter_id) || $mitarbeiter_id == '')) + { + $this->errormsg = 'mitarbeiter_id muss eine gueltige Zahl sein'; + return false; + } + + $qry = "SELECT * FROM mitarbeiter_lehreinheit where lehreinheit_fk = '$lehreinheit_id'"; + + if($mitarbeiter_id != null) + $qry .= " AND mitarbeiter_id = '$mitarbeiter_id'"; + + if(!$res = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Datensatz konnte nicht geladen werden'; + return false; + } + + while($row = pg_fetch_object($res)) + { + $einh_obj = new lehreinheit($this->conn); + + $einh_obj->mitarbeiter_lehreinheit_id = $row->mitarbeiter_lehreinheit_pk; + $einh_obj->lehreinheit_fk = $row->lehreinheit_fk; + $einh_obj->lehrfunktion_id = $row->lehrfunktion_fk; + $einh_obj->mitarbeiter_id = $row->mitarbeiter_fk; + $einh_obj->faktor = $row->faktor; + $einh_obj->kosten = $row->kosten; + $einh_obj->gesamtstunden_mitarbeiter = $row->rvar1; + + $this->result[] = $einh_obj; + } + return true; + } + + /** + * Laedt die Mitarbeiterzuteilung + * @param $mitarbeiter_lehreinheit_id ID der Zuteilung + * @return true wenn ok, false im Fehlerfall + */ + function load_mitarbeiterzuteilung($mitarbeiter_lehreinheit_id) + { + //Variablen pruefen + if(!is_numeric($mitarbeiter_lehreinheit_id) || $mitarbeiter_lehreinheit_id == '') + { + $this->errormsg = 'mitarbeiter_lehreinheit_id muss eine gueltige Zahl sein'; + return false; + } + + $qry = "SELECT * FROM mitarbeiter_lehreinheit where mitarbeiter_lehreinheit_pk = '$mitarbeiter_lehreinheit_id'"; + + if(!$res = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Datensatz konnte nicht geladen werden'; + return false; + } + + while($row = pg_fetch_object($res)) + { + $einh_obj = new lehreinheit($this->conn); + + $einh_obj->mitarbeiter_lehreinheit_id = $row->mitarbeiter_lehreinheit_pk; + $einh_obj->lehreinheit_fk = $row->lehreinheit_fk; + $einh_obj->lehrfunktion_id = $row->lehrfunktion_fk; + $einh_obj->mitarbeiter_id = $row->mitarbeiter_fk; + $einh_obj->faktor = $row->faktor; + $einh_obj->kosten = $row->kosten; + $einh_obj->gesamtstunden_mitarbeiter = $row->rvar1; + + $this->result[] = $einh_obj; + } + return true; + } + + /** + * Prueft die variablen auf gueltigkeit + * @return true wenn ok, false im Fehlerfall + */ + function checkvars_zuteilung() + { + + if(!is_numeric($this->mitarbeiter_id)) + { + $this->errormsg = 'Bitte einen gueltigen Mitarbeiter auswaehlen'; + return false; + } + if(!is_numeric($this->lehreinheit_fk)) + { + $this->errormsg = 'lehreinheit_fk ist ungueltig'; + return false; + } + if(!is_numeric($this->lehrfunktion_id)) + { + $this->errormsg = 'Die Lehrfuntkion ist ungueltig'; + return false; + } + if(!is_numeric($this->kosten)) + { + $this->errormsg = 'Die Kosten muessen eine gueltige Zahl sein'; + return false; + } + if(!is_numeric($this->faktor)) + { + $this->errormsg = 'Faktor muss eine gueltige Zahl sein'; + return false; + } + if(!is_numeric($this->gesamtstunden_mitarbeiter)) + { + $this->errormsg = 'Gesamtstunden muss eine gueltige Zahl sein'; + return false; + } + + $this->errormsg = ''; + return true; + } + + /** + * Speichert die Zuteilung eines Mitarbeiters zu einer Lehreinheit + * @return true wenn ok, false im Fehlerfall + */ + function save_zuteilung() + { + if(!$this->checkvars_zuteilung()) + return false; + + if($this->new) + { + $qry = "SELECT nextval('mitarbeiter_lehreinheit_seq') as id;"; + if(!$row = pg_fetch_object(pg_query($this->conn, $qry))) + { + $this->errormsg = 'Sequence konnte nicht ausgelesen werden'; + return false; + } + + $this->mitarbeiter_lehreinheit_id = $row->id; + + $qry = "INSERT INTO mitarbeiter_lehreinheit (mitarbeiter_lehreinheit_pk, mitarbeiter_fk, lehreinheit_fk,". + " lehrfunktion_fk, kosten, faktor, rvar1, creationdate, creationuser) VALUES(". + " '$this->mitarbeiter_lehreinheit_id', '$this->mitarbeiter_id', '$this->lehreinheit_fk', '$this->lehrfunktion_id',". + " '$this->kosten', '$this->faktor', '$this->gesamtstunden_mitarbeiter', now(), '$this->updatevon');"; + } + else + { + //mitarbeiter_lehreinheit_id auf gueltigkeit pruefen + if(!is_numeric($this->mitarbeiter_lehreinheit_id) || $this->mitarbeiter_lehreinheit_id =='') + { + $this->errormsg = 'mitarbeiter_lehreinheit muss eine gueltige Zahl sein'; + return false; + } + + $qry = "UPDATE mitarbeiter_lehreinheit SET mitarbeiter_fk = '$this->mitarbeiter_id',". + " lehreinheit_fk = '$this->lehreinheit_fk', lehrfunktion_fk = '$this->lehrfunktion_id',". + " kosten = '$this->kosten', faktor = '$this->faktor', rvar1 = '$this->gesamtstunden_mitarbeiter'". + " WHERE mitarbeiter_lehreinheit_pk = '$this->mitarbeiter_lehreinheit_id';"; + } + + if(pg_query($this->conn, $qry)) + { + //Log schreiben + $sql = $qry; + $qry = "SELECT nextval('log_seq') as id;"; + if(!$row = pg_fetch_object(pg_query($this->conn, $qry))) + { + $this->errormsg = 'Fehler beim Auslesen der Log-Sequence'; + return false; + } + + $qry = "INSERT INTO log(log_pk, creationdate, creationuser, sql) VALUES('$row->id', now(), '$this->updatevon', '".addslashes($sql)."')"; + if(pg_query($this->conn, $qry)) + return true; + else + { + $this->errormsg = 'Fehler beim Speichern des Log-Eintrages'; + return false; + } + } + else + { + $this->errormsg = 'Fehler beim Speichern des Datensatzes'; + return false; + } + } + + /** + * Loescht die Zuteilung eines Mitarbeiters zu einer Lehreinheit + * @param $mitarbeiter_lehreinheit_id ID des zu loeschenden Datensatzes + * @return true wenn ok, false im Fehlerfall + */ + function delete_zuteilung($mitarbeiter_lehreinheit_id) + { + //Pruefen ob mitarbeiter_lehreinheit_id eine gueltige Zahl ist + if(!is_numeric($mitarbeiter_lehreinheit_id) || $mitarbeiter_lehreinheit_id == '') + { + $this->errormsg = 'mitarbeiter_lehreinheit_id muss eine gueltige Zahl sein'; + return false; + } + + $qry = "DELETE FROM mitarbeiter_lehreinheit WHERE mitarbeiter_lehreinheit_pk = '$mitarbeiter_lehreinheit_id';"; + + if(!pg_query($this->conn, $qry)) + { + $this->errormsg = 'Fehler beim loeschen der Zuteilung'; + return false; + } + else + { + //Log schreiben + $sql = $qry; + $qry = "SELECT nextval('log_seq') as id;"; + if(!$row = pg_fetch_object(pg_query($this->conn, $qry))) + { + $this->errormsg = 'Fehler beim Auslesen der Log-Sequence'; + return false; + } + + $qry = "INSERT INTO log(log_pk, creationdate, creationuser, sql) VALUES('$row->id', now(), '$this->updatevon', '".addslashes($sql)."')"; + if(pg_query($this->conn, $qry)) + return true; + else + { + $this->errormsg = 'Fehler beim Speichern des Log-Eintrages'; + return false; + } + } + + } + + /** + * Liefert die Lehreinheiten mit den dazugehoerigen Attributen + * @param stg Studiengang + * sem Semester + * stsem Studiensemester + */ + function getLehreinheiten($stg=null, $sem=null, $stsem=null, $lehreinheit_id=null, $include_partizipierungen=false) + { + $qry = "SELECT lehreinheit.lehreinheit_pk as lehreinheit_id, + studiengang.studiengang_pk as studiengang_id, + (CASE WHEN studiengang.studiengangsart=1 THEN 'B' + WHEN studiengang.studiengangsart=2 THEN 'M' + WHEN studiengang.studiengangsart=3 THEN 'D' END) || studiengang.kuerzel as studiengang_kurzbz, + studiensemester.studiensemester_pk as studiensemester_id, + (CASE WHEN studiensemester.art=1 THEN 'WS' + WHEN studiensemester.art=2 THEN 'SS' END) || studiensemester.jahr as studiensemester_kurzbz, + lehreinheit.lehrveranstaltung_fk as lehrveranstaltung_id, + lehreinheit.fachbereich_fk as fachbereich_id, + fachbereich.name as fachbereich_bezeichnung, + lehreinheit.ausbildungssemester_fk as ausbildungssemester_id, + ausbildungssemester.semester as ausbildungssemester_semester, + ausbildungssemester.name as ausbildungssemester_kurzbz, + lehreinheit.lehreinheit_fk as lehreinheit_fk, + lehreinheit.lehrform_fk as lehrform_id, + lehrform.kurzbezeichnung as lehrform_kurzbz, + lehreinheit.gruppe_fk as gruppe_id, + fas_function_get_fullname_from_gruppe(lehreinheit.gruppe_fk) as gruppe_kurzbz, + lehreinheit.nummer as nummer, + lehreinheit.bezeichnung as bezeichnung, + lehreinheit.kurzbezeichnung as kurzbezeichnung, + lehreinheit.semesterwochenstunden as semesterwochenstunden, + lehreinheit.gesamtstunden as gesamtstunden, + lehreinheit.plankostenprolektor as plankostenprolektor, + lehreinheit.planfaktor as planfaktor, + lehreinheit.planlektoren as planlektoren, + lehreinheit.raumtyp_fk as raumtyp_id, + lehreinheit.alternativraumtyp_fk as raumtypalternativ_id, + lehreinheit.bemerkungen as bemerkungen, + lehreinheit.ivar1 as wochenrythmus, + lehreinheit.ivar2 as kalenderwoche, + lehreinheit.ivar3 as stundenblockung, + lehreinheit.bivar1 as koordinator_id, + (Select vorname from person join mitarbeiter on (person_fk=person_pk) where mitarbeiter_pk=lehreinheit.bivar1) as koordinator_vorname, + (Select familienname from person join mitarbeiter on (person_fk=person_pk) where mitarbeiter_pk=lehreinheit.bivar1) as koordinator_nachname, + lehreinheit.creationdate as creationdate, + lehreinheit.creationuser as creationuser + FROM lehreinheit, studiengang, studiensemester, fachbereich, ausbildungssemester, lehrform + WHERE lehreinheit.studiengang_fk=studiengang.studiengang_pk + AND lehreinheit.studiensemester_fk=studiensemester.studiensemester_pk + AND lehreinheit.fachbereich_fk = fachbereich.fachbereich_pk + AND ausbildungssemester.ausbildungssemester_pk=lehreinheit.ausbildungssemester_fk + AND lehreinheit.lehrform_fk = lehrform.lehrform_pk"; + + if($stg!=null) + $qry .= " AND studiengang.studiengang_pk = '$stg'"; + if($sem!=null) + $qry .= " AND ausbildungssemester.semester= '$sem'"; + if($stsem!=null) + $qry .= " AND studiensemester.studiensemester_pk= '$stsem'"; + if($lehreinheit_id!=null) + $qry .= " AND lehreinheit_pk = '$lehreinheit_id'"; + $qry .= " Order by lehreinheit_fk"; + if($res=pg_query($this->conn, $qry)) + { + while($row=pg_fetch_object($res)) + { + $lehreinheit_obj = new lehreinheit($this->conn); + + $lehreinheit_obj->lehreinheit_id = $row->lehreinheit_id; + $lehreinheit_obj->studiengang_id = $row->studiengang_id; + $lehreinheit_obj->studiengang_kurzbz = $row->studiengang_kurzbz; + $lehreinheit_obj->studiensemester_id = $row->studiensemester_id; + $lehreinheit_obj->studiensemester_kurzbz = $row->studiensemester_kurzbz; + $lehreinheit_obj->lehrveranstaltung_id = $row->lehrveranstaltung_id; + $lehreinheit_obj->fachbereich_id = $row->fachbereich_id; + $lehreinheit_obj->fachbereich_bezeichnung = $row->fachbereich_bezeichnung; + $lehreinheit_obj->ausbildungssemester_id = $row->ausbildungssemester_id; + $lehreinheit_obj->ausbildungssemester_semester = $row->ausbildungssemester_semester; + $lehreinheit_obj->ausbildungssemester_kurzbz = $row->ausbildungssemester_kurzbz; + $lehreinheit_obj->lehreinheit_fk = $row->lehreinheit_fk; + $lehreinheit_obj->lehrform_id = $row->lehrform_id; + $lehreinheit_obj->lehrform_kurzbz = $row->lehrform_kurzbz; + $lehreinheit_obj->gruppe_id = $row->gruppe_id; + $lehreinheit_obj->gruppe_kurzbz = $row->gruppe_kurzbz; + $lehreinheit_obj->nummer = $row->nummer; + $lehreinheit_obj->bezeichnung = $row->bezeichnung; + $lehreinheit_obj->kurzbezeichnung = $row->kurzbezeichnung; + $lehreinheit_obj->semesterwochenstunden = $row->semesterwochenstunden; + $lehreinheit_obj->gesamtstunden = $row->gesamtstunden; + $lehreinheit_obj->plankostenprolektor = $row->plankostenprolektor; + $lehreinheit_obj->planfaktor = $row->planfaktor; + $lehreinheit_obj->planlektoren = $row->planlektoren; + $lehreinheit_obj->raumtyp_id = $row->raumtyp_id; + $lehreinheit_obj->raumtypalternativ_id = $row->raumtypalternativ_id; + $lehreinheit_obj->bemerkungen = $row->bemerkungen; + $lehreinheit_obj->wochenrythmus = $row->wochenrythmus; + $lehreinheit_obj->start_kw = $row->kalenderwoche; + $lehreinheit_obj->stundenblockung = $row->stundenblockung; + $lehreinheit_obj->koordinator_id = $row->koordinator_id; + $lehreinheit_obj->koordinator_vorname = $row->koordinator_vorname; + $lehreinheit_obj->koordinator_nachname = $row->koordinator_nachname; + $lehreinheit_obj->updateamum = $row->creationdate; + $lehreinheit_obj->updatevon = $row->creationuser; + + $this->result[] = $lehreinheit_obj; + $lehreinheit_id = $row->lehreinheit_id; + //Laden der Datensaetze die partizipiert sind aber in einem anderen Studiengang/Gruppe sind + if($include_partizipierungen) + { + if($row->lehreinheit_fk!='' && $row->lehreinheit_fk!='-1') + { + $qry = "SELECT lehreinheit.lehreinheit_pk as lehreinheit_id, + studiengang.studiengang_pk as studiengang_id, + (CASE WHEN studiengang.studiengangsart=1 THEN 'B' + WHEN studiengang.studiengangsart=2 THEN 'M' + WHEN studiengang.studiengangsart=3 THEN 'D' END) || studiengang.kuerzel as studiengang_kurzbz, + studiensemester.studiensemester_pk as studiensemester_id, + (CASE WHEN studiensemester.art=1 THEN 'WS' + WHEN studiensemester.art=2 THEN 'SS' END) || studiensemester.jahr as studiensemester_kurzbz, + lehreinheit.lehrveranstaltung_fk as lehrveranstaltung_id, + lehreinheit.fachbereich_fk as fachbereich_id, + fachbereich.name as fachbereich_bezeichnung, + lehreinheit.ausbildungssemester_fk as ausbildungssemester_id, + ausbildungssemester.semester as ausbildungssemester_semester, + ausbildungssemester.name as ausbildungssemester_kurzbz, + lehreinheit.lehreinheit_fk as lehreinheit_fk, + lehreinheit.lehrform_fk as lehrform_id, + lehrform.kurzbezeichnung as lehrform_kurzbz, + lehreinheit.gruppe_fk as gruppe_id, + fas_function_get_fullname_from_gruppe(lehreinheit.gruppe_fk) as gruppe_kurzbz, + lehreinheit.nummer as nummer, + lehreinheit.bezeichnung as bezeichnung, + lehreinheit.kurzbezeichnung as kurzbezeichnung, + lehreinheit.semesterwochenstunden as semesterwochenstunden, + lehreinheit.gesamtstunden as gesamtstunden, + lehreinheit.plankostenprolektor as plankostenprolektor, + lehreinheit.planfaktor as planfaktor, + lehreinheit.planlektoren as planlektoren, + lehreinheit.raumtyp_fk as raumtyp_id, + lehreinheit.alternativraumtyp_fk as raumtypalternativ_id, + lehreinheit.bemerkungen as bemerkungen, + lehreinheit.ivar1 as wochenrythmus, + lehreinheit.ivar2 as kalenderwoche, + lehreinheit.ivar3 as stundenblockung, + lehreinheit.bivar1 as koordinator_id, + (Select vorname from person join mitarbeiter on (person_fk=person_pk) where mitarbeiter_pk=lehreinheit.bivar1) as koordinator_vorname, + (Select familienname from person join mitarbeiter on (person_fk=person_pk) where mitarbeiter_pk=lehreinheit.bivar1) as koordinator_nachname, + lehreinheit.creationdate as creationdate, + lehreinheit.creationuser as creationuser + FROM lehreinheit, studiengang, studiensemester, fachbereich, ausbildungssemester, lehrform + WHERE lehreinheit.studiengang_fk=studiengang.studiengang_pk + AND lehreinheit.studiensemester_fk=studiensemester.studiensemester_pk + AND lehreinheit.fachbereich_fk = fachbereich.fachbereich_pk + AND ausbildungssemester.ausbildungssemester_pk=lehreinheit.ausbildungssemester_fk + AND lehreinheit.lehrform_fk = lehrform.lehrform_pk + AND lehreinheit_pk='$row->lehreinheit_fk'"; + + if($result=pg_query($this->conn,$qry)) + { + if($row=pg_fetch_object($result)) + { + if($row->studiengang_id!=$stg) + { + $lehreinheit_obj = new lehreinheit($this->conn); + + $lehreinheit_obj->lehreinheit_id = $row->lehreinheit_id; + $lehreinheit_obj->studiengang_id = $row->studiengang_id; + $lehreinheit_obj->studiengang_kurzbz = $row->studiengang_kurzbz; + $lehreinheit_obj->studiensemester_id = $row->studiensemester_id; + $lehreinheit_obj->studiensemester_kurzbz = $row->studiensemester_kurzbz; + $lehreinheit_obj->lehrveranstaltung_id = $row->lehrveranstaltung_id; + $lehreinheit_obj->fachbereich_id = $row->fachbereich_id; + $lehreinheit_obj->fachbereich_bezeichnung = $row->fachbereich_bezeichnung; + $lehreinheit_obj->ausbildungssemester_id = $row->ausbildungssemester_id; + $lehreinheit_obj->ausbildungssemester_semester = $row->ausbildungssemester_semester; + $lehreinheit_obj->ausbildungssemester_kurzbz = $row->ausbildungssemester_kurzbz; + $lehreinheit_obj->lehreinheit_fk = $row->lehreinheit_fk; + $lehreinheit_obj->lehrform_id = $row->lehrform_id; + $lehreinheit_obj->lehrform_kurzbz = $row->lehrform_kurzbz; + $lehreinheit_obj->gruppe_id = $row->gruppe_id; + $lehreinheit_obj->gruppe_kurzbz = $row->gruppe_kurzbz; + $lehreinheit_obj->nummer = $row->nummer; + $lehreinheit_obj->bezeichnung = $row->bezeichnung; + $lehreinheit_obj->kurzbezeichnung = $row->kurzbezeichnung; + $lehreinheit_obj->semesterwochenstunden = $row->semesterwochenstunden; + $lehreinheit_obj->gesamtstunden = $row->gesamtstunden; + $lehreinheit_obj->plankostenprolektor = $row->plankostenprolektor; + $lehreinheit_obj->planfaktor = $row->planfaktor; + $lehreinheit_obj->planlektoren = $row->planlektoren; + $lehreinheit_obj->raumtyp_id = $row->raumtyp_id; + $lehreinheit_obj->raumtypalternativ_id = $row->raumtypalternativ_id; + $lehreinheit_obj->bemerkungen = $row->bemerkungen; + $lehreinheit_obj->wochenrythmus = $row->wochenrythmus; + $lehreinheit_obj->start_kw = $row->kalenderwoche; + $lehreinheit_obj->stundenblockung = $row->stundenblockung; + $lehreinheit_obj->koordinator_id = $row->koordinator_id; + $lehreinheit_obj->koordinator_vorname = $row->koordinator_vorname; + $lehreinheit_obj->koordinator_nachname = $row->koordinator_nachname; + $lehreinheit_obj->updateamum = $row->creationdate; + $lehreinheit_obj->updatevon = $row->creationuser; + + $this->result[] = $lehreinheit_obj; + } + } + } + else + { + $this->errormsg = 'Fehler beim laden der Partizipierungen aus anderen Studiengaengen'; + return false; + } + } + + //Laden der uebergeordneten + + $qry = "SELECT lehreinheit.lehreinheit_pk as lehreinheit_id, + studiengang.studiengang_pk as studiengang_id, + (CASE WHEN studiengang.studiengangsart=1 THEN 'B' + WHEN studiengang.studiengangsart=2 THEN 'M' + WHEN studiengang.studiengangsart=3 THEN 'D' END) || studiengang.kuerzel as studiengang_kurzbz, + studiensemester.studiensemester_pk as studiensemester_id, + (CASE WHEN studiensemester.art=1 THEN 'WS' + WHEN studiensemester.art=2 THEN 'SS' END) || studiensemester.jahr as studiensemester_kurzbz, + lehreinheit.lehrveranstaltung_fk as lehrveranstaltung_id, + lehreinheit.fachbereich_fk as fachbereich_id, + fachbereich.name as fachbereich_bezeichnung, + lehreinheit.ausbildungssemester_fk as ausbildungssemester_id, + ausbildungssemester.semester as ausbildungssemester_semester, + ausbildungssemester.name as ausbildungssemester_kurzbz, + lehreinheit.lehreinheit_fk as lehreinheit_fk, + lehreinheit.lehrform_fk as lehrform_id, + lehrform.kurzbezeichnung as lehrform_kurzbz, + lehreinheit.gruppe_fk as gruppe_id, + fas_function_get_fullname_from_gruppe(lehreinheit.gruppe_fk) as gruppe_kurzbz, + lehreinheit.nummer as nummer, + lehreinheit.bezeichnung as bezeichnung, + lehreinheit.kurzbezeichnung as kurzbezeichnung, + lehreinheit.semesterwochenstunden as semesterwochenstunden, + lehreinheit.gesamtstunden as gesamtstunden, + lehreinheit.plankostenprolektor as plankostenprolektor, + lehreinheit.planfaktor as planfaktor, + lehreinheit.planlektoren as planlektoren, + lehreinheit.raumtyp_fk as raumtyp_id, + lehreinheit.alternativraumtyp_fk as raumtypalternativ_id, + lehreinheit.bemerkungen as bemerkungen, + lehreinheit.ivar1 as wochenrythmus, + lehreinheit.ivar2 as kalenderwoche, + lehreinheit.ivar3 as stundenblockung, + lehreinheit.bivar1 as koordinator_id, + (Select vorname from person join mitarbeiter on (person_fk=person_pk) where mitarbeiter_pk=lehreinheit.bivar1) as koordinator_vorname, + (Select familienname from person join mitarbeiter on (person_fk=person_pk) where mitarbeiter_pk=lehreinheit.bivar1) as koordinator_nachname, + lehreinheit.creationdate as creationdate, + lehreinheit.creationuser as creationuser + FROM lehreinheit, studiengang, studiensemester, fachbereich, ausbildungssemester, lehrform + WHERE lehreinheit.studiengang_fk=studiengang.studiengang_pk + AND lehreinheit.studiensemester_fk=studiensemester.studiensemester_pk + AND lehreinheit.fachbereich_fk = fachbereich.fachbereich_pk + AND ausbildungssemester.ausbildungssemester_pk=lehreinheit.ausbildungssemester_fk + AND lehreinheit.lehrform_fk = lehrform.lehrform_pk + AND lehreinheit_fk='$lehreinheit_id'"; + + if($result=pg_query($this->conn,$qry)) + { + while($row=pg_fetch_object($result)) + { + if($row->studiengang_id!=$stg) + { + $lehreinheit_obj = new lehreinheit($this->conn); + + $lehreinheit_obj->lehreinheit_id = $row->lehreinheit_id; + $lehreinheit_obj->studiengang_id = $row->studiengang_id; + $lehreinheit_obj->studiengang_kurzbz = $row->studiengang_kurzbz; + $lehreinheit_obj->studiensemester_id = $row->studiensemester_id; + $lehreinheit_obj->studiensemester_kurzbz = $row->studiensemester_kurzbz; + $lehreinheit_obj->lehrveranstaltung_id = $row->lehrveranstaltung_id; + $lehreinheit_obj->fachbereich_id = $row->fachbereich_id; + $lehreinheit_obj->fachbereich_bezeichnung = $row->fachbereich_bezeichnung; + $lehreinheit_obj->ausbildungssemester_id = $row->ausbildungssemester_id; + $lehreinheit_obj->ausbildungssemester_semester = $row->ausbildungssemester_semester; + $lehreinheit_obj->ausbildungssemester_kurzbz = $row->ausbildungssemester_kurzbz; + $lehreinheit_obj->lehreinheit_fk = $row->lehreinheit_fk; + $lehreinheit_obj->lehrform_id = $row->lehrform_id; + $lehreinheit_obj->lehrform_kurzbz = $row->lehrform_kurzbz; + $lehreinheit_obj->gruppe_id = $row->gruppe_id; + $lehreinheit_obj->gruppe_kurzbz = $row->gruppe_kurzbz; + $lehreinheit_obj->nummer = $row->nummer; + $lehreinheit_obj->bezeichnung = $row->bezeichnung; + $lehreinheit_obj->kurzbezeichnung = $row->kurzbezeichnung; + $lehreinheit_obj->semesterwochenstunden = $row->semesterwochenstunden; + $lehreinheit_obj->gesamtstunden = $row->gesamtstunden; + $lehreinheit_obj->plankostenprolektor = $row->plankostenprolektor; + $lehreinheit_obj->planfaktor = $row->planfaktor; + $lehreinheit_obj->planlektoren = $row->planlektoren; + $lehreinheit_obj->raumtyp_id = $row->raumtyp_id; + $lehreinheit_obj->raumtypalternativ_id = $row->raumtypalternativ_id; + $lehreinheit_obj->bemerkungen = $row->bemerkungen; + $lehreinheit_obj->wochenrythmus = $row->wochenrythmus; + $lehreinheit_obj->start_kw = $row->kalenderwoche; + $lehreinheit_obj->stundenblockung = $row->stundenblockung; + $lehreinheit_obj->koordinator_id = $row->koordinator_id; + $lehreinheit_obj->koordinator_vorname = $row->koordinator_vorname; + $lehreinheit_obj->koordinator_nachname = $row->koordinator_nachname; + $lehreinheit_obj->updateamum = $row->creationdate; + $lehreinheit_obj->updatevon = $row->creationuser; + + $this->result[] = $lehreinheit_obj; + } + } + } + else + { + $this->errormsg = 'Fehler beim laden der Partizipierungen aus anderen Studiengaengen'; + return false; + } + + } + } + } + else + { + $this->errormsg = "Fehler bei einer SQL Abfrage"; + return false; + } + return true; + } + + /** + * Liefert die Lehreinheiten mit den dazugehoerigen Attributen + * @param stg Studiengang + * sem Semester + * stsem Studiensemester + */ + function getLehreinheitenfromGruppe($gruppe_id, $stsem) + { + + $qry = "SELECT lehreinheit.lehreinheit_pk as lehreinheit_id, + studiengang.studiengang_pk as studiengang_id, + (CASE WHEN studiengang.studiengangsart=1 THEN 'B' + WHEN studiengang.studiengangsart=2 THEN 'M' + WHEN studiengang.studiengangsart=3 THEN 'D' END) || studiengang.kuerzel as studiengang_kurzbz, + studiensemester.studiensemester_pk as studiensemester_id, + (CASE WHEN studiensemester.art=1 THEN 'WS' + WHEN studiensemester.art=2 THEN 'SS' END) || studiensemester.jahr as studiensemester_kurzbz, + lehreinheit.lehrveranstaltung_fk as lehrveranstaltung_id, + lehreinheit.fachbereich_fk as fachbereich_id, + fachbereich.name as fachbereich_bezeichnung, + lehreinheit.ausbildungssemester_fk as ausbildungssemester_id, + ausbildungssemester.semester as ausbildungssemester_semester, + ausbildungssemester.name as ausbildungssemester_kurzbz, + lehreinheit.lehreinheit_fk as lehreinheit_fk, + lehreinheit.lehrform_fk as lehrform_id, + lehrform.kurzbezeichnung as lehrform_kurzbz, + lehreinheit.gruppe_fk as gruppe_id, + fas_function_get_fullname_from_gruppe(lehreinheit.gruppe_fk) as gruppe_kurzbz, + lehreinheit.nummer as nummer, + lehreinheit.bezeichnung as bezeichnung, + lehreinheit.kurzbezeichnung as kurzbezeichnung, + lehreinheit.semesterwochenstunden as semesterwochenstunden, + lehreinheit.gesamtstunden as gesamtstunden, + lehreinheit.plankostenprolektor as plankostenprolektor, + lehreinheit.planfaktor as planfaktor, + lehreinheit.planlektoren as planlektoren, + lehreinheit.raumtyp_fk as raumtyp_id, + lehreinheit.alternativraumtyp_fk as raumtypalternativ_id, + lehreinheit.bemerkungen as bemerkungen, + lehreinheit.ivar1 as wochenrythmus, + lehreinheit.ivar2 as kalenderwoche, + lehreinheit.ivar3 as stundenblockung, + lehreinheit.bivar1 as koordinator_id, + (Select vorname from person join mitarbeiter on (person_fk=person_pk) where mitarbeiter_pk=lehreinheit.bivar1) as koordinator_vorname, + (Select familienname from person join mitarbeiter on (person_fk=person_pk) where mitarbeiter_pk=lehreinheit.bivar1) as koordinator_nachname, + lehreinheit.creationdate as creationdate, + lehreinheit.creationuser as creationuser + FROM lehreinheit, studiengang, studiensemester, fachbereich, ausbildungssemester, lehrform + WHERE lehreinheit.studiengang_fk=studiengang.studiengang_pk + AND lehreinheit.studiensemester_fk=studiensemester.studiensemester_pk + AND lehreinheit.fachbereich_fk = fachbereich.fachbereich_pk + AND ausbildungssemester.ausbildungssemester_pk=lehreinheit.ausbildungssemester_fk + AND lehreinheit.lehrform_fk = lehrform.lehrform_pk + AND gruppe_fk in (Select gruppe_pk from gruppe where gruppe_pk=$gruppe_id union Select gruppe_pk from gruppe where gruppe_pk in (Select gruppe_pk from gruppe where obergruppe_fk=$gruppe_id) union Select gruppe_pk from gruppe where obergruppe_fk in (Select gruppe_pk from gruppe where obergruppe_fk in (Select gruppe_pk from gruppe where gruppe_pk=$gruppe_id))) + "; + $qry .= " AND studiensemester.studiensemester_pk= '$stsem'"; + + $qry .= " Order by lehreinheit_fk"; + if($res=pg_query($this->conn, $qry)) + { + while($row=pg_fetch_object($res)) + { + $lehreinheit_obj = new lehreinheit($this->conn); + + $lehreinheit_obj->lehreinheit_id = $row->lehreinheit_id; + $lehreinheit_obj->studiengang_id = $row->studiengang_id; + $lehreinheit_obj->studiengang_kurzbz = $row->studiengang_kurzbz; + $lehreinheit_obj->studiensemester_id = $row->studiensemester_id; + $lehreinheit_obj->studiensemester_kurzbz = $row->studiensemester_kurzbz; + $lehreinheit_obj->lehrveranstaltung_id = $row->lehrveranstaltung_id; + $lehreinheit_obj->fachbereich_id = $row->fachbereich_id; + $lehreinheit_obj->fachbereich_bezeichnung = $row->fachbereich_bezeichnung; + $lehreinheit_obj->ausbildungssemester_id = $row->ausbildungssemester_id; + $lehreinheit_obj->ausbildungssemester_semester = $row->ausbildungssemester_semester; + $lehreinheit_obj->ausbildungssemester_kurzbz = $row->ausbildungssemester_kurzbz; + $lehreinheit_obj->lehreinheit_fk = $row->lehreinheit_fk; + $lehreinheit_obj->lehrform_id = $row->lehrform_id; + $lehreinheit_obj->lehrform_kurzbz = $row->lehrform_kurzbz; + $lehreinheit_obj->gruppe_id = $row->gruppe_id; + $lehreinheit_obj->gruppe_kurzbz = $row->gruppe_kurzbz; + $lehreinheit_obj->nummer = $row->nummer; + $lehreinheit_obj->bezeichnung = $row->bezeichnung; + $lehreinheit_obj->kurzbezeichnung = $row->kurzbezeichnung; + $lehreinheit_obj->semesterwochenstunden = $row->semesterwochenstunden; + $lehreinheit_obj->gesamtstunden = $row->gesamtstunden; + $lehreinheit_obj->plankostenprolektor = $row->plankostenprolektor; + $lehreinheit_obj->planfaktor = $row->planfaktor; + $lehreinheit_obj->planlektoren = $row->planlektoren; + $lehreinheit_obj->raumtyp_id = $row->raumtyp_id; + $lehreinheit_obj->raumtypalternativ_id = $row->raumtypalternativ_id; + $lehreinheit_obj->bemerkungen = $row->bemerkungen; + $lehreinheit_obj->wochenrythmus = $row->wochenrythmus; + $lehreinheit_obj->start_kw = $row->kalenderwoche; + $lehreinheit_obj->stundenblockung = $row->stundenblockung; + $lehreinheit_obj->koordinator_id = $row->koordinator_id; + $lehreinheit_obj->koordinator_vorname = $row->koordinator_vorname; + $lehreinheit_obj->koordinator_nachname = $row->koordinator_nachname; + $lehreinheit_obj->updateamum = $row->creationdate; + $lehreinheit_obj->updatevon = $row->creationuser; + + $this->result[] = $lehreinheit_obj; + + $lehreinheit_id = $row->lehreinheit_id; + //Wenn eine Obergruppe existiert und diese nicht in der selben Gruppe ist + //dann wird diese auch geladen + + if($row->lehreinheit_fk!='' && $row->lehreinheit_fk!='-1' ) + { + + $qry = "SELECT lehreinheit.lehreinheit_pk as lehreinheit_id, + studiengang.studiengang_pk as studiengang_id, + (CASE WHEN studiengang.studiengangsart=1 THEN 'B' + WHEN studiengang.studiengangsart=2 THEN 'M' + WHEN studiengang.studiengangsart=3 THEN 'D' END) || studiengang.kuerzel as studiengang_kurzbz, + studiensemester.studiensemester_pk as studiensemester_id, + (CASE WHEN studiensemester.art=1 THEN 'WS' + WHEN studiensemester.art=2 THEN 'SS' END) || studiensemester.jahr as studiensemester_kurzbz, + lehreinheit.lehrveranstaltung_fk as lehrveranstaltung_id, + lehreinheit.fachbereich_fk as fachbereich_id, + fachbereich.name as fachbereich_bezeichnung, + lehreinheit.ausbildungssemester_fk as ausbildungssemester_id, + ausbildungssemester.semester as ausbildungssemester_semester, + ausbildungssemester.name as ausbildungssemester_kurzbz, + lehreinheit.lehreinheit_fk as lehreinheit_fk, + lehreinheit.lehrform_fk as lehrform_id, + lehrform.kurzbezeichnung as lehrform_kurzbz, + lehreinheit.gruppe_fk as gruppe_id, + fas_function_get_fullname_from_gruppe(lehreinheit.gruppe_fk) as gruppe_kurzbz, + lehreinheit.nummer as nummer, + lehreinheit.bezeichnung as bezeichnung, + lehreinheit.kurzbezeichnung as kurzbezeichnung, + lehreinheit.semesterwochenstunden as semesterwochenstunden, + lehreinheit.gesamtstunden as gesamtstunden, + lehreinheit.plankostenprolektor as plankostenprolektor, + lehreinheit.planfaktor as planfaktor, + lehreinheit.planlektoren as planlektoren, + lehreinheit.raumtyp_fk as raumtyp_id, + lehreinheit.alternativraumtyp_fk as raumtypalternativ_id, + lehreinheit.bemerkungen as bemerkungen, + lehreinheit.ivar1 as wochenrythmus, + lehreinheit.ivar2 as kalenderwoche, + lehreinheit.ivar3 as stundenblockung, + lehreinheit.bivar1 as koordinator_id, + (Select vorname from person join mitarbeiter on (person_fk=person_pk) where mitarbeiter_pk=lehreinheit.bivar1) as koordinator_vorname, + (Select familienname from person join mitarbeiter on (person_fk=person_pk) where mitarbeiter_pk=lehreinheit.bivar1) as koordinator_nachname, + lehreinheit.creationdate as creationdate, + lehreinheit.creationuser as creationuser + FROM lehreinheit, studiengang, studiensemester, fachbereich, ausbildungssemester, lehrform + WHERE lehreinheit.studiengang_fk=studiengang.studiengang_pk + AND lehreinheit.studiensemester_fk=studiensemester.studiensemester_pk + AND lehreinheit.fachbereich_fk = fachbereich.fachbereich_pk + AND ausbildungssemester.ausbildungssemester_pk=lehreinheit.ausbildungssemester_fk + AND lehreinheit.lehrform_fk = lehrform.lehrform_pk + AND studiensemester.studiensemester_pk= '$stsem' + AND lehreinheit_pk='$row->lehreinheit_fk'"; + + if($result=pg_query($this->conn,$qry)) + { + if($row=pg_fetch_object($result)) + { + + if($row->gruppe_id!=$gruppe_id) + { + + $lehreinheit_obj = new lehreinheit($this->conn); + + $lehreinheit_obj->lehreinheit_id = $row->lehreinheit_id; + $lehreinheit_obj->studiengang_id = $row->studiengang_id; + $lehreinheit_obj->studiengang_kurzbz = $row->studiengang_kurzbz; + $lehreinheit_obj->studiensemester_id = $row->studiensemester_id; + $lehreinheit_obj->studiensemester_kurzbz = $row->studiensemester_kurzbz; + $lehreinheit_obj->lehrveranstaltung_id = $row->lehrveranstaltung_id; + $lehreinheit_obj->fachbereich_id = $row->fachbereich_id; + $lehreinheit_obj->fachbereich_bezeichnung = $row->fachbereich_bezeichnung; + $lehreinheit_obj->ausbildungssemester_id = $row->ausbildungssemester_id; + $lehreinheit_obj->ausbildungssemester_semester = $row->ausbildungssemester_semester; + $lehreinheit_obj->ausbildungssemester_kurzbz = $row->ausbildungssemester_kurzbz; + $lehreinheit_obj->lehreinheit_fk = $row->lehreinheit_fk; + $lehreinheit_obj->lehrform_id = $row->lehrform_id; + $lehreinheit_obj->lehrform_kurzbz = $row->lehrform_kurzbz; + $lehreinheit_obj->gruppe_id = $row->gruppe_id; + $lehreinheit_obj->gruppe_kurzbz = $row->gruppe_kurzbz; + $lehreinheit_obj->nummer = $row->nummer; + $lehreinheit_obj->bezeichnung = $row->bezeichnung; + $lehreinheit_obj->kurzbezeichnung = $row->kurzbezeichnung; + $lehreinheit_obj->semesterwochenstunden = $row->semesterwochenstunden; + $lehreinheit_obj->gesamtstunden = $row->gesamtstunden; + $lehreinheit_obj->plankostenprolektor = $row->plankostenprolektor; + $lehreinheit_obj->planfaktor = $row->planfaktor; + $lehreinheit_obj->planlektoren = $row->planlektoren; + $lehreinheit_obj->raumtyp_id = $row->raumtyp_id; + $lehreinheit_obj->raumtypalternativ_id = $row->raumtypalternativ_id; + $lehreinheit_obj->bemerkungen = $row->bemerkungen; + $lehreinheit_obj->wochenrythmus = $row->wochenrythmus; + $lehreinheit_obj->start_kw = $row->kalenderwoche; + $lehreinheit_obj->stundenblockung = $row->stundenblockung; + $lehreinheit_obj->koordinator_id = $row->koordinator_id; + $lehreinheit_obj->koordinator_vorname = $row->koordinator_vorname; + $lehreinheit_obj->koordinator_nachname = $row->koordinator_nachname; + $lehreinheit_obj->updateamum = $row->creationdate; + $lehreinheit_obj->updatevon = $row->creationuser; + + $this->result[] = $lehreinheit_obj; + } + } + else + { + $this->errormsg = 'Fehler beim laden der partizipierenden Lehreinheiten'.$qry; + return false; + } + } + else + { + $this->errormsg = 'Fehler beim laden der partizipierenden Lehreinheiten'; + return false; + } + } + + //Laden der Datensaetze die partizipiert sind aber in einem anderen Studiengang/Gruppe sind + $qry = "SELECT lehreinheit.lehreinheit_pk as lehreinheit_id, + studiengang.studiengang_pk as studiengang_id, + (CASE WHEN studiengang.studiengangsart=1 THEN 'B' + WHEN studiengang.studiengangsart=2 THEN 'M' + WHEN studiengang.studiengangsart=3 THEN 'D' END) || studiengang.kuerzel as studiengang_kurzbz, + studiensemester.studiensemester_pk as studiensemester_id, + (CASE WHEN studiensemester.art=1 THEN 'WS' + WHEN studiensemester.art=2 THEN 'SS' END) || studiensemester.jahr as studiensemester_kurzbz, + lehreinheit.lehrveranstaltung_fk as lehrveranstaltung_id, + lehreinheit.fachbereich_fk as fachbereich_id, + fachbereich.name as fachbereich_bezeichnung, + lehreinheit.ausbildungssemester_fk as ausbildungssemester_id, + ausbildungssemester.semester as ausbildungssemester_semester, + ausbildungssemester.name as ausbildungssemester_kurzbz, + lehreinheit.lehreinheit_fk as lehreinheit_fk, + lehreinheit.lehrform_fk as lehrform_id, + lehrform.kurzbezeichnung as lehrform_kurzbz, + lehreinheit.gruppe_fk as gruppe_id, + fas_function_get_fullname_from_gruppe(lehreinheit.gruppe_fk) as gruppe_kurzbz, + lehreinheit.nummer as nummer, + lehreinheit.bezeichnung as bezeichnung, + lehreinheit.kurzbezeichnung as kurzbezeichnung, + lehreinheit.semesterwochenstunden as semesterwochenstunden, + lehreinheit.gesamtstunden as gesamtstunden, + lehreinheit.plankostenprolektor as plankostenprolektor, + lehreinheit.planfaktor as planfaktor, + lehreinheit.planlektoren as planlektoren, + lehreinheit.raumtyp_fk as raumtyp_id, + lehreinheit.alternativraumtyp_fk as raumtypalternativ_id, + lehreinheit.bemerkungen as bemerkungen, + lehreinheit.ivar1 as wochenrythmus, + lehreinheit.ivar2 as kalenderwoche, + lehreinheit.ivar3 as stundenblockung, + lehreinheit.bivar1 as koordinator_id, + (Select vorname from person join mitarbeiter on (person_fk=person_pk) where mitarbeiter_pk=lehreinheit.bivar1) as koordinator_vorname, + (Select familienname from person join mitarbeiter on (person_fk=person_pk) where mitarbeiter_pk=lehreinheit.bivar1) as koordinator_nachname, + lehreinheit.creationdate as creationdate, + lehreinheit.creationuser as creationuser + FROM lehreinheit, studiengang, studiensemester, fachbereich, ausbildungssemester, lehrform + WHERE lehreinheit.studiengang_fk=studiengang.studiengang_pk + AND lehreinheit.studiensemester_fk=studiensemester.studiensemester_pk + AND lehreinheit.fachbereich_fk = fachbereich.fachbereich_pk + AND ausbildungssemester.ausbildungssemester_pk=lehreinheit.ausbildungssemester_fk + AND lehreinheit.lehrform_fk = lehrform.lehrform_pk + AND studiensemester.studiensemester_pk= '$stsem' + AND lehreinheit_fk='$lehreinheit_id'"; + + if($result=pg_query($this->conn,$qry)) + { + while($row=pg_fetch_object($result)) + { + + if($row->gruppe_id!=$gruppe_id) + { + + $lehreinheit_obj = new lehreinheit($this->conn); + + $lehreinheit_obj->lehreinheit_id = $row->lehreinheit_id; + $lehreinheit_obj->studiengang_id = $row->studiengang_id; + $lehreinheit_obj->studiengang_kurzbz = $row->studiengang_kurzbz; + $lehreinheit_obj->studiensemester_id = $row->studiensemester_id; + $lehreinheit_obj->studiensemester_kurzbz = $row->studiensemester_kurzbz; + $lehreinheit_obj->lehrveranstaltung_id = $row->lehrveranstaltung_id; + $lehreinheit_obj->fachbereich_id = $row->fachbereich_id; + $lehreinheit_obj->fachbereich_bezeichnung = $row->fachbereich_bezeichnung; + $lehreinheit_obj->ausbildungssemester_id = $row->ausbildungssemester_id; + $lehreinheit_obj->ausbildungssemester_semester = $row->ausbildungssemester_semester; + $lehreinheit_obj->ausbildungssemester_kurzbz = $row->ausbildungssemester_kurzbz; + $lehreinheit_obj->lehreinheit_fk = $row->lehreinheit_fk; + $lehreinheit_obj->lehrform_id = $row->lehrform_id; + $lehreinheit_obj->lehrform_kurzbz = $row->lehrform_kurzbz; + $lehreinheit_obj->gruppe_id = $row->gruppe_id; + $lehreinheit_obj->gruppe_kurzbz = $row->gruppe_kurzbz; + $lehreinheit_obj->nummer = $row->nummer; + $lehreinheit_obj->bezeichnung = $row->bezeichnung; + $lehreinheit_obj->kurzbezeichnung = $row->kurzbezeichnung; + $lehreinheit_obj->semesterwochenstunden = $row->semesterwochenstunden; + $lehreinheit_obj->gesamtstunden = $row->gesamtstunden; + $lehreinheit_obj->plankostenprolektor = $row->plankostenprolektor; + $lehreinheit_obj->planfaktor = $row->planfaktor; + $lehreinheit_obj->planlektoren = $row->planlektoren; + $lehreinheit_obj->raumtyp_id = $row->raumtyp_id; + $lehreinheit_obj->raumtypalternativ_id = $row->raumtypalternativ_id; + $lehreinheit_obj->bemerkungen = $row->bemerkungen; + $lehreinheit_obj->wochenrythmus = $row->wochenrythmus; + $lehreinheit_obj->start_kw = $row->kalenderwoche; + $lehreinheit_obj->stundenblockung = $row->stundenblockung; + $lehreinheit_obj->koordinator_id = $row->koordinator_id; + $lehreinheit_obj->koordinator_vorname = $row->koordinator_vorname; + $lehreinheit_obj->koordinator_nachname = $row->koordinator_nachname; + $lehreinheit_obj->updateamum = $row->creationdate; + $lehreinheit_obj->updatevon = $row->creationuser; + + $this->result[] = $lehreinheit_obj; + } + } + } + else + { + $this->errormsg = "Fehler beim Auslesen der partizipierenden Lehreinheiten"; + return false; + } + } + + } + else + { + $this->errormsg = "Fehler bei einer SQL Abfrage"; + return false; + } + //$this->errormsg = $qry; + // return false; + return true; + } + + /** + * Setzt eine Partizipierung + * @param $quell_lehreinheit_id ... Lehreinheit welche an eine andere Lehreinheit angehaengt wird + * $ziel_lehreinheit_id .... Lehreinheit an welche die andere Lehreinheit angehaengt wird + * + * Wenn $ziel_lehreinheit_id = -1 dann wird die zuteilung entfernt + * Wenn Ziel Lehreinheit bereits eine Partizipierende ist, dann wird automatisch die uebergeordnete genommen + */ + function setPartizipierung($quell_lehreinheit_id, $ziel_lehreinheit_id) + { + //Parameter auf gueltigkeit pruefen + if(is_numeric($quell_lehreinheit_id) && is_numeric($ziel_lehreinheit_id)) + { + //Keine Aktion bei gleicher ID + if($quell_lehreinheit_id != $ziel_lehreinheit_id) + { + //Wenn Ziel = -1 dann die Partizipierung loeschen + if($ziel_lehreinheit_id!=-1) + { + //Wenn die Quell-Lehreinheit eine Partizipierende Lehreinheit hat dann kann Sie nicht an eine andere + //angehaengt werden + $qry = "SELECT count(*) as anz FROM lehreinheit WHERE lehreinheit_fk='$quell_lehreinheit_id'"; + if($result = pg_query($this->conn,$qry)) + { + if($row = pg_fetch_object($result)) + { + if($row->anz>0) + { + $this->errormsg = 'Operation nicht zulaessig'; + return false; + } + } + else + { + $this->errormsg = 'Fehler beim Auslesen der Quell-Lehreinheit'; + return false; + } + } + else + { + $this->errormsg = 'Fehler beim Auslesen der Quell-Lehreinheit'; + return false; + } + //Nummer der Ziel Lehreinheit ermitteln + $qry = "SELECT nummer, lehreinheit_fk FROM lehreinheit WHERE lehreinheit_pk='$ziel_lehreinheit_id'"; + if($result = pg_query($this->conn, $qry)) + { + if($row = pg_fetch_object($result)) + { + if($row->lehreinheit_fk==-1 || $row->lehreinheit_fk==null) + { + $nummer = $row->nummer; + } + else + { + //Wenn Ziel Lehreinheit selbst eine Partizipierende Lehreinheit ist, + //wird die uebergeordnete Lehreinheit genommen + $ziel_lehreinheit_id = $row->lehreinheit_fk; + + $qry = "SELECT nummer FROM lehreinheit WHERE lehreinheit_pk='$ziel_lehreinheit_id'"; + if($result = pg_query($this->conn, $qry)) + { + if($row = pg_fetch_object($result)) + $nummer = $row->nummer; + else + { + $this->errormsg = 'Fehler beim Auslesen der Nummer'; + return false; + } + } + else + { + $this->errormsg = 'Fehler beim Auslesen der Nummer'; + return false; + } + } + //Zuteilung speichern + $qry = "UPDATE lehreinheit SET lehreinheit_fk='$ziel_lehreinheit_id', + bemerkungen=(bemerkungen || ' Partizipierende LVA bei $nummer') + WHERE lehreinheit_pk = '$quell_lehreinheit_id'"; + + if(pg_query($this->conn, $qry)) + return true; + else + { + $this->errormsg = 'Fehler beim speichern'; + return false; + } + + } + else + { + $this->errormsg = 'Ziel Lehreinheit konnte nicht ermittelt werden'; + return true; + } + } + else + { + $this->errormsg = 'Ziel Lehreinheit konnte nicht ermittelt werden'; + return false; + } + } + else + { + $qry = "SELECT b.nummer as nummer, a.bemerkungen as bemerkung FROM lehreinheit as a, lehreinheit as b where a.lehreinheit_fk=b.lehreinheit_pk AND a.lehreinheit_pk='$quell_lehreinheit_id'"; + if($result = pg_query($this->conn, $qry)) + { + if($row = pg_fetch_object($result)) + { + $bemerkung = $row->bemerkung; + $bemerkung = str_replace('Partizipierende LVA bei '.$row->nummer,'',$bemerkung); + + //Loeschen der Zuteilung + $qry = "UPDATE lehreinheit SET lehreinheit_fk='-1', bemerkungen = '$bemerkung' WHERE lehreinheit_pk='$quell_lehreinheit_id'"; + if(pg_query($this->conn, $qry)) + return true; + else + { + $this->errormsg = 'Fehler beim speichern'; + return false; + } + } + else + { + $this->errormsg = 'Nummer konnte nicht ermittelt werden'; + return false; + } + } + else + { + $this->errormsg = 'Nummer konnte nicht ermittelt werden'; + return false; + } + } + } + else + { + $this->errormsg = 'Quell und Ziel ID sind identisch'; + return false; + } + } + else + { + $this->errormsg = 'Quell und Ziel ID muessen gueltige Zahlen sein'; + return false; + } + } +} +?> \ No newline at end of file diff --git a/include/fas/lehrform.class.php b/include/fas/lehrform.class.php new file mode 100644 index 000000000..d35c9287c --- /dev/null +++ b/include/fas/lehrform.class.php @@ -0,0 +1,131 @@ +conn = $conn; + $qry = "SET CLIENT_ENCODING TO 'UNICODE';"; + if(!pg_query($conn,$qry)) + { + $this->errormsg = "Encoding konnte nicht gesetzt werden"; + return false; + } + if($lehrform_id != null) + $this->load($lehrform_id); + } + + /** + * Laedt einen Datensatz + * @param $lform_id ID des zu ladenden Datensatzes + * @return true wenn ok, false im Fehlerfall + */ + function load($lform_id) + { + //pruefen ob lform_id eine gueltige Zahl ist + if(!is_numeric($lform_id) || $lform_id == '') + { + $this->errormsg = 'lehrform_id muss eine gueltige Zahl sein'; + return false; + } + + //Datensatz laden + $qry = "SELECT * FROM lehrform WHERE lehrform_pk = '$lform_id';"; + + if(!$res = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Der Datensatz konnte nicht geladen werden'; + return false; + } + + if($row = pg_fetch_object($res)) + { + $this->lehrform_id = $row->lehrform_pk; + $this->bezeichnung = $row->bezeichnung; + $this->kurzbezeichnung = $row->kurzbezeichnung; + $this->standardfaktor = $row->standardfaktor; + $this->updateamum = $row->creationdate; + $this->updatevon = $row->creationuser; + } + else + { + $this->errormsg = 'Der Datensatz konnte nicht geladen werden'; + return false; + } + + return true; + } + + /** + * Liefert alle lehrformen + * @return true wenn ok, false im Fehlerfall + */ + function getAll() + { + $qry = "SELECT * FROM lehrform;"; + + if(!$res = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Der Datensatz konnte nicht geladen werden'; + return false; + } + + while($row = pg_fetch_object($res)) + { + $form_obj = new lehrform($this->conn); + + $form_obj->lehrform_id = $row->lehrform_pk; + $form_obj->bezeichnung = $row->bezeichnung; + $form_obj->kurzbezeichnung = $row->kurzbezeichnung; + $form_obj->standardfaktor = $row->standardfaktor; + $form_obj->updateamum = $row->creationdate; + $form_obj->updatevon = $row->creationdate; + + $this->result[] = $form_obj; + } + + return true; + } + + /** + * Loescht einen Datensatz + * @param lehrform_id ID des zu loeschenden Datensatzes + * @return true wenn ok, false im Fehlerfall + */ + function delete($lehrform_id) + { + $this->errormsg = 'Noch nicht implementiert'; + return false; + } + + /** + * Speichert einen Datensatz + * @return true wenn ok, false im Fehlerfall + */ + function save() + { + $this->errormsg = 'Noch nicht implemeniert'; + return false; + } +} +?> \ No newline at end of file diff --git a/include/fas/lehrfunktion.class.php b/include/fas/lehrfunktion.class.php new file mode 100644 index 000000000..a2bd65a33 --- /dev/null +++ b/include/fas/lehrfunktion.class.php @@ -0,0 +1,124 @@ +conn = $conn; + $qry = "SET CLIENT_ENCODING TO 'UNICODE';"; + if(!pg_query($conn,$qry)) + { + $this->errormsg = "Encoding konnte nicht gesetzt werden"; + return false; + } + if($lehrfkt_id != null) + $this->load($lehrfkt_id); + } + + /** + * Laedt eine Lehrfunktion + * @param lehrfkt_id ID des Datensatzes der zu laden ist + * @return true wenn ok, false im Fehlerfall + */ + function load($lehrfkt_id) + { + if(!is_numeric($lehrfkt_id) || $lehrfkt_id == '') + { + $this->errormsg = 'lehrfunktion_id muss eine gueltige Zahl sein'; + return false; + } + + $qry = "SELECT * FROM lehrfunktion WHERE lehrfunktion_pk = '$lehrfkt_id';"; + + if(!$res = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Fehler beim laden des Datensatzes'; + return false; + } + + if($row = pg_fetch_object($res)) + { + $this->lehrfunktion_id = $row->lehrfunktion_pk; + $this->bezeichnung = $row->bezeichnung; + $this->standardfaktor = $row->standardfaktor; + $this->updateamum = $row->creationdate; + $this->updatevon = $row->creationuser; + } + else + { + $this->errormsg = 'Es ist kein Datensatz mit dieser ID vorhanden'; + return false; + } + return true; + } + + /** + * Laedt alle Lehrfunktionen + * @return true wenn ok, false im Fehlerfall + */ + function getAll() + { + $qry = "SELECT * FROM lehrfunktion;"; + + if(!$res = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Fehler beim laden der Datensaetze'; + return false; + } + + while($row = pg_fetch_object($res)) + { + $lehrfkt_obj = new lehrfunktion($this->conn); + + $lehrfkt_obj->lehrfunktion_id = $row->lehrfunktion_id; + $lehrfkt_obj->bezeichnung = $row->bezeichnung; + $lehrfkt_obj->standardfaktor = $row->standardfaktor; + $lehrfkt_obj->updateamum = $row->creationdate; + $lehrfkt_obj->updatevon = $row->creationuser; + + $this->result[] = $lehrfkt_obj; + } + return true; + } + + /** + * Speichert den aktuellen Datensatz in die Datenbank + * @return true wenn ok, false im Fehlerfall + */ + function save() + { + $this->errormsg = 'Noch nicht implementiert'; + return false; + } + + /** + * Loescht den Datensatz mit der ID die uebergeben wird + * @param lehrfkt_id ID des zu loeschenden Datensatzes + * @return true wenn ok, false im Fehlerfall + */ + function delete($lehrfkt_id) + { + $this->errormsg = 'Noch nicht implementiert'; + return false; + } +} +?> \ No newline at end of file diff --git a/include/fas/lehrveranstaltung.class.php b/include/fas/lehrveranstaltung.class.php new file mode 100644 index 000000000..8b145f5aa --- /dev/null +++ b/include/fas/lehrveranstaltung.class.php @@ -0,0 +1,427 @@ +conn = $conn; + $qry = "SET CLIENT_ENCODING TO 'UNICODE';"; + if(!pg_query($conn,$qry)) + { + $this->errormsg = "Encoding konnte nicht gesetzt werden"; + return false; + } + if($lehrveranstaltung_id != null) + $this->load($lehrveranstaltung_id); + } + + /** + * Laedt einen Datensatz + * @param $lehrveranstaltung_id ID des zu ladenden Datensatzes + * @return true wenn ok, false im Fehlerfall + */ + function load($lehrveranstaltung_id) + { + //gueltigkeit von lehrveranstaltung_id pruefen + if(!is_numeric($lehrveranstaltung_id) || $lehrveranstaltung_id == '') + { + $this->errormsg = 'lehrveranstaltung_id muss eine gueltige Zahl sein'; + return false; + } + + $qry = "SELECT * FROM lehrveranstaltung WHERE lehrveranstaltung_pk = '$lehrveranstaltung_id';"; + + if(!$res = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Datensatz konnte nicht geladen werden'; + return false; + } + + if($row = pg_fetch_object($res)) + { + $this->lehrveranstaltung_id = $row->lehrveranstaltung_pk; + $this->art = $row->art; + $this->ausbildungssemester_id = $row->ausbildungssemester_fk; + $this->beschreibung = $row->beschreibung; + $this->ectspunkte = $row->ectspunkte; + $this->fachbereich_id = $row->fachbereich_fk; + $this->kategorie = $row->kategorie; + $this->kurzbezeichnung = $row->kurzbezeichnung; + $this->name = $row->name; + $this->notenlektor_id = $row->notenlektor_fk; + $this->nummer = $row->nummer; + $this->nummerintern = $row->nummerintern; + $this->sortierung = $row->sortierung; + $this->studentenwochenstunden = $row->studentenwochenstunden; + $this->studiengang_id = $row->studiengang_fk; + $this->studiensemester_id = $row->studiensemester_fk; + $this->updateamum = $row->creationdate; + $this->updatevon = $row->creationuser; + } + else + { + $this->errormsg = 'Datensatz konnte nicht geladen werden'; + return false; + } + + return true; + } + + /** + * Liefert alle Lehrveranstaltungen + * @return true wenn ok, false im Fehlerfall + */ + function getAll() + { + $qry = "SELECT * FROM lehrveranstaltung;"; + + if(!$res = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Datensatz konnte nicht geladen werden'; + return false; + } + + while($row = pg_fetch_object($res)) + { + $lv_obj = new lehrveranstaltung($this->conn); + + $lv_obj->lehrveranstaltung_id = $row->lehrveranstaltung_pk; + $lv_obj->art = $row->art; + $lv_obj->ausbildungssemester_id = $row->ausbildungssemester_fk; + $lv_obj->beschreibung = $row->beschreibung; + $lv_obj->ectspunkte = $row->ectspunkte; + $lv_obj->fachbereich_id = $row->fachbereich_fk; + $lv_obj->kategorie = $row->kategorie; + $lv_obj->kurzbezeichnung = $row->kurzbezeichnung; + $lv_obj->name = $row->name; + $lv_obj->notenlektor_id = $row->notenlektor_fk; + $lv_obj->nummer = $row->nummer; + $lv_obj->nummerintern = $row->nummerintern; + $lv_obj->sortierung = $row->sortierung; + $lv_obj->studentenwochenstunden = $row->studentenwochenstunden; + $lv_obj->studiengang_id = $row->studiengang_fk; + $lv_obj->studiensemester_id = $row->studiensemester_fk; + $lv_obj->updateamum = $row->creationdate; + $lv_obj->updatevon = $row->creationuser; + + $this->result[] = $lv_obj; + } + + return true; + } + + /** + * Liefert alle Lehrveranstaltungen zu einem Studiengang/Studiensemester/Ausbildungssemester + * @param $studiengang_id ID des Studienganges + * $studiensemester_id ID des Studiensemesters (optional) + * $ausbildungssemester_id ID des ausbildungssemesters (optional) + * @return true wenn ok, false im Fehlerfall + */ + function load_lva($studiengang_id, $studiensemester_id=null, $ausbildungssemester_id=null) + { + //Variablen pruefen + if(!is_numeric($studiengang_id) || $studiengang_id =='') + { + $this->errormsg = 'studiengang_id muss eine gueltige Zahl sein'; + return false; + } + if($studiensemester_id != null && (!is_numeric($studiensemester_id) || $studiensemester_id == '')) + { + $this->errormsg = 'studiensemester_id muss eine gueltige Zahl sein'; + return false; + } + if($ausbildungssemester_id != null && (!is_numeric($ausbildungssemester_id) || $ausbildungssemester_id == '')) + { + $this->errormsg = 'ausbildungssemester_id muss eine gueltige Zahl sein'; + return false; + } + + //Select Befehl zusammenbauen + $qry = "SELECT * FROM lehrveranstaltung WHERE studiengang_fk = '$studiengang_id'"; + + if($studiensemester_id != null) + $qry .= " AND studiensemester_fk = '$studiensemester_id'"; + + if($ausbildungssemester_id != null) + $qry .= " AND ausbildungssemester_fk = '$ausbildungssemester_id'"; + $qry .= " ORDER BY name"; + //Datensaetze laden + if(!$res = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Datensatz konnte nicht geladen werden'; + return false; + } + + while($row = pg_fetch_object($res)) + { + $lv_obj = new lehrveranstaltung($this->conn); + + $lv_obj->lehrveranstaltung_id = $row->lehrveranstaltung_pk; + $lv_obj->art = $row->art; + $lv_obj->ausbildungssemester_id = $row->ausbildungssemester_fk; + $lv_obj->beschreibung = $row->beschreibung; + $lv_obj->ectspunkte = $row->ectspunkte; + $lv_obj->fachbereich_id = $row->fachbereich_fk; + $lv_obj->kategorie = $row->kategorie; + $lv_obj->kurzbezeichnung = $row->kurzbezeichnung; + $lv_obj->name = $row->name; + $lv_obj->notenlektor_id = $row->notenlektor_fk; + $lv_obj->nummer = $row->nummer; + $lv_obj->nummerintern = $row->nummerintern; + $lv_obj->sortierung = $row->sortierung; + $lv_obj->studentenwochenstunden = $row->studentenwochenstunden; + $lv_obj->studiengang_id = $row->studiengang_fk; + $lv_obj->studiensemester_id = $row->studiensemester_fk; + $lv_obj->updateamum = $row->creationdate; + $lv_obj->updatevon = $row->creationuser; + + $this->result[] = $lv_obj; + } + + return true; + } + + /** + * Prueft die Gueltigkeit der Variablen + * @return true wenn ok, false im Fehlerfall + */ + function checkvars() + { + $this->name = str_replace("'",'´',$this->name); + $this->nummer = str_replace("'",'´',$this->nummer); + $this->kurzbezeichnung = str_replace("'",'´',$this->kurzbezeichnung); + + //Laenge Pruefen + $this->errormsg = 'Eine der Gesamtlaengen wurde ueberschritten'; + if(strlen($this->name)>255) + { + $this->errormsg = 'Name darf nicht laenger als 255 Zeichen sein'; + return false; + } + if(strlen($this->nummer)>20) + { + $this->errormsg = 'Nummer darf nicht laenger als 20 Zeichen sein'; + return false; + } + if(strlen($this->kurzbezeichnung)>20) + { + $this->errormsg = 'kurzbezeichnung darf nicht laenger als 20 Zeichen sein'; + return false; + } + + if(!is_numeric($this->fachbereich_id)) + { + $this->errormsg = 'Fachbereich_id ist ungueltig'; + return false; + } + if(!is_numeric($this->studiengang_id)) + { + $this->errormsg = 'Studiengang_id ist ungueltig'; + return false; + } + if(!is_numeric($this->ausbildungssemester_id)) + { + $this->errormsg = 'Ausbildungssemester_id ist ungueltig'; + return false; + } + if($this->art!='' && !is_numeric($this->art)) + { + $this->errormsg = 'Art ist ungueltig'; + return false; + } + if($this->studentenwochenstunden!='' && !is_numeric($this->studentenwochenstunden)) + { + $this->errormsg = 'Studentenwochenstunden ist ungueltig'; + return false; + } + if($this->kategorie!='' && !is_numeric($this->kategorie)) + { + $this->errormsg = "Kategorie ist ungueltig"; + return false; + } + if($this->ectspunkte!='' && !is_numeric($this->ectspunkte)) + { + $this->errormsg = 'ECTSPunkte sind ungueltig'; + return false; + } + if($this->notentlektor_id!='' && !is_numeric($this->notenlektor_id)) + { + $this->errormsg = 'Notenlektor ist ungueltig'; + return false; + } + if($this->sortierung!='' && !is_numeric($this->sortierung)) + { + $this->errormsg = 'Sortierung ist ungueltig'; + return false; + } + if($this->nummerintern!='' && !is_numeric($this->nummerintern)) + { + $this->errormsg = 'NummerIntern ist ungueltig'; + return false; + } + + if(!is_numeric($this->studiensemester_id)) + { + $this->errormsg = 'Studiensemester_id ist ungueltig'; + return false; + } + + $this->errormsg = ''; + return true; + } + + /** + * Speichert den aktuellen Datensatz + * @return true wenn ok, false im Fehlerfall + */ + function save() + { + //Gueltigkeit der Variablen pruefen + if(!$this->checkvars()) + return false; + + if($this->new) + { + //Neuen Datensatz anlegen + + //naechste ID aus der Sequence holen + $qry = "SELECT nextval('lehrveranstaltung_seq') as id;"; + if(!$row = pg_fetch_object(pg_query($this->conn, $qry))) + { + $this->errormsg = 'Sequence konnte nicht ausgelesen werden'; + return false; + } + $this->lehrveranstaltung_id = $row->id; + + $qry = "INSERT INTO lehrveranstaltung(lehrveranstaltung_pk, fachbereich_fk, studiengang_fk, ausbildungssemester_fk,". + " name, nummer, kurzbezeichnung, beschreibung, art, studentenwochenstunden, creationdate, creationuser,". + " kategorie, ectspunkte, studiensemester_fk, notenlektor_fk, sortierung, nummerintern) VALUES(". + " '$this->lehrveranstaltung_id', '$this->fachbereich_id', '$this->studiengang_id', '$this->ausbildungssemester_id',". + " '$this->name', '$this->nummer', '$this->kurzbezeichnung', '$this->beschreibung', '$this->art',". + " '$this->studentenwochenstunden', now(), $this->updatevon, '$this->kategorie', '$this->ectspunkte', '$this->studiensemester_id',". + " '$this->notenlektor_id', '$this->sortierung', '$this->nummerintern');"; + } + else + { + //bestehenden Datensatz akualisieren + + //Pruefen ob lehrveranstaltung_id eine gueltige Zahl ist + if(!is_numeric($this->lehrveranstaltung_id) || $this->lehrveranstaltung_id == '') + { + $this->errormsg = 'lehrveranstaltung_id muss eine gueltige Zahl sein'; + return false; + } + + $qry = "UPDATE lehrveranstaltung SET fachbereich_fk = '$this->fachbereich_id', studiengang_fk = '$this->studiengang_id',". + " ausbildungssemester_fk = '$this->ausbildungssemester_id', name = '$this->name', nummer = '$this->nummer',". + " kurzbezeichnung = '$this->kurzbezeichnung', beschreibung = '$this->beschreibung', art = '$this->art',". + " studentenwochenstunden = '$this->studentenwochenstunden', kategorie = '$this->kategorie', ". + " ectspunkte = '$this->ectspunkte', studiensemester_fk = '$this->studiensemester_id',". + " notenlektor_fk = '$this->notenlektor_id', sortierung = '$this->sortierung', nummerintern = '$this->nummerintern'". + " WHERE lehrveranstaltung_pk = '$this->lehrveranstaltung_id';"; + } + + if(pg_query($this->conn, $qry)) + { + //Log schreiben + $sql = $qry; + $qry = "SELECT nextval('log_seq') as id;"; + if(!$row = pg_fetch_object(pg_query($this->conn, $qry))) + { + $this->errormsg = 'Fehler beim Auslesen der Log-Sequence'; + return false; + } + + $qry = "INSERT INTO log(log_pk, creationdate, creationuser, sql) VALUES('$row->id', now(), '$this->updatevon', '".addslashes($sql)."')"; + if(pg_query($this->conn, $qry)) + return true; + else + { + $this->errormsg = 'Fehler beim Speichern des Log-Eintrages'; + return false; + } + } + else + { + $this->errormsg = 'Fehler beim speichern des Datensatzes'; + return false; + } + } + + /** + * Loescht einen Datensatz + * @param $lehrveranstaltung_id ID des zu loeeschenden Datensatzes + * @return true wenn ok, false im Fehlerfall + */ + function delete($lehrveranstaltung_id) + { + //lehrveranstaltung_id auf gueltigkeit pruefen + if(!is_numeric($lehrveranstaltung_id) || $lehrveranstaltung_id == '') + { + $this->errormsg = 'lehrveranstaltung_id muss eine gueltige Zahl sein'; + return false; + } + + //Loeschen des Datensatzes + $qry = "DELETE FROM lehrveranstaltung WHERE lehrveranstaltung_pk = '$lehrveranstaltung_id';"; + + if(pg_query($this->conn, $qry)) + { + //Log schreiben + $sql = $qry; + $qry = "SELECT nextval('log_seq') as id;"; + if(!$row = pg_fetch_object(pg_query($this->conn, $qry))) + { + $this->errormsg = 'Fehler beim Auslesen der Log-Sequence'; + return false; + } + + $qry = "INSERT INTO log(log_pk, creationdate, creationuser, sql) VALUES('$row->id', now(), '$this->updatevon', '".addslashes($sql)."')"; + if(pg_query($this->conn, $qry)) + return true; + else + { + $this->errormsg = 'Fehler beim Speichern des Log-Eintrages'; + return false; + } + } + else + { + $this->errormsg = 'Fehler beim loeschen des Datensatzes'; + return false; + } + } +} +?> \ No newline at end of file diff --git a/include/fas/mitarbeiter.class.php b/include/fas/mitarbeiter.class.php new file mode 100644 index 000000000..a53bdfcdb --- /dev/null +++ b/include/fas/mitarbeiter.class.php @@ -0,0 +1,742 @@ +conn = $conn; + $qry = "SET CLIENT_ENCODING TO 'UNICODE';"; + if(!pg_query($conn,$qry)) + { + $this->errormsg = "Encoding konnte nicht gesetzt werden"; + return false; + } + //Mitarbeiter laden + if($person_id!=null) + $this->load($person_id); + } + + /** + * ueberprueft die Variablen auf Gueltigkeit + * @return true wenn gueltig, false im Fehlerfall + */ + function checkvars() + { + //Hochkomma herausfiltern + $this->persnr = str_replace("'","`", $this->persnr); + $this->kurzbez = str_replace("'","`", $this->kurzbez); + + //Maximallaenge pruefen + $this->errormsg='Die Maximallaenge eines Feldes wurde ueberschritten'; + if(strlen($this->persnr)>20) + { + $this->errormsg='PersonalNr darf nicht länger als 20 Zeichen sein'; + return false; + } + if(strlen($this->kurzbez)>10) + { + $this->errormsg="Kurzbezeichnung darf nicht länger als 10 Zeichen sein:".strlen($this->kurzbez); + return false; + } + + //Zahlenwerte ueberpruefen + $this->errormsg='Ein Zahlenfeld enthaelt ungueltige Zeichen'; + //if(!is_numeric($this->qualifikation)) return false; + //if(!is_numeric($this->hauptberuf)) return false; + if(!is_numeric($this->stundensatz) && $this->stundensatz!='') + { + $this->errormsg='Stundensatz muss eine gueltige Zahl sein'; + return false; + } + if(!is_numeric($this->ausbildung) && $this->ausbildung!='') + { + $this->errormsg='ausbildung muss eine gueltige Zahl sein'; + return false; + } + /*if(!is_numeric($this->semesterwochenstunden)) + { + $this->errormsg='SWS muss eine gueltige Zahl sein'; + return false; + }*/ + + if($this->kurzbz_exists($this->kurzbez, $this->mitarbeiter_id)) + { + $this->errormsg = 'Diese Kurzbezeichnung wird bereits verwendet'; + return false; + } + + $this->errormsg = ''; + return true; + } + + + /** + * Speichert die Mitarbeiterdaten in die Datenbank + * @return true wenn ok, false im Fehlerfall + */ + function save() + { + //Variablen checken + if(!$this->checkvars()) + return false; + + pg_query($this->conn,"Begin;"); + //Basisdaten speichern + if(!person::save()) + { + pg_query($this->conn,"Rollback;"); + return false; + } + + if($this->new) + { + //Neuen Datensatz einfuegen + + //naechste ID aus Sequence auslesen + $qry = "SELECT nextval('mitarbeiter_seq') as id;"; + if(!$row = pg_fetch_object(pg_query($this->conn,$qry))) + { + $this->errormsg = 'Fehler beim auslesen der Sequence'; + return false; + } + $this->mitarbeiter_id = $row->id; + + $qry = "INSERT INTO mitarbeiter (mitarbeiter_pk, beginndatum, akadgrad, habilitation,". + //" mitgliedentwicklungsteam,". + //" qualifikation, hauptberuflich, hauptberuf, semesterwochenstunden,". + " creationdate, creationuser, persnr,". + " person_fk, beendigungsdatum, ausgeschieden, kurzbez, stundensatz, ausbildung, aktiv) VALUES (". + " '$this->mitarbeiter_id',". + (strlen($this->beginndatum)>0?"'$this->beginndatum'":"NULL") .", '".($this->akadgrad?'J':'N')."',". + " '".($this->habilitation?'J':'N')."', ". + //"'".($this->mitgliedentwicklungsteam?'J':'N')."',". + //" '$this->qualifikation', '".($this->hauptberuflich?'J':'N')."', '$this->hauptberuf', '$this->semesterwochenstunden',". + " now(),". + " '$this->updatevon', '$this->persnr', '$this->person_id',". + (strlen($this->beendigungsdatum)>0?"'$this->beendigungsdatum'":"null").",". + " '".($this->ausgeschieden?'J':'N')."',". + (strlen($this->kurzbez)>0?"'$this->kurzbez'":"null").", '$this->stundensatz',". + ($this->ausbildung!=''?"'$this->ausbildung'":'null').",'$this->aktiv');"; + } + else + { + //Bestehenden Datensatz ueberschreiben + + //mitarbeiter_id auf Gueltigkeit pruefen + if(!is_numeric($this->mitarbeiter_id)) + { + $this->errormsg = 'mitarbeiter_id muss eine gueltige Zahl sein'; + return false; + } + + $qry = "UPDATE mitarbeiter SET". + " beginndatum=".($this->beginndatum!=''?"'$this->beginndatum'":'null').",". + " akadgrad='".($this->akadgrad?'J':'N')."',". + " habilitation='".($this->habilitation?'J':'N')."',". + //" mitgliedentwicklungsteam='".($this->mitgliedentwicklungsteam?'J':'N')."',". + //" qualifikation='$this->qualifikation', hauptberuflich='".($this->hauptberuflich?'J':'N')."',". + //" hauptberuf='$this->hauptberuf', semesterwochenstunden='$this->semesterwochenstunden',". + " persnr=".($this->persnr!=''?"'$this->persnr'":'null').",". + " person_fk='$this->person_id',". + " beendigungsdatum=".($this->beendigungsdatum!=''?"'$this->beendigungsdatum'":'null').",". + " ausgeschieden='".($this->ausgeschieden?'J':'N')."',". + " kurzbez=".($this->kurzbez!=''?"'$this->kurzbez'":'null').",". + " stundensatz=".($this->stundensatz!=''?"'$this->stundensatz'":'null').",". + " ausbildung=".($this->ausbildung!=''?"'$this->ausbildung'":'null').",". + " aktiv='$this->aktiv'". + " WHERE mitarbeiter_pk=$this->mitarbeiter_id;"; + } + + if(pg_query($this->conn,$qry)) + { + //Wenn nicht ausgeschieden dann den Status neu setzen + //Da sonst beim ruecksetzen des Hakerls ausgeschieden der status bleibt + if(!$this->ausgeschieden) + { + if(!person::updateaktstatus($this->person_id)) + { + pg_query($this->conn,"Rollback;"); + return false; + } + } + else + { + if(!person::setaktstatus(150,$this->person_id)) + { + pg_query($this->conn,"Rollback;"); + return false; + } + } + pg_query($this->conn,"Commit;"); + //Log schreiben + $sql = $qry; + $qry = "SELECT nextval('log_seq') as id;"; + if(!$row = pg_fetch_object(pg_query($this->conn, $qry))) + { + $this->errormsg = 'Fehler beim Auslesen der Log-Sequence'; + return false; + } + + $qry = "INSERT INTO log(log_pk, creationdate, creationuser, sql) VALUES('$row->id', now(), '$this->updatevon', '".addslashes($sql)."')"; + if(pg_query($this->conn, $qry)) + return true; + else + { + $this->errormsg = 'Fehler beim Speichern des Log-Eintrages'; + return false; + } + } + else + { + pg_query($this->conn,"Rollback;"); + $this->errormsg = 'Fehler beim Speichern des Mitarbeiter-Datensatzes'; + return false; + } + } + + /** + * Ladet die Daten aus der Datenbank + * @param $fix wenn 'true' Fixangestellte laden + * wenn 'false' Freie MA laden + * $stgl wenn 'true' Studiengangsleiter laden + * $fbl wenn 'true' Fachbereichsleiter laden + * $aktiv wenn 'true' Aktive MA laden + * $karrenziert wenn 'true' Karenzierte laden + * $ausgesch wenn 'true' Ausgeschiedene laden + * @return true wenn ok, false im Fehlerfall + */ + function getMitarbeiter($mitarbeiter_id='', $fix='', $stgl='', $fbl='', $aktiv='', $karenziert='', $ausgesch='', $adresse=false, $studiensemester_id='') + { + $qry = "SELECT * FROM (mitarbeiter JOIN person ON (person_pk=mitarbeiter.person_fk))"; + if($adresse) + $qry .= " LEFT JOIN adresse on(person_pk=adresse.person_fk)"; + $qry .= " WHERE true"; + + if($mitarbeiter_id!='') + if(is_numeric($mitarbeiter_id)) + $qry .= " AND mitarbeiter_pk = $mitarbeiter_id"; + else + { + $this->errormsg = "mitarbeiter_id muss eine gueltige Zahl sein"; + return false; + } + + if($studiensemester_id=='') + { + $query = "Select studiensemester_pk FROM studiensemester WHERE aktuell='J'"; + if($row = pg_fetch_object(pg_query($this->conn, $query))) + $studiensemester_id = $row->studiensemester_pk; + } + + if($fix=='true') // Alle Fixangestellten + $qry .= " AND mitarbeiter_pk IN(SELECT distinct funktion.mitarbeiter_fk FROM funktion WHERE funktion.beschart1=3 AND funktion.studiensemester_fk='$studiensemester_id')"; + + if($fix=='false') // Freie Mitarbeiter + $qry .= " AND mitarbeiter_pk IN(SELECT distinct funktion.mitarbeiter_fk FROM funktion WHERE funktion.beschart1=4 AND funktion.studiensemester_fk='$studiensemester_id')"; + + if($stgl=='true') //Alle Studiengangsleiter + $qry .= " AND mitarbeiter_pk IN(SELECT distinct funktion.mitarbeiter_fk FROM funktion WHERE funktion.funktion=5 AND funktion.studiensemester_fk='$studiensemester_id')"; + + + if($fbl=='true') //Alle Fachbereichsleiter + $qry .= " AND mitarbeiter_pk IN(SELECT distinct funktion.mitarbeiter_fk FROM funktion WHERE funktion.funktion=6 AND funktion.studiensemester_fk='$studiensemester_id')"; + + if($aktiv=='true') //Alle aktiven + $qry .= " AND aktiv=true"; + + if($karenziert=='true') //Alle Karenzierten + $qry .= " AND mitarbeiter_pk IN(SELECT distinct funktion.mitarbeiter_fk FROM funktion WHERE funktion.ausmass=5 AND funktion.studiensemester_fk='$studiensemester_id')"; + + if($ausgesch=='true') // Alle Ausgeschiedenen + $qry .= " AND beendigungsdatum is not null"; + + $qry .= " ORDER BY familienname"; + if(!$res = pg_query($this->conn,$qry)) + { + $this->errormsg = 'Fehler bei einer Datenbankabfrage'; + return false; + } + + while($row = pg_fetch_object($res)) + { + $mitarb = new mitarbeiter($this->conn); + //Personendaten + $mitarb->person_id = $row->person_pk; + $mitarb->familienname = $row->familienname; + $mitarb->angelegtam = $row->angelegtam; + $mitarb->vorname = $row->vorname; + $mitarb->anrede = $row->anrede; + $mitarb->vornamen = $row->vornamen; + $mitarb->geschlecht = $row->geschlecht; + $mitarb->gebdat = $row->gebdat; + $mitarb->gebort = $row->gebort; + $mitarb->staatsbuergerschaft = $row->staatsbuergerschaft; + $mitarb->familienstand = $row->familienstand; + $mitarb->familienstand_bezeichnung = $this->getFamilienstandBezeichnung($row->familienstand); + $mitarb->svnr = $row->svnr; + $mitarb->anzahlderkinder = $row->anzahlderkinder; + $mitarb->ersatzkennzeichen = $row->ersatzkennzeichen; + $mitarb->bemerkung = $row->bemerkung; + $mitarb->aktstatus = $row->aktstatus; + $mitarb->aktstatus_bezeichnung = $this->getAktstatusBezeichnung($row->aktstatus); + $mitarb->bismelden = ($row->bismelden=='J'?true:false); + $mitarb->bismelden_bezeichnung = ($row->bismelden=='J'?'Ja':'Nein'); + $mitarb->titelpre = $row->titel; + $mitarb->titelpost = $row->postnomentitel; + $mitarb->uid = $row->uid; + $mitarb->gebnation = $row->gebnation; + + //Mitarbeiterdaten + $mitarb->mitarbeiter_id = $row->mitarbeiter_pk; + $mitarb->beginndatum = $row->beginndatum; + $mitarb->akadgrad = ($row->akadgrad=='J'?true:false); + $mitarb->akadgrad_bezeichnung = ($row->akadgrad=='J'?'Ja':'Nein'); + $mitarb->habilitation = ($row->habilitation=='J'?true:false); + $mitarb->habilitation_bezeichnung = ($row->habilitation=='J'?'Ja':'Nein'); + $mitarb->mitgliedentwicklungsteam = ($row->mitgliedentwicklungsteam=='J'?true:false); + $mitarb->qualifikation = $row->qualifikation; + $mitarb->hauptberuflich = ($row->hauptberuflich=='J'?true:false); + $mitarb->hauptberuf = $row->hauptberuf; + $mitarb->updateamum = $row->creationdate; + $mitarb->updatevon = $row->creationuser; + $mitarb->semesterwochenstunden = $row->semesterwochenstunden; + $mitarb->persnr = $row->persnr; + $mitarb->beendigungsdatum = $row->beendigungsdatum; + $mitarb->ausgeschieden = ($row->ausgeschieden=='J'?true:false); + $mitarb->ausgeschieden_bezeichnung = ($row->ausgeschieden=='J'?'Ja':'Nein'); + $mitarb->kurzbez = $row->kurzbez; + $mitarb->stundensatz = $row->stundensatz; + $mitarb->ausbildung = $row->ausbildung; + $mitarb->ausbildung_bezeichnung = $this->getAusbildungBezeichnung($row->ausbildung); + $mitarb->aktiv = ($row->aktiv=='t'?true:false); + $mitarb->aktiv_bezeichnung = ($row->aktiv=='t'?'Ja':'Nein'); + + if($adresse) + { + $mitarb->zustelladresse_plz = $row->plz; + $mitarb->zustelladresse_strasse = $row->strasse; + $mitarb->zustelladresse_ort = $row->ort; + } + $this->result[] = $mitarb; + } + return true; + } + + /** + * Liefert alle Mitarbeiter + * @return true wenn ok, false im Fehlerfall + */ + function getAll() + { + + $qry = "Select person_pk, familienname, angelegtam, vorname, anrede, vornamen, geschlecht, gebdat, gebort, staatsbuergerschaft, ". + "familienstand, svnr, anzahlderkinder, ersatzkennzeichen, bemerkung, aktstatus, bismelden, titel, postnomentitel, uid, gebnation, ". + "mitarbeiter_pk, beginndatum, akadgrad, habilitation, mitgliedentwicklungsteam, qualifikation, hauptberuflich, hauptberuf, ". + "mitarbeiter.creationdate, mitarbeiter.creationuser, semesterwochenstunden, persnr, beendigungsdatum, ausgeschieden, ". + "kurzbez, stundensatz, ausbildung, aktiv FROM mitarbeiter JOIN person ON(person_pk=person_fk)"; + if(!$res = pg_query($this->conn,$qry)) + { + $this->errormsg = 'Fehler bei einer Datenbankabfrage'; + return false; + } + + while($row = pg_fetch_object($res)) + { + $mitarb = new mitarbeiter($this->conn); + //Personendaten + $mitarb->person_id = $row->person_pk; + $mitarb->familienname = $row->familienname; + $mitarb->angelegtam = $row->angelegtam; + $mitarb->vorname = $row->vorname; + $mitarb->anrede = $row->anrede; + $mitarb->vornamen = $row->vornamen; + $mitarb->geschlecht = $row->geschlecht; + $mitarb->gebdat = $row->gebdat; + $mitarb->gebort = $row->gebort; + $mitarb->staatsbuergerschaft = $row->staatsbuergerschaft; + $mitarb->familienstand = $row->familienstand; + $mitarb->svnr = $row->svnr; + $mitarb->anzahlderkinder = $row->anzahlderkinder; + $mitarb->ersatzkennzeichen = $row->ersatzkennzeichen; + $mitarb->bemerkung = $row->bemerkung; + $mitarb->aktstatus = $row->aktstatus; + $mitarb->bismelden = ($row->bismelden=='J'?true:false); + $mitarb->titelpre = $row->titel; + $mitarb->titelpost = $row->postnomentitel; + $mitarb->uid = $row->uid; + $mitarb->gebnation = $row->gebnation; + //Mitarbeiterdaten + $mitarb->mitarbeiter_id = $row->mitarbeiter_pk; + $mitarb->beginndatum = $row->beginndatum; + $mitarb->akadgrad = ($row->akadgrad=='J'?true:false); + $mitarb->habilitation = ($row->habilitation=='J'?true:false); + $mitarb->mitgliedentwicklungsteam = ($row->mitgliedentwicklungsteam=='J'?true:false); + $mitarb->qualifikation = $row->qualifikation; + $mitarb->hauptberuflich = ($row->hauptberuflich=='J'?true:false); + $mitarb->hauptberuf = $row->hauptberuf; + $mitarb->updateamum = $row->creationdate; + $mitarb->updatevon = $row->creationuser; + $mitarb->semesterwochenstunden = $row->semesterwochenstunden; + $mitarb->persnr = $row->persnr; + $mitarb->beendigungsdatum = $row->beendigungsdatum; + $mitarb->ausgeschieden = ($row->ausgeschieden=='J'?true:false); + $mitarb->kurzbez = $row->kurzbez; + $mitarb->stundensatz = $row->stundensatz; + $mitarb->ausbildung = $row->ausbildung; + $mitarb->aktiv = ($row->aktiv=='t'?true:false); + + $this->result[] = $mitarb; + } + return true; + + } + + /** + * Laedt die Mitarbeiterdaten der uebergebenen ID + * @param $person_id ID der Person die geladen werden soll + * @return true wenn ok, false im Fehlerfall + */ + function load($person_id) + { + //person_id auf Gueltigkeit pruefen + if(!is_numeric($person_id) || $person_id=='') + { + $this->errormsg = 'Person_id muss eine Zahl sein'; + return false; + } + + $qry = "SELECT person_pk, familienname, angelegtam, vorname, anrede, vornamen, geschlecht, gebdat, gebort, staatsbuergerschaft, ". + "familienstand, svnr, anzahlderkinder, ersatzkennzeichen, bemerkung, aktstatus, bismelden, titel, postnomentitel, uid, gebnation, ". + "mitarbeiter_pk, beginndatum, akadgrad, habilitation, mitgliedentwicklungsteam, qualifikation, hauptberuflich, hauptberuf, ". + "mitarbeiter.creationdate, mitarbeiter.creationuser, semesterwochenstunden, persnr, beendigungsdatum, ausgeschieden, ". + "kurzbez, stundensatz, ausbildung, aktiv FROM mitarbeiter JOIN person ON(person_pk=person_fk) where person_pk=$person_id"; + if(!$res = pg_query($this->conn,$qry)) + { + $this->errormsg = 'Fehler bei einer Datenbankabfrage'; + return false; + } + + if($row = pg_fetch_object($res)) + { + //Personendaten + $this->person_id = $row->person_pk; + $this->familienname = $row->familienname; + $this->angelegtam = $row->angelegtam; + $this->vorname = $row->vorname; + $this->anrede = $row->anrede; + $this->vornamen = $row->vornamen; + $this->geschlecht = $row->geschlecht; + $this->gebdat = $row->gebdat; + $this->gebort = $row->gebort; + $this->staatsbuergerschaft = $row->staatsbuergerschaft; + $this->familienstand = $row->familienstand; + $this->svnr = $row->svnr; + $this->anzahlderkinder = $row->anzahlderkinder; + $this->ersatzkennzeichen = $row->ersatzkennzeichen; + $this->bemerkung = $row->bemerkung; + $this->aktstatus = $row->aktstatus; + $this->bismelden = ($row->bismelden=='J'?true:false); + $this->titelpre = $row->titel; + $this->titelpost = $row->postnomentitel; + $this->uid = $row->uid; + $this->gebnation = $row->gebnation; + //Mitarbeiterdaten + $this->mitarbeiter_id = $row->mitarbeiter_pk; + $this->beginndatum = $row->beginndatum; + $this->akadgrad = ($row->akadgrad=='J'?true:false); + $this->habilitation = ($row->habilitation=='J'?true:false); + $this->mitgliedentwicklungsteam = ($row->mitgliedentwicklungsteam=='J'?true:false); + $this->qualifikation = $row->qualifikation; + $this->hauptberuflich = ($row->hauptberuflich=='J'?true:false); + $this->hauptberuf = $row->hauptberuf; + $this->updateamum = $row->creationdate; + $this->updatevon = $row->creationuser; + $this->semesterwochenstunden = $row->semesterwochenstunden; + $this->persnr = $row->persnr; + $this->beendigungsdatum = $row->beendigungsdatum; + $this->ausgeschieden = ($row->ausgeschieden=='J'?true:false); + $this->kurzbez = $row->kurzbez; + $this->stundensatz = $row->stundensatz; + $this->ausbildung = $row->ausbildung; + $this->aktiv = ($row->aktiv=='t'?true:false); + } + else + { + $this->errormsg = 'Es ist kein Datensatz mit dieser ID vorhanden'; + return false; + } + + return true; + } + + /** + * Laedt die Mitarbeiterdaten der uebergebenen ID + * @param $mitarbeiter_id ID der Person die geladen werden soll + * @return true wenn ok, false im Fehlerfall + */ + function load_mitarbeiter($mitarbeiter_id) + { + //person_id auf Gueltigkeit pruefen + if(!is_numeric($mitarbeiter_id) || $mitarbeiter_id=='') + { + $this->errormsg = 'Person_id muss eine Zahl sein'; + return false; + } + + $qry = "SELECT person_pk, familienname, angelegtam, vorname, anrede, vornamen, geschlecht, gebdat, gebort, staatsbuergerschaft, ". + "familienstand, svnr, anzahlderkinder, ersatzkennzeichen, bemerkung, aktstatus, bismelden, titel, postnomentitel, uid, gebnation, ". + "mitarbeiter_pk, beginndatum, akadgrad, habilitation, mitgliedentwicklungsteam, qualifikation, hauptberuflich, hauptberuf, ". + "mitarbeiter.creationdate, mitarbeiter.creationuser, semesterwochenstunden, persnr, beendigungsdatum, ausgeschieden, ". + "kurzbez, stundensatz, ausbildung, aktiv FROM mitarbeiter JOIN person ON(person_pk=person_fk) where mitarbeiter_pk=$mitarbeiter_id"; + if(!$res = pg_query($this->conn,$qry)) + { + $this->errormsg = 'Fehler bei einer Datenbankabfrage'; + return false; + } + + if($row = pg_fetch_object($res)) + { + //Personendaten + $this->person_id = $row->person_pk; + $this->familienname = $row->familienname; + $this->angelegtam = $row->angelegtam; + $this->vorname = $row->vorname; + $this->anrede = $row->anrede; + $this->vornamen = $row->vornamen; + $this->geschlecht = $row->geschlecht; + $this->gebdat = $row->gebdat; + $this->gebort = $row->gebort; + $this->staatsbuergerschaft = $row->staatsbuergerschaft; + $this->familienstand = $row->familienstand; + $this->svnr = $row->svnr; + $this->anzahlderkinder = $row->anzahlderkinder; + $this->ersatzkennzeichen = $row->ersatzkennzeichen; + $this->bemerkung = $row->bemerkung; + $this->aktstatus = $row->aktstatus; + $this->bismelden = ($row->bismelden=='J'?true:false); + $this->titelpre = $row->titel; + $this->titelpost = $row->postnomentitel; + $this->uid = $row->uid; + $this->gebnation = $row->gebnation; + //Mitarbeiterdaten + $this->mitarbeiter_id = $row->mitarbeiter_pk; + $this->beginndatum = $row->beginndatum; + $this->akadgrad = ($row->akadgrad=='J'?true:false); + $this->habilitation = ($row->habilitation=='J'?true:false); + $this->mitgliedentwicklungsteam = ($row->mitgliedentwicklungsteam=='J'?true:false); + $this->qualifikation = $row->qualifikation; + $this->hauptberuflich = ($row->hauptberuflich=='J'?true:false); + $this->hauptberuf = $row->hauptberuf; + $this->updateamum = $row->creationdate; + $this->updatevon = $row->creationuser; + $this->semesterwochenstunden = $row->semesterwochenstunden; + $this->persnr = $row->persnr; + $this->beendigungsdatum = $row->beendigungsdatum; + $this->ausgeschieden = ($row->ausgeschieden=='J'?true:false); + $this->kurzbez = $row->kurzbez; + $this->stundensatz = $row->stundensatz; + $this->ausbildung = $row->ausbildung; + $this->aktiv = ($row->aktiv=='t'?true:false); + } + else + { + $this->errormsg = 'Es ist kein Datensatz mit dieser ID vorhanden'; + return false; + } + + return true; + } + + /** + * loescht den Mitarbeiter mit der uebergebenen ID + * @param ma_id Mitarbeiter_id + * @return true wenn ok, false im Fehlerfall + */ + function delete($person_id) + { + //person_id auf Gueltigkeit pruefen + if(!is_numeric($person_id) || $person_id=='') + { + $this->errormsg = 'Person_id muss eine Zahl sein'; + return false; + } + + $qry = "DELETE FROM funktion where mitarbeiter_fk=(Select mitarbeiter_pk from mitarbeiter where person_fk=$person_id);". + " DELETE FROM adresse where person_fk=$person_id;". + " DELETE FROM telefonnummer where person_fk=$person_id;". + " DELETE FROM email where person_fk=$person_id;". + " DELETE FROM mitarbeiter where person_fk=$person_id"; + + if(!pg_query($this->conn,$qry)) + { + $this->errormsg = 'Fehler beim Loeschen'; + return false; + } + else + { + if(!person::delete($person_id)) + return false; + else + { + //Log schreiben + $sql = $qry; + $qry = "SELECT nextval('log_seq') as id;"; + if(!$row = pg_fetch_object(pg_query($this->conn, $qry))) + { + $this->errormsg = 'Fehler beim Auslesen der Log-Sequence'; + return false; + } + + $qry = "INSERT INTO log(log_pk, creationdate, creationuser, sql) VALUES('$row->id', now(), '$this->updatevon', '".addslashes($sql)."')"; + if(pg_query($this->conn, $qry)) + return true; + else + { + $this->errormsg = 'Fehler beim Speichern des Log-Eintrages'; + return false; + } + } + } + return true; + } + + /** + * Liefert die passende Bezeichnung des Familienstandes + * @param $id ID des Familienstandes + */ + function getFamilienstandBezeichnung($id) + { + switch($id) + { + case 1: return 'ledig'; + case 2: return 'verheiratet'; + case 3: return 'geschieden'; + case 4: return 'verwitwet'; + default: return ''; + } + } + + /** + * Liefert die passende Bezeichnung der Ausbildung + * @param $id ID der Ausbildung + */ + function getAusbildungBezeichnung($id) + { + switch($id) + { + case 1: return 'Universitätsabschluss mit Doktorat als Zweit- oder Dritt- oder PhD-Abschluss'; + case 2: return 'Universitäts- oder Hochschulabschluss auf Diplom oder Magisterebene, Doktor als Erstabschluss'; + case 3: return 'Fachhochschulabschluss auf Diplom- oder Magisterebene'; + case 4: return 'Universitätsabschluss auf Bakkalaureatsebene'; + case 5: return 'Fachhochschulabschluss auf Bakkalaureatsebene'; + case 6: return 'Diplom einer Akademie'; + case 7: return 'Anderer tertiärer Bildungsabschluss'; + case 8: return 'Reifeprüfung einer allgemeinbildenden höheren Schule'; + case 9: return 'Reifeprüfung einer berufsbildenden höheren Schule'; + case 10: return 'Lehrabschlussprüfung'; + case 11: return 'Pflichtschule'; + default: return ''; + } + } + + /** + * Liefert die passende Bezeichnung des Aktuellen Status + * @param $id ID des Status + */ + function getAktstatusBezeichnung($id) + { + switch($id) + { + case 100: return 'Mitarbeiter'; + case 101: return 'Lektor'; + case 102: return 'Koordinator'; + case 103: return 'Fachbereichsleiter'; + case 104: return 'Studiengangsleiter'; + case 150: return 'Ausgeschieden'; + default: return ''; + } + } + + /** + * Prüft ob eine Kurzbezeichnung schon existiert. Falls eine mitarbeiter_id + * angegeben wird, dann wird dieser Datensatz von der ueberpruefung ausgeschlossen + * ( fuer Update eines Datensatzes) + */ + function kurzbz_exists($kurzbz, $mitarbeiter_id='') + { + if($kurzbz!='') + { + $this->errormsg = ''; + $qry = "SELECT count(*) as anz from mitarbeiter where kurzbez='$kurzbz'"; + if($mitarbeiter_id!='') + $qry .= " AND mitarbeiter_pk<>".$mitarbeiter_id; + + if($result = pg_query($this->conn,$qry)) + { + while ($row=pg_fetch_object($result)) + { + if($row->anz == 0) + { + return false; + } + else + { + return true; + } + } + } + else + { + $this->errormsg = 'Fehler beim pruefen der Kurzbezeichnung'; + return false; + } + } + return false; + } + + /** + * Liefert die naechste Personalnummer + */ + function getNextPersonalnr() + { + $qry = "SELECT max(persnr) AS persnr FROM mitarbeiter WHERE length(persnr)=(SELECT max(length(persnr)) FROM mitarbeiter)"; + if($row = pg_fetch_object(pg_query($this->conn,$qry))) + return $row->persnr+1; + else + return false; + } +} +?> \ No newline at end of file diff --git a/include/fas/nation.class.php b/include/fas/nation.class.php new file mode 100644 index 000000000..5e9e240e0 --- /dev/null +++ b/include/fas/nation.class.php @@ -0,0 +1,92 @@ +conn = $conn; + $qry = "SET CLIENT_ENCODING TO 'UNICODE';"; + if(!pg_query($conn,$qry)) + { + $this->errormsg = "Encoding konnte nicht gesetzt werden"; + return false; + } + if($code != null) + $this->load($code); + } + + /** + * Laedt die Funktion mit der ID $adress_id + * @param $code code der zu ladenden Nation + * @return true wenn ok, false im Fehlerfall + */ + function load($code) + { + $this->errormsg = 'Noch nicht implementiert'; + return false; + } + + /** + * Laedt alle Nationen + * @param ohnesperre wenn dieser Parameter auf true gesetzt ist werden + * nur die nationen geliefert dessen Buerger bei uns studieren duerfen + */ + function getAll($ohnesperre=false) + { + //Lesen der Daten aus der Datenbank + $qry = "SELECT * FROM nation"; + if($ohnesperre) + $qry .= " where sperre='N'"; + + $qry .=" order by kurztext"; + + if(!$res = pg_query($this->conn,$qry)) + { + $this->errormsg = 'Fehler bei einer Datenbankabfrage'; + return false; + } + + while($row = pg_fetch_object($res)) + { + $nation_obj = new nation($this->conn); + + $nation_obj->code = $row->code; + $nation_obj->sperre = $row->sperre; + $nation_obj->kontinent = $row->sperre; + $nation_obj->entwland = $row->entwland; + $nation_obj->euflag = $row->euflag; + $nation_obj->ewrflag = $row->ewrflag; + $nation_obj->kurztext = $row->kurztext; + $nation_obj->langtext = $row->langtext; + $nation_obj->engltext = $row->engltext; + + $this->result[] = $nation_obj; + } + return true; + } +} +?> \ No newline at end of file diff --git a/include/fas/person.class.php b/include/fas/person.class.php new file mode 100644 index 000000000..2d353c7e3 --- /dev/null +++ b/include/fas/person.class.php @@ -0,0 +1,615 @@ +conn = $conn; + $qry = "SET CLIENT_ENCODING TO 'UNICODE';"; + if(!pg_query($conn,$qry)) + { + $this->errormsg = "Encoding konnte nicht gesetzt werden"; + return false; + } + if($pers_id != null) + $this->load($pers_id); + } + + /** + * Laden einen Datensatz mit der Personal_id die uebergeben wird + * @param $person_id ID der Person die geladen werden soll + */ + function load($person_id) + { + //person_id auf gueltigkeit pruefen + if(is_numeric($person_id) && $person_id!='') + { + $qry = "SELECT * FROM person WHERE person_pk=$person_id"; + if(!$res=pg_query($this->conn,$qry)) + { + $this->errormsg = 'Fehler beim auslesen der Daten'; + return false; + } + + if($row = pg_fetch_object($res)) + { + $this->person_id = $row->person_pk; + $this->aktstatus = $row->aktstatus; + $this->angelegtam = $row->angelegtam; + $this->anrede = $row->anrede; + $this->anzahlderkinder = $row->anzahlderkinder; + $this->bemerkung = $row->bemerkung; + $this->bismelden = ($row->bismelden=='J'?true:false); + $this->ersatzkennzeichen = $row->ersatzkennzeichen; + $this->familienname = $row->familienname; + $this->familienstand = $row->familienstand; + $this->gebdat = $row->gebdat; + $this->gebnation = $row->gebnation; + $this->gebort = $row->gebort; + $this->geschlecht = $row->geschlecht; + $this->staatsbuergerschaft = $row->staatsbuergerschaft; + $this->svnr = $row->svnr; + $this->titelpre = $row->titel; + $this->titlepost = $row->postnomentitel; + $this->uid = $row->uid; + $this->vorname = $row->vorname; + $this->vornamen = $row->vornamen; + $this->updateamum = $row->creationdate; + $this->updatevon = $row->creationuser; + } + else + { + $this->errormsg = 'Es ist kein Datensatz mit dieser ID vorhanden'; + return false; + } + + return true; + } + else + { + $this->errormsg = "Die person_id muss eine Zahl sein"; + return false; + } + } + + // Clean stuff from a string + function clean_string1($string) + { + $trans = array("ä" => "ae", + "Ä" => "Ae", + "ö" => "oe", + "Ö" => "Oe", + "ü" => "ue", + "Ü" => "Ue", + "á" => "a", + "à" => "a", + "é" => "e", + "è" => "e", + "ó" => "o", + "ò" => "o", + "í" => "i", + "ì" => "i", + "ú" => "u", + "ù" => "u", + "ß" => "ss"); + $string = strtr($string, $trans); + return ereg_replace("[^a-zA-Z0-9]", "", $string); + //[:space:] + } + + /** + * Prueft die Variablen auf Gueltigkeit + * @return true wenn ok, false wenn Variablen ungueltig sind + */ + function checkvars1() + { + //Hochkomma herausfiltern + $this->familienname = str_replace("'","`", $this->familienname); + $this->vorname = str_replace("'","`", $this->vorname); + $this->anrede = str_replace("'","`", $this->anrede); + $this->vornamen = str_replace("'","`", $this->vornamen); + $this->gebort = str_replace("'","`", $this->gebort); + $this->svnr = str_replace("'","`", $this->svnr); + $this->titelpre = str_replace("'","`", $this->titelpre); + $this->titelpost = str_replace("'","`", $this->titelpost); + $this->gebnation = str_replace("'","`", $this->gebnation); + $this->ersatzkennzeichen = str_replace("'","`", $this->ersatzkennzeichen); + $this->bemerkung = str_replace("'","`", $this->bemerkung); + if(ereg("[^a-zA-Z0-9]", $this->uid)) + { + $this->errormsg = "UID darf keine Umlaute oder Sonderzeichen enthalten"; + return false; + } + + //Maximallaenge pruefen + if(strlen($this->familienname)>255) + { + $this->errormsg = 'Familienname darf nicht laenger als 255 Zeichen sein'; + return false; + } + if(strlen($this->vorname)>255) + { + $this->errormsg = 'Vorname darf nicht laenger als 255 Zeichen sein'; + return false; + } + if(strlen($this->anrede)>20) + { + $this->errormsg = 'Anrede darf nicht laenger als 20 Zeichen sein'; + return false; + } + if(strlen($this->vornamen)>255) + { + $this->errormsg = 'Vornamen darf nicht laenger als 255 Zeichen sein'; + return false; + } + if(strlen($this->geschlecht)>1) + { + $this->errormsg = 'Geschlecht darf nicht laenger als 1 Zeichen sein'; + return false; + } + if(strlen($this->gebort)>255) + { + $this->errormsg = 'Geburtsort darf nicht laenger als 255 Zeichen sein'; + return false; + } + if(strlen($this->svnr)!=10) + { + $this->errormsg = 'SVNR muss 10 Zeichen lang sein'; + return false; + } + if(!is_numeric($this->svnr)) + { + $this->errormsg = 'SVNR muss eine gueltige Zahl sein'; + return false; + } + + if($this->svnr=='0000000000') //Leere SVNR wird zum anlegen des neuen Leerdatensatzes benoetigt + $this->svnr=''; + else + { + //SVNR mit Pruefziffer pruefen + //Die 4. Stelle in der SVNR ist die Pruefziffer + //(Summe von (gewichtung[i]*svnr[i])) modulo 11 ergibt diese Pruefziffer + //Falls nicht, ist die SVNR ungueltig + $gewichtung = array(3,7,9,0,5,8,4,2,1,6); + $erg=0; + //Quersumme bilden + for($i=0;$i<10;$i++) + $erg += $gewichtung[$i] * $this->svnr{$i}; + + if($this->svnr{3}!=($erg%11)) //Vergleichen der Pruefziffer mit Quersumme Modulo 11 + { + $this->errormsg = 'SVNR ist ungueltig'; + return false; + } + } + if(strlen($this->bismelden)>1) + { + $this->errormsg = 'bismelden darf nicht laenger als 1 Zeichen sein'; + return false; + } + if(strlen($this->titelpre)>30) + { + $this->errormsg = 'titelpre darf nicht laenger als 30 Zeichen sein'; + return false; + } + if(strlen($this->titelpost)>30) + { + $this->errormsg = 'titelpost darf nicht laenger als 30 Zeichen sein'; + return false; + } + if(strlen($this->uid)>20) + { + $this->errormsg = 'uid darf nicht laenger als 20 Zeichen sein'; + return false; + } + if(strlen($this->gebnation)>3) + { + $this->errormsg = 'Geburtsnation darf nicht laenger als 3 Zeichen sein'; + return false; + } + if(strlen($this->staatsbuergerschaft)>3) + { + $this->errormsg = 'Staatsbürgerschaft darf nicht laenger als 3 Zeichen sein'; + return false; + } + if(strlen($this->ersatzkennzeichen)>10) + { + $this->errormsg = 'ersatzkennzeichen darf nicht laenger als 10 Zeichen sein'; + return false; + } + + //Zahlenwerte ueberpruefen + $this->errormsg = 'Ein Zahlenfeld enthaelt ungueltige Zeichen'; + if(!is_numeric($this->familienstand) && $this->familienstand!='') return false; + if(!is_numeric($this->anzahlderkinder) && $this->anzahlderkinder!='') return false; + if(!is_numeric($this->aktstatus) && $this->aktstatus!='') return false; + + if($this->gebdat!='' && (time() - strtotime($this->gebdat))<315360000) // Wenn nicht aelter als 10 Jahre = 315360000 Sekunden + { + $this->errormsg = 'Geburtsdatum ist falsch: Person muss älter als 10 Jahre sein'; + return false; + } + + if($this->uid_exists($this->uid, $this->person_id)) + { + $this->errormsg = 'Diese UID existiert bereits'; + return false; + } + + $this->errormsg=''; + return true; + } + + /** + * Speichert die Daten in die Datenbank + * Wenn $new auf true gesetzt ist wird eingefuegt + * ansonsten der datensatz $person_id upgedated + * @return true wenn erfolgreich, false im Fehlerfall + */ + function save() + { + //Variablen auf Gueltigkeit pruefen + if(!$this->checkvars1()) + return false; + + if($this->new) //Wenn new true ist dann ein INSERT absetzen ansonsten ein UPDATE + { + //Naechste ID aus Sequence holen + $qry = "SELECT nextval('person_seq') as id;"; + if(!$row=pg_fetch_object(pg_query($this->conn,$qry))) + { + $this->errormsg = "Fehler beim Auslesen der Sequence"; + return false; + } + $this->person_id = $row->id; + + $qry = "INSERT INTO person (person_pk, familienname, angelegtam, vorname, anrede, vornamen,". + " geschlecht, gebdat, gebort, staatsbuergerschaft, familienstand, svnr, anzahlderkinder,". + " ersatzkennzeichen, bemerkung, creationdate,creationuser, aktstatus, bismelden, titel, postnomentitel,". + " uid, gebnation) VALUES( $this->person_id,". + " '$this->familienname', now(), '$this->vorname', '$this->anrede', '$this->vornamen',". + ($this->geschlecht!=''?"'$this->geschlecht'":"'M'").", ". + ($this->gebdat!=''?"'$this->gebdat'":'null').", '$this->gebort', '$this->staatsbuergerschaft',". + ($this->familienstand!=''?"'$this->familienstand'":'null').",". + " '$this->svnr', ". + ($this->anzahlderkinder!=''?"'$this->anzahlderkinder'":'null').",". + " '$this->ersatzkennzeichen', '$this->bemerkung', now(),". + " '$this->updatevon', '".($this->aktstatus>0?$this->aktstatus:100)."', '".($this->bismelden?'J':'N')."', '$this->titelpre', '$this->titelpost',". + (strlen($this->uid)>0?" '$this->uid'":'null').",". + " '$this->gebnation');"; + + } + else + { + //peson_id auf gueltigkeit pruefen + if(!is_numeric($this->person_id)) + { + $this->errormsg = 'person_id muss eine gueltige Zahl sein'; + return false; + } + + $qry = "UPDATE person SET ". + " familienname='$this->familienname',". + " vorname='$this->vorname',". + " anrede='$this->anrede',". + " vornamen='$this->vornamen',". + " geschlecht=".($this->geschlecht!=''?"'$this->geschlecht'":"'M'").",". + " gebdat=".($this->gebdat!=''?"'$this->gebdat'":'null').",". + " gebort='$this->gebort',". + " staatsbuergerschaft='$this->staatsbuergerschaft',". + " familienstand=".($this->familienstand!=''?"'$this->familienstand'":'0').",". + " svnr=".($this->svnr!=''?"'$this->svnr'":'null').",". + " anzahlderkinder=".($this->anzahlderkinder!=''?"'$this->anzahlderkinder'":'0').",". + " ersatzkennzeichen='$this->ersatzkennzeichen',". + " bemerkung='$this->bemerkung',". + " aktstatus='$this->aktstatus',". + " bismelden='".($this->bismelden?'J':'N')."',". + " titel='$this->titelpre',". + " postnomentitel='$this->titelpost',". + " uid='$this->uid',". + " gebnation='$this->gebnation'". + " WHERE person_pk='$this->person_id'"; + } + + if(pg_query($this->conn,$qry)) + { + //Log schreiben + $sql = $qry; + $qry = "SELECT nextval('log_seq') as id;"; + if(!$row = pg_fetch_object(pg_query($this->conn, $qry))) + { + $this->errormsg = 'Fehler beim Auslesen der Log-Sequence'; + return false; + } + + $qry = "INSERT INTO log(log_pk, creationdate, creationuser, sql) VALUES('$row->id', now(), '$this->updatevon', '".addslashes($sql)."')"; + if(pg_query($this->conn, $qry)) + return true; + else + { + $this->errormsg = 'Fehler beim Speichern des Log-Eintrages'; + return false; + } + } + else + { + $this->errormsg = "Fehler beim Speichern des Person-Datensatzes:".$qry; + return false; + } + } + + /** + * Loescht einen Datensatz + * @param $person_id ID des zu loeschenden Datensatzes + * @return true wenn OK false im Fehlerfall + */ + function delete($person_id) + { + //person_id auf Gueltigkeit pruefen + if(!is_numeric($person_id) || $person_id=='') + { + $this->errormsg = 'Person_id muss eine Zahl sein'; + return false; + } + + $qry = "Delete from person where person_pk=$person_id"; + + if(!pg_query($this->conn,$qry)) + { + $this->errormsg = 'Fehler beim Loeschen'; + return false; + } + else + { + //Log schreiben + $sql = $qry; + $qry = "SELECT nextval('log_seq') as id;"; + if(!$row = pg_fetch_object(pg_query($this->conn, $qry))) + { + $this->errormsg = 'Fehler beim Auslesen der Log-Sequence'; + return false; + } + + $qry = "INSERT INTO log(log_pk, creationdate, creationuser, sql) VALUES('$row->id', now(), '$this->updatevon', '".addslashes($sql)."')"; + if(pg_query($this->conn, $qry)) + return true; + else + { + $this->errormsg = 'Fehler beim Speichern des Log-Eintrages'; + return false; + } + } + + } + + /** + * Holt alle Personen aus der Datenbank + * @return true wenn OK, false im Fehlerfall + */ + function getAll() + { + /** Braucht zuviel Speicher + + $qry = "SELECT * FROM person"; + if(!$res = pg_query($this->conn,$qry)) + { + $this->errormsg = 'Fehler beim auslesen der Datensaetze'; + return false; + } + + while($row = pg_fetch_object($res)) + { + $pers=new person($this->conn); + + $pers->person_id = $row->person_pk; + $pers->aktstatus = $row->aktstatus; + $pers->angelegtam = $row->angelegtam; + $pers->anrede = $row->anrede; + $pers->anzahlderkinder = $row->anzahlderkinder; + $pers->bemerkung = $row->bemerkung; + $pers->bismelden = ($row->bismelden=='J'?true:false); + $pers->ersatzkennzeichen = $row->ersatzkennzeichen; + $pers->familienname = $row->familienname; + $pers->familienstand = $row->familienstand; + $pers->gebdat = $row->gebdat; + $pers->gebnation = $row->gebnation; + $pers->gebort = $row->gebort; + $pers->geschlecht = $row->geschlecht; + $pers->staatsbuergerschaft = $row->staatsbuergerschaft; + $pers->svnr = $row->svnr; + $pers->titelpre = $row->titel; + $pers->titelpost = $row->postnomentitel; + $pers->uid = $row->uid; + $pers->vorname = $row->vorname; + $pers->vornamen = $row->vornamen; + $pers->updateamum = $row->creationdate; + $pers->updatevon = $row->creationuser; + + $this->result[] = $pers; + } + return true; + */ + return false; + } + + /** + * Prueft ob die UID schon vergeben ist. Wenn ein zweiter + * Parameter angegeben wird, wird diese ID von der ueberpruefung + * ausgeschlossen ( fuer Update eines Datensatzes ) + */ + function uid_exists($uid, $person_id='') + { + if($uid!='') + { + $this->errormsg = ''; + //Datenbank Check + $qry = "SELECT count(*) as anz from person where uid='$uid'"; + if($person_id!='') + $qry .= " AND person_pk<>".$person_id; + + if($result = pg_query($this->conn,$qry)) + { + while ($row=pg_fetch_object($result)) + { + if($row->anz == 0) + { + //Wurde deaktiviert weil der Zugriff vom auf den LDAP Server + //vom der Calva aus nicht funktioniert + //Ldap Check + //$ds = ldap_connect(LDAP_SERVER); + //$dn = "ou=People, dc=technikum-wien, dc=at"; + //$sr = ldap_search($ds,$dn,"uid=$uid"); + + //if(ldap_count_entries($ds,$sr)>0) + // return true; + //else + return false; + } + else + return true; + } + } + else + { + $this->errormsg = 'Fehler beim checken der uid'; + return false; + } + } + return false; + } + + /** + * Aktualisiert den AktStatus + */ + function updateaktstatus($person_id) + { + $mitarbeiter_id = ''; + $qry = "Select mitarbeiter_pk from mitarbeiter where person_fk='$person_id'"; + if($result = pg_query($this->conn, $qry)) + { + if($row = pg_fetch_object($result)) + $mitarbeiter_id = $row->mitarbeiter_pk; + else + { + $this->errormsg = 'Fehler beim ermitteln der Mitarbeiter_id'; + return false; + } + } + else + { + $this->errormsg = 'Fehler beim ermitteln der mitarbeiter_id'; + return false; + } + + //Funktionen holen + $qry = "Select funktion from funktion where ". + "studiensemester_fk = (Select studiensemester_pk from studiensemester where aktuell='J')". + " AND mitarbeiter_fk = '$mitarbeiter_id'"; + if($result = pg_query($this->conn, $qry)) + { + $fkt=array(); + $i=0; + while($row=pg_fetch_object($result)) + { + $fkt[$i]=$row->funktion; + $i++; + } + + //Aktstatus ermitteln + if(in_array(5,$fkt)) //STGL + $aktstatus = 104; + elseif(in_array(6,$fkt)) //FBL + $aktstatus = 103; + elseif(in_array(2,$fkt)) //FBK + $aktstatus = 102; + elseif(in_array(1,$fkt)) //LKT + $aktstatus = 101; + else + $aktstatus = 100; //Mitarbeiter + + $this->status = $aktstatus; + //neuen akstatus setzen + $qry = "Update person set aktstatus = $aktstatus where person_pk = $person_id"; + if(pg_query($qry)) + { + //Log schreiben + $sql .= $qry; + $qry = "SELECT nextval('log_seq') as id;"; + if(!$row = pg_fetch_object(pg_query($this->conn, $qry))) + { + $this->errormsg = 'Fehler beim Auslesen der Log-Sequence'; + return false; + } + + $qry = "INSERT INTO log(log_pk, creationdate, creationuser, sql) VALUES('$row->id', now(), '$this->updatevon', '".addslashes($sql)."')"; + if(pg_query($this->conn, $qry)) + return true; + else + { + $this->errormsg = 'Fehler beim Speichern des Log-Eintrages'; + return false; + } + } + else + { + $this->errormsg = 'Fehler beim setzen des Aktstatus'; + return false; + } + } + } + + function setaktstatus($status, $person_id) + { + $qry = "Update person set aktstatus = '$status' where person_pk='$person_id'"; + if(!pg_query($this->conn, $qry)) + { + $this->errormsg = 'Fehler beim Setzen des aktuellen Status'.$qry; + return false; + } + return true; + } +} +?> \ No newline at end of file diff --git a/include/fas/raumtyp.class.php b/include/fas/raumtyp.class.php new file mode 100644 index 000000000..f162e27a7 --- /dev/null +++ b/include/fas/raumtyp.class.php @@ -0,0 +1,126 @@ +conn = $conn; + $qry = "SET CLIENT_ENCODING TO 'UNICODE';"; + if(!pg_query($conn,$qry)) + { + $this->errormsg = "Encoding konnte nicht gesetzt werden"; + return false; + } + if($raum_id != null) + $this->load($raum_id); + } + + /** + * Laedt einen Datensatz + * @param $raum_id ID des zu ladenden Datensatzes + * @return true wenn ok, false im Fehlerfall + */ + function load($raum_id) + { + if(!is_numeric($raum_id) || $raum_id == '') + { + $this->errormsg = 'raum_id muss eine gueltige Zahl sein'; + return false; + } + + $qry = "SELECT * FROM raumtyp WHERE raumtyp_pk = '$raum_id';"; + + if(!$res = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Fehler beim laden des Datenstatzes'; + return false; + } + + if($row = pg_fetch_object($res)) + { + $this->raumtyp_id = $row->raumtyp_pk; + $this->bezeichnung = $row->bezeichnung; + $this->kurzbezeichnung = $row->kurzbezeichnung; + $this->plaetze = $row->plaetze; + $this->updateamum = $row->creationdate; + $this->updatevon = $row->creationuser; + } + else + { + $this->errormsg = 'Es ist kein Datensatz mit dieser ID vorhanden'; + return false; + } + return true; + } + + /** + * Laedt alle Datensaetze + * @return ture wenn ok, false im Fehlerfall + */ + function getAll() + { + $qry = "SELECT * FROM raumtyp;"; + + if(!$res = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Fehler beim laden der Datensaetze'; + return false; + } + + while($row = pg_fetch_object($res)) + { + $raum_obj = new raumtyp($this->conn); + + $raum_obj->raumtyp_id = $row->raumtyp_pk; + $raum_obj->bezeichnung = $row->bezeichnung; + $raum_obj->kurzbezeichnung = $row->kurzbezeichnung; + $raum_obj->plaetze = $row->plaetze; + $raum_obj->updateamum = $row->creationdate; + $raum_obj->updatevon = $row->creationuser; + + $this->result[] = $raum_obj; + } + return true; + } + + /** + * Speichert den aktuellen Datensatz + * @return true wenn ok, false im Fehlerfall + */ + function save() + { + $this->errormsg = 'Noch nicht Implementiert'; + return false; + } + + /** + * Loescht einen Datensatz + * @return true wenn ok, false im Fehlerfall + */ + function delete($raum_id) + { + $this->errormsg = 'Noch nicht Implementiert'; + return false; + } +} +?> \ No newline at end of file diff --git a/include/fas/studiengang.class.php b/include/fas/studiengang.class.php new file mode 100644 index 000000000..7f9958f3a --- /dev/null +++ b/include/fas/studiengang.class.php @@ -0,0 +1,228 @@ +conn = $conn; + $qry = "SET CLIENT_ENCODING TO 'UNICODE';"; + if(!pg_query($conn,$qry)) + { + $this->errormsg = "Encoding konnte nicht gesetzt werden"; + return false; + } + if($studiengang_id != null) + $this->load($studiengang_id); + } + + /** + * Laedt einen Studiengang + * @param stg_id ID des Studienganges der zu laden ist + * @return true wenn ok, false im Fehlerfall + */ + function load($stg_id) + { + //Pruefen ob stg_id eine gueltige Zahl ist + if(!is_numeric($stg_id) || $stg_id == '') + { + $this->errormsg = 'stg_id muss eine gueltige Zahl sein'; + return false; + } + + $qry = "SELECT * FROM studiengang WHERE studiengang_pk = '$stg_id'"; + + if(!$res=pg_query($this->conn, $qry)) + { + $this->errormsg = 'Fehler beim laden des Datensatzes'; + return false; + } + + if($row = pg_fetch_object($res)) + { + $this->studiengang_id = $row->studiengang_pk; + $this->name = $row->name; + $this->erhalter_id = $row->erhalter_fk; + $this->kuerzel = $row->kuerzel; + $this->studiengangsart = $row->studiengangsart; + $this->organisationsform = $row->organisationsform; + $this->kennzahl = $row->kennzahl; + $this->updateamum = $row->creationdate; + $this->updatevon = $row->creationuser; + $this->standort = $row->standort; + $this->regelstudiendauer = $row->regelstudiendauer; + $this->emailkuerzel = $row->emailkuerzel; + $this->beschreibung = $row->beschreibung; + $this->telefonnummer = $row->telefonnummer; + $this->bescheid = $row->bescheid; + $this->bescheidvom = $row->bescheidvom; + $this->bescheidgz = $row->bescheidgz; + $this->bescheidbgbl1 = $row->bescheidbgbl1; + $this->bescheidbgbl2 = $row->bescheidbgbl2; + $this->kennzahl_neu = $row->kennzahl_neu; + $this->nummerintern = $row->nummerintern; + $this->bafirmaaufzeugnis = ($row->bafirmaaufzeugnis=='t'?true:false); + $this->batitelaufzeugnis = ($row->batitelaufzeugnis=='t'?true:false); + } + else + { + $this->errormsg = 'Kein Datensatz mit dieser Nummer vorhanden'; + return false; + } + return true; + } + + /** + * Laedt Studiengang und Studiensemester + * @param stg_id Studiengangs_id + * stsem_id Studiensemester_id + */ + function load_stsem($stg_id, $stsem_id) + { + //Studiengang laden + if(!$this->load($stg_id)) + return false; + + //pruefen ob stsem_id eine gueltige Zahl ist + if(!is_numeric($stsem_id) || $stsem_id == '') + { + $this->errormsg = 'studiensemester_id muss eine gueltige Zahl sein'; + return false; + } + + $qry = "SELECT * FROM studiengang_studiensemester WHERE studiengang_fk='$this->studiengang_id' ". + "AND studiensemester_fk='$stsem_id';"; + + if(!$res = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Datensatz konnte nicht geladen werden'; + return false; + } + + if($row = pg_fetch_object($res)) + { + $this->studiensemester_id = $row->studiensemester_fk; + $this->startdatum = $row->startdatum; + $this->endedatum = $row->endedatum; + $this->regelwochenstunden = $row->regelwochen; + $this->betreuerstunden = $row->rvar1; + } + else + { + $this->errormsg = 'Datensatz konnte nicht geladen werden'; + return false; + } + return true; + } + + /** + * Liefert alle Studiengaenge + * @return true wenn ok, false im Fehlerfall + */ + function getAll() + { + $qry = "SELECT * FROM studiengang order by name;"; + + if(!$res = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Datensatz konnte nicht geladen werden'; + return false; + } + + while($row = pg_fetch_object($res)) + { + $stg_obj = new studiengang($this->conn); + + $stg_obj->studiengang_id = $row->studiengang_pk; + $stg_obj->name = $row->name; + $stg_obj->erhalter_id = $row->erhalter_fk; + $stg_obj->kuerzel = $row->kuerzel; + $stg_obj->studiengangsart = $row->studiengangsart; + $stg_obj->organisationsform = $row->organisationsform; + $stg_obj->kennzahl = $row->kennzahl; + $stg_obj->updateamum = $row->creationdate; + $stg_obj->updatevon = $row->creationuser; + $stg_obj->standort = $row->standort; + $stg_obj->regelstudiendauer = $row->regelstudiendauer; + $stg_obj->emailkuerzel = $row->emailkuerzel; + $stg_obj->beschreibung = $row->beschreibung; + $stg_obj->telefonnummer = $row->telefonnummer; + $stg_obj->bescheid = $row->bescheid; + $stg_obj->bescheidvom = $row->bescheidvom; + $stg_obj->bescheidgz = $row->bescheidgz; + $stg_obj->bescheidbgbl1 = $row->bescheidbgbl1; + $stg_obj->bescheidbgbl2 = $row->bescheidbgbl2; + $stg_obj->kennzahl_neu = $row->kennzahl_neu; + $stg_obj->nummerintern = $row->nummerintern; + $stg_obj->bafirmaaufzeugnis = ($row->bafirmaaufzeugnis=='t'?true:false); + $stg_obj->batitelaufzeugnis = ($row->batitelaufzeugnis=='t'?true:false); + + $this->result[] = $stg_obj; + } + + return true; + } + + /** + * Loescht einen Studiengang + * @param $stg_id ID des zu loeschenden Studienganges + * @return true wenn ok, false im Fehlerfall + */ + function delete($stg_id) + { + $this->errormsg = 'Noch nicht implementiert'; + return false; + } + + /** + * Speichert den aktuellen Datensatz + * @return true wenn ok, false im Fehlerfall + */ + function save() + { + $this->errormsg = 'Noch nicht implementiert'; + return false; + } +} +?> \ No newline at end of file diff --git a/include/fas/studiensemester.class.php b/include/fas/studiensemester.class.php new file mode 100644 index 000000000..f22a474c0 --- /dev/null +++ b/include/fas/studiensemester.class.php @@ -0,0 +1,163 @@ +conn = $conn; + $qry = "SET CLIENT_ENCODING TO 'UNICODE';"; + if(!pg_query($conn,$qry)) + { + $this->errormsg = "Encoding konnte nicht gesetzt werden"; + return false; + } + if($stsem_id != null) + $this->load($stsem_id); + } + + /** + * Laedt den Datensatz mit der ID die uebergeben wird + * @param stsem_id ID des zu ladenden Datensatzes + * @return true wenn ok, false im fehlerfall; + */ + function load($stsem_id) + { + //Pruefen ob stsem_id eine gueltige Zahl ist + if(!is_numeric($stsem_id) || $stsem_id == '') + { + $this->errormsg = 'stsem_id muss eine gueltige Zahl sein'; + return false; + } + + //Laden eines Datensatzes + $qry = "SELECT * FROM studiensemester WHERE studiensemester_pk = '$stsem_id';"; + + if(!$res = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Fehler beim laden des Datensatzes'; + return false; + } + + if($row = pg_fetch_object($res)) + { + $this->studiensemester_id = $row->studiensemester_pk; + $this->aktuell = ($row->aktuell=='J'?true:false); + $this->art = $row->art; + $this->jahr = $row->jahr; + $this->updateamum = $row->creationdate; + $this->updatevon = $row->creationuser; + } + else + { + $this->errormsg = 'Fehler beim laden des Datensatzes'; + return false; + } + + return true; + } + + + /** + * Laedt das aktuelle Studiensemester + * @return true wenn ok, false im Fehlerfall + */ + function load_akt() + { + $qry = "SELECT * FROM studiensemester WHERE aktuell='J'"; + + if(!$res = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Fehler beim laden des Datensatzes'; + return false; + } + + if($row = pg_fetch_object($res)) + { + $this->studiensemester_id = $row->studiensemester_pk; + $this->aktuell = ($row->aktuell=='J'?true:false); + $this->art = $row->art; + $this->jahr = $row->jahr; + $this->updateamum = $row->creationdate; + $this->updatevon = $row->creationuser; + } + else + { + $this->errormsg = 'Fehler beim laden des Datensatzes'; + return false; + } + + return true; + } + + /** + * Laedt alle studiensemester + * @return true wenn ok, false im Fehlerfall + */ + function getAll() + { + $qry = "SELECT * FROM studiensemester order by jahr, art desc;"; + + if(!$res = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Fehler beim laden des Datensatzes'; + return false; + } + + while($row = pg_fetch_object($res)) + { + $stsem_obj = new studiensemester($this->conn); + + $stsem_obj->studiensemester_id = $row->studiensemester_pk; + $stsem_obj->aktuell = ($row->aktuell=='J'?true:false); + $stsem_obj->art = $row->art; + $stsem_obj->jahr = $row->jahr; + $stsem_obj->updateamum = $row->creationdate; + $stsem_obj->updatevon = $row->creationuser; + + $this->result[] = $stsem_obj; + } + return true; + } + + /** + * Loescht einen Datensatz + * @param $stsem_id ID des zu loeschenden Datensatzes + * @return true wenn ok, false im Fehlerfall + */ + function delete($stsem_id) + { + $this->errormsg = 'Noch nicht implementiert'; + return false; + } + + /** + * Speichert den aktuellen Datensatz + * @return true wenn ok, false im Fehlerfall + */ + function save() + { + $this->errormsg = 'Noch nicht implementiert'; + return false; + } +} +?> \ No newline at end of file diff --git a/include/fas/telefonnummer.class.php b/include/fas/telefonnummer.class.php new file mode 100644 index 000000000..93528e06d --- /dev/null +++ b/include/fas/telefonnummer.class.php @@ -0,0 +1,296 @@ +conn = $conn; + $qry = "SET CLIENT_ENCODING TO 'UNICODE';"; + if(!pg_query($conn,$qry)) + { + $this->errormsg = "Encoding konnte nicht gesetzt werden"; + return false; + } + if($telefonnummer_id != null) + $this->load($telefonnummer_id); + } + + /** + * Laedt den Datensatz mit der ID die uebergeben wurde + * @param $telefonnummer_id ID des zu ladenden Datensatzes + * @return true wenn ok, false im Fehlerfall + */ + function load($telefonnummer_id) + { + //Gueltigkeit von telefonnummer_id pruefen + if(!is_numeric($telefonnummer_id) || $telefonnummer_id == '') + { + $this->errormsg = 'telefonnummer_id muss eine Zahl sein'; + return false; + } + + $qry = "SELECT * FROM telefonnummer WHERE telefonnummer_pk=$telefonnummer_id"; + + if(!$res = pg_query($this->conn,$qry)) + { + $this->errormsg = 'Fehler beim Laden des Datensatzes'; + return false; + } + + if($row = pg_fetch_object($res)) + { + $this->telefonnummer_id = $row->telefonnummer_pk; + $this->name = $row->name; + $this->nummer = $row->nummer; + $this->person_id = $row->person_fk; + $this->typ = $row->typ; + $this->updateamum = $row->creationdate; + $this->updatevon = $row->creationuser; + } + else + { + $this->errormsg = 'Es ist kein Datensatz mit dieser ID vorhanden'; + return false; + } + + return true; + } + + /** + * Laedt alle Telefonnummern einer Person + * @param $person_id Person zu der die Telefonnummern gesucht werden sollen + * @return true wenn ok, false im Fehlerfall + */ + function load_pers($person_id) + { + //Gueltigkeit von person_id pruefen + if(!is_numeric($person_id) || $person_id == '') + { + $this->errormsg = 'person_id muss eine gueltige Zahl sein'; + return false; + } + + $qry = "SELECT * from telefonnummer where person_fk=$person_id"; + + if(!$res = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Der Datensatz konnte nicht geladen werden'; + return false; + } + + while($row = pg_fetch_object($res)) + { + $tel_obj = new telefonnummer($this->conn); + + $tel_obj->telefonnummer_id = $row->telefonnummer_pk; + $tel_obj->name = $row->name; + $tel_obj->nummer = $row->nummer; + $tel_obj->person_id = $row->person_fk; + $tel_obj->typ = $row->typ; + $tel_obj->updateamum = $row->creationdate; + $tel_obj->updatevon = $row->creationuser; + + $this->result[] = $tel_obj; + } + return true; + } + + /** + * Liefert alle Telefonnummern + * @return true wenn ok, false im Fehlerfall + */ + function getAll() + { + /* Benoetigt zu viel Speicher + + $qry = "SELECT * FROM telefonnummer;"; + + if(!$res = pg_query($this->conn, $qry)) + { + $this->errormsg = 'Fehler beim laden der Telefonnummern'; + return false; + } + + while($row = pg_fetch_object($res)) + { + $tel_obj = new telefonnummer($this->conn); + + $tel_obj->telefonnummer_id = $row->telefonnummer_pk; + $tel_obj->name = $row->name; + $tel_obj->nummer = $row->nummer; + $tel_obj->person_id = $row->person_fk; + $tel_obj->typ = $row->typ; + $tel_obj->updateamum = $row->creationdate; + $tel_obj->updatevon = $row->creationuser; + + $this->result[] = $tel_obj; + } + + return true; + */ + return false; + } + + /** + * Prueft die gueltigkeit der Variablen + * @return true wenn ok, false im Fehlerfall + */ + function checkvars() + { + //Hochkomma und HTML Tags ersetzen + //$this->name = htmlentities($this->name, ENT_QUOTES); + //$this->nummer = htmlentities($this->nummer, ENT_QUOTES); + + //Laenge pruefen + $this->errormsg = 'Eine der Gesamtlaengen wurde ueberschritten'; + if(strlen($this->name)>255) return false; + if(strlen($this->nummer)>30) return false; + + //Zahlenfelder pruefen + $this->errormsg = 'Ein Zahlenfeld enthaelt ungueltige Zeichen'; + if(!is_numeric($this->person_id)) return false; + if(!is_numeric($this->typ)) return false; + + $this->errormsg = ''; + return true; + } + + /** + * Speichert den aktuellen Datensatz + * Wenn $neu auf true gesetzt ist wird ein neuer Datensatz angelegt + * andernfalls wird der Datensatz mit der ID in $telefonnummer_id aktualisiert + * @return true wenn ok, false im Fehlerfall + */ + function save() + { + //Variablen pruefen + if(!$this->checkvars()) + return false; + + if($this->new) + { + //Neuen Datensatz anlegen + + //neue ID aus der Sequence holen + $qry = "SELECT nextval('telefonnummer_seq') as id;"; + if(!$row = pg_fetch_object(pg_query($this->conn, $qry))) + { + $this->errormsg = 'Fehler beim auslesen der Sequence'; + return false; + } + + $this->telefonnummer_id = $row->id; + + $qry = "INSERT INTO telefonnummer (telefonnummer_pk, person_fk, name, nummer, typ, creationdate, creationuser)". + " VALUES('$this->telefonnummer_id', '$this->person_id', '$this->name', '$this->nummer', '$this->typ', now(), '$this->updatevon');"; + } + else + { + //Bestehenden Datensatz aktualisieren + + //Pruefen der ID + if(!is_numeric($this->telefonnummer_id) || $this->telefonnummer_id == '') + { + $this->errormsg = 'telefonnummer_id muss eine gueltige Zahl sein'; + return false; + } + + $qry = "UPDATE telefonnummer SET person_fk='$this->person_id', name='$this->name', typ='$this->typ', nummer='$this->nummer'". + " WHERE telefonnummer_pk='$this->telefonnummer_id'"; + } + + if(pg_query($this->conn, $qry)) + { + //Log schreiben + $sql = $qry; + $qry = "SELECT nextval('log_seq') as id;"; + if(!$row = pg_fetch_object(pg_query($this->conn, $qry))) + { + $this->errormsg = 'Fehler beim Auslesen der Log-Sequence'; + return false; + } + + $qry = "INSERT INTO log(log_pk, creationdate, creationuser, sql) VALUES('$row->id', now(), '$this->updatevon', '".addslashes($sql)."')"; + if(pg_query($this->conn, $qry)) + return true; + else + { + $this->errormsg = 'Fehler beim Speichern des Log-Eintrages'; + return false; + } + } + else + { + $this->errormsg = 'Fehler beim Speichern der Daten'; + return false; + } + } + + /** + * Loescht den Datensatz mit der uebergebenen ID + * @param telefonnummer_id ID des zu leoschenen Datensatzes + * @return true wenn ok, false im Fehlerfall + */ + function delete($telefonnummer_id) + { + //Pruefen der ID + if(!is_numeric($telefonnummer_id) || $telefonnummer_id == '') + { + $this->errormsg = 'telefonnummer_id muss eine gueltige Zahl sein'; + return false; + } + + //loeschen des Datensatzes + $qry = "DELETE FROM telefonnummer where telefonnummer_pk='$telefonnummer_id'"; + + if(pg_query($this->conn, $qry)) + { + //Log schreiben + $sql = $qry; + $qry = "SELECT nextval('log_seq') as id;"; + if(!$row = pg_fetch_object(pg_query($this->conn, $qry))) + { + $this->errormsg = 'Fehler beim Auslesen der Log-Sequence'; + return false; + } + + $qry = "INSERT INTO log(log_pk, creationdate, creationuser, sql) VALUES('$row->id', now(), '$this->updatevon', '".addslashes($sql)."')"; + if(pg_query($this->conn, $qry)) + return true; + else + { + $this->errormsg = 'Fehler beim Speichern des Log-Eintrages'; + return false; + } + } + else + { + $this->errormsg = 'Fehler beim loeschen eines Datensatzes'; + return false; + } + } +} +?> \ No newline at end of file diff --git a/include/ferien.class.php b/include/ferien.class.php new file mode 100644 index 000000000..f22e6844b --- /dev/null +++ b/include/ferien.class.php @@ -0,0 +1,88 @@ +conn=$conn; + } + + + /** + * Alle Fachbereiche zurueckgeben + * @return array mit Fachbereichen oder false=fehler + */ + function getAll($stg_kz) + { + $sql_query="SELECT * FROM tbl_ferien WHERE studiengang_kz=0 OR studiengang_kz=$stg_kz ORDER BY vondatum"; + if (!$result=@pg_query($this->conn, $sql_query)) + { + $this->errormsg = pg_errormessage($this->conn); + return false; + } + //$num_rows=pg_numrows($result); + //for ($i=0; $i<$num_rows; $i++) + while ($row=@pg_fetch_object($result)) + { + // Record holen + // Instanz erzeugen + $f = new ferien($this->conn); + $f->bezeichnung=$row->bezeichnung; + $f->studiengang_kz = $row->studiengang_kz; + $f->vondatum=$row->vondatum; + $f->bisdatum=$row->bisdatum; + $f->vontimestamp=mktime(0,0,0,substr($row->vondatum,5,2),substr($row->vondatum,8),substr($row->vondatum,0,4));; + $f->bistimestamp=mktime(23,59,59,substr($row->bisdatum,5,2),substr($row->bisdatum,8),substr($row->bisdatum,0,4));; + // in array speichern + $this->ferien[]=$f; + } + return true; + } + + function isferien($timestamp) + { + foreach ($this->ferien AS $f) + if ($timestamp>=$f->vontimestamp && $timestamp<=$f->bistimestamp) + return true; + return false; + } +} +?> \ No newline at end of file diff --git a/include/functions.inc.php b/include/functions.inc.php new file mode 100644 index 000000000..8ee93e955 --- /dev/null +++ b/include/functions.inc.php @@ -0,0 +1,155 @@ +0) + { + $row=pg_fetch_object($result); + return $row->uid; + } + else + return 0; +} + +function check_student($uid, $conn) +{ + // uid von Tabelle 'Student' holen + $sql_query="SELECT uid FROM tbl_student WHERE uid='$uid'"; + //echo $sql_query; + $result=pg_query($conn, $sql_query) or die(pg_last_error($conn)); + $num_rows=pg_numrows($result); + // Wenn kein ergebnis return 0 sonst ID + if ($num_rows>0) + return pg_result($result,0,'uid'); + else + return 0; +} + +function kalenderwoche($datum) +{ + //$woche=date("W",mktime($date[hours],$date[minutes],$date[seconds],$date[mon],$date[mday],$date[year])); + if (!date("w",$datum)) + $datum+=86400; + //echo date("l j.m.Y - W",$datum); + $woche=date("W",$datum); + //if ($woche==53) + // $woche=1; + return $woche; +} + +/****************************************************************************** + * Springt zum vorhergehenden Montag, wenn $datum kein Sonntag oder Montag ist. + * + */ +function montag($datum) +{ + // Wochentag + $wt=date("w",$datum); + // Sonntag? + if (!$wt) + $wt++; + if($wt!=1) + $datum-=86400*($wt-1); + + return $datum; +} + +function jump_day($datum, $tage) +{ + // Ein Tag sind 86400 Sekunden + $datum+=86400*$tage; + return $datum; +} + +function jump_week($datum, $wochen) +{ + $stunde_vor=date("G",$datum); + // Eine Woche sind 604800 Sekunden + $datum+=604800*$wochen; + $stunde_nach=date("G",$datum); + if ($stunde_nach!=$stunde_vor) + $datum+=3600; + return $datum; +} + +function jahreskalenderjump($link) +{ + $datum=mktime(); + $woche=kalenderwoche($datum); + $datum=montag($datum); + echo '
    Jump to KW
    '; + for ($anz=1;$anz<26;$anz++) + { + $linknew=$link.'&datum='.$datum; + if ($woche==54) + $woche=1; + echo ' '.$woche.' '; + if ($anz%5==0) + echo '
    '; + $datum+=60*60*24*7; + $woche++; + } + echo '
    '; +} + +function loadVariables($conn, $user) +{ + $error_msg=''; + if(!($result=@pg_query($conn, "SELECT * FROM tbl_variable WHERE uid='$user'"))) + $error_msg.=pg_errormessage($conn).'
    '.$sql_query; + else + $num_rows=@pg_numrows($result); + + for ($i=0;$i<$num_rows;$i++) + { + $row=pg_fetch_object($result,$i); + global ${$row->name}; + ${$row->name}=$row->wert; + } + if (!isset($semester_aktuell)) + if(!($result=@pg_query($conn, 'SELECT * FROM tbl_studiensemester WHERE ende>now() ORDER BY start LIMIT 1'))) + $error_msg.=pg_errormessage($conn).'
    '.$sql_query; + else + { + $num_rows=@pg_numrows($result); + if ($num_rows>0) + { + $row=pg_fetch_object($result,$i); + global $semester_aktuell; + $semester_aktuell=$row->studiensemester_kurzbz; + } + } + if (!isset($db_stpl_table)) + $db_stpl_table='stundenplan'; + + return $error_msg; +} + +function writeCISlog($stat, $rm = '') +{ + if($stat=='STOP') + $stat = 'STOP '; + $handle = fopen(CIS_LOG_PATH,'a'); + fwrite($handle, date('Y-m-d H:i:s').' '. $stat .' '. getmypid() .' '. $_SERVER['REMOTE_USER'] .' '. $_SERVER['REQUEST_URI'] .' '.$rm.' +'); +} + +?> diff --git a/include/funktion.class.php b/include/funktion.class.php new file mode 100644 index 000000000..08dd03f75 --- /dev/null +++ b/include/funktion.class.php @@ -0,0 +1,279 @@ +conn = $conn; + } + + + /** + * Ladet die Attribute der Funktion aus der Datenbank. Bei Fehler ist der + * Rueckgabewert 'false' und die Fehlermeldung steht in 'errormsg'. + * @return boolean true=ok, false=fehler + */ + function load($kurzbz) + { + $this->kurzbz=$kurzbz; + $qry="select * from tbl_funktion where funktion_kurzbz='$kurzbz'"; + if (is_null($this->conn)) { + return false; + } + if(!($erg=@pg_exec($this->conn, $qry))) + { + $this->errormsg=pg_errormessage($this->conn); + return false; + } + $num_rows=pg_numrows($erg); + if($num_rows!=1) { + $this->errormsg="Zuwenige oder zuviele Ergebnisse (Anzahl: $num_rows)!"; + return false; + } + $row=pg_fetch_object($erg,0); + $this->bezeichnung=$row->bezeichnung; + $this->aktiv=$row->aktiv=='t'?true:false; + $this->new=false; + return true; + } + + /** + * Speichert die Funktion in die Datenbank. Bei Fehler ist der Rueckgabewert + * 'false' und die Fehlermeldung steht in 'errormsg'. INSERT oder DELETE wird + * durch 'new' bestimmt. + * @return boolean true=ok, false=fehler + */ + function save() + { + if (is_null($this->conn)) { + return false; + } + if (strlen($this->kurzbz)==0) + { + $this->errormsg="kurzbz nicht gesetzt"; + return false; + } + if ($this->new) + { + $qry="insert into tbl_funktion(funktion_kurzbz,bezeichnung,aktiv) ". + "values('".$this->kurzbz."','".$this->bezeichnung."',".($this->aktiv?'t':'f').")"; + } else + { + $qry="update tbl_funktion set bezeichnung='".$this->bezeichnung."',". + "aktiv=".($this->aktiv?'t':'f')." where funktion_kurzbzb='$this->kurzbz'"; + } + if(!($erg=@pg_exec($this->conn, $qry))) + { + $this->errormsg=pg_errormessage($this->conn); + return false; + } + return true; + } + + /** + * Loescht die Funktion aus der Datenbank. Bei Fehler ist der Rueckgabewert + * 'false' und die Fehlermeldung steht in 'errormsg'. + * @return boolean true=ok, false=fehler + */ + function delete() + { + if (is_null($this->conn)) { + return false; + } + if (strlen($this->kurzbz)==0) + { + $this->errormsg="kurzbz nicht gesetzt"; + return false; + } + $qry="delete from tbl_funktion where funktion_kurzbz='".$this->kurzbz."'"; + if(!($erg=@pg_exec($this->conn, $qry))) + { + $this->errormsg=pg_errormessage($this->conn); + return false; + } + return true; + } + + /** + * alle Personen mit dieser Funktion holen + * @param string $kurzbz Kurzbezeichnung der Funktion (wenn nicht angegeben + * wird lokale $kurzbz verwendet) + * @return array key=personfunktion_id, value=array('person','studiengang_kz'', + * 'studiengang_kurzbz','fachbereich_id', 'fachbereich_kurzbz') oder false, wenn Fehler + */ + function getPersonen($kurzbz='') + { + // Array für Suchergebnis + $result=array(); + + if (strlen($kurzbz)==0) + { + $search_kurzbz=$this->kurzbz; + } else + { + $search_kurzbz=$kurzbz; + } + $qry="select tbl_personfunktion.*,tbl_studiengang.kurzbz as studiengang_kurzbz,tbl_fachbereich.kurzbz as fachbereich_kurzbz from tbl_personfunktion join tbl_person using(uid) ". + "left join tbl_studiengang using(studiengang_kz) ". + "left join tbl_fachbereich using(fachbereich_id) ". + "where funktion_kurzbz='$search_kurzbz' ". + "order by upper(tbl_person.nachname)"; + if (is_null($this->conn)) { + return false; + } + //echo "'".$qry."'"; + if(!($erg=@pg_exec($this->conn, $qry))) + { + $this->errormsg=pg_errormessage($this->conn); + return false; + } + $num_rows=pg_numrows($erg); + for ($i=0;$i<$num_rows;$i++) + { + // Person laden (nicht für große Anzahl von Personen geeignet) + $temp_person=new person($this->conn); + $temp_person->load(pg_result($erg,$i,'uid')); + // und in Array speichern + $result[pg_result($erg,$i,'personfunktion_id')]=array( + 'person'=>$temp_person, + 'studiengang_kz'=>@pg_result($erg,$i,'studiengang_kz'), + 'studiengang_kurzbz'=>@pg_result($erg,$i,'studiengang_kurzbz'), + 'fachbereich_kurzbz'=>@pg_result($erg,$i,'fachbereich_kurzbz'), + 'fachbereich_id'=>@pg_result($erg,$i,'fachbereich_id') + ); + } + return $result; + } + + /** + * Person Funktion dazugeben + * @param string $uid User-ID + * @param string $studiengang_kz Studiengang-Kennzahl (optional) + * @param integer $fachbereich_id optional + * @return boolean true=ok, false=fehler + */ + function addPerson($uid,$studiengang_kz=null,$fachbereich_id=null) + { + if (is_null($this->conn)) { + return false; + } + $targetlist="uid,funktion_kurzbz"; + if (strlen($studiengang_kz)>0) $targetlist.=",studiengang_kz"; + if (strlen($fachbereich_id)>0) $targetlist.=",fachbereich_id"; + $values="'$uid','".$this->kurzbz."'"; + if (strlen($studiengang_kz)>0) $values.=",$studiengang_kz"; + if (strlen($fachbereich_id)>0) $values.=",$fachbereich_id"; + $qry="insert into tbl_personfunktion($targetlist) ". + "values($values)"; + //echo $qry; + if(!($erg=@pg_exec($this->conn, $qry))) + { + $this->errormsg=pg_errormessage($this->conn); + return false; + } + return true; + } + + /** + * Person Funktion wegnehmen + * @param string $uid User-ID + * @param string $studiengang_kz Studiengang-Kennzahl (optional) + * @param integer $fachbereich_id optional + * @return boolean true=ok, false=fehler + */ + function removePerson($personfunktion_id) + { + if (is_null($this->conn)) { + return false; + } + if (strlen($personfunktion_id)==0) { + $this->errormsg="personfunktion_id darf nicht NULL sein"; + return false; + } + $qry="delete from tbl_personfunktion where personfunktion_id=$personfunktion_id"; + if(!($erg=@pg_exec($this->conn, $qry))) + { + $this->errormsg=pg_errormessage($this->conn); + return false; + } + return true; + } + + /** + * Personfunktion aktualisieren + * @param integer $personfunktion ID aus der Zuordnungstabelle + * @param string $uid User-ID + * @param string $studiengang_kz Studiengang-Kennzahl (optional) + * @param integer $fachbereich_id optional + * @return boolean true=ok, false=fehler + */ + function updatePerson($personfunktion_id,$uid,$studiengang_kz=null, + $fachbereich_id=null) { + if (is_null($this->conn)) { + return false; + } + if (strlen($studiengang_kz)>0) + { + $values.=",studiengang_kz=$studiengang_kz "; + } else + { + $values.=",studiengang_kz=NULL "; + } + if (strlen($fachbereich_id)>0) + { + $values.=",fachbereich_id=$fachbereich_id"; + } else + { + if (strlen($studiengang_kz)==0) { + $this->errormsg="Studiengang oder Fachbereich fehlt."; + return false; + } + $values.=",fachbereich_id=NULL"; + } + $qry="update tbl_personfunktion set ". + "uid='$uid'$values ". + "where personfunktion_id=$personfunktion_id"; + //echo $qry; + if(!($erg=@pg_exec($this->conn, $qry))) + { + $this->errormsg=pg_errormessage($this->conn); + return false; + } + return true; + } +} +?> \ No newline at end of file diff --git a/include/globals.inc.php b/include/globals.inc.php new file mode 100644 index 000000000..1d8b54a85 --- /dev/null +++ b/include/globals.inc.php @@ -0,0 +1,22 @@ + \ No newline at end of file diff --git a/include/lehrfach.class.php b/include/lehrfach.class.php new file mode 100644 index 000000000..86ca6065e --- /dev/null +++ b/include/lehrfach.class.php @@ -0,0 +1,206 @@ +conn=$conn; + } + + /** + * Ladet einen Datensatz mit der id $id + * @param $id lehrfach_nr + * @return true wenn erfolgreich sonst false + */ + function load($id) + { + $sql_query = "Select * from tbl_lehrfach where lehrfach_nr=$id"; + if($result=pg_exec($sql_query)) + { + if($row=pg_fetch_object($result)) + { + $this->lehrfach_nr = $id; + $this->studiengang_kz = $row->studiengang_kz; + $this->fachbereich_id = $row->fachbereich_id; + $this->kurzbz = $row->kurzbz; + $this->bezeichnung = $row->bezeichnung; + $this->lehrevz = $row->lehrevz; + $this->farbe = $row->farbe; + //$this->lehrform = $row->lehrform; + $this->aktiv = $row->aktiv; + $this->ects = $row->ects; + $this->semester = $row->semester; + $this->sprache = $row->sprache; + return true; + } + } + return false; + } + + /** + * Liefert die Tabellenelemente die den Kriterien der Parameter entsprechen + * @param $stg Studiengangs_kz + * $sem Semester + * $order Sortierkriterium + * $fachb fachbereichs_id + * @return array mit Fachbereichen oder false=fehler + */ + function getTab($stg='-1',$sem='-1', $order='lehrfach_nr', $fachb='-1',$lehre='') + { + + $sql_query = "SELECT * FROM tbl_lehrfach"; + + if($stg!=-1 || $sem!=-1 || $fachb!=-1) + $sql_query .= " WHERE true"; + + if($stg!=-1) + { + $sql_query .= " AND studiengang_kz=$stg"; + } + + if($sem!=-1) + { + $sql_query .= " AND semester=$sem"; + } + + if($fachb!=-1) + { + $sql_query .= " AND fachbereich_id=$fachb"; + } + + if($lehre!='') + { + $sql_query .= " AND lehre=$lehre"; + } + + $sql_query .= " ORDER BY $order"; + + if($result=pg_exec($this->conn,$sql_query)) + { + while($row=pg_fetch_object($result)) + { + $l = new lehrfach($this->conn); + $l->lehrfach_nr = $row->lehrfach_nr; + $l->fachbereich_id = $row->fachbereich_id; + $l->kurzbz = $row->kurzbz; + $l->bezeichnung = $row->bezeichnung; + $l->lehrevz = $row->lehrevz; + $l->farbe = $row->farbe; + //$l->lehrform_kurzbz = $row->lehrform_kurzbz; + $l->aktiv = $row->aktiv; + $l->ects = $row->ects; + $l->studiengang_kz = $row->studiengang_kz; + $l->semester = $row->semester; + $this->fkterg[]=$l; + } + } + else + { + $this->errormsg = pg_errormessage($this->conn); + return false; + } + return true; + } + + /** + * Alle Fachbereiche zurückgeben + * @return array mit Fachbereichen oder false=fehler + */ + function getAll() + { + if (is_null($this->conn)) + { + return false; + } + $qry = "select * from tbl_lehrfach ". + "order by kurzbz"; + //echo $qry; + if (!($erg = pg_exec($this->conn, $qry))) + { + $this->errormsg = pg_errormessage($this->conn); + return false; + } + $result = array(); + $num_rows = pg_numrows($erg); + for ($i = 0; $i < $num_rows; $i ++) + { + // Record holen + $row = pg_fetch_object($erg, $i); + // Instanz erzeugen + $lf = new lehrfach($this->conn); + $lf->lehrfach_nr = $row->lehrfach_nr; + $lf->fachbereich_id = $row->fachbereich_id; + $lf->kurzbz = $row->kurzbz; + $lf->bezeichnung = $row->bezeichnung; + $lf->lehrelink = $row->lehrelink; + $lf->farbe = $row->farbe; + //$lf->lehrform_kurzbz = $row->lehrform_kurzbz; + $lf->aktiv = $row->aktiv; + $lf->ects = $row->ects; + $lf->studiengang_kz = $row->studiengang_kz; + // in array speichern + $result[] = $lf; + } + return $result; + } +} +?> \ No newline at end of file diff --git a/include/lehrform.class.php b/include/lehrform.class.php new file mode 100644 index 000000000..094822551 --- /dev/null +++ b/include/lehrform.class.php @@ -0,0 +1,62 @@ +conn = $conn; + } + + /** + * Alle Fachbereiche zurückgeben + * @return array mit Fachbereichen oder false=fehler + */ + function getAll() + { + if (is_null($this->conn)) + { + return false; + } + $qry = "select lehrform_kurzbz, bezeichnung from tbl_lehrform ". + "order by lehrform_kurzbz"; + //echo $qry; + if (!($erg = pg_exec($this->conn, $qry))) + { + $this->errormsg = pg_errormessage($this->conn); + return false; + } + $result = array(); + $num_rows = pg_numrows($erg); + for ($i = 0; $i < $num_rows; $i ++) + { + // Record holen + $row = pg_fetch_object($erg, $i); + // Instanz erzeugen + $lf = new lehrform($this->conn); + $lf->kurzbz = $row->lehrform_kurzbz; + $lf->bezeichnung = $row->bezeichnung; + // in array speichern + $result[] = $lf; + } + return $result; + } +} +?> \ No newline at end of file diff --git a/include/lehrstunde.class.php b/include/lehrstunde.class.php new file mode 100644 index 000000000..9e5a19376 --- /dev/null +++ b/include/lehrstunde.class.php @@ -0,0 +1,457 @@ +conn=$conn; + $this->new=TRUE; + } + + + /** + * Einen Datensatz laden + * + */ + function load($stundenplan_id,$stpl_table='stundenplandev') + { + /////////////////////////////////////////////////////////////////////// + // Parameter Checken + // Bezeichnung der Stundenplan-Tabelle und des Keys + $stpl_id=$stpl_table.TABLE_ID; + $stpl_view=VIEW_BEGIN.$stpl_table; + $stpl_table=TABLE_BEGIN.$stpl_table; + + $sql_query="SELECT * FROM $stpl_view WHERE $stpl_id=$stundenplan_id;"; + //echo $sql_query.'
    '; + + + //Datenbankabfrage + if (! $stpl_tbl=pg_query($this->conn, $sql_query)) + { + $this->errormsg=pg_last_error($this->conn); + //echo $this->errormsg; + return false; + } + $this->anzahl=pg_numrows($stpl_tbl); + //Daten uebernehmen + if ($this->anzahl!=1) + { + $this->errormsg='Keinen Datensatz gefunden'; + return false; + } + else + { + $row=pg_fetch_object ($stpl_tbl); + $this->stundenplan_id=$row->{$stpl_id}; + $this->unr=$row->unr; + $this->lektor_uid=$row->uid; + $this->lektor_kurzbz=$row->lektor; + $this->datum=$row->datum; + $this->stunde=$row->stunde; + $this->ort_kurzbz=$row->ort_kurzbz; + $this->lehrfach=$row->lehrfach; + $this->lehrfach_bez=$row->lehrfach_bez; + $this->lehrfach_nr=$row->lehrfach_nr; + $this->lehrform=$row->lehrform; + $this->studiengang_kz=$row->studiengang_kz; + $this->studiengang=$row->stg_kurzbz; + $this->sem=$row->semester; + $this->ver=$row->verband; + $this->grp=$row->gruppe; + $this->einheit_kurzbz=$row->einheit_kurzbz; + $this->titel=$row->titel; + $this->anmerkung=$row->anmerkung; + $this->updateamum=$row->updateamum; + $this->updatevon=$row->updatevon; + $this->new=false; + } + return true; + } + + /** + * Datensatz in DB speichern + * + */ + function save($uid, $stpl_table='stundenplandev') + { + // Parameter Checken + // Bezeichnung der Stundenplan-Tabelle und des Keys + $stpl_id=$stpl_table.TABLE_ID; + $stpl_table=TABLE_BEGIN.$stpl_table; + if ($this->new) + { + // insert + } + else + { + // update + $sql_query='UPDATE '.$stpl_table; + $sql_query.=" SET datum='$this->datum', stunde=$this->stunde"; + $sql_query.=", ort_kurzbz='$this->ort_kurzbz', uid='$this->lektor_uid'"; + $sql_query.=", updateamum=now(), updatevon='$uid'"; + $sql_query.=" WHERE $stpl_id=$this->stundenplan_id"; + //echo $sql_query."
    "; + + //Datenbankabfrage + if (! @pg_query($this->conn, $sql_query)) + { + $this->errormsg=$sql_query.pg_last_error($this->conn); + //echo $this->errormsg; + return false; + } + //$this->errormsg.=$sql_query; + } + + return true; + } + + /** + * Datensatz aus DB entfernen + * @param id ID des Datensatzes in der Tabelle + * @param stpl_table Name der Tabelle + * + */ + function delete($id, $stpl_table='stundenplandev') + { + // Parameter Checken + // Bezeichnung der Stundenplan-Tabelle und des Keys + $stpl_id=$stpl_table.TABLE_ID; + $stpl_table=TABLE_BEGIN.$stpl_table; + // Delete SQL vorbereiten + $sql_query='DELETE FROM '.$stpl_table; + $sql_query.=" WHERE $stpl_id=$id"; + //echo $sql_query."
    "; + + //Datenbankrequest + if (! pg_query($this->conn, $sql_query)) + { + $this->errormsg=$sql_query.pg_last_error($this->conn); + //echo $this->errormsg; + return false; + } + else + return true; + } + + /** + * @param type (student, lektor, lehrverband, einheit, ort, ....) + * @param datum_von (inklusive) Startdatum der Abfrage + * @param datum_bis (exklusive) Enddatum der Abfrage + * @param uid (des Lektors oder Studenten) kann auch NULL sein + * @param ort_kurzbz (Kurzbezeichnung des Orts) kann auch NULL sein + * @param studiengang_kz + * @param sem + * @param ver + * @param grp + * @param einheit_kurzbz + * + */ + function load_lehrstunden($type, $datum_von, $datum_bis, $uid, $ort_kurzbz=NULL, $studiengang_kz=NULL, $sem=NULL, $ver=NULL, $grp=NULL, $einheit_kurzbz=NULL, $stpl_view='stundenplan') + { + /////////////////////////////////////////////////////////////////////// + // Parameter Checken + // Bezeichnung der Stundenplan-Tabelle und des Keys + $stpl_id=$stpl_view.TABLE_ID; + $stpl_view=VIEW_BEGIN.$stpl_view; + // Datum im Format YYYY-MM-TT ? + if (!ereg("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})",$datum_von) ) + { + $this->errormsg='Fehler: Startdatum hat falsches Format!'; + return -1; + } + if (!ereg("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})",$datum_bis) ) + { + $this->errormsg='Fehler: Enddatum hat falsches Format!'; + return -1; + } + // Person + if (($type=='student' || $type=='lektor') && $uid==NULL) + { + $this->errormsg='Fehler: uid der Person ist nicht gesetzt'; + return -1; + } + // Ort + if ($type=='ort' && $ort_kurzbz==NULL) + { + $this->errormsg='Fehler: Kurzbezeichnung des Orts ist nicht gesetzt'; + return -1; + } + // Einheit + if ($type=='einheit' && $einheit_kurzbz==NULL) + { + $this->errormsg='Fehler: Kurzbezeichnung der Einheit ist nicht gesetzt'; + return -1; + } + + /////////////////////////////////////////////////////////////////////// + // Zusaetzliche Daten ermitteln + // Personendaten + if ($type=='student') + { + // Lehrverband ermitteln + $sql_query="SELECT studiengang_kz, semester, verband, gruppe FROM tbl_student WHERE uid='$uid'"; + //echo $sql_query; + if (! $result=@pg_query($this->conn, $sql_query) ) + { + $this->errormsg=pg_last_error($this->conn); + return -2; + } + $num_rows=pg_num_rows($result); + if ($num_rows>0) + $row=pg_fetch_object($result); + else + { + $this->errormsg='Fehler: Student ('.$uid.') wurde nicht gefunden!'; + return -2; + } + $studiengang_kz=$row->studiengang_kz; + $sem=$row->semester; + $ver=$row->verband; + $grp=$row->gruppe; + + // Einheiten ermitteln + $sql_query="SELECT einheit_kurzbz FROM tbl_einheitstudent WHERE uid='$uid'"; + //echo $sql_query; + if (! $result_einheit=@pg_query($this->conn, $sql_query) ) + { + $this->errormsg=pg_last_error($this->conn); + return -2; + } + $num_rows_einheit=pg_num_rows($result_einheit); + } + + /////////////////////////////////////////////////////////////////////// + // Stundenplandaten ermitteln + // Abfrage generieren + $sql_query_stdplan='SELECT * FROM '.$stpl_view; + $sql_query=" WHERE datum>='$datum_von' AND datum<'$datum_bis'"; + if ($type=='lektor') + $sql_query.=" AND uid='$uid'"; + elseif ($type=='ort') + $sql_query.=" AND ort_kurzbz='$ort_kurzbz'"; + elseif ($type=='einheit') + $sql_query.=" AND einheit_kurzbz='$einheit_kurzbz'"; + else + { + $sql_query.=' AND ( (studiengang_kz='.$studiengang_kz; + if ($sem!='0' && $sem!=null && $sem!=0 && $sem!='') + { + $sql_query.=" AND (semester=$sem OR semester IS NULL"; + if ($type=='student') + $sql_query.=' OR semester='.($sem+1); + $sql_query.=')'; + } + if ($ver!='0' && $ver!=null && $ver!='') + $sql_query.=" AND (verband='$ver' OR verband IS NULL OR verband='0' OR verband='')"; + if ($grp!='0' && $grp!=null && $grp!='') + $sql_query.=" AND (gruppe='$grp' OR gruppe IS NULL OR gruppe='0' OR gruppe='')"; + if ($type=='student') + $sql_query.=' AND einheit_kurzbz IS NULL'; + $sql_query.=' )'; + for ($i=0;$i<$num_rows_einheit;$i++) + { + $row=pg_fetch_object($result_einheit,$i); + $sql_query.=" OR einheit_kurzbz='$row->einheit_kurzbz'"; + } + $sql_query.=')'; + } + $sql_query.=' ORDER BY datum, stunde, studiengang_kz, semester, verband, gruppe, einheit_kurzbz, uid'; + $sql_query_stdplan.=$sql_query; + //echo ''; + + //Datenbankabfrage + if (! $stpl_tbl=pg_query($this->conn, $sql_query_stdplan)) + { + $this->errormsg=pg_last_error($this->conn); + //echo $this->errormsg; + return -2; + } + $num_rows=pg_numrows($stpl_tbl); + $this->anzahl=$num_rows; + //Daten uebernehmen + for ($i=0;$i<$num_rows;$i++) + { + $row=pg_fetch_object ($stpl_tbl, $i); + $stunde=new lehrstunde($this->conn); + $stunde->stundenplan_id=$row->{$stpl_id}; + $stunde->unr=$row->unr; + $stunde->lektor_uid=$row->uid; + $stunde->lektor_kurzbz=$row->lektor; + $stunde->datum=$row->datum; + $stunde->stunde=$row->stunde; + $stunde->ort_kurzbz=$row->ort_kurzbz; + $stunde->lehrfach=$row->lehrfach; + $stunde->lehrfach_bez=$row->lehrfach_bez; + $stunde->lehrfach_nr=$row->lehrfach_nr; + $stunde->lehrform=$row->lehrform; + if ($row->farbe!=' ' && $row->farbe!=null) + $stunde->farbe=$row->farbe; + else + $stunde->farbe='FFFFFF'; + $stunde->studiengang_kz=$row->studiengang_kz; + $stunde->studiengang=$row->stg_kurzbz; + $stunde->sem=$row->semester; + $stunde->ver=$row->verband; + $stunde->grp=$row->gruppe; + $stunde->einheit_kurzbz=$row->einheit_kurzbz; + $stunde->titel=$row->titel; + $stunde->anmerkung=$row->anmerkung; + $stunde->updateamum=$row->updateamum; + $stunde->updatevon=$row->updatevon; + $stunde->reservierung=false; + $this->lehrstunden[$i]=$stunde; + } + + /////////////////////////////////////////////////////////////////////// + // Reservierungsdaten ermitteln + // Datenbankabfrage generieren + $sql_query_reservierung='SELECT * FROM vw_reservierung'; + $sql_query_reservierung.=$sql_query; + //echo $sql_query_reservierung; + //Datenbankabfrage + if (! $stpl_tbl=pg_query($this->conn, $sql_query_reservierung)) + { + $this->errormsg=pg_last_error($this->conn); + return -2; + } + $num_rows=pg_numrows($stpl_tbl); + $this->anzahl+=$num_rows; + + //Daten uebernehmen + for ($i=0;$i<$num_rows;$i++) + { + $row=pg_fetch_object ($stpl_tbl, $i); + $stunde=new lehrstunde($this->conn); + $stunde->reservierung=true; + $stunde->stundenplan_id=$row->reservierung_id; + $stunde->unr=0; + $stunde->lektor_uid=$row->uid; + $stunde->lektor_kurzbz=$row->uid; + $stunde->datum=$row->datum; + $stunde->stunde=$row->stunde; + $stunde->ort_kurzbz=$row->ort_kurzbz; + //$stunde->lehrfach_nr=$row->lehrfach_nr; + $stunde->lehrfach=$row->titel; + $stunde->lehrfach_bez=$row->beschreibung; + $stunde->studiengang_kz=$row->studiengang_kz; + $stunde->studiengang=$row->stg_kurzbz; + $stunde->sem=$row->semester; + $stunde->ver=$row->verband; + $stunde->grp=$row->gruppe; + $stunde->einheit_kurzbz=$row->einheit_kurzbz; + $stunde->titel=$row->titel; + $stunde->anmerkung=$row->beschreibung; + $this->lehrstunden[]=$stunde; + //var_dump($stunde); + } + //echo $this->anzahl; + return $this->anzahl; + } + + /************************************************************************* + * Prueft die geladene Lehrveranstaltung auf Kollisionen im Stundenplan. + * Rueckgabewert 'false' und die Fehlermeldung steht in '$this->errormsg'. + * @param string datum gewuenschtes Datum YYYY-MM-TT + * @param integer stunde gewuenschte Stunde + * @param string ort gewuenschter Ort + * @param string db_stpl_table Tabllenname des Stundenplans im DBMS + * @return boolean true=ok, false=fehler + *************************************************************************/ + function kollision($stpl_table='stundenplandev') + { + // Parameter Checken + // Bezeichnung der Stundenplan-Tabelle und des Keys + $stpl_id=$stpl_table.TABLE_ID; + $stpl_table=VIEW_BEGIN.$stpl_table; + + // Datenbank abfragen + $sql_query="SELECT $stpl_id AS id, lektor, stg_kurzbz, ort_kurzbz, semester, verband, gruppe, einheit_kurzbz, datum, stunde FROM $stpl_table + WHERE datum='$this->datum' AND stunde=$this->stunde AND (ort_kurzbz='$this->ort_kurzbz' OR "; + if ($this->lektor_uid!='_DummyLektor') + $sql_query.="(uid='$this->lektor_uid') AND uid!='_DummyLektor' OR "; + $sql_query.="(studiengang_kz=$this->studiengang_kz AND semester=$this->sem"; + if ($this->ver!=null && $this->ver!='' && $this->ver!=' ') + $sql_query.=" AND (verband='$this->ver' OR verband IS NULL OR verband='' OR verband=' ')"; + if ($this->grp!=null && $this->grp!='' && $this->grp!=' ') + $sql_query.=" AND (gruppe='$this->grp' OR gruppe IS NULL OR gruppe='' OR gruppe=' ')"; + if ($this->einheit_kurzbz!=null && $this->einheit_kurzbz!='' && $this->einheit_kurzbz!=' ') + $sql_query.=" AND (einheit_kurzbz='$this->einheit_kurzbz')"; + $sql_query.=")) AND unr!=$this->unr"; + + //echo $sql_query.'
    '; + if (! $erg_stpl=pg_query($this->conn, $sql_query)) + { + $this->errormsg=pg_last_error($this->conn); + return true; + } + $anz=pg_numrows($erg_stpl); + //Check + if ($anz==0) + return false; + else + { + $row=pg_fetch_object($erg_stpl); + $this->errormsg="Kollision ($stpl_table): $row->id|$row->lektor|$row->ort_kurzbz|$row->stg_kurzbz-$row->semester$row->verband$row->gruppe$row->einheit_kurzbz - $row->datum/$row->stunde"; + return true; + } + } +} + +?> \ No newline at end of file diff --git a/include/lehrveranstaltung.class.php b/include/lehrveranstaltung.class.php new file mode 100644 index 000000000..265d5477b --- /dev/null +++ b/include/lehrveranstaltung.class.php @@ -0,0 +1,392 @@ +conn=$conn; + $this->errormsg=''; + if (strlen($id)>0) + { + $this->lehrveranstaltung_id=$id; + $this->load($id); + } + } + + + /************************************************************************* + * Prueft die geladene Lehrveranstaltung auf Kollisionen im Stundenplan. + * Rueckgabewert 'false' und die Fehlermeldung steht in '$this->errormsg'. + * @param string datum gewuenschtes Datum YYYY-MM-TT + * @param integer stunde gewuenschte Stunde + * @param string ort gewuenschter Ort + * @param string db_stpl_table Tabllenname des Stundenplans im DBMS + * @return boolean true=ok, false=fehler + *************************************************************************/ + function check_lva($datum,$stunde,$ort,$stpl_table) + { + // Parameter Checken + // Bezeichnung der Stundenplan-Tabelle und des Keys + $stpl_id=$stpl_table.TABLE_ID; + $stpl_table=TABLE_BEGIN.$stpl_table; + + /*// Connection holen + if (is_null($conn=$this->getConnection())) + { + return false; + }*/ + + // Datenbank abfragen + $sql_query="SELECT $stpl_id FROM $stpl_table + WHERE datum='$datum' AND stunde=$stunde + AND ((ort_kurzbz='$ort' OR (uid='$this->lektor' AND uid!='_DummyLektor')) + AND unr!=$this->unr)"; //AND lehrveranstaltung_id!=$this->lehrveranstaltung_id + //$this->errormsg=$sql_query; + if (! $erg_stpl=pg_query($this->conn, $sql_query)) + { + $this->errormsg=pg_last_error($this->conn); + //echo $this->errormsg; + return false; + } + $anzahl=pg_numrows($erg_stpl); + //Check + if ($anzahl==0) + return true; + else + { + $row=pg_fetch_row($erg_stpl); + $this->errormsg="Kollision mit StundenplanID($stpl_table.$stpl_id): $row[0]"; + return false; + } + } + + /************************************************************************* + * Speichert die geladene Lehrveranstaltung im Stundenplan. + * Rueckgabewert 'false' und die Fehlermeldung steht in '$this->errormsg'. + * @param string datum gewuenschtes Datum YYYY-MM-TT + * @param integer stunde gewuenschte Stunde + * @param string ort gewuenschter Ort + * @param string db_stpl_table Tabllenname des Stundenplans im DBMS + * @param string user UID des aktuellen Bentzers + * @return boolean true=ok, false=fehler + *************************************************************************/ + function save_stpl($datum,$stunde,$ort,$stpl_table, $user) + { + // Parameter Checken + // Bezeichnung der Stundenplan-Tabelle und des Keys + $stpl_id=$stpl_table.TABLE_ID; + $stpl_table=TABLE_BEGIN.$stpl_table; + + // Datenbank abfragen + $sql_query="INSERT INTO $stpl_table + (unr,uid,datum, stunde, ort_kurzbz,lehrfach_nr,lehrform_kurzbz,studiengang_kz,semester,verband, + gruppe, einheit_kurzbz, titel, anmerkung, updatevon, lehrveranstaltung_id) + VALUES ($this->unr,'$this->lektor','$datum',$stunde, + '$ort',$this->lehrfach_nr, '$this->lehrform', $this->studiengang_kz,$this->semester, + '$this->verband','$this->gruppe'"; + if ($this->einheit_kurzbz==null) + $sql_query.=',NULL'; + else + $sql_query.=",'$this->einheit_kurzbz'"; + $sql_query.=",'$this->titel','$this->anmerkung','$user',$this->lehrveranstaltung_id)"; + //$this->errormsg=$sql_query.'
    '; + //return false; + if (! $erg_stpl=pg_query($this->conn, $sql_query)) + { + $this->errormsg=pg_last_error($this->conn); + //echo $this->errormsg; + return false; + } + return true; + } + + /** + * Ladet die Attribute der LVA aus der Datenbank. Bei Fehler ist der + * Rueckgabewert 'false' und die Fehlermeldung steht in 'errormsg'. + * @return boolean true=ok, false=fehler + */ + function load($id='') + { + // optional: id setzen + if ($id!='') + $this->lehrveranstaltung_id=$id; + // id vorhanden? + if (strlen($this->lehrveranstaltung_id)==0) + { + $this->errormsg='lehrveranstaltung_id nicht gesetzt.'; + return false; + } + + // LVA-Daten holen + $sql_query='SELECT * FROM tbl_lehrveranstaltung WHERE lehrveranstaltung_id='.$this->lehrveranstaltung_id; + //$this->errormsg.=$sql_query; + //return false; + if(!($erg=pg_exec($this->conn, $sql_query))) + { + $this->errormsg.=pg_errormessage($this->conn); + return false; + } + $num_rows=pg_numrows($erg); + if($num_rows!=1) + { + $this->errormsg.="Zuwenige oder zuviele Ergebnisse (Anzahl: $num_rows)!"; + return false; + } + $row=pg_fetch_object($erg,0); + + $this->lvnr=$row->lvnr; + $this->unr=$row->unr; + $this->einheit_kurzbz=$row->einheit_kurzbz; + $this->lektor=$row->lektor; + $this->lehrfach_nr=$row->lehrfach_nr; + $this->lehrform=$row->lehrform_kurzbz; + $this->studiengang_kz=$row->studiengang_kz; + $this->fachbereich_id=$row->fachbereich_id; + $this->semester=$row->semester; + $this->verband=$row->verband; + $this->gruppe=$row->gruppe; + $this->raumtyp=$row->raumtyp; + $this->raumtypalternativ=$row->raumtypalternativ; + $this->semesterstunden=$row->semesterstunden; + $this->stundenblockung=$row->stundenblockung; + $this->wochenrythmus=$row->wochenrythmus; + $this->start_kw=$row->start_kw; + $this->anmerkung=$row->anmerkung; + $this->studiensemester_kurzbz=$row->studiensemester_kurzbz; + //$this->fas_id=$row->fas_id; + $this->new=false; + return true; + } + + /** + * @return boolean true=ok, false=fehler + */ + function save() + { + global $auth; + + // Daten zur Person speichern + + if (!person::save()) { + $this->errormsg.="Daten zur LVA konnten nicht gespeichert werden."; + return false; + } + if ($this->new) { + $sql_query="INSERT INTO tbl_lehrveranstaltung(lvnr,unr,einheit_kurzbz,". + "lektor,lehrfach_nr,lehrform_kurzbz,studiengang_kz,fachbereich_id,semester,verband,". + "gruppe,raumtyp,raumtypalternativ,semesterstunden,stundenblockung,". + "wochenrythmus,start_kw,anmerkung)". + "values(". + "'".$this->lvnr."',". + "'".$this->unr."',". + "'".$this->einheit_kurzbz."',". + "'".$this->lektor."',". + (strlen($this->lehrfach_nr)>0?$this->lehrfach_nr:NULL).",". + "'".$this->lehrform."',". + (strlen($this->studiengang_kz)>0?$this->studiengang_kz:NULL).",". + (strlen($this->fachbereich_id)>0?$this->fachbereich_id:NULL).",". + (strlen($this->semester)>0?$this->semester:NULL).",". + "'".$this->verband."',". + "'".$this->gruppe."',". + (strlen($this->raumtyp)>0?"'".$this->raumtyp."'":NULL).",". + (strlen($this->raumtypalternativ)>0?"'".$this->raumtypalternativ."'":NULL).",". + (strlen($this->semesterstunden)>0?$this->semesterstunden:NULL).",". + (strlen($this->stundenblockung)>0?$this->stundenblockung:NULL).",". + (strlen($this->wochenrythmus)>0?$this->wochenrythmus:NULL).",". + (strlen($this->start_kw)>0?$this->start_kw:NULL).",". + (strlen($this->anmerkung)>0?"'".$this->anmerkung."'":NULL).",". + ")"; + } else + { + $sql_query="UPDATE tbl_lehrveranstaltung ". + "SET lvnr='".$this->lvnr."',". + "unr='".$this->unr."',". + "einheit_kurzbz='".$this->einheit_kurzbz."',". + "lektor='".$this->lektor."',". + "lehrfach_nr=".(strlen($this->lehrfach_nr)>0?$this->lehrfach_nr:NULL).",". + "lehrform_kurzbz=".(strlen($this->lehrform)>0?$this->lehrform:NULL).",". + "studiengang_kz=".(strlen($this->studiengang_kz)>0?$this->studiengang_kz:NULL).",". + "fachbereich_id=".(strlen($this->fachbereich_id)>0?$this->fachbereich_id:NULL).",". + "semester=".(strlen($this->semester)>0?$this->semester:NULL).",". + "verband='".$this->verband."',". + "gruppe='".$this->gruppe."',". + "raumtyp=".(strlen($this->raumtyp)>0?"'".$this->raumtyp."'":NULL).",". + "raumtypalternativ=".(strlen($this->raumtypalternativ)>0?"'".$this->raumtypalternativ."'":NULL).",". + "semesterstunden=".(strlen($this->semesterstunden)>0?$this->semesterstunden:NULL).",". + "stundenblockung=".(strlen($this->stundenblockung)>0?$this->stundenblockung:NULL).",". + "wochenrythmus=".(strlen($this->wochenrythmus)>0?$this->wochenrythmus:NULL).",". + "start_kw=".(strlen($this->start_kw)>0?$this->start_kw:NULL).",". + "anmerkung=".(strlen($this->anmerkung)>0?"'".$this->anmerkung."'":NULL). + " WHERE lehrveranstaltung_id='".$this->lehrveranstaltung_id."'"; + } + //echo "
    ".$sql_query; + if(!($erg=pg_exec($this->conn, $sql_query))) + { + $this->errormsg=pg_errormessage($this->conn); + return false; + } + return true; + } + + + /** + * Rueckgabewert ist ein Array mit den Ergebnissen. Bei Fehler false und die + * Fehlermeldung liegt in errormsg. + * Wenn der Parameter stg_kz NULL ist tritt einheit_kurzbzb in Kraft. + * @param string $einheit_kurzbz Einheit + * @param string grp Gruppe + * @param string ver Verband + * @param integer sem Semester + * @param integer stg_kz Kennzahl des Studiengangs + * @return variabel Array mit LVA; false bei Fehler + */ + function getLehrveranstaltungSTPL($db_stpl_table,$studiensemester, $type, $stg_kz, $sem, $lektor, $ver=null, $grp=null, $einheit=null) + { + $lva_stpl_view=VIEW_BEGIN.'lva_'.$db_stpl_table; + + if (strlen($studiensemester)<=0) + { + $this->errormsg='Ausbildungssemester ist nicht gesetzt!'; + return false; + } + else $where=" studiensemester_kurzbz='$studiensemester'"; + + if ($type=='lektor') + $where.=" AND lektor_uid='$lektor'"; + elseif ($type=='einheit') + $where.=" AND einheit='$einheit'"; + elseif ($type=='verband') + { + $where.=" AND studiengang_kz='$stg_kz'"; + if ($sem>0) + $where.=" AND semester=$sem"; + if (strlen($ver)>0 && $ver!=' ') + $where.=" AND verband='$ver'"; + if (strlen($grp)>0 && $grp!=' ') + $where.=" AND gruppe='$grp' "; + } + $sql_query='SELECT *, semesterstunden-verplant::smallint AS offenestunden + FROM '.$lva_stpl_view.' JOIN tbl_lehrform ON '.$lva_stpl_view.'.lehrform=tbl_lehrform.lehrform_kurzbz + WHERE '.$where.' AND verplanen ORDER BY offenestunden DESC, lehrfach, lehrform, semester, verband, gruppe, einheit;'; + //$this->errormsg=$sql_query; + //return false; + if(!($erg=@pg_exec($this->conn, $sql_query))) + { + $this->errormsg=pg_errormessage($this->conn); + return false; + } + $num_rows=pg_numrows($erg); + $l=array(); + for($i=0;$i<$num_rows;$i++) + { + $row=pg_fetch_object($erg,$i); + //$l[$row->unr]=new lehrveranstaltung(); + $l[$row->unr]->lehrveranstaltung_id[]=$row->lehrveranstaltung_id; + $l[$row->unr]->lvnr[]=$row->lvnr; + $l[$row->unr]->unr=$row->unr; + $l[$row->unr]->fachbereich_id=$row->fachbereich_id; + $l[$row->unr]->fachbereich=$row->fachbereich_kurzbz; + $l[$row->unr]->lehrfach_nr=$row->lehrfach_nr; + $l[$row->unr]->lehrfach[]=$row->lehrfach; + $l[$row->unr]->lehrfach_bez[]=$row->lehrfach_bez; + $l[$row->unr]->lehrfach_farbe[]=$row->lehrfach_farbe; + $l[$row->unr]->lehrform[]=$row->lehrform; + $l[$row->unr]->lektor_uid[]=$row->lektor_uid; + $l[$row->unr]->lektor[]=trim($row->lektor); + $l[$row->unr]->stg_kz[]=$row->studiengang_kz; + $l[$row->unr]->stg[]=$row->studiengang; + $l[$row->unr]->einheit[]=$row->einheit; + $l[$row->unr]->semester[]=$row->semester; + $l[$row->unr]->verband[]=$row->verband; + $l[$row->unr]->gruppe[]=$row->gruppe; + $l[$row->unr]->raumtyp=$row->raumtyp; + $l[$row->unr]->raumtypalternativ=$row->raumtypalternativ; + $l[$row->unr]->stundenblockung[]=$row->stundenblockung; + $l[$row->unr]->wochenrythmus[]=$row->wochenrythmus; + $l[$row->unr]->semesterstunden[]=$row->semesterstunden; + $l[$row->unr]->start_kw[]=$row->start_kw; + $l[$row->unr]->anmerkung[]=$row->anmerkung; + $l[$row->unr]->studiensemester_kurzbz=$row->studiensemester_kurzbz; + $l[$row->unr]->verplant[]=$row->verplant; + $l[$row->unr]->offenestunden[]=$row->offenestunden; + if (isset($l[$row->unr]->verplant_gesamt)) + $l[$row->unr]->verplant_gesamt+=$row->verplant; + else + $l[$row->unr]->verplant_gesamt=$row->verplant; + $lvb=$row->studiengang.'-'.$row->semester; + if ($row->verband!='' && $row->verband!=' ' && $row->verband!='0' && $row->verband!=null) + $lvb.=$row->verband; + if ($row->gruppe!='' && $row->gruppe!=' ' && $row->gruppe!='0' && $row->gruppe!=null) + $lvb.=$row->gruppe; + if ($row->einheit!='' && $row->einheit!=null) + $l[$row->unr]->lehrverband[]=$row->einheit; + else + $l[$row->unr]->lehrverband[]=$lvb; + } + return $l; + } +} \ No newline at end of file diff --git a/include/lfvt.class.php b/include/lfvt.class.php new file mode 100644 index 000000000..8430b7b88 --- /dev/null +++ b/include/lfvt.class.php @@ -0,0 +1,423 @@ +conn=$conn; + if (strlen($id)>0) { + $this->$lehrveranstaltung_id=$id; + $this->load(); + } + } + + /** + * Ladet die Attribute der LVA aus der Datenbank. Bei Fehler ist der + * Rueckgabewert 'false' und die Fehlermeldung steht in 'errormsg'. + * @return boolean true=ok, false=fehler + */ + function load($id='') + { + // optional: id setzen + if (strlen($id)>0) + $this->$lehrveranstaltung_id=$id; + // id vorhanden? + if (strlen($this->$this->$lehrveranstaltung_id)==0) { + $this->errormsg='lehrveranstaltung_id nicht gesetzt.'; + return false; + } + // LVA-Daten holen + $sql_query="SELECT lva.* ". + "FROM tbl_lehrveranstaltung as lva ". + "WHERE lehrveranstaltung_id='".$this->lehrveranstaltung_id."'"; + if(!($erg=pg_exec($this->conn, $sql_query))) + die(pg_errormessage($this->conn)); + $num_rows=pg_numrows($erg); + if($num_rows!=1) { + $this->errormsg="Zuwenige oder zuviele Ergebnisse (Anzahl: $num_rows)!"; + return false; + } + $row=pg_fetch_object($erg,0); + + $this->lvnr=$row->lvnr; + $this->unr=$row->unr; + $this->einheit_kurzbz=$row->einheit_kurzbz; + $this->lektor=$row->lektor; + $this->lehrfach_nr=$row->lehrfach_nr; + $this->lehrform=$row->lehrform_kurzbz; + $this->studiengang_kz=$row->studiengang_kz; + $this->fachbereich_id=$row->fachbereich_id; + $this->semester=$row->semester; + $this->verband=$row->verband; + $this->gruppe=$row->gruppe; + $this->raumtyp=$row->raumtyp; + $this->raumtypalternativ=$row->raumtypalternativ; + $this->semesterstunden=$row->semesterstunden; + $this->stundenblockung=$row->stundenblockung; + $this->wochenrythmus=$row->wochenrythmus; + $this->start_kw=$row->start_kw; + $this->anmerkung=$row->anmerkung; + $this->studiensemester_kurzbz=$row->studiensemester_kurzbz; + //$this->fas_id=$row->fas_id; + $this->new=false; + return true; + } + + + + /** + * @return boolean true=ok, false=fehler + */ + function save() + { + global $auth; + if (!isset($this->unr)) { + $this->errormsg='unr fehlt'; + return false; + } + if (!isset($this->lvnr)) { + $this->errormsg='lvnr fehlt'; + return false; + } + if (!isset($this->lektor)) { + $this->errormsg='lektor fehlt'; + return false; + } + if (!isset($this->lehrfach_nr)) { + $this->errormsg='lehrfach_nr fehlt'; + return false; + } + if (!isset($this->lehrform)) + { + $this->errormsg='lehrform fehlt'; + return false; + } + if (!isset($this->studiengang_kz)) { + $this->errormsg='studiengang_kz fehlt'; + return false; + } + if (!isset($this->fachbereich_id)) { + $this->errormsg='fachbereich_id fehlt'; + return false; + } + if (!isset($this->raumtyp)) { + $this->errormsg='raumtyp fehlt'; + return false; + } + if (!isset($this->semesterstunden)) { + $this->errormsg='semesterstunden fehlt'; + return false; + } + if (!isset($this->stundenblockung)) { + $this->errormsg='stundenblockung fehlt'; + return false; + } + if (!isset($this->wochenrythmus)) { + $this->errormsg='wochenrythmus fehlt'; + return false; + } + if (!isset($this->studiensemester_kurzbz)) { + $this->errormsg='studiensemester_kurzbz fehlt'; + return false; + } + + if ($this->new) { + $qry="INSERT INTO tbl_lehrveranstaltung(lvnr,unr,einheit_kurzbz,". + "lektor,lehrfach_nr,lehrform_kurzbz,studiengang_kz,fachbereich_id,semester,verband,". + "gruppe,raumtyp,raumtypalternativ,semesterstunden,stundenblockung,". + "wochenrythmus,start_kw,anmerkung,studiensemester_kurzbz)\n". + "values(". + "'".$this->lvnr."',". + "'".$this->unr."',". + (strlen($this->einheit_kurzbz)>0?"'".$this->einheit_kurzbz."'":'NULL').",". + "'".$this->lektor."',". + (strlen($this->lehrfach_nr)>0?$this->lehrfach_nr:'NULL').",". + "'".$this->lehrform."',". + (strlen($this->studiengang_kz)>0?$this->studiengang_kz:'NULL').",". + (strlen($this->fachbereich_id)>0?$this->fachbereich_id:'NULL').",". + (strlen($this->semester)>0?$this->semester:'NULL').",". + "'".$this->verband."',". + "'".$this->gruppe."',". + (strlen($this->raumtyp)>0?"'".$this->raumtyp."'":'NULL').",". + (strlen($this->raumtypalternativ)>0?"'".$this->raumtypalternativ."'":'NULL').",". + (strlen($this->semesterstunden)>0?$this->semesterstunden:'NULL').",". + (strlen($this->stundenblockung)>0?$this->stundenblockung:'NULL').",". + (strlen($this->wochenrythmus)>0?$this->wochenrythmus:'NULL').",". + (strlen($this->start_kw)>0?$this->start_kw:'NULL').",". + (strlen($this->anmerkung)>0?"'".$this->anmerkung."'":'NULL').','. + (strlen($this->studiensemester_kurzbz)>0?"'".$this->studiensemester_kurzbz."'":'NULL'). + ")"; + } else + { + $qry="UPDATE tbl_lehrveranstaltung ". + "SET lvnr='".$this->lvnr."',". + "unr='".$this->unr."',". + "einheit_kurzbz=".(strlen($this->einheit_kurzbz)>0?"'".$this->einheit_kurzbz."'":'NULL').",". + "lektor='".$this->lektor."',\n". + "lehrfach_nr=".(strlen($this->lehrfach_nr)>0?$this->lehrfach_nr:'NULL').",". + "lehrform_kurzbz='".$this->lehrform."',\n". + "studiengang_kz=".(strlen($this->studiengang_kz)>0?$this->studiengang_kz:'NULL').",". + "fachbereich_id=".(strlen($this->fachbereich_id)>0?$this->fachbereich_id:'NULL').",". + "semester=".(strlen($this->semester)>0?$this->semester:'NULL').",\n". + "verband='".$this->verband."',". + "gruppe='".$this->gruppe."',". + "raumtyp='".$this->raumtyp."',". + "raumtypalternativ=".(strlen($this->raumtypalternativ)>0?"'".$this->raumtypalternativ."'":'NULL').",\n". + "semesterstunden=".(strlen($this->semesterstunden)>0?$this->semesterstunden:'NULL').",". + "stundenblockung=".(strlen($this->stundenblockung)>0?$this->stundenblockung:'NULL').",". + "wochenrythmus=".(strlen($this->wochenrythmus)>0?$this->wochenrythmus:'NULL').",\n". + "start_kw=".($this->start_kw>0?$this->start_kw:'NULL').",". + "anmerkung=".(strlen($this->anmerkung)>0?"'".$this->anmerkung."'":'NULL'). + " WHERE lehrveranstaltung_id=".$this->lehrveranstaltung_id; + } + //echo "
    ".$qry.'start_kw: <'.$this->start_kw.'>'; + if(!($erg=pg_exec($this->conn, $qry))) + { + $this->errormsg=pg_errormessage($this->conn).' sql: '.$qry; + return false; + } + if ($this->new) { + // neue Lehrveranstaltungs-ID herausfinden und speichern + $lastoid=pg_getlastoid($erg); + $qry="select lehrveranstaltung_id from tbl_lehrveranstaltung where oid=$lastoid"; + if(!($erg=pg_exec($this->conn, $qry))) + { + $this->errormsg=pg_errormessage($this->conn).' sql: '.$qry;; + return false; + } + $row=pg_fetch_object($erg,0); + $this->lehrveranstaltung_id=$row->lehrveranstaltung_id; + $this->new=false; + } + return true; + } + + function delete() { + global $auth; + if ($this->new) { + $this->errormsg='Datensatz mit new=true kann nicht gel?scht werden.'; + return false; + } + $qry="delete from tbl_lehrveranstaltung where lehrveranstaltung_id=".addslashes($this->lehrveranstaltung_id); + if(!($erg=pg_exec($this->conn, $qry))) + { + $this->errormsg=pg_errormessage($this->conn)." \nSQL: ".$qry; + return false; + } + return true; + } + + + /** + * Rueckgabewert ist ein Array mit den Ergebnissen. Bei Fehler false und die + * Fehlermeldung liegt in errormsg. + * Wenn der Parameter stg_kz NULL ist tritt einheit_kurzbzb in Kraft. + * @param string $einheit_kurzbz Einheit + * @param string grp Gruppe + * @param string ver Verband + * @param integer sem Semester + * @param integer stg_kz Kennzahl des Studiengangs + * @return variabel Array mit LVA; false bei Fehler + */ + function getLVAs($einheit_kurzbz, $grp, $ver, $sem, $stg_kz,$lektor, $stsem='') + { + if (strlen($einheit_kurzbz)>0) + { + // einheit? + //$join=" join tbl_einheitstudent on (m.uid=tbl_einheitstudent.uid) "; + $where=" lva.einheit_kurzbz='".$einheit_kurzbz."'"; + } + if (strlen($grp)>0) + { + // Gruppe + $where.=(strlen($where)>0?' and ':'')." lva.gruppe='".$grp."' "; + } + if (strlen($ver)>0) + { + // Verband + $where.=(strlen($where)>0?' and ':'')." lva.verband='".$ver."' "; + } + if (strlen($sem)>0) + { + // Semester + $where.=(strlen($where)>0?' and ':'')." lva.semester=".$sem." "; + } + if (strlen($stg_kz)>0) + { + // Studiengang + $where.=(strlen($where)>0?' and ':'')." lva.studiengang_kz='".$stg_kz."' "; + } + if (strlen($lektor)>0) + { + // Lektor + $where.=(strlen($where)>0?' and ':'')." lva.lektor='".$lektor."' "; + } + if (strlen($stsem)>0) + { + // Studiensemester + $where.=(strlen($where)>0?' and ':'')." lva.studiensemester_kurzbz='".$stsem."' "; + } + $sql_query="set datestyle to german;SELECT lva.*,tbl_lehrfach.bezeichnung as lehrfach_bezeichnung, ". + " tbl_person.nachname || ', ' || tbl_person.titel || ' ' || tbl_person.vornamen as lektorName ". + "FROM tbl_lehrveranstaltung as lva join tbl_lehrfach using(lehrfach_nr) ". + " left join tbl_person on(lva.lektor=tbl_person.uid) ". + (strlen($where)>1?'WHERE '.$where:''). + "ORDER by upper(lva.unr),upper(lva.lvnr)"; + //echo $sql_query; + if(!($erg=pg_exec($this->conn, $sql_query))) { + $this->errormsg=pg_errormessage($this->conn); + return false; + } + $num_rows=pg_numrows($erg); + $result=array(); + for($i=0;$i<$num_rows;$i++) + { + $row=pg_fetch_object($erg,$i); + $l=new lfvt($this->conn); + $l->lehrveranstaltung_id=$row->lehrveranstaltung_id; + $l->lvnr=$row->lvnr; + $l->unr=$row->unr; + $l->einheit_kurzbz=$row->einheit_kurzbz; + $l->lektor=$row->lektor; + $l->lektorPrettyPrint=$row->lektorname; + $l->lehrfach_nr=$row->lehrfach_nr; + $l->lehrform=$row->lehrform_kurzbz; + $l->studiengang_kz=$row->studiengang_kz; + $l->fachbereich_id=$row->fachbereich_id; + $l->semester=$row->semester; + $l->verband=strlen($row->verband)>0?$row->verband:null; + $l->gruppe=$row->gruppe; + $l->raumtyp=$row->raumtyp; + $l->raumtypalternativ=$row->raumtypalternativ; + $l->semesterstunden=$row->semesterstunden; + $l->stundenblockung=$row->stundenblockung; + $l->wochenrythmus=$row->wochenrythmus; + $l->start_kw=$row->start_kw; + $l->anmerkung=$row->anmerkung; + $l->studiensemester_kurzbz=$row->studiensemester_kurzbz; + $l->lehrfach=$row->lehrfach_bezeichnung; + // lva in Array speichern + $result[]=$l; + } + return $result; + } + +} diff --git a/include/lv_info.class.php b/include/lv_info.class.php new file mode 100644 index 000000000..c161767df --- /dev/null +++ b/include/lv_info.class.php @@ -0,0 +1,324 @@ +conn = $conn; + } + + /******************************************************************** + * @brief Speichert die Daten in der Datenbank ab. Wenn new auf true + * gesetzt ist wird INSERT ausgefuehrt sonst UPDATE + * @param keine + * + * @return true=Ok false=Fehler + ********************************************************************/ + function save() + { + + if (is_null($this->conn)) + { + $this->errormsg = "Fehler: Keine Datenbank connection vorhanden"; + return false; + } + + //Variablen ueberpruefen + //$this->checkvars(); + + if($this->neu) + { + $sql_query = "INSERT INTO tbl_lvinfo (studiensemester_kurzbz,lehrziele,lehrinhalte,voraussetzungen,basiert_auf,". + "kooperiert_mit, liefert_fuer, unterlagen, pruefungsordnung, anmerkungen, niveau,". + "lehrformen, genehmigt, aktiv,updatevon,lehrfach_nr, sprache, lehrende, lehrfach, semstunden)". + " VALUES('$this->studiensemester_kurzbz',". + (strlen($this->lehrziele)>0?"'".$this->lehrziele."'":'NULL').",". + (strlen($this->lehrinhalte)>0?"'".$this->lehrinhalte."'":'NULL').",". + (strlen($this->voraussetzungen)>0?"'".$this->voraussetzungen."'":'NULL').",". + (strlen($this->basiert_auf)>0?"'".$this->basiert_auf."'":'NULL').",". + (strlen($this->kooperiert_mit)>0?"'".$this->kooperiert_mit."'":'NULL').",". + (strlen($this->liefert_fuer)>0?"'".$this->liefert_fuer."'":'NULL').",". + (strlen($this->unterlagen)>0?"'".$this->unterlagen."'":'NULL').",". + (strlen($this->pruefungsordnung)>0?"'".$this->pruefungsordnung."'":'NULL').",". + (strlen($this->anmerkungen)>0?"'".$this->anmerkungen."'":'NULL').",". + (strlen($this->niveau)>0?"'".$this->niveau."'":'NULL').",". + (strlen($this->lehrformen)>0?"'".$this->lehrformen."'":'NULL').",". + ($this->genehmigt=="'true'"?'true':'false').",".($this->aktiv=='true'?'true':'false').",'$this->updatevon',$this->lehrfach_nr,'$this->sprache',". + (strlen($this->lehrende)>0?"'".$this->lehrende."'":'NULL').",". + (strlen($this->lehrfach)>0?"'".$this->lehrfach."'":'NULL').",". + ($this->semstunden!=''?"'".$this->semstunden."'":'NULL') .");"; + + } + else + { + $sql_query = "UPDATE tbl_lvinfo SET". + " studiensemester_kurzbz='$this->studiensemester_kurzbz'". + ", lehrziele=".(strlen($this->lehrziele)>0?"'".$this->lehrziele."'":'NULL') . + ", lehrinhalte=".(strlen($this->lehrinhalte)>0?"'".$this->lehrinhalte."'":'NULL') . + ", voraussetzungen=".(strlen($this->voraussetzungen)>0?"'".$this->voraussetzungen."'":'NULL') . + ", basiert_auf=".(strlen($this->basiert_auf)>0?"'".$this->basiert_auf."'":'NULL') . + ", kooperiert_mit=".(strlen($this->kooperiert_mit)>0?"'".$this->kooperiert_mit."'":'NULL') . + ", liefert_fuer=".(strlen($this->liefert_fuer)>0?"'".$this->liefert_fuer."'":'NULL') . + ", unterlagen=".(strlen($this->unterlagen)>0?"'".$this->unterlagen."'":'NULL') . + ", pruefungsordnung=".(strlen($this->pruefungsordnung)>0?"'".$this->pruefungsordnung."'":'NULL') . + ", anmerkungen=".(strlen($this->anmerkungen)>0?"'".$this->anmerkungen."'":'NULL') . + ", niveau=".(strlen($this->niveau)>0?"'".$this->niveau."'":'NULL') . + ", lehrformen=".(strlen($this->lehrformen)>0?"'".$this->lehrformen."'":'NULL') . + ", lehrende=".(strlen($this->lehrende)>0?"'".$this->lehrende."'":'NULL') . + ($this->genehmigt==''?'':", genehmigt=$this->genehmigt"). + ($this->aktiv==''?'':", aktiv=$this->aktiv"). + ", updateamum=now()". + ", updatevon='".$_SERVER["REMOTE_USER"]."'". + ", lehrfach_nr=$this->lehrfach_nr". + ", lehrfach='$this->lehrfach'". + ($this->semstunden!=''?", semstunden=$this->semstunden ":''). + ", sprache='$this->sprache' WHERE lvinfo_id=$this->lvinfo_id"; + + } + + $this->lastqry=$sql_query."--$this->genehmigt--"; + //echo $sql_query; + if(pg_exec($this->conn,$sql_query)) + { + return true; + } + else + { + $this->errormsg=pg_errormessage($this->conn); + return false; + } + } + + /******************************************************************** + * @brief Fuehrt einen Selectbefehl aus und Schreibt das Ergebnis in + * $result + * + * @param $sql_query - Select befehl + * + * @return true=Ok, Erg in $Result false=Fehler, Meldung in $errormsg + * Anzahl der Datensaetze steht in $anz + ********************************************************************/ + function getData($sql_query) + { + if (is_null($this->conn)) + { + $this->errormsg = "Fehler: Keine Datenbank connection vorhanden"; + return false; + } + + if($res=pg_exec($this->conn,$sql_query)) + { + while($row=pg_fetch_object($res)) + { + $elem = new lv_info($this->conn); + $elem->lvinfo_id = $row->lvinfo_id; + $elem->studiensemester_kurzbz = $row->studiensemester_kurzbz; + $elem->lehrziele = $row->lehrziele; + $elem->lehrinhalte = $row->lehrinhalte; + $elem->voraussetzungen = $row->voraussetzungen; + $elem->basiert_auf = $row->basiert_auf; + $elem->kooperiert_mit = $row->kooperiert_mit; + $elem->liefert_fuer = $row->liefert_fuer; + $elem->unterlagen = $row->unterlagen; + $elem->pruefungsordnung = $row->pruefungsordnung; + $elem->anmerkungen = $row->anmerkungen; + $elem->niveau = $row->niveau; + $elem->lehrformen = $row->lehrformen; + $elem->genehmigt = $row->genehmigt; + $elem->aktiv = $row->aktiv; + $elem->updateamum = $row->updateamum; + $elem->updatevon = $row->updatevon; + $elem->lehrfach_nr = $row->lehrfach_nr; + $elem->lehrfach = $row->lehrfach; + $elem->sprache = $row->sprache; + $elem->lehrende = $row->lehrende; + $elem->semstunden = $row->semstunden; + $this->result[] = $elem; + } + $this->anz = pg_num_rows($res); + } + else + { + $this->errormsg = pg_errormessage($this->conn); + return false; + } + return true; + } + + /******************************************************************** + * @brief Liefert alle Datensaetze der Tabelle tbl_lvinfo + * + * @param keine + * + * @return true=Ok, Erg in $Result false=Fehler, Meldung in $errormsg + ********************************************************************/ + function getAll() + { + $sql_query = "Select * from tbl_lvinfo"; + return $this->getData($sql_query); + } + + /******************************************************************** + * @brief Liefert alle Datensaetze der Tabelle tbl_lvinfo mit der + * lvinfo_id $id + * @param $id lvinfo_id + * + * @return true=Ok, Erg in $Result false=Fehler, Meldung in $errormsg + ********************************************************************/ + function getByID($id) + { + $sql_query = "SELECT * from tbl_lvinfo WHERE lvinfo_id=$id"; + return $this->getData($sql_query); + } + + /******************************************************************** + * @brief Liefert alle Datensaetze mit den Kriterien die ueberg. wurden + * + * @param $lf Lehrfach + * $stg Studiengang + * $sem Semester + * $sprache Sprache + * $studiensemester_kurzbz Studiensemester + * + * @return true=Ok, Erg in $Result false=Fehler, Meldung in $errormsg + ********************************************************************/ + function getByElem($lf,$stg,$sem,$sprache='',$studiensemester_kurzbz='',$order='version DESC') + { + if($sprache=='') + { + if($studiensemester_kurzbz=='') + { + $sql_query = "SELECT * from tbl_lvinfo, tbl_lehrfach WHERE tbl_lvinfo.lehrfach_nr=tbl_lehrfach.lehrfach_nr ". + "AND tbl_lvinfo.lehrfach_nr=$lf AND studiengang_kz = $stg AND semester = $sem AND tbl_lvinfo.aktiv=true ORDER BY $order"; + } + else + { + $sql_query = "SELECT * from tbl_lvinfo, tbl_lehrfach WHERE tbl_lvinfo.lehrfach_nr=tbl_lehrfach.lehrfach_nr ". + "AND tbl_lvinfo.lehrfach_nr=$lf AND studiengang_kz = $stg AND semester = $sem AND studiensemester_kurzbz='$studiensemester_kurzbz' AND tbl_lvinfo.aktiv=true ORDER BY $order"; + } + } + else + { + if($studiensemester_kurzbz=='') + { + $sql_query = "SELECT * from tbl_lvinfo, tbl_lehrfach WHERE tbl_lvinfo.lehrfach_nr=tbl_lehrfach.lehrfach_nr ". + "AND tbl_lvinfo.sprache='$sprache' AND tbl_lvinfo.lehrfach_nr=$lf AND studiengang_kz = $stg AND semester = $sem AND tbl_lvinfo.aktiv=true ORDER BY $order"; + } + else + { + $sql_query = "SELECT * from tbl_lvinfo, tbl_lehrfach WHERE tbl_lvinfo.lehrfach_nr=tbl_lehrfach.lehrfach_nr ". + "AND tbl_lvinfo.sprache='$sprache' AND tbl_lvinfo.lehrfach_nr=$lf AND studiengang_kz = $stg AND semester = $sem AND studiensemester_kurzbz='$studiensemester_kurzbz' AND tbl_lvinfo.aktiv=true ORDER BY $order"; + } + } + return $this->getData($sql_query); + } + + /******************************************************************** + * @brief Sieht in der DB nach ob ein Eintrag mit den Kriterien + * vorhanden ist. + * @param $studiensemester_kurzbz Studiensemester + * $lf Lehrfach + * + * @return true=Vorhanden, id des DS in $lvinfo_id false=Nicht vorhanden + ********************************************************************/ + function vorhanden($lf, $studiensemester_kurzbz, $sprache) + { + $sql_query = "SELECT * from tbl_lvinfo WHERE ". + "lehrfach_nr=$lf AND studiensemester_kurzbz='$studiensemester_kurzbz' AND sprache='$sprache' AND aktiv=true"; + $res=pg_exec($this->conn, $sql_query); + if(pg_numrows($res)>0) + { + $row=pg_fetch_object($res); + $this->lvinfo_id=$row->lvinfo_id; + return true; + } + else + { + return false; + } + } +} +?> \ No newline at end of file diff --git a/include/lv_verteilung.class.php b/include/lv_verteilung.class.php new file mode 100644 index 000000000..6d2f82b2a --- /dev/null +++ b/include/lv_verteilung.class.php @@ -0,0 +1,359 @@ +connection = $conn; + } + + function load($lv_id) + { + $sql_query = "SELECT * FROM tbl_lehrveranstaltung where lehrveranstaltung_id='$lv_id'"; + + $result = pg_exec($this->connection,$sql_query); + + if($row=pg_fetch_object($result)) + { + $this->lehrveranstaltung_id = $row->lehrveranstaltung_id; + $this->lvnr = $row->lvnr; + $this->einheit_kurzbz = $row->einheit_kurzbz; + $this->lektor = $row->lektor; + $this->lehrfach_nr = $row->lehrfach_nr; + $this->lehrform = $row->lehrform_kurzbz; + $this->studiengang_kz = $row->studiengang_kz; + $this->fachbereich_id = $row->fachbereich_id; + $this->semester = $row->semester; + $this->verband = $row->verband; + $this->gruppe = $row->gruppe; + $this->raumtyp = $row->raumtyp; + $this->raumtypalternativ = $row->raumtypalernativ; + $this->semesterstunden = $row->semesterstunden; + $this->stundenblockung = $row->stundenblockung; + $this->wochenrythmus = $row->wochenrythmus; + $this->start_kw = $row->start_kw; + $this->anmerkung = $row->anmerkung; + $this->studiensemester_kurzbz = $row->studiensemester_kurzbz; + $this->fas_id = $row->fas_id; + $this->unr = $row->unr; + $this->lehre = $row->lehre; + } + else + { + $this->errormsg = "Kein Datensatz mit dieser ID vorhanden"; + return false; + } + + return true; + } + + /******************************************************************** + * @brief Prüft ob die Variablen gültige Werte enthalten + * + * @return true=OK false=Fehler + ********************************************************************/ + function checkvars() + { + if(!is_numeric($this->semesterstunden)) + { + $this->errormsg = "Fehler: Semesterstunden muss eine Zahl sein"; + return false; + } + + if(!is_numeric($this->stundenblockung)) + { + $this->errormsg = "Fehler: Stundenblockung muss eine Zahl sein"; + return false; + } + + if(!is_numeric($this->wochenrythmus)) + { + $this->errormsg = "Fehler: Wochenrythmus muss eine Zahl sein"; + return false; + } + + if(strlen($this->lvnr)==0) + { + $this->errormsg = "Fehler: LVNR muss eingegeben werden"; + return false; + } + + if(!is_numeric($this->start_kw) AND strlen($this->start_kw)>0) + { + $this->errormsg = "Fehler: Start-KW muss eine Zahl sein"; + return false; + } + + return true; + } + + /******************************************************************** + * @brief Speichert die Daten in der Datenbank ab. Wenn new auf true + * gesetzt ist wird INSERT ausgeführt sonst UPDATE + * @param keine + * + * @return true=Ok false=Fehler + ********************************************************************/ + function save() + { + // Connection überprüfen + if (is_null($this->connection)) + { + $this->errormsg = "Fehler: Keine Datenbank connection vorhanden"; + return false; + } + + if ($this->new) { + $qry="INSERT INTO tbl_lehrveranstaltung(lvnr,unr,einheit_kurzbz,". + "lektor,lehrfach_nr,lehrform_kurzbz,studiengang_kz,fachbereich_id,semester,verband,". + "gruppe,raumtyp,raumtypalternativ,semesterstunden,stundenblockung,". + "wochenrythmus,start_kw,anmerkung,studiensemester_kurzbz,lehre)". + "values(". + "'".$this->lvnr."',". + (strlen($this->unr)>0?"'".$this->unr."'":'NULL').",". + (strlen($this->einheit_kurzbz)>0?"'".$this->einheit_kurzbz."'":'NULL').",". + "'".$this->lektor."',". + (strlen($this->lehrfach_nr)>0?$this->lehrfach_nr:'0').",". + "'".$this->lehrform."',". + (strlen($this->studiengang_kz)>0?$this->studiengang_kz:'0').",". + (strlen($this->fachbereich_id)>0?$this->fachbereich_id:'NULL').",". + (strlen($this->semester)>0?$this->semester:'NULL').",". + (strlen($this->verband)>0?"'".$this->verband."'":'NULL').",". + (strlen($this->gruppe)>0?"'".$this->gruppe."'":'NULL').",". + (strlen($this->raumtyp)>0?"'".$this->raumtyp."'":'0').",". + (strlen($this->raumtypalternativ)>0?"'".$this->raumtypalternativ."'":'NULL').",". + (strlen($this->semesterstunden)>0?$this->semesterstunden:'1').",". + (strlen($this->stundenblockung)>0?$this->stundenblockung:'1').",". + (strlen($this->wochenrythmus)>0?$this->wochenrythmus:'1').",". + (strlen($this->start_kw)>0?$this->start_kw:'NULL').",". + (strlen($this->anmerkung)>0?"'".$this->anmerkung."'":'NULL').",". + (strlen($this->studiensemester_kurzbz)>0?"'".$this->studiensemester_kurzbz."'":'0').",". + (($this->lehre=='on')?'true':'false'). + ")"; + } + else + { + $qry="UPDATE tbl_lehrveranstaltung ". + "SET lvnr='".$this->lvnr."',". + "unr=".(strlen($this->unr)>0?"'".$this->unr."'":'NULL').",". + "einheit_kurzbz=".(strlen($this->einheit_kurzbz)>0?"'".$this->einheit_kurzbz."'":'NULL').",". + "lektor='".$this->lektor."',". + "lehrfach_nr=".(strlen($this->lehrfach_nr)>0?$this->lehrfach_nr:'0').",". + "lehrform_kurzbz='".$this->lehrform."',". + "studiengang_kz=".(strlen($this->studiengang_kz)>0?$this->studiengang_kz:'0').",". + "fachbereich_id=".(strlen($this->fachbereich_id)>0?$this->fachbereich_id:'NULL').",". + "semester=".(strlen($this->semester)>0?$this->semester:'NULL').",". + "verband=".(strlen($this->verband)>0?"'".$this->verband."'":'NULL').",". + "gruppe=".(strlen($this->gruppe)>0?"'".$this->gruppe."'":'NULL').",". + "raumtyp=".(strlen($this->raumtyp)>0?"'".$this->raumtyp."'":'0').",". + "raumtypalternativ=".(strlen($this->raumtypalternativ)>0?"'".$this->raumtypalternativ."'":'NULL').",". + "semesterstunden=".(strlen($this->semesterstunden)>0?$this->semesterstunden:'1').",". + "stundenblockung=".(strlen($this->stundenblockung)>0?$this->stundenblockung:'1').",". + "wochenrythmus=".(strlen($this->wochenrythmus)>0?$this->wochenrythmus:'1').",". + "start_kw=".(strlen($this->start_kw)>0?$this->start_kw:'NULL').",". + "anmerkung=".(strlen($this->anmerkung)>0?"'".$this->anmerkung."'":'NULL').",". + "studiensemester_kurzbz=".(strlen($this->studiensemester_kurzbz)>0?"'".$this->studiensemester_kurzbz."'":'0').",". + "lehre=".(($this->lehre=='on')?'true':'false'). + " WHERE lehrveranstaltung_id='".$this->lehrveranstaltung_id."'"; + } + //echo $qry.':'.$this->lehre; + if($this->checkvars()) + { + if(!($erg=pg_exec($this->connection, $qry))) + { + $this->errormsg=pg_errormessage($this->connection); + return false; + } + } + else + { + return false; + } + return true; + } + + + + /******************************************************************** + * @brief Liefert die Datensätze aus der Tabelle tbl_lehrveranstaltung + * die zu diesen Kriterien passen + * @param $stsem Studiensemester / -1 wenn keines gewählt + * $sem Semester / -1 wenn keines gewählt + * $stg Studiengang / -1 wenn keiner gewählt + * $lektor Lektor / -1 wenn keiner gewählt + * @return $result=Array mit den Elementen false=Fehler + ********************************************************************/ + function getTab($stsem, $sem, $stg, $lektor, $order) + { + $sql_query="SELECT a.semester As sem,a.lehre as lvlehre, * FROM (SELECT * FROM public.tbl_lehrveranstaltung"; + $and = false; + + //Zusammenstöpseln des SQL Strings + if($lektor!=-1 OR $stsem!=-1 OR $stg!=-1) + { + $sql_query = $sql_query." WHERE"; + } + + //Zusammenstöpseln des SQL Strings + if($lektor!=-1) + { + $sql_query = $sql_query." lektor='$lektor'"; + $and=true; + } + + if($stsem!=-1) + { + if($and) + $sql_query = $sql_query." AND studiensemester_kurzbz='$stsem'"; + else + $sql_query = $sql_query." studiensemester_kurzbz='$stsem'"; + $and=true; + } + + if($stg!=-1) + { + if($sem!=-1) + { + if($and) + $sql_query = $sql_query." AND studiengang_kz='$stg' AND semester='$sem'"; + else + $sql_query = $sql_query." studiengang_kz='$stg' AND semester='$sem'"; + } + else + { + if($and) + $sql_query = $sql_query." AND studiengang_kz='$stg'"; + else + $sql_query = $sql_query." studiengang_kz='$stg'"; + } + } + + $sql_query = $sql_query.") AS a, tbl_lehrfach b WHERE a.lehrfach_nr=b.lehrfach_nr ORDER BY $order"; + //echo $sql_query; + + $result = pg_exec($this->connection,$sql_query); + $this->anz = pg_numrows($result); + while($row=pg_fetch_object($result)) + { + $lv = new lv_verteilung($connection); + $lv->lehrveranstaltung_id=$row->lehrveranstaltung_id; + $lv->lvnr = $row->lvnr; + $lv->einheit_kurzbz = $row->einheit_kurzbz; + $lv->lektor = $row->lektor; + $lv->lehrfach_nr = $row->lehrfach_nr; + $lv->lehrform = $row->lehrform_kurzbz; + $lv->studiengang_kz = $row->studiengang_kz; + $lv->fachbereich_id = $row->fachbereich_id; + $lv->semester = $row->sem; + $lv->verband = $row->verband; + $lv->gruppe = $row->gruppe; + $lv->raumtyp = $row->raumtyp; + $lv->raumtypalternativ = $row->raumtypalternativ; + $lv->semesterstunden = $row->semesterstunden; + $lv->stundenblockung = $row->stundenblockung; + $lv->wochenrythmus = $row->wochenrythmus; + $lv->start_kw = $row->start_kw; + $lv->anmerkung = $row->anmerkung; + $lv->studiensemester_kurzbz = $row->studiensemester_kurzbz; + $lv->fas_id = $row->fas_id; + $lv->unr = $row->unr; + $lv->lehrfach_kurzbz = $row->kurzbz; + $lv->lehrevz = $row->lehrevz; + $lv->lehre = $row->lvlehre; + $lv->lehrfach_bz = $row->bezeichnung; + $this->retwert[] = $lv; + } + + if($this->anz>0) + return true; + else + return false; + } +} \ No newline at end of file diff --git a/include/mailgrp.class.php b/include/mailgrp.class.php new file mode 100644 index 000000000..5e7c1d284 --- /dev/null +++ b/include/mailgrp.class.php @@ -0,0 +1,84 @@ +conn=$conn; + + } + + /** + * Verbindung zur Datenbank herstellen + * @return PostgreSQL-Connection oder NULL + + function getConnection() { + if (!$conn = @pg_pconnect(CONN_STRING)) { + $this->errormsg="Es konnte keine Verbindung zum Server ". + "aufgebaut werden."; + return null; + } + return $conn; + }*/ + + /** + * Liefert alle Elemente der tbl_mailgrp + * @param studiengang_kz + * @return true wenn OK false wenn Fehler + */ + function getAll($studiengang_kz='') + { + if (is_null($this->conn)) { + $this->errormsg = "Keine Connection vorhanden"; + return false; + } + if (strlen($this->studiengang_kz)>0) + { + $where=" where studiengang_kz='".$studiengang_kz."' "; + } else + { + $where=""; + } + $qry="select * FROM tbl_mailgrp". + "$where order by mailgrp_kurzbz"; + if(!($erg=pg_exec($this->conn, $qry))) { + $this->errormsg=pg_errormessage($this->conn); + return false; + } + + + while($row=pg_fetch_object($erg)) + { + $l=new mailgrp($this->conn); + $l->mailgrp_kurzbz = $row->mailgrp_kurzbz; + $l->studiengang_kz = $row->studiengang_kz; + $l->beschreibung = $row->beschreibung; + $l->aktiv = $row->aktiv; + $l->generiert = $row->generiert; + $l->sichtbar = $row->sichtbar; + $result[]=$l; + } + return $result; + } +} +?> \ No newline at end of file diff --git a/include/mitarbeiter.class.php b/include/mitarbeiter.class.php new file mode 100644 index 000000000..66bc84b5c --- /dev/null +++ b/include/mitarbeiter.class.php @@ -0,0 +1,362 @@ +conn=$conn; + if (strlen($uid)>0) { + $this->uid=$uid; + $this->load(); + } + } + + /** + * @return boolean true=ok, false=fehler + */ + function save() + { + global $auth; + // uid vorhanden? + if (strlen($this->uid)==0) { + $this->errormsg='uid nicht gesetzt.'; + return false; + } + // Connection holen + if (is_null($conn=person::getConnection())) { + return false; + } + // Daten zur Person speichern + + if (!person::save()) { + $this->errormsg.="
    Daten zur Person konnten nicht gespeichert werden."; + return false; + } + if ($this->new) { + $qry="INSERT INTO tbl_mitarbeiter(uid,personalnummer,kurzbz,". + "lektor,fixangestellt,telefonklappe,updateamum,updatevon, ort_kurzbz)". + "values(". + "'".$this->uid."',". + "'".$this->personalnummer."',". + "'".$this->kurzbz."','". + ($this->lektor?'t':'f')."','". + ($this->fixangestellt?'t':'f')."',". + "'".$this->telefonklappe."',". + "now(),'".$_SERVER['PHP_AUTH_USER']."', ".($this->ort_kurzbz!='0'?"'$this->ort_kurzbz'":'NULL'). + ")"; + } else + { + $qry="UPDATE tbl_mitarbeiter ". + "SET personalnummer='".$this->personalnummer."',". + "kurzbz='".$this->kurzbz."',". + "lektor='".($this->lektor?'t':'f')."',". + "fixangestellt='".($this->fixangestellt?'t':'f')."',". + "telefonklappe='".$this->telefonklappe."',". + "updateamum=now(),updatevon='".$_SERVER['PHP_AUTH_USER']."', ort_kurzbz=".($this->ort_kurzbz!='0'?"'$this->ort_kurzbz'":'NULL'). + " WHERE uid='".$this->uid."'"; + } + //echo "
    ".$qry; + if(!($erg=pg_exec($conn, $qry))) + { + $this->errormsg=pg_errormessage($conn); + return false; + } + return true; + } + + /** + * Ladet die Attribute des Studenten aus der Datenbank. Bei Fehler ist der + * Rueckgabewert 'false' und die Fehlermeldung steht in 'errormsg'. + * @return boolean true=ok, false=fehler + */ + function load($uid='') + { + // optional: uid setzen + if (strlen($uid)>0) + $this->uid=$uid; + // uid vorhanden? + if (strlen($this->uid)==0) { + $this->errormsg='uid nicht gesetzt.'; + return false; + } + // Connection holen + if (is_null($conn=person::getConnection())) { + return false; + } + // Daten zur Person laden + if (!person::load()) { + $this->errormsg.="
    Daten zur Person konnten nicht geladen werden."; + return false; + } + // MA-Daten holen + $sql_query="SELECT m.personalnummer,m.kurzbz,m.lektor,m.fixangestellt,m.telefonklappe,m.updateamum,m.updatevon, m.ort_kurzbz ". + "FROM tbl_mitarbeiter as m ". + "WHERE uid='".$this->uid."'"; + if(!($erg=pg_exec($conn, $sql_query))) + die(pg_errormessage($conn)); + $num_rows=pg_numrows($erg); + if($num_rows!=1) { + $this->errormsg="Zuwenige oder zuviele Ergebnisse (Anzahl: $num_rows)!"; + return false; + } + $row=pg_fetch_object($erg,0); + + $this->personalnummer=$row->personalnummer; + $this->kurzbz=$row->kurzbz; + $this->lektor=$row->lektor=='t'?true:false; + $this->fixangestellt=$row->fixangestellt=='t'?true:false; + $this->telefonklappe=$row->telefonklappe; + $this->updateamum=$row->updateamum; + $this->updatevon=$row->updatevon; + $this->ort_kurzbz=$row->ort_kurzbz; + + + return true; + } + + /** + * Loescht den Mitarbeiter aus der Datenbank. Bei Fehler ist der Rueckgabewert + * 'false' und die Fehlermeldung steht in 'errormsg'. + * @return boolean true=ok, false=fehler + * vererbt, wenn Person gelöscht wird, sollte wahrscheinlich auch + * automatisch der Eintrag in den anderen Tabellen gelöscht werden + */ + /* + function delete() + { + if (is_null($conn=$this->getConnection())) { + return false; + } + + + return true; + }*/ + + /** + * gibt array mit allen Lektoren zurück + * @return array mit Lektoren + */ + function getLektoren() + { + if (is_null($conn=$this->getConnection())) + { + return false; + } + $sql_query="set datestyle to german;SELECT tbl_person.*,". + "m.personalnummer,m.kurzbz,m.lektor,m.fixangestellt,m.telefonklappe, m.ort_kurzbz ". + "FROM tbl_person join tbl_mitarbeiter as m using(uid) ". + "WHERE m.lektor=true ". + "ORDER by upper(tbl_person.nachname),upper(tbl_person.vornamen)"; + if(!($erg=@pg_exec($conn, $sql_query))) { + $this->errormsg=pg_errormessage($conn); + return false; + } + $num_rows=pg_numrows($erg); + $result=array(); + for($i=0;$i<$num_rows;$i++) + { + $row=pg_fetch_object($erg,$i); + $l=new mitarbeiter($this->conn); + // Personendaten + $l->uid=$row->uid; + $l->titel=$row->titel; + $l->vornamen=$row->vornamen; + $l->nachname=$row->nachname; + $l->gebdatum=$row->gebdatum; + $l->gebort=$row->gebort; + $l->gebzeit=$row->gebzeit; + $l->foto=$row->foto; + $l->anmerkungen=$row->anmerkungen; + $l->aktiv=$row->aktiv=='t'?true:false; + $l->email=$row->email; + $l->homepage=$row->homepage; + $l->updateamum=$row->updateamum; + $l->updatevon=$row->updatevon; + // Lektorendaten + $l->personalnummer=$row->personalnummer; + $l->kurzbz=$row->kurzbz; + $l->lektor=$row->lektor=='t'?true:false; + $l->fixangestellt=$row->fixangestellt=='t'?true:false; + $l->telefonklappe=$row->telefonklappe; + $l->ort_kurzbz=$row->ort_kurzbz; + // Lektor in Array speichern + $result[]=$l; + } + return $result; + } + + /** + * gibt array mit allen Mitarbeitern zurück + * @param $order gibt die spalte an nach der Sortiert werden soll + * @return array mit MA + */ + function getAll($order='upper(tbl_person.nachname),upper(tbl_person.vornamen)') + { + if (is_null($conn=$this->getConnection())) + { + return false; + } + $sql_query="set datestyle to german;SELECT tbl_person.*,". + "m.personalnummer,m.kurzbz,m.lektor,m.fixangestellt,m.telefonklappe, m.ort_kurzbz ". + "FROM tbl_person join tbl_mitarbeiter as m using(uid) ". + "ORDER by $order"; + if(!($erg=@pg_exec($conn, $sql_query))) + { + $this->errormsg=pg_errormessage($conn); + return false; + } + $num_rows=pg_numrows($erg); + $result=array(); + for($i=0;$i<$num_rows;$i++) + { + $row=pg_fetch_object($erg,$i); + $l=new mitarbeiter($this->conn); + // Personendaten + $l->uid=$row->uid; + $l->titel=$row->titel; + $l->vornamen=$row->vornamen; + $l->nachname=$row->nachname; + $l->gebdatum=$row->gebdatum; + $l->gebort=$row->gebort; + $l->gebzeit=$row->gebzeit; + $l->foto=$row->foto; + $l->anmerkungen=$row->anmerkungen; + $l->aktiv=$row->aktiv=='t'?true:false; + $l->email=$row->email; + $l->homepage=$row->homepage; + $l->updateamum=$row->updateamum; + $l->updatevon=$row->updatevon; + // Lektorendaten + $l->personalnummer=$row->personalnummer; + $l->kurzbz=$row->kurzbz; + $l->lektor=($row->lektor=='t'?'true':'false'); + $l->fixangestellt=($row->fixangestellt=='t'?'true':'false'); + $l->telefonklappe=$row->telefonklappe; + $l->ort_kurzbz=$row->ort_kurzbz; + // MA in Array speichern + $result[]=$l; + } + return $result; + + } + + /** + * gibt array mit allen Mitarbeitern zurueck + * @return array mit Mitarbeitern + */ + function getMitarbeiter($lektor=true,$fixangestellt=null,$stg_kz=null,$fachbereich_id=null) + { + if (is_null($conn=$this->getConnection())) + { + return false; + } + $sql_query='SELECT DISTINCT vw_mitarbeiter.* FROM vw_mitarbeiter + LEFT OUTER JOIN tbl_personfunktion USING(uid) + WHERE'; + if (!$lektor) + $sql_query.=' NOT'; + $sql_query.=' lektor'; + if ($fixangestellt!=null) + { + $sql_query.=' AND'; + if (!$fixangestellt) + $sql_query.=' NOT'; + $sql_query.=' fixangestellt'; + } + if ($stg_kz!=null) + $sql_query.=' AND studiengang_kz='.$stg_kz; + if ($fachbereich_id!=null) + $sql_query.=' AND fachbereich_id='.$fachbereich_id; + $sql_query.=' ORDER BY nachname, vornamen, kurzbz'; + //echo $sql_query; + if(!($erg=@pg_query($conn, $sql_query))) + { + $this->errormsg=pg_errormessage($conn); + return false; + } + $num_rows=pg_numrows($erg); + $result=array(); + for($i=0;$i<$num_rows;$i++) + { + $row=pg_fetch_object($erg,$i); + $l=new mitarbeiter($this->conn); + // Personendaten + $l->uid=$row->uid; + $l->titel=$row->titel; + $l->vornamen=$row->vornamen; + $l->nachname=$row->nachname; + $l->gebdatum=$row->gebdatum; + $l->gebort=$row->gebort; + $l->gebzeit=$row->gebzeit; + $l->foto=$row->foto; + $l->anmerkungen=$row->anmerkungen; + $l->aktiv=$row->aktiv=='t'?true:false; + $l->email=$row->email; + $l->homepage=$row->homepage; + $l->updateamum=$row->updateamum; + $l->updatevon=$row->updatevon; + // Lektorendaten + $l->personalnummer=$row->personalnummer; + $l->kurzbz=$row->kurzbz; + $l->lektor=$row->lektor=='t'?true:false; + $l->fixangestellt=$row->fixangestellt=='t'?true:false; + $l->telefonklappe=$row->telefonklappe; + //$l->ort_kurzbz=$row->ort_kurzbz; + // Lektor in Array speichern + $result[]=$l; + } + return $result; + } +} +?> \ No newline at end of file diff --git a/include/pdf.inc.php b/include/pdf.inc.php new file mode 100644 index 000000000..04608593b --- /dev/null +++ b/include/pdf.inc.php @@ -0,0 +1,191 @@ +FPDF($orientation,$unit,$format); + //Initialization + $this->B=0; + $this->I=0; + $this->U=0; + $this->HREF=''; + } + + /** + * gibt eine Fusszeile aus + * + */ + function Footer() + { + // Check if Footer for this page already exists (do the same for Header()) + if(!$this->footerset[$this->page]) { + $this->SetY(-30); + //Page number + $this->Cell(0,10,'Seite '.$this->PageNo().'/{nb}',0,0,'C'); + // set footerset + $this->footerset[$this->page] = 1; + } + } + + /** + * gibt eine Kopfzeile aus + * + */ + function Header() + { + // Check if Header for this page already exists (do the same for Footer()) + if(!$this->headerset[$this->page]) { + $this->SetFont('Arial','B',10); + $this->SetY(25); + //Page number + $this->Cell(0,10,'',0,0,'C'); + // set headerset + $this->SetY(100); + $this->headerset[$this->page] = 1; + } + } + + /** + * Erzeugt eine Tabelle + * @param $datas Array - 1. Zeile = Spaltenueberschrift + * x. Zeile = Eintraege + * $lineheight Zeilenhoehe + * $aligns Array - enthaelt die ausrichtung der Spalten (L=Left,R=Right,C=Center) + */ + function morepagestable($datas,$lineheight=12,$aligns) + { + // some things to set and 'remember' + $l = $this->lMargin; + $startheight = $h = $this->GetY(); + $startpage = $currpage = $this->page; + + // calculate the whole width + foreach($this->tablewidths AS $width) + { + $fullwidth += $width; + } + + // Now let's start to write the table + $r=0; + $markline=false; + foreach($datas AS $row => $data) + { + $this->page = $currpage; + // write the horizontal borders + if($r<=1) + { + $this->SetLineWidth(1.5); + $this->Line($l,$h,$fullwidth+$l,$h); + } + else + { + //$this->SetLineWidth(0.001); + //$this->Line($l,$h,$fullwidth+$l,$h); NO-Line + } + + //Farben fuer die zeilenmarkierung setzen + if($markline) + $this->SetFillColor(230,230,230); + else + $this->SetFillColor(255,255,255); + + $markline=!$markline; + + // write the content and remember the height of the highest col + foreach($data AS $col => $txt) + { + $this->page = $currpage; + $this->SetXY($l,$h); + $align=($r==0)?'C':$aligns[$col]; + if($r==0) $this->SetFont('Arial','B',$lineheight-2); + else $this->SetFont('Arial','',$lineheight-2); + + //erste und zweite zeile nicht fuellen da sonst der rahmen verloren geht + if($row==0) + $this->MultiCell($this->tablewidths[$col],$lineheight,$txt,0,$align,0); + else + $this->MultiCell($this->tablewidths[$col],$lineheight,$txt,0,$align,1); + + $l += $this->tablewidths[$col]; + + if($tmpheight[$row.'-'.$this->page] < $this->GetY()) + { + $tmpheight[$row.'-'.$this->page] = $this->GetY(); + } + if($this->page > $maxpage) + $maxpage = $this->page; + } + + // get the height we were in the last used page + $h = $tmpheight[$row.'-'.$maxpage]; + // set the "pointer" to the left margin + $l = $this->lMargin; + // set the $currpage to the last page + $currpage = $maxpage; + $r++; + } + // draw the borders + // we start adding a horizontal line on the last page + $this->page = $maxpage; + $this->SetLineWidth(1.5); + //Immer gleich + if($h<=660) + $h=660; + else + $h=810; + + $this->Line($l,$h,$fullwidth+$l,$h); + // now we start at the top of the document and walk down + for($i = $startpage; $i <= $maxpage; $i++) + { + $this->page = $i; + $l = $this->lMargin; + $t = ($i == $startpage) ? $startheight : $this->tMargin; + $lh = ($i == $maxpage) ? $h : $this->h-$this->bMargin; + $this->SetLineWidth(1.5); + $this->Line($l,$t,$l,$lh); + $n=0; + $maxcol=count($this->tablewidths)-1; + foreach($this->tablewidths AS $width) + { + $l += $width; + if($n==$maxcol) $this->SetLineWidth(1.5); + else $this->SetLineWidth(0.5); + $this->Line($l,$t,$l,$lh); + $n++; + } + } + // set it to the last page, if not it'll cause some problems + $this->page = $maxpage; + $this->SetY($h); + } + +} +?> \ No newline at end of file diff --git a/include/pdf/FAQ.htm b/include/pdf/FAQ.htm new file mode 100644 index 000000000..6cabb39dc --- /dev/null +++ b/include/pdf/FAQ.htm @@ -0,0 +1,286 @@ + + + +FAQ + + + +

    FAQ

    +1. What's exactly the license of FPDF? Are there any usage restrictions?
    +2. When I try to create a PDF, a lot of weird characters show on the screen. Why?
    +3. I try to generate a PDF and IE displays a blank page. What happens?
    +4. I send parameters using the POST method and the values don't appear in the PDF.
    +5. When I use a PHP session, IE doesn't display my PDF any more but asks me to download it.
    +6. When I'm on SSL, IE can't open the PDF.
    +7. When I execute a script I get the message "FPDF error: Don't alter the locale before including class file".
    +8. I try to put a PNG and Acrobat says "There was an error processing a page. A drawing error occurred".
    +9. I encounter the following error when I try to generate a PDF: Warning: Cannot add header information - headers already sent by (output started at script.php:X)
    +10. I try to display a variable in the Header method but nothing prints.
    +11. I defined the Header and Footer methods in my PDF class but nothing appears.
    +12. I can't make line breaks work. I put \n in the string printed by MultiCell but it doesn't work.
    +13. I try to put the euro symbol but it doesn't work.
    +14. I draw a frame with very precise dimensions, but when printed I notice some differences.
    +15. I'd like to use the whole surface of the page, but when printed I always have some margins. How can I get rid of them?
    +16. What's the limit of the file sizes I can generate with FPDF?
    +17. Can I modify a PDF with FPDF?
    +18. I'd like to make a search engine in PHP and index PDF files. Can I do it with FPDF?
    +19. Can I convert an HTML page to PDF with FPDF?
    +20. Can I concatenate PDF files with FPDF?
    +

    +

    1. What's exactly the license of FPDF? Are there any usage restrictions?

    +FPDF is Freeware (it is stated at the beginning of the source file). There is no usage +restriction. You may embed it freely in your application (commercial or not), with or +without modification. You may redistribute it, too. +

    2. When I try to create a PDF, a lot of weird characters show on the screen. Why?

    +These "weird" characters are in fact the actual content of your PDF. This behaviour is a bug of +IE. When it first receives an HTML page, then a PDF from the same URL, it displays it directly +without launching Acrobat. This happens frequently during the development stage: on the least +script error, an HTML page is sent, and after correction, the PDF arrives. +
    +To solve the problem, simply quit and restart IE. You can also go to another URL and come +back. +
    +To avoid this kind of inconvenience during the development, you can generate the PDF directly +to a file and open it through the explorer. +

    3. I try to generate a PDF and IE displays a blank page. What happens?

    +First of all, check that you send nothing to the browser after the PDF (not even a space or a +carriage return). You can put an exit statement just after the call to the Output() method to +be sure. +
    +If it still doesn't work, it means you're a victim of the "blank page syndrome". IE used in +conjunction with the Acrobat plug-in suffers from numerous bugs, in all versions. You should +test your application with as many IE versions as possible (at least if you're on the Internet). +The problem occurs mostly with the POST method, so it is strongly advised to avoid it (all the +more that it causes other problems, see the next question). The GET works better but may fail +when the URL becomes too long: don't use a query string with more than 45 characters. However, a +tip exists to exceed this limit: end the URL with .pdf, which tricks IE. If you use a form, you +can add a hidden field at the last position: +
    +
    +
    + +<INPUT TYPE="HIDDEN" NAME="ext" VALUE=".pdf"> + +

    +The usage of PHP sessions also often causes trouble (avoid using HTTP headers preventing caching). +See question 5 for a workaround. +
    +
    +To avoid all these problems in a reliable manner, two main techniques exist: +
    +
    +- Disable the plug-in and use Acrobat as a helper application. To do this, launch Acrobat; in +the File menu, Preferences, General, uncheck the option "Web Browser Integration" (for Acrobat +5: Edit, Preferences, Options, "Display PDF in Browser"). Then, the next time you load a PDF in +IE, it displays the dialog box "Open it" or "Save it to disk". Uncheck the option "Always ask +before opening this type of file" and choose Open. From now on, PDF files will open +automatically in an external Acrobat window. +
    +The drawback of the method is that you need to alter the client configuration, which you can do +in an intranet environment but not for the Internet. +
    +
    +- Use a redirection technique. It consists in generating the PDF in a temporary file on the +server and redirect the client on it (by using JavaScript, not the Location HTTP header which +also causes trouble). For instance, at the end of the script, you can put the following: +
    +
    +
    + +//Determine a temporary file name in the current directory
    +$file=basename(tempnam(getcwd(),'tmp'));
    +//Save PDF to file
    +$pdf->Output($file);
    +//JavaScript redirection
    +echo "<HTML><SCRIPT>document.location='getpdf.php?f=$file';</SCRIPT></HTML>"; +
    +

    +Then create the getpdf.php file with this: +
    +
    +
    + +<?php
    +$f=$HTTP_GET_VARS['f'];
    +//Check file (don't skip it!)
    +if(substr($f,0,3)!='tmp' or strpos($f,'/') or strpos($f,'\\'))
    +    die('Incorrect file name');
    +if(!file_exists($f))
    +    die('File does not exist');
    +//Handle special IE request if needed
    +if($HTTP_SERVER_VARS['HTTP_USER_AGENT']=='contype')
    +{
    +    Header('Content-Type: application/pdf');
    +    exit;
    +}
    +//Output PDF
    +Header('Content-Type: application/pdf');
    +Header('Content-Length: '.filesize($f));
    +readfile($f);
    +//Remove file
    +unlink($f);
    +exit;
    +?> +
    +

    +This method works in most cases but IE6 can still experience trouble. The "ultimate" method +consists in redirecting directly to the temporary file. The file name must therefore end with .pdf: +
    +
    +
    + +//Determine a temporary file name in the current directory
    +$file=basename(tempnam(getcwd(),'tmp'));
    +rename($file,$file.'.pdf');
    +$file.='.pdf';
    +//Save PDF to file
    +$pdf->Output($file);
    +//JavaScript redirection
    +echo "<HTML><SCRIPT>document.location='$file';</SCRIPT></HTML>"; +
    +

    +This method turns the dynamic PDF into a static one and avoids all troubles. But you have to do +some cleaning in order to delete the temporary files. For instance: +
    +
    +
    + +function CleanFiles($dir)
    +{
    +    //Delete temporary files
    +    $t=time();
    +    $h=opendir($dir);
    +    while($file=readdir($h))
    +    {
    +        if(substr($file,0,3)=='tmp' and substr($file,-4)=='.pdf')
    +        {
    +            $path=$dir.'/'.$file;
    +            if($t-filemtime($path)>3600)
    +                @unlink($path);
    +        }
    +    }
    +    closedir($h);
    +} +
    +

    +This function deletes all files of the form tmp*.pdf older than an hour in the specified +directory. You may call it where you want, for instance in the script which generates the PDF. +
    +
    +Remark: it is necessary to open the PDF in a new window, as you can't go backwards due to the +redirection. +

    4. I send parameters using the POST method and the values don't appear in the PDF.

    +It's a problem affecting some versions of IE (especially the first 5.5). See the previous +question for the ways to work around it. +

    5. When I use a PHP session, IE doesn't display my PDF any more but asks me to download it.

    +It's a problem affecting some versions of IE. To work around it, add the following line before +session_start(): +
    +
    +
    + +session_cache_limiter('private'); + +

    +or do a redirection as explained in question 3. +

    6. When I'm on SSL, IE can't open the PDF.

    +The problem may be fixed by adding this line:
    +
    +
    + +Header('Pragma: public'); + +

    + +

    7. When I execute a script I get the message "FPDF error: Don't alter the locale before including class file".

    +When the decimal separator is configured as a comma before including a file, there is a +bug in some PHP versions and decimal +numbers get truncated. Therefore you shouldn't make a call to setlocale() before including the class. +On Unix, you shouldn't set the LC_ALL environment variable neither, for it is equivalent to a +setlocale() call. +

    8. I try to put a PNG and Acrobat says "There was an error processing a page. A drawing error occurred".

    +Acrobat 5 has a bug and is unable to display transparent monochrome images (i.e. with 1 bit per +pixel). Remove transparency or save your image in 16 colors (4 bits per pixel) or more. +

    9. I encounter the following error when I try to generate a PDF: Warning: Cannot add header information - headers already sent by (output started at script.php:X)

    +You must send nothing to the browser except the PDF itself: no HTML, no space, no carriage return, +neither before nor after. The script outputs something at line X. +

    10. I try to display a variable in the Header method but nothing prints.

    +You have to use the global keyword, for instance: +
    +
    +
    + +function Header()
    +{
    +    global $title;
    +
    +    $this->SetFont('Arial','B',15);
    +    $this->Cell(0,10,$title,1,1,'C');
    +} +
    +

    + +

    11. I defined the Header and Footer methods in my PDF class but nothing appears.

    +You have to create an object from the PDF class, not FPDF:
    +
    +
    + +$pdf=new PDF(); + +

    + +

    12. I can't make line breaks work. I put \n in the string printed by MultiCell but it doesn't work.

    +You have to enclose your string with double quotes, not single ones. +

    13. I try to put the euro symbol but it doesn't work.

    +The standard fonts have the euro character at position 128. You can define a constant like this +for convenience: +
    +
    +
    + +define('EURO',chr(128)); + +

    +Note: Acrobat 4 or higher is required to display euro. +

    14. I draw a frame with very precise dimensions, but when printed I notice some differences.

    +To respect dimensions, you have to uncheck the option "Fit to page" in the print dialog box. +

    15. I'd like to use the whole surface of the page, but when printed I always have some margins. How can I get rid of them?

    +All printers have physical margins (different depending on the model), it is therefore impossible +to remove them and print on the totality of the paper. +

    16. What's the limit of the file sizes I can generate with FPDF?

    +There is no particular limit. There are some constraints however: +
    +
    +- The maximum memory size allocated to PHP scripts defaults to 8MB. For very big documents, +especially with images, this limit may be reached (the file being built into memory). The +parameter is configured in the php.ini file. +
    +
    +- The maximum execution time allocated defaults to 30 seconds. This limit can of course be easily +reached. It is configured in php.ini and may be altered dynamically with set_time_limit(). +
    +
    +- Browsers generally have a 5 minute time-out. If you send the PDF directly to the browser and +reach the limit, it will be lost. It is therefore advised for very big documents to +generate them in a file, and to send some data to the browser from time to time (for instance +page 1, page 2... with flush() to force the output). When the document is finished, you can send +a redirection on it with JavaScript or create a link. +
    +Remark: even when the browser goes in time-out, the script may continue to run on the server. +

    17. Can I modify a PDF with FPDF?

    +No. +

    18. I'd like to make a search engine in PHP and index PDF files. Can I do it with FPDF?

    +No. But a GPL C utility does exist, pdftotext, which is able to extract the textual content from +a PDF. It is provided with the Xpdf package:
    +
    +http://www.foolabs.com/xpdf/ +

    19. Can I convert an HTML page to PDF with FPDF?

    +No. But a GPL C utility does exist, htmldoc, which allows to do it and gives good results:
    +
    +http://www.easysw.com/htmldoc/ +

    20. Can I concatenate PDF files with FPDF?

    +No. But a free C utility exists to perform this task:
    +
    +http://thierry.schmit.free.fr/dev/mbtPdfAsm/enMbtPdfAsm2.html + + diff --git a/include/pdf/doc/acceptpagebreak.htm b/include/pdf/doc/acceptpagebreak.htm new file mode 100644 index 000000000..eb40f2b52 --- /dev/null +++ b/include/pdf/doc/acceptpagebreak.htm @@ -0,0 +1,70 @@ + + + +AcceptPageBreak + + + +

    AcceptPageBreak

    +boolean AcceptPageBreak() +

    Version

    +1.4 +

    Description

    +Whenever a page break condition is met, the method is called, and the break is issued or not +depending on the returned value. The default implementation returns a value according to the +mode selected by SetAutoPageBreak(). +
    +This method is called automatically and should not be called directly by the application. +

    Example

    +The method is overriden in an inherited class in order to obtain a 3 column layout: +
    +
    +
    + +class PDF extends FPDF
    +{
    +var $col=0;
    +
    +function SetCol($col)
    +{
    +    //Move position to a column
    +    $this->col=$col;
    +    $x=10+$col*65;
    +    $this->SetLeftMargin($x);
    +    $this->SetX($x);
    +}
    +
    +function AcceptPageBreak()
    +{
    +    if($this->col<2)
    +    {
    +        //Go to next column
    +        $this->SetCol($this->col+1);
    +        $this->SetY(10);
    +        return false;
    +    }
    +    else
    +    {
    +        //Go back to first column and issue page break
    +        $this->SetCol(0);
    +        return true;
    +    }
    +}
    +}
    +
    +$pdf=new PDF();
    +$pdf->Open();
    +$pdf->AddPage();
    +$pdf->SetFont('Arial','',12);
    +for($i=1;$i<=300;$i++)
    +    $pdf->Cell(0,5,"Line $i",0,1);
    +$pdf->Output(); +
    +

    +

    See also

    +SetAutoPageBreak(). +
    +
    + + + diff --git a/include/pdf/doc/addfont.htm b/include/pdf/doc/addfont.htm new file mode 100644 index 000000000..4912f5e1b --- /dev/null +++ b/include/pdf/doc/addfont.htm @@ -0,0 +1,62 @@ + + + +AddFont + + + +

    AddFont

    +AddFont(string family [, string style [, string file]]) +

    Version

    +1.5 +

    Description

    +Imports a TrueType or Type1 font and makes it available. It is necessary to generate a font +definition file first with the makefont.php utility. +
    +The definition file (and the font file itself when embedding) must be present either in the +current directory or in the one indicated by FPDF_FONTPATH if the constant is defined. +If it could not be found, the error "Could not include font definition file" is generated. +

    Parameters

    +family +
    +Font family. The name can be chosen arbitrarily. If it is a standard family name, it will +override the corresponding font. +
    +style +
    +Font style. Possible values are (case insensitive): +
      +
    • empty string: regular +
    • B: bold +
    • I: italic +
    • BI or IB: bold italic +
    +The default value is regular. +
    +file +
    +The font definition file. +
    +By default, the name is built from the family and style, in lower case with no space. +
    +

    Example

    +
    + +$pdf->AddFont('Comic','I'); + +

    +is equivalent to: +
    +
    +
    + +$pdf->AddFont('Comic','I','comici.php'); + +

    +

    See also

    +SetFont(). +
    +
    + + + diff --git a/include/pdf/doc/addlink.htm b/include/pdf/doc/addlink.htm new file mode 100644 index 000000000..1763ebf62 --- /dev/null +++ b/include/pdf/doc/addlink.htm @@ -0,0 +1,28 @@ + + + +AddLink + + + +

    AddLink

    +int AddLink() +

    Version

    +1.5 +

    Description

    +Creates a new internal link and returns its identifier. An internal link is a clickable area +which directs to another place within the document. +
    +The identifier can then be passed to Cell(), Write(), Image() or Link(). The destination is +defined with SetLink(). +

    See also

    +Cell(), +Write(), +Image(), +Link(), +SetLink(). +
    +
    + + + diff --git a/include/pdf/doc/addpage.htm b/include/pdf/doc/addpage.htm new file mode 100644 index 000000000..6f8b4c526 --- /dev/null +++ b/include/pdf/doc/addpage.htm @@ -0,0 +1,42 @@ + + + +AddPage + + + +

    AddPage

    +AddPage([string orientation]) +

    Version

    +1.0 +

    Description

    +Adds a new page to the document. If a page is already present, the Footer() method is called +first to output the footer. Then the page is added, the current position set to the top-left +corner according to the left and top margins, and Header() is called to display the header. +
    +The font which was set before calling is automatically restored. There is no need to call +SetFont() again if you want to continue with the same font. The same is true for colors and +line width. +
    +The origin of the coordinate system is at the top-left corner and increasing ordinates go +downwards. +

    Parameters

    +orientation +
    +Page orientation. Possible values are (case insensitive): +
      +
    • P or Portrait +
    • L or Landscape +
    +The default value is the one passed to the constructor. +
    +

    See also

    +FPDF(), +Header(), +Footer(), +SetMargins(). +
    +
    + + + diff --git a/include/pdf/doc/aliasnbpages.htm b/include/pdf/doc/aliasnbpages.htm new file mode 100644 index 000000000..8e1759e07 --- /dev/null +++ b/include/pdf/doc/aliasnbpages.htm @@ -0,0 +1,47 @@ + + + +AliasNbPages + + + +

    AliasNbPages

    +AliasNbPages([string alias]) +

    Version

    +1.4 +

    Description

    +Defines an alias for the total number of pages. It will be substituted as the document is +closed. +

    Parameters

    +alias +
    +The alias. Default value: {nb}. +
    +

    Example

    +
    + +class PDF extends FPDF
    +{
    +function Footer()
    +{
    +    //Go to 1.5 cm from bottom
    +    $this->SetY(-15);
    +    //Select Arial italic 8
    +    $this->SetFont('Arial','I',8);
    +    //Print current and total page numbers
    +    $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
    +}
    +}
    +
    +$pdf=new PDF();
    +$pdf->AliasNbPages(); +
    +

    +

    See also

    +PageNo(), +Footer(). +
    +
    + + + diff --git a/include/pdf/doc/cell.htm b/include/pdf/doc/cell.htm new file mode 100644 index 000000000..1f8dabd1d --- /dev/null +++ b/include/pdf/doc/cell.htm @@ -0,0 +1,106 @@ + + + +Cell + + + +

    Cell

    +Cell(float w [, float h [, string txt [, mixed border [, int ln [, string align [, int fill [, mixed link]]]]]]]) +

    Version

    +1.0 +

    Description

    +Prints a cell (rectangular area) with optional borders, background color and character string. +The upper-left corner of the cell corresponds to the current position. The text can be aligned +or centered. After the call, the current position moves to the right or to the next line. It is +possible to put a link on the text. +
    +If automatic page breaking is enabled and the cell goes beyond the limit, a page break is +done before outputting. +

    Parameters

    +w +
    +Cell width. If 0, the cell extends up to the right margin. +
    +h +
    +Cell height. +Default value: 0. +
    +txt +
    +String to print. +Default value: empty string. +
    +border +
    +Indicates if borders must be drawn around the cell. The value can be either a number: +
      +
    • 0: no border +
    • 1: frame +
    +or a string containing some or all of the following characters (in any order): +
      +
    • L: left +
    • T: top +
    • R: right +
    • B: bottom +
    +Default value: 0. +
    +ln +
    +Indicates where the current position should go after the call. Possible values are: +
      +
    • 0: to the right +
    • 1: to the beginning of the next line +
    • 2: below +
    +Putting 1 is equivalent to putting 0 and calling Ln() just after. +Default value: 0. +
    +align +
    +Allows to center or align the text. Possible values are: +
      +
    • L or empty string: left align (default value) +
    • C: center +
    • R: right align +
    +
    +fill +
    +Indicates if the cell background must be painted (1) or transparent (0). +Default value: 0. +
    +link +
    +URL or identifier returned by AddLink(). +
    +

    Example

    +
    + +//Set font
    +$pdf->SetFont('Arial','B',16);
    +//Move to 8 cm to the right
    +$pdf->Cell(80);
    +//Centered text in a framed 20*10 mm cell and line break
    +$pdf->Cell(20,10,'Title',1,1,'C'); +
    +

    +

    See also

    +SetFont(), +SetDrawColor(), +SetFillColor(), +SetTextColor(), +SetLineWidth(), +AddLink(), +Ln(), +MultiCell(), +Write(), +SetAutoPageBreak(). +
    +
    + + + diff --git a/include/pdf/doc/close.htm b/include/pdf/doc/close.htm new file mode 100644 index 000000000..dcce911b0 --- /dev/null +++ b/include/pdf/doc/close.htm @@ -0,0 +1,24 @@ + + + +Close + + + +

    Close

    +Close() +

    Version

    +1.0 +

    Description

    +Terminates the PDF document. It is not necessary to call this method explicitly because Output() +does it automatically. +
    +If the document contains no page, AddPage() is called to prevent from getting an invalid document. +

    See also

    +Open(), +Output(). +
    +
    + + + diff --git a/include/pdf/doc/error.htm b/include/pdf/doc/error.htm new file mode 100644 index 000000000..e31a921ab --- /dev/null +++ b/include/pdf/doc/error.htm @@ -0,0 +1,25 @@ + + + +Error + + + +

    Error

    +Error(string msg) +

    Version

    +1.0 +

    Description

    +This method is automatically called in case of fatal error; it simply outputs the message +and halts the execution. An inherited class may override it to customize the error handling +but should always halt the script, or the resulting document would probably be invalid. +

    Parameters

    +msg +
    +The error message. +
    +
    +
    + + + diff --git a/include/pdf/doc/footer.htm b/include/pdf/doc/footer.htm new file mode 100644 index 000000000..3ff01dfc7 --- /dev/null +++ b/include/pdf/doc/footer.htm @@ -0,0 +1,39 @@ + + + +Footer + + + +

    Footer

    +Footer() +

    Version

    +1.0 +

    Description

    +This method is used to render the page footer. It is automatically called by AddPage() and +Close() and should not be called directly by the application. The implementation in FPDF is +empty, so you have to subclass it and override the method if you want a specific processing. +

    Example

    +
    + +class PDF extends FPDF
    +{
    +function Footer()
    +{
    +    //Go to 1.5 cm from bottom
    +    $this->SetY(-15);
    +    //Select Arial italic 8
    +    $this->SetFont('Arial','I',8);
    +    //Print centered page number
    +    $this->Cell(0,10,'Page '.$this->PageNo(),0,0,'C');
    +}
    +} +
    +

    +

    See also

    +Header(). +
    +
    + + + diff --git a/include/pdf/doc/fpdf.htm b/include/pdf/doc/fpdf.htm new file mode 100644 index 000000000..dffea26b2 --- /dev/null +++ b/include/pdf/doc/fpdf.htm @@ -0,0 +1,57 @@ + + + +FPDF + + + +

    FPDF

    +FPDF([string orientation [, string unit [, mixed format]]]) +

    Version

    +1.0 +

    Description

    +This is the class constructor. It allows to set up the page format, the orientation and the +measure unit used in all the methods (except for the font sizes). +

    Parameters

    +orientation +
    +Default page orientation. Possible values are (case insensitive): +
      +
    • P or Portrait +
    • L or Landscape +
    +Default value is P. +
    +unit +
    +User measure unit. Possible values are: +
      +
    • pt: point +
    • mm: millimeter +
    • cm: centimeter +
    • in: inch +
    +A point equals 1/72 of inch, that is to say about 0.35 mm (an inch being 2.54 cm). This +is a very common unit in typography; font sizes are expressed in that unit. +
    +
    +Default value is mm. +
    +format +
    +The format used for pages. It can be either one of the following values (case insensitive): +
      +
    • A3 +
    • A4 +
    • A5 +
    • Letter +
    • Legal +
    +or a custom format in the form of a two-element array containing the width and the height +(expressed in the unit given by unit). +
    +
    +
    + + + diff --git a/include/pdf/doc/getstringwidth.htm b/include/pdf/doc/getstringwidth.htm new file mode 100644 index 000000000..b879b95e4 --- /dev/null +++ b/include/pdf/doc/getstringwidth.htm @@ -0,0 +1,23 @@ + + + +GetStringWidth + + + +

    GetStringWidth

    +float GetStringWidth(string s) +

    Version

    +1.2 +

    Description

    +Returns the length of a string in user unit. A font must be selected. +

    Parameters

    +s +
    +The string whose length is to be computed. +
    +
    +
    + + + diff --git a/include/pdf/doc/getx.htm b/include/pdf/doc/getx.htm new file mode 100644 index 000000000..ba49feca5 --- /dev/null +++ b/include/pdf/doc/getx.htm @@ -0,0 +1,22 @@ + + + +GetX + + + +

    GetX

    +float GetX() +

    Version

    +1.2 +

    Description

    +Returns the abscissa of the current position. +

    See also

    +SetX(), +GetY(), +SetY(). +
    +
    + + + diff --git a/include/pdf/doc/gety.htm b/include/pdf/doc/gety.htm new file mode 100644 index 000000000..e04eff01d --- /dev/null +++ b/include/pdf/doc/gety.htm @@ -0,0 +1,22 @@ + + + +GetY + + + +

    GetY

    +float GetY() +

    Version

    +1.0 +

    Description

    +Returns the ordinate of the current position. +

    See also

    +SetY(), +GetX(), +SetX(). +
    +
    + + + diff --git a/include/pdf/doc/header.htm b/include/pdf/doc/header.htm new file mode 100644 index 000000000..88701cb2b --- /dev/null +++ b/include/pdf/doc/header.htm @@ -0,0 +1,41 @@ + + + +Header + + + +

    Header

    +Header() +

    Version

    +1.0 +

    Description

    +This method is used to render the page header. It is automatically called by AddPage() and +should not be called directly by the application. The implementation in FPDF is empty, so +you have to subclass it and override the method if you want a specific processing. +

    Example

    +
    + +class PDF extends FPDF
    +{
    +function Header()
    +{
    +    //Select Arial bold 15
    +    $this->SetFont('Arial','B',15);
    +    //Move to the right
    +    $this->Cell(80);
    +    //Framed title
    +    $this->Cell(30,10,'Title',1,0,'C');
    +    //Line break
    +    $this->Ln(20);
    +}
    +} +
    +

    +

    See also

    +Footer(). +
    +
    + + + diff --git a/include/pdf/doc/image.htm b/include/pdf/doc/image.htm new file mode 100644 index 000000000..35e83b36e --- /dev/null +++ b/include/pdf/doc/image.htm @@ -0,0 +1,88 @@ + + + +Image + + + +

    Image

    +Image(string file, float x, float y [, float w [, float h [, string type [, mixed link]]]]) +

    Version

    +1.1 +

    Description

    +Puts an image in the page. The upper-left corner must be given. The dimensions can be specified +in different ways: +
      +
    • explicit width and height (expressed in user unit) +
    • one explicit dimension, the other being calculated automatically in order to keep the original +proportions +
    • no explicit dimension, in which case the image is put at 72 dpi +
    +Supported formats are JPEG and PNG. +
    +
    +For JPEG, all flavors are allowed: +
      +
    • gray scales +
    • true colors (24 bits) +
    • CMYK (32 bits) +
    +For PNG, are allowed: +
      +
    • gray scales on at most 8 bits (256 levels) +
    • indexed colors +
    • true colors (24 bits) +
    +but are not supported: +
      +
    • Interlacing +
    • Alpha channel +
    +If a transparent color is defined, it will be taken into account (but will be only interpreted +by Acrobat 4 and above). +
    +The format can be specified explicitly or inferred from the file extension. +
    +It is possible to put a link on the image. +
    +
    +Remark: if an image is used several times, only one copy will be embedded in the file. +

    Parameters

    +file +
    +Name of the file containing the image. +
    +x +
    +Abscissa of the upper-left corner. +
    +y +
    +Ordinate of the upper-left corner. +
    +w +
    +Width of the image in the page. If not specified or equal to zero, it is automatically +calculated. +
    +h +
    +Height of the image in the page. If not specified or equal to zero, it is automatically +calculated. +
    +type +
    +Image format. Possible values are (case insensitive): JPG, JPEG, PNG. +If not specified, the type is inferred from the file extension. +
    +link +
    +URL or identifier returned by AddLink(). +
    +

    See also

    +AddLink(). +
    +
    + + + diff --git a/include/pdf/doc/index.htm b/include/pdf/doc/index.htm new file mode 100644 index 000000000..74a4f5c73 --- /dev/null +++ b/include/pdf/doc/index.htm @@ -0,0 +1,57 @@ + + + +FPDF 1.52 Reference Manual + + + +

    FPDF 1.52 Reference Manual

    +AcceptPageBreak - accept or not automatic page break
    +AddFont - add a new font
    +AddLink - create an internal link
    +AddPage - add a new page
    +AliasNbPages - define an alias for number of pages
    +Cell - print a cell
    +Close - terminate the document
    +Error - fatal error
    +Footer - page footer
    +FPDF - constructor
    +GetStringWidth - compute string length
    +GetX - get current x position
    +GetY - get current y position
    +Header - page header
    +Image - output an image
    +Line - draw a line
    +Link - put a link
    +Ln - line break
    +MultiCell - print text with line breaks
    +Open - create a document
    +Output - save or send the document
    +PageNo - page number
    +Rect - draw a rectangle
    +SetAuthor - set the document author
    +SetAutoPageBreak - set the automatic page breaking mode
    +SetCompression - turn compression on or off
    +SetCreator - set document creator
    +SetDisplayMode - set display mode
    +SetDrawColor - set drawing color
    +SetFillColor - set filling color
    +SetFont - set font
    +SetFontSize - set font size
    +SetKeywords - associate keywords with document
    +SetLeftMargin - set left margin
    +SetLineWidth - set line width
    +SetLink - set internal link destination
    +SetMargins - set margins
    +SetRightMargin - set right margin
    +SetSubject - set document subject
    +SetTextColor - set text color
    +SetTitle - set document title
    +SetTopMargin - set top margin
    +SetX - set current x position
    +SetXY - set current x and y positions
    +SetY - set current y position
    +Text - print a string
    +Write - print flowing text
    + + diff --git a/include/pdf/doc/line.htm b/include/pdf/doc/line.htm new file mode 100644 index 000000000..f9c1e5afd --- /dev/null +++ b/include/pdf/doc/line.htm @@ -0,0 +1,38 @@ + + + +Line + + + +

    Line

    +Line(float x1, float y1, float x2, float y2) +

    Version

    +1.0 +

    Description

    +Draws a line between two points. +

    Parameters

    +x1 +
    +Abscissa of first point. +
    +y1 +
    +Ordinate of first point. +
    +x2 +
    +Abscissa of second point. +
    +y2 +
    +Ordinate of second point. +
    +

    See also

    +SetLineWidth(), +SetDrawColor(). +
    +
    + + + diff --git a/include/pdf/doc/link.htm b/include/pdf/doc/link.htm new file mode 100644 index 000000000..4a7b8560c --- /dev/null +++ b/include/pdf/doc/link.htm @@ -0,0 +1,46 @@ + + + +Link + + + +

    Link

    +Link(float x, float y, float w, float h, mixed link) +

    Version

    +1.5 +

    Description

    +Puts a link on a rectangular area of the page. Text or image links are generally put via Cell(), +Write() or Image(), but this method can be useful for instance to define a clickable area inside +an image. +

    Parameters

    +x +
    +Abscissa of the upper-left corner of the rectangle. +
    +y +
    +Ordinate of the upper-left corner of the rectangle. +
    +w +
    +Width of the rectangle. +
    +h +
    +Height of the rectangle. +
    +link +
    +URL or identifier returned by AddLink(). +
    +

    See also

    +AddLink(), +Cell(), +Write(), +Image(). +
    +
    + + + diff --git a/include/pdf/doc/ln.htm b/include/pdf/doc/ln.htm new file mode 100644 index 000000000..c9f3bc895 --- /dev/null +++ b/include/pdf/doc/ln.htm @@ -0,0 +1,28 @@ + + + +Ln + + + +

    Ln

    +Ln([float h]) +

    Version

    +1.0 +

    Description

    +Performs a line break. The current abscissa goes back to the left margin and the ordinate +increases by the amount passed in parameter. +

    Parameters

    +h +
    +The height of the break. +
    +By default, the value equals the height of the last printed cell. +
    +

    See also

    +Cell(). +
    +
    + + + diff --git a/include/pdf/doc/multicell.htm b/include/pdf/doc/multicell.htm new file mode 100644 index 000000000..fb0be4650 --- /dev/null +++ b/include/pdf/doc/multicell.htm @@ -0,0 +1,76 @@ + + + +MultiCell + + + +

    MultiCell

    +MultiCell(float w, float h, string txt [, mixed border [, string align [, int fill]]]) +

    Version

    +1.3 +

    Description

    +This method allows printing text with line breaks. They can be automatic (as soon as the +text reaches the right border of the cell) or explicit (via the \n character). As many cells +as necessary are output, one below the other. +
    +Text can be aligned, centered or justified. The cell block can be framed and the background +painted. +

    Parameters

    +w +
    +Width of cells. If 0, they extend up to the right margin of the page. +
    +h +
    +Height of cells. +
    +txt +
    +String to print. +
    +border +
    +Indicates if borders must be drawn around the cell block. The value can be either a number: +
      +
    • 0: no border +
    • 1: frame +
    +or a string containing some or all of the following characters (in any order): +
      +
    • L: left +
    • T: top +
    • R: right +
    • B: bottom +
    +Default value: 0. +
    +align +
    +Sets the text alignment. Possible values are: +
      +
    • L: left alignment +
    • C: center +
    • R: right alignment +
    • J: justification (default value) +
    +
    +fill +
    +Indicates if the cell background must be painted (1) or transparent (0). +Default value: 0. +
    +

    See also

    +SetFont(), +SetDrawColor(), +SetFillColor(), +SetTextColor(), +SetLineWidth(), +Cell(), +Write(), +SetAutoPageBreak(). +
    +
    + + + diff --git a/include/pdf/doc/open.htm b/include/pdf/doc/open.htm new file mode 100644 index 000000000..010ce230f --- /dev/null +++ b/include/pdf/doc/open.htm @@ -0,0 +1,23 @@ + + + +Open + + + +

    Open

    +Open() +

    Version

    +1.0 +

    Description

    +This method begins the generation of the PDF document. It is not necessary to call it +explicitly because AddPage() does it automatically.
    +Note: no page is created by this method. +

    See also

    +AddPage(), +Close(). +
    +
    + + + diff --git a/include/pdf/doc/output.htm b/include/pdf/doc/output.htm new file mode 100644 index 000000000..8317c09c7 --- /dev/null +++ b/include/pdf/doc/output.htm @@ -0,0 +1,47 @@ + + + +Output + + + +

    Output

    +string Output([string name [, string dest]]) +

    Version

    +1.0 +

    Description

    +Send the document to a given destination: string, local file or browser. In the last case, the +plug-in may be used (if present) or a download ("Save as" dialog box) may be forced. +
    +The method first calls Close() if necessary to terminate the document. +

    Parameters

    +name +
    +The name of the file. If not given, the document will be sent to the browser +(destination I) with the name doc.pdf. +
    +dest +
    +Destination where to send the document. It can take one of the following values: +
      +
    • I: send the file inline to the browser. The plug-in is used if available. +The name given by name is used when one selects the "Save as" option on the +link generating the PDF. +
    • D: send to the browser and force a file download with the name given by +name. +
    • F: save to a local file with the name given by name. +
    • S: return the document as a string. name is ignored. +
    +If the parameter is not specified but a name is given, destination is F. If no +parameter is specified at all, destination is I.
    +
    +Note: for compatibility with previous versions, a boolean value is also accepted +(false for F and true for D). +
    +

    See also

    +Close(). +
    +
    + + + diff --git a/include/pdf/doc/pageno.htm b/include/pdf/doc/pageno.htm new file mode 100644 index 000000000..5aab5f616 --- /dev/null +++ b/include/pdf/doc/pageno.htm @@ -0,0 +1,20 @@ + + + +PageNo + + + +

    PageNo

    +int PageNo() +

    Version

    +1.0 +

    Description

    +Returns the current page number. +

    See also

    +AliasNbPages(). +
    +
    + + + diff --git a/include/pdf/doc/rect.htm b/include/pdf/doc/rect.htm new file mode 100644 index 000000000..e639b51e9 --- /dev/null +++ b/include/pdf/doc/rect.htm @@ -0,0 +1,48 @@ + + + +Rect + + + +

    Rect

    +Rect(float x, float y, float w, float h [, string style]) +

    Version

    +1.0 +

    Description

    +Outputs a rectangle. It can be drawn (border only), filled (with no border) or both. +

    Parameters

    +x +
    +Abscissa of upper-left corner. +
    +y +
    +Ordinate of upper-left corner. +
    +w +
    +Width. +
    +h +
    +Height. +
    +style +
    +Style of rendering. Possible values are: +
      +
    • D or empty string: draw. This is the default value. +
    • F: fill +
    • DF or FD: draw and fill +
    +
    +

    See also

    +SetLineWidth(), +SetDrawColor(), +SetFillColor(). +
    +
    + + + diff --git a/include/pdf/doc/setauthor.htm b/include/pdf/doc/setauthor.htm new file mode 100644 index 000000000..2e9769463 --- /dev/null +++ b/include/pdf/doc/setauthor.htm @@ -0,0 +1,28 @@ + + + +SetAuthor + + + +

    SetAuthor

    +SetAuthor(string author) +

    Version

    +1.2 +

    Description

    +Defines the author of the document. +

    Parameters

    +author +
    +The name of the author. +
    +

    See also

    +SetCreator(), +SetKeywords(), +SetSubject(), +SetTitle(). +
    +
    + + + diff --git a/include/pdf/doc/setautopagebreak.htm b/include/pdf/doc/setautopagebreak.htm new file mode 100644 index 000000000..98193f987 --- /dev/null +++ b/include/pdf/doc/setautopagebreak.htm @@ -0,0 +1,33 @@ + + + +SetAutoPageBreak + + + +

    SetAutoPageBreak

    +SetAutoPageBreak(boolean auto [, float margin]) +

    Version

    +1.0 +

    Description

    +Enables or disables the automatic page breaking mode. When enabling, the second parameter is +the distance from the bottom of the page that defines the triggering limit. By default, the +mode is on and the margin is 2 cm. +

    Parameters

    +auto +
    +Boolean indicating if mode should be on or off. +
    +margin +
    +Distance from the bottom of the page. +
    +

    See also

    +Cell(), +MultiCell(), +AcceptPageBreak(). +
    +
    + + + diff --git a/include/pdf/doc/setcompression.htm b/include/pdf/doc/setcompression.htm new file mode 100644 index 000000000..33c15f159 --- /dev/null +++ b/include/pdf/doc/setcompression.htm @@ -0,0 +1,31 @@ + + + +SetCompression + + + +

    SetCompression

    +SetCompression(boolean compress) +

    Version

    +1.4 +

    Description

    +Activates or deactivates page compression. When activated, the internal representation of +each page is compressed, which leads to a compression ratio of about 2 for the resulting +document. +
    +Compression is on by default. +
    +
    +Note: the Zlib extension is required for this feature. If not present, compression +will be turned off. +

    Parameters

    +compress +
    +Boolean indicating if compression must be enabled. +
    +
    +
    + + + diff --git a/include/pdf/doc/setcreator.htm b/include/pdf/doc/setcreator.htm new file mode 100644 index 000000000..abdd887f5 --- /dev/null +++ b/include/pdf/doc/setcreator.htm @@ -0,0 +1,29 @@ + + + +SetCreator + + + +

    SetCreator

    +SetCreator(string creator) +

    Version

    +1.2 +

    Description

    +Defines the creator of the document. This is typically the name of the application that +generates the PDF. +

    Parameters

    +creator +
    +The name of the creator. +
    +

    See also

    +SetAuthor(), +SetKeywords(), +SetSubject(), +SetTitle(). +
    +
    + + + diff --git a/include/pdf/doc/setdisplaymode.htm b/include/pdf/doc/setdisplaymode.htm new file mode 100644 index 000000000..5211db556 --- /dev/null +++ b/include/pdf/doc/setdisplaymode.htm @@ -0,0 +1,47 @@ + + + +SetDisplayMode + + + +

    SetDisplayMode

    +SetDisplayMode(mixed zoom [, string layout]) +

    Version

    +1.2 +

    Description

    +Defines the way the document is to be displayed by the viewer. The zoom level can be set: pages can be +displayed entirely on screen, occupy the full width of the window, use real size, be scaled by a +specific zooming factor or use viewer default (configured in the Preferences menu of Acrobat). +The page layout can be specified too: single at once, continuous display, two columns or viewer +default. +
    +By default, documents use the full width mode with continuous display. +

    Parameters

    +zoom +
    +The zoom to use. It can be one of the following string values: +
      +
    • fullpage: displays the entire page on screen +
    • fullwidth: uses maximum width of window +
    • real: uses real size (equivalent to 100% zoom) +
    • default: uses viewer default mode +
    +or a number indicating the zooming factor to use. +
    +layout +
    +The page layout. Possible values are: +
      +
    • single: displays one page at once +
    • continuous: displays pages continuously +
    • two: displays two pages on two columns +
    • default: uses viewer default mode +
    +Default value is continuous. +
    +
    +
    + + + diff --git a/include/pdf/doc/setdrawcolor.htm b/include/pdf/doc/setdrawcolor.htm new file mode 100644 index 000000000..ca54be265 --- /dev/null +++ b/include/pdf/doc/setdrawcolor.htm @@ -0,0 +1,41 @@ + + + +SetDrawColor + + + +

    SetDrawColor

    +SetDrawColor(int r [, int g, int b]) +

    Version

    +1.3 +

    Description

    +Defines the color used for all drawing operations (lines, rectangles and cell borders). It +can be expressed in RGB components or gray scale. The method can be called before the first +page is created and the value is retained from page to page. +

    Parameters

    +r +
    +If g et b are given, red component; if not, indicates the gray level. +Value between 0 and 255. +
    +g +
    +Green component (between 0 and 255). +
    +b +
    +Blue component (between 0 and 255). +
    +

    See also

    +SetFillColor(), +SetTextColor(), +Line(), +Rect(), +Cell(), +MultiCell(). +
    +
    + + + diff --git a/include/pdf/doc/setfillcolor.htm b/include/pdf/doc/setfillcolor.htm new file mode 100644 index 000000000..9e59e9529 --- /dev/null +++ b/include/pdf/doc/setfillcolor.htm @@ -0,0 +1,40 @@ + + + +SetFillColor + + + +

    SetFillColor

    +SetFillColor(int r [, int g, int b]) +

    Version

    +1.3 +

    Description

    +Defines the color used for all filling operations (filled rectangles and cell backgrounds). +It can be expressed in RGB components or gray scale. The method can be called before the first +page is created and the value is retained from page to page. +

    Parameters

    +r +
    +If g and b are given, red component; if not, indicates the gray level. +Value between 0 and 255. +
    +g +
    +Green component (between 0 and 255). +
    +b +
    +Blue component (between 0 and 255). +
    +

    See also

    +SetDrawColor(), +SetTextColor(), +Rect(), +Cell(), +MultiCell(). +
    +
    + + + diff --git a/include/pdf/doc/setfont.htm b/include/pdf/doc/setfont.htm new file mode 100644 index 000000000..5c2dc709c --- /dev/null +++ b/include/pdf/doc/setfont.htm @@ -0,0 +1,103 @@ + + + +SetFont + + + +

    SetFont

    +SetFont(string family [, string style [, float size]]) +

    Version

    +1.0 +

    Description

    +Sets the font used to print character strings. It is mandatory to call this method +at least once before printing text or the resulting document would not be valid. +
    +The font can be either a standard one or a font added via the AddFont() method. Standard fonts +use Windows encoding cp1252 (Western Europe). +
    +The method can be called before the first page is created and the font is retained from page +to page. +
    +If you just wish to change the current font size, it is simpler to call SetFontSize(). +
    +
    +Note: for the standard fonts, the font metric files must be accessible. There are three +possibilities for this: +
    +
    +
      +
    • They are in the current directory (the one where the running script lies) +
      +
    • They are in one of the directories defined by the include_path parameter +
      +
    • They are in the directory defined by the FPDF_FONTPATH constant +
    +Example for the last case (note the trailing slash): +
    +
    +
    + +define('FPDF_FONTPATH','/home/www/font/');
    +require('fpdf.php'); +
    +

    +If the file corresponding to the requested font is not found, the error "Could not include +font metric file" is generated. +

    Parameters

    +family +
    +Family font. It can be either a name defined by AddFont() or one of the standard families (case +insensitive): +
      +
    • Courier (fixed-width) +
    • Helvetica or Arial (synonymous; sans serif) +
    • Times (serif) +
    • Symbol (symbolic) +
    • ZapfDingbats (symbolic) +
    +It is also possible to pass an empty string. In that case, the current family is retained. +
    +style +
    +Font style. Possible values are (case insensitive): +
      +
    • empty string: regular +
    • B: bold +
    • I: italic +
    • U: underline +
    +or any combination. The default value is regular. +Bold and italic styles do not apply to Symbol and ZapfDingbats. +
    +size +
    +Font size in points. +
    +The default value is the current size. If no size has been specified since the beginning of +the document, the value taken is 12. +
    +

    Example

    +
    + +//Times regular 12
    +$pdf->SetFont('Times');
    +//Arial bold 14
    +$pdf->SetFont('Arial','B',14);
    +//Removes bold
    +$pdf->SetFont('');
    +//Times bold, italic and underlined 14
    +$pdf->SetFont('Times','BIU'); +
    +

    +

    See also

    +AddFont(), +SetFontSize(), +Cell(), +MultiCell(), +Write(). +
    +
    + + + diff --git a/include/pdf/doc/setfontsize.htm b/include/pdf/doc/setfontsize.htm new file mode 100644 index 000000000..b05205d46 --- /dev/null +++ b/include/pdf/doc/setfontsize.htm @@ -0,0 +1,25 @@ + + + +SetFontSize + + + +

    SetFontSize

    +SetFontSize(float size) +

    Version

    +1.0 +

    Description

    +Defines the size of the current font. +

    Parameters

    +size +
    +The size (in points). +
    +

    See also

    +SetFont(). +
    +
    + + + diff --git a/include/pdf/doc/setkeywords.htm b/include/pdf/doc/setkeywords.htm new file mode 100644 index 000000000..118ef5a5f --- /dev/null +++ b/include/pdf/doc/setkeywords.htm @@ -0,0 +1,28 @@ + + + +SetKeywords + + + +

    SetKeywords

    +SetKeywords(string keywords) +

    Version

    +1.2 +

    Description

    +Associates keywords with the document, generally in the form 'keyword1 keyword2 ...'. +

    Parameters

    +keywords +
    +The list of keywords. +
    +

    See also

    +SetAuthor(), +SetCreator(), +SetSubject(), +SetTitle(). +
    +
    + + + diff --git a/include/pdf/doc/setleftmargin.htm b/include/pdf/doc/setleftmargin.htm new file mode 100644 index 000000000..fd26d87c0 --- /dev/null +++ b/include/pdf/doc/setleftmargin.htm @@ -0,0 +1,30 @@ + + + +SetLeftMargin + + + +

    SetLeftMargin

    +SetLeftMargin(float margin) +

    Version

    +1.4 +

    Description

    +Defines the left margin. The method can be called before creating the first page. +
    +If the current abscissa gets out of page, it is brought back to the margin. +

    Parameters

    +margin +
    +The margin. +
    +

    See also

    +SetTopMargin(), +SetRightMargin(), +SetAutoPageBreak(), +SetMargins(). +
    +
    + + + diff --git a/include/pdf/doc/setlinewidth.htm b/include/pdf/doc/setlinewidth.htm new file mode 100644 index 000000000..85aa8feb1 --- /dev/null +++ b/include/pdf/doc/setlinewidth.htm @@ -0,0 +1,29 @@ + + + +SetLineWidth + + + +

    SetLineWidth

    +SetLineWidth(float width) +

    Version

    +1.0 +

    Description

    +Defines the line width. By default, the value equals 0.2 mm. The method can be called before +the first page is created and the value is retained from page to page. +

    Parameters

    +width +
    +The width. +
    +

    See also

    +Line(), +Rect(), +Cell(), +MultiCell(). +
    +
    + + + diff --git a/include/pdf/doc/setlink.htm b/include/pdf/doc/setlink.htm new file mode 100644 index 000000000..86a163f61 --- /dev/null +++ b/include/pdf/doc/setlink.htm @@ -0,0 +1,34 @@ + + + +SetLink + + + +

    SetLink

    +SetLink(int link [, float y [, int page]]) +

    Version

    +1.5 +

    Description

    +Defines the page and position a link points to. +

    Parameters

    +link +
    +The link identifier returned by AddLink(). +
    +y +
    +Ordinate of target position; -1 indicates the current position. +The default value is 0 (top of page). +
    +page +
    +Number of target page; -1 indicates the current page. This is the default value. +
    +

    See also

    +AddLink(). +
    +
    + + + diff --git a/include/pdf/doc/setmargins.htm b/include/pdf/doc/setmargins.htm new file mode 100644 index 000000000..766718bbe --- /dev/null +++ b/include/pdf/doc/setmargins.htm @@ -0,0 +1,37 @@ + + + +SetMargins + + + +

    SetMargins

    +SetMargins(float left, float top [, float right]) +

    Version

    +1.0 +

    Description

    +Defines the left, top and right margins. By default, they equal 1 cm. Call this method to change +them. +

    Parameters

    +left +
    +Left margin. +
    +top +
    +Top margin. +
    +right +
    +Right margin. Default value is the left one. +
    +

    See also

    +SetLeftMargin(), +SetTopMargin(), +SetRightMargin(), +SetAutoPageBreak(). +
    +
    + + + diff --git a/include/pdf/doc/setrightmargin.htm b/include/pdf/doc/setrightmargin.htm new file mode 100644 index 000000000..ff3ee90bd --- /dev/null +++ b/include/pdf/doc/setrightmargin.htm @@ -0,0 +1,28 @@ + + + +SetRightMargin + + + +

    SetRightMargin

    +SetRightMargin(float margin) +

    Version

    +1.5 +

    Description

    +Defines the right margin. The method can be called before creating the first page. +

    Parameters

    +margin +
    +The margin. +
    +

    See also

    +SetLeftMargin(), +SetTopMargin(), +SetAutoPageBreak(), +SetMargins(). +
    +
    + + + diff --git a/include/pdf/doc/setsubject.htm b/include/pdf/doc/setsubject.htm new file mode 100644 index 000000000..5c95ae892 --- /dev/null +++ b/include/pdf/doc/setsubject.htm @@ -0,0 +1,28 @@ + + + +SetSubject + + + +

    SetSubject

    +SetSubject(string subject) +

    Version

    +1.2 +

    Description

    +Defines the subject of the document. +

    Parameters

    +subject +
    +The subject. +
    +

    See also

    +SetAuthor(), +SetCreator(), +SetKeywords(), +SetTitle(). +
    +
    + + + diff --git a/include/pdf/doc/settextcolor.htm b/include/pdf/doc/settextcolor.htm new file mode 100644 index 000000000..7e6e12cf8 --- /dev/null +++ b/include/pdf/doc/settextcolor.htm @@ -0,0 +1,40 @@ + + + +SetTextColor + + + +

    SetTextColor

    +SetTextColor(int r [, int g, int b]) +

    Version

    +1.3 +

    Description

    +Defines the color used for text. It can be expressed in RGB components or gray scale. The +method can be called before the first page is created and the value is retained from page to +page. +

    Parameters

    +r +
    +If g et b are given, red component; if not, indicates the gray level. +Value between 0 and 255. +
    +g +
    +Green component (between 0 and 255). +
    +b +
    +Blue component (between 0 and 255). +
    +

    See also

    +SetDrawColor(), +SetFillColor(), +Text(), +Cell(), +MultiCell(). +
    +
    + + + diff --git a/include/pdf/doc/settitle.htm b/include/pdf/doc/settitle.htm new file mode 100644 index 000000000..6da2faa5b --- /dev/null +++ b/include/pdf/doc/settitle.htm @@ -0,0 +1,28 @@ + + + +SetTitle + + + +

    SetTitle

    +SetTitle(string title) +

    Version

    +1.2 +

    Description

    +Defines the title of the document. +

    Parameters

    +title +
    +The title. +
    +

    See also

    +SetAuthor(), +SetCreator(), +SetKeywords(), +SetSubject(). +
    +
    + + + diff --git a/include/pdf/doc/settopmargin.htm b/include/pdf/doc/settopmargin.htm new file mode 100644 index 000000000..380de708b --- /dev/null +++ b/include/pdf/doc/settopmargin.htm @@ -0,0 +1,28 @@ + + + +SetTopMargin + + + +

    SetTopMargin

    +SetTopMargin(float margin) +

    Version

    +1.5 +

    Description

    +Defines the top margin. The method can be called before creating the first page. +

    Parameters

    +margin +
    +The margin. +
    +

    See also

    +SetLeftMargin(), +SetRightMargin(), +SetAutoPageBreak(), +SetMargins(). +
    +
    + + + diff --git a/include/pdf/doc/setx.htm b/include/pdf/doc/setx.htm new file mode 100644 index 000000000..96b8eedae --- /dev/null +++ b/include/pdf/doc/setx.htm @@ -0,0 +1,29 @@ + + + +SetX + + + +

    SetX

    +SetX(float x) +

    Version

    +1.2 +

    Description

    +Defines the abscissa of the current position. If the passed value is negative, it is relative +to the right of the page. +

    Parameters

    +x +
    +The value of the abscissa. +
    +

    See also

    +GetX(), +GetY(), +SetY(), +SetXY(). +
    +
    + + + diff --git a/include/pdf/doc/setxy.htm b/include/pdf/doc/setxy.htm new file mode 100644 index 000000000..fd6ec6435 --- /dev/null +++ b/include/pdf/doc/setxy.htm @@ -0,0 +1,31 @@ + + + +SetXY + + + +

    SetXY

    +SetXY(float x, float y) +

    Version

    +1.2 +

    Description

    +Defines the abscissa and ordinate of the current position. If the passed values are negative, +they are relative respectively to the right and bottom of the page. +

    Parameters

    +x +
    +The value of the abscissa. +
    +y +
    +The value of the ordinate. +
    +

    See also

    +SetX(), +SetY(). +
    +
    + + + diff --git a/include/pdf/doc/sety.htm b/include/pdf/doc/sety.htm new file mode 100644 index 000000000..9c3a321ad --- /dev/null +++ b/include/pdf/doc/sety.htm @@ -0,0 +1,29 @@ + + + +SetY + + + +

    SetY

    +SetY(float y) +

    Version

    +1.0 +

    Description

    +Moves the current abscissa back to the left margin and sets the ordinate. If the passed value +is negative, it is relative to the bottom of the page. +

    Parameters

    +y +
    +The value of the ordinate. +
    +

    See also

    +GetX(), +GetY(), +SetY(), +SetXY(). +
    +
    + + + diff --git a/include/pdf/doc/text.htm b/include/pdf/doc/text.htm new file mode 100644 index 000000000..af47881c1 --- /dev/null +++ b/include/pdf/doc/text.htm @@ -0,0 +1,39 @@ + + + +Text + + + +

    Text

    +Text(float x, float y, string txt) +

    Version

    +1.0 +

    Description

    +Prints a character string. The origin is on the left of the first charcter, on the baseline. +This method allows to place a string precisely on the page, but it is usually easier to use +Cell(), MultiCell() or Write() which are the standard methods to print text. +

    Parameters

    +x +
    +Abscissa of the origin. +
    +y +
    +Ordinate of the origin. +
    +txt +
    +String to print. +
    +

    See also

    +SetFont(), +SetTextColor(), +Cell(), +MultiCell(), +Write(). +
    +
    + + + diff --git a/include/pdf/doc/write.htm b/include/pdf/doc/write.htm new file mode 100644 index 000000000..e33c39c17 --- /dev/null +++ b/include/pdf/doc/write.htm @@ -0,0 +1,53 @@ + + + +Write + + + +

    Write

    +Write(float h, string txt [, mixed link]) +

    Version

    +1.5 +

    Description

    +This method prints text from the current position. When the right margin is reached (or the \n +character is met) a line break occurs and text continues from the left margin. Upon method exit, +the current position is left just at the end of the text. +
    +It is possible to put a link on the text. +

    Parameters

    +h +
    +Line height. +
    +txt +
    +String to print. +
    +link +
    +URL or identifier returned by AddLink(). +
    +

    Example

    +
    + +//Begin with regular font
    +$pdf->SetFont('Arial','',14);
    +$pdf->Write(5,'Visit ');
    +//Then put a blue underlined link
    +$pdf->SetTextColor(0,0,255);
    +$pdf->SetFont('','U');
    +$pdf->Write(5,'www.fpdf.org','http://www.fpdf.org'); +
    +

    +

    See also

    +SetFont(), +SetTextColor(), +AddLink(), +MultiCell(), +SetAutoPageBreak(). +
    +
    + + + diff --git a/include/pdf/font/courier.php b/include/pdf/font/courier.php new file mode 100644 index 000000000..913f9a453 --- /dev/null +++ b/include/pdf/font/courier.php @@ -0,0 +1,7 @@ + diff --git a/include/pdf/font/helvetica.php b/include/pdf/font/helvetica.php new file mode 100644 index 000000000..ca94cdf21 --- /dev/null +++ b/include/pdf/font/helvetica.php @@ -0,0 +1,15 @@ +278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278, + chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>278,'"'=>355,'#'=>556,'$'=>556,'%'=>889,'&'=>667,'\''=>191,'('=>333,')'=>333,'*'=>389,'+'=>584, + ','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>278,';'=>278,'<'=>584,'='=>584,'>'=>584,'?'=>556,'@'=>1015,'A'=>667, + 'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>500,'K'=>667,'L'=>556,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944, + 'X'=>667,'Y'=>667,'Z'=>611,'['=>278,'\\'=>278,']'=>278,'^'=>469,'_'=>556,'`'=>333,'a'=>556,'b'=>556,'c'=>500,'d'=>556,'e'=>556,'f'=>278,'g'=>556,'h'=>556,'i'=>222,'j'=>222,'k'=>500,'l'=>222,'m'=>833, + 'n'=>556,'o'=>556,'p'=>556,'q'=>556,'r'=>333,'s'=>500,'t'=>278,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>500,'{'=>334,'|'=>260,'}'=>334,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>222,chr(131)=>556, + chr(132)=>333,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>222,chr(146)=>222,chr(147)=>333,chr(148)=>333,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000, + chr(154)=>500,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>260,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333, + chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>556,chr(182)=>537,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667, + chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722, + chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>500,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>556,chr(241)=>556, + chr(242)=>556,chr(243)=>556,chr(244)=>556,chr(245)=>556,chr(246)=>556,chr(247)=>584,chr(248)=>611,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500); +?> diff --git a/include/pdf/font/helveticab.php b/include/pdf/font/helveticab.php new file mode 100644 index 000000000..276cfa8cb --- /dev/null +++ b/include/pdf/font/helveticab.php @@ -0,0 +1,15 @@ +278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278, + chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>333,'"'=>474,'#'=>556,'$'=>556,'%'=>889,'&'=>722,'\''=>238,'('=>333,')'=>333,'*'=>389,'+'=>584, + ','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>333,';'=>333,'<'=>584,'='=>584,'>'=>584,'?'=>611,'@'=>975,'A'=>722, + 'B'=>722,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>556,'K'=>722,'L'=>611,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944, + 'X'=>667,'Y'=>667,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>584,'_'=>556,'`'=>333,'a'=>556,'b'=>611,'c'=>556,'d'=>611,'e'=>556,'f'=>333,'g'=>611,'h'=>611,'i'=>278,'j'=>278,'k'=>556,'l'=>278,'m'=>889, + 'n'=>611,'o'=>611,'p'=>611,'q'=>611,'r'=>389,'s'=>556,'t'=>333,'u'=>611,'v'=>556,'w'=>778,'x'=>556,'y'=>556,'z'=>500,'{'=>389,'|'=>280,'}'=>389,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>278,chr(131)=>556, + chr(132)=>500,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>278,chr(146)=>278,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000, + chr(154)=>556,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>280,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333, + chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>611,chr(182)=>556,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722, + chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722, + chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>556,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>611,chr(241)=>611, + chr(242)=>611,chr(243)=>611,chr(244)=>611,chr(245)=>611,chr(246)=>611,chr(247)=>584,chr(248)=>611,chr(249)=>611,chr(250)=>611,chr(251)=>611,chr(252)=>611,chr(253)=>556,chr(254)=>611,chr(255)=>556); +?> diff --git a/include/pdf/font/helveticabi.php b/include/pdf/font/helveticabi.php new file mode 100644 index 000000000..8d2177432 --- /dev/null +++ b/include/pdf/font/helveticabi.php @@ -0,0 +1,15 @@ +278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278, + chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>333,'"'=>474,'#'=>556,'$'=>556,'%'=>889,'&'=>722,'\''=>238,'('=>333,')'=>333,'*'=>389,'+'=>584, + ','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>333,';'=>333,'<'=>584,'='=>584,'>'=>584,'?'=>611,'@'=>975,'A'=>722, + 'B'=>722,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>556,'K'=>722,'L'=>611,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944, + 'X'=>667,'Y'=>667,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>584,'_'=>556,'`'=>333,'a'=>556,'b'=>611,'c'=>556,'d'=>611,'e'=>556,'f'=>333,'g'=>611,'h'=>611,'i'=>278,'j'=>278,'k'=>556,'l'=>278,'m'=>889, + 'n'=>611,'o'=>611,'p'=>611,'q'=>611,'r'=>389,'s'=>556,'t'=>333,'u'=>611,'v'=>556,'w'=>778,'x'=>556,'y'=>556,'z'=>500,'{'=>389,'|'=>280,'}'=>389,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>278,chr(131)=>556, + chr(132)=>500,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>278,chr(146)=>278,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000, + chr(154)=>556,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>280,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333, + chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>611,chr(182)=>556,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722, + chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722, + chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>556,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>611,chr(241)=>611, + chr(242)=>611,chr(243)=>611,chr(244)=>611,chr(245)=>611,chr(246)=>611,chr(247)=>584,chr(248)=>611,chr(249)=>611,chr(250)=>611,chr(251)=>611,chr(252)=>611,chr(253)=>556,chr(254)=>611,chr(255)=>556); +?> diff --git a/include/pdf/font/helveticai.php b/include/pdf/font/helveticai.php new file mode 100644 index 000000000..88bf4371b --- /dev/null +++ b/include/pdf/font/helveticai.php @@ -0,0 +1,15 @@ +278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278, + chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>278,'"'=>355,'#'=>556,'$'=>556,'%'=>889,'&'=>667,'\''=>191,'('=>333,')'=>333,'*'=>389,'+'=>584, + ','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>278,';'=>278,'<'=>584,'='=>584,'>'=>584,'?'=>556,'@'=>1015,'A'=>667, + 'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>500,'K'=>667,'L'=>556,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944, + 'X'=>667,'Y'=>667,'Z'=>611,'['=>278,'\\'=>278,']'=>278,'^'=>469,'_'=>556,'`'=>333,'a'=>556,'b'=>556,'c'=>500,'d'=>556,'e'=>556,'f'=>278,'g'=>556,'h'=>556,'i'=>222,'j'=>222,'k'=>500,'l'=>222,'m'=>833, + 'n'=>556,'o'=>556,'p'=>556,'q'=>556,'r'=>333,'s'=>500,'t'=>278,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>500,'{'=>334,'|'=>260,'}'=>334,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>222,chr(131)=>556, + chr(132)=>333,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>222,chr(146)=>222,chr(147)=>333,chr(148)=>333,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000, + chr(154)=>500,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>260,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333, + chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>556,chr(182)=>537,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667, + chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722, + chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>500,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>556,chr(241)=>556, + chr(242)=>556,chr(243)=>556,chr(244)=>556,chr(245)=>556,chr(246)=>556,chr(247)=>584,chr(248)=>611,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500); +?> diff --git a/include/pdf/font/makefont/cp1250.map b/include/pdf/font/makefont/cp1250.map new file mode 100644 index 000000000..ec110af06 --- /dev/null +++ b/include/pdf/font/makefont/cp1250.map @@ -0,0 +1,251 @@ +!00 U+0000 .notdef +!01 U+0001 .notdef +!02 U+0002 .notdef +!03 U+0003 .notdef +!04 U+0004 .notdef +!05 U+0005 .notdef +!06 U+0006 .notdef +!07 U+0007 .notdef +!08 U+0008 .notdef +!09 U+0009 .notdef +!0A U+000A .notdef +!0B U+000B .notdef +!0C U+000C .notdef +!0D U+000D .notdef +!0E U+000E .notdef +!0F U+000F .notdef +!10 U+0010 .notdef +!11 U+0011 .notdef +!12 U+0012 .notdef +!13 U+0013 .notdef +!14 U+0014 .notdef +!15 U+0015 .notdef +!16 U+0016 .notdef +!17 U+0017 .notdef +!18 U+0018 .notdef +!19 U+0019 .notdef +!1A U+001A .notdef +!1B U+001B .notdef +!1C U+001C .notdef +!1D U+001D .notdef +!1E U+001E .notdef +!1F U+001F .notdef +!20 U+0020 space +!21 U+0021 exclam +!22 U+0022 quotedbl +!23 U+0023 numbersign +!24 U+0024 dollar +!25 U+0025 percent +!26 U+0026 ampersand +!27 U+0027 quotesingle +!28 U+0028 parenleft +!29 U+0029 parenright +!2A U+002A asterisk +!2B U+002B plus +!2C U+002C comma +!2D U+002D hyphen +!2E U+002E period +!2F U+002F slash +!30 U+0030 zero +!31 U+0031 one +!32 U+0032 two +!33 U+0033 three +!34 U+0034 four +!35 U+0035 five +!36 U+0036 six +!37 U+0037 seven +!38 U+0038 eight +!39 U+0039 nine +!3A U+003A colon +!3B U+003B semicolon +!3C U+003C less +!3D U+003D equal +!3E U+003E greater +!3F U+003F question +!40 U+0040 at +!41 U+0041 A +!42 U+0042 B +!43 U+0043 C +!44 U+0044 D +!45 U+0045 E +!46 U+0046 F +!47 U+0047 G +!48 U+0048 H +!49 U+0049 I +!4A U+004A J +!4B U+004B K +!4C U+004C L +!4D U+004D M +!4E U+004E N +!4F U+004F O +!50 U+0050 P +!51 U+0051 Q +!52 U+0052 R +!53 U+0053 S +!54 U+0054 T +!55 U+0055 U +!56 U+0056 V +!57 U+0057 W +!58 U+0058 X +!59 U+0059 Y +!5A U+005A Z +!5B U+005B bracketleft +!5C U+005C backslash +!5D U+005D bracketright +!5E U+005E asciicircum +!5F U+005F underscore +!60 U+0060 grave +!61 U+0061 a +!62 U+0062 b +!63 U+0063 c +!64 U+0064 d +!65 U+0065 e +!66 U+0066 f +!67 U+0067 g +!68 U+0068 h +!69 U+0069 i +!6A U+006A j +!6B U+006B k +!6C U+006C l +!6D U+006D m +!6E U+006E n +!6F U+006F o +!70 U+0070 p +!71 U+0071 q +!72 U+0072 r +!73 U+0073 s +!74 U+0074 t +!75 U+0075 u +!76 U+0076 v +!77 U+0077 w +!78 U+0078 x +!79 U+0079 y +!7A U+007A z +!7B U+007B braceleft +!7C U+007C bar +!7D U+007D braceright +!7E U+007E asciitilde +!7F U+007F .notdef +!80 U+20AC Euro +!82 U+201A quotesinglbase +!84 U+201E quotedblbase +!85 U+2026 ellipsis +!86 U+2020 dagger +!87 U+2021 daggerdbl +!89 U+2030 perthousand +!8A U+0160 Scaron +!8B U+2039 guilsinglleft +!8C U+015A Sacute +!8D U+0164 Tcaron +!8E U+017D Zcaron +!8F U+0179 Zacute +!91 U+2018 quoteleft +!92 U+2019 quoteright +!93 U+201C quotedblleft +!94 U+201D quotedblright +!95 U+2022 bullet +!96 U+2013 endash +!97 U+2014 emdash +!99 U+2122 trademark +!9A U+0161 scaron +!9B U+203A guilsinglright +!9C U+015B sacute +!9D U+0165 tcaron +!9E U+017E zcaron +!9F U+017A zacute +!A0 U+00A0 space +!A1 U+02C7 caron +!A2 U+02D8 breve +!A3 U+0141 Lslash +!A4 U+00A4 currency +!A5 U+0104 Aogonek +!A6 U+00A6 brokenbar +!A7 U+00A7 section +!A8 U+00A8 dieresis +!A9 U+00A9 copyright +!AA U+015E Scedilla +!AB U+00AB guillemotleft +!AC U+00AC logicalnot +!AD U+00AD hyphen +!AE U+00AE registered +!AF U+017B Zdotaccent +!B0 U+00B0 degree +!B1 U+00B1 plusminus +!B2 U+02DB ogonek +!B3 U+0142 lslash +!B4 U+00B4 acute +!B5 U+00B5 mu +!B6 U+00B6 paragraph +!B7 U+00B7 periodcentered +!B8 U+00B8 cedilla +!B9 U+0105 aogonek +!BA U+015F scedilla +!BB U+00BB guillemotright +!BC U+013D Lcaron +!BD U+02DD hungarumlaut +!BE U+013E lcaron +!BF U+017C zdotaccent +!C0 U+0154 Racute +!C1 U+00C1 Aacute +!C2 U+00C2 Acircumflex +!C3 U+0102 Abreve +!C4 U+00C4 Adieresis +!C5 U+0139 Lacute +!C6 U+0106 Cacute +!C7 U+00C7 Ccedilla +!C8 U+010C Ccaron +!C9 U+00C9 Eacute +!CA U+0118 Eogonek +!CB U+00CB Edieresis +!CC U+011A Ecaron +!CD U+00CD Iacute +!CE U+00CE Icircumflex +!CF U+010E Dcaron +!D0 U+0110 Dcroat +!D1 U+0143 Nacute +!D2 U+0147 Ncaron +!D3 U+00D3 Oacute +!D4 U+00D4 Ocircumflex +!D5 U+0150 Ohungarumlaut +!D6 U+00D6 Odieresis +!D7 U+00D7 multiply +!D8 U+0158 Rcaron +!D9 U+016E Uring +!DA U+00DA Uacute +!DB U+0170 Uhungarumlaut +!DC U+00DC Udieresis +!DD U+00DD Yacute +!DE U+0162 Tcommaaccent +!DF U+00DF germandbls +!E0 U+0155 racute +!E1 U+00E1 aacute +!E2 U+00E2 acircumflex +!E3 U+0103 abreve +!E4 U+00E4 adieresis +!E5 U+013A lacute +!E6 U+0107 cacute +!E7 U+00E7 ccedilla +!E8 U+010D ccaron +!E9 U+00E9 eacute +!EA U+0119 eogonek +!EB U+00EB edieresis +!EC U+011B ecaron +!ED U+00ED iacute +!EE U+00EE icircumflex +!EF U+010F dcaron +!F0 U+0111 dcroat +!F1 U+0144 nacute +!F2 U+0148 ncaron +!F3 U+00F3 oacute +!F4 U+00F4 ocircumflex +!F5 U+0151 ohungarumlaut +!F6 U+00F6 odieresis +!F7 U+00F7 divide +!F8 U+0159 rcaron +!F9 U+016F uring +!FA U+00FA uacute +!FB U+0171 uhungarumlaut +!FC U+00FC udieresis +!FD U+00FD yacute +!FE U+0163 tcommaaccent +!FF U+02D9 dotaccent diff --git a/include/pdf/font/makefont/cp1251.map b/include/pdf/font/makefont/cp1251.map new file mode 100644 index 000000000..de6a198d9 --- /dev/null +++ b/include/pdf/font/makefont/cp1251.map @@ -0,0 +1,255 @@ +!00 U+0000 .notdef +!01 U+0001 .notdef +!02 U+0002 .notdef +!03 U+0003 .notdef +!04 U+0004 .notdef +!05 U+0005 .notdef +!06 U+0006 .notdef +!07 U+0007 .notdef +!08 U+0008 .notdef +!09 U+0009 .notdef +!0A U+000A .notdef +!0B U+000B .notdef +!0C U+000C .notdef +!0D U+000D .notdef +!0E U+000E .notdef +!0F U+000F .notdef +!10 U+0010 .notdef +!11 U+0011 .notdef +!12 U+0012 .notdef +!13 U+0013 .notdef +!14 U+0014 .notdef +!15 U+0015 .notdef +!16 U+0016 .notdef +!17 U+0017 .notdef +!18 U+0018 .notdef +!19 U+0019 .notdef +!1A U+001A .notdef +!1B U+001B .notdef +!1C U+001C .notdef +!1D U+001D .notdef +!1E U+001E .notdef +!1F U+001F .notdef +!20 U+0020 space +!21 U+0021 exclam +!22 U+0022 quotedbl +!23 U+0023 numbersign +!24 U+0024 dollar +!25 U+0025 percent +!26 U+0026 ampersand +!27 U+0027 quotesingle +!28 U+0028 parenleft +!29 U+0029 parenright +!2A U+002A asterisk +!2B U+002B plus +!2C U+002C comma +!2D U+002D hyphen +!2E U+002E period +!2F U+002F slash +!30 U+0030 zero +!31 U+0031 one +!32 U+0032 two +!33 U+0033 three +!34 U+0034 four +!35 U+0035 five +!36 U+0036 six +!37 U+0037 seven +!38 U+0038 eight +!39 U+0039 nine +!3A U+003A colon +!3B U+003B semicolon +!3C U+003C less +!3D U+003D equal +!3E U+003E greater +!3F U+003F question +!40 U+0040 at +!41 U+0041 A +!42 U+0042 B +!43 U+0043 C +!44 U+0044 D +!45 U+0045 E +!46 U+0046 F +!47 U+0047 G +!48 U+0048 H +!49 U+0049 I +!4A U+004A J +!4B U+004B K +!4C U+004C L +!4D U+004D M +!4E U+004E N +!4F U+004F O +!50 U+0050 P +!51 U+0051 Q +!52 U+0052 R +!53 U+0053 S +!54 U+0054 T +!55 U+0055 U +!56 U+0056 V +!57 U+0057 W +!58 U+0058 X +!59 U+0059 Y +!5A U+005A Z +!5B U+005B bracketleft +!5C U+005C backslash +!5D U+005D bracketright +!5E U+005E asciicircum +!5F U+005F underscore +!60 U+0060 grave +!61 U+0061 a +!62 U+0062 b +!63 U+0063 c +!64 U+0064 d +!65 U+0065 e +!66 U+0066 f +!67 U+0067 g +!68 U+0068 h +!69 U+0069 i +!6A U+006A j +!6B U+006B k +!6C U+006C l +!6D U+006D m +!6E U+006E n +!6F U+006F o +!70 U+0070 p +!71 U+0071 q +!72 U+0072 r +!73 U+0073 s +!74 U+0074 t +!75 U+0075 u +!76 U+0076 v +!77 U+0077 w +!78 U+0078 x +!79 U+0079 y +!7A U+007A z +!7B U+007B braceleft +!7C U+007C bar +!7D U+007D braceright +!7E U+007E asciitilde +!7F U+007F .notdef +!80 U+0402 afii10051 +!81 U+0403 afii10052 +!82 U+201A quotesinglbase +!83 U+0453 afii10100 +!84 U+201E quotedblbase +!85 U+2026 ellipsis +!86 U+2020 dagger +!87 U+2021 daggerdbl +!88 U+20AC Euro +!89 U+2030 perthousand +!8A U+0409 afii10058 +!8B U+2039 guilsinglleft +!8C U+040A afii10059 +!8D U+040C afii10061 +!8E U+040B afii10060 +!8F U+040F afii10145 +!90 U+0452 afii10099 +!91 U+2018 quoteleft +!92 U+2019 quoteright +!93 U+201C quotedblleft +!94 U+201D quotedblright +!95 U+2022 bullet +!96 U+2013 endash +!97 U+2014 emdash +!99 U+2122 trademark +!9A U+0459 afii10106 +!9B U+203A guilsinglright +!9C U+045A afii10107 +!9D U+045C afii10109 +!9E U+045B afii10108 +!9F U+045F afii10193 +!A0 U+00A0 space +!A1 U+040E afii10062 +!A2 U+045E afii10110 +!A3 U+0408 afii10057 +!A4 U+00A4 currency +!A5 U+0490 afii10050 +!A6 U+00A6 brokenbar +!A7 U+00A7 section +!A8 U+0401 afii10023 +!A9 U+00A9 copyright +!AA U+0404 afii10053 +!AB U+00AB guillemotleft +!AC U+00AC logicalnot +!AD U+00AD hyphen +!AE U+00AE registered +!AF U+0407 afii10056 +!B0 U+00B0 degree +!B1 U+00B1 plusminus +!B2 U+0406 afii10055 +!B3 U+0456 afii10103 +!B4 U+0491 afii10098 +!B5 U+00B5 mu +!B6 U+00B6 paragraph +!B7 U+00B7 periodcentered +!B8 U+0451 afii10071 +!B9 U+2116 afii61352 +!BA U+0454 afii10101 +!BB U+00BB guillemotright +!BC U+0458 afii10105 +!BD U+0405 afii10054 +!BE U+0455 afii10102 +!BF U+0457 afii10104 +!C0 U+0410 afii10017 +!C1 U+0411 afii10018 +!C2 U+0412 afii10019 +!C3 U+0413 afii10020 +!C4 U+0414 afii10021 +!C5 U+0415 afii10022 +!C6 U+0416 afii10024 +!C7 U+0417 afii10025 +!C8 U+0418 afii10026 +!C9 U+0419 afii10027 +!CA U+041A afii10028 +!CB U+041B afii10029 +!CC U+041C afii10030 +!CD U+041D afii10031 +!CE U+041E afii10032 +!CF U+041F afii10033 +!D0 U+0420 afii10034 +!D1 U+0421 afii10035 +!D2 U+0422 afii10036 +!D3 U+0423 afii10037 +!D4 U+0424 afii10038 +!D5 U+0425 afii10039 +!D6 U+0426 afii10040 +!D7 U+0427 afii10041 +!D8 U+0428 afii10042 +!D9 U+0429 afii10043 +!DA U+042A afii10044 +!DB U+042B afii10045 +!DC U+042C afii10046 +!DD U+042D afii10047 +!DE U+042E afii10048 +!DF U+042F afii10049 +!E0 U+0430 afii10065 +!E1 U+0431 afii10066 +!E2 U+0432 afii10067 +!E3 U+0433 afii10068 +!E4 U+0434 afii10069 +!E5 U+0435 afii10070 +!E6 U+0436 afii10072 +!E7 U+0437 afii10073 +!E8 U+0438 afii10074 +!E9 U+0439 afii10075 +!EA U+043A afii10076 +!EB U+043B afii10077 +!EC U+043C afii10078 +!ED U+043D afii10079 +!EE U+043E afii10080 +!EF U+043F afii10081 +!F0 U+0440 afii10082 +!F1 U+0441 afii10083 +!F2 U+0442 afii10084 +!F3 U+0443 afii10085 +!F4 U+0444 afii10086 +!F5 U+0445 afii10087 +!F6 U+0446 afii10088 +!F7 U+0447 afii10089 +!F8 U+0448 afii10090 +!F9 U+0449 afii10091 +!FA U+044A afii10092 +!FB U+044B afii10093 +!FC U+044C afii10094 +!FD U+044D afii10095 +!FE U+044E afii10096 +!FF U+044F afii10097 diff --git a/include/pdf/font/makefont/cp1252.map b/include/pdf/font/makefont/cp1252.map new file mode 100644 index 000000000..dd490e596 --- /dev/null +++ b/include/pdf/font/makefont/cp1252.map @@ -0,0 +1,251 @@ +!00 U+0000 .notdef +!01 U+0001 .notdef +!02 U+0002 .notdef +!03 U+0003 .notdef +!04 U+0004 .notdef +!05 U+0005 .notdef +!06 U+0006 .notdef +!07 U+0007 .notdef +!08 U+0008 .notdef +!09 U+0009 .notdef +!0A U+000A .notdef +!0B U+000B .notdef +!0C U+000C .notdef +!0D U+000D .notdef +!0E U+000E .notdef +!0F U+000F .notdef +!10 U+0010 .notdef +!11 U+0011 .notdef +!12 U+0012 .notdef +!13 U+0013 .notdef +!14 U+0014 .notdef +!15 U+0015 .notdef +!16 U+0016 .notdef +!17 U+0017 .notdef +!18 U+0018 .notdef +!19 U+0019 .notdef +!1A U+001A .notdef +!1B U+001B .notdef +!1C U+001C .notdef +!1D U+001D .notdef +!1E U+001E .notdef +!1F U+001F .notdef +!20 U+0020 space +!21 U+0021 exclam +!22 U+0022 quotedbl +!23 U+0023 numbersign +!24 U+0024 dollar +!25 U+0025 percent +!26 U+0026 ampersand +!27 U+0027 quotesingle +!28 U+0028 parenleft +!29 U+0029 parenright +!2A U+002A asterisk +!2B U+002B plus +!2C U+002C comma +!2D U+002D hyphen +!2E U+002E period +!2F U+002F slash +!30 U+0030 zero +!31 U+0031 one +!32 U+0032 two +!33 U+0033 three +!34 U+0034 four +!35 U+0035 five +!36 U+0036 six +!37 U+0037 seven +!38 U+0038 eight +!39 U+0039 nine +!3A U+003A colon +!3B U+003B semicolon +!3C U+003C less +!3D U+003D equal +!3E U+003E greater +!3F U+003F question +!40 U+0040 at +!41 U+0041 A +!42 U+0042 B +!43 U+0043 C +!44 U+0044 D +!45 U+0045 E +!46 U+0046 F +!47 U+0047 G +!48 U+0048 H +!49 U+0049 I +!4A U+004A J +!4B U+004B K +!4C U+004C L +!4D U+004D M +!4E U+004E N +!4F U+004F O +!50 U+0050 P +!51 U+0051 Q +!52 U+0052 R +!53 U+0053 S +!54 U+0054 T +!55 U+0055 U +!56 U+0056 V +!57 U+0057 W +!58 U+0058 X +!59 U+0059 Y +!5A U+005A Z +!5B U+005B bracketleft +!5C U+005C backslash +!5D U+005D bracketright +!5E U+005E asciicircum +!5F U+005F underscore +!60 U+0060 grave +!61 U+0061 a +!62 U+0062 b +!63 U+0063 c +!64 U+0064 d +!65 U+0065 e +!66 U+0066 f +!67 U+0067 g +!68 U+0068 h +!69 U+0069 i +!6A U+006A j +!6B U+006B k +!6C U+006C l +!6D U+006D m +!6E U+006E n +!6F U+006F o +!70 U+0070 p +!71 U+0071 q +!72 U+0072 r +!73 U+0073 s +!74 U+0074 t +!75 U+0075 u +!76 U+0076 v +!77 U+0077 w +!78 U+0078 x +!79 U+0079 y +!7A U+007A z +!7B U+007B braceleft +!7C U+007C bar +!7D U+007D braceright +!7E U+007E asciitilde +!7F U+007F .notdef +!80 U+20AC Euro +!82 U+201A quotesinglbase +!83 U+0192 florin +!84 U+201E quotedblbase +!85 U+2026 ellipsis +!86 U+2020 dagger +!87 U+2021 daggerdbl +!88 U+02C6 circumflex +!89 U+2030 perthousand +!8A U+0160 Scaron +!8B U+2039 guilsinglleft +!8C U+0152 OE +!8E U+017D Zcaron +!91 U+2018 quoteleft +!92 U+2019 quoteright +!93 U+201C quotedblleft +!94 U+201D quotedblright +!95 U+2022 bullet +!96 U+2013 endash +!97 U+2014 emdash +!98 U+02DC tilde +!99 U+2122 trademark +!9A U+0161 scaron +!9B U+203A guilsinglright +!9C U+0153 oe +!9E U+017E zcaron +!9F U+0178 Ydieresis +!A0 U+00A0 space +!A1 U+00A1 exclamdown +!A2 U+00A2 cent +!A3 U+00A3 sterling +!A4 U+00A4 currency +!A5 U+00A5 yen +!A6 U+00A6 brokenbar +!A7 U+00A7 section +!A8 U+00A8 dieresis +!A9 U+00A9 copyright +!AA U+00AA ordfeminine +!AB U+00AB guillemotleft +!AC U+00AC logicalnot +!AD U+00AD hyphen +!AE U+00AE registered +!AF U+00AF macron +!B0 U+00B0 degree +!B1 U+00B1 plusminus +!B2 U+00B2 twosuperior +!B3 U+00B3 threesuperior +!B4 U+00B4 acute +!B5 U+00B5 mu +!B6 U+00B6 paragraph +!B7 U+00B7 periodcentered +!B8 U+00B8 cedilla +!B9 U+00B9 onesuperior +!BA U+00BA ordmasculine +!BB U+00BB guillemotright +!BC U+00BC onequarter +!BD U+00BD onehalf +!BE U+00BE threequarters +!BF U+00BF questiondown +!C0 U+00C0 Agrave +!C1 U+00C1 Aacute +!C2 U+00C2 Acircumflex +!C3 U+00C3 Atilde +!C4 U+00C4 Adieresis +!C5 U+00C5 Aring +!C6 U+00C6 AE +!C7 U+00C7 Ccedilla +!C8 U+00C8 Egrave +!C9 U+00C9 Eacute +!CA U+00CA Ecircumflex +!CB U+00CB Edieresis +!CC U+00CC Igrave +!CD U+00CD Iacute +!CE U+00CE Icircumflex +!CF U+00CF Idieresis +!D0 U+00D0 Eth +!D1 U+00D1 Ntilde +!D2 U+00D2 Ograve +!D3 U+00D3 Oacute +!D4 U+00D4 Ocircumflex +!D5 U+00D5 Otilde +!D6 U+00D6 Odieresis +!D7 U+00D7 multiply +!D8 U+00D8 Oslash +!D9 U+00D9 Ugrave +!DA U+00DA Uacute +!DB U+00DB Ucircumflex +!DC U+00DC Udieresis +!DD U+00DD Yacute +!DE U+00DE Thorn +!DF U+00DF germandbls +!E0 U+00E0 agrave +!E1 U+00E1 aacute +!E2 U+00E2 acircumflex +!E3 U+00E3 atilde +!E4 U+00E4 adieresis +!E5 U+00E5 aring +!E6 U+00E6 ae +!E7 U+00E7 ccedilla +!E8 U+00E8 egrave +!E9 U+00E9 eacute +!EA U+00EA ecircumflex +!EB U+00EB edieresis +!EC U+00EC igrave +!ED U+00ED iacute +!EE U+00EE icircumflex +!EF U+00EF idieresis +!F0 U+00F0 eth +!F1 U+00F1 ntilde +!F2 U+00F2 ograve +!F3 U+00F3 oacute +!F4 U+00F4 ocircumflex +!F5 U+00F5 otilde +!F6 U+00F6 odieresis +!F7 U+00F7 divide +!F8 U+00F8 oslash +!F9 U+00F9 ugrave +!FA U+00FA uacute +!FB U+00FB ucircumflex +!FC U+00FC udieresis +!FD U+00FD yacute +!FE U+00FE thorn +!FF U+00FF ydieresis diff --git a/include/pdf/font/makefont/cp1253.map b/include/pdf/font/makefont/cp1253.map new file mode 100644 index 000000000..4bd826fb2 --- /dev/null +++ b/include/pdf/font/makefont/cp1253.map @@ -0,0 +1,239 @@ +!00 U+0000 .notdef +!01 U+0001 .notdef +!02 U+0002 .notdef +!03 U+0003 .notdef +!04 U+0004 .notdef +!05 U+0005 .notdef +!06 U+0006 .notdef +!07 U+0007 .notdef +!08 U+0008 .notdef +!09 U+0009 .notdef +!0A U+000A .notdef +!0B U+000B .notdef +!0C U+000C .notdef +!0D U+000D .notdef +!0E U+000E .notdef +!0F U+000F .notdef +!10 U+0010 .notdef +!11 U+0011 .notdef +!12 U+0012 .notdef +!13 U+0013 .notdef +!14 U+0014 .notdef +!15 U+0015 .notdef +!16 U+0016 .notdef +!17 U+0017 .notdef +!18 U+0018 .notdef +!19 U+0019 .notdef +!1A U+001A .notdef +!1B U+001B .notdef +!1C U+001C .notdef +!1D U+001D .notdef +!1E U+001E .notdef +!1F U+001F .notdef +!20 U+0020 space +!21 U+0021 exclam +!22 U+0022 quotedbl +!23 U+0023 numbersign +!24 U+0024 dollar +!25 U+0025 percent +!26 U+0026 ampersand +!27 U+0027 quotesingle +!28 U+0028 parenleft +!29 U+0029 parenright +!2A U+002A asterisk +!2B U+002B plus +!2C U+002C comma +!2D U+002D hyphen +!2E U+002E period +!2F U+002F slash +!30 U+0030 zero +!31 U+0031 one +!32 U+0032 two +!33 U+0033 three +!34 U+0034 four +!35 U+0035 five +!36 U+0036 six +!37 U+0037 seven +!38 U+0038 eight +!39 U+0039 nine +!3A U+003A colon +!3B U+003B semicolon +!3C U+003C less +!3D U+003D equal +!3E U+003E greater +!3F U+003F question +!40 U+0040 at +!41 U+0041 A +!42 U+0042 B +!43 U+0043 C +!44 U+0044 D +!45 U+0045 E +!46 U+0046 F +!47 U+0047 G +!48 U+0048 H +!49 U+0049 I +!4A U+004A J +!4B U+004B K +!4C U+004C L +!4D U+004D M +!4E U+004E N +!4F U+004F O +!50 U+0050 P +!51 U+0051 Q +!52 U+0052 R +!53 U+0053 S +!54 U+0054 T +!55 U+0055 U +!56 U+0056 V +!57 U+0057 W +!58 U+0058 X +!59 U+0059 Y +!5A U+005A Z +!5B U+005B bracketleft +!5C U+005C backslash +!5D U+005D bracketright +!5E U+005E asciicircum +!5F U+005F underscore +!60 U+0060 grave +!61 U+0061 a +!62 U+0062 b +!63 U+0063 c +!64 U+0064 d +!65 U+0065 e +!66 U+0066 f +!67 U+0067 g +!68 U+0068 h +!69 U+0069 i +!6A U+006A j +!6B U+006B k +!6C U+006C l +!6D U+006D m +!6E U+006E n +!6F U+006F o +!70 U+0070 p +!71 U+0071 q +!72 U+0072 r +!73 U+0073 s +!74 U+0074 t +!75 U+0075 u +!76 U+0076 v +!77 U+0077 w +!78 U+0078 x +!79 U+0079 y +!7A U+007A z +!7B U+007B braceleft +!7C U+007C bar +!7D U+007D braceright +!7E U+007E asciitilde +!7F U+007F .notdef +!80 U+20AC Euro +!82 U+201A quotesinglbase +!83 U+0192 florin +!84 U+201E quotedblbase +!85 U+2026 ellipsis +!86 U+2020 dagger +!87 U+2021 daggerdbl +!89 U+2030 perthousand +!8B U+2039 guilsinglleft +!91 U+2018 quoteleft +!92 U+2019 quoteright +!93 U+201C quotedblleft +!94 U+201D quotedblright +!95 U+2022 bullet +!96 U+2013 endash +!97 U+2014 emdash +!99 U+2122 trademark +!9B U+203A guilsinglright +!A0 U+00A0 space +!A1 U+0385 dieresistonos +!A2 U+0386 Alphatonos +!A3 U+00A3 sterling +!A4 U+00A4 currency +!A5 U+00A5 yen +!A6 U+00A6 brokenbar +!A7 U+00A7 section +!A8 U+00A8 dieresis +!A9 U+00A9 copyright +!AB U+00AB guillemotleft +!AC U+00AC logicalnot +!AD U+00AD hyphen +!AE U+00AE registered +!AF U+2015 afii00208 +!B0 U+00B0 degree +!B1 U+00B1 plusminus +!B2 U+00B2 twosuperior +!B3 U+00B3 threesuperior +!B4 U+0384 tonos +!B5 U+00B5 mu +!B6 U+00B6 paragraph +!B7 U+00B7 periodcentered +!B8 U+0388 Epsilontonos +!B9 U+0389 Etatonos +!BA U+038A Iotatonos +!BB U+00BB guillemotright +!BC U+038C Omicrontonos +!BD U+00BD onehalf +!BE U+038E Upsilontonos +!BF U+038F Omegatonos +!C0 U+0390 iotadieresistonos +!C1 U+0391 Alpha +!C2 U+0392 Beta +!C3 U+0393 Gamma +!C4 U+0394 Delta +!C5 U+0395 Epsilon +!C6 U+0396 Zeta +!C7 U+0397 Eta +!C8 U+0398 Theta +!C9 U+0399 Iota +!CA U+039A Kappa +!CB U+039B Lambda +!CC U+039C Mu +!CD U+039D Nu +!CE U+039E Xi +!CF U+039F Omicron +!D0 U+03A0 Pi +!D1 U+03A1 Rho +!D3 U+03A3 Sigma +!D4 U+03A4 Tau +!D5 U+03A5 Upsilon +!D6 U+03A6 Phi +!D7 U+03A7 Chi +!D8 U+03A8 Psi +!D9 U+03A9 Omega +!DA U+03AA Iotadieresis +!DB U+03AB Upsilondieresis +!DC U+03AC alphatonos +!DD U+03AD epsilontonos +!DE U+03AE etatonos +!DF U+03AF iotatonos +!E0 U+03B0 upsilondieresistonos +!E1 U+03B1 alpha +!E2 U+03B2 beta +!E3 U+03B3 gamma +!E4 U+03B4 delta +!E5 U+03B5 epsilon +!E6 U+03B6 zeta +!E7 U+03B7 eta +!E8 U+03B8 theta +!E9 U+03B9 iota +!EA U+03BA kappa +!EB U+03BB lambda +!EC U+03BC mu +!ED U+03BD nu +!EE U+03BE xi +!EF U+03BF omicron +!F0 U+03C0 pi +!F1 U+03C1 rho +!F2 U+03C2 sigma1 +!F3 U+03C3 sigma +!F4 U+03C4 tau +!F5 U+03C5 upsilon +!F6 U+03C6 phi +!F7 U+03C7 chi +!F8 U+03C8 psi +!F9 U+03C9 omega +!FA U+03CA iotadieresis +!FB U+03CB upsilondieresis +!FC U+03CC omicrontonos +!FD U+03CD upsilontonos +!FE U+03CE omegatonos diff --git a/include/pdf/font/makefont/cp1254.map b/include/pdf/font/makefont/cp1254.map new file mode 100644 index 000000000..829473b28 --- /dev/null +++ b/include/pdf/font/makefont/cp1254.map @@ -0,0 +1,249 @@ +!00 U+0000 .notdef +!01 U+0001 .notdef +!02 U+0002 .notdef +!03 U+0003 .notdef +!04 U+0004 .notdef +!05 U+0005 .notdef +!06 U+0006 .notdef +!07 U+0007 .notdef +!08 U+0008 .notdef +!09 U+0009 .notdef +!0A U+000A .notdef +!0B U+000B .notdef +!0C U+000C .notdef +!0D U+000D .notdef +!0E U+000E .notdef +!0F U+000F .notdef +!10 U+0010 .notdef +!11 U+0011 .notdef +!12 U+0012 .notdef +!13 U+0013 .notdef +!14 U+0014 .notdef +!15 U+0015 .notdef +!16 U+0016 .notdef +!17 U+0017 .notdef +!18 U+0018 .notdef +!19 U+0019 .notdef +!1A U+001A .notdef +!1B U+001B .notdef +!1C U+001C .notdef +!1D U+001D .notdef +!1E U+001E .notdef +!1F U+001F .notdef +!20 U+0020 space +!21 U+0021 exclam +!22 U+0022 quotedbl +!23 U+0023 numbersign +!24 U+0024 dollar +!25 U+0025 percent +!26 U+0026 ampersand +!27 U+0027 quotesingle +!28 U+0028 parenleft +!29 U+0029 parenright +!2A U+002A asterisk +!2B U+002B plus +!2C U+002C comma +!2D U+002D hyphen +!2E U+002E period +!2F U+002F slash +!30 U+0030 zero +!31 U+0031 one +!32 U+0032 two +!33 U+0033 three +!34 U+0034 four +!35 U+0035 five +!36 U+0036 six +!37 U+0037 seven +!38 U+0038 eight +!39 U+0039 nine +!3A U+003A colon +!3B U+003B semicolon +!3C U+003C less +!3D U+003D equal +!3E U+003E greater +!3F U+003F question +!40 U+0040 at +!41 U+0041 A +!42 U+0042 B +!43 U+0043 C +!44 U+0044 D +!45 U+0045 E +!46 U+0046 F +!47 U+0047 G +!48 U+0048 H +!49 U+0049 I +!4A U+004A J +!4B U+004B K +!4C U+004C L +!4D U+004D M +!4E U+004E N +!4F U+004F O +!50 U+0050 P +!51 U+0051 Q +!52 U+0052 R +!53 U+0053 S +!54 U+0054 T +!55 U+0055 U +!56 U+0056 V +!57 U+0057 W +!58 U+0058 X +!59 U+0059 Y +!5A U+005A Z +!5B U+005B bracketleft +!5C U+005C backslash +!5D U+005D bracketright +!5E U+005E asciicircum +!5F U+005F underscore +!60 U+0060 grave +!61 U+0061 a +!62 U+0062 b +!63 U+0063 c +!64 U+0064 d +!65 U+0065 e +!66 U+0066 f +!67 U+0067 g +!68 U+0068 h +!69 U+0069 i +!6A U+006A j +!6B U+006B k +!6C U+006C l +!6D U+006D m +!6E U+006E n +!6F U+006F o +!70 U+0070 p +!71 U+0071 q +!72 U+0072 r +!73 U+0073 s +!74 U+0074 t +!75 U+0075 u +!76 U+0076 v +!77 U+0077 w +!78 U+0078 x +!79 U+0079 y +!7A U+007A z +!7B U+007B braceleft +!7C U+007C bar +!7D U+007D braceright +!7E U+007E asciitilde +!7F U+007F .notdef +!80 U+20AC Euro +!82 U+201A quotesinglbase +!83 U+0192 florin +!84 U+201E quotedblbase +!85 U+2026 ellipsis +!86 U+2020 dagger +!87 U+2021 daggerdbl +!88 U+02C6 circumflex +!89 U+2030 perthousand +!8A U+0160 Scaron +!8B U+2039 guilsinglleft +!8C U+0152 OE +!91 U+2018 quoteleft +!92 U+2019 quoteright +!93 U+201C quotedblleft +!94 U+201D quotedblright +!95 U+2022 bullet +!96 U+2013 endash +!97 U+2014 emdash +!98 U+02DC tilde +!99 U+2122 trademark +!9A U+0161 scaron +!9B U+203A guilsinglright +!9C U+0153 oe +!9F U+0178 Ydieresis +!A0 U+00A0 space +!A1 U+00A1 exclamdown +!A2 U+00A2 cent +!A3 U+00A3 sterling +!A4 U+00A4 currency +!A5 U+00A5 yen +!A6 U+00A6 brokenbar +!A7 U+00A7 section +!A8 U+00A8 dieresis +!A9 U+00A9 copyright +!AA U+00AA ordfeminine +!AB U+00AB guillemotleft +!AC U+00AC logicalnot +!AD U+00AD hyphen +!AE U+00AE registered +!AF U+00AF macron +!B0 U+00B0 degree +!B1 U+00B1 plusminus +!B2 U+00B2 twosuperior +!B3 U+00B3 threesuperior +!B4 U+00B4 acute +!B5 U+00B5 mu +!B6 U+00B6 paragraph +!B7 U+00B7 periodcentered +!B8 U+00B8 cedilla +!B9 U+00B9 onesuperior +!BA U+00BA ordmasculine +!BB U+00BB guillemotright +!BC U+00BC onequarter +!BD U+00BD onehalf +!BE U+00BE threequarters +!BF U+00BF questiondown +!C0 U+00C0 Agrave +!C1 U+00C1 Aacute +!C2 U+00C2 Acircumflex +!C3 U+00C3 Atilde +!C4 U+00C4 Adieresis +!C5 U+00C5 Aring +!C6 U+00C6 AE +!C7 U+00C7 Ccedilla +!C8 U+00C8 Egrave +!C9 U+00C9 Eacute +!CA U+00CA Ecircumflex +!CB U+00CB Edieresis +!CC U+00CC Igrave +!CD U+00CD Iacute +!CE U+00CE Icircumflex +!CF U+00CF Idieresis +!D0 U+011E Gbreve +!D1 U+00D1 Ntilde +!D2 U+00D2 Ograve +!D3 U+00D3 Oacute +!D4 U+00D4 Ocircumflex +!D5 U+00D5 Otilde +!D6 U+00D6 Odieresis +!D7 U+00D7 multiply +!D8 U+00D8 Oslash +!D9 U+00D9 Ugrave +!DA U+00DA Uacute +!DB U+00DB Ucircumflex +!DC U+00DC Udieresis +!DD U+0130 Idotaccent +!DE U+015E Scedilla +!DF U+00DF germandbls +!E0 U+00E0 agrave +!E1 U+00E1 aacute +!E2 U+00E2 acircumflex +!E3 U+00E3 atilde +!E4 U+00E4 adieresis +!E5 U+00E5 aring +!E6 U+00E6 ae +!E7 U+00E7 ccedilla +!E8 U+00E8 egrave +!E9 U+00E9 eacute +!EA U+00EA ecircumflex +!EB U+00EB edieresis +!EC U+00EC igrave +!ED U+00ED iacute +!EE U+00EE icircumflex +!EF U+00EF idieresis +!F0 U+011F gbreve +!F1 U+00F1 ntilde +!F2 U+00F2 ograve +!F3 U+00F3 oacute +!F4 U+00F4 ocircumflex +!F5 U+00F5 otilde +!F6 U+00F6 odieresis +!F7 U+00F7 divide +!F8 U+00F8 oslash +!F9 U+00F9 ugrave +!FA U+00FA uacute +!FB U+00FB ucircumflex +!FC U+00FC udieresis +!FD U+0131 dotlessi +!FE U+015F scedilla +!FF U+00FF ydieresis diff --git a/include/pdf/font/makefont/cp1255.map b/include/pdf/font/makefont/cp1255.map new file mode 100644 index 000000000..079e10c61 --- /dev/null +++ b/include/pdf/font/makefont/cp1255.map @@ -0,0 +1,233 @@ +!00 U+0000 .notdef +!01 U+0001 .notdef +!02 U+0002 .notdef +!03 U+0003 .notdef +!04 U+0004 .notdef +!05 U+0005 .notdef +!06 U+0006 .notdef +!07 U+0007 .notdef +!08 U+0008 .notdef +!09 U+0009 .notdef +!0A U+000A .notdef +!0B U+000B .notdef +!0C U+000C .notdef +!0D U+000D .notdef +!0E U+000E .notdef +!0F U+000F .notdef +!10 U+0010 .notdef +!11 U+0011 .notdef +!12 U+0012 .notdef +!13 U+0013 .notdef +!14 U+0014 .notdef +!15 U+0015 .notdef +!16 U+0016 .notdef +!17 U+0017 .notdef +!18 U+0018 .notdef +!19 U+0019 .notdef +!1A U+001A .notdef +!1B U+001B .notdef +!1C U+001C .notdef +!1D U+001D .notdef +!1E U+001E .notdef +!1F U+001F .notdef +!20 U+0020 space +!21 U+0021 exclam +!22 U+0022 quotedbl +!23 U+0023 numbersign +!24 U+0024 dollar +!25 U+0025 percent +!26 U+0026 ampersand +!27 U+0027 quotesingle +!28 U+0028 parenleft +!29 U+0029 parenright +!2A U+002A asterisk +!2B U+002B plus +!2C U+002C comma +!2D U+002D hyphen +!2E U+002E period +!2F U+002F slash +!30 U+0030 zero +!31 U+0031 one +!32 U+0032 two +!33 U+0033 three +!34 U+0034 four +!35 U+0035 five +!36 U+0036 six +!37 U+0037 seven +!38 U+0038 eight +!39 U+0039 nine +!3A U+003A colon +!3B U+003B semicolon +!3C U+003C less +!3D U+003D equal +!3E U+003E greater +!3F U+003F question +!40 U+0040 at +!41 U+0041 A +!42 U+0042 B +!43 U+0043 C +!44 U+0044 D +!45 U+0045 E +!46 U+0046 F +!47 U+0047 G +!48 U+0048 H +!49 U+0049 I +!4A U+004A J +!4B U+004B K +!4C U+004C L +!4D U+004D M +!4E U+004E N +!4F U+004F O +!50 U+0050 P +!51 U+0051 Q +!52 U+0052 R +!53 U+0053 S +!54 U+0054 T +!55 U+0055 U +!56 U+0056 V +!57 U+0057 W +!58 U+0058 X +!59 U+0059 Y +!5A U+005A Z +!5B U+005B bracketleft +!5C U+005C backslash +!5D U+005D bracketright +!5E U+005E asciicircum +!5F U+005F underscore +!60 U+0060 grave +!61 U+0061 a +!62 U+0062 b +!63 U+0063 c +!64 U+0064 d +!65 U+0065 e +!66 U+0066 f +!67 U+0067 g +!68 U+0068 h +!69 U+0069 i +!6A U+006A j +!6B U+006B k +!6C U+006C l +!6D U+006D m +!6E U+006E n +!6F U+006F o +!70 U+0070 p +!71 U+0071 q +!72 U+0072 r +!73 U+0073 s +!74 U+0074 t +!75 U+0075 u +!76 U+0076 v +!77 U+0077 w +!78 U+0078 x +!79 U+0079 y +!7A U+007A z +!7B U+007B braceleft +!7C U+007C bar +!7D U+007D braceright +!7E U+007E asciitilde +!7F U+007F .notdef +!80 U+20AC Euro +!82 U+201A quotesinglbase +!83 U+0192 florin +!84 U+201E quotedblbase +!85 U+2026 ellipsis +!86 U+2020 dagger +!87 U+2021 daggerdbl +!88 U+02C6 circumflex +!89 U+2030 perthousand +!8B U+2039 guilsinglleft +!91 U+2018 quoteleft +!92 U+2019 quoteright +!93 U+201C quotedblleft +!94 U+201D quotedblright +!95 U+2022 bullet +!96 U+2013 endash +!97 U+2014 emdash +!98 U+02DC tilde +!99 U+2122 trademark +!9B U+203A guilsinglright +!A0 U+00A0 space +!A1 U+00A1 exclamdown +!A2 U+00A2 cent +!A3 U+00A3 sterling +!A4 U+20AA afii57636 +!A5 U+00A5 yen +!A6 U+00A6 brokenbar +!A7 U+00A7 section +!A8 U+00A8 dieresis +!A9 U+00A9 copyright +!AA U+00D7 multiply +!AB U+00AB guillemotleft +!AC U+00AC logicalnot +!AD U+00AD sfthyphen +!AE U+00AE registered +!AF U+00AF macron +!B0 U+00B0 degree +!B1 U+00B1 plusminus +!B2 U+00B2 twosuperior +!B3 U+00B3 threesuperior +!B4 U+00B4 acute +!B5 U+00B5 mu +!B6 U+00B6 paragraph +!B7 U+00B7 middot +!B8 U+00B8 cedilla +!B9 U+00B9 onesuperior +!BA U+00F7 divide +!BB U+00BB guillemotright +!BC U+00BC onequarter +!BD U+00BD onehalf +!BE U+00BE threequarters +!BF U+00BF questiondown +!C0 U+05B0 afii57799 +!C1 U+05B1 afii57801 +!C2 U+05B2 afii57800 +!C3 U+05B3 afii57802 +!C4 U+05B4 afii57793 +!C5 U+05B5 afii57794 +!C6 U+05B6 afii57795 +!C7 U+05B7 afii57798 +!C8 U+05B8 afii57797 +!C9 U+05B9 afii57806 +!CB U+05BB afii57796 +!CC U+05BC afii57807 +!CD U+05BD afii57839 +!CE U+05BE afii57645 +!CF U+05BF afii57841 +!D0 U+05C0 afii57842 +!D1 U+05C1 afii57804 +!D2 U+05C2 afii57803 +!D3 U+05C3 afii57658 +!D4 U+05F0 afii57716 +!D5 U+05F1 afii57717 +!D6 U+05F2 afii57718 +!D7 U+05F3 gereshhebrew +!D8 U+05F4 gershayimhebrew +!E0 U+05D0 afii57664 +!E1 U+05D1 afii57665 +!E2 U+05D2 afii57666 +!E3 U+05D3 afii57667 +!E4 U+05D4 afii57668 +!E5 U+05D5 afii57669 +!E6 U+05D6 afii57670 +!E7 U+05D7 afii57671 +!E8 U+05D8 afii57672 +!E9 U+05D9 afii57673 +!EA U+05DA afii57674 +!EB U+05DB afii57675 +!EC U+05DC afii57676 +!ED U+05DD afii57677 +!EE U+05DE afii57678 +!EF U+05DF afii57679 +!F0 U+05E0 afii57680 +!F1 U+05E1 afii57681 +!F2 U+05E2 afii57682 +!F3 U+05E3 afii57683 +!F4 U+05E4 afii57684 +!F5 U+05E5 afii57685 +!F6 U+05E6 afii57686 +!F7 U+05E7 afii57687 +!F8 U+05E8 afii57688 +!F9 U+05E9 afii57689 +!FA U+05EA afii57690 +!FD U+200E afii299 +!FE U+200F afii300 diff --git a/include/pdf/font/makefont/cp1257.map b/include/pdf/font/makefont/cp1257.map new file mode 100644 index 000000000..2f2ecfa21 --- /dev/null +++ b/include/pdf/font/makefont/cp1257.map @@ -0,0 +1,244 @@ +!00 U+0000 .notdef +!01 U+0001 .notdef +!02 U+0002 .notdef +!03 U+0003 .notdef +!04 U+0004 .notdef +!05 U+0005 .notdef +!06 U+0006 .notdef +!07 U+0007 .notdef +!08 U+0008 .notdef +!09 U+0009 .notdef +!0A U+000A .notdef +!0B U+000B .notdef +!0C U+000C .notdef +!0D U+000D .notdef +!0E U+000E .notdef +!0F U+000F .notdef +!10 U+0010 .notdef +!11 U+0011 .notdef +!12 U+0012 .notdef +!13 U+0013 .notdef +!14 U+0014 .notdef +!15 U+0015 .notdef +!16 U+0016 .notdef +!17 U+0017 .notdef +!18 U+0018 .notdef +!19 U+0019 .notdef +!1A U+001A .notdef +!1B U+001B .notdef +!1C U+001C .notdef +!1D U+001D .notdef +!1E U+001E .notdef +!1F U+001F .notdef +!20 U+0020 space +!21 U+0021 exclam +!22 U+0022 quotedbl +!23 U+0023 numbersign +!24 U+0024 dollar +!25 U+0025 percent +!26 U+0026 ampersand +!27 U+0027 quotesingle +!28 U+0028 parenleft +!29 U+0029 parenright +!2A U+002A asterisk +!2B U+002B plus +!2C U+002C comma +!2D U+002D hyphen +!2E U+002E period +!2F U+002F slash +!30 U+0030 zero +!31 U+0031 one +!32 U+0032 two +!33 U+0033 three +!34 U+0034 four +!35 U+0035 five +!36 U+0036 six +!37 U+0037 seven +!38 U+0038 eight +!39 U+0039 nine +!3A U+003A colon +!3B U+003B semicolon +!3C U+003C less +!3D U+003D equal +!3E U+003E greater +!3F U+003F question +!40 U+0040 at +!41 U+0041 A +!42 U+0042 B +!43 U+0043 C +!44 U+0044 D +!45 U+0045 E +!46 U+0046 F +!47 U+0047 G +!48 U+0048 H +!49 U+0049 I +!4A U+004A J +!4B U+004B K +!4C U+004C L +!4D U+004D M +!4E U+004E N +!4F U+004F O +!50 U+0050 P +!51 U+0051 Q +!52 U+0052 R +!53 U+0053 S +!54 U+0054 T +!55 U+0055 U +!56 U+0056 V +!57 U+0057 W +!58 U+0058 X +!59 U+0059 Y +!5A U+005A Z +!5B U+005B bracketleft +!5C U+005C backslash +!5D U+005D bracketright +!5E U+005E asciicircum +!5F U+005F underscore +!60 U+0060 grave +!61 U+0061 a +!62 U+0062 b +!63 U+0063 c +!64 U+0064 d +!65 U+0065 e +!66 U+0066 f +!67 U+0067 g +!68 U+0068 h +!69 U+0069 i +!6A U+006A j +!6B U+006B k +!6C U+006C l +!6D U+006D m +!6E U+006E n +!6F U+006F o +!70 U+0070 p +!71 U+0071 q +!72 U+0072 r +!73 U+0073 s +!74 U+0074 t +!75 U+0075 u +!76 U+0076 v +!77 U+0077 w +!78 U+0078 x +!79 U+0079 y +!7A U+007A z +!7B U+007B braceleft +!7C U+007C bar +!7D U+007D braceright +!7E U+007E asciitilde +!7F U+007F .notdef +!80 U+20AC Euro +!82 U+201A quotesinglbase +!84 U+201E quotedblbase +!85 U+2026 ellipsis +!86 U+2020 dagger +!87 U+2021 daggerdbl +!89 U+2030 perthousand +!8B U+2039 guilsinglleft +!8D U+00A8 dieresis +!8E U+02C7 caron +!8F U+00B8 cedilla +!91 U+2018 quoteleft +!92 U+2019 quoteright +!93 U+201C quotedblleft +!94 U+201D quotedblright +!95 U+2022 bullet +!96 U+2013 endash +!97 U+2014 emdash +!99 U+2122 trademark +!9B U+203A guilsinglright +!9D U+00AF macron +!9E U+02DB ogonek +!A0 U+00A0 space +!A2 U+00A2 cent +!A3 U+00A3 sterling +!A4 U+00A4 currency +!A6 U+00A6 brokenbar +!A7 U+00A7 section +!A8 U+00D8 Oslash +!A9 U+00A9 copyright +!AA U+0156 Rcommaaccent +!AB U+00AB guillemotleft +!AC U+00AC logicalnot +!AD U+00AD hyphen +!AE U+00AE registered +!AF U+00C6 AE +!B0 U+00B0 degree +!B1 U+00B1 plusminus +!B2 U+00B2 twosuperior +!B3 U+00B3 threesuperior +!B4 U+00B4 acute +!B5 U+00B5 mu +!B6 U+00B6 paragraph +!B7 U+00B7 periodcentered +!B8 U+00F8 oslash +!B9 U+00B9 onesuperior +!BA U+0157 rcommaaccent +!BB U+00BB guillemotright +!BC U+00BC onequarter +!BD U+00BD onehalf +!BE U+00BE threequarters +!BF U+00E6 ae +!C0 U+0104 Aogonek +!C1 U+012E Iogonek +!C2 U+0100 Amacron +!C3 U+0106 Cacute +!C4 U+00C4 Adieresis +!C5 U+00C5 Aring +!C6 U+0118 Eogonek +!C7 U+0112 Emacron +!C8 U+010C Ccaron +!C9 U+00C9 Eacute +!CA U+0179 Zacute +!CB U+0116 Edotaccent +!CC U+0122 Gcommaaccent +!CD U+0136 Kcommaaccent +!CE U+012A Imacron +!CF U+013B Lcommaaccent +!D0 U+0160 Scaron +!D1 U+0143 Nacute +!D2 U+0145 Ncommaaccent +!D3 U+00D3 Oacute +!D4 U+014C Omacron +!D5 U+00D5 Otilde +!D6 U+00D6 Odieresis +!D7 U+00D7 multiply +!D8 U+0172 Uogonek +!D9 U+0141 Lslash +!DA U+015A Sacute +!DB U+016A Umacron +!DC U+00DC Udieresis +!DD U+017B Zdotaccent +!DE U+017D Zcaron +!DF U+00DF germandbls +!E0 U+0105 aogonek +!E1 U+012F iogonek +!E2 U+0101 amacron +!E3 U+0107 cacute +!E4 U+00E4 adieresis +!E5 U+00E5 aring +!E6 U+0119 eogonek +!E7 U+0113 emacron +!E8 U+010D ccaron +!E9 U+00E9 eacute +!EA U+017A zacute +!EB U+0117 edotaccent +!EC U+0123 gcommaaccent +!ED U+0137 kcommaaccent +!EE U+012B imacron +!EF U+013C lcommaaccent +!F0 U+0161 scaron +!F1 U+0144 nacute +!F2 U+0146 ncommaaccent +!F3 U+00F3 oacute +!F4 U+014D omacron +!F5 U+00F5 otilde +!F6 U+00F6 odieresis +!F7 U+00F7 divide +!F8 U+0173 uogonek +!F9 U+0142 lslash +!FA U+015B sacute +!FB U+016B umacron +!FC U+00FC udieresis +!FD U+017C zdotaccent +!FE U+017E zcaron +!FF U+02D9 dotaccent diff --git a/include/pdf/font/makefont/cp1258.map b/include/pdf/font/makefont/cp1258.map new file mode 100644 index 000000000..fed915f71 --- /dev/null +++ b/include/pdf/font/makefont/cp1258.map @@ -0,0 +1,247 @@ +!00 U+0000 .notdef +!01 U+0001 .notdef +!02 U+0002 .notdef +!03 U+0003 .notdef +!04 U+0004 .notdef +!05 U+0005 .notdef +!06 U+0006 .notdef +!07 U+0007 .notdef +!08 U+0008 .notdef +!09 U+0009 .notdef +!0A U+000A .notdef +!0B U+000B .notdef +!0C U+000C .notdef +!0D U+000D .notdef +!0E U+000E .notdef +!0F U+000F .notdef +!10 U+0010 .notdef +!11 U+0011 .notdef +!12 U+0012 .notdef +!13 U+0013 .notdef +!14 U+0014 .notdef +!15 U+0015 .notdef +!16 U+0016 .notdef +!17 U+0017 .notdef +!18 U+0018 .notdef +!19 U+0019 .notdef +!1A U+001A .notdef +!1B U+001B .notdef +!1C U+001C .notdef +!1D U+001D .notdef +!1E U+001E .notdef +!1F U+001F .notdef +!20 U+0020 space +!21 U+0021 exclam +!22 U+0022 quotedbl +!23 U+0023 numbersign +!24 U+0024 dollar +!25 U+0025 percent +!26 U+0026 ampersand +!27 U+0027 quotesingle +!28 U+0028 parenleft +!29 U+0029 parenright +!2A U+002A asterisk +!2B U+002B plus +!2C U+002C comma +!2D U+002D hyphen +!2E U+002E period +!2F U+002F slash +!30 U+0030 zero +!31 U+0031 one +!32 U+0032 two +!33 U+0033 three +!34 U+0034 four +!35 U+0035 five +!36 U+0036 six +!37 U+0037 seven +!38 U+0038 eight +!39 U+0039 nine +!3A U+003A colon +!3B U+003B semicolon +!3C U+003C less +!3D U+003D equal +!3E U+003E greater +!3F U+003F question +!40 U+0040 at +!41 U+0041 A +!42 U+0042 B +!43 U+0043 C +!44 U+0044 D +!45 U+0045 E +!46 U+0046 F +!47 U+0047 G +!48 U+0048 H +!49 U+0049 I +!4A U+004A J +!4B U+004B K +!4C U+004C L +!4D U+004D M +!4E U+004E N +!4F U+004F O +!50 U+0050 P +!51 U+0051 Q +!52 U+0052 R +!53 U+0053 S +!54 U+0054 T +!55 U+0055 U +!56 U+0056 V +!57 U+0057 W +!58 U+0058 X +!59 U+0059 Y +!5A U+005A Z +!5B U+005B bracketleft +!5C U+005C backslash +!5D U+005D bracketright +!5E U+005E asciicircum +!5F U+005F underscore +!60 U+0060 grave +!61 U+0061 a +!62 U+0062 b +!63 U+0063 c +!64 U+0064 d +!65 U+0065 e +!66 U+0066 f +!67 U+0067 g +!68 U+0068 h +!69 U+0069 i +!6A U+006A j +!6B U+006B k +!6C U+006C l +!6D U+006D m +!6E U+006E n +!6F U+006F o +!70 U+0070 p +!71 U+0071 q +!72 U+0072 r +!73 U+0073 s +!74 U+0074 t +!75 U+0075 u +!76 U+0076 v +!77 U+0077 w +!78 U+0078 x +!79 U+0079 y +!7A U+007A z +!7B U+007B braceleft +!7C U+007C bar +!7D U+007D braceright +!7E U+007E asciitilde +!7F U+007F .notdef +!80 U+20AC Euro +!82 U+201A quotesinglbase +!83 U+0192 florin +!84 U+201E quotedblbase +!85 U+2026 ellipsis +!86 U+2020 dagger +!87 U+2021 daggerdbl +!88 U+02C6 circumflex +!89 U+2030 perthousand +!8B U+2039 guilsinglleft +!8C U+0152 OE +!91 U+2018 quoteleft +!92 U+2019 quoteright +!93 U+201C quotedblleft +!94 U+201D quotedblright +!95 U+2022 bullet +!96 U+2013 endash +!97 U+2014 emdash +!98 U+02DC tilde +!99 U+2122 trademark +!9B U+203A guilsinglright +!9C U+0153 oe +!9F U+0178 Ydieresis +!A0 U+00A0 space +!A1 U+00A1 exclamdown +!A2 U+00A2 cent +!A3 U+00A3 sterling +!A4 U+00A4 currency +!A5 U+00A5 yen +!A6 U+00A6 brokenbar +!A7 U+00A7 section +!A8 U+00A8 dieresis +!A9 U+00A9 copyright +!AA U+00AA ordfeminine +!AB U+00AB guillemotleft +!AC U+00AC logicalnot +!AD U+00AD hyphen +!AE U+00AE registered +!AF U+00AF macron +!B0 U+00B0 degree +!B1 U+00B1 plusminus +!B2 U+00B2 twosuperior +!B3 U+00B3 threesuperior +!B4 U+00B4 acute +!B5 U+00B5 mu +!B6 U+00B6 paragraph +!B7 U+00B7 periodcentered +!B8 U+00B8 cedilla +!B9 U+00B9 onesuperior +!BA U+00BA ordmasculine +!BB U+00BB guillemotright +!BC U+00BC onequarter +!BD U+00BD onehalf +!BE U+00BE threequarters +!BF U+00BF questiondown +!C0 U+00C0 Agrave +!C1 U+00C1 Aacute +!C2 U+00C2 Acircumflex +!C3 U+0102 Abreve +!C4 U+00C4 Adieresis +!C5 U+00C5 Aring +!C6 U+00C6 AE +!C7 U+00C7 Ccedilla +!C8 U+00C8 Egrave +!C9 U+00C9 Eacute +!CA U+00CA Ecircumflex +!CB U+00CB Edieresis +!CC U+0300 gravecomb +!CD U+00CD Iacute +!CE U+00CE Icircumflex +!CF U+00CF Idieresis +!D0 U+0110 Dcroat +!D1 U+00D1 Ntilde +!D2 U+0309 hookabovecomb +!D3 U+00D3 Oacute +!D4 U+00D4 Ocircumflex +!D5 U+01A0 Ohorn +!D6 U+00D6 Odieresis +!D7 U+00D7 multiply +!D8 U+00D8 Oslash +!D9 U+00D9 Ugrave +!DA U+00DA Uacute +!DB U+00DB Ucircumflex +!DC U+00DC Udieresis +!DD U+01AF Uhorn +!DE U+0303 tildecomb +!DF U+00DF germandbls +!E0 U+00E0 agrave +!E1 U+00E1 aacute +!E2 U+00E2 acircumflex +!E3 U+0103 abreve +!E4 U+00E4 adieresis +!E5 U+00E5 aring +!E6 U+00E6 ae +!E7 U+00E7 ccedilla +!E8 U+00E8 egrave +!E9 U+00E9 eacute +!EA U+00EA ecircumflex +!EB U+00EB edieresis +!EC U+0301 acutecomb +!ED U+00ED iacute +!EE U+00EE icircumflex +!EF U+00EF idieresis +!F0 U+0111 dcroat +!F1 U+00F1 ntilde +!F2 U+0323 dotbelowcomb +!F3 U+00F3 oacute +!F4 U+00F4 ocircumflex +!F5 U+01A1 ohorn +!F6 U+00F6 odieresis +!F7 U+00F7 divide +!F8 U+00F8 oslash +!F9 U+00F9 ugrave +!FA U+00FA uacute +!FB U+00FB ucircumflex +!FC U+00FC udieresis +!FD U+01B0 uhorn +!FE U+20AB dong +!FF U+00FF ydieresis diff --git a/include/pdf/font/makefont/cp874.map b/include/pdf/font/makefont/cp874.map new file mode 100644 index 000000000..1006e6b17 --- /dev/null +++ b/include/pdf/font/makefont/cp874.map @@ -0,0 +1,225 @@ +!00 U+0000 .notdef +!01 U+0001 .notdef +!02 U+0002 .notdef +!03 U+0003 .notdef +!04 U+0004 .notdef +!05 U+0005 .notdef +!06 U+0006 .notdef +!07 U+0007 .notdef +!08 U+0008 .notdef +!09 U+0009 .notdef +!0A U+000A .notdef +!0B U+000B .notdef +!0C U+000C .notdef +!0D U+000D .notdef +!0E U+000E .notdef +!0F U+000F .notdef +!10 U+0010 .notdef +!11 U+0011 .notdef +!12 U+0012 .notdef +!13 U+0013 .notdef +!14 U+0014 .notdef +!15 U+0015 .notdef +!16 U+0016 .notdef +!17 U+0017 .notdef +!18 U+0018 .notdef +!19 U+0019 .notdef +!1A U+001A .notdef +!1B U+001B .notdef +!1C U+001C .notdef +!1D U+001D .notdef +!1E U+001E .notdef +!1F U+001F .notdef +!20 U+0020 space +!21 U+0021 exclam +!22 U+0022 quotedbl +!23 U+0023 numbersign +!24 U+0024 dollar +!25 U+0025 percent +!26 U+0026 ampersand +!27 U+0027 quotesingle +!28 U+0028 parenleft +!29 U+0029 parenright +!2A U+002A asterisk +!2B U+002B plus +!2C U+002C comma +!2D U+002D hyphen +!2E U+002E period +!2F U+002F slash +!30 U+0030 zero +!31 U+0031 one +!32 U+0032 two +!33 U+0033 three +!34 U+0034 four +!35 U+0035 five +!36 U+0036 six +!37 U+0037 seven +!38 U+0038 eight +!39 U+0039 nine +!3A U+003A colon +!3B U+003B semicolon +!3C U+003C less +!3D U+003D equal +!3E U+003E greater +!3F U+003F question +!40 U+0040 at +!41 U+0041 A +!42 U+0042 B +!43 U+0043 C +!44 U+0044 D +!45 U+0045 E +!46 U+0046 F +!47 U+0047 G +!48 U+0048 H +!49 U+0049 I +!4A U+004A J +!4B U+004B K +!4C U+004C L +!4D U+004D M +!4E U+004E N +!4F U+004F O +!50 U+0050 P +!51 U+0051 Q +!52 U+0052 R +!53 U+0053 S +!54 U+0054 T +!55 U+0055 U +!56 U+0056 V +!57 U+0057 W +!58 U+0058 X +!59 U+0059 Y +!5A U+005A Z +!5B U+005B bracketleft +!5C U+005C backslash +!5D U+005D bracketright +!5E U+005E asciicircum +!5F U+005F underscore +!60 U+0060 grave +!61 U+0061 a +!62 U+0062 b +!63 U+0063 c +!64 U+0064 d +!65 U+0065 e +!66 U+0066 f +!67 U+0067 g +!68 U+0068 h +!69 U+0069 i +!6A U+006A j +!6B U+006B k +!6C U+006C l +!6D U+006D m +!6E U+006E n +!6F U+006F o +!70 U+0070 p +!71 U+0071 q +!72 U+0072 r +!73 U+0073 s +!74 U+0074 t +!75 U+0075 u +!76 U+0076 v +!77 U+0077 w +!78 U+0078 x +!79 U+0079 y +!7A U+007A z +!7B U+007B braceleft +!7C U+007C bar +!7D U+007D braceright +!7E U+007E asciitilde +!7F U+007F .notdef +!80 U+20AC Euro +!85 U+2026 ellipsis +!91 U+2018 quoteleft +!92 U+2019 quoteright +!93 U+201C quotedblleft +!94 U+201D quotedblright +!95 U+2022 bullet +!96 U+2013 endash +!97 U+2014 emdash +!A0 U+00A0 space +!A1 U+0E01 kokaithai +!A2 U+0E02 khokhaithai +!A3 U+0E03 khokhuatthai +!A4 U+0E04 khokhwaithai +!A5 U+0E05 khokhonthai +!A6 U+0E06 khorakhangthai +!A7 U+0E07 ngonguthai +!A8 U+0E08 chochanthai +!A9 U+0E09 chochingthai +!AA U+0E0A chochangthai +!AB U+0E0B sosothai +!AC U+0E0C chochoethai +!AD U+0E0D yoyingthai +!AE U+0E0E dochadathai +!AF U+0E0F topatakthai +!B0 U+0E10 thothanthai +!B1 U+0E11 thonangmonthothai +!B2 U+0E12 thophuthaothai +!B3 U+0E13 nonenthai +!B4 U+0E14 dodekthai +!B5 U+0E15 totaothai +!B6 U+0E16 thothungthai +!B7 U+0E17 thothahanthai +!B8 U+0E18 thothongthai +!B9 U+0E19 nonuthai +!BA U+0E1A bobaimaithai +!BB U+0E1B poplathai +!BC U+0E1C phophungthai +!BD U+0E1D fofathai +!BE U+0E1E phophanthai +!BF U+0E1F fofanthai +!C0 U+0E20 phosamphaothai +!C1 U+0E21 momathai +!C2 U+0E22 yoyakthai +!C3 U+0E23 roruathai +!C4 U+0E24 ruthai +!C5 U+0E25 lolingthai +!C6 U+0E26 luthai +!C7 U+0E27 wowaenthai +!C8 U+0E28 sosalathai +!C9 U+0E29 sorusithai +!CA U+0E2A sosuathai +!CB U+0E2B hohipthai +!CC U+0E2C lochulathai +!CD U+0E2D oangthai +!CE U+0E2E honokhukthai +!CF U+0E2F paiyannoithai +!D0 U+0E30 saraathai +!D1 U+0E31 maihanakatthai +!D2 U+0E32 saraaathai +!D3 U+0E33 saraamthai +!D4 U+0E34 saraithai +!D5 U+0E35 saraiithai +!D6 U+0E36 sarauethai +!D7 U+0E37 saraueethai +!D8 U+0E38 sarauthai +!D9 U+0E39 sarauuthai +!DA U+0E3A phinthuthai +!DF U+0E3F bahtthai +!E0 U+0E40 saraethai +!E1 U+0E41 saraaethai +!E2 U+0E42 saraothai +!E3 U+0E43 saraaimaimuanthai +!E4 U+0E44 saraaimaimalaithai +!E5 U+0E45 lakkhangyaothai +!E6 U+0E46 maiyamokthai +!E7 U+0E47 maitaikhuthai +!E8 U+0E48 maiekthai +!E9 U+0E49 maithothai +!EA U+0E4A maitrithai +!EB U+0E4B maichattawathai +!EC U+0E4C thanthakhatthai +!ED U+0E4D nikhahitthai +!EE U+0E4E yamakkanthai +!EF U+0E4F fongmanthai +!F0 U+0E50 zerothai +!F1 U+0E51 onethai +!F2 U+0E52 twothai +!F3 U+0E53 threethai +!F4 U+0E54 fourthai +!F5 U+0E55 fivethai +!F6 U+0E56 sixthai +!F7 U+0E57 seventhai +!F8 U+0E58 eightthai +!F9 U+0E59 ninethai +!FA U+0E5A angkhankhuthai +!FB U+0E5B khomutthai diff --git a/include/pdf/font/makefont/iso-8859-1.map b/include/pdf/font/makefont/iso-8859-1.map new file mode 100644 index 000000000..61740a38f --- /dev/null +++ b/include/pdf/font/makefont/iso-8859-1.map @@ -0,0 +1,256 @@ +!00 U+0000 .notdef +!01 U+0001 .notdef +!02 U+0002 .notdef +!03 U+0003 .notdef +!04 U+0004 .notdef +!05 U+0005 .notdef +!06 U+0006 .notdef +!07 U+0007 .notdef +!08 U+0008 .notdef +!09 U+0009 .notdef +!0A U+000A .notdef +!0B U+000B .notdef +!0C U+000C .notdef +!0D U+000D .notdef +!0E U+000E .notdef +!0F U+000F .notdef +!10 U+0010 .notdef +!11 U+0011 .notdef +!12 U+0012 .notdef +!13 U+0013 .notdef +!14 U+0014 .notdef +!15 U+0015 .notdef +!16 U+0016 .notdef +!17 U+0017 .notdef +!18 U+0018 .notdef +!19 U+0019 .notdef +!1A U+001A .notdef +!1B U+001B .notdef +!1C U+001C .notdef +!1D U+001D .notdef +!1E U+001E .notdef +!1F U+001F .notdef +!20 U+0020 space +!21 U+0021 exclam +!22 U+0022 quotedbl +!23 U+0023 numbersign +!24 U+0024 dollar +!25 U+0025 percent +!26 U+0026 ampersand +!27 U+0027 quotesingle +!28 U+0028 parenleft +!29 U+0029 parenright +!2A U+002A asterisk +!2B U+002B plus +!2C U+002C comma +!2D U+002D hyphen +!2E U+002E period +!2F U+002F slash +!30 U+0030 zero +!31 U+0031 one +!32 U+0032 two +!33 U+0033 three +!34 U+0034 four +!35 U+0035 five +!36 U+0036 six +!37 U+0037 seven +!38 U+0038 eight +!39 U+0039 nine +!3A U+003A colon +!3B U+003B semicolon +!3C U+003C less +!3D U+003D equal +!3E U+003E greater +!3F U+003F question +!40 U+0040 at +!41 U+0041 A +!42 U+0042 B +!43 U+0043 C +!44 U+0044 D +!45 U+0045 E +!46 U+0046 F +!47 U+0047 G +!48 U+0048 H +!49 U+0049 I +!4A U+004A J +!4B U+004B K +!4C U+004C L +!4D U+004D M +!4E U+004E N +!4F U+004F O +!50 U+0050 P +!51 U+0051 Q +!52 U+0052 R +!53 U+0053 S +!54 U+0054 T +!55 U+0055 U +!56 U+0056 V +!57 U+0057 W +!58 U+0058 X +!59 U+0059 Y +!5A U+005A Z +!5B U+005B bracketleft +!5C U+005C backslash +!5D U+005D bracketright +!5E U+005E asciicircum +!5F U+005F underscore +!60 U+0060 grave +!61 U+0061 a +!62 U+0062 b +!63 U+0063 c +!64 U+0064 d +!65 U+0065 e +!66 U+0066 f +!67 U+0067 g +!68 U+0068 h +!69 U+0069 i +!6A U+006A j +!6B U+006B k +!6C U+006C l +!6D U+006D m +!6E U+006E n +!6F U+006F o +!70 U+0070 p +!71 U+0071 q +!72 U+0072 r +!73 U+0073 s +!74 U+0074 t +!75 U+0075 u +!76 U+0076 v +!77 U+0077 w +!78 U+0078 x +!79 U+0079 y +!7A U+007A z +!7B U+007B braceleft +!7C U+007C bar +!7D U+007D braceright +!7E U+007E asciitilde +!7F U+007F .notdef +!80 U+0080 .notdef +!81 U+0081 .notdef +!82 U+0082 .notdef +!83 U+0083 .notdef +!84 U+0084 .notdef +!85 U+0085 .notdef +!86 U+0086 .notdef +!87 U+0087 .notdef +!88 U+0088 .notdef +!89 U+0089 .notdef +!8A U+008A .notdef +!8B U+008B .notdef +!8C U+008C .notdef +!8D U+008D .notdef +!8E U+008E .notdef +!8F U+008F .notdef +!90 U+0090 .notdef +!91 U+0091 .notdef +!92 U+0092 .notdef +!93 U+0093 .notdef +!94 U+0094 .notdef +!95 U+0095 .notdef +!96 U+0096 .notdef +!97 U+0097 .notdef +!98 U+0098 .notdef +!99 U+0099 .notdef +!9A U+009A .notdef +!9B U+009B .notdef +!9C U+009C .notdef +!9D U+009D .notdef +!9E U+009E .notdef +!9F U+009F .notdef +!A0 U+00A0 space +!A1 U+00A1 exclamdown +!A2 U+00A2 cent +!A3 U+00A3 sterling +!A4 U+00A4 currency +!A5 U+00A5 yen +!A6 U+00A6 brokenbar +!A7 U+00A7 section +!A8 U+00A8 dieresis +!A9 U+00A9 copyright +!AA U+00AA ordfeminine +!AB U+00AB guillemotleft +!AC U+00AC logicalnot +!AD U+00AD hyphen +!AE U+00AE registered +!AF U+00AF macron +!B0 U+00B0 degree +!B1 U+00B1 plusminus +!B2 U+00B2 twosuperior +!B3 U+00B3 threesuperior +!B4 U+00B4 acute +!B5 U+00B5 mu +!B6 U+00B6 paragraph +!B7 U+00B7 periodcentered +!B8 U+00B8 cedilla +!B9 U+00B9 onesuperior +!BA U+00BA ordmasculine +!BB U+00BB guillemotright +!BC U+00BC onequarter +!BD U+00BD onehalf +!BE U+00BE threequarters +!BF U+00BF questiondown +!C0 U+00C0 Agrave +!C1 U+00C1 Aacute +!C2 U+00C2 Acircumflex +!C3 U+00C3 Atilde +!C4 U+00C4 Adieresis +!C5 U+00C5 Aring +!C6 U+00C6 AE +!C7 U+00C7 Ccedilla +!C8 U+00C8 Egrave +!C9 U+00C9 Eacute +!CA U+00CA Ecircumflex +!CB U+00CB Edieresis +!CC U+00CC Igrave +!CD U+00CD Iacute +!CE U+00CE Icircumflex +!CF U+00CF Idieresis +!D0 U+00D0 Eth +!D1 U+00D1 Ntilde +!D2 U+00D2 Ograve +!D3 U+00D3 Oacute +!D4 U+00D4 Ocircumflex +!D5 U+00D5 Otilde +!D6 U+00D6 Odieresis +!D7 U+00D7 multiply +!D8 U+00D8 Oslash +!D9 U+00D9 Ugrave +!DA U+00DA Uacute +!DB U+00DB Ucircumflex +!DC U+00DC Udieresis +!DD U+00DD Yacute +!DE U+00DE Thorn +!DF U+00DF germandbls +!E0 U+00E0 agrave +!E1 U+00E1 aacute +!E2 U+00E2 acircumflex +!E3 U+00E3 atilde +!E4 U+00E4 adieresis +!E5 U+00E5 aring +!E6 U+00E6 ae +!E7 U+00E7 ccedilla +!E8 U+00E8 egrave +!E9 U+00E9 eacute +!EA U+00EA ecircumflex +!EB U+00EB edieresis +!EC U+00EC igrave +!ED U+00ED iacute +!EE U+00EE icircumflex +!EF U+00EF idieresis +!F0 U+00F0 eth +!F1 U+00F1 ntilde +!F2 U+00F2 ograve +!F3 U+00F3 oacute +!F4 U+00F4 ocircumflex +!F5 U+00F5 otilde +!F6 U+00F6 odieresis +!F7 U+00F7 divide +!F8 U+00F8 oslash +!F9 U+00F9 ugrave +!FA U+00FA uacute +!FB U+00FB ucircumflex +!FC U+00FC udieresis +!FD U+00FD yacute +!FE U+00FE thorn +!FF U+00FF ydieresis diff --git a/include/pdf/font/makefont/iso-8859-11.map b/include/pdf/font/makefont/iso-8859-11.map new file mode 100644 index 000000000..916881206 --- /dev/null +++ b/include/pdf/font/makefont/iso-8859-11.map @@ -0,0 +1,248 @@ +!00 U+0000 .notdef +!01 U+0001 .notdef +!02 U+0002 .notdef +!03 U+0003 .notdef +!04 U+0004 .notdef +!05 U+0005 .notdef +!06 U+0006 .notdef +!07 U+0007 .notdef +!08 U+0008 .notdef +!09 U+0009 .notdef +!0A U+000A .notdef +!0B U+000B .notdef +!0C U+000C .notdef +!0D U+000D .notdef +!0E U+000E .notdef +!0F U+000F .notdef +!10 U+0010 .notdef +!11 U+0011 .notdef +!12 U+0012 .notdef +!13 U+0013 .notdef +!14 U+0014 .notdef +!15 U+0015 .notdef +!16 U+0016 .notdef +!17 U+0017 .notdef +!18 U+0018 .notdef +!19 U+0019 .notdef +!1A U+001A .notdef +!1B U+001B .notdef +!1C U+001C .notdef +!1D U+001D .notdef +!1E U+001E .notdef +!1F U+001F .notdef +!20 U+0020 space +!21 U+0021 exclam +!22 U+0022 quotedbl +!23 U+0023 numbersign +!24 U+0024 dollar +!25 U+0025 percent +!26 U+0026 ampersand +!27 U+0027 quotesingle +!28 U+0028 parenleft +!29 U+0029 parenright +!2A U+002A asterisk +!2B U+002B plus +!2C U+002C comma +!2D U+002D hyphen +!2E U+002E period +!2F U+002F slash +!30 U+0030 zero +!31 U+0031 one +!32 U+0032 two +!33 U+0033 three +!34 U+0034 four +!35 U+0035 five +!36 U+0036 six +!37 U+0037 seven +!38 U+0038 eight +!39 U+0039 nine +!3A U+003A colon +!3B U+003B semicolon +!3C U+003C less +!3D U+003D equal +!3E U+003E greater +!3F U+003F question +!40 U+0040 at +!41 U+0041 A +!42 U+0042 B +!43 U+0043 C +!44 U+0044 D +!45 U+0045 E +!46 U+0046 F +!47 U+0047 G +!48 U+0048 H +!49 U+0049 I +!4A U+004A J +!4B U+004B K +!4C U+004C L +!4D U+004D M +!4E U+004E N +!4F U+004F O +!50 U+0050 P +!51 U+0051 Q +!52 U+0052 R +!53 U+0053 S +!54 U+0054 T +!55 U+0055 U +!56 U+0056 V +!57 U+0057 W +!58 U+0058 X +!59 U+0059 Y +!5A U+005A Z +!5B U+005B bracketleft +!5C U+005C backslash +!5D U+005D bracketright +!5E U+005E asciicircum +!5F U+005F underscore +!60 U+0060 grave +!61 U+0061 a +!62 U+0062 b +!63 U+0063 c +!64 U+0064 d +!65 U+0065 e +!66 U+0066 f +!67 U+0067 g +!68 U+0068 h +!69 U+0069 i +!6A U+006A j +!6B U+006B k +!6C U+006C l +!6D U+006D m +!6E U+006E n +!6F U+006F o +!70 U+0070 p +!71 U+0071 q +!72 U+0072 r +!73 U+0073 s +!74 U+0074 t +!75 U+0075 u +!76 U+0076 v +!77 U+0077 w +!78 U+0078 x +!79 U+0079 y +!7A U+007A z +!7B U+007B braceleft +!7C U+007C bar +!7D U+007D braceright +!7E U+007E asciitilde +!7F U+007F .notdef +!80 U+0080 .notdef +!81 U+0081 .notdef +!82 U+0082 .notdef +!83 U+0083 .notdef +!84 U+0084 .notdef +!85 U+0085 .notdef +!86 U+0086 .notdef +!87 U+0087 .notdef +!88 U+0088 .notdef +!89 U+0089 .notdef +!8A U+008A .notdef +!8B U+008B .notdef +!8C U+008C .notdef +!8D U+008D .notdef +!8E U+008E .notdef +!8F U+008F .notdef +!90 U+0090 .notdef +!91 U+0091 .notdef +!92 U+0092 .notdef +!93 U+0093 .notdef +!94 U+0094 .notdef +!95 U+0095 .notdef +!96 U+0096 .notdef +!97 U+0097 .notdef +!98 U+0098 .notdef +!99 U+0099 .notdef +!9A U+009A .notdef +!9B U+009B .notdef +!9C U+009C .notdef +!9D U+009D .notdef +!9E U+009E .notdef +!9F U+009F .notdef +!A0 U+00A0 space +!A1 U+0E01 kokaithai +!A2 U+0E02 khokhaithai +!A3 U+0E03 khokhuatthai +!A4 U+0E04 khokhwaithai +!A5 U+0E05 khokhonthai +!A6 U+0E06 khorakhangthai +!A7 U+0E07 ngonguthai +!A8 U+0E08 chochanthai +!A9 U+0E09 chochingthai +!AA U+0E0A chochangthai +!AB U+0E0B sosothai +!AC U+0E0C chochoethai +!AD U+0E0D yoyingthai +!AE U+0E0E dochadathai +!AF U+0E0F topatakthai +!B0 U+0E10 thothanthai +!B1 U+0E11 thonangmonthothai +!B2 U+0E12 thophuthaothai +!B3 U+0E13 nonenthai +!B4 U+0E14 dodekthai +!B5 U+0E15 totaothai +!B6 U+0E16 thothungthai +!B7 U+0E17 thothahanthai +!B8 U+0E18 thothongthai +!B9 U+0E19 nonuthai +!BA U+0E1A bobaimaithai +!BB U+0E1B poplathai +!BC U+0E1C phophungthai +!BD U+0E1D fofathai +!BE U+0E1E phophanthai +!BF U+0E1F fofanthai +!C0 U+0E20 phosamphaothai +!C1 U+0E21 momathai +!C2 U+0E22 yoyakthai +!C3 U+0E23 roruathai +!C4 U+0E24 ruthai +!C5 U+0E25 lolingthai +!C6 U+0E26 luthai +!C7 U+0E27 wowaenthai +!C8 U+0E28 sosalathai +!C9 U+0E29 sorusithai +!CA U+0E2A sosuathai +!CB U+0E2B hohipthai +!CC U+0E2C lochulathai +!CD U+0E2D oangthai +!CE U+0E2E honokhukthai +!CF U+0E2F paiyannoithai +!D0 U+0E30 saraathai +!D1 U+0E31 maihanakatthai +!D2 U+0E32 saraaathai +!D3 U+0E33 saraamthai +!D4 U+0E34 saraithai +!D5 U+0E35 saraiithai +!D6 U+0E36 sarauethai +!D7 U+0E37 saraueethai +!D8 U+0E38 sarauthai +!D9 U+0E39 sarauuthai +!DA U+0E3A phinthuthai +!DF U+0E3F bahtthai +!E0 U+0E40 saraethai +!E1 U+0E41 saraaethai +!E2 U+0E42 saraothai +!E3 U+0E43 saraaimaimuanthai +!E4 U+0E44 saraaimaimalaithai +!E5 U+0E45 lakkhangyaothai +!E6 U+0E46 maiyamokthai +!E7 U+0E47 maitaikhuthai +!E8 U+0E48 maiekthai +!E9 U+0E49 maithothai +!EA U+0E4A maitrithai +!EB U+0E4B maichattawathai +!EC U+0E4C thanthakhatthai +!ED U+0E4D nikhahitthai +!EE U+0E4E yamakkanthai +!EF U+0E4F fongmanthai +!F0 U+0E50 zerothai +!F1 U+0E51 onethai +!F2 U+0E52 twothai +!F3 U+0E53 threethai +!F4 U+0E54 fourthai +!F5 U+0E55 fivethai +!F6 U+0E56 sixthai +!F7 U+0E57 seventhai +!F8 U+0E58 eightthai +!F9 U+0E59 ninethai +!FA U+0E5A angkhankhuthai +!FB U+0E5B khomutthai diff --git a/include/pdf/font/makefont/iso-8859-15.map b/include/pdf/font/makefont/iso-8859-15.map new file mode 100644 index 000000000..6c2b57127 --- /dev/null +++ b/include/pdf/font/makefont/iso-8859-15.map @@ -0,0 +1,256 @@ +!00 U+0000 .notdef +!01 U+0001 .notdef +!02 U+0002 .notdef +!03 U+0003 .notdef +!04 U+0004 .notdef +!05 U+0005 .notdef +!06 U+0006 .notdef +!07 U+0007 .notdef +!08 U+0008 .notdef +!09 U+0009 .notdef +!0A U+000A .notdef +!0B U+000B .notdef +!0C U+000C .notdef +!0D U+000D .notdef +!0E U+000E .notdef +!0F U+000F .notdef +!10 U+0010 .notdef +!11 U+0011 .notdef +!12 U+0012 .notdef +!13 U+0013 .notdef +!14 U+0014 .notdef +!15 U+0015 .notdef +!16 U+0016 .notdef +!17 U+0017 .notdef +!18 U+0018 .notdef +!19 U+0019 .notdef +!1A U+001A .notdef +!1B U+001B .notdef +!1C U+001C .notdef +!1D U+001D .notdef +!1E U+001E .notdef +!1F U+001F .notdef +!20 U+0020 space +!21 U+0021 exclam +!22 U+0022 quotedbl +!23 U+0023 numbersign +!24 U+0024 dollar +!25 U+0025 percent +!26 U+0026 ampersand +!27 U+0027 quotesingle +!28 U+0028 parenleft +!29 U+0029 parenright +!2A U+002A asterisk +!2B U+002B plus +!2C U+002C comma +!2D U+002D hyphen +!2E U+002E period +!2F U+002F slash +!30 U+0030 zero +!31 U+0031 one +!32 U+0032 two +!33 U+0033 three +!34 U+0034 four +!35 U+0035 five +!36 U+0036 six +!37 U+0037 seven +!38 U+0038 eight +!39 U+0039 nine +!3A U+003A colon +!3B U+003B semicolon +!3C U+003C less +!3D U+003D equal +!3E U+003E greater +!3F U+003F question +!40 U+0040 at +!41 U+0041 A +!42 U+0042 B +!43 U+0043 C +!44 U+0044 D +!45 U+0045 E +!46 U+0046 F +!47 U+0047 G +!48 U+0048 H +!49 U+0049 I +!4A U+004A J +!4B U+004B K +!4C U+004C L +!4D U+004D M +!4E U+004E N +!4F U+004F O +!50 U+0050 P +!51 U+0051 Q +!52 U+0052 R +!53 U+0053 S +!54 U+0054 T +!55 U+0055 U +!56 U+0056 V +!57 U+0057 W +!58 U+0058 X +!59 U+0059 Y +!5A U+005A Z +!5B U+005B bracketleft +!5C U+005C backslash +!5D U+005D bracketright +!5E U+005E asciicircum +!5F U+005F underscore +!60 U+0060 grave +!61 U+0061 a +!62 U+0062 b +!63 U+0063 c +!64 U+0064 d +!65 U+0065 e +!66 U+0066 f +!67 U+0067 g +!68 U+0068 h +!69 U+0069 i +!6A U+006A j +!6B U+006B k +!6C U+006C l +!6D U+006D m +!6E U+006E n +!6F U+006F o +!70 U+0070 p +!71 U+0071 q +!72 U+0072 r +!73 U+0073 s +!74 U+0074 t +!75 U+0075 u +!76 U+0076 v +!77 U+0077 w +!78 U+0078 x +!79 U+0079 y +!7A U+007A z +!7B U+007B braceleft +!7C U+007C bar +!7D U+007D braceright +!7E U+007E asciitilde +!7F U+007F .notdef +!80 U+0080 .notdef +!81 U+0081 .notdef +!82 U+0082 .notdef +!83 U+0083 .notdef +!84 U+0084 .notdef +!85 U+0085 .notdef +!86 U+0086 .notdef +!87 U+0087 .notdef +!88 U+0088 .notdef +!89 U+0089 .notdef +!8A U+008A .notdef +!8B U+008B .notdef +!8C U+008C .notdef +!8D U+008D .notdef +!8E U+008E .notdef +!8F U+008F .notdef +!90 U+0090 .notdef +!91 U+0091 .notdef +!92 U+0092 .notdef +!93 U+0093 .notdef +!94 U+0094 .notdef +!95 U+0095 .notdef +!96 U+0096 .notdef +!97 U+0097 .notdef +!98 U+0098 .notdef +!99 U+0099 .notdef +!9A U+009A .notdef +!9B U+009B .notdef +!9C U+009C .notdef +!9D U+009D .notdef +!9E U+009E .notdef +!9F U+009F .notdef +!A0 U+00A0 space +!A1 U+00A1 exclamdown +!A2 U+00A2 cent +!A3 U+00A3 sterling +!A4 U+20AC Euro +!A5 U+00A5 yen +!A6 U+0160 Scaron +!A7 U+00A7 section +!A8 U+0161 scaron +!A9 U+00A9 copyright +!AA U+00AA ordfeminine +!AB U+00AB guillemotleft +!AC U+00AC logicalnot +!AD U+00AD hyphen +!AE U+00AE registered +!AF U+00AF macron +!B0 U+00B0 degree +!B1 U+00B1 plusminus +!B2 U+00B2 twosuperior +!B3 U+00B3 threesuperior +!B4 U+017D Zcaron +!B5 U+00B5 mu +!B6 U+00B6 paragraph +!B7 U+00B7 periodcentered +!B8 U+017E zcaron +!B9 U+00B9 onesuperior +!BA U+00BA ordmasculine +!BB U+00BB guillemotright +!BC U+0152 OE +!BD U+0153 oe +!BE U+0178 Ydieresis +!BF U+00BF questiondown +!C0 U+00C0 Agrave +!C1 U+00C1 Aacute +!C2 U+00C2 Acircumflex +!C3 U+00C3 Atilde +!C4 U+00C4 Adieresis +!C5 U+00C5 Aring +!C6 U+00C6 AE +!C7 U+00C7 Ccedilla +!C8 U+00C8 Egrave +!C9 U+00C9 Eacute +!CA U+00CA Ecircumflex +!CB U+00CB Edieresis +!CC U+00CC Igrave +!CD U+00CD Iacute +!CE U+00CE Icircumflex +!CF U+00CF Idieresis +!D0 U+00D0 Eth +!D1 U+00D1 Ntilde +!D2 U+00D2 Ograve +!D3 U+00D3 Oacute +!D4 U+00D4 Ocircumflex +!D5 U+00D5 Otilde +!D6 U+00D6 Odieresis +!D7 U+00D7 multiply +!D8 U+00D8 Oslash +!D9 U+00D9 Ugrave +!DA U+00DA Uacute +!DB U+00DB Ucircumflex +!DC U+00DC Udieresis +!DD U+00DD Yacute +!DE U+00DE Thorn +!DF U+00DF germandbls +!E0 U+00E0 agrave +!E1 U+00E1 aacute +!E2 U+00E2 acircumflex +!E3 U+00E3 atilde +!E4 U+00E4 adieresis +!E5 U+00E5 aring +!E6 U+00E6 ae +!E7 U+00E7 ccedilla +!E8 U+00E8 egrave +!E9 U+00E9 eacute +!EA U+00EA ecircumflex +!EB U+00EB edieresis +!EC U+00EC igrave +!ED U+00ED iacute +!EE U+00EE icircumflex +!EF U+00EF idieresis +!F0 U+00F0 eth +!F1 U+00F1 ntilde +!F2 U+00F2 ograve +!F3 U+00F3 oacute +!F4 U+00F4 ocircumflex +!F5 U+00F5 otilde +!F6 U+00F6 odieresis +!F7 U+00F7 divide +!F8 U+00F8 oslash +!F9 U+00F9 ugrave +!FA U+00FA uacute +!FB U+00FB ucircumflex +!FC U+00FC udieresis +!FD U+00FD yacute +!FE U+00FE thorn +!FF U+00FF ydieresis diff --git a/include/pdf/font/makefont/iso-8859-16.map b/include/pdf/font/makefont/iso-8859-16.map new file mode 100644 index 000000000..202c8fe59 --- /dev/null +++ b/include/pdf/font/makefont/iso-8859-16.map @@ -0,0 +1,256 @@ +!00 U+0000 .notdef +!01 U+0001 .notdef +!02 U+0002 .notdef +!03 U+0003 .notdef +!04 U+0004 .notdef +!05 U+0005 .notdef +!06 U+0006 .notdef +!07 U+0007 .notdef +!08 U+0008 .notdef +!09 U+0009 .notdef +!0A U+000A .notdef +!0B U+000B .notdef +!0C U+000C .notdef +!0D U+000D .notdef +!0E U+000E .notdef +!0F U+000F .notdef +!10 U+0010 .notdef +!11 U+0011 .notdef +!12 U+0012 .notdef +!13 U+0013 .notdef +!14 U+0014 .notdef +!15 U+0015 .notdef +!16 U+0016 .notdef +!17 U+0017 .notdef +!18 U+0018 .notdef +!19 U+0019 .notdef +!1A U+001A .notdef +!1B U+001B .notdef +!1C U+001C .notdef +!1D U+001D .notdef +!1E U+001E .notdef +!1F U+001F .notdef +!20 U+0020 space +!21 U+0021 exclam +!22 U+0022 quotedbl +!23 U+0023 numbersign +!24 U+0024 dollar +!25 U+0025 percent +!26 U+0026 ampersand +!27 U+0027 quotesingle +!28 U+0028 parenleft +!29 U+0029 parenright +!2A U+002A asterisk +!2B U+002B plus +!2C U+002C comma +!2D U+002D hyphen +!2E U+002E period +!2F U+002F slash +!30 U+0030 zero +!31 U+0031 one +!32 U+0032 two +!33 U+0033 three +!34 U+0034 four +!35 U+0035 five +!36 U+0036 six +!37 U+0037 seven +!38 U+0038 eight +!39 U+0039 nine +!3A U+003A colon +!3B U+003B semicolon +!3C U+003C less +!3D U+003D equal +!3E U+003E greater +!3F U+003F question +!40 U+0040 at +!41 U+0041 A +!42 U+0042 B +!43 U+0043 C +!44 U+0044 D +!45 U+0045 E +!46 U+0046 F +!47 U+0047 G +!48 U+0048 H +!49 U+0049 I +!4A U+004A J +!4B U+004B K +!4C U+004C L +!4D U+004D M +!4E U+004E N +!4F U+004F O +!50 U+0050 P +!51 U+0051 Q +!52 U+0052 R +!53 U+0053 S +!54 U+0054 T +!55 U+0055 U +!56 U+0056 V +!57 U+0057 W +!58 U+0058 X +!59 U+0059 Y +!5A U+005A Z +!5B U+005B bracketleft +!5C U+005C backslash +!5D U+005D bracketright +!5E U+005E asciicircum +!5F U+005F underscore +!60 U+0060 grave +!61 U+0061 a +!62 U+0062 b +!63 U+0063 c +!64 U+0064 d +!65 U+0065 e +!66 U+0066 f +!67 U+0067 g +!68 U+0068 h +!69 U+0069 i +!6A U+006A j +!6B U+006B k +!6C U+006C l +!6D U+006D m +!6E U+006E n +!6F U+006F o +!70 U+0070 p +!71 U+0071 q +!72 U+0072 r +!73 U+0073 s +!74 U+0074 t +!75 U+0075 u +!76 U+0076 v +!77 U+0077 w +!78 U+0078 x +!79 U+0079 y +!7A U+007A z +!7B U+007B braceleft +!7C U+007C bar +!7D U+007D braceright +!7E U+007E asciitilde +!7F U+007F .notdef +!80 U+0080 .notdef +!81 U+0081 .notdef +!82 U+0082 .notdef +!83 U+0083 .notdef +!84 U+0084 .notdef +!85 U+0085 .notdef +!86 U+0086 .notdef +!87 U+0087 .notdef +!88 U+0088 .notdef +!89 U+0089 .notdef +!8A U+008A .notdef +!8B U+008B .notdef +!8C U+008C .notdef +!8D U+008D .notdef +!8E U+008E .notdef +!8F U+008F .notdef +!90 U+0090 .notdef +!91 U+0091 .notdef +!92 U+0092 .notdef +!93 U+0093 .notdef +!94 U+0094 .notdef +!95 U+0095 .notdef +!96 U+0096 .notdef +!97 U+0097 .notdef +!98 U+0098 .notdef +!99 U+0099 .notdef +!9A U+009A .notdef +!9B U+009B .notdef +!9C U+009C .notdef +!9D U+009D .notdef +!9E U+009E .notdef +!9F U+009F .notdef +!A0 U+00A0 space +!A1 U+0104 Aogonek +!A2 U+0105 aogonek +!A3 U+0141 Lslash +!A4 U+20AC Euro +!A5 U+201E quotedblbase +!A6 U+0160 Scaron +!A7 U+00A7 section +!A8 U+0161 scaron +!A9 U+00A9 copyright +!AA U+0218 Scommaaccent +!AB U+00AB guillemotleft +!AC U+0179 Zacute +!AD U+00AD hyphen +!AE U+017A zacute +!AF U+017B Zdotaccent +!B0 U+00B0 degree +!B1 U+00B1 plusminus +!B2 U+010C Ccaron +!B3 U+0142 lslash +!B4 U+017D Zcaron +!B5 U+201D quotedblright +!B6 U+00B6 paragraph +!B7 U+00B7 periodcentered +!B8 U+017E zcaron +!B9 U+010D ccaron +!BA U+0219 scommaaccent +!BB U+00BB guillemotright +!BC U+0152 OE +!BD U+0153 oe +!BE U+0178 Ydieresis +!BF U+017C zdotaccent +!C0 U+00C0 Agrave +!C1 U+00C1 Aacute +!C2 U+00C2 Acircumflex +!C3 U+0102 Abreve +!C4 U+00C4 Adieresis +!C5 U+0106 Cacute +!C6 U+00C6 AE +!C7 U+00C7 Ccedilla +!C8 U+00C8 Egrave +!C9 U+00C9 Eacute +!CA U+00CA Ecircumflex +!CB U+00CB Edieresis +!CC U+00CC Igrave +!CD U+00CD Iacute +!CE U+00CE Icircumflex +!CF U+00CF Idieresis +!D0 U+0110 Dcroat +!D1 U+0143 Nacute +!D2 U+00D2 Ograve +!D3 U+00D3 Oacute +!D4 U+00D4 Ocircumflex +!D5 U+0150 Ohungarumlaut +!D6 U+00D6 Odieresis +!D7 U+015A Sacute +!D8 U+0170 Uhungarumlaut +!D9 U+00D9 Ugrave +!DA U+00DA Uacute +!DB U+00DB Ucircumflex +!DC U+00DC Udieresis +!DD U+0118 Eogonek +!DE U+021A Tcommaaccent +!DF U+00DF germandbls +!E0 U+00E0 agrave +!E1 U+00E1 aacute +!E2 U+00E2 acircumflex +!E3 U+0103 abreve +!E4 U+00E4 adieresis +!E5 U+0107 cacute +!E6 U+00E6 ae +!E7 U+00E7 ccedilla +!E8 U+00E8 egrave +!E9 U+00E9 eacute +!EA U+00EA ecircumflex +!EB U+00EB edieresis +!EC U+00EC igrave +!ED U+00ED iacute +!EE U+00EE icircumflex +!EF U+00EF idieresis +!F0 U+0111 dcroat +!F1 U+0144 nacute +!F2 U+00F2 ograve +!F3 U+00F3 oacute +!F4 U+00F4 ocircumflex +!F5 U+0151 ohungarumlaut +!F6 U+00F6 odieresis +!F7 U+015B sacute +!F8 U+0171 uhungarumlaut +!F9 U+00F9 ugrave +!FA U+00FA uacute +!FB U+00FB ucircumflex +!FC U+00FC udieresis +!FD U+0119 eogonek +!FE U+021B tcommaaccent +!FF U+00FF ydieresis diff --git a/include/pdf/font/makefont/iso-8859-2.map b/include/pdf/font/makefont/iso-8859-2.map new file mode 100644 index 000000000..65ae09f95 --- /dev/null +++ b/include/pdf/font/makefont/iso-8859-2.map @@ -0,0 +1,256 @@ +!00 U+0000 .notdef +!01 U+0001 .notdef +!02 U+0002 .notdef +!03 U+0003 .notdef +!04 U+0004 .notdef +!05 U+0005 .notdef +!06 U+0006 .notdef +!07 U+0007 .notdef +!08 U+0008 .notdef +!09 U+0009 .notdef +!0A U+000A .notdef +!0B U+000B .notdef +!0C U+000C .notdef +!0D U+000D .notdef +!0E U+000E .notdef +!0F U+000F .notdef +!10 U+0010 .notdef +!11 U+0011 .notdef +!12 U+0012 .notdef +!13 U+0013 .notdef +!14 U+0014 .notdef +!15 U+0015 .notdef +!16 U+0016 .notdef +!17 U+0017 .notdef +!18 U+0018 .notdef +!19 U+0019 .notdef +!1A U+001A .notdef +!1B U+001B .notdef +!1C U+001C .notdef +!1D U+001D .notdef +!1E U+001E .notdef +!1F U+001F .notdef +!20 U+0020 space +!21 U+0021 exclam +!22 U+0022 quotedbl +!23 U+0023 numbersign +!24 U+0024 dollar +!25 U+0025 percent +!26 U+0026 ampersand +!27 U+0027 quotesingle +!28 U+0028 parenleft +!29 U+0029 parenright +!2A U+002A asterisk +!2B U+002B plus +!2C U+002C comma +!2D U+002D hyphen +!2E U+002E period +!2F U+002F slash +!30 U+0030 zero +!31 U+0031 one +!32 U+0032 two +!33 U+0033 three +!34 U+0034 four +!35 U+0035 five +!36 U+0036 six +!37 U+0037 seven +!38 U+0038 eight +!39 U+0039 nine +!3A U+003A colon +!3B U+003B semicolon +!3C U+003C less +!3D U+003D equal +!3E U+003E greater +!3F U+003F question +!40 U+0040 at +!41 U+0041 A +!42 U+0042 B +!43 U+0043 C +!44 U+0044 D +!45 U+0045 E +!46 U+0046 F +!47 U+0047 G +!48 U+0048 H +!49 U+0049 I +!4A U+004A J +!4B U+004B K +!4C U+004C L +!4D U+004D M +!4E U+004E N +!4F U+004F O +!50 U+0050 P +!51 U+0051 Q +!52 U+0052 R +!53 U+0053 S +!54 U+0054 T +!55 U+0055 U +!56 U+0056 V +!57 U+0057 W +!58 U+0058 X +!59 U+0059 Y +!5A U+005A Z +!5B U+005B bracketleft +!5C U+005C backslash +!5D U+005D bracketright +!5E U+005E asciicircum +!5F U+005F underscore +!60 U+0060 grave +!61 U+0061 a +!62 U+0062 b +!63 U+0063 c +!64 U+0064 d +!65 U+0065 e +!66 U+0066 f +!67 U+0067 g +!68 U+0068 h +!69 U+0069 i +!6A U+006A j +!6B U+006B k +!6C U+006C l +!6D U+006D m +!6E U+006E n +!6F U+006F o +!70 U+0070 p +!71 U+0071 q +!72 U+0072 r +!73 U+0073 s +!74 U+0074 t +!75 U+0075 u +!76 U+0076 v +!77 U+0077 w +!78 U+0078 x +!79 U+0079 y +!7A U+007A z +!7B U+007B braceleft +!7C U+007C bar +!7D U+007D braceright +!7E U+007E asciitilde +!7F U+007F .notdef +!80 U+0080 .notdef +!81 U+0081 .notdef +!82 U+0082 .notdef +!83 U+0083 .notdef +!84 U+0084 .notdef +!85 U+0085 .notdef +!86 U+0086 .notdef +!87 U+0087 .notdef +!88 U+0088 .notdef +!89 U+0089 .notdef +!8A U+008A .notdef +!8B U+008B .notdef +!8C U+008C .notdef +!8D U+008D .notdef +!8E U+008E .notdef +!8F U+008F .notdef +!90 U+0090 .notdef +!91 U+0091 .notdef +!92 U+0092 .notdef +!93 U+0093 .notdef +!94 U+0094 .notdef +!95 U+0095 .notdef +!96 U+0096 .notdef +!97 U+0097 .notdef +!98 U+0098 .notdef +!99 U+0099 .notdef +!9A U+009A .notdef +!9B U+009B .notdef +!9C U+009C .notdef +!9D U+009D .notdef +!9E U+009E .notdef +!9F U+009F .notdef +!A0 U+00A0 space +!A1 U+0104 Aogonek +!A2 U+02D8 breve +!A3 U+0141 Lslash +!A4 U+00A4 currency +!A5 U+013D Lcaron +!A6 U+015A Sacute +!A7 U+00A7 section +!A8 U+00A8 dieresis +!A9 U+0160 Scaron +!AA U+015E Scedilla +!AB U+0164 Tcaron +!AC U+0179 Zacute +!AD U+00AD hyphen +!AE U+017D Zcaron +!AF U+017B Zdotaccent +!B0 U+00B0 degree +!B1 U+0105 aogonek +!B2 U+02DB ogonek +!B3 U+0142 lslash +!B4 U+00B4 acute +!B5 U+013E lcaron +!B6 U+015B sacute +!B7 U+02C7 caron +!B8 U+00B8 cedilla +!B9 U+0161 scaron +!BA U+015F scedilla +!BB U+0165 tcaron +!BC U+017A zacute +!BD U+02DD hungarumlaut +!BE U+017E zcaron +!BF U+017C zdotaccent +!C0 U+0154 Racute +!C1 U+00C1 Aacute +!C2 U+00C2 Acircumflex +!C3 U+0102 Abreve +!C4 U+00C4 Adieresis +!C5 U+0139 Lacute +!C6 U+0106 Cacute +!C7 U+00C7 Ccedilla +!C8 U+010C Ccaron +!C9 U+00C9 Eacute +!CA U+0118 Eogonek +!CB U+00CB Edieresis +!CC U+011A Ecaron +!CD U+00CD Iacute +!CE U+00CE Icircumflex +!CF U+010E Dcaron +!D0 U+0110 Dcroat +!D1 U+0143 Nacute +!D2 U+0147 Ncaron +!D3 U+00D3 Oacute +!D4 U+00D4 Ocircumflex +!D5 U+0150 Ohungarumlaut +!D6 U+00D6 Odieresis +!D7 U+00D7 multiply +!D8 U+0158 Rcaron +!D9 U+016E Uring +!DA U+00DA Uacute +!DB U+0170 Uhungarumlaut +!DC U+00DC Udieresis +!DD U+00DD Yacute +!DE U+0162 Tcommaaccent +!DF U+00DF germandbls +!E0 U+0155 racute +!E1 U+00E1 aacute +!E2 U+00E2 acircumflex +!E3 U+0103 abreve +!E4 U+00E4 adieresis +!E5 U+013A lacute +!E6 U+0107 cacute +!E7 U+00E7 ccedilla +!E8 U+010D ccaron +!E9 U+00E9 eacute +!EA U+0119 eogonek +!EB U+00EB edieresis +!EC U+011B ecaron +!ED U+00ED iacute +!EE U+00EE icircumflex +!EF U+010F dcaron +!F0 U+0111 dcroat +!F1 U+0144 nacute +!F2 U+0148 ncaron +!F3 U+00F3 oacute +!F4 U+00F4 ocircumflex +!F5 U+0151 ohungarumlaut +!F6 U+00F6 odieresis +!F7 U+00F7 divide +!F8 U+0159 rcaron +!F9 U+016F uring +!FA U+00FA uacute +!FB U+0171 uhungarumlaut +!FC U+00FC udieresis +!FD U+00FD yacute +!FE U+0163 tcommaaccent +!FF U+02D9 dotaccent diff --git a/include/pdf/font/makefont/iso-8859-4.map b/include/pdf/font/makefont/iso-8859-4.map new file mode 100644 index 000000000..a7d87bf3e --- /dev/null +++ b/include/pdf/font/makefont/iso-8859-4.map @@ -0,0 +1,256 @@ +!00 U+0000 .notdef +!01 U+0001 .notdef +!02 U+0002 .notdef +!03 U+0003 .notdef +!04 U+0004 .notdef +!05 U+0005 .notdef +!06 U+0006 .notdef +!07 U+0007 .notdef +!08 U+0008 .notdef +!09 U+0009 .notdef +!0A U+000A .notdef +!0B U+000B .notdef +!0C U+000C .notdef +!0D U+000D .notdef +!0E U+000E .notdef +!0F U+000F .notdef +!10 U+0010 .notdef +!11 U+0011 .notdef +!12 U+0012 .notdef +!13 U+0013 .notdef +!14 U+0014 .notdef +!15 U+0015 .notdef +!16 U+0016 .notdef +!17 U+0017 .notdef +!18 U+0018 .notdef +!19 U+0019 .notdef +!1A U+001A .notdef +!1B U+001B .notdef +!1C U+001C .notdef +!1D U+001D .notdef +!1E U+001E .notdef +!1F U+001F .notdef +!20 U+0020 space +!21 U+0021 exclam +!22 U+0022 quotedbl +!23 U+0023 numbersign +!24 U+0024 dollar +!25 U+0025 percent +!26 U+0026 ampersand +!27 U+0027 quotesingle +!28 U+0028 parenleft +!29 U+0029 parenright +!2A U+002A asterisk +!2B U+002B plus +!2C U+002C comma +!2D U+002D hyphen +!2E U+002E period +!2F U+002F slash +!30 U+0030 zero +!31 U+0031 one +!32 U+0032 two +!33 U+0033 three +!34 U+0034 four +!35 U+0035 five +!36 U+0036 six +!37 U+0037 seven +!38 U+0038 eight +!39 U+0039 nine +!3A U+003A colon +!3B U+003B semicolon +!3C U+003C less +!3D U+003D equal +!3E U+003E greater +!3F U+003F question +!40 U+0040 at +!41 U+0041 A +!42 U+0042 B +!43 U+0043 C +!44 U+0044 D +!45 U+0045 E +!46 U+0046 F +!47 U+0047 G +!48 U+0048 H +!49 U+0049 I +!4A U+004A J +!4B U+004B K +!4C U+004C L +!4D U+004D M +!4E U+004E N +!4F U+004F O +!50 U+0050 P +!51 U+0051 Q +!52 U+0052 R +!53 U+0053 S +!54 U+0054 T +!55 U+0055 U +!56 U+0056 V +!57 U+0057 W +!58 U+0058 X +!59 U+0059 Y +!5A U+005A Z +!5B U+005B bracketleft +!5C U+005C backslash +!5D U+005D bracketright +!5E U+005E asciicircum +!5F U+005F underscore +!60 U+0060 grave +!61 U+0061 a +!62 U+0062 b +!63 U+0063 c +!64 U+0064 d +!65 U+0065 e +!66 U+0066 f +!67 U+0067 g +!68 U+0068 h +!69 U+0069 i +!6A U+006A j +!6B U+006B k +!6C U+006C l +!6D U+006D m +!6E U+006E n +!6F U+006F o +!70 U+0070 p +!71 U+0071 q +!72 U+0072 r +!73 U+0073 s +!74 U+0074 t +!75 U+0075 u +!76 U+0076 v +!77 U+0077 w +!78 U+0078 x +!79 U+0079 y +!7A U+007A z +!7B U+007B braceleft +!7C U+007C bar +!7D U+007D braceright +!7E U+007E asciitilde +!7F U+007F .notdef +!80 U+0080 .notdef +!81 U+0081 .notdef +!82 U+0082 .notdef +!83 U+0083 .notdef +!84 U+0084 .notdef +!85 U+0085 .notdef +!86 U+0086 .notdef +!87 U+0087 .notdef +!88 U+0088 .notdef +!89 U+0089 .notdef +!8A U+008A .notdef +!8B U+008B .notdef +!8C U+008C .notdef +!8D U+008D .notdef +!8E U+008E .notdef +!8F U+008F .notdef +!90 U+0090 .notdef +!91 U+0091 .notdef +!92 U+0092 .notdef +!93 U+0093 .notdef +!94 U+0094 .notdef +!95 U+0095 .notdef +!96 U+0096 .notdef +!97 U+0097 .notdef +!98 U+0098 .notdef +!99 U+0099 .notdef +!9A U+009A .notdef +!9B U+009B .notdef +!9C U+009C .notdef +!9D U+009D .notdef +!9E U+009E .notdef +!9F U+009F .notdef +!A0 U+00A0 space +!A1 U+0104 Aogonek +!A2 U+0138 kgreenlandic +!A3 U+0156 Rcommaaccent +!A4 U+00A4 currency +!A5 U+0128 Itilde +!A6 U+013B Lcommaaccent +!A7 U+00A7 section +!A8 U+00A8 dieresis +!A9 U+0160 Scaron +!AA U+0112 Emacron +!AB U+0122 Gcommaaccent +!AC U+0166 Tbar +!AD U+00AD hyphen +!AE U+017D Zcaron +!AF U+00AF macron +!B0 U+00B0 degree +!B1 U+0105 aogonek +!B2 U+02DB ogonek +!B3 U+0157 rcommaaccent +!B4 U+00B4 acute +!B5 U+0129 itilde +!B6 U+013C lcommaaccent +!B7 U+02C7 caron +!B8 U+00B8 cedilla +!B9 U+0161 scaron +!BA U+0113 emacron +!BB U+0123 gcommaaccent +!BC U+0167 tbar +!BD U+014A Eng +!BE U+017E zcaron +!BF U+014B eng +!C0 U+0100 Amacron +!C1 U+00C1 Aacute +!C2 U+00C2 Acircumflex +!C3 U+00C3 Atilde +!C4 U+00C4 Adieresis +!C5 U+00C5 Aring +!C6 U+00C6 AE +!C7 U+012E Iogonek +!C8 U+010C Ccaron +!C9 U+00C9 Eacute +!CA U+0118 Eogonek +!CB U+00CB Edieresis +!CC U+0116 Edotaccent +!CD U+00CD Iacute +!CE U+00CE Icircumflex +!CF U+012A Imacron +!D0 U+0110 Dcroat +!D1 U+0145 Ncommaaccent +!D2 U+014C Omacron +!D3 U+0136 Kcommaaccent +!D4 U+00D4 Ocircumflex +!D5 U+00D5 Otilde +!D6 U+00D6 Odieresis +!D7 U+00D7 multiply +!D8 U+00D8 Oslash +!D9 U+0172 Uogonek +!DA U+00DA Uacute +!DB U+00DB Ucircumflex +!DC U+00DC Udieresis +!DD U+0168 Utilde +!DE U+016A Umacron +!DF U+00DF germandbls +!E0 U+0101 amacron +!E1 U+00E1 aacute +!E2 U+00E2 acircumflex +!E3 U+00E3 atilde +!E4 U+00E4 adieresis +!E5 U+00E5 aring +!E6 U+00E6 ae +!E7 U+012F iogonek +!E8 U+010D ccaron +!E9 U+00E9 eacute +!EA U+0119 eogonek +!EB U+00EB edieresis +!EC U+0117 edotaccent +!ED U+00ED iacute +!EE U+00EE icircumflex +!EF U+012B imacron +!F0 U+0111 dcroat +!F1 U+0146 ncommaaccent +!F2 U+014D omacron +!F3 U+0137 kcommaaccent +!F4 U+00F4 ocircumflex +!F5 U+00F5 otilde +!F6 U+00F6 odieresis +!F7 U+00F7 divide +!F8 U+00F8 oslash +!F9 U+0173 uogonek +!FA U+00FA uacute +!FB U+00FB ucircumflex +!FC U+00FC udieresis +!FD U+0169 utilde +!FE U+016B umacron +!FF U+02D9 dotaccent diff --git a/include/pdf/font/makefont/iso-8859-5.map b/include/pdf/font/makefont/iso-8859-5.map new file mode 100644 index 000000000..f9cd4edcf --- /dev/null +++ b/include/pdf/font/makefont/iso-8859-5.map @@ -0,0 +1,256 @@ +!00 U+0000 .notdef +!01 U+0001 .notdef +!02 U+0002 .notdef +!03 U+0003 .notdef +!04 U+0004 .notdef +!05 U+0005 .notdef +!06 U+0006 .notdef +!07 U+0007 .notdef +!08 U+0008 .notdef +!09 U+0009 .notdef +!0A U+000A .notdef +!0B U+000B .notdef +!0C U+000C .notdef +!0D U+000D .notdef +!0E U+000E .notdef +!0F U+000F .notdef +!10 U+0010 .notdef +!11 U+0011 .notdef +!12 U+0012 .notdef +!13 U+0013 .notdef +!14 U+0014 .notdef +!15 U+0015 .notdef +!16 U+0016 .notdef +!17 U+0017 .notdef +!18 U+0018 .notdef +!19 U+0019 .notdef +!1A U+001A .notdef +!1B U+001B .notdef +!1C U+001C .notdef +!1D U+001D .notdef +!1E U+001E .notdef +!1F U+001F .notdef +!20 U+0020 space +!21 U+0021 exclam +!22 U+0022 quotedbl +!23 U+0023 numbersign +!24 U+0024 dollar +!25 U+0025 percent +!26 U+0026 ampersand +!27 U+0027 quotesingle +!28 U+0028 parenleft +!29 U+0029 parenright +!2A U+002A asterisk +!2B U+002B plus +!2C U+002C comma +!2D U+002D hyphen +!2E U+002E period +!2F U+002F slash +!30 U+0030 zero +!31 U+0031 one +!32 U+0032 two +!33 U+0033 three +!34 U+0034 four +!35 U+0035 five +!36 U+0036 six +!37 U+0037 seven +!38 U+0038 eight +!39 U+0039 nine +!3A U+003A colon +!3B U+003B semicolon +!3C U+003C less +!3D U+003D equal +!3E U+003E greater +!3F U+003F question +!40 U+0040 at +!41 U+0041 A +!42 U+0042 B +!43 U+0043 C +!44 U+0044 D +!45 U+0045 E +!46 U+0046 F +!47 U+0047 G +!48 U+0048 H +!49 U+0049 I +!4A U+004A J +!4B U+004B K +!4C U+004C L +!4D U+004D M +!4E U+004E N +!4F U+004F O +!50 U+0050 P +!51 U+0051 Q +!52 U+0052 R +!53 U+0053 S +!54 U+0054 T +!55 U+0055 U +!56 U+0056 V +!57 U+0057 W +!58 U+0058 X +!59 U+0059 Y +!5A U+005A Z +!5B U+005B bracketleft +!5C U+005C backslash +!5D U+005D bracketright +!5E U+005E asciicircum +!5F U+005F underscore +!60 U+0060 grave +!61 U+0061 a +!62 U+0062 b +!63 U+0063 c +!64 U+0064 d +!65 U+0065 e +!66 U+0066 f +!67 U+0067 g +!68 U+0068 h +!69 U+0069 i +!6A U+006A j +!6B U+006B k +!6C U+006C l +!6D U+006D m +!6E U+006E n +!6F U+006F o +!70 U+0070 p +!71 U+0071 q +!72 U+0072 r +!73 U+0073 s +!74 U+0074 t +!75 U+0075 u +!76 U+0076 v +!77 U+0077 w +!78 U+0078 x +!79 U+0079 y +!7A U+007A z +!7B U+007B braceleft +!7C U+007C bar +!7D U+007D braceright +!7E U+007E asciitilde +!7F U+007F .notdef +!80 U+0080 .notdef +!81 U+0081 .notdef +!82 U+0082 .notdef +!83 U+0083 .notdef +!84 U+0084 .notdef +!85 U+0085 .notdef +!86 U+0086 .notdef +!87 U+0087 .notdef +!88 U+0088 .notdef +!89 U+0089 .notdef +!8A U+008A .notdef +!8B U+008B .notdef +!8C U+008C .notdef +!8D U+008D .notdef +!8E U+008E .notdef +!8F U+008F .notdef +!90 U+0090 .notdef +!91 U+0091 .notdef +!92 U+0092 .notdef +!93 U+0093 .notdef +!94 U+0094 .notdef +!95 U+0095 .notdef +!96 U+0096 .notdef +!97 U+0097 .notdef +!98 U+0098 .notdef +!99 U+0099 .notdef +!9A U+009A .notdef +!9B U+009B .notdef +!9C U+009C .notdef +!9D U+009D .notdef +!9E U+009E .notdef +!9F U+009F .notdef +!A0 U+00A0 space +!A1 U+0401 afii10023 +!A2 U+0402 afii10051 +!A3 U+0403 afii10052 +!A4 U+0404 afii10053 +!A5 U+0405 afii10054 +!A6 U+0406 afii10055 +!A7 U+0407 afii10056 +!A8 U+0408 afii10057 +!A9 U+0409 afii10058 +!AA U+040A afii10059 +!AB U+040B afii10060 +!AC U+040C afii10061 +!AD U+00AD hyphen +!AE U+040E afii10062 +!AF U+040F afii10145 +!B0 U+0410 afii10017 +!B1 U+0411 afii10018 +!B2 U+0412 afii10019 +!B3 U+0413 afii10020 +!B4 U+0414 afii10021 +!B5 U+0415 afii10022 +!B6 U+0416 afii10024 +!B7 U+0417 afii10025 +!B8 U+0418 afii10026 +!B9 U+0419 afii10027 +!BA U+041A afii10028 +!BB U+041B afii10029 +!BC U+041C afii10030 +!BD U+041D afii10031 +!BE U+041E afii10032 +!BF U+041F afii10033 +!C0 U+0420 afii10034 +!C1 U+0421 afii10035 +!C2 U+0422 afii10036 +!C3 U+0423 afii10037 +!C4 U+0424 afii10038 +!C5 U+0425 afii10039 +!C6 U+0426 afii10040 +!C7 U+0427 afii10041 +!C8 U+0428 afii10042 +!C9 U+0429 afii10043 +!CA U+042A afii10044 +!CB U+042B afii10045 +!CC U+042C afii10046 +!CD U+042D afii10047 +!CE U+042E afii10048 +!CF U+042F afii10049 +!D0 U+0430 afii10065 +!D1 U+0431 afii10066 +!D2 U+0432 afii10067 +!D3 U+0433 afii10068 +!D4 U+0434 afii10069 +!D5 U+0435 afii10070 +!D6 U+0436 afii10072 +!D7 U+0437 afii10073 +!D8 U+0438 afii10074 +!D9 U+0439 afii10075 +!DA U+043A afii10076 +!DB U+043B afii10077 +!DC U+043C afii10078 +!DD U+043D afii10079 +!DE U+043E afii10080 +!DF U+043F afii10081 +!E0 U+0440 afii10082 +!E1 U+0441 afii10083 +!E2 U+0442 afii10084 +!E3 U+0443 afii10085 +!E4 U+0444 afii10086 +!E5 U+0445 afii10087 +!E6 U+0446 afii10088 +!E7 U+0447 afii10089 +!E8 U+0448 afii10090 +!E9 U+0449 afii10091 +!EA U+044A afii10092 +!EB U+044B afii10093 +!EC U+044C afii10094 +!ED U+044D afii10095 +!EE U+044E afii10096 +!EF U+044F afii10097 +!F0 U+2116 afii61352 +!F1 U+0451 afii10071 +!F2 U+0452 afii10099 +!F3 U+0453 afii10100 +!F4 U+0454 afii10101 +!F5 U+0455 afii10102 +!F6 U+0456 afii10103 +!F7 U+0457 afii10104 +!F8 U+0458 afii10105 +!F9 U+0459 afii10106 +!FA U+045A afii10107 +!FB U+045B afii10108 +!FC U+045C afii10109 +!FD U+00A7 section +!FE U+045E afii10110 +!FF U+045F afii10193 diff --git a/include/pdf/font/makefont/iso-8859-7.map b/include/pdf/font/makefont/iso-8859-7.map new file mode 100644 index 000000000..e163796b1 --- /dev/null +++ b/include/pdf/font/makefont/iso-8859-7.map @@ -0,0 +1,250 @@ +!00 U+0000 .notdef +!01 U+0001 .notdef +!02 U+0002 .notdef +!03 U+0003 .notdef +!04 U+0004 .notdef +!05 U+0005 .notdef +!06 U+0006 .notdef +!07 U+0007 .notdef +!08 U+0008 .notdef +!09 U+0009 .notdef +!0A U+000A .notdef +!0B U+000B .notdef +!0C U+000C .notdef +!0D U+000D .notdef +!0E U+000E .notdef +!0F U+000F .notdef +!10 U+0010 .notdef +!11 U+0011 .notdef +!12 U+0012 .notdef +!13 U+0013 .notdef +!14 U+0014 .notdef +!15 U+0015 .notdef +!16 U+0016 .notdef +!17 U+0017 .notdef +!18 U+0018 .notdef +!19 U+0019 .notdef +!1A U+001A .notdef +!1B U+001B .notdef +!1C U+001C .notdef +!1D U+001D .notdef +!1E U+001E .notdef +!1F U+001F .notdef +!20 U+0020 space +!21 U+0021 exclam +!22 U+0022 quotedbl +!23 U+0023 numbersign +!24 U+0024 dollar +!25 U+0025 percent +!26 U+0026 ampersand +!27 U+0027 quotesingle +!28 U+0028 parenleft +!29 U+0029 parenright +!2A U+002A asterisk +!2B U+002B plus +!2C U+002C comma +!2D U+002D hyphen +!2E U+002E period +!2F U+002F slash +!30 U+0030 zero +!31 U+0031 one +!32 U+0032 two +!33 U+0033 three +!34 U+0034 four +!35 U+0035 five +!36 U+0036 six +!37 U+0037 seven +!38 U+0038 eight +!39 U+0039 nine +!3A U+003A colon +!3B U+003B semicolon +!3C U+003C less +!3D U+003D equal +!3E U+003E greater +!3F U+003F question +!40 U+0040 at +!41 U+0041 A +!42 U+0042 B +!43 U+0043 C +!44 U+0044 D +!45 U+0045 E +!46 U+0046 F +!47 U+0047 G +!48 U+0048 H +!49 U+0049 I +!4A U+004A J +!4B U+004B K +!4C U+004C L +!4D U+004D M +!4E U+004E N +!4F U+004F O +!50 U+0050 P +!51 U+0051 Q +!52 U+0052 R +!53 U+0053 S +!54 U+0054 T +!55 U+0055 U +!56 U+0056 V +!57 U+0057 W +!58 U+0058 X +!59 U+0059 Y +!5A U+005A Z +!5B U+005B bracketleft +!5C U+005C backslash +!5D U+005D bracketright +!5E U+005E asciicircum +!5F U+005F underscore +!60 U+0060 grave +!61 U+0061 a +!62 U+0062 b +!63 U+0063 c +!64 U+0064 d +!65 U+0065 e +!66 U+0066 f +!67 U+0067 g +!68 U+0068 h +!69 U+0069 i +!6A U+006A j +!6B U+006B k +!6C U+006C l +!6D U+006D m +!6E U+006E n +!6F U+006F o +!70 U+0070 p +!71 U+0071 q +!72 U+0072 r +!73 U+0073 s +!74 U+0074 t +!75 U+0075 u +!76 U+0076 v +!77 U+0077 w +!78 U+0078 x +!79 U+0079 y +!7A U+007A z +!7B U+007B braceleft +!7C U+007C bar +!7D U+007D braceright +!7E U+007E asciitilde +!7F U+007F .notdef +!80 U+0080 .notdef +!81 U+0081 .notdef +!82 U+0082 .notdef +!83 U+0083 .notdef +!84 U+0084 .notdef +!85 U+0085 .notdef +!86 U+0086 .notdef +!87 U+0087 .notdef +!88 U+0088 .notdef +!89 U+0089 .notdef +!8A U+008A .notdef +!8B U+008B .notdef +!8C U+008C .notdef +!8D U+008D .notdef +!8E U+008E .notdef +!8F U+008F .notdef +!90 U+0090 .notdef +!91 U+0091 .notdef +!92 U+0092 .notdef +!93 U+0093 .notdef +!94 U+0094 .notdef +!95 U+0095 .notdef +!96 U+0096 .notdef +!97 U+0097 .notdef +!98 U+0098 .notdef +!99 U+0099 .notdef +!9A U+009A .notdef +!9B U+009B .notdef +!9C U+009C .notdef +!9D U+009D .notdef +!9E U+009E .notdef +!9F U+009F .notdef +!A0 U+00A0 space +!A1 U+2018 quoteleft +!A2 U+2019 quoteright +!A3 U+00A3 sterling +!A6 U+00A6 brokenbar +!A7 U+00A7 section +!A8 U+00A8 dieresis +!A9 U+00A9 copyright +!AB U+00AB guillemotleft +!AC U+00AC logicalnot +!AD U+00AD hyphen +!AF U+2015 afii00208 +!B0 U+00B0 degree +!B1 U+00B1 plusminus +!B2 U+00B2 twosuperior +!B3 U+00B3 threesuperior +!B4 U+0384 tonos +!B5 U+0385 dieresistonos +!B6 U+0386 Alphatonos +!B7 U+00B7 periodcentered +!B8 U+0388 Epsilontonos +!B9 U+0389 Etatonos +!BA U+038A Iotatonos +!BB U+00BB guillemotright +!BC U+038C Omicrontonos +!BD U+00BD onehalf +!BE U+038E Upsilontonos +!BF U+038F Omegatonos +!C0 U+0390 iotadieresistonos +!C1 U+0391 Alpha +!C2 U+0392 Beta +!C3 U+0393 Gamma +!C4 U+0394 Delta +!C5 U+0395 Epsilon +!C6 U+0396 Zeta +!C7 U+0397 Eta +!C8 U+0398 Theta +!C9 U+0399 Iota +!CA U+039A Kappa +!CB U+039B Lambda +!CC U+039C Mu +!CD U+039D Nu +!CE U+039E Xi +!CF U+039F Omicron +!D0 U+03A0 Pi +!D1 U+03A1 Rho +!D3 U+03A3 Sigma +!D4 U+03A4 Tau +!D5 U+03A5 Upsilon +!D6 U+03A6 Phi +!D7 U+03A7 Chi +!D8 U+03A8 Psi +!D9 U+03A9 Omega +!DA U+03AA Iotadieresis +!DB U+03AB Upsilondieresis +!DC U+03AC alphatonos +!DD U+03AD epsilontonos +!DE U+03AE etatonos +!DF U+03AF iotatonos +!E0 U+03B0 upsilondieresistonos +!E1 U+03B1 alpha +!E2 U+03B2 beta +!E3 U+03B3 gamma +!E4 U+03B4 delta +!E5 U+03B5 epsilon +!E6 U+03B6 zeta +!E7 U+03B7 eta +!E8 U+03B8 theta +!E9 U+03B9 iota +!EA U+03BA kappa +!EB U+03BB lambda +!EC U+03BC mu +!ED U+03BD nu +!EE U+03BE xi +!EF U+03BF omicron +!F0 U+03C0 pi +!F1 U+03C1 rho +!F2 U+03C2 sigma1 +!F3 U+03C3 sigma +!F4 U+03C4 tau +!F5 U+03C5 upsilon +!F6 U+03C6 phi +!F7 U+03C7 chi +!F8 U+03C8 psi +!F9 U+03C9 omega +!FA U+03CA iotadieresis +!FB U+03CB upsilondieresis +!FC U+03CC omicrontonos +!FD U+03CD upsilontonos +!FE U+03CE omegatonos diff --git a/include/pdf/font/makefont/iso-8859-9.map b/include/pdf/font/makefont/iso-8859-9.map new file mode 100644 index 000000000..48c123ae6 --- /dev/null +++ b/include/pdf/font/makefont/iso-8859-9.map @@ -0,0 +1,256 @@ +!00 U+0000 .notdef +!01 U+0001 .notdef +!02 U+0002 .notdef +!03 U+0003 .notdef +!04 U+0004 .notdef +!05 U+0005 .notdef +!06 U+0006 .notdef +!07 U+0007 .notdef +!08 U+0008 .notdef +!09 U+0009 .notdef +!0A U+000A .notdef +!0B U+000B .notdef +!0C U+000C .notdef +!0D U+000D .notdef +!0E U+000E .notdef +!0F U+000F .notdef +!10 U+0010 .notdef +!11 U+0011 .notdef +!12 U+0012 .notdef +!13 U+0013 .notdef +!14 U+0014 .notdef +!15 U+0015 .notdef +!16 U+0016 .notdef +!17 U+0017 .notdef +!18 U+0018 .notdef +!19 U+0019 .notdef +!1A U+001A .notdef +!1B U+001B .notdef +!1C U+001C .notdef +!1D U+001D .notdef +!1E U+001E .notdef +!1F U+001F .notdef +!20 U+0020 space +!21 U+0021 exclam +!22 U+0022 quotedbl +!23 U+0023 numbersign +!24 U+0024 dollar +!25 U+0025 percent +!26 U+0026 ampersand +!27 U+0027 quotesingle +!28 U+0028 parenleft +!29 U+0029 parenright +!2A U+002A asterisk +!2B U+002B plus +!2C U+002C comma +!2D U+002D hyphen +!2E U+002E period +!2F U+002F slash +!30 U+0030 zero +!31 U+0031 one +!32 U+0032 two +!33 U+0033 three +!34 U+0034 four +!35 U+0035 five +!36 U+0036 six +!37 U+0037 seven +!38 U+0038 eight +!39 U+0039 nine +!3A U+003A colon +!3B U+003B semicolon +!3C U+003C less +!3D U+003D equal +!3E U+003E greater +!3F U+003F question +!40 U+0040 at +!41 U+0041 A +!42 U+0042 B +!43 U+0043 C +!44 U+0044 D +!45 U+0045 E +!46 U+0046 F +!47 U+0047 G +!48 U+0048 H +!49 U+0049 I +!4A U+004A J +!4B U+004B K +!4C U+004C L +!4D U+004D M +!4E U+004E N +!4F U+004F O +!50 U+0050 P +!51 U+0051 Q +!52 U+0052 R +!53 U+0053 S +!54 U+0054 T +!55 U+0055 U +!56 U+0056 V +!57 U+0057 W +!58 U+0058 X +!59 U+0059 Y +!5A U+005A Z +!5B U+005B bracketleft +!5C U+005C backslash +!5D U+005D bracketright +!5E U+005E asciicircum +!5F U+005F underscore +!60 U+0060 grave +!61 U+0061 a +!62 U+0062 b +!63 U+0063 c +!64 U+0064 d +!65 U+0065 e +!66 U+0066 f +!67 U+0067 g +!68 U+0068 h +!69 U+0069 i +!6A U+006A j +!6B U+006B k +!6C U+006C l +!6D U+006D m +!6E U+006E n +!6F U+006F o +!70 U+0070 p +!71 U+0071 q +!72 U+0072 r +!73 U+0073 s +!74 U+0074 t +!75 U+0075 u +!76 U+0076 v +!77 U+0077 w +!78 U+0078 x +!79 U+0079 y +!7A U+007A z +!7B U+007B braceleft +!7C U+007C bar +!7D U+007D braceright +!7E U+007E asciitilde +!7F U+007F .notdef +!80 U+0080 .notdef +!81 U+0081 .notdef +!82 U+0082 .notdef +!83 U+0083 .notdef +!84 U+0084 .notdef +!85 U+0085 .notdef +!86 U+0086 .notdef +!87 U+0087 .notdef +!88 U+0088 .notdef +!89 U+0089 .notdef +!8A U+008A .notdef +!8B U+008B .notdef +!8C U+008C .notdef +!8D U+008D .notdef +!8E U+008E .notdef +!8F U+008F .notdef +!90 U+0090 .notdef +!91 U+0091 .notdef +!92 U+0092 .notdef +!93 U+0093 .notdef +!94 U+0094 .notdef +!95 U+0095 .notdef +!96 U+0096 .notdef +!97 U+0097 .notdef +!98 U+0098 .notdef +!99 U+0099 .notdef +!9A U+009A .notdef +!9B U+009B .notdef +!9C U+009C .notdef +!9D U+009D .notdef +!9E U+009E .notdef +!9F U+009F .notdef +!A0 U+00A0 space +!A1 U+00A1 exclamdown +!A2 U+00A2 cent +!A3 U+00A3 sterling +!A4 U+00A4 currency +!A5 U+00A5 yen +!A6 U+00A6 brokenbar +!A7 U+00A7 section +!A8 U+00A8 dieresis +!A9 U+00A9 copyright +!AA U+00AA ordfeminine +!AB U+00AB guillemotleft +!AC U+00AC logicalnot +!AD U+00AD hyphen +!AE U+00AE registered +!AF U+00AF macron +!B0 U+00B0 degree +!B1 U+00B1 plusminus +!B2 U+00B2 twosuperior +!B3 U+00B3 threesuperior +!B4 U+00B4 acute +!B5 U+00B5 mu +!B6 U+00B6 paragraph +!B7 U+00B7 periodcentered +!B8 U+00B8 cedilla +!B9 U+00B9 onesuperior +!BA U+00BA ordmasculine +!BB U+00BB guillemotright +!BC U+00BC onequarter +!BD U+00BD onehalf +!BE U+00BE threequarters +!BF U+00BF questiondown +!C0 U+00C0 Agrave +!C1 U+00C1 Aacute +!C2 U+00C2 Acircumflex +!C3 U+00C3 Atilde +!C4 U+00C4 Adieresis +!C5 U+00C5 Aring +!C6 U+00C6 AE +!C7 U+00C7 Ccedilla +!C8 U+00C8 Egrave +!C9 U+00C9 Eacute +!CA U+00CA Ecircumflex +!CB U+00CB Edieresis +!CC U+00CC Igrave +!CD U+00CD Iacute +!CE U+00CE Icircumflex +!CF U+00CF Idieresis +!D0 U+011E Gbreve +!D1 U+00D1 Ntilde +!D2 U+00D2 Ograve +!D3 U+00D3 Oacute +!D4 U+00D4 Ocircumflex +!D5 U+00D5 Otilde +!D6 U+00D6 Odieresis +!D7 U+00D7 multiply +!D8 U+00D8 Oslash +!D9 U+00D9 Ugrave +!DA U+00DA Uacute +!DB U+00DB Ucircumflex +!DC U+00DC Udieresis +!DD U+0130 Idotaccent +!DE U+015E Scedilla +!DF U+00DF germandbls +!E0 U+00E0 agrave +!E1 U+00E1 aacute +!E2 U+00E2 acircumflex +!E3 U+00E3 atilde +!E4 U+00E4 adieresis +!E5 U+00E5 aring +!E6 U+00E6 ae +!E7 U+00E7 ccedilla +!E8 U+00E8 egrave +!E9 U+00E9 eacute +!EA U+00EA ecircumflex +!EB U+00EB edieresis +!EC U+00EC igrave +!ED U+00ED iacute +!EE U+00EE icircumflex +!EF U+00EF idieresis +!F0 U+011F gbreve +!F1 U+00F1 ntilde +!F2 U+00F2 ograve +!F3 U+00F3 oacute +!F4 U+00F4 ocircumflex +!F5 U+00F5 otilde +!F6 U+00F6 odieresis +!F7 U+00F7 divide +!F8 U+00F8 oslash +!F9 U+00F9 ugrave +!FA U+00FA uacute +!FB U+00FB ucircumflex +!FC U+00FC udieresis +!FD U+0131 dotlessi +!FE U+015F scedilla +!FF U+00FF ydieresis diff --git a/include/pdf/font/makefont/koi8-r.map b/include/pdf/font/makefont/koi8-r.map new file mode 100644 index 000000000..6ad5d05d0 --- /dev/null +++ b/include/pdf/font/makefont/koi8-r.map @@ -0,0 +1,256 @@ +!00 U+0000 .notdef +!01 U+0001 .notdef +!02 U+0002 .notdef +!03 U+0003 .notdef +!04 U+0004 .notdef +!05 U+0005 .notdef +!06 U+0006 .notdef +!07 U+0007 .notdef +!08 U+0008 .notdef +!09 U+0009 .notdef +!0A U+000A .notdef +!0B U+000B .notdef +!0C U+000C .notdef +!0D U+000D .notdef +!0E U+000E .notdef +!0F U+000F .notdef +!10 U+0010 .notdef +!11 U+0011 .notdef +!12 U+0012 .notdef +!13 U+0013 .notdef +!14 U+0014 .notdef +!15 U+0015 .notdef +!16 U+0016 .notdef +!17 U+0017 .notdef +!18 U+0018 .notdef +!19 U+0019 .notdef +!1A U+001A .notdef +!1B U+001B .notdef +!1C U+001C .notdef +!1D U+001D .notdef +!1E U+001E .notdef +!1F U+001F .notdef +!20 U+0020 space +!21 U+0021 exclam +!22 U+0022 quotedbl +!23 U+0023 numbersign +!24 U+0024 dollar +!25 U+0025 percent +!26 U+0026 ampersand +!27 U+0027 quotesingle +!28 U+0028 parenleft +!29 U+0029 parenright +!2A U+002A asterisk +!2B U+002B plus +!2C U+002C comma +!2D U+002D hyphen +!2E U+002E period +!2F U+002F slash +!30 U+0030 zero +!31 U+0031 one +!32 U+0032 two +!33 U+0033 three +!34 U+0034 four +!35 U+0035 five +!36 U+0036 six +!37 U+0037 seven +!38 U+0038 eight +!39 U+0039 nine +!3A U+003A colon +!3B U+003B semicolon +!3C U+003C less +!3D U+003D equal +!3E U+003E greater +!3F U+003F question +!40 U+0040 at +!41 U+0041 A +!42 U+0042 B +!43 U+0043 C +!44 U+0044 D +!45 U+0045 E +!46 U+0046 F +!47 U+0047 G +!48 U+0048 H +!49 U+0049 I +!4A U+004A J +!4B U+004B K +!4C U+004C L +!4D U+004D M +!4E U+004E N +!4F U+004F O +!50 U+0050 P +!51 U+0051 Q +!52 U+0052 R +!53 U+0053 S +!54 U+0054 T +!55 U+0055 U +!56 U+0056 V +!57 U+0057 W +!58 U+0058 X +!59 U+0059 Y +!5A U+005A Z +!5B U+005B bracketleft +!5C U+005C backslash +!5D U+005D bracketright +!5E U+005E asciicircum +!5F U+005F underscore +!60 U+0060 grave +!61 U+0061 a +!62 U+0062 b +!63 U+0063 c +!64 U+0064 d +!65 U+0065 e +!66 U+0066 f +!67 U+0067 g +!68 U+0068 h +!69 U+0069 i +!6A U+006A j +!6B U+006B k +!6C U+006C l +!6D U+006D m +!6E U+006E n +!6F U+006F o +!70 U+0070 p +!71 U+0071 q +!72 U+0072 r +!73 U+0073 s +!74 U+0074 t +!75 U+0075 u +!76 U+0076 v +!77 U+0077 w +!78 U+0078 x +!79 U+0079 y +!7A U+007A z +!7B U+007B braceleft +!7C U+007C bar +!7D U+007D braceright +!7E U+007E asciitilde +!7F U+007F .notdef +!80 U+2500 SF100000 +!81 U+2502 SF110000 +!82 U+250C SF010000 +!83 U+2510 SF030000 +!84 U+2514 SF020000 +!85 U+2518 SF040000 +!86 U+251C SF080000 +!87 U+2524 SF090000 +!88 U+252C SF060000 +!89 U+2534 SF070000 +!8A U+253C SF050000 +!8B U+2580 upblock +!8C U+2584 dnblock +!8D U+2588 block +!8E U+258C lfblock +!8F U+2590 rtblock +!90 U+2591 ltshade +!91 U+2592 shade +!92 U+2593 dkshade +!93 U+2320 integraltp +!94 U+25A0 filledbox +!95 U+2219 periodcentered +!96 U+221A radical +!97 U+2248 approxequal +!98 U+2264 lessequal +!99 U+2265 greaterequal +!9A U+00A0 space +!9B U+2321 integralbt +!9C U+00B0 degree +!9D U+00B2 twosuperior +!9E U+00B7 periodcentered +!9F U+00F7 divide +!A0 U+2550 SF430000 +!A1 U+2551 SF240000 +!A2 U+2552 SF510000 +!A3 U+0451 afii10071 +!A4 U+2553 SF520000 +!A5 U+2554 SF390000 +!A6 U+2555 SF220000 +!A7 U+2556 SF210000 +!A8 U+2557 SF250000 +!A9 U+2558 SF500000 +!AA U+2559 SF490000 +!AB U+255A SF380000 +!AC U+255B SF280000 +!AD U+255C SF270000 +!AE U+255D SF260000 +!AF U+255E SF360000 +!B0 U+255F SF370000 +!B1 U+2560 SF420000 +!B2 U+2561 SF190000 +!B3 U+0401 afii10023 +!B4 U+2562 SF200000 +!B5 U+2563 SF230000 +!B6 U+2564 SF470000 +!B7 U+2565 SF480000 +!B8 U+2566 SF410000 +!B9 U+2567 SF450000 +!BA U+2568 SF460000 +!BB U+2569 SF400000 +!BC U+256A SF540000 +!BD U+256B SF530000 +!BE U+256C SF440000 +!BF U+00A9 copyright +!C0 U+044E afii10096 +!C1 U+0430 afii10065 +!C2 U+0431 afii10066 +!C3 U+0446 afii10088 +!C4 U+0434 afii10069 +!C5 U+0435 afii10070 +!C6 U+0444 afii10086 +!C7 U+0433 afii10068 +!C8 U+0445 afii10087 +!C9 U+0438 afii10074 +!CA U+0439 afii10075 +!CB U+043A afii10076 +!CC U+043B afii10077 +!CD U+043C afii10078 +!CE U+043D afii10079 +!CF U+043E afii10080 +!D0 U+043F afii10081 +!D1 U+044F afii10097 +!D2 U+0440 afii10082 +!D3 U+0441 afii10083 +!D4 U+0442 afii10084 +!D5 U+0443 afii10085 +!D6 U+0436 afii10072 +!D7 U+0432 afii10067 +!D8 U+044C afii10094 +!D9 U+044B afii10093 +!DA U+0437 afii10073 +!DB U+0448 afii10090 +!DC U+044D afii10095 +!DD U+0449 afii10091 +!DE U+0447 afii10089 +!DF U+044A afii10092 +!E0 U+042E afii10048 +!E1 U+0410 afii10017 +!E2 U+0411 afii10018 +!E3 U+0426 afii10040 +!E4 U+0414 afii10021 +!E5 U+0415 afii10022 +!E6 U+0424 afii10038 +!E7 U+0413 afii10020 +!E8 U+0425 afii10039 +!E9 U+0418 afii10026 +!EA U+0419 afii10027 +!EB U+041A afii10028 +!EC U+041B afii10029 +!ED U+041C afii10030 +!EE U+041D afii10031 +!EF U+041E afii10032 +!F0 U+041F afii10033 +!F1 U+042F afii10049 +!F2 U+0420 afii10034 +!F3 U+0421 afii10035 +!F4 U+0422 afii10036 +!F5 U+0423 afii10037 +!F6 U+0416 afii10024 +!F7 U+0412 afii10019 +!F8 U+042C afii10046 +!F9 U+042B afii10045 +!FA U+0417 afii10025 +!FB U+0428 afii10042 +!FC U+042D afii10047 +!FD U+0429 afii10043 +!FE U+0427 afii10041 +!FF U+042A afii10044 diff --git a/include/pdf/font/makefont/koi8-u.map b/include/pdf/font/makefont/koi8-u.map new file mode 100644 index 000000000..40a7e4fd7 --- /dev/null +++ b/include/pdf/font/makefont/koi8-u.map @@ -0,0 +1,256 @@ +!00 U+0000 .notdef +!01 U+0001 .notdef +!02 U+0002 .notdef +!03 U+0003 .notdef +!04 U+0004 .notdef +!05 U+0005 .notdef +!06 U+0006 .notdef +!07 U+0007 .notdef +!08 U+0008 .notdef +!09 U+0009 .notdef +!0A U+000A .notdef +!0B U+000B .notdef +!0C U+000C .notdef +!0D U+000D .notdef +!0E U+000E .notdef +!0F U+000F .notdef +!10 U+0010 .notdef +!11 U+0011 .notdef +!12 U+0012 .notdef +!13 U+0013 .notdef +!14 U+0014 .notdef +!15 U+0015 .notdef +!16 U+0016 .notdef +!17 U+0017 .notdef +!18 U+0018 .notdef +!19 U+0019 .notdef +!1A U+001A .notdef +!1B U+001B .notdef +!1C U+001C .notdef +!1D U+001D .notdef +!1E U+001E .notdef +!1F U+001F .notdef +!20 U+0020 space +!21 U+0021 exclam +!22 U+0022 quotedbl +!23 U+0023 numbersign +!24 U+0024 dollar +!25 U+0025 percent +!26 U+0026 ampersand +!27 U+0027 quotesingle +!28 U+0028 parenleft +!29 U+0029 parenright +!2A U+002A asterisk +!2B U+002B plus +!2C U+002C comma +!2D U+002D hyphen +!2E U+002E period +!2F U+002F slash +!30 U+0030 zero +!31 U+0031 one +!32 U+0032 two +!33 U+0033 three +!34 U+0034 four +!35 U+0035 five +!36 U+0036 six +!37 U+0037 seven +!38 U+0038 eight +!39 U+0039 nine +!3A U+003A colon +!3B U+003B semicolon +!3C U+003C less +!3D U+003D equal +!3E U+003E greater +!3F U+003F question +!40 U+0040 at +!41 U+0041 A +!42 U+0042 B +!43 U+0043 C +!44 U+0044 D +!45 U+0045 E +!46 U+0046 F +!47 U+0047 G +!48 U+0048 H +!49 U+0049 I +!4A U+004A J +!4B U+004B K +!4C U+004C L +!4D U+004D M +!4E U+004E N +!4F U+004F O +!50 U+0050 P +!51 U+0051 Q +!52 U+0052 R +!53 U+0053 S +!54 U+0054 T +!55 U+0055 U +!56 U+0056 V +!57 U+0057 W +!58 U+0058 X +!59 U+0059 Y +!5A U+005A Z +!5B U+005B bracketleft +!5C U+005C backslash +!5D U+005D bracketright +!5E U+005E asciicircum +!5F U+005F underscore +!60 U+0060 grave +!61 U+0061 a +!62 U+0062 b +!63 U+0063 c +!64 U+0064 d +!65 U+0065 e +!66 U+0066 f +!67 U+0067 g +!68 U+0068 h +!69 U+0069 i +!6A U+006A j +!6B U+006B k +!6C U+006C l +!6D U+006D m +!6E U+006E n +!6F U+006F o +!70 U+0070 p +!71 U+0071 q +!72 U+0072 r +!73 U+0073 s +!74 U+0074 t +!75 U+0075 u +!76 U+0076 v +!77 U+0077 w +!78 U+0078 x +!79 U+0079 y +!7A U+007A z +!7B U+007B braceleft +!7C U+007C bar +!7D U+007D braceright +!7E U+007E asciitilde +!7F U+007F .notdef +!80 U+2500 SF100000 +!81 U+2502 SF110000 +!82 U+250C SF010000 +!83 U+2510 SF030000 +!84 U+2514 SF020000 +!85 U+2518 SF040000 +!86 U+251C SF080000 +!87 U+2524 SF090000 +!88 U+252C SF060000 +!89 U+2534 SF070000 +!8A U+253C SF050000 +!8B U+2580 upblock +!8C U+2584 dnblock +!8D U+2588 block +!8E U+258C lfblock +!8F U+2590 rtblock +!90 U+2591 ltshade +!91 U+2592 shade +!92 U+2593 dkshade +!93 U+2320 integraltp +!94 U+25A0 filledbox +!95 U+2022 bullet +!96 U+221A radical +!97 U+2248 approxequal +!98 U+2264 lessequal +!99 U+2265 greaterequal +!9A U+00A0 space +!9B U+2321 integralbt +!9C U+00B0 degree +!9D U+00B2 twosuperior +!9E U+00B7 periodcentered +!9F U+00F7 divide +!A0 U+2550 SF430000 +!A1 U+2551 SF240000 +!A2 U+2552 SF510000 +!A3 U+0451 afii10071 +!A4 U+0454 afii10101 +!A5 U+2554 SF390000 +!A6 U+0456 afii10103 +!A7 U+0457 afii10104 +!A8 U+2557 SF250000 +!A9 U+2558 SF500000 +!AA U+2559 SF490000 +!AB U+255A SF380000 +!AC U+255B SF280000 +!AD U+0491 afii10098 +!AE U+255D SF260000 +!AF U+255E SF360000 +!B0 U+255F SF370000 +!B1 U+2560 SF420000 +!B2 U+2561 SF190000 +!B3 U+0401 afii10023 +!B4 U+0404 afii10053 +!B5 U+2563 SF230000 +!B6 U+0406 afii10055 +!B7 U+0407 afii10056 +!B8 U+2566 SF410000 +!B9 U+2567 SF450000 +!BA U+2568 SF460000 +!BB U+2569 SF400000 +!BC U+256A SF540000 +!BD U+0490 afii10050 +!BE U+256C SF440000 +!BF U+00A9 copyright +!C0 U+044E afii10096 +!C1 U+0430 afii10065 +!C2 U+0431 afii10066 +!C3 U+0446 afii10088 +!C4 U+0434 afii10069 +!C5 U+0435 afii10070 +!C6 U+0444 afii10086 +!C7 U+0433 afii10068 +!C8 U+0445 afii10087 +!C9 U+0438 afii10074 +!CA U+0439 afii10075 +!CB U+043A afii10076 +!CC U+043B afii10077 +!CD U+043C afii10078 +!CE U+043D afii10079 +!CF U+043E afii10080 +!D0 U+043F afii10081 +!D1 U+044F afii10097 +!D2 U+0440 afii10082 +!D3 U+0441 afii10083 +!D4 U+0442 afii10084 +!D5 U+0443 afii10085 +!D6 U+0436 afii10072 +!D7 U+0432 afii10067 +!D8 U+044C afii10094 +!D9 U+044B afii10093 +!DA U+0437 afii10073 +!DB U+0448 afii10090 +!DC U+044D afii10095 +!DD U+0449 afii10091 +!DE U+0447 afii10089 +!DF U+044A afii10092 +!E0 U+042E afii10048 +!E1 U+0410 afii10017 +!E2 U+0411 afii10018 +!E3 U+0426 afii10040 +!E4 U+0414 afii10021 +!E5 U+0415 afii10022 +!E6 U+0424 afii10038 +!E7 U+0413 afii10020 +!E8 U+0425 afii10039 +!E9 U+0418 afii10026 +!EA U+0419 afii10027 +!EB U+041A afii10028 +!EC U+041B afii10029 +!ED U+041C afii10030 +!EE U+041D afii10031 +!EF U+041E afii10032 +!F0 U+041F afii10033 +!F1 U+042F afii10049 +!F2 U+0420 afii10034 +!F3 U+0421 afii10035 +!F4 U+0422 afii10036 +!F5 U+0423 afii10037 +!F6 U+0416 afii10024 +!F7 U+0412 afii10019 +!F8 U+042C afii10046 +!F9 U+042B afii10045 +!FA U+0417 afii10025 +!FB U+0428 afii10042 +!FC U+042D afii10047 +!FD U+0429 afii10043 +!FE U+0427 afii10041 +!FF U+042A afii10044 diff --git a/include/pdf/font/makefont/makefont.php b/include/pdf/font/makefont/makefont.php new file mode 100644 index 000000000..769e8f30f --- /dev/null +++ b/include/pdf/font/makefont/makefont.php @@ -0,0 +1,400 @@ +Error: encoding not found: '.$enc); + $cc2gn=array(); + foreach($a as $l) + { + if($l{0}=='!') + { + $e=preg_split('/[ \\t]+/',chop($l)); + $cc=hexdec(substr($e[0],1)); + $gn=$e[2]; + $cc2gn[$cc]=$gn; + } + } + for($i=0;$i<=255;$i++) + if(!isset($cc2gn[$i])) + $cc2gn[$i]='.notdef'; + return $cc2gn; +} + +function ReadAFM($file,&$map) +{ + //Read a font metric file + $a=file($file); + if(empty($a)) + die('File not found'); + $widths=array(); + $fm=array(); + $fix=array('Edot'=>'Edotaccent','edot'=>'edotaccent','Idot'=>'Idotaccent','Zdot'=>'Zdotaccent','zdot'=>'zdotaccent', + 'Odblacute'=>'Ohungarumlaut','odblacute'=>'ohungarumlaut','Udblacute'=>'Uhungarumlaut','udblacute'=>'uhungarumlaut', + 'Gcedilla'=>'Gcommaaccent','gcedilla'=>'gcommaaccent','Kcedilla'=>'Kcommaaccent','kcedilla'=>'kcommaaccent', + 'Lcedilla'=>'Lcommaaccent','lcedilla'=>'lcommaaccent','Ncedilla'=>'Ncommaaccent','ncedilla'=>'ncommaaccent', + 'Rcedilla'=>'Rcommaaccent','rcedilla'=>'rcommaaccent','Scedilla'=>'Scommaaccent','scedilla'=>'scommaaccent', + 'Tcedilla'=>'Tcommaaccent','tcedilla'=>'tcommaaccent','Dslash'=>'Dcroat','dslash'=>'dcroat','Dmacron'=>'Dcroat','dmacron'=>'dcroat', + 'combininggraveaccent'=>'gravecomb','combininghookabove'=>'hookabovecomb','combiningtildeaccent'=>'tildecomb', + 'combiningacuteaccent'=>'acutecomb','combiningdotbelow'=>'dotbelowcomb','dongsign'=>'dong'); + foreach($a as $l) + { + $e=explode(' ',chop($l)); + if(count($e)<2) + continue; + $code=$e[0]; + $param=$e[1]; + if($code=='C') + { + //Character metrics + $cc=(int)$e[1]; + $w=$e[4]; + $gn=$e[7]; + if(substr($gn,-4)=='20AC') + $gn='Euro'; + if(isset($fix[$gn])) + { + //Fix incorrect glyph name + foreach($map as $c=>$n) + if($n==$fix[$gn]) + $map[$c]=$gn; + } + if(empty($map)) + { + //Symbolic font: use built-in encoding + $widths[$cc]=$w; + } + else + { + $widths[$gn]=$w; + if($gn=='X') + $fm['CapXHeight']=$e[13]; + } + if($gn=='.notdef') + $fm['MissingWidth']=$w; + } + elseif($code=='FontName') + $fm['FontName']=$param; + elseif($code=='Weight') + $fm['Weight']=$param; + elseif($code=='ItalicAngle') + $fm['ItalicAngle']=(double)$param; + elseif($code=='Ascender') + $fm['Ascender']=(int)$param; + elseif($code=='Descender') + $fm['Descender']=(int)$param; + elseif($code=='UnderlineThickness') + $fm['UnderlineThickness']=(int)$param; + elseif($code=='UnderlinePosition') + $fm['UnderlinePosition']=(int)$param; + elseif($code=='IsFixedPitch') + $fm['IsFixedPitch']=($param=='true'); + elseif($code=='FontBBox') + $fm['FontBBox']=array($e[1],$e[2],$e[3],$e[4]); + elseif($code=='CapHeight') + $fm['CapHeight']=(int)$param; + elseif($code=='StdVW') + $fm['StdVW']=(int)$param; + } + if(!isset($fm['FontName'])) + die('FontName not found'); + if(!empty($map)) + { + if(!isset($widths['.notdef'])) + $widths['.notdef']=600; + if(!isset($widths['Delta']) and isset($widths['increment'])) + $widths['Delta']=$widths['increment']; + //Order widths according to map + for($i=0;$i<=255;$i++) + { + if(!isset($widths[$map[$i]])) + { + echo 'Warning: character '.$map[$i].' is missing
    '; + $widths[$i]=$widths['.notdef']; + } + else + $widths[$i]=$widths[$map[$i]]; + } + } + $fm['Widths']=$widths; + return $fm; +} + +function MakeFontDescriptor($fm,$symbolic) +{ + //Ascent + $asc=(isset($fm['Ascender']) ? $fm['Ascender'] : 1000); + $fd="array('Ascent'=>".$asc; + //Descent + $desc=(isset($fm['Descender']) ? $fm['Descender'] : -200); + $fd.=",'Descent'=>".$desc; + //CapHeight + if(isset($fm['CapHeight'])) + $ch=$fm['CapHeight']; + elseif(isset($fm['CapXHeight'])) + $ch=$fm['CapXHeight']; + else + $ch=$asc; + $fd.=",'CapHeight'=>".$ch; + //Flags + $flags=0; + if(isset($fm['IsFixedPitch']) and $fm['IsFixedPitch']) + $flags+=1<<0; + if($symbolic) + $flags+=1<<2; + if(!$symbolic) + $flags+=1<<5; + if(isset($fm['ItalicAngle']) and $fm['ItalicAngle']!=0) + $flags+=1<<6; + $fd.=",'Flags'=>".$flags; + //FontBBox + if(isset($fm['FontBBox'])) + $fbb=$fm['FontBBox']; + else + $fbb=array(0,$des-100,1000,$asc+100); + $fd.=",'FontBBox'=>'[".$fbb[0].' '.$fbb[1].' '.$fbb[2].' '.$fbb[3]."]'"; + //ItalicAngle + $ia=(isset($fm['ItalicAngle']) ? $fm['ItalicAngle'] : 0); + $fd.=",'ItalicAngle'=>".$ia; + //StemV + if(isset($fm['StdVW'])) + $stemv=$fm['StdVW']; + elseif(isset($fm['Weight']) and eregi('(bold|black)',$fm['Weight'])) + $stemv=120; + else + $stemv=70; + $fd.=",'StemV'=>".$stemv; + //MissingWidth + if(isset($fm['MissingWidth'])) + $fd.=",'MissingWidth'=>".$fm['MissingWidth']; + $fd.=')'; + return $fd; +} + +function MakeWidthArray($fm) +{ + //Make character width array + $s="array(\n\t"; + $cw=$fm['Widths']; + for($i=0;$i<=255;$i++) + { + if(chr($i)=="'") + $s.="'\\''"; + elseif(chr($i)=="\\") + $s.="'\\\\'"; + elseif($i>=32 and $i<=126) + $s.="'".chr($i)."'"; + else + $s.="chr($i)"; + $s.='=>'.$fm['Widths'][$i]; + if($i<255) + $s.=','; + if(($i+1)%22==0) + $s.="\n\t"; + } + $s.=')'; + return $s; +} + +function MakeFontEncoding($map) +{ + //Build differences from reference encoding + $ref=ReadMap('cp1252'); + $s=''; + $last=0; + for($i=32;$i<=255;$i++) + { + if($map[$i]!=$ref[$i]) + { + if($i!=$last+1) + $s.=$i.' '; + $last=$i; + $s.='/'.$map[$i].' '; + } + } + return chop($s); +} + +function SaveToFile($file,$s,$mode='t') +{ + $f=fopen($file,'w'.$mode); + if(!$f) + die('Can\'t write to file '.$file); + fwrite($f,$s,strlen($s)); + fclose($f); +} + +function ReadShort($f) +{ + $a=unpack('n1n',fread($f,2)); + return $a['n']; +} + +function ReadLong($f) +{ + $a=unpack('N1N',fread($f,4)); + return $a['N']; +} + +function CheckTTF($file) +{ + //Check if font license allows embedding + $f=fopen($file,'rb'); + if(!$f) + die('Error: Can\'t open '.$file); + //Extract number of tables + fseek($f,4,SEEK_CUR); + $nb=ReadShort($f); + fseek($f,6,SEEK_CUR); + //Seek OS/2 table + $found=false; + for($i=0;$i<$nb;$i++) + { + if(fread($f,4)=='OS/2') + { + $found=true; + break; + } + fseek($f,12,SEEK_CUR); + } + if(!$found) + { + fclose($f); + return; + } + fseek($f,4,SEEK_CUR); + $offset=ReadLong($f); + fseek($f,$offset,SEEK_SET); + //Extract fsType flags + fseek($f,8,SEEK_CUR); + $fsType=ReadShort($f); + $rl=($fsType & 0x02)!=0; + $pp=($fsType & 0x04)!=0; + $e=($fsType & 0x08)!=0; + fclose($f); + if($rl and !$pp and !$e) + echo 'Warning: font license does not allow embedding'; +} + +/******************************************************************************* +* $fontfile: path to TTF file (or empty string if not to be embedded) * +* $afmfile: path to AFM file * +* $enc: font encoding (or empty string for symbolic fonts) * +* $patch: optional patch for encoding * +* $type : font type if $fontfile is empty * +*******************************************************************************/ +function MakeFont($fontfile,$afmfile,$enc='cp1252',$patch=array(),$type='TrueType') +{ + //Generate a font definition file + set_magic_quotes_runtime(0); + if($enc) + { + $map=ReadMap($enc); + foreach($patch as $cc=>$gn) + $map[$cc]=$gn; + } + else + $map=array(); + if(!file_exists($afmfile)) + die('Error: AFM file not found: '.$afmfile); + $fm=ReadAFM($afmfile,$map); + if($enc) + $diff=MakeFontEncoding($map); + else + $diff=''; + $fd=MakeFontDescriptor($fm,empty($map)); + //Find font type + if($fontfile) + { + $ext=strtolower(substr($fontfile,-3)); + if($ext=='ttf') + $type='TrueType'; + elseif($ext=='pfb') + $type='Type1'; + else + die('Error: unrecognized font file extension: '.$ext); + } + else + { + if($type!='TrueType' and $type!='Type1') + die('Error: incorrect font type: '.$type); + } + //Start generation + $s='Error: font file not found: '.$fontfile); + if($type=='TrueType') + CheckTTF($fontfile); + $f=fopen($fontfile,'rb'); + if(!$f) + die('Error: Can\'t open '.$fontfile); + $file=fread($f,filesize($fontfile)); + fclose($f); + if($type=='Type1') + { + //Find first two sections and discard third one + $pos=strpos($file,'eexec'); + if(!$pos) + die('Error: font file does not seem to be valid Type1'); + $size1=$pos+6; + $pos=strpos($file,'00000000'); + if(!$pos) + die('Error: font file does not seem to be valid Type1'); + $size2=$pos-$size1; + $file=substr($file,0,$size1+$size2); + } + if(function_exists('gzcompress')) + { + $cmp=$basename.'.z'; + SaveToFile($cmp,gzcompress($file),'b'); + $s.='$file=\''.$cmp."';\n"; + echo 'Font file compressed ('.$cmp.')
    '; + } + else + { + $s.='$file=\''.basename($fontfile)."';\n"; + echo 'Notice: font file could not be compressed (gzcompress not available)
    '; + } + if($type=='Type1') + { + $s.='$size1='.$size1.";\n"; + $s.='$size2='.$size2.";\n"; + } + else + $s.='$originalsize='.filesize($fontfile).";\n"; + } + else + { + //Not embedded font + $s.='$file='."'';\n"; + } + $s.="?>\n"; + SaveToFile($basename.'.php',$s); + echo 'Font definition file generated ('.$basename.'.php'.')
    '; +} +?> diff --git a/include/pdf/font/symbol.php b/include/pdf/font/symbol.php new file mode 100644 index 000000000..43b50e451 --- /dev/null +++ b/include/pdf/font/symbol.php @@ -0,0 +1,15 @@ +250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250, + chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>713,'#'=>500,'$'=>549,'%'=>833,'&'=>778,'\''=>439,'('=>333,')'=>333,'*'=>500,'+'=>549, + ','=>250,'-'=>549,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>278,';'=>278,'<'=>549,'='=>549,'>'=>549,'?'=>444,'@'=>549,'A'=>722, + 'B'=>667,'C'=>722,'D'=>612,'E'=>611,'F'=>763,'G'=>603,'H'=>722,'I'=>333,'J'=>631,'K'=>722,'L'=>686,'M'=>889,'N'=>722,'O'=>722,'P'=>768,'Q'=>741,'R'=>556,'S'=>592,'T'=>611,'U'=>690,'V'=>439,'W'=>768, + 'X'=>645,'Y'=>795,'Z'=>611,'['=>333,'\\'=>863,']'=>333,'^'=>658,'_'=>500,'`'=>500,'a'=>631,'b'=>549,'c'=>549,'d'=>494,'e'=>439,'f'=>521,'g'=>411,'h'=>603,'i'=>329,'j'=>603,'k'=>549,'l'=>549,'m'=>576, + 'n'=>521,'o'=>549,'p'=>549,'q'=>521,'r'=>549,'s'=>603,'t'=>439,'u'=>576,'v'=>713,'w'=>686,'x'=>493,'y'=>686,'z'=>494,'{'=>480,'|'=>200,'}'=>480,'~'=>549,chr(127)=>0,chr(128)=>0,chr(129)=>0,chr(130)=>0,chr(131)=>0, + chr(132)=>0,chr(133)=>0,chr(134)=>0,chr(135)=>0,chr(136)=>0,chr(137)=>0,chr(138)=>0,chr(139)=>0,chr(140)=>0,chr(141)=>0,chr(142)=>0,chr(143)=>0,chr(144)=>0,chr(145)=>0,chr(146)=>0,chr(147)=>0,chr(148)=>0,chr(149)=>0,chr(150)=>0,chr(151)=>0,chr(152)=>0,chr(153)=>0, + chr(154)=>0,chr(155)=>0,chr(156)=>0,chr(157)=>0,chr(158)=>0,chr(159)=>0,chr(160)=>750,chr(161)=>620,chr(162)=>247,chr(163)=>549,chr(164)=>167,chr(165)=>713,chr(166)=>500,chr(167)=>753,chr(168)=>753,chr(169)=>753,chr(170)=>753,chr(171)=>1042,chr(172)=>987,chr(173)=>603,chr(174)=>987,chr(175)=>603, + chr(176)=>400,chr(177)=>549,chr(178)=>411,chr(179)=>549,chr(180)=>549,chr(181)=>713,chr(182)=>494,chr(183)=>460,chr(184)=>549,chr(185)=>549,chr(186)=>549,chr(187)=>549,chr(188)=>1000,chr(189)=>603,chr(190)=>1000,chr(191)=>658,chr(192)=>823,chr(193)=>686,chr(194)=>795,chr(195)=>987,chr(196)=>768,chr(197)=>768, + chr(198)=>823,chr(199)=>768,chr(200)=>768,chr(201)=>713,chr(202)=>713,chr(203)=>713,chr(204)=>713,chr(205)=>713,chr(206)=>713,chr(207)=>713,chr(208)=>768,chr(209)=>713,chr(210)=>790,chr(211)=>790,chr(212)=>890,chr(213)=>823,chr(214)=>549,chr(215)=>250,chr(216)=>713,chr(217)=>603,chr(218)=>603,chr(219)=>1042, + chr(220)=>987,chr(221)=>603,chr(222)=>987,chr(223)=>603,chr(224)=>494,chr(225)=>329,chr(226)=>790,chr(227)=>790,chr(228)=>786,chr(229)=>713,chr(230)=>384,chr(231)=>384,chr(232)=>384,chr(233)=>384,chr(234)=>384,chr(235)=>384,chr(236)=>494,chr(237)=>494,chr(238)=>494,chr(239)=>494,chr(240)=>0,chr(241)=>329, + chr(242)=>274,chr(243)=>686,chr(244)=>686,chr(245)=>686,chr(246)=>384,chr(247)=>384,chr(248)=>384,chr(249)=>384,chr(250)=>384,chr(251)=>384,chr(252)=>494,chr(253)=>494,chr(254)=>494,chr(255)=>0); +?> diff --git a/include/pdf/font/times.php b/include/pdf/font/times.php new file mode 100644 index 000000000..837c706e0 --- /dev/null +++ b/include/pdf/font/times.php @@ -0,0 +1,15 @@ +250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250, + chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>408,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>180,'('=>333,')'=>333,'*'=>500,'+'=>564, + ','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>278,';'=>278,'<'=>564,'='=>564,'>'=>564,'?'=>444,'@'=>921,'A'=>722, + 'B'=>667,'C'=>667,'D'=>722,'E'=>611,'F'=>556,'G'=>722,'H'=>722,'I'=>333,'J'=>389,'K'=>722,'L'=>611,'M'=>889,'N'=>722,'O'=>722,'P'=>556,'Q'=>722,'R'=>667,'S'=>556,'T'=>611,'U'=>722,'V'=>722,'W'=>944, + 'X'=>722,'Y'=>722,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>469,'_'=>500,'`'=>333,'a'=>444,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>333,'g'=>500,'h'=>500,'i'=>278,'j'=>278,'k'=>500,'l'=>278,'m'=>778, + 'n'=>500,'o'=>500,'p'=>500,'q'=>500,'r'=>333,'s'=>389,'t'=>278,'u'=>500,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>444,'{'=>480,'|'=>200,'}'=>480,'~'=>541,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500, + chr(132)=>444,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>889,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>444,chr(148)=>444,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>980, + chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>444,chr(159)=>722,chr(160)=>250,chr(161)=>333,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>200,chr(167)=>500,chr(168)=>333,chr(169)=>760,chr(170)=>276,chr(171)=>500,chr(172)=>564,chr(173)=>333,chr(174)=>760,chr(175)=>333, + chr(176)=>400,chr(177)=>564,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>500,chr(182)=>453,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>310,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>444,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722, + chr(198)=>889,chr(199)=>667,chr(200)=>611,chr(201)=>611,chr(202)=>611,chr(203)=>611,chr(204)=>333,chr(205)=>333,chr(206)=>333,chr(207)=>333,chr(208)=>722,chr(209)=>722,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>564,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722, + chr(220)=>722,chr(221)=>722,chr(222)=>556,chr(223)=>500,chr(224)=>444,chr(225)=>444,chr(226)=>444,chr(227)=>444,chr(228)=>444,chr(229)=>444,chr(230)=>667,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>500, + chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>564,chr(248)=>500,chr(249)=>500,chr(250)=>500,chr(251)=>500,chr(252)=>500,chr(253)=>500,chr(254)=>500,chr(255)=>500); +?> diff --git a/include/pdf/font/timesb.php b/include/pdf/font/timesb.php new file mode 100644 index 000000000..09cff86ac --- /dev/null +++ b/include/pdf/font/timesb.php @@ -0,0 +1,15 @@ +250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250, + chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>555,'#'=>500,'$'=>500,'%'=>1000,'&'=>833,'\''=>278,'('=>333,')'=>333,'*'=>500,'+'=>570, + ','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>570,'='=>570,'>'=>570,'?'=>500,'@'=>930,'A'=>722, + 'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>778,'I'=>389,'J'=>500,'K'=>778,'L'=>667,'M'=>944,'N'=>722,'O'=>778,'P'=>611,'Q'=>778,'R'=>722,'S'=>556,'T'=>667,'U'=>722,'V'=>722,'W'=>1000, + 'X'=>722,'Y'=>722,'Z'=>667,'['=>333,'\\'=>278,']'=>333,'^'=>581,'_'=>500,'`'=>333,'a'=>500,'b'=>556,'c'=>444,'d'=>556,'e'=>444,'f'=>333,'g'=>500,'h'=>556,'i'=>278,'j'=>333,'k'=>556,'l'=>278,'m'=>833, + 'n'=>556,'o'=>500,'p'=>556,'q'=>556,'r'=>444,'s'=>389,'t'=>333,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>444,'{'=>394,'|'=>220,'}'=>394,'~'=>520,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500, + chr(132)=>500,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>667,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>1000, + chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>444,chr(159)=>722,chr(160)=>250,chr(161)=>333,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>220,chr(167)=>500,chr(168)=>333,chr(169)=>747,chr(170)=>300,chr(171)=>500,chr(172)=>570,chr(173)=>333,chr(174)=>747,chr(175)=>333, + chr(176)=>400,chr(177)=>570,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>556,chr(182)=>540,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>330,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722, + chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>389,chr(205)=>389,chr(206)=>389,chr(207)=>389,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>570,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722, + chr(220)=>722,chr(221)=>722,chr(222)=>611,chr(223)=>556,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>722,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>556, + chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>570,chr(248)=>500,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500); +?> diff --git a/include/pdf/font/timesbi.php b/include/pdf/font/timesbi.php new file mode 100644 index 000000000..b4e38d763 --- /dev/null +++ b/include/pdf/font/timesbi.php @@ -0,0 +1,15 @@ +250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250, + chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>389,'"'=>555,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>278,'('=>333,')'=>333,'*'=>500,'+'=>570, + ','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>570,'='=>570,'>'=>570,'?'=>500,'@'=>832,'A'=>667, + 'B'=>667,'C'=>667,'D'=>722,'E'=>667,'F'=>667,'G'=>722,'H'=>778,'I'=>389,'J'=>500,'K'=>667,'L'=>611,'M'=>889,'N'=>722,'O'=>722,'P'=>611,'Q'=>722,'R'=>667,'S'=>556,'T'=>611,'U'=>722,'V'=>667,'W'=>889, + 'X'=>667,'Y'=>611,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>570,'_'=>500,'`'=>333,'a'=>500,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>333,'g'=>500,'h'=>556,'i'=>278,'j'=>278,'k'=>500,'l'=>278,'m'=>778, + 'n'=>556,'o'=>500,'p'=>500,'q'=>500,'r'=>389,'s'=>389,'t'=>278,'u'=>556,'v'=>444,'w'=>667,'x'=>500,'y'=>444,'z'=>389,'{'=>348,'|'=>220,'}'=>348,'~'=>570,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500, + chr(132)=>500,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>944,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>1000, + chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>389,chr(159)=>611,chr(160)=>250,chr(161)=>389,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>220,chr(167)=>500,chr(168)=>333,chr(169)=>747,chr(170)=>266,chr(171)=>500,chr(172)=>606,chr(173)=>333,chr(174)=>747,chr(175)=>333, + chr(176)=>400,chr(177)=>570,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>576,chr(182)=>500,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>300,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667, + chr(198)=>944,chr(199)=>667,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>389,chr(205)=>389,chr(206)=>389,chr(207)=>389,chr(208)=>722,chr(209)=>722,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>570,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722, + chr(220)=>722,chr(221)=>611,chr(222)=>611,chr(223)=>500,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>722,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>556, + chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>570,chr(248)=>500,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>444,chr(254)=>500,chr(255)=>444); +?> diff --git a/include/pdf/font/timesi.php b/include/pdf/font/timesi.php new file mode 100644 index 000000000..0ba2b7773 --- /dev/null +++ b/include/pdf/font/timesi.php @@ -0,0 +1,15 @@ +250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250, + chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>420,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>214,'('=>333,')'=>333,'*'=>500,'+'=>675, + ','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>675,'='=>675,'>'=>675,'?'=>500,'@'=>920,'A'=>611, + 'B'=>611,'C'=>667,'D'=>722,'E'=>611,'F'=>611,'G'=>722,'H'=>722,'I'=>333,'J'=>444,'K'=>667,'L'=>556,'M'=>833,'N'=>667,'O'=>722,'P'=>611,'Q'=>722,'R'=>611,'S'=>500,'T'=>556,'U'=>722,'V'=>611,'W'=>833, + 'X'=>611,'Y'=>556,'Z'=>556,'['=>389,'\\'=>278,']'=>389,'^'=>422,'_'=>500,'`'=>333,'a'=>500,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>278,'g'=>500,'h'=>500,'i'=>278,'j'=>278,'k'=>444,'l'=>278,'m'=>722, + 'n'=>500,'o'=>500,'p'=>500,'q'=>500,'r'=>389,'s'=>389,'t'=>278,'u'=>500,'v'=>444,'w'=>667,'x'=>444,'y'=>444,'z'=>389,'{'=>400,'|'=>275,'}'=>400,'~'=>541,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500, + chr(132)=>556,chr(133)=>889,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>500,chr(139)=>333,chr(140)=>944,chr(141)=>350,chr(142)=>556,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>556,chr(148)=>556,chr(149)=>350,chr(150)=>500,chr(151)=>889,chr(152)=>333,chr(153)=>980, + chr(154)=>389,chr(155)=>333,chr(156)=>667,chr(157)=>350,chr(158)=>389,chr(159)=>556,chr(160)=>250,chr(161)=>389,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>275,chr(167)=>500,chr(168)=>333,chr(169)=>760,chr(170)=>276,chr(171)=>500,chr(172)=>675,chr(173)=>333,chr(174)=>760,chr(175)=>333, + chr(176)=>400,chr(177)=>675,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>500,chr(182)=>523,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>310,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>611,chr(193)=>611,chr(194)=>611,chr(195)=>611,chr(196)=>611,chr(197)=>611, + chr(198)=>889,chr(199)=>667,chr(200)=>611,chr(201)=>611,chr(202)=>611,chr(203)=>611,chr(204)=>333,chr(205)=>333,chr(206)=>333,chr(207)=>333,chr(208)=>722,chr(209)=>667,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>675,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722, + chr(220)=>722,chr(221)=>556,chr(222)=>611,chr(223)=>500,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>667,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>500, + chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>675,chr(248)=>500,chr(249)=>500,chr(250)=>500,chr(251)=>500,chr(252)=>500,chr(253)=>444,chr(254)=>500,chr(255)=>444); +?> diff --git a/include/pdf/font/zapfdingbats.php b/include/pdf/font/zapfdingbats.php new file mode 100644 index 000000000..1f926a8c3 --- /dev/null +++ b/include/pdf/font/zapfdingbats.php @@ -0,0 +1,15 @@ +0,chr(1)=>0,chr(2)=>0,chr(3)=>0,chr(4)=>0,chr(5)=>0,chr(6)=>0,chr(7)=>0,chr(8)=>0,chr(9)=>0,chr(10)=>0,chr(11)=>0,chr(12)=>0,chr(13)=>0,chr(14)=>0,chr(15)=>0,chr(16)=>0,chr(17)=>0,chr(18)=>0,chr(19)=>0,chr(20)=>0,chr(21)=>0, + chr(22)=>0,chr(23)=>0,chr(24)=>0,chr(25)=>0,chr(26)=>0,chr(27)=>0,chr(28)=>0,chr(29)=>0,chr(30)=>0,chr(31)=>0,' '=>278,'!'=>974,'"'=>961,'#'=>974,'$'=>980,'%'=>719,'&'=>789,'\''=>790,'('=>791,')'=>690,'*'=>960,'+'=>939, + ','=>549,'-'=>855,'.'=>911,'/'=>933,'0'=>911,'1'=>945,'2'=>974,'3'=>755,'4'=>846,'5'=>762,'6'=>761,'7'=>571,'8'=>677,'9'=>763,':'=>760,';'=>759,'<'=>754,'='=>494,'>'=>552,'?'=>537,'@'=>577,'A'=>692, + 'B'=>786,'C'=>788,'D'=>788,'E'=>790,'F'=>793,'G'=>794,'H'=>816,'I'=>823,'J'=>789,'K'=>841,'L'=>823,'M'=>833,'N'=>816,'O'=>831,'P'=>923,'Q'=>744,'R'=>723,'S'=>749,'T'=>790,'U'=>792,'V'=>695,'W'=>776, + 'X'=>768,'Y'=>792,'Z'=>759,'['=>707,'\\'=>708,']'=>682,'^'=>701,'_'=>826,'`'=>815,'a'=>789,'b'=>789,'c'=>707,'d'=>687,'e'=>696,'f'=>689,'g'=>786,'h'=>787,'i'=>713,'j'=>791,'k'=>785,'l'=>791,'m'=>873, + 'n'=>761,'o'=>762,'p'=>762,'q'=>759,'r'=>759,'s'=>892,'t'=>892,'u'=>788,'v'=>784,'w'=>438,'x'=>138,'y'=>277,'z'=>415,'{'=>392,'|'=>392,'}'=>668,'~'=>668,chr(127)=>0,chr(128)=>390,chr(129)=>390,chr(130)=>317,chr(131)=>317, + chr(132)=>276,chr(133)=>276,chr(134)=>509,chr(135)=>509,chr(136)=>410,chr(137)=>410,chr(138)=>234,chr(139)=>234,chr(140)=>334,chr(141)=>334,chr(142)=>0,chr(143)=>0,chr(144)=>0,chr(145)=>0,chr(146)=>0,chr(147)=>0,chr(148)=>0,chr(149)=>0,chr(150)=>0,chr(151)=>0,chr(152)=>0,chr(153)=>0, + chr(154)=>0,chr(155)=>0,chr(156)=>0,chr(157)=>0,chr(158)=>0,chr(159)=>0,chr(160)=>0,chr(161)=>732,chr(162)=>544,chr(163)=>544,chr(164)=>910,chr(165)=>667,chr(166)=>760,chr(167)=>760,chr(168)=>776,chr(169)=>595,chr(170)=>694,chr(171)=>626,chr(172)=>788,chr(173)=>788,chr(174)=>788,chr(175)=>788, + chr(176)=>788,chr(177)=>788,chr(178)=>788,chr(179)=>788,chr(180)=>788,chr(181)=>788,chr(182)=>788,chr(183)=>788,chr(184)=>788,chr(185)=>788,chr(186)=>788,chr(187)=>788,chr(188)=>788,chr(189)=>788,chr(190)=>788,chr(191)=>788,chr(192)=>788,chr(193)=>788,chr(194)=>788,chr(195)=>788,chr(196)=>788,chr(197)=>788, + chr(198)=>788,chr(199)=>788,chr(200)=>788,chr(201)=>788,chr(202)=>788,chr(203)=>788,chr(204)=>788,chr(205)=>788,chr(206)=>788,chr(207)=>788,chr(208)=>788,chr(209)=>788,chr(210)=>788,chr(211)=>788,chr(212)=>894,chr(213)=>838,chr(214)=>1016,chr(215)=>458,chr(216)=>748,chr(217)=>924,chr(218)=>748,chr(219)=>918, + chr(220)=>927,chr(221)=>928,chr(222)=>928,chr(223)=>834,chr(224)=>873,chr(225)=>828,chr(226)=>924,chr(227)=>924,chr(228)=>917,chr(229)=>930,chr(230)=>931,chr(231)=>463,chr(232)=>883,chr(233)=>836,chr(234)=>836,chr(235)=>867,chr(236)=>867,chr(237)=>696,chr(238)=>696,chr(239)=>874,chr(240)=>0,chr(241)=>874, + chr(242)=>760,chr(243)=>946,chr(244)=>771,chr(245)=>865,chr(246)=>771,chr(247)=>888,chr(248)=>967,chr(249)=>888,chr(250)=>831,chr(251)=>873,chr(252)=>927,chr(253)=>970,chr(254)=>918,chr(255)=>0); +?> diff --git a/include/pdf/fpdf.css b/include/pdf/fpdf.css new file mode 100644 index 000000000..045a32e37 --- /dev/null +++ b/include/pdf/fpdf.css @@ -0,0 +1,11 @@ +BODY {font-family:times new roman,serif} +H2 {color:#4000A0} +P.demo {text-align:center; margin-top:-10px} +A.demo {text-decoration:none; font-weight:bold; color:#0000CC} +A.demo:link {text-decoration:none; font-weight:bold; color:#0000CC} +A.demo:hover {text-decoration:none; font-weight:bold; color:#0000FF} +A.demo:active {text-decoration:none; font-weight:bold; color:#0000FF} +.st {font-weight:bold; color:#900000} +.kw {color:#000080; font-weight:bold} +.str {color:#CC0000} +.cmt {color:#008000} diff --git a/include/pdf/fpdf.php b/include/pdf/fpdf.php new file mode 100644 index 000000000..482af32c2 --- /dev/null +++ b/include/pdf/fpdf.php @@ -0,0 +1,1622 @@ +_dochecks(); + //Initialization of properties + $this->page=0; + $this->n=2; + $this->buffer=''; + $this->pages=array(); + $this->OrientationChanges=array(); + $this->state=0; + $this->fonts=array(); + $this->FontFiles=array(); + $this->diffs=array(); + $this->images=array(); + $this->links=array(); + $this->InFooter=false; + $this->lasth=0; + $this->FontFamily=''; + $this->FontStyle=''; + $this->FontSizePt=12; + $this->underline=false; + $this->DrawColor='0 G'; + $this->FillColor='0 g'; + $this->TextColor='0 g'; + $this->ColorFlag=false; + $this->ws=0; + //Standard fonts + $this->CoreFonts=array('courier'=>'Courier','courierB'=>'Courier-Bold','courierI'=>'Courier-Oblique','courierBI'=>'Courier-BoldOblique', + 'helvetica'=>'Helvetica','helveticaB'=>'Helvetica-Bold','helveticaI'=>'Helvetica-Oblique','helveticaBI'=>'Helvetica-BoldOblique', + 'times'=>'Times-Roman','timesB'=>'Times-Bold','timesI'=>'Times-Italic','timesBI'=>'Times-BoldItalic', + 'symbol'=>'Symbol','zapfdingbats'=>'ZapfDingbats'); + //Scale factor + if($unit=='pt') + $this->k=1; + elseif($unit=='mm') + $this->k=72/25.4; + elseif($unit=='cm') + $this->k=72/2.54; + elseif($unit=='in') + $this->k=72; + else + $this->Error('Incorrect unit: '.$unit); + //Page format + if(is_string($format)) + { + $format=strtolower($format); + if($format=='a3') + $format=array(841.89,1190.55); + elseif($format=='a4') + $format=array(595.28,841.89); + elseif($format=='a5') + $format=array(420.94,595.28); + elseif($format=='letter') + $format=array(612,792); + elseif($format=='legal') + $format=array(612,1008); + else + $this->Error('Unknown page format: '.$format); + $this->fwPt=$format[0]; + $this->fhPt=$format[1]; + } + else + { + $this->fwPt=$format[0]*$this->k; + $this->fhPt=$format[1]*$this->k; + } + $this->fw=$this->fwPt/$this->k; + $this->fh=$this->fhPt/$this->k; + //Page orientation + $orientation=strtolower($orientation); + if($orientation=='p' or $orientation=='portrait') + { + $this->DefOrientation='P'; + $this->wPt=$this->fwPt; + $this->hPt=$this->fhPt; + } + elseif($orientation=='l' or $orientation=='landscape') + { + $this->DefOrientation='L'; + $this->wPt=$this->fhPt; + $this->hPt=$this->fwPt; + } + else + $this->Error('Incorrect orientation: '.$orientation); + $this->CurOrientation=$this->DefOrientation; + $this->w=$this->wPt/$this->k; + $this->h=$this->hPt/$this->k; + //Page margins (1 cm) + $margin=28.35/$this->k; + $this->SetMargins($margin,$margin); + //Interior cell margin (1 mm) + $this->cMargin=$margin/10; + //Line width (0.2 mm) + $this->LineWidth=.567/$this->k; + //Automatic page break + $this->SetAutoPageBreak(true,2*$margin); + //Full width display mode + $this->SetDisplayMode('fullwidth'); + //Compression + $this->SetCompression(true); +} + +function SetMargins($left,$top,$right=-1) +{ + //Set left, top and right margins + $this->lMargin=$left; + $this->tMargin=$top; + if($right==-1) + $right=$left; + $this->rMargin=$right; +} + +function SetLeftMargin($margin) +{ + //Set left margin + $this->lMargin=$margin; + if($this->page>0 and $this->x<$margin) + $this->x=$margin; +} + +function SetTopMargin($margin) +{ + //Set top margin + $this->tMargin=$margin; +} + +function SetRightMargin($margin) +{ + //Set right margin + $this->rMargin=$margin; +} + +function SetAutoPageBreak($auto,$margin=0) +{ + //Set auto page break mode and triggering margin + $this->AutoPageBreak=$auto; + $this->bMargin=$margin; + $this->PageBreakTrigger=$this->h-$margin; +} + +function SetDisplayMode($zoom,$layout='continuous') +{ + //Set display mode in viewer + if($zoom=='fullpage' or $zoom=='fullwidth' or $zoom=='real' or $zoom=='default' or !is_string($zoom)) + $this->ZoomMode=$zoom; + else + $this->Error('Incorrect zoom display mode: '.$zoom); + if($layout=='single' or $layout=='continuous' or $layout=='two' or $layout=='default') + $this->LayoutMode=$layout; + else + $this->Error('Incorrect layout display mode: '.$layout); +} + +function SetCompression($compress) +{ + //Set page compression + if(function_exists('gzcompress')) + $this->compress=$compress; + else + $this->compress=false; +} + +function SetTitle($title) +{ + //Title of document + $this->title=$title; +} + +function SetSubject($subject) +{ + //Subject of document + $this->subject=$subject; +} + +function SetAuthor($author) +{ + //Author of document + $this->author=$author; +} + +function SetKeywords($keywords) +{ + //Keywords of document + $this->keywords=$keywords; +} + +function SetCreator($creator) +{ + //Creator of document + $this->creator=$creator; +} + +function AliasNbPages($alias='{nb}') +{ + //Define an alias for total number of pages + $this->AliasNbPages=$alias; +} + +function Error($msg) +{ + //Fatal error + die('FPDF error: '.$msg); +} + +function Open() +{ + //Begin document + if($this->state==0) + $this->_begindoc(); +} + +function Close() +{ + //Terminate document + if($this->state==3) + return; + if($this->page==0) + $this->AddPage(); + //Page footer + $this->InFooter=true; + $this->Footer(); + $this->InFooter=false; + //Close page + $this->_endpage(); + //Close document + $this->_enddoc(); +} + +function AddPage($orientation='') +{ + //Start a new page + if($this->state==0) + $this->Open(); + $family=$this->FontFamily; + $style=$this->FontStyle.($this->underline ? 'U' : ''); + $size=$this->FontSizePt; + $lw=$this->LineWidth; + $dc=$this->DrawColor; + $fc=$this->FillColor; + $tc=$this->TextColor; + $cf=$this->ColorFlag; + if($this->page>0) + { + //Page footer + $this->InFooter=true; + $this->Footer(); + $this->InFooter=false; + //Close page + $this->_endpage(); + } + //Start new page + $this->_beginpage($orientation); + //Set line cap style to square + $this->_out('2 J'); + //Set line width + $this->LineWidth=$lw; + $this->_out(sprintf('%.2f w',$lw*$this->k)); + //Set font + if($family) + $this->SetFont($family,$style,$size); + //Set colors + $this->DrawColor=$dc; + if($dc!='0 G') + $this->_out($dc); + $this->FillColor=$fc; + if($fc!='0 g') + $this->_out($fc); + $this->TextColor=$tc; + $this->ColorFlag=$cf; + //Page header + $this->Header(); + //Restore line width + if($this->LineWidth!=$lw) + { + $this->LineWidth=$lw; + $this->_out(sprintf('%.2f w',$lw*$this->k)); + } + //Restore font + if($family) + $this->SetFont($family,$style,$size); + //Restore colors + if($this->DrawColor!=$dc) + { + $this->DrawColor=$dc; + $this->_out($dc); + } + if($this->FillColor!=$fc) + { + $this->FillColor=$fc; + $this->_out($fc); + } + $this->TextColor=$tc; + $this->ColorFlag=$cf; +} + +function Header() +{ + //To be implemented in your own inherited class +} + +function Footer() +{ + //To be implemented in your own inherited class +} + +function PageNo() +{ + //Get current page number + return $this->page; +} + +function SetDrawColor($r,$g=-1,$b=-1) +{ + //Set color for all stroking operations + if(($r==0 and $g==0 and $b==0) or $g==-1) + $this->DrawColor=sprintf('%.3f G',$r/255); + else + $this->DrawColor=sprintf('%.3f %.3f %.3f RG',$r/255,$g/255,$b/255); + if($this->page>0) + $this->_out($this->DrawColor); +} + +function SetFillColor($r,$g=-1,$b=-1) +{ + //Set color for all filling operations + if(($r==0 and $g==0 and $b==0) or $g==-1) + $this->FillColor=sprintf('%.3f g',$r/255); + else + $this->FillColor=sprintf('%.3f %.3f %.3f rg',$r/255,$g/255,$b/255); + $this->ColorFlag=($this->FillColor!=$this->TextColor); + if($this->page>0) + $this->_out($this->FillColor); +} + +function SetTextColor($r,$g=-1,$b=-1) +{ + //Set color for text + if(($r==0 and $g==0 and $b==0) or $g==-1) + $this->TextColor=sprintf('%.3f g',$r/255); + else + $this->TextColor=sprintf('%.3f %.3f %.3f rg',$r/255,$g/255,$b/255); + $this->ColorFlag=($this->FillColor!=$this->TextColor); +} + +function GetStringWidth($s) +{ + //Get width of a string in the current font + $s=(string)$s; + $cw=&$this->CurrentFont['cw']; + $w=0; + $l=strlen($s); + for($i=0;$i<$l;$i++) + $w+=$cw[$s{$i}]; + return $w*$this->FontSize/1000; +} + +function SetLineWidth($width) +{ + //Set line width + $this->LineWidth=$width; + if($this->page>0) + $this->_out(sprintf('%.2f w',$width*$this->k)); +} + +function Line($x1,$y1,$x2,$y2) +{ + //Draw a line + $this->_out(sprintf('%.2f %.2f m %.2f %.2f l S',$x1*$this->k,($this->h-$y1)*$this->k,$x2*$this->k,($this->h-$y2)*$this->k)); +} + +function Rect($x,$y,$w,$h,$style='') +{ + //Draw a rectangle + if($style=='F') + $op='f'; + elseif($style=='FD' or $style=='DF') + $op='B'; + else + $op='S'; + $this->_out(sprintf('%.2f %.2f %.2f %.2f re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op)); +} + +function AddFont($family,$style='',$file='') +{ + //Add a TrueType or Type1 font + $family=strtolower($family); + if($family=='arial') + $family='helvetica'; + $style=strtoupper($style); + if($style=='IB') + $style='BI'; + if(isset($this->fonts[$family.$style])) + $this->Error('Font already added: '.$family.' '.$style); + if($file=='') + $file=str_replace(' ','',$family).strtolower($style).'.php'; + if(defined('FPDF_FONTPATH')) + $file=FPDF_FONTPATH.$file; + include($file); + if(!isset($name)) + $this->Error('Could not include font definition file'); + $i=count($this->fonts)+1; + $this->fonts[$family.$style]=array('i'=>$i,'type'=>$type,'name'=>$name,'desc'=>$desc,'up'=>$up,'ut'=>$ut,'cw'=>$cw,'enc'=>$enc,'file'=>$file); + if($diff) + { + //Search existing encodings + $d=0; + $nb=count($this->diffs); + for($i=1;$i<=$nb;$i++) + if($this->diffs[$i]==$diff) + { + $d=$i; + break; + } + if($d==0) + { + $d=$nb+1; + $this->diffs[$d]=$diff; + } + $this->fonts[$family.$style]['diff']=$d; + } + if($file) + { + if($type=='TrueType') + $this->FontFiles[$file]=array('length1'=>$originalsize); + else + $this->FontFiles[$file]=array('length1'=>$size1,'length2'=>$size2); + } +} + +function SetFont($family,$style='',$size=0) +{ + //Select a font; size given in points + global $fpdf_charwidths; + + $family=strtolower($family); + if($family=='') + $family=$this->FontFamily; + if($family=='arial') + $family='helvetica'; + elseif($family=='symbol' or $family=='zapfdingbats') + $style=''; + $style=strtoupper($style); + if(is_int(strpos($style,'U'))) + { + $this->underline=true; + $style=str_replace('U','',$style); + } + else + $this->underline=false; + if($style=='IB') + $style='BI'; + if($size==0) + $size=$this->FontSizePt; + //Test if font is already selected + if($this->FontFamily==$family and $this->FontStyle==$style and $this->FontSizePt==$size) + return; + //Test if used for the first time + $fontkey=$family.$style; + if(!isset($this->fonts[$fontkey])) + { + //Check if one of the standard fonts + if(isset($this->CoreFonts[$fontkey])) + { + if(!isset($fpdf_charwidths[$fontkey])) + { + //Load metric file + $file=$family; + if($family=='times' or $family=='helvetica') + $file.=strtolower($style); + $file.='.php'; + if(defined('FPDF_FONTPATH')) + $file=FPDF_FONTPATH.$file; + include($file); + if(!isset($fpdf_charwidths[$fontkey])) + $this->Error('Could not include font metric file'); + } + $i=count($this->fonts)+1; + $this->fonts[$fontkey]=array('i'=>$i,'type'=>'core','name'=>$this->CoreFonts[$fontkey],'up'=>-100,'ut'=>50,'cw'=>$fpdf_charwidths[$fontkey]); + } + else + $this->Error('Undefined font: '.$family.' '.$style); + } + //Select it + $this->FontFamily=$family; + $this->FontStyle=$style; + $this->FontSizePt=$size; + $this->FontSize=$size/$this->k; + $this->CurrentFont=&$this->fonts[$fontkey]; + if($this->page>0) + $this->_out(sprintf('BT /F%d %.2f Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); +} + +function SetFontSize($size) +{ + //Set font size in points + if($this->FontSizePt==$size) + return; + $this->FontSizePt=$size; + $this->FontSize=$size/$this->k; + if($this->page>0) + $this->_out(sprintf('BT /F%d %.2f Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); +} + +function AddLink() +{ + //Create a new internal link + $n=count($this->links)+1; + $this->links[$n]=array(0,0); + return $n; +} + +function SetLink($link,$y=0,$page=-1) +{ + //Set destination of internal link + if($y==-1) + $y=$this->y; + if($page==-1) + $page=$this->page; + $this->links[$link]=array($page,$y); +} + +function Link($x,$y,$w,$h,$link) +{ + //Put a link on the page + $this->PageLinks[$this->page][]=array($x*$this->k,$this->hPt-$y*$this->k,$w*$this->k,$h*$this->k,$link); +} + +function Text($x,$y,$txt) +{ + //Output a string + $s=sprintf('BT %.2f %.2f Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt)); + if($this->underline and $txt!='') + $s.=' '.$this->_dounderline($x,$y,$txt); + if($this->ColorFlag) + $s='q '.$this->TextColor.' '.$s.' Q'; + $this->_out($s); +} + +function AcceptPageBreak() +{ + //Accept automatic page break or not + return $this->AutoPageBreak; +} + +function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='') +{ + //Output a cell + $k=$this->k; + if($this->y+$h>$this->PageBreakTrigger and !$this->InFooter and $this->AcceptPageBreak()) + { + //Automatic page break + $x=$this->x; + $ws=$this->ws; + if($ws>0) + { + $this->ws=0; + $this->_out('0 Tw'); + } + $this->AddPage($this->CurOrientation); + $this->x=$x; + if($ws>0) + { + $this->ws=$ws; + $this->_out(sprintf('%.3f Tw',$ws*$k)); + } + } + if($w==0) + $w=$this->w-$this->rMargin-$this->x; + $s=''; + if($fill==1 or $border==1) + { + if($fill==1) + $op=($border==1) ? 'B' : 'f'; + else + $op='S'; + $s=sprintf('%.2f %.2f %.2f %.2f re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op); + } + if(is_string($border)) + { + $x=$this->x; + $y=$this->y; + if(is_int(strpos($border,'L'))) + $s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k); + if(is_int(strpos($border,'T'))) + $s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k); + if(is_int(strpos($border,'R'))) + $s.=sprintf('%.2f %.2f m %.2f %.2f l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k); + if(is_int(strpos($border,'B'))) + $s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k); + } + if($txt!='') + { + if($align=='R') + $dx=$w-$this->cMargin-$this->GetStringWidth($txt); + elseif($align=='C') + $dx=($w-$this->GetStringWidth($txt))/2; + else + $dx=$this->cMargin; + if($this->ColorFlag) + $s.='q '.$this->TextColor.' '; + $txt2=str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$txt))); + $s.=sprintf('BT %.2f %.2f Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$txt2); + if($this->underline) + $s.=' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt); + if($this->ColorFlag) + $s.=' Q'; + if($link) + $this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link); + } + if($s) + $this->_out($s); + $this->lasth=$h; + if($ln>0) + { + //Go to next line + $this->y+=$h; + if($ln==1) + $this->x=$this->lMargin; + } + else + $this->x+=$w; +} + +function MultiCell($w,$h,$txt,$border=0,$align='J',$fill=0) +{ + //Output text with automatic or explicit line breaks + $cw=&$this->CurrentFont['cw']; + if($w==0) + $w=$this->w-$this->rMargin-$this->x; + $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; + $s=str_replace("\r",'',$txt); + $nb=strlen($s); + if($nb>0 and $s[$nb-1]=="\n") + $nb--; + $b=0; + if($border) + { + if($border==1) + { + $border='LTRB'; + $b='LRT'; + $b2='LR'; + } + else + { + $b2=''; + if(is_int(strpos($border,'L'))) + $b2.='L'; + if(is_int(strpos($border,'R'))) + $b2.='R'; + $b=is_int(strpos($border,'T')) ? $b2.'T' : $b2; + } + } + $sep=-1; + $i=0; + $j=0; + $l=0; + $ns=0; + $nl=1; + while($i<$nb) + { + //Get next character + $c=$s{$i}; + if($c=="\n") + { + //Explicit line break + if($this->ws>0) + { + $this->ws=0; + $this->_out('0 Tw'); + } + $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); + $i++; + $sep=-1; + $j=$i; + $l=0; + $ns=0; + $nl++; + if($border and $nl==2) + $b=$b2; + continue; + } + if($c==' ') + { + $sep=$i; + $ls=$l; + $ns++; + } + $l+=$cw[$c]; + if($l>$wmax) + { + //Automatic line break + if($sep==-1) + { + if($i==$j) + $i++; + if($this->ws>0) + { + $this->ws=0; + $this->_out('0 Tw'); + } + $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); + } + else + { + if($align=='J') + { + $this->ws=($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0; + $this->_out(sprintf('%.3f Tw',$this->ws*$this->k)); + } + $this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill); + $i=$sep+1; + } + $sep=-1; + $j=$i; + $l=0; + $ns=0; + $nl++; + if($border and $nl==2) + $b=$b2; + } + else + $i++; + } + //Last chunk + if($this->ws>0) + { + $this->ws=0; + $this->_out('0 Tw'); + } + if($border and is_int(strpos($border,'B'))) + $b.='B'; + $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); + $this->x=$this->lMargin; +} + +function Write($h,$txt,$link='') +{ + //Output text in flowing mode + $cw=&$this->CurrentFont['cw']; + $w=$this->w-$this->rMargin-$this->x; + $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; + $s=str_replace("\r",'',$txt); + $nb=strlen($s); + $sep=-1; + $i=0; + $j=0; + $l=0; + $nl=1; + while($i<$nb) + { + //Get next character + $c=$s{$i}; + if($c=="\n") + { + //Explicit line break + $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link); + $i++; + $sep=-1; + $j=$i; + $l=0; + if($nl==1) + { + $this->x=$this->lMargin; + $w=$this->w-$this->rMargin-$this->x; + $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; + } + $nl++; + continue; + } + if($c==' ') + $sep=$i; + $l+=$cw[$c]; + if($l>$wmax) + { + //Automatic line break + if($sep==-1) + { + if($this->x>$this->lMargin) + { + //Move to next line + $this->x=$this->lMargin; + $this->y+=$h; + $w=$this->w-$this->rMargin-$this->x; + $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; + $i++; + $nl++; + continue; + } + if($i==$j) + $i++; + $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link); + } + else + { + $this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',0,$link); + $i=$sep+1; + } + $sep=-1; + $j=$i; + $l=0; + if($nl==1) + { + $this->x=$this->lMargin; + $w=$this->w-$this->rMargin-$this->x; + $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; + } + $nl++; + } + else + $i++; + } + //Last chunk + if($i!=$j) + $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',0,$link); +} + +function Image($file,$x,$y,$w=0,$h=0,$type='',$link='') +{ + //Put an image on the page + if(!isset($this->images[$file])) + { + //First use of image, get info + if($type=='') + { + $pos=strrpos($file,'.'); + if(!$pos) + $this->Error('Image file has no extension and no type was specified: '.$file); + $type=substr($file,$pos+1); + } + $type=strtolower($type); + $mqr=get_magic_quotes_runtime(); + set_magic_quotes_runtime(0); + if($type=='jpg' or $type=='jpeg') + $info=$this->_parsejpg($file); + elseif($type=='png') + $info=$this->_parsepng($file); + else + { + //Allow for additional formats + $mtd='_parse'.$type; + if(!method_exists($this,$mtd)) + $this->Error('Unsupported image type: '.$type); + $info=$this->$mtd($file); + } + set_magic_quotes_runtime($mqr); + $info['i']=count($this->images)+1; + $this->images[$file]=$info; + } + else + $info=$this->images[$file]; + //Automatic width and height calculation if needed + if($w==0 and $h==0) + { + //Put image at 72 dpi + $w=$info['w']/$this->k; + $h=$info['h']/$this->k; + } + if($w==0) + $w=$h*$info['w']/$info['h']; + if($h==0) + $h=$w*$info['h']/$info['w']; + $this->_out(sprintf('q %.2f 0 0 %.2f %.2f %.2f cm /I%d Do Q',$w*$this->k,$h*$this->k,$x*$this->k,($this->h-($y+$h))*$this->k,$info['i'])); + if($link) + $this->Link($x,$y,$w,$h,$link); +} + +function Ln($h='') +{ + //Line feed; default value is last cell height + $this->x=$this->lMargin; + if(is_string($h)) + $this->y+=$this->lasth; + else + $this->y+=$h; +} + +function GetX() +{ + //Get x position + return $this->x; +} + +function SetX($x) +{ + //Set x position + if($x>=0) + $this->x=$x; + else + $this->x=$this->w+$x; +} + +function GetY() +{ + //Get y position + return $this->y; +} + +function SetY($y) +{ + //Set y position and reset x + $this->x=$this->lMargin; + if($y>=0) + $this->y=$y; + else + $this->y=$this->h+$y; +} + +function SetXY($x,$y) +{ + //Set x and y positions + $this->SetY($y); + $this->SetX($x); +} + +function Output($name='',$dest='') +{ + //Output PDF to some destination + global $HTTP_SERVER_VARS; + + //Finish document if necessary + if($this->state<3) + $this->Close(); + //Normalize parameters + if(is_bool($dest)) + $dest=$dest ? 'D' : 'F'; + $dest=strtoupper($dest); + if($dest=='') + { + if($name=='') + { + $name='doc.pdf'; + $dest='I'; + } + else + $dest='F'; + } + switch($dest) + { + case 'I': + //Send to standard output + if(isset($_SERVER['SERVER_NAME'])) + { + //We send to a browser + // ffe, regarding a https pdf download issue, 20050720 + Header('Pragma: '); + Header('Cache-Control: '); + // end of modification + Header('Content-Type: application/pdf'); + if(headers_sent()) + $this->Error('Some data has already been output to browser, can\'t send PDF file'); + Header('Content-Length: '.strlen($this->buffer)); + Header('Content-disposition: inline; filename='.$name); + } + echo $this->buffer; + break; + case 'D': + //Download file + if(isset($_SERVER['HTTP_USER_AGENT']) and strpos($_SERVER['HTTP_USER_AGENT'],'MSIE')) + Header('Content-Type: application/force-download'); + else + Header('Content-Type: application/octet-stream'); + if(headers_sent()) + $this->Error('Some data has already been output to browser, can\'t send PDF file'); + Header('Content-Length: '.strlen($this->buffer)); + Header('Content-disposition: attachment; filename='.$name); + echo $this->buffer; + break; + case 'F': + //Save to local file + $f=fopen($name,'wb'); + if(!$f) + $this->Error('Unable to create output file: '.$name); + fwrite($f,$this->buffer,strlen($this->buffer)); + fclose($f); + break; + case 'S': + //Return as a string + return $this->buffer; + default: + $this->Error('Incorrect output destination: '.$dest); + } + return ''; +} + +/******************************************************************************* +* * +* Protected methods * +* * +*******************************************************************************/ +function _dochecks() +{ + //Check for locale-related bug + if(1.1==1) + $this->Error('Don\'t alter the locale before including class file'); + //Check for decimal separator + if(sprintf('%.1f',1.0)!='1.0') + setlocale(LC_NUMERIC,'C'); +} + +function _begindoc() +{ + //Start document + $this->state=1; + $this->_out('%PDF-1.3'); +} + +function _putpages() +{ + $nb=$this->page; + if(!empty($this->AliasNbPages)) + { + //Replace number of pages + for($n=1;$n<=$nb;$n++) + $this->pages[$n]=str_replace($this->AliasNbPages,$nb,$this->pages[$n]); + } + if($this->DefOrientation=='P') + { + $wPt=$this->fwPt; + $hPt=$this->fhPt; + } + else + { + $wPt=$this->fhPt; + $hPt=$this->fwPt; + } + $filter=($this->compress) ? '/Filter /FlateDecode ' : ''; + for($n=1;$n<=$nb;$n++) + { + //Page + $this->_newobj(); + $this->_out('<_out('/Parent 1 0 R'); + if(isset($this->OrientationChanges[$n])) + $this->_out(sprintf('/MediaBox [0 0 %.2f %.2f]',$hPt,$wPt)); + $this->_out('/Resources 2 0 R'); + if(isset($this->PageLinks[$n])) + { + //Links + $annots='/Annots ['; + foreach($this->PageLinks[$n] as $pl) + { + $rect=sprintf('%.2f %.2f %.2f %.2f',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]); + $annots.='<_textstring($pl[4]).'>>>>'; + else + { + $l=$this->links[$pl[4]]; + $h=isset($this->OrientationChanges[$l[0]]) ? $wPt : $hPt; + $annots.=sprintf('/Dest [%d 0 R /XYZ 0 %.2f null]>>',1+2*$l[0],$h-$l[1]*$this->k); + } + } + $this->_out($annots.']'); + } + $this->_out('/Contents '.($this->n+1).' 0 R>>'); + $this->_out('endobj'); + //Page content + $p=($this->compress) ? gzcompress($this->pages[$n]) : $this->pages[$n]; + $this->_newobj(); + $this->_out('<<'.$filter.'/Length '.strlen($p).'>>'); + $this->_putstream($p); + $this->_out('endobj'); + } + //Pages root + $this->offsets[1]=strlen($this->buffer); + $this->_out('1 0 obj'); + $this->_out('<_out($kids.']'); + $this->_out('/Count '.$nb); + $this->_out(sprintf('/MediaBox [0 0 %.2f %.2f]',$wPt,$hPt)); + $this->_out('>>'); + $this->_out('endobj'); +} + +function _putfonts() +{ + $nf=$this->n; + foreach($this->diffs as $diff) + { + //Encodings + $this->_newobj(); + $this->_out('<>'); + $this->_out('endobj'); + } + $mqr=get_magic_quotes_runtime(); + set_magic_quotes_runtime(0); + foreach($this->FontFiles as $file=>$info) + { + //Font file embedding + $this->_newobj(); + $this->FontFiles[$file]['n']=$this->n; + if(defined('FPDF_FONTPATH')) + $file=FPDF_FONTPATH.$file; + $size=filesize($file); + if(!$size) + $this->Error('Font file not found'); + $this->_out('<_out('/Filter /FlateDecode'); + $this->_out('/Length1 '.$info['length1']); + if(isset($info['length2'])) + $this->_out('/Length2 '.$info['length2'].' /Length3 0'); + $this->_out('>>'); + $f=fopen($file,'rb'); + $this->_putstream(fread($f,$size)); + fclose($f); + $this->_out('endobj'); + } + set_magic_quotes_runtime($mqr); + foreach($this->fonts as $k=>$font) + { + //Font objects + $this->fonts[$k]['n']=$this->n+1; + $type=$font['type']; + $name=$font['name']; + if($type=='core') + { + //Standard font + $this->_newobj(); + $this->_out('<_out('/BaseFont /'.$name); + $this->_out('/Subtype /Type1'); + if($name!='Symbol' and $name!='ZapfDingbats') + $this->_out('/Encoding /WinAnsiEncoding'); + $this->_out('>>'); + $this->_out('endobj'); + } + elseif($type=='Type1' or $type=='TrueType') + { + //Additional Type1 or TrueType font + $this->_newobj(); + $this->_out('<_out('/BaseFont /'.$name); + $this->_out('/Subtype /'.$type); + $this->_out('/FirstChar 32 /LastChar 255'); + $this->_out('/Widths '.($this->n+1).' 0 R'); + $this->_out('/FontDescriptor '.($this->n+2).' 0 R'); + if($font['enc']) + { + if(isset($font['diff'])) + $this->_out('/Encoding '.($nf+$font['diff']).' 0 R'); + else + $this->_out('/Encoding /WinAnsiEncoding'); + } + $this->_out('>>'); + $this->_out('endobj'); + //Widths + $this->_newobj(); + $cw=&$font['cw']; + $s='['; + for($i=32;$i<=255;$i++) + $s.=$cw[chr($i)].' '; + $this->_out($s.']'); + $this->_out('endobj'); + //Descriptor + $this->_newobj(); + $s='<$v) + $s.=' /'.$k.' '.$v; + $file=$font['file']; + if($file) + $s.=' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$file]['n'].' 0 R'; + $this->_out($s.'>>'); + $this->_out('endobj'); + } + else + { + //Allow for additional types + $mtd='_put'.strtolower($type); + if(!method_exists($this,$mtd)) + $this->Error('Unsupported font type: '.$type); + $this->$mtd($font); + } + } +} + +function _putimages() +{ + $filter=($this->compress) ? '/Filter /FlateDecode ' : ''; + reset($this->images); + while(list($file,$info)=each($this->images)) + { + $this->_newobj(); + $this->images[$file]['n']=$this->n; + $this->_out('<_out('/Subtype /Image'); + $this->_out('/Width '.$info['w']); + $this->_out('/Height '.$info['h']); + if($info['cs']=='Indexed') + $this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]'); + else + { + $this->_out('/ColorSpace /'.$info['cs']); + if($info['cs']=='DeviceCMYK') + $this->_out('/Decode [1 0 1 0 1 0 1 0]'); + } + $this->_out('/BitsPerComponent '.$info['bpc']); + $this->_out('/Filter /'.$info['f']); + if(isset($info['parms'])) + $this->_out($info['parms']); + if(isset($info['trns']) and is_array($info['trns'])) + { + $trns=''; + for($i=0;$i_out('/Mask ['.$trns.']'); + } + $this->_out('/Length '.strlen($info['data']).'>>'); + $this->_putstream($info['data']); + unset($this->images[$file]['data']); + $this->_out('endobj'); + //Palette + if($info['cs']=='Indexed') + { + $this->_newobj(); + $pal=($this->compress) ? gzcompress($info['pal']) : $info['pal']; + $this->_out('<<'.$filter.'/Length '.strlen($pal).'>>'); + $this->_putstream($pal); + $this->_out('endobj'); + } + } +} + +function _putresources() +{ + $this->_putfonts(); + $this->_putimages(); + //Resource dictionary + $this->offsets[2]=strlen($this->buffer); + $this->_out('2 0 obj'); + $this->_out('<_out('/Font <<'); + foreach($this->fonts as $font) + $this->_out('/F'.$font['i'].' '.$font['n'].' 0 R'); + $this->_out('>>'); + if(count($this->images)) + { + $this->_out('/XObject <<'); + foreach($this->images as $image) + $this->_out('/I'.$image['i'].' '.$image['n'].' 0 R'); + $this->_out('>>'); + } + $this->_out('>>'); + $this->_out('endobj'); +} + +function _putinfo() +{ + $this->_out('/Producer '.$this->_textstring('FPDF '.FPDF_VERSION)); + if(!empty($this->title)) + $this->_out('/Title '.$this->_textstring($this->title)); + if(!empty($this->subject)) + $this->_out('/Subject '.$this->_textstring($this->subject)); + if(!empty($this->author)) + $this->_out('/Author '.$this->_textstring($this->author)); + if(!empty($this->keywords)) + $this->_out('/Keywords '.$this->_textstring($this->keywords)); + if(!empty($this->creator)) + $this->_out('/Creator '.$this->_textstring($this->creator)); + $this->_out('/CreationDate '.$this->_textstring('D:'.date('YmdHis'))); +} + +function _putcatalog() +{ + $this->_out('/Type /Catalog'); + $this->_out('/Pages 1 0 R'); + if($this->ZoomMode=='fullpage') + $this->_out('/OpenAction [3 0 R /Fit]'); + elseif($this->ZoomMode=='fullwidth') + $this->_out('/OpenAction [3 0 R /FitH null]'); + elseif($this->ZoomMode=='real') + $this->_out('/OpenAction [3 0 R /XYZ null null 1]'); + elseif(!is_string($this->ZoomMode)) + $this->_out('/OpenAction [3 0 R /XYZ null null '.($this->ZoomMode/100).']'); + if($this->LayoutMode=='single') + $this->_out('/PageLayout /SinglePage'); + elseif($this->LayoutMode=='continuous') + $this->_out('/PageLayout /OneColumn'); + elseif($this->LayoutMode=='two') + $this->_out('/PageLayout /TwoColumnLeft'); +} + +function _puttrailer() +{ + $this->_out('/Size '.($this->n+1)); + $this->_out('/Root '.$this->n.' 0 R'); + $this->_out('/Info '.($this->n-1).' 0 R'); +} + +function _enddoc() +{ + $this->_putpages(); + $this->_putresources(); + //Info + $this->_newobj(); + $this->_out('<<'); + $this->_putinfo(); + $this->_out('>>'); + $this->_out('endobj'); + //Catalog + $this->_newobj(); + $this->_out('<<'); + $this->_putcatalog(); + $this->_out('>>'); + $this->_out('endobj'); + //Cross-ref + $o=strlen($this->buffer); + $this->_out('xref'); + $this->_out('0 '.($this->n+1)); + $this->_out('0000000000 65535 f '); + for($i=1;$i<=$this->n;$i++) + $this->_out(sprintf('%010d 00000 n ',$this->offsets[$i])); + //Trailer + $this->_out('trailer'); + $this->_out('<<'); + $this->_puttrailer(); + $this->_out('>>'); + $this->_out('startxref'); + $this->_out($o); + $this->_out('%%EOF'); + $this->state=3; +} + +function _beginpage($orientation) +{ + $this->page++; + $this->pages[$this->page]=''; + $this->state=2; + $this->x=$this->lMargin; + $this->y=$this->tMargin; + $this->FontFamily=''; + //Page orientation + if(!$orientation) + $orientation=$this->DefOrientation; + else + { + $orientation=strtoupper($orientation{0}); + if($orientation!=$this->DefOrientation) + $this->OrientationChanges[$this->page]=true; + } + if($orientation!=$this->CurOrientation) + { + //Change orientation + if($orientation=='P') + { + $this->wPt=$this->fwPt; + $this->hPt=$this->fhPt; + $this->w=$this->fw; + $this->h=$this->fh; + } + else + { + $this->wPt=$this->fhPt; + $this->hPt=$this->fwPt; + $this->w=$this->fh; + $this->h=$this->fw; + } + $this->PageBreakTrigger=$this->h-$this->bMargin; + $this->CurOrientation=$orientation; + } +} + +function _endpage() +{ + //End of page contents + $this->state=1; +} + +function _newobj() +{ + //Begin a new object + $this->n++; + $this->offsets[$this->n]=strlen($this->buffer); + $this->_out($this->n.' 0 obj'); +} + +function _dounderline($x,$y,$txt) +{ + //Underline text + $up=$this->CurrentFont['up']; + $ut=$this->CurrentFont['ut']; + $w=$this->GetStringWidth($txt)+$this->ws*substr_count($txt,' '); + return sprintf('%.2f %.2f %.2f %.2f re f',$x*$this->k,($this->h-($y-$up/1000*$this->FontSize))*$this->k,$w*$this->k,-$ut/1000*$this->FontSizePt); +} + +function _parsejpg($file) +{ + //Extract info from a JPEG file + $a=GetImageSize($file); + if(!$a) + $this->Error('Missing or incorrect image file: '.$file); + if($a[2]!=2) + $this->Error('Not a JPEG file: '.$file); + if(!isset($a['channels']) or $a['channels']==3) + $colspace='DeviceRGB'; + elseif($a['channels']==4) + $colspace='DeviceCMYK'; + else + $colspace='DeviceGray'; + $bpc=isset($a['bits']) ? $a['bits'] : 8; + //Read whole file + $f=fopen($file,'rb'); + $data=''; + while(!feof($f)) + $data.=fread($f,4096); + fclose($f); + return array('w'=>$a[0],'h'=>$a[1],'cs'=>$colspace,'bpc'=>$bpc,'f'=>'DCTDecode','data'=>$data); +} + +function _parsepng($file) +{ + //Extract info from a PNG file + $f=fopen($file,'rb'); + if(!$f) + $this->Error('Can\'t open image file: '.$file); + //Check signature + if(fread($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) + $this->Error('Not a PNG file: '.$file); + //Read header chunk + fread($f,4); + if(fread($f,4)!='IHDR') + $this->Error('Incorrect PNG file: '.$file); + $w=$this->_freadint($f); + $h=$this->_freadint($f); + $bpc=ord(fread($f,1)); + if($bpc>8) + $this->Error('16-bit depth not supported: '.$file); + $ct=ord(fread($f,1)); + if($ct==0) + $colspace='DeviceGray'; + elseif($ct==2) + $colspace='DeviceRGB'; + elseif($ct==3) + $colspace='Indexed'; + else + $this->Error('Alpha channel not supported: '.$file); + if(ord(fread($f,1))!=0) + $this->Error('Unknown compression method: '.$file); + if(ord(fread($f,1))!=0) + $this->Error('Unknown filter method: '.$file); + if(ord(fread($f,1))!=0) + $this->Error('Interlacing not supported: '.$file); + fread($f,4); + $parms='/DecodeParms <>'; + //Scan chunks looking for palette, transparency and image data + $pal=''; + $trns=''; + $data=''; + do + { + $n=$this->_freadint($f); + $type=fread($f,4); + if($type=='PLTE') + { + //Read palette + $pal=fread($f,$n); + fread($f,4); + } + elseif($type=='tRNS') + { + //Read transparency info + $t=fread($f,$n); + if($ct==0) + $trns=array(ord(substr($t,1,1))); + elseif($ct==2) + $trns=array(ord(substr($t,1,1)),ord(substr($t,3,1)),ord(substr($t,5,1))); + else + { + $pos=strpos($t,chr(0)); + if(is_int($pos)) + $trns=array($pos); + } + fread($f,4); + } + elseif($type=='IDAT') + { + //Read image data block + $data.=fread($f,$n); + fread($f,4); + } + elseif($type=='IEND') + break; + else + fread($f,$n+4); + } + while($n); + if($colspace=='Indexed' and empty($pal)) + $this->Error('Missing palette in '.$file); + fclose($f); + return array('w'=>$w,'h'=>$h,'cs'=>$colspace,'bpc'=>$bpc,'f'=>'FlateDecode','parms'=>$parms,'pal'=>$pal,'trns'=>$trns,'data'=>$data); +} + +function _freadint($f) +{ + //Read a 4-byte integer from file + $i=ord(fread($f,1))<<24; + $i+=ord(fread($f,1))<<16; + $i+=ord(fread($f,1))<<8; + $i+=ord(fread($f,1)); + return $i; +} + +function _textstring($s) +{ + //Format a text string + return '('.$this->_escape($s).')'; +} + +function _escape($s) +{ + //Add \ before \, ( and ) + return str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$s))); +} + +function _putstream($s) +{ + $this->_out('stream'); + $this->_out($s); + $this->_out('endstream'); +} + +function _out($s) +{ + //Add a line to the document + if($this->state==2) + $this->pages[$this->page].=$s."\n"; + else + $this->buffer.=$s."\n"; +} +//End of class +} + +//Handle special IE contype request +if(isset($_SERVER['HTTP_USER_AGENT']) and $_SERVER['HTTP_USER_AGENT']=='contype') +{ + Header('Content-Type: application/pdf'); + exit; +} + +} +?> diff --git a/include/pdf/fpdf.php.ie b/include/pdf/fpdf.php.ie new file mode 100644 index 000000000..631ab7f1e --- /dev/null +++ b/include/pdf/fpdf.php.ie @@ -0,0 +1,1618 @@ +_dochecks(); + //Initialization of properties + $this->page=0; + $this->n=2; + $this->buffer=''; + $this->pages=array(); + $this->OrientationChanges=array(); + $this->state=0; + $this->fonts=array(); + $this->FontFiles=array(); + $this->diffs=array(); + $this->images=array(); + $this->links=array(); + $this->InFooter=false; + $this->lasth=0; + $this->FontFamily=''; + $this->FontStyle=''; + $this->FontSizePt=12; + $this->underline=false; + $this->DrawColor='0 G'; + $this->FillColor='0 g'; + $this->TextColor='0 g'; + $this->ColorFlag=false; + $this->ws=0; + //Standard fonts + $this->CoreFonts=array('courier'=>'Courier','courierB'=>'Courier-Bold','courierI'=>'Courier-Oblique','courierBI'=>'Courier-BoldOblique', + 'helvetica'=>'Helvetica','helveticaB'=>'Helvetica-Bold','helveticaI'=>'Helvetica-Oblique','helveticaBI'=>'Helvetica-BoldOblique', + 'times'=>'Times-Roman','timesB'=>'Times-Bold','timesI'=>'Times-Italic','timesBI'=>'Times-BoldItalic', + 'symbol'=>'Symbol','zapfdingbats'=>'ZapfDingbats'); + //Scale factor + if($unit=='pt') + $this->k=1; + elseif($unit=='mm') + $this->k=72/25.4; + elseif($unit=='cm') + $this->k=72/2.54; + elseif($unit=='in') + $this->k=72; + else + $this->Error('Incorrect unit: '.$unit); + //Page format + if(is_string($format)) + { + $format=strtolower($format); + if($format=='a3') + $format=array(841.89,1190.55); + elseif($format=='a4') + $format=array(595.28,841.89); + elseif($format=='a5') + $format=array(420.94,595.28); + elseif($format=='letter') + $format=array(612,792); + elseif($format=='legal') + $format=array(612,1008); + else + $this->Error('Unknown page format: '.$format); + $this->fwPt=$format[0]; + $this->fhPt=$format[1]; + } + else + { + $this->fwPt=$format[0]*$this->k; + $this->fhPt=$format[1]*$this->k; + } + $this->fw=$this->fwPt/$this->k; + $this->fh=$this->fhPt/$this->k; + //Page orientation + $orientation=strtolower($orientation); + if($orientation=='p' or $orientation=='portrait') + { + $this->DefOrientation='P'; + $this->wPt=$this->fwPt; + $this->hPt=$this->fhPt; + } + elseif($orientation=='l' or $orientation=='landscape') + { + $this->DefOrientation='L'; + $this->wPt=$this->fhPt; + $this->hPt=$this->fwPt; + } + else + $this->Error('Incorrect orientation: '.$orientation); + $this->CurOrientation=$this->DefOrientation; + $this->w=$this->wPt/$this->k; + $this->h=$this->hPt/$this->k; + //Page margins (1 cm) + $margin=28.35/$this->k; + $this->SetMargins($margin,$margin); + //Interior cell margin (1 mm) + $this->cMargin=$margin/10; + //Line width (0.2 mm) + $this->LineWidth=.567/$this->k; + //Automatic page break + $this->SetAutoPageBreak(true,2*$margin); + //Full width display mode + $this->SetDisplayMode('fullwidth'); + //Compression + $this->SetCompression(true); +} + +function SetMargins($left,$top,$right=-1) +{ + //Set left, top and right margins + $this->lMargin=$left; + $this->tMargin=$top; + if($right==-1) + $right=$left; + $this->rMargin=$right; +} + +function SetLeftMargin($margin) +{ + //Set left margin + $this->lMargin=$margin; + if($this->page>0 and $this->x<$margin) + $this->x=$margin; +} + +function SetTopMargin($margin) +{ + //Set top margin + $this->tMargin=$margin; +} + +function SetRightMargin($margin) +{ + //Set right margin + $this->rMargin=$margin; +} + +function SetAutoPageBreak($auto,$margin=0) +{ + //Set auto page break mode and triggering margin + $this->AutoPageBreak=$auto; + $this->bMargin=$margin; + $this->PageBreakTrigger=$this->h-$margin; +} + +function SetDisplayMode($zoom,$layout='continuous') +{ + //Set display mode in viewer + if($zoom=='fullpage' or $zoom=='fullwidth' or $zoom=='real' or $zoom=='default' or !is_string($zoom)) + $this->ZoomMode=$zoom; + else + $this->Error('Incorrect zoom display mode: '.$zoom); + if($layout=='single' or $layout=='continuous' or $layout=='two' or $layout=='default') + $this->LayoutMode=$layout; + else + $this->Error('Incorrect layout display mode: '.$layout); +} + +function SetCompression($compress) +{ + //Set page compression + if(function_exists('gzcompress')) + $this->compress=$compress; + else + $this->compress=false; +} + +function SetTitle($title) +{ + //Title of document + $this->title=$title; +} + +function SetSubject($subject) +{ + //Subject of document + $this->subject=$subject; +} + +function SetAuthor($author) +{ + //Author of document + $this->author=$author; +} + +function SetKeywords($keywords) +{ + //Keywords of document + $this->keywords=$keywords; +} + +function SetCreator($creator) +{ + //Creator of document + $this->creator=$creator; +} + +function AliasNbPages($alias='{nb}') +{ + //Define an alias for total number of pages + $this->AliasNbPages=$alias; +} + +function Error($msg) +{ + //Fatal error + die('FPDF error: '.$msg); +} + +function Open() +{ + //Begin document + if($this->state==0) + $this->_begindoc(); +} + +function Close() +{ + //Terminate document + if($this->state==3) + return; + if($this->page==0) + $this->AddPage(); + //Page footer + $this->InFooter=true; + $this->Footer(); + $this->InFooter=false; + //Close page + $this->_endpage(); + //Close document + $this->_enddoc(); +} + +function AddPage($orientation='') +{ + //Start a new page + if($this->state==0) + $this->Open(); + $family=$this->FontFamily; + $style=$this->FontStyle.($this->underline ? 'U' : ''); + $size=$this->FontSizePt; + $lw=$this->LineWidth; + $dc=$this->DrawColor; + $fc=$this->FillColor; + $tc=$this->TextColor; + $cf=$this->ColorFlag; + if($this->page>0) + { + //Page footer + $this->InFooter=true; + $this->Footer(); + $this->InFooter=false; + //Close page + $this->_endpage(); + } + //Start new page + $this->_beginpage($orientation); + //Set line cap style to square + $this->_out('2 J'); + //Set line width + $this->LineWidth=$lw; + $this->_out(sprintf('%.2f w',$lw*$this->k)); + //Set font + if($family) + $this->SetFont($family,$style,$size); + //Set colors + $this->DrawColor=$dc; + if($dc!='0 G') + $this->_out($dc); + $this->FillColor=$fc; + if($fc!='0 g') + $this->_out($fc); + $this->TextColor=$tc; + $this->ColorFlag=$cf; + //Page header + $this->Header(); + //Restore line width + if($this->LineWidth!=$lw) + { + $this->LineWidth=$lw; + $this->_out(sprintf('%.2f w',$lw*$this->k)); + } + //Restore font + if($family) + $this->SetFont($family,$style,$size); + //Restore colors + if($this->DrawColor!=$dc) + { + $this->DrawColor=$dc; + $this->_out($dc); + } + if($this->FillColor!=$fc) + { + $this->FillColor=$fc; + $this->_out($fc); + } + $this->TextColor=$tc; + $this->ColorFlag=$cf; +} + +function Header() +{ + //To be implemented in your own inherited class +} + +function Footer() +{ + //To be implemented in your own inherited class +} + +function PageNo() +{ + //Get current page number + return $this->page; +} + +function SetDrawColor($r,$g=-1,$b=-1) +{ + //Set color for all stroking operations + if(($r==0 and $g==0 and $b==0) or $g==-1) + $this->DrawColor=sprintf('%.3f G',$r/255); + else + $this->DrawColor=sprintf('%.3f %.3f %.3f RG',$r/255,$g/255,$b/255); + if($this->page>0) + $this->_out($this->DrawColor); +} + +function SetFillColor($r,$g=-1,$b=-1) +{ + //Set color for all filling operations + if(($r==0 and $g==0 and $b==0) or $g==-1) + $this->FillColor=sprintf('%.3f g',$r/255); + else + $this->FillColor=sprintf('%.3f %.3f %.3f rg',$r/255,$g/255,$b/255); + $this->ColorFlag=($this->FillColor!=$this->TextColor); + if($this->page>0) + $this->_out($this->FillColor); +} + +function SetTextColor($r,$g=-1,$b=-1) +{ + //Set color for text + if(($r==0 and $g==0 and $b==0) or $g==-1) + $this->TextColor=sprintf('%.3f g',$r/255); + else + $this->TextColor=sprintf('%.3f %.3f %.3f rg',$r/255,$g/255,$b/255); + $this->ColorFlag=($this->FillColor!=$this->TextColor); +} + +function GetStringWidth($s) +{ + //Get width of a string in the current font + $s=(string)$s; + $cw=&$this->CurrentFont['cw']; + $w=0; + $l=strlen($s); + for($i=0;$i<$l;$i++) + $w+=$cw[$s{$i}]; + return $w*$this->FontSize/1000; +} + +function SetLineWidth($width) +{ + //Set line width + $this->LineWidth=$width; + if($this->page>0) + $this->_out(sprintf('%.2f w',$width*$this->k)); +} + +function Line($x1,$y1,$x2,$y2) +{ + //Draw a line + $this->_out(sprintf('%.2f %.2f m %.2f %.2f l S',$x1*$this->k,($this->h-$y1)*$this->k,$x2*$this->k,($this->h-$y2)*$this->k)); +} + +function Rect($x,$y,$w,$h,$style='') +{ + //Draw a rectangle + if($style=='F') + $op='f'; + elseif($style=='FD' or $style=='DF') + $op='B'; + else + $op='S'; + $this->_out(sprintf('%.2f %.2f %.2f %.2f re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op)); +} + +function AddFont($family,$style='',$file='') +{ + //Add a TrueType or Type1 font + $family=strtolower($family); + if($family=='arial') + $family='helvetica'; + $style=strtoupper($style); + if($style=='IB') + $style='BI'; + if(isset($this->fonts[$family.$style])) + $this->Error('Font already added: '.$family.' '.$style); + if($file=='') + $file=str_replace(' ','',$family).strtolower($style).'.php'; + if(defined('FPDF_FONTPATH')) + $file=FPDF_FONTPATH.$file; + include($file); + if(!isset($name)) + $this->Error('Could not include font definition file'); + $i=count($this->fonts)+1; + $this->fonts[$family.$style]=array('i'=>$i,'type'=>$type,'name'=>$name,'desc'=>$desc,'up'=>$up,'ut'=>$ut,'cw'=>$cw,'enc'=>$enc,'file'=>$file); + if($diff) + { + //Search existing encodings + $d=0; + $nb=count($this->diffs); + for($i=1;$i<=$nb;$i++) + if($this->diffs[$i]==$diff) + { + $d=$i; + break; + } + if($d==0) + { + $d=$nb+1; + $this->diffs[$d]=$diff; + } + $this->fonts[$family.$style]['diff']=$d; + } + if($file) + { + if($type=='TrueType') + $this->FontFiles[$file]=array('length1'=>$originalsize); + else + $this->FontFiles[$file]=array('length1'=>$size1,'length2'=>$size2); + } +} + +function SetFont($family,$style='',$size=0) +{ + //Select a font; size given in points + global $fpdf_charwidths; + + $family=strtolower($family); + if($family=='') + $family=$this->FontFamily; + if($family=='arial') + $family='helvetica'; + elseif($family=='symbol' or $family=='zapfdingbats') + $style=''; + $style=strtoupper($style); + if(is_int(strpos($style,'U'))) + { + $this->underline=true; + $style=str_replace('U','',$style); + } + else + $this->underline=false; + if($style=='IB') + $style='BI'; + if($size==0) + $size=$this->FontSizePt; + //Test if font is already selected + if($this->FontFamily==$family and $this->FontStyle==$style and $this->FontSizePt==$size) + return; + //Test if used for the first time + $fontkey=$family.$style; + if(!isset($this->fonts[$fontkey])) + { + //Check if one of the standard fonts + if(isset($this->CoreFonts[$fontkey])) + { + if(!isset($fpdf_charwidths[$fontkey])) + { + //Load metric file + $file=$family; + if($family=='times' or $family=='helvetica') + $file.=strtolower($style); + $file.='.php'; + if(defined('FPDF_FONTPATH')) + $file=FPDF_FONTPATH.$file; + include($file); + if(!isset($fpdf_charwidths[$fontkey])) + $this->Error('Could not include font metric file'); + } + $i=count($this->fonts)+1; + $this->fonts[$fontkey]=array('i'=>$i,'type'=>'core','name'=>$this->CoreFonts[$fontkey],'up'=>-100,'ut'=>50,'cw'=>$fpdf_charwidths[$fontkey]); + } + else + $this->Error('Undefined font: '.$family.' '.$style); + } + //Select it + $this->FontFamily=$family; + $this->FontStyle=$style; + $this->FontSizePt=$size; + $this->FontSize=$size/$this->k; + $this->CurrentFont=&$this->fonts[$fontkey]; + if($this->page>0) + $this->_out(sprintf('BT /F%d %.2f Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); +} + +function SetFontSize($size) +{ + //Set font size in points + if($this->FontSizePt==$size) + return; + $this->FontSizePt=$size; + $this->FontSize=$size/$this->k; + if($this->page>0) + $this->_out(sprintf('BT /F%d %.2f Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); +} + +function AddLink() +{ + //Create a new internal link + $n=count($this->links)+1; + $this->links[$n]=array(0,0); + return $n; +} + +function SetLink($link,$y=0,$page=-1) +{ + //Set destination of internal link + if($y==-1) + $y=$this->y; + if($page==-1) + $page=$this->page; + $this->links[$link]=array($page,$y); +} + +function Link($x,$y,$w,$h,$link) +{ + //Put a link on the page + $this->PageLinks[$this->page][]=array($x*$this->k,$this->hPt-$y*$this->k,$w*$this->k,$h*$this->k,$link); +} + +function Text($x,$y,$txt) +{ + //Output a string + $s=sprintf('BT %.2f %.2f Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt)); + if($this->underline and $txt!='') + $s.=' '.$this->_dounderline($x,$y,$txt); + if($this->ColorFlag) + $s='q '.$this->TextColor.' '.$s.' Q'; + $this->_out($s); +} + +function AcceptPageBreak() +{ + //Accept automatic page break or not + return $this->AutoPageBreak; +} + +function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='') +{ + //Output a cell + $k=$this->k; + if($this->y+$h>$this->PageBreakTrigger and !$this->InFooter and $this->AcceptPageBreak()) + { + //Automatic page break + $x=$this->x; + $ws=$this->ws; + if($ws>0) + { + $this->ws=0; + $this->_out('0 Tw'); + } + $this->AddPage($this->CurOrientation); + $this->x=$x; + if($ws>0) + { + $this->ws=$ws; + $this->_out(sprintf('%.3f Tw',$ws*$k)); + } + } + if($w==0) + $w=$this->w-$this->rMargin-$this->x; + $s=''; + if($fill==1 or $border==1) + { + if($fill==1) + $op=($border==1) ? 'B' : 'f'; + else + $op='S'; + $s=sprintf('%.2f %.2f %.2f %.2f re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op); + } + if(is_string($border)) + { + $x=$this->x; + $y=$this->y; + if(is_int(strpos($border,'L'))) + $s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k); + if(is_int(strpos($border,'T'))) + $s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k); + if(is_int(strpos($border,'R'))) + $s.=sprintf('%.2f %.2f m %.2f %.2f l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k); + if(is_int(strpos($border,'B'))) + $s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k); + } + if($txt!='') + { + if($align=='R') + $dx=$w-$this->cMargin-$this->GetStringWidth($txt); + elseif($align=='C') + $dx=($w-$this->GetStringWidth($txt))/2; + else + $dx=$this->cMargin; + if($this->ColorFlag) + $s.='q '.$this->TextColor.' '; + $txt2=str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$txt))); + $s.=sprintf('BT %.2f %.2f Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$txt2); + if($this->underline) + $s.=' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt); + if($this->ColorFlag) + $s.=' Q'; + if($link) + $this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link); + } + if($s) + $this->_out($s); + $this->lasth=$h; + if($ln>0) + { + //Go to next line + $this->y+=$h; + if($ln==1) + $this->x=$this->lMargin; + } + else + $this->x+=$w; +} + +function MultiCell($w,$h,$txt,$border=0,$align='J',$fill=0) +{ + //Output text with automatic or explicit line breaks + $cw=&$this->CurrentFont['cw']; + if($w==0) + $w=$this->w-$this->rMargin-$this->x; + $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; + $s=str_replace("\r",'',$txt); + $nb=strlen($s); + if($nb>0 and $s[$nb-1]=="\n") + $nb--; + $b=0; + if($border) + { + if($border==1) + { + $border='LTRB'; + $b='LRT'; + $b2='LR'; + } + else + { + $b2=''; + if(is_int(strpos($border,'L'))) + $b2.='L'; + if(is_int(strpos($border,'R'))) + $b2.='R'; + $b=is_int(strpos($border,'T')) ? $b2.'T' : $b2; + } + } + $sep=-1; + $i=0; + $j=0; + $l=0; + $ns=0; + $nl=1; + while($i<$nb) + { + //Get next character + $c=$s{$i}; + if($c=="\n") + { + //Explicit line break + if($this->ws>0) + { + $this->ws=0; + $this->_out('0 Tw'); + } + $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); + $i++; + $sep=-1; + $j=$i; + $l=0; + $ns=0; + $nl++; + if($border and $nl==2) + $b=$b2; + continue; + } + if($c==' ') + { + $sep=$i; + $ls=$l; + $ns++; + } + $l+=$cw[$c]; + if($l>$wmax) + { + //Automatic line break + if($sep==-1) + { + if($i==$j) + $i++; + if($this->ws>0) + { + $this->ws=0; + $this->_out('0 Tw'); + } + $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); + } + else + { + if($align=='J') + { + $this->ws=($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0; + $this->_out(sprintf('%.3f Tw',$this->ws*$this->k)); + } + $this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill); + $i=$sep+1; + } + $sep=-1; + $j=$i; + $l=0; + $ns=0; + $nl++; + if($border and $nl==2) + $b=$b2; + } + else + $i++; + } + //Last chunk + if($this->ws>0) + { + $this->ws=0; + $this->_out('0 Tw'); + } + if($border and is_int(strpos($border,'B'))) + $b.='B'; + $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); + $this->x=$this->lMargin; +} + +function Write($h,$txt,$link='') +{ + //Output text in flowing mode + $cw=&$this->CurrentFont['cw']; + $w=$this->w-$this->rMargin-$this->x; + $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; + $s=str_replace("\r",'',$txt); + $nb=strlen($s); + $sep=-1; + $i=0; + $j=0; + $l=0; + $nl=1; + while($i<$nb) + { + //Get next character + $c=$s{$i}; + if($c=="\n") + { + //Explicit line break + $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link); + $i++; + $sep=-1; + $j=$i; + $l=0; + if($nl==1) + { + $this->x=$this->lMargin; + $w=$this->w-$this->rMargin-$this->x; + $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; + } + $nl++; + continue; + } + if($c==' ') + $sep=$i; + $l+=$cw[$c]; + if($l>$wmax) + { + //Automatic line break + if($sep==-1) + { + if($this->x>$this->lMargin) + { + //Move to next line + $this->x=$this->lMargin; + $this->y+=$h; + $w=$this->w-$this->rMargin-$this->x; + $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; + $i++; + $nl++; + continue; + } + if($i==$j) + $i++; + $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link); + } + else + { + $this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',0,$link); + $i=$sep+1; + } + $sep=-1; + $j=$i; + $l=0; + if($nl==1) + { + $this->x=$this->lMargin; + $w=$this->w-$this->rMargin-$this->x; + $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; + } + $nl++; + } + else + $i++; + } + //Last chunk + if($i!=$j) + $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',0,$link); +} + +function Image($file,$x,$y,$w=0,$h=0,$type='',$link='') +{ + //Put an image on the page + if(!isset($this->images[$file])) + { + //First use of image, get info + if($type=='') + { + $pos=strrpos($file,'.'); + if(!$pos) + $this->Error('Image file has no extension and no type was specified: '.$file); + $type=substr($file,$pos+1); + } + $type=strtolower($type); + $mqr=get_magic_quotes_runtime(); + set_magic_quotes_runtime(0); + if($type=='jpg' or $type=='jpeg') + $info=$this->_parsejpg($file); + elseif($type=='png') + $info=$this->_parsepng($file); + else + { + //Allow for additional formats + $mtd='_parse'.$type; + if(!method_exists($this,$mtd)) + $this->Error('Unsupported image type: '.$type); + $info=$this->$mtd($file); + } + set_magic_quotes_runtime($mqr); + $info['i']=count($this->images)+1; + $this->images[$file]=$info; + } + else + $info=$this->images[$file]; + //Automatic width and height calculation if needed + if($w==0 and $h==0) + { + //Put image at 72 dpi + $w=$info['w']/$this->k; + $h=$info['h']/$this->k; + } + if($w==0) + $w=$h*$info['w']/$info['h']; + if($h==0) + $h=$w*$info['h']/$info['w']; + $this->_out(sprintf('q %.2f 0 0 %.2f %.2f %.2f cm /I%d Do Q',$w*$this->k,$h*$this->k,$x*$this->k,($this->h-($y+$h))*$this->k,$info['i'])); + if($link) + $this->Link($x,$y,$w,$h,$link); +} + +function Ln($h='') +{ + //Line feed; default value is last cell height + $this->x=$this->lMargin; + if(is_string($h)) + $this->y+=$this->lasth; + else + $this->y+=$h; +} + +function GetX() +{ + //Get x position + return $this->x; +} + +function SetX($x) +{ + //Set x position + if($x>=0) + $this->x=$x; + else + $this->x=$this->w+$x; +} + +function GetY() +{ + //Get y position + return $this->y; +} + +function SetY($y) +{ + //Set y position and reset x + $this->x=$this->lMargin; + if($y>=0) + $this->y=$y; + else + $this->y=$this->h+$y; +} + +function SetXY($x,$y) +{ + //Set x and y positions + $this->SetY($y); + $this->SetX($x); +} + +function Output($name='',$dest='') +{ + //Output PDF to some destination + global $HTTP_SERVER_VARS; + + //Finish document if necessary + if($this->state<3) + $this->Close(); + //Normalize parameters + if(is_bool($dest)) + $dest=$dest ? 'D' : 'F'; + $dest=strtoupper($dest); + if($dest=='') + { + if($name=='') + { + $name='doc.pdf'; + $dest='I'; + } + else + $dest='F'; + } + switch($dest) + { + case 'I': + //Send to standard output + if(isset($HTTP_SERVER_VARS['SERVER_NAME'])) + { + //We send to a browser + Header('Content-Type: application/pdf'); + if(headers_sent()) + $this->Error('Some data has already been output to browser, can\'t send PDF file'); + Header('Content-Length: '.strlen($this->buffer)); + Header('Content-disposition: inline; filename='.$name); + } + echo $this->buffer; + break; + case 'D': + //Download file + if(isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']) and strpos($HTTP_SERVER_VARS['HTTP_USER_AGENT'],'MSIE')) + Header('Content-Type: application/force-download'); + else + Header('Content-Type: application/octet-stream'); + if(headers_sent()) + $this->Error('Some data has already been output to browser, can\'t send PDF file'); + Header('Content-Length: '.strlen($this->buffer)); + Header('Content-disposition: attachment; filename='.$name); + echo $this->buffer; + break; + case 'F': + //Save to local file + $f=fopen($name,'wb'); + if(!$f) + $this->Error('Unable to create output file: '.$name); + fwrite($f,$this->buffer,strlen($this->buffer)); + fclose($f); + break; + case 'S': + //Return as a string + return $this->buffer; + default: + $this->Error('Incorrect output destination: '.$dest); + } + return ''; +} + +/******************************************************************************* +* * +* Protected methods * +* * +*******************************************************************************/ +function _dochecks() +{ + //Check for locale-related bug + if(1.1==1) + $this->Error('Don\'t alter the locale before including class file'); + //Check for decimal separator + if(sprintf('%.1f',1.0)!='1.0') + setlocale(LC_NUMERIC,'C'); +} + +function _begindoc() +{ + //Start document + $this->state=1; + $this->_out('%PDF-1.3'); +} + +function _putpages() +{ + $nb=$this->page; + if(!empty($this->AliasNbPages)) + { + //Replace number of pages + for($n=1;$n<=$nb;$n++) + $this->pages[$n]=str_replace($this->AliasNbPages,$nb,$this->pages[$n]); + } + if($this->DefOrientation=='P') + { + $wPt=$this->fwPt; + $hPt=$this->fhPt; + } + else + { + $wPt=$this->fhPt; + $hPt=$this->fwPt; + } + $filter=($this->compress) ? '/Filter /FlateDecode ' : ''; + for($n=1;$n<=$nb;$n++) + { + //Page + $this->_newobj(); + $this->_out('<_out('/Parent 1 0 R'); + if(isset($this->OrientationChanges[$n])) + $this->_out(sprintf('/MediaBox [0 0 %.2f %.2f]',$hPt,$wPt)); + $this->_out('/Resources 2 0 R'); + if(isset($this->PageLinks[$n])) + { + //Links + $annots='/Annots ['; + foreach($this->PageLinks[$n] as $pl) + { + $rect=sprintf('%.2f %.2f %.2f %.2f',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]); + $annots.='<_textstring($pl[4]).'>>>>'; + else + { + $l=$this->links[$pl[4]]; + $h=isset($this->OrientationChanges[$l[0]]) ? $wPt : $hPt; + $annots.=sprintf('/Dest [%d 0 R /XYZ 0 %.2f null]>>',1+2*$l[0],$h-$l[1]*$this->k); + } + } + $this->_out($annots.']'); + } + $this->_out('/Contents '.($this->n+1).' 0 R>>'); + $this->_out('endobj'); + //Page content + $p=($this->compress) ? gzcompress($this->pages[$n]) : $this->pages[$n]; + $this->_newobj(); + $this->_out('<<'.$filter.'/Length '.strlen($p).'>>'); + $this->_putstream($p); + $this->_out('endobj'); + } + //Pages root + $this->offsets[1]=strlen($this->buffer); + $this->_out('1 0 obj'); + $this->_out('<_out($kids.']'); + $this->_out('/Count '.$nb); + $this->_out(sprintf('/MediaBox [0 0 %.2f %.2f]',$wPt,$hPt)); + $this->_out('>>'); + $this->_out('endobj'); +} + +function _putfonts() +{ + $nf=$this->n; + foreach($this->diffs as $diff) + { + //Encodings + $this->_newobj(); + $this->_out('<>'); + $this->_out('endobj'); + } + $mqr=get_magic_quotes_runtime(); + set_magic_quotes_runtime(0); + foreach($this->FontFiles as $file=>$info) + { + //Font file embedding + $this->_newobj(); + $this->FontFiles[$file]['n']=$this->n; + if(defined('FPDF_FONTPATH')) + $file=FPDF_FONTPATH.$file; + $size=filesize($file); + if(!$size) + $this->Error('Font file not found'); + $this->_out('<_out('/Filter /FlateDecode'); + $this->_out('/Length1 '.$info['length1']); + if(isset($info['length2'])) + $this->_out('/Length2 '.$info['length2'].' /Length3 0'); + $this->_out('>>'); + $f=fopen($file,'rb'); + $this->_putstream(fread($f,$size)); + fclose($f); + $this->_out('endobj'); + } + set_magic_quotes_runtime($mqr); + foreach($this->fonts as $k=>$font) + { + //Font objects + $this->fonts[$k]['n']=$this->n+1; + $type=$font['type']; + $name=$font['name']; + if($type=='core') + { + //Standard font + $this->_newobj(); + $this->_out('<_out('/BaseFont /'.$name); + $this->_out('/Subtype /Type1'); + if($name!='Symbol' and $name!='ZapfDingbats') + $this->_out('/Encoding /WinAnsiEncoding'); + $this->_out('>>'); + $this->_out('endobj'); + } + elseif($type=='Type1' or $type=='TrueType') + { + //Additional Type1 or TrueType font + $this->_newobj(); + $this->_out('<_out('/BaseFont /'.$name); + $this->_out('/Subtype /'.$type); + $this->_out('/FirstChar 32 /LastChar 255'); + $this->_out('/Widths '.($this->n+1).' 0 R'); + $this->_out('/FontDescriptor '.($this->n+2).' 0 R'); + if($font['enc']) + { + if(isset($font['diff'])) + $this->_out('/Encoding '.($nf+$font['diff']).' 0 R'); + else + $this->_out('/Encoding /WinAnsiEncoding'); + } + $this->_out('>>'); + $this->_out('endobj'); + //Widths + $this->_newobj(); + $cw=&$font['cw']; + $s='['; + for($i=32;$i<=255;$i++) + $s.=$cw[chr($i)].' '; + $this->_out($s.']'); + $this->_out('endobj'); + //Descriptor + $this->_newobj(); + $s='<$v) + $s.=' /'.$k.' '.$v; + $file=$font['file']; + if($file) + $s.=' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$file]['n'].' 0 R'; + $this->_out($s.'>>'); + $this->_out('endobj'); + } + else + { + //Allow for additional types + $mtd='_put'.strtolower($type); + if(!method_exists($this,$mtd)) + $this->Error('Unsupported font type: '.$type); + $this->$mtd($font); + } + } +} + +function _putimages() +{ + $filter=($this->compress) ? '/Filter /FlateDecode ' : ''; + reset($this->images); + while(list($file,$info)=each($this->images)) + { + $this->_newobj(); + $this->images[$file]['n']=$this->n; + $this->_out('<_out('/Subtype /Image'); + $this->_out('/Width '.$info['w']); + $this->_out('/Height '.$info['h']); + if($info['cs']=='Indexed') + $this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]'); + else + { + $this->_out('/ColorSpace /'.$info['cs']); + if($info['cs']=='DeviceCMYK') + $this->_out('/Decode [1 0 1 0 1 0 1 0]'); + } + $this->_out('/BitsPerComponent '.$info['bpc']); + $this->_out('/Filter /'.$info['f']); + if(isset($info['parms'])) + $this->_out($info['parms']); + if(isset($info['trns']) and is_array($info['trns'])) + { + $trns=''; + for($i=0;$i_out('/Mask ['.$trns.']'); + } + $this->_out('/Length '.strlen($info['data']).'>>'); + $this->_putstream($info['data']); + unset($this->images[$file]['data']); + $this->_out('endobj'); + //Palette + if($info['cs']=='Indexed') + { + $this->_newobj(); + $pal=($this->compress) ? gzcompress($info['pal']) : $info['pal']; + $this->_out('<<'.$filter.'/Length '.strlen($pal).'>>'); + $this->_putstream($pal); + $this->_out('endobj'); + } + } +} + +function _putresources() +{ + $this->_putfonts(); + $this->_putimages(); + //Resource dictionary + $this->offsets[2]=strlen($this->buffer); + $this->_out('2 0 obj'); + $this->_out('<_out('/Font <<'); + foreach($this->fonts as $font) + $this->_out('/F'.$font['i'].' '.$font['n'].' 0 R'); + $this->_out('>>'); + if(count($this->images)) + { + $this->_out('/XObject <<'); + foreach($this->images as $image) + $this->_out('/I'.$image['i'].' '.$image['n'].' 0 R'); + $this->_out('>>'); + } + $this->_out('>>'); + $this->_out('endobj'); +} + +function _putinfo() +{ + $this->_out('/Producer '.$this->_textstring('FPDF '.FPDF_VERSION)); + if(!empty($this->title)) + $this->_out('/Title '.$this->_textstring($this->title)); + if(!empty($this->subject)) + $this->_out('/Subject '.$this->_textstring($this->subject)); + if(!empty($this->author)) + $this->_out('/Author '.$this->_textstring($this->author)); + if(!empty($this->keywords)) + $this->_out('/Keywords '.$this->_textstring($this->keywords)); + if(!empty($this->creator)) + $this->_out('/Creator '.$this->_textstring($this->creator)); + $this->_out('/CreationDate '.$this->_textstring('D:'.date('YmdHis'))); +} + +function _putcatalog() +{ + $this->_out('/Type /Catalog'); + $this->_out('/Pages 1 0 R'); + if($this->ZoomMode=='fullpage') + $this->_out('/OpenAction [3 0 R /Fit]'); + elseif($this->ZoomMode=='fullwidth') + $this->_out('/OpenAction [3 0 R /FitH null]'); + elseif($this->ZoomMode=='real') + $this->_out('/OpenAction [3 0 R /XYZ null null 1]'); + elseif(!is_string($this->ZoomMode)) + $this->_out('/OpenAction [3 0 R /XYZ null null '.($this->ZoomMode/100).']'); + if($this->LayoutMode=='single') + $this->_out('/PageLayout /SinglePage'); + elseif($this->LayoutMode=='continuous') + $this->_out('/PageLayout /OneColumn'); + elseif($this->LayoutMode=='two') + $this->_out('/PageLayout /TwoColumnLeft'); +} + +function _puttrailer() +{ + $this->_out('/Size '.($this->n+1)); + $this->_out('/Root '.$this->n.' 0 R'); + $this->_out('/Info '.($this->n-1).' 0 R'); +} + +function _enddoc() +{ + $this->_putpages(); + $this->_putresources(); + //Info + $this->_newobj(); + $this->_out('<<'); + $this->_putinfo(); + $this->_out('>>'); + $this->_out('endobj'); + //Catalog + $this->_newobj(); + $this->_out('<<'); + $this->_putcatalog(); + $this->_out('>>'); + $this->_out('endobj'); + //Cross-ref + $o=strlen($this->buffer); + $this->_out('xref'); + $this->_out('0 '.($this->n+1)); + $this->_out('0000000000 65535 f '); + for($i=1;$i<=$this->n;$i++) + $this->_out(sprintf('%010d 00000 n ',$this->offsets[$i])); + //Trailer + $this->_out('trailer'); + $this->_out('<<'); + $this->_puttrailer(); + $this->_out('>>'); + $this->_out('startxref'); + $this->_out($o); + $this->_out('%%EOF'); + $this->state=3; +} + +function _beginpage($orientation) +{ + $this->page++; + $this->pages[$this->page]=''; + $this->state=2; + $this->x=$this->lMargin; + $this->y=$this->tMargin; + $this->FontFamily=''; + //Page orientation + if(!$orientation) + $orientation=$this->DefOrientation; + else + { + $orientation=strtoupper($orientation{0}); + if($orientation!=$this->DefOrientation) + $this->OrientationChanges[$this->page]=true; + } + if($orientation!=$this->CurOrientation) + { + //Change orientation + if($orientation=='P') + { + $this->wPt=$this->fwPt; + $this->hPt=$this->fhPt; + $this->w=$this->fw; + $this->h=$this->fh; + } + else + { + $this->wPt=$this->fhPt; + $this->hPt=$this->fwPt; + $this->w=$this->fh; + $this->h=$this->fw; + } + $this->PageBreakTrigger=$this->h-$this->bMargin; + $this->CurOrientation=$orientation; + } +} + +function _endpage() +{ + //End of page contents + $this->state=1; +} + +function _newobj() +{ + //Begin a new object + $this->n++; + $this->offsets[$this->n]=strlen($this->buffer); + $this->_out($this->n.' 0 obj'); +} + +function _dounderline($x,$y,$txt) +{ + //Underline text + $up=$this->CurrentFont['up']; + $ut=$this->CurrentFont['ut']; + $w=$this->GetStringWidth($txt)+$this->ws*substr_count($txt,' '); + return sprintf('%.2f %.2f %.2f %.2f re f',$x*$this->k,($this->h-($y-$up/1000*$this->FontSize))*$this->k,$w*$this->k,-$ut/1000*$this->FontSizePt); +} + +function _parsejpg($file) +{ + //Extract info from a JPEG file + $a=GetImageSize($file); + if(!$a) + $this->Error('Missing or incorrect image file: '.$file); + if($a[2]!=2) + $this->Error('Not a JPEG file: '.$file); + if(!isset($a['channels']) or $a['channels']==3) + $colspace='DeviceRGB'; + elseif($a['channels']==4) + $colspace='DeviceCMYK'; + else + $colspace='DeviceGray'; + $bpc=isset($a['bits']) ? $a['bits'] : 8; + //Read whole file + $f=fopen($file,'rb'); + $data=''; + while(!feof($f)) + $data.=fread($f,4096); + fclose($f); + return array('w'=>$a[0],'h'=>$a[1],'cs'=>$colspace,'bpc'=>$bpc,'f'=>'DCTDecode','data'=>$data); +} + +function _parsepng($file) +{ + //Extract info from a PNG file + $f=fopen($file,'rb'); + if(!$f) + $this->Error('Can\'t open image file: '.$file); + //Check signature + if(fread($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) + $this->Error('Not a PNG file: '.$file); + //Read header chunk + fread($f,4); + if(fread($f,4)!='IHDR') + $this->Error('Incorrect PNG file: '.$file); + $w=$this->_freadint($f); + $h=$this->_freadint($f); + $bpc=ord(fread($f,1)); + if($bpc>8) + $this->Error('16-bit depth not supported: '.$file); + $ct=ord(fread($f,1)); + if($ct==0) + $colspace='DeviceGray'; + elseif($ct==2) + $colspace='DeviceRGB'; + elseif($ct==3) + $colspace='Indexed'; + else + $this->Error('Alpha channel not supported: '.$file); + if(ord(fread($f,1))!=0) + $this->Error('Unknown compression method: '.$file); + if(ord(fread($f,1))!=0) + $this->Error('Unknown filter method: '.$file); + if(ord(fread($f,1))!=0) + $this->Error('Interlacing not supported: '.$file); + fread($f,4); + $parms='/DecodeParms <>'; + //Scan chunks looking for palette, transparency and image data + $pal=''; + $trns=''; + $data=''; + do + { + $n=$this->_freadint($f); + $type=fread($f,4); + if($type=='PLTE') + { + //Read palette + $pal=fread($f,$n); + fread($f,4); + } + elseif($type=='tRNS') + { + //Read transparency info + $t=fread($f,$n); + if($ct==0) + $trns=array(ord(substr($t,1,1))); + elseif($ct==2) + $trns=array(ord(substr($t,1,1)),ord(substr($t,3,1)),ord(substr($t,5,1))); + else + { + $pos=strpos($t,chr(0)); + if(is_int($pos)) + $trns=array($pos); + } + fread($f,4); + } + elseif($type=='IDAT') + { + //Read image data block + $data.=fread($f,$n); + fread($f,4); + } + elseif($type=='IEND') + break; + else + fread($f,$n+4); + } + while($n); + if($colspace=='Indexed' and empty($pal)) + $this->Error('Missing palette in '.$file); + fclose($f); + return array('w'=>$w,'h'=>$h,'cs'=>$colspace,'bpc'=>$bpc,'f'=>'FlateDecode','parms'=>$parms,'pal'=>$pal,'trns'=>$trns,'data'=>$data); +} + +function _freadint($f) +{ + //Read a 4-byte integer from file + $i=ord(fread($f,1))<<24; + $i+=ord(fread($f,1))<<16; + $i+=ord(fread($f,1))<<8; + $i+=ord(fread($f,1)); + return $i; +} + +function _textstring($s) +{ + //Format a text string + return '('.$this->_escape($s).')'; +} + +function _escape($s) +{ + //Add \ before \, ( and ) + return str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$s))); +} + +function _putstream($s) +{ + $this->_out('stream'); + $this->_out($s); + $this->_out('endstream'); +} + +function _out($s) +{ + //Add a line to the document + if($this->state==2) + $this->pages[$this->page].=$s."\n"; + else + $this->buffer.=$s."\n"; +} +//End of class +} + +//Handle special IE contype request +if(isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']) and $HTTP_SERVER_VARS['HTTP_USER_AGENT']=='contype') +{ + Header('Content-Type: application/pdf'); + exit; +} + +} +?> diff --git a/include/pdf/histo.htm b/include/pdf/histo.htm new file mode 100644 index 000000000..7f261bf8b --- /dev/null +++ b/include/pdf/histo.htm @@ -0,0 +1,103 @@ + + + +History + + + +

    History

    +v1.52 (2003-12-30) +
    +- Image() now displays the image at 72 dpi if no dimension is given.
    +- Output() takes a string as second parameter to indicate destination.
    +- Open() is now called automatically by AddPage().
    +- Inserting remote JPEG images doesn't generate an error any longer.
    +- Decimal separator is forced to dot in the constructor.
    +- Added several encodings (Turkish, Thai, Hebrew, Ukrainian and Vietnamese).
    +- The last line of a right-aligned MultiCell() was not correctly aligned if it was terminated by a carriage return.
    +- No more error message about already sent headers when outputting the PDF to the standard output from the command line.
    +- The underlining was going too far for text containing characters \, ( or ).
    +- $HTTP_ENV_VARS has been replaced by $HTTP_SERVER_VARS.
    +
    +v1.51 (2002-08-03) +
    +- Type1 font support.
    +- Added Baltic encoding.
    +- The class now works internally in points with the origin at the bottom in order to avoid two bugs occurring with Acrobat 5 :
      * The line thickness was too large when printed under Windows 98 SE and ME.
      * TrueType fonts didn't appear immediately inside the plug-in (a substitution font was used), one had to cause a window refresh to make them show up.
    +- It is no longer necessary to set the decimal separator as dot to produce valid documents.
    +- The clickable area in a cell was always on the left independently from the text alignment.
    +- JPEG images in CMYK mode appeared in inverted colors.
    +- Transparent PNG images in grayscale or true color mode were incorrectly handled.
    +- Adding new fonts now works correctly even with the magic_quotes_runtime option set to on.
    +
    +v1.5 (2002-05-28) +
    +- TrueType font (AddFont()) and encoding support (Western and Eastern Europe, Cyrillic and Greek).
    +- Added Write() method.
    +- Added underlined style.
    +- Internal and external link support (AddLink(), SetLink(), Link()).
    +- Added right margin management and methods SetRightMargin(), SetTopMargin().
    +- Modification of SetDisplayMode() to select page layout.
    +- The border parameter of MultiCell() now lets choose borders to draw as Cell().
    +- When a document contains no page, Close() now calls AddPage() instead of causing a fatal error.
    +
    +v1.41 (2002-03-13) +
    +- Fixed SetDisplayMode() which no longer worked (the PDF viewer used its default display).
    +
    +v1.4 (2002-03-02) +
    +- PHP3 is no longer supported.
    +- Page compression (SetCompression()).
    +- Choice of page format and possibility to change orientation inside document.
    +- Added AcceptPageBreak() method.
    +- Ability to print the total number of pages (AliasNbPages()).
    +- Choice of cell borders to draw.
    +- New mode for Cell(): the current position can now move under the cell.
    +- Ability to include an image by specifying height only (width is calculated automatically).
    +- Fixed a bug: when a justified line triggered a page break, the footer inherited the corresponding word spacing.
    +
    +v1.31 (2002-01-12) +
    +- Fixed a bug in drawing frame with MultiCell(): the last line always started from the left margin.
    +- Removed Expires HTTP header (gives trouble in some situations).
    +- Added Content-disposition HTTP header (seems to help in some situations).
    +
    +v1.3 (2001-12-03) +
    +- Line break and text justification support (MultiCell()).
    +- Color support (SetDrawColor(), SetFillColor(), SetTextColor()). Possibility to draw filled rectangles and paint cell background.
    +- A cell whose width is declared null extends up to the right margin of the page.
    +- Line width is now retained from page to page and defaults to 0.2 mm.
    +- Added SetXY() method.
    +- Fixed a passing by reference done in a deprecated manner for PHP4.
    +
    +v1.2 (2001-11-11) +
    +- Added font metric files and GetStringWidth() method.
    +- Centering and right-aligning text in cells.
    +- Display mode control (SetDisplayMode()).
    +- Added methods to set document properties (SetAuthor(), SetCreator(), SetKeywords(), SetSubject(), SetTitle()).
    +- Possibility to force PDF download by browser.
    +- Added SetX() and GetX() methods.
    +- During automatic page break, current abscissa is now retained.
    +
    +v1.11 (2001-10-20) +
    +- PNG support doesn't require PHP4/Zlib any more. Data are now put directly into PDF without any decompression/recompression stage.
    +- Image insertion now works correctly even with magic_quotes_runtime option set to on.
    +
    +v1.1 (2001-10-07) +
    +- JPEG and PNG image support.
    +
    +v1.01 (2001-10-03) +
    +- Fixed a bug involving page break: in case when Header() doesn't specify a font, the one from previous page was not restored and produced an incorrect document.
    +
    +v1.0 (2001-09-17) +
    +- First version.
    +
    + + diff --git a/include/pdf/install.txt b/include/pdf/install.txt new file mode 100644 index 000000000..494fcf784 --- /dev/null +++ b/include/pdf/install.txt @@ -0,0 +1,29 @@ +The FPDF library is made up of the following elements: + +- the main file, fpdf.php, which contains the class +- the font metric files (located in the font directory of this archive) + +The metric files are necessary as soon as you want to output text in a document. +They can be accessed from three different locations: + +- the current directory (the one where the running script lies) +- one of the directories defined by the include_path parameter +- the directory defined by the FPDF_FONTPATH constant + +Here is an example for the last case (note the mandatory final slash): + +define('FPDF_FONTPATH','/home/www/font/'); +require('fpdf.php'); + +If the files are not accessible, the SetFont() method will produce the following error: + +FPDF error: Could not include font metric file + +If so, check if you have correctly defined the constant. + +Remarks: + +- You can also define FPDF_FONTPATH directly at the beginning of fpdf.php +- Only the files corresponding to the fonts actually used are necessary + +The tutorials provided in this package are ready to be executed. diff --git a/include/pdf/tutorial/20k_c1.txt b/include/pdf/tutorial/20k_c1.txt new file mode 100644 index 000000000..0b09f265f --- /dev/null +++ b/include/pdf/tutorial/20k_c1.txt @@ -0,0 +1,10 @@ +The year 1866 was marked by a bizarre development, an unexplained and downright inexplicable phenomenon that surely no one has forgotten. Without getting into those rumors that upset civilians in the seaports and deranged the public mind even far inland, it must be said that professional seamen were especially alarmed. Traders, shipowners, captains of vessels, skippers, and master mariners from Europe and America, naval officers from every country, and at their heels the various national governments on these two continents, were all extremely disturbed by the business. +In essence, over a period of time several ships had encountered "an enormous thing" at sea, a long spindle-shaped object, sometimes giving off a phosphorescent glow, infinitely bigger and faster than any whale. +The relevant data on this apparition, as recorded in various logbooks, agreed pretty closely as to the structure of the object or creature in question, its unprecedented speed of movement, its startling locomotive power, and the unique vitality with which it seemed to be gifted. If it was a cetacean, it exceeded in bulk any whale previously classified by science. No naturalist, neither Cuvier nor Lacépède, neither Professor Dumeril nor Professor de Quatrefages, would have accepted the existence of such a monster sight unseen -- specifically, unseen by their own scientific eyes. +Striking an average of observations taken at different times -- rejecting those timid estimates that gave the object a length of 200 feet, and ignoring those exaggerated views that saw it as a mile wide and three long--you could still assert that this phenomenal creature greatly exceeded the dimensions of anything then known to ichthyologists, if it existed at all. +Now then, it did exist, this was an undeniable fact; and since the human mind dotes on objects of wonder, you can understand the worldwide excitement caused by this unearthly apparition. As for relegating it to the realm of fiction, that charge had to be dropped. +In essence, on July 20, 1866, the steamer Governor Higginson, from the Calcutta & Burnach Steam Navigation Co., encountered this moving mass five miles off the eastern shores of Australia. Captain Baker at first thought he was in the presence of an unknown reef; he was even about to fix its exact position when two waterspouts shot out of this inexplicable object and sprang hissing into the air some 150 feet. So, unless this reef was subject to the intermittent eruptions of a geyser, the Governor Higginson had fair and honest dealings with some aquatic mammal, until then unknown, that could spurt from its blowholes waterspouts mixed with air and steam. +Similar events were likewise observed in Pacific seas, on July 23 of the same year, by the Christopher Columbus from the West India & Pacific Steam Navigation Co. Consequently, this extraordinary cetacean could transfer itself from one locality to another with startling swiftness, since within an interval of just three days, the Governor Higginson and the Christopher Columbus had observed it at two positions on the charts separated by a distance of more than 700 nautical leagues. +Fifteen days later and 2,000 leagues farther, the Helvetia from the Compagnie Nationale and the Shannon from the Royal Mail line, running on opposite tacks in that part of the Atlantic lying between the United States and Europe, respectively signaled each other that the monster had been sighted in latitude 42 degrees 15' north and longitude 60 degrees 35' west of the meridian of Greenwich. From their simultaneous observations, they were able to estimate the mammal's minimum length at more than 350 English feet; this was because both the Shannon and the Helvetia were of smaller dimensions, although each measured 100 meters stem to stern. Now then, the biggest whales, those rorqual whales that frequent the waterways of the Aleutian Islands, have never exceeded a length of 56 meters--if they reach even that. +One after another, reports arrived that would profoundly affect public opinion: new observations taken by the transatlantic liner Pereire, the Inman line's Etna running afoul of the monster, an official report drawn up by officers on the French frigate Normandy, dead-earnest reckonings obtained by the general staff of Commodore Fitz-James aboard the Lord Clyde. In lighthearted countries, people joked about this phenomenon, but such serious, practical countries as England, America, and Germany were deeply concerned. +In every big city the monster was the latest rage; they sang about it in the coffee houses, they ridiculed it in the newspapers, they dramatized it in the theaters. The tabloids found it a fine opportunity for hatching all sorts of hoaxes. In those newspapers short of copy, you saw the reappearance of every gigantic imaginary creature, from "Moby Dick," that dreadful white whale from the High Arctic regions, to the stupendous kraken whose tentacles could entwine a 500-ton craft and drag it into the ocean depths. They even reprinted reports from ancient times: the views of Aristotle and Pliny accepting the existence of such monsters, then the Norwegian stories of Bishop Pontoppidan, the narratives of Paul Egede, and finally the reports of Captain Harrington -- whose good faith is above suspicion--in which he claims he saw, while aboard the Castilian in 1857, one of those enormous serpents that, until then, had frequented only the seas of France's old extremist newspaper, The Constitutionalist. diff --git a/include/pdf/tutorial/20k_c2.txt b/include/pdf/tutorial/20k_c2.txt new file mode 100644 index 000000000..096dbd193 --- /dev/null +++ b/include/pdf/tutorial/20k_c2.txt @@ -0,0 +1,23 @@ +During the period in which these developments were occurring, I had returned from a scientific undertaking organized to explore the Nebraska badlands in the United States. In my capacity as Assistant Professor at the Paris Museum of Natural History, I had been attached to this expedition by the French government. After spending six months in Nebraska, I arrived in New York laden with valuable collections near the end of March. My departure for France was set for early May. In the meantime, then, I was busy classifying my mineralogical, botanical, and zoological treasures when that incident took place with the Scotia. +I was perfectly abreast of this question, which was the big news of the day, and how could I not have been? I had read and reread every American and European newspaper without being any farther along. This mystery puzzled me. Finding it impossible to form any views, I drifted from one extreme to the other. Something was out there, that much was certain, and any doubting Thomas was invited to place his finger on the Scotia's wound. +When I arrived in New York, the question was at the boiling point. The hypothesis of a drifting islet or an elusive reef, put forward by people not quite in their right minds, was completely eliminated. And indeed, unless this reef had an engine in its belly, how could it move about with such prodigious speed? +Also discredited was the idea of a floating hull or some other enormous wreckage, and again because of this speed of movement. +So only two possible solutions to the question were left, creating two very distinct groups of supporters: on one side, those favoring a monster of colossal strength; on the other, those favoring an "underwater boat" of tremendous motor power. +Now then, although the latter hypothesis was completely admissible, it couldn't stand up to inquiries conducted in both the New World and the Old. That a private individual had such a mechanism at his disposal was less than probable. Where and when had he built it, and how could he have built it in secret? +Only some government could own such an engine of destruction, and in these disaster-filled times, when men tax their ingenuity to build increasingly powerful aggressive weapons, it was possible that, unknown to the rest of the world, some nation could have been testing such a fearsome machine. The Chassepot rifle led to the torpedo, and the torpedo has led to this underwater battering ram, which in turn will lead to the world putting its foot down. At least I hope it will. +But this hypothesis of a war machine collapsed in the face of formal denials from the various governments. Since the public interest was at stake and transoceanic travel was suffering, the sincerity of these governments could not be doubted. Besides, how could the assembly of this underwater boat have escaped public notice? Keeping a secret under such circumstances would be difficult enough for an individual, and certainly impossible for a nation whose every move is under constant surveillance by rival powers. +So, after inquiries conducted in England, France, Russia, Prussia, Spain, Italy, America, and even Turkey, the hypothesis of an underwater Monitor was ultimately rejected. +After I arrived in New York, several people did me the honor of consulting me on the phenomenon in question. In France I had published a two-volume work, in quarto, entitled The Mysteries of the Great Ocean Depths. Well received in scholarly circles, this book had established me as a specialist in this pretty obscure field of natural history. My views were in demand. As long as I could deny the reality of the business, I confined myself to a flat "no comment." But soon, pinned to the wall, I had to explain myself straight out. And in this vein, "the honorable Pierre Aronnax, Professor at the Paris Museum," was summoned by The New York Herald to formulate his views no matter what. +I complied. Since I could no longer hold my tongue, I let it wag. I discussed the question in its every aspect, both political and scientific, and this is an excerpt from the well-padded article I published in the issue of April 30. + +"Therefore," I wrote, "after examining these different hypotheses one by one, we are forced, every other supposition having been refuted, to accept the existence of an extremely powerful marine animal. +"The deepest parts of the ocean are totally unknown to us. No soundings have been able to reach them. What goes on in those distant depths? What creatures inhabit, or could inhabit, those regions twelve or fifteen miles beneath the surface of the water? What is the constitution of these animals? It's almost beyond conjecture. +"However, the solution to this problem submitted to me can take the form of a choice between two alternatives. +"Either we know every variety of creature populating our planet, or we do not. +"If we do not know every one of them, if nature still keeps ichthyological secrets from us, nothing is more admissible than to accept the existence of fish or cetaceans of new species or even new genera, animals with a basically 'cast-iron' constitution that inhabit strata beyond the reach of our soundings, and which some development or other, an urge or a whim if you prefer, can bring to the upper level of the ocean for long intervals. +"If, on the other hand, we do know every living species, we must look for the animal in question among those marine creatures already cataloged, and in this event I would be inclined to accept the existence of a giant narwhale. +"The common narwhale, or sea unicorn, often reaches a length of sixty feet. Increase its dimensions fivefold or even tenfold, then give this cetacean a strength in proportion to its size while enlarging its offensive weapons, and you have the animal we're looking for. It would have the proportions determined by the officers of the Shannon, the instrument needed to perforate the Scotia, and the power to pierce a steamer's hull. +"In essence, the narwhale is armed with a sort of ivory sword, or lance, as certain naturalists have expressed it. It's a king-sized tooth as hard as steel. Some of these teeth have been found buried in the bodies of baleen whales, which the narwhale attacks with invariable success. Others have been wrenched, not without difficulty, from the undersides of vessels that narwhales have pierced clean through, as a gimlet pierces a wine barrel. The museum at the Faculty of Medicine in Paris owns one of these tusks with a length of 2.25 meters and a width at its base of forty-eight centimeters! +"All right then! Imagine this weapon to be ten times stronger and the animal ten times more powerful, launch it at a speed of twenty miles per hour, multiply its mass times its velocity, and you get just the collision we need to cause the specified catastrophe. +"So, until information becomes more abundant, I plump for a sea unicorn of colossal dimensions, no longer armed with a mere lance but with an actual spur, like ironclad frigates or those warships called 'rams,' whose mass and motor power it would possess simultaneously. +"This inexplicable phenomenon is thus explained away--unless it's something else entirely, which, despite everything that has been sighted, studied, explored and experienced, is still possible!" diff --git a/include/pdf/tutorial/calligra.afm b/include/pdf/tutorial/calligra.afm new file mode 100644 index 000000000..806685eae --- /dev/null +++ b/include/pdf/tutorial/calligra.afm @@ -0,0 +1,275 @@ +StartFontMetrics 4.1 +FontName Calligrapher-Regular +FullName Calligrapher Regular +Notice Generated by Fontographer 3.5 +EncodingScheme FontSpecific +FamilyName Calligrapher +Weight Regular +Version (Altsys Fontographer 3.5 5/26/92) +Characters 215 +ItalicAngle 0.0 +Ascender 899 +Descender -234 +UnderlineThickness 20 +UnderlinePosition -200 +IsFixedPitch false +FontBBox -50 -234 1328 899 +StartCharMetrics 256 +C 0 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 1 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 2 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 3 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 4 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 5 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 6 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 7 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 8 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 9 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 10 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 11 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 12 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 13 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 14 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 15 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 16 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 17 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 18 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 19 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 20 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 21 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 22 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 23 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 24 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 25 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 26 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 27 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 28 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 29 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 30 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 31 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 32 ; WX 282 ; N space ; B 67 -16 251 718 ; +C 33 ; WX 324 ; N exclam ; B 67 -16 251 718 ; +C 34 ; WX 405 ; N quotedbl ; B 60 460 353 718 ; +C 35 ; WX 584 ; N numbersign ; B 35 0 549 701 ; +C 36 ; WX 632 ; N dollar ; B 32 -126 595 814 ; +C 37 ; WX 980 ; N percent ; B 35 -16 945 703 ; +C 38 ; WX 776 ; N ampersand ; B 41 -17 811 670 ; +C 39 ; WX 259 ; N quotesingle ; B 72 460 206 718 ; +C 40 ; WX 299 ; N parenleft ; B 57 -119 299 785 ; +C 41 ; WX 299 ; N parenright ; B 0 -119 242 785 ; +C 42 ; WX 377 ; N asterisk ; B 35 407 342 714 ; +C 43 ; WX 600 ; N plus ; B 47 0 553 506 ; +C 44 ; WX 259 ; N comma ; B 35 -67 224 162 ; +C 45 ; WX 432 ; N hyphen ; B 28 249 404 377 ; +C 46 ; WX 254 ; N period ; B 43 -16 227 162 ; +C 47 ; WX 597 ; N slash ; B 7 -14 591 714 ; +C 48 ; WX 529 ; N zero ; B 21 -18 508 583 ; +C 49 ; WX 298 ; N one ; B 8 -15 233 582 ; +C 50 ; WX 451 ; N two ; B 17 -8 430 588 ; +C 51 ; WX 359 ; N three ; B 11 -54 337 582 ; +C 52 ; WX 525 ; N four ; B 18 -20 519 602 ; +C 53 ; WX 423 ; N five ; B 10 -55 420 582 ; +C 54 ; WX 464 ; N six ; B 23 -14 447 589 ; +C 55 ; WX 417 ; N seven ; B 8 -18 415 589 ; +C 56 ; WX 457 ; N eight ; B 19 -16 432 583 ; +C 57 ; WX 479 ; N nine ; B 26 -16 450 588 ; +C 58 ; WX 275 ; N colon ; B 59 -16 242 491 ; +C 59 ; WX 282 ; N semicolon ; B 54 -67 245 491 ; +C 60 ; WX 600 ; N less ; B 47 -8 553 514 ; +C 61 ; WX 600 ; N equal ; B 47 98 553 408 ; +C 62 ; WX 600 ; N greater ; B 47 -8 553 514 ; +C 63 ; WX 501 ; N question ; B 21 -16 473 721 ; +C 64 ; WX 800 ; N at ; B 29 -12 771 730 ; +C 65 ; WX 743 ; N A ; B -23 -14 754 723 ; +C 66 ; WX 636 ; N B ; B -42 -7 608 706 ; +C 67 ; WX 598 ; N C ; B 27 -12 572 712 ; +C 68 ; WX 712 ; N D ; B -42 -11 684 705 ; +C 69 ; WX 608 ; N E ; B -21 0 608 708 ; +C 70 ; WX 562 ; N F ; B -21 -18 584 716 ; +C 71 ; WX 680 ; N G ; B 29 -8 668 714 ; +C 72 ; WX 756 ; N H ; B 70 -17 777 728 ; +C 73 ; WX 308 ; N I ; B 14 -15 238 718 ; +C 74 ; WX 314 ; N J ; B 7 -223 244 727 ; +C 75 ; WX 676 ; N K ; B 14 -16 683 725 ; +C 76 ; WX 552 ; N L ; B 14 -8 580 713 ; +C 77 ; WX 1041 ; N M ; B 42 -17 1017 739 ; +C 78 ; WX 817 ; N N ; B -42 -17 747 736 ; +C 79 ; WX 729 ; N O ; B 32 -16 698 709 ; +C 80 ; WX 569 ; N P ; B -35 -15 570 716 ; +C 81 ; WX 698 ; N Q ; B 27 -201 1328 715 ; +C 82 ; WX 674 ; N R ; B -35 -20 696 712 ; +C 83 ; WX 618 ; N S ; B 31 -16 589 709 ; +C 84 ; WX 673 ; N T ; B -21 -20 702 714 ; +C 85 ; WX 805 ; N U ; B 0 -19 804 722 ; +C 86 ; WX 753 ; N V ; B -28 -20 788 729 ; +C 87 ; WX 1238 ; N W ; B -28 -17 1273 736 ; +C 88 ; WX 716 ; N X ; B 7 -38 709 731 ; +C 89 ; WX 754 ; N Y ; B -35 -17 789 747 ; +C 90 ; WX 599 ; N Z ; B 30 -5 584 748 ; +C 91 ; WX 315 ; N bracketleft ; B 93 -124 322 718 ; +C 92 ; WX 463 ; N backslash ; B -21 -18 484 736 ; +C 93 ; WX 315 ; N bracketright ; B -7 -124 222 718 ; +C 94 ; WX 600 ; N asciicircum ; B 63 266 537 658 ; +C 95 ; WX 547 ; N underscore ; B -7 -198 554 -163 ; +C 96 ; WX 278 ; N grave ; B -1 541 214 693 ; +C 97 ; WX 581 ; N a ; B 21 -16 581 494 ; +C 98 ; WX 564 ; N b ; B -24 -17 543 793 ; +C 99 ; WX 440 ; N c ; B 21 -17 422 490 ; +C 100 ; WX 571 ; N d ; B 0 -15 550 659 ; +C 101 ; WX 450 ; N e ; B 28 -23 428 493 ; +C 102 ; WX 347 ; N f ; B -35 -14 474 785 ; +C 103 ; WX 628 ; N g ; B 19 -219 612 496 ; +C 104 ; WX 611 ; N h ; B -29 -18 569 785 ; +C 105 ; WX 283 ; N i ; B -14 -15 241 679 ; +C 106 ; WX 283 ; N j ; B -14 -234 241 679 ; +C 107 ; WX 560 ; N k ; B -24 -15 582 789 ; +C 108 ; WX 252 ; N l ; B -28 -15 210 789 ; +C 109 ; WX 976 ; N m ; B -21 -16 927 494 ; +C 110 ; WX 595 ; N n ; B -28 -15 574 493 ; +C 111 ; WX 508 ; N o ; B 27 -17 485 490 ; +C 112 ; WX 549 ; N p ; B -28 -216 526 496 ; +C 113 ; WX 540 ; N q ; B 28 -219 491 493 ; +C 114 ; WX 395 ; N r ; B -21 -19 430 492 ; +C 115 ; WX 441 ; N s ; B 34 -15 413 493 ; +C 116 ; WX 307 ; N t ; B -21 -16 378 621 ; +C 117 ; WX 614 ; N u ; B -14 -18 558 501 ; +C 118 ; WX 556 ; N v ; B -28 -20 569 483 ; +C 119 ; WX 915 ; N w ; B -28 -17 928 495 ; +C 120 ; WX 559 ; N x ; B 14 -17 546 500 ; +C 121 ; WX 597 ; N y ; B -21 -227 541 500 ; +C 122 ; WX 452 ; N z ; B 28 -5 442 515 ; +C 123 ; WX 315 ; N braceleft ; B 6 -118 309 718 ; +C 124 ; WX 222 ; N bar ; B 63 -18 159 730 ; +C 125 ; WX 315 ; N braceright ; B 6 -118 309 718 ; +C 126 ; WX 600 ; N asciitilde ; B 69 166 531 340 ; +C 127 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 128 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 129 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 130 ; WX 0 ; N quotesinglbase ; B -23 -14 754 877 ; +C 131 ; WX 0 ; N florin ; B 0 -19 804 854 ; +C 132 ; WX 0 ; N quotedblbase ; B -23 -14 754 877 ; +C 133 ; WX 780 ; N ellipsis ; B 43 -16 747 162 ; +C 134 ; WX 0 ; N dagger ; B 27 -122 437 592 ; +C 135 ; WX 0 ; N daggerdbl ; B 43 278 227 456 ; +C 136 ; WX 278 ; N circumflex ; B -14 557 292 677 ; +C 137 ; WX 0 ; N perthousand ; B -23 -14 754 877 ; +C 138 ; WX 0 ; N Scaron ; B 0 0 0 100 ; +C 139 ; WX 0 ; N guilsinglleft ; B 43 278 227 456 ; +C 140 ; WX 1064 ; N OE ; B 32 -16 1055 709 ; +C 141 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 142 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 143 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 144 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 145 ; WX 259 ; N quoteleft ; B 35 489 224 717 ; +C 146 ; WX 259 ; N quoteright ; B 35 489 224 717 ; +C 147 ; WX 470 ; N quotedblleft ; B 35 489 443 717 ; +C 148 ; WX 470 ; N quotedblright ; B 35 487 443 717 ; +C 149 ; WX 500 ; N bullet ; B 70 179 430 539 ; +C 150 ; WX 300 ; N endash ; B 0 245 300 350 ; +C 151 ; WX 600 ; N emdash ; B 0 245 600 350 ; +C 152 ; WX 278 ; N tilde ; B -44 563 326 689 ; +C 153 ; WX 990 ; N trademark ; B 62 306 928 718 ; +C 154 ; WX 0 ; N scaron ; B 0 0 0 100 ; +C 155 ; WX 0 ; N guilsinglright ; B 43 278 227 456 ; +C 156 ; WX 790 ; N oe ; B 27 -23 764 493 ; +C 157 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 158 ; WX 800 ; N .notdef ; B 50 0 750 800 ; +C 159 ; WX 754 ; N Ydieresis ; B -35 -17 789 882 ; +C 160 ; WX 282 ; N nbspace ; B -23 -14 754 893 ; +C 161 ; WX 324 ; N exclamdown ; B 69 -203 253 531 ; +C 162 ; WX 450 ; N cent ; B 27 -122 437 592 ; +C 163 ; WX 640 ; N sterling ; B 0 -9 619 716 ; +C 164 ; WX 518 ; N currency ; B 3 72 515 586 ; +C 165 ; WX 603 ; N yen ; B -28 -65 631 747 ; +C 166 ; WX 0 ; N brokenbar ; B 0 0 0 100 ; +C 167 ; WX 519 ; N section ; B -50 -216 524 762 ; +C 168 ; WX 254 ; N dieresis ; B -20 554 308 682 ; +C 169 ; WX 800 ; N copyright ; B 29 -12 771 730 ; +C 170 ; WX 349 ; N ordfeminine ; B 13 385 349 717 ; +C 171 ; WX 0 ; N guillemotleft ; B 43 -16 747 162 ; +C 172 ; WX 0 ; N logicalnot ; B 30 0 730 700 ; +C 173 ; WX 432 ; N hyphen ; B 28 249 404 377 ; +C 174 ; WX 800 ; N registered ; B 29 -12 771 730 ; +C 175 ; WX 278 ; N macron ; B -47 584 325 665 ; +C 176 ; WX 0 ; N degree ; B 27 -122 437 592 ; +C 177 ; WX 0 ; N plusminus ; B 29 -8 668 877 ; +C 178 ; WX 0 ; N twosuperior ; B 0 0 0 100 ; +C 179 ; WX 0 ; N threesuperior ; B 0 0 0 100 ; +C 180 ; WX 278 ; N acute ; B 49 536 279 693 ; +C 181 ; WX 614 ; N mu ; B -14 -231 558 501 ; +C 182 ; WX 0 ; N paragraph ; B -35 -15 668 785 ; +C 183 ; WX 254 ; N periodcentered ; B 43 278 227 456 ; +C 184 ; WX 278 ; N cedilla ; B -8 -216 231 6 ; +C 185 ; WX 0 ; N onesuperior ; B 0 0 0 100 ; +C 186 ; WX 305 ; N ordmasculine ; B 16 373 291 702 ; +C 187 ; WX 0 ; N guillemotright ; B 43 -16 747 162 ; +C 188 ; WX 0 ; N onequarter ; B 0 0 0 100 ; +C 189 ; WX 0 ; N onehalf ; B 0 0 0 100 ; +C 190 ; WX 0 ; N threequarters ; B 0 0 0 100 ; +C 191 ; WX 501 ; N questiondown ; B 15 -196 467 541 ; +C 192 ; WX 743 ; N Agrave ; B -23 -14 754 893 ; +C 193 ; WX 743 ; N Aacute ; B -23 -14 754 893 ; +C 194 ; WX 743 ; N Acircumflex ; B -23 -14 754 877 ; +C 195 ; WX 743 ; N Atilde ; B -23 -14 754 889 ; +C 196 ; WX 743 ; N Adieresis ; B -23 -14 754 882 ; +C 197 ; WX 743 ; N Aring ; B -23 -14 754 899 ; +C 198 ; WX 1060 ; N AE ; B -29 -14 1053 708 ; +C 199 ; WX 598 ; N Ccedilla ; B 27 -183 572 712 ; +C 200 ; WX 608 ; N Egrave ; B -21 0 608 893 ; +C 201 ; WX 608 ; N Eacute ; B -21 0 608 893 ; +C 202 ; WX 608 ; N Ecircumflex ; B -21 0 608 877 ; +C 203 ; WX 608 ; N Edieresis ; B -21 0 608 882 ; +C 204 ; WX 308 ; N Igrave ; B 14 -15 264 893 ; +C 205 ; WX 308 ; N Iacute ; B 14 -15 274 893 ; +C 206 ; WX 308 ; N Icircumflex ; B 1 -15 307 877 ; +C 207 ; WX 308 ; N Idieresis ; B -15 -15 313 882 ; +C 208 ; WX 0 ; N Eth ; B 0 0 0 100 ; +C 209 ; WX 817 ; N Ntilde ; B -42 -17 747 889 ; +C 210 ; WX 729 ; N Ograve ; B 32 -16 698 893 ; +C 211 ; WX 729 ; N Oacute ; B 32 -16 698 893 ; +C 212 ; WX 729 ; N Ocircumflex ; B 32 -16 698 877 ; +C 213 ; WX 729 ; N Otilde ; B 32 -16 698 889 ; +C 214 ; WX 729 ; N Odieresis ; B 32 -16 698 882 ; +C 215 ; WX 0 ; N multiply ; B 0 0 0 100 ; +C 216 ; WX 729 ; N Oslash ; B 14 -24 724 709 ; +C 217 ; WX 805 ; N Ugrave ; B 0 -19 804 893 ; +C 218 ; WX 805 ; N Uacute ; B 0 -19 804 893 ; +C 219 ; WX 805 ; N Ucircumflex ; B 0 -19 804 877 ; +C 220 ; WX 805 ; N Udieresis ; B 0 -19 804 882 ; +C 221 ; WX 0 ; N _235 ; B 0 0 0 100 ; +C 222 ; WX 0 ; N Thorn ; B 0 0 0 100 ; +C 223 ; WX 688 ; N germandbls ; B -35 -15 668 785 ; +C 224 ; WX 581 ; N agrave ; B 21 -16 581 693 ; +C 225 ; WX 581 ; N aacute ; B 21 -16 581 693 ; +C 226 ; WX 581 ; N acircumflex ; B 21 -16 581 677 ; +C 227 ; WX 581 ; N atilde ; B 21 -16 581 689 ; +C 228 ; WX 581 ; N adieresis ; B 21 -16 581 682 ; +C 229 ; WX 581 ; N aring ; B 21 -16 581 734 ; +C 230 ; WX 792 ; N ae ; B 21 -23 773 494 ; +C 231 ; WX 440 ; N ccedilla ; B 21 -183 422 490 ; +C 232 ; WX 450 ; N egrave ; B 28 -23 428 693 ; +C 233 ; WX 450 ; N eacute ; B 28 -23 428 693 ; +C 234 ; WX 450 ; N ecircumflex ; B 28 -23 432 677 ; +C 235 ; WX 450 ; N edieresis ; B 28 -23 428 682 ; +C 236 ; WX 283 ; N igrave ; B -14 -15 244 693 ; +C 237 ; WX 283 ; N iacute ; B -14 -15 269 693 ; +C 238 ; WX 283 ; N icircumflex ; B -14 -15 297 677 ; +C 239 ; WX 283 ; N idieresis ; B -25 -15 303 682 ; +C 240 ; WX 0 ; N Yacute ; B 0 0 0 100 ; +C 241 ; WX 595 ; N ntilde ; B -28 -15 574 689 ; +C 242 ; WX 508 ; N ograve ; B 27 -17 485 693 ; +C 243 ; WX 508 ; N oacute ; B 27 -17 485 693 ; +C 244 ; WX 508 ; N ocircumflex ; B 27 -17 485 677 ; +C 245 ; WX 508 ; N otilde ; B 27 -17 485 689 ; +C 246 ; WX 508 ; N odieresis ; B 27 -17 485 682 ; +C 247 ; WX 0 ; N divide ; B 35 0 760 727 ; +C 248 ; WX 508 ; N oslash ; B -8 -54 496 589 ; +C 249 ; WX 614 ; N ugrave ; B -14 -18 558 693 ; +C 250 ; WX 614 ; N uacute ; B -14 -18 558 693 ; +C 251 ; WX 614 ; N ucircumflex ; B -14 -18 558 677 ; +C 252 ; WX 614 ; N udieresis ; B -14 -18 558 682 ; +C 253 ; WX 0 ; N yacute ; B 0 0 0 100 ; +C 254 ; WX 0 ; N thorn ; B 0 0 0 100 ; +C 255 ; WX 597 ; N ydieresis ; B -21 -227 541 682 ; +EndCharMetrics +EndFontMetrics diff --git a/include/pdf/tutorial/calligra.php b/include/pdf/tutorial/calligra.php new file mode 100644 index 000000000..1af82ac82 --- /dev/null +++ b/include/pdf/tutorial/calligra.php @@ -0,0 +1,24 @@ +899,'Descent'=>-234,'CapHeight'=>731,'Flags'=>32,'FontBBox'=>'[-50 -234 1328 899]','ItalicAngle'=>0,'StemV'=>70,'MissingWidth'=>800); +$up=-200; +$ut=20; +$cw=array( + chr(0)=>800,chr(1)=>800,chr(2)=>800,chr(3)=>800,chr(4)=>800,chr(5)=>800,chr(6)=>800,chr(7)=>800,chr(8)=>800,chr(9)=>800,chr(10)=>800,chr(11)=>800,chr(12)=>800,chr(13)=>800,chr(14)=>800,chr(15)=>800,chr(16)=>800,chr(17)=>800,chr(18)=>800,chr(19)=>800,chr(20)=>800,chr(21)=>800, + chr(22)=>800,chr(23)=>800,chr(24)=>800,chr(25)=>800,chr(26)=>800,chr(27)=>800,chr(28)=>800,chr(29)=>800,chr(30)=>800,chr(31)=>800,' '=>282,'!'=>324,'"'=>405,'#'=>584,'$'=>632,'%'=>980,'&'=>776,'\''=>259,'('=>299,')'=>299,'*'=>377,'+'=>600, + ','=>259,'-'=>432,'.'=>254,'/'=>597,'0'=>529,'1'=>298,'2'=>451,'3'=>359,'4'=>525,'5'=>423,'6'=>464,'7'=>417,'8'=>457,'9'=>479,':'=>275,';'=>282,'<'=>600,'='=>600,'>'=>600,'?'=>501,'@'=>800,'A'=>743, + 'B'=>636,'C'=>598,'D'=>712,'E'=>608,'F'=>562,'G'=>680,'H'=>756,'I'=>308,'J'=>314,'K'=>676,'L'=>552,'M'=>1041,'N'=>817,'O'=>729,'P'=>569,'Q'=>698,'R'=>674,'S'=>618,'T'=>673,'U'=>805,'V'=>753,'W'=>1238, + 'X'=>716,'Y'=>754,'Z'=>599,'['=>315,'\\'=>463,']'=>315,'^'=>600,'_'=>547,'`'=>278,'a'=>581,'b'=>564,'c'=>440,'d'=>571,'e'=>450,'f'=>347,'g'=>628,'h'=>611,'i'=>283,'j'=>283,'k'=>560,'l'=>252,'m'=>976, + 'n'=>595,'o'=>508,'p'=>549,'q'=>540,'r'=>395,'s'=>441,'t'=>307,'u'=>614,'v'=>556,'w'=>915,'x'=>559,'y'=>597,'z'=>452,'{'=>315,'|'=>222,'}'=>315,'~'=>600,chr(127)=>800,chr(128)=>800,chr(129)=>800,chr(130)=>0,chr(131)=>0, + chr(132)=>0,chr(133)=>780,chr(134)=>0,chr(135)=>0,chr(136)=>278,chr(137)=>0,chr(138)=>0,chr(139)=>0,chr(140)=>1064,chr(141)=>800,chr(142)=>800,chr(143)=>800,chr(144)=>800,chr(145)=>259,chr(146)=>259,chr(147)=>470,chr(148)=>470,chr(149)=>500,chr(150)=>300,chr(151)=>600,chr(152)=>278,chr(153)=>990, + chr(154)=>0,chr(155)=>0,chr(156)=>790,chr(157)=>800,chr(158)=>800,chr(159)=>754,chr(160)=>282,chr(161)=>324,chr(162)=>450,chr(163)=>640,chr(164)=>518,chr(165)=>603,chr(166)=>0,chr(167)=>519,chr(168)=>254,chr(169)=>800,chr(170)=>349,chr(171)=>0,chr(172)=>0,chr(173)=>432,chr(174)=>800,chr(175)=>278, + chr(176)=>0,chr(177)=>0,chr(178)=>0,chr(179)=>0,chr(180)=>278,chr(181)=>614,chr(182)=>0,chr(183)=>254,chr(184)=>278,chr(185)=>0,chr(186)=>305,chr(187)=>0,chr(188)=>0,chr(189)=>0,chr(190)=>0,chr(191)=>501,chr(192)=>743,chr(193)=>743,chr(194)=>743,chr(195)=>743,chr(196)=>743,chr(197)=>743, + chr(198)=>1060,chr(199)=>598,chr(200)=>608,chr(201)=>608,chr(202)=>608,chr(203)=>608,chr(204)=>308,chr(205)=>308,chr(206)=>308,chr(207)=>308,chr(208)=>0,chr(209)=>817,chr(210)=>729,chr(211)=>729,chr(212)=>729,chr(213)=>729,chr(214)=>729,chr(215)=>0,chr(216)=>729,chr(217)=>805,chr(218)=>805,chr(219)=>805, + chr(220)=>805,chr(221)=>0,chr(222)=>0,chr(223)=>688,chr(224)=>581,chr(225)=>581,chr(226)=>581,chr(227)=>581,chr(228)=>581,chr(229)=>581,chr(230)=>792,chr(231)=>440,chr(232)=>450,chr(233)=>450,chr(234)=>450,chr(235)=>450,chr(236)=>283,chr(237)=>283,chr(238)=>283,chr(239)=>283,chr(240)=>800,chr(241)=>595, + chr(242)=>508,chr(243)=>508,chr(244)=>508,chr(245)=>508,chr(246)=>508,chr(247)=>0,chr(248)=>508,chr(249)=>614,chr(250)=>614,chr(251)=>614,chr(252)=>614,chr(253)=>0,chr(254)=>0,chr(255)=>597); +$enc='cp1252'; +$diff=''; +$file='calligra.z'; +$originalsize=40120; +?> diff --git a/include/pdf/tutorial/calligra.ttf b/include/pdf/tutorial/calligra.ttf new file mode 100644 index 000000000..9713c468c Binary files /dev/null and b/include/pdf/tutorial/calligra.ttf differ diff --git a/include/pdf/tutorial/calligra.z b/include/pdf/tutorial/calligra.z new file mode 100644 index 000000000..1c0bebd20 Binary files /dev/null and b/include/pdf/tutorial/calligra.z differ diff --git a/include/pdf/tutorial/countries.txt b/include/pdf/tutorial/countries.txt new file mode 100644 index 000000000..aa8886cc3 --- /dev/null +++ b/include/pdf/tutorial/countries.txt @@ -0,0 +1,15 @@ +Austria;Vienna;83859;8075 +Belgium;Brussels;30518;10192 +Denmark;Copenhagen;43094;5295 +Finland;Helsinki;304529;5147 +France;Paris;543965;58728 +Germany;Berlin;357022;82057 +Greece;Athens;131625;10511 +Ireland;Dublin;70723;3694 +Italy;Roma;301316;57563 +Luxembourg;Luxembourg;2586;424 +Netherlands;Amsterdam;41526;15654 +Portugal;Lisbon;91906;9957 +Spain;Madrid;504790;39348 +Sweden;Stockholm;410934;8839 +United Kingdom;London;243820;58862 diff --git a/include/pdf/tutorial/index.htm b/include/pdf/tutorial/index.htm new file mode 100644 index 000000000..6df359643 --- /dev/null +++ b/include/pdf/tutorial/index.htm @@ -0,0 +1,18 @@ + + + +Tutorials + + + +

    Tutorials

    +The different examples rapidly show how to use FPDF. You will find all main features explained.

    +Tutorial 1: Minimal example
    +Tutorial 2: Header, footer, page break and image
    +Tutorial 3: Line breaks and colors
    +Tutorial 4: Multi-columns
    +Tutorial 5: Tables
    +Tutorial 6: Links and flowing text
    +Tutorial 7: Adding new fonts and encoding support
    + + diff --git a/include/pdf/tutorial/logo.png b/include/pdf/tutorial/logo.png new file mode 100644 index 000000000..284a0071c Binary files /dev/null and b/include/pdf/tutorial/logo.png differ diff --git a/include/pdf/tutorial/logo_pb.png b/include/pdf/tutorial/logo_pb.png new file mode 100644 index 000000000..e6827c15e Binary files /dev/null and b/include/pdf/tutorial/logo_pb.png differ diff --git a/include/pdf/tutorial/makefont.php b/include/pdf/tutorial/makefont.php new file mode 100644 index 000000000..3773429bd --- /dev/null +++ b/include/pdf/tutorial/makefont.php @@ -0,0 +1,6 @@ + diff --git a/include/pdf/tutorial/tuto1.htm b/include/pdf/tutorial/tuto1.htm new file mode 100644 index 000000000..34f0480b7 --- /dev/null +++ b/include/pdf/tutorial/tuto1.htm @@ -0,0 +1,92 @@ + + + +Minimal example + + + +

    Minimal example

    +Let's start with the classic example: +
    +
    +
    + +<?php
    define('FPDF_FONTPATH','font/');
    require(
    'fpdf.php');

    $pdf=new FPDF();
    $pdf->AddPage();
    $pdf->SetFont('Arial','B',16);
    $pdf->Cell(40,10,'Hello World!');
    $pdf->Output();
    ?> +
    +

    + +The first line defines where the font directory resides, relative to the current directory.
    +Then, after including the library file, we create an FPDF object. +The FPDF() constructor is used here with the default values: pages are in A4 portrait and +the measure unit is millimeter. It could have been specified explicitly with: +
    +
    +
    + +$pdf=new FPDF('P','mm','A4');
    +
    +

    +It is possible to use landscape (L), other page formats (such as Letter and +Legal) and measure units (pt, cm, in). +
    +
    +There is no page for the moment, so we have to add one with AddPage(). The origin +is at the upper-left corner and the current position is by default placed at 1 cm from the +borders; the margins can be changed with SetMargins(). +
    +
    +Before we can print text, it is mandatory to select a font with SetFont(), otherwise the +document would be invalid. We choose Arial bold 16: +
    +
    +
    + +$pdf->SetFont('Arial','B',16);
    +
    +

    +We could have specified italics with I, underlined with U or a regular font with an empty string +(or any combination). Note that the font size is given in points, not millimeters (or another +user unit); it is the only exception. The other standard fonts are Times, Courier, Symbol and +ZapfDingbats. +
    +
    +We can now print a cell with Cell(). A cell is a rectangular area, possibly framed, +which contains some text. It is output at the current position. We specify its dimensions, +its text (centered or aligned), if borders should be drawn, and where the current position +moves after it (to the right, below or to the beginning of the next line). To add a frame, we would do this: +
    +
    +
    + +$pdf->Cell(40,10,'Hello World !',1);
    +
    +

    +To add a new cell next to it with centered text and go to the next line, we would do: +
    +
    +
    + +$pdf->Cell(60,10,'Powered by FPDF.',0,1,'C');
    +
    +

    +Remark : the line break can also be done with Ln(). This method allows to specify +in addition the height of the break. +
    +
    +Finally, the document is closed and sent to the browser with Output(). We could have saved +it in a file by passing the desired file name. +
    +
    +Caution: in case when the PDF is sent to the browser, nothing else must be output, not before +nor after (the least space or carriage return matters). If you send some data before, you will +get the error message: "Some data has already been output to browser, can't send PDF file". If +you send after, your browser may display a blank page. + + diff --git a/include/pdf/tutorial/tuto1.php b/include/pdf/tutorial/tuto1.php new file mode 100644 index 000000000..14b836242 --- /dev/null +++ b/include/pdf/tutorial/tuto1.php @@ -0,0 +1,10 @@ +AddPage(); +$pdf->SetFont('Arial','B',16); +$pdf->Cell(40,10,'Hello World!'); +$pdf->Output(); +?> diff --git a/include/pdf/tutorial/tuto2.htm b/include/pdf/tutorial/tuto2.htm new file mode 100644 index 000000000..22e052d00 --- /dev/null +++ b/include/pdf/tutorial/tuto2.htm @@ -0,0 +1,50 @@ + + + +Header, footer, page break and image + + + +

    Header, footer, page break and image

    +Here is a two page example with header, footer and logo: +
    +
    +
    + +<?php
    define('FPDF_FONTPATH','font/');
    require(
    'fpdf.php');

    class
    PDF extends FPDF
    {
    //Page header
    function Header()
    {
        
    //Logo
        
    $this->Image('logo_pb.png',10,8,33);
        
    //Arial bold 15
        
    $this->SetFont('Arial','B',15);
        
    //Move to the right
        
    $this->Cell(80);
        
    //Title
        
    $this->Cell(30,10,'Title',1,0,'C');
        
    //Line break
        
    $this->Ln(20);
    }

    //Page footer
    function Footer()
    {
        
    //Position at 1.5 cm from bottom
        
    $this->SetY(-15);
        
    //Arial italic 8
        
    $this->SetFont('Arial','I',8);
        
    //Page number
        
    $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
    }
    }

    //Instanciation of inherited class
    $pdf=new PDF();
    $pdf->AliasNbPages();
    $pdf->AddPage();
    $pdf->SetFont('Times','',12);
    for(
    $i=1;$i<=40;$i++)
        
    $pdf->Cell(0,10,'Printing line number '.$i,0,1);
    $pdf->Output();
    ?> +
    +

    + +This example makes use of the Header() and Footer() methods to process page headers and +footers. They are called automatically. They already exist in the FPDF class but do nothing, +therefore we have to extend the class and override them. +
    +
    +The logo is printed with the Image() method by specifying its upper-left corner and +its width. The height is calculated automatically to respect the image proportions. +
    +
    +To print the page number, a null value is passed as the cell width. It means that the cell +should extend up to the right margin of the page; it is handy to center text. The current page +number is returned by the PageNo() method; as for the total number of pages, it is obtained +by means of the special value {nb} which will be substituted on document closure +(provided you first called AliasNbPages()). +
    +Note the use of the SetY() method which allows to set position at an absolute location in +the page, starting from the top or the bottom. +
    +
    +Another interesting feature is used here: the automatic page breaking. As soon as a cell would +cross a limit in the page (at 2 centimeters from the bottom by default), a break is performed +and the font restored. Although the header and footer select their own font (Arial), the body +continues with Times. This mechanism of automatic restoration also applies to colors and line +width. The limit which triggers page breaks can be set with SetAutoPageBreak(). + + diff --git a/include/pdf/tutorial/tuto2.php b/include/pdf/tutorial/tuto2.php new file mode 100644 index 000000000..1bb8ddd05 --- /dev/null +++ b/include/pdf/tutorial/tuto2.php @@ -0,0 +1,42 @@ +Image('logo_pb.png',10,8,33); + //Arial bold 15 + $this->SetFont('Arial','B',15); + //Move to the right + $this->Cell(80); + //Title + $this->Cell(30,10,'Title',1,0,'C'); + //Line break + $this->Ln(20); +} + +//Page footer +function Footer() +{ + //Position at 1.5 cm from bottom + $this->SetY(-15); + //Arial italic 8 + $this->SetFont('Arial','I',8); + //Page number + $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C'); +} +} + +//Instanciation of inherited class +$pdf=new PDF(); +$pdf->AliasNbPages(); +$pdf->AddPage(); +$pdf->SetFont('Times','',12); +for($i=1;$i<=40;$i++) + $pdf->Cell(0,10,'Printing line number '.$i,0,1); +$pdf->Output(); +?> diff --git a/include/pdf/tutorial/tuto3.htm b/include/pdf/tutorial/tuto3.htm new file mode 100644 index 000000000..41e434c17 --- /dev/null +++ b/include/pdf/tutorial/tuto3.htm @@ -0,0 +1,43 @@ + + + +Line breaks and colors + + + +

    Line breaks and colors

    +Let's continue with an example which prints justified paragraphs. It also illustrates the use +of colors. +
    +
    +
    + +<?php
    define('FPDF_FONTPATH','font/');
    require(
    'fpdf.php');

    class
    PDF extends FPDF
    {
    function
    Header()
    {
        global
    $title;

        
    //Arial bold 15
        
    $this->SetFont('Arial','B',15);
        
    //Calculate width of title and position
        
    $w=$this->GetStringWidth($title)+6;
        
    $this->SetX((210-$w)/2);
        
    //Colors of frame, background and text
        
    $this->SetDrawColor(0,80,180);
        
    $this->SetFillColor(230,230,0);
        
    $this->SetTextColor(220,50,50);
        
    //Thickness of frame (1 mm)
        
    $this->SetLineWidth(1);
        
    //Title
        
    $this->Cell($w,9,$title,1,1,'C',1);
        
    //Line break
        
    $this->Ln(10);
    }

    function
    Footer()
    {
        
    //Position at 1.5 cm from bottom
        
    $this->SetY(-15);
        
    //Arial italic 8
        
    $this->SetFont('Arial','I',8);
        
    //Text color in gray
        
    $this->SetTextColor(128);
        
    //Page number
        
    $this->Cell(0,10,'Page '.$this->PageNo(),0,0,'C');
    }

    function
    ChapterTitle($num,$label)
    {
        
    //Arial 12
        
    $this->SetFont('Arial','',12);
        
    //Background color
        
    $this->SetFillColor(200,220,255);
        
    //Title
        
    $this->Cell(0,6,"Chapter $num : $label",0,1,'L',1);
        
    //Line break
        
    $this->Ln(4);
    }

    function
    ChapterBody($file)
    {
        
    //Read text file
        
    $f=fopen($file,'r');
        
    $txt=fread($f,filesize($file));
        
    fclose($f);
        
    //Times 12
        
    $this->SetFont('Times','',12);
        
    //Output justified text
        
    $this->MultiCell(0,5,$txt);
        
    //Line break
        
    $this->Ln();
        
    //Mention in italics
        
    $this->SetFont('','I');
        
    $this->Cell(0,5,'(end of excerpt)');
    }

    function
    PrintChapter($num,$title,$file)
    {
        
    $this->AddPage();
        
    $this->ChapterTitle($num,$title);
        
    $this->ChapterBody($file);
    }
    }

    $pdf=new PDF();
    $title='20000 Leagues Under the Seas';
    $pdf->SetTitle($title);
    $pdf->SetAuthor('Jules Verne');
    $pdf->PrintChapter(1,'A RUNAWAY REEF','20k_c1.txt');
    $pdf->PrintChapter(2,'THE PROS AND CONS','20k_c2.txt');
    $pdf->Output();
    ?> +
    +

    + +The GetStringWidth() method allows to determine the length of a string in the current font, +which is used here to calculate the position and the width of the frame surrounding the title. +Then colors are set (via SetDrawColor(), SetFillColor() and SetTextColor()) and the +thickness of the line is set to 1 mm (against 0.2 by default) with SetLineWidth(). Finally, +we output the cell (the last parameter to 1 indicates that the background must be filled). +
    +
    +The method used to print the paragraphs is MultiCell(). Each time a line reaches the +right extremity of the cell or a carriage-return character is met, a line break is issued +and a new cell automatically created under the current one. Text is justified by default. +
    +
    +Two document properties are defined: title (SetTitle()) and author (SetAuthor()). +Properties can be viewed by two means. First is open the document directly with Acrobat Reader, +go to the File menu, Document info, General. Second, also available from the plug-in, is click +on the triangle just above the right scrollbar and choose Document info. + + diff --git a/include/pdf/tutorial/tuto3.php b/include/pdf/tutorial/tuto3.php new file mode 100644 index 000000000..f2c38ff99 --- /dev/null +++ b/include/pdf/tutorial/tuto3.php @@ -0,0 +1,84 @@ +SetFont('Arial','B',15); + //Calculate width of title and position + $w=$this->GetStringWidth($title)+6; + $this->SetX((210-$w)/2); + //Colors of frame, background and text + $this->SetDrawColor(0,80,180); + $this->SetFillColor(230,230,0); + $this->SetTextColor(220,50,50); + //Thickness of frame (1 mm) + $this->SetLineWidth(1); + //Title + $this->Cell($w,9,$title,1,1,'C',1); + //Line break + $this->Ln(10); +} + +function Footer() +{ + //Position at 1.5 cm from bottom + $this->SetY(-15); + //Arial italic 8 + $this->SetFont('Arial','I',8); + //Text color in gray + $this->SetTextColor(128); + //Page number + $this->Cell(0,10,'Page '.$this->PageNo(),0,0,'C'); +} + +function ChapterTitle($num,$label) +{ + //Arial 12 + $this->SetFont('Arial','',12); + //Background color + $this->SetFillColor(200,220,255); + //Title + $this->Cell(0,6,"Chapter $num : $label",0,1,'L',1); + //Line break + $this->Ln(4); +} + +function ChapterBody($file) +{ + //Read text file + $f=fopen($file,'r'); + $txt=fread($f,filesize($file)); + fclose($f); + //Times 12 + $this->SetFont('Times','',12); + //Output justified text + $this->MultiCell(0,5,$txt); + //Line break + $this->Ln(); + //Mention in italics + $this->SetFont('','I'); + $this->Cell(0,5,'(end of excerpt)'); +} + +function PrintChapter($num,$title,$file) +{ + $this->AddPage(); + $this->ChapterTitle($num,$title); + $this->ChapterBody($file); +} +} + +$pdf=new PDF(); +$title='20000 Leagues Under the Seas'; +$pdf->SetTitle($title); +$pdf->SetAuthor('Jules Verne'); +$pdf->PrintChapter(1,'A RUNAWAY REEF','20k_c1.txt'); +$pdf->PrintChapter(2,'THE PROS AND CONS','20k_c2.txt'); +$pdf->Output(); +?> diff --git a/include/pdf/tutorial/tuto4.htm b/include/pdf/tutorial/tuto4.htm new file mode 100644 index 000000000..5d7ae86eb --- /dev/null +++ b/include/pdf/tutorial/tuto4.htm @@ -0,0 +1,34 @@ + + + +Multi-columns + + + +

    Multi-columns

    +This example is a variant of the previous one showing how to lay the text across multiple +columns. +
    +
    +
    + +<?php
    define('FPDF_FONTPATH','font/');
    require(
    'fpdf.php');

    class
    PDF extends FPDF
    {
    //Current column
    var $col=0;
    //Ordinate of column start
    var $y0;

    function
    Header()
    {
        
    //Page header
        
    global $title;

        
    $this->SetFont('Arial','B',15);
        
    $w=$this->GetStringWidth($title)+6;
        
    $this->SetX((210-$w)/2);
        
    $this->SetDrawColor(0,80,180);
        
    $this->SetFillColor(230,230,0);
        
    $this->SetTextColor(220,50,50);
        
    $this->SetLineWidth(1);
        
    $this->Cell($w,9,$title,1,1,'C',1);
        
    $this->Ln(10);
        
    //Save ordinate
        
    $this->y0=$this->GetY();
    }

    function
    Footer()
    {
        
    //Page footer
        
    $this->SetY(-15);
        
    $this->SetFont('Arial','I',8);
        
    $this->SetTextColor(128);
        
    $this->Cell(0,10,'Page '.$this->PageNo(),0,0,'C');
    }

    function
    SetCol($col)
    {
        
    //Set position at a given column
        
    $this->col=$col;
        
    $x=10+$col*65;
        
    $this->SetLeftMargin($x);
        
    $this->SetX($x);
    }

    function
    AcceptPageBreak()
    {
        
    //Method accepting or not automatic page break
        
    if($this->col<2)
        {
            
    //Go to next column
            
    $this->SetCol($this->col+1);
            
    //Set ordinate to top
            
    $this->SetY($this->y0);
            
    //Keep on page
            
    return false;
        }
        else
        {
            
    //Go back to first column
            
    $this->SetCol(0);
            
    //Page break
            
    return true;
        }
    }

    function
    ChapterTitle($num,$label)
    {
        
    //Title
        
    $this->SetFont('Arial','',12);
        
    $this->SetFillColor(200,220,255);
        
    $this->Cell(0,6,"Chapter  $num : $label",0,1,'L',1);
        
    $this->Ln(4);
        
    //Save ordinate
        
    $this->y0=$this->GetY();
    }

    function
    ChapterBody($fichier)
    {
        
    //Read text file
        
    $f=fopen($fichier,'r');
        
    $txt=fread($f,filesize($fichier));
        
    fclose($f);
        
    //Font
        
    $this->SetFont('Times','',12);
        
    //Output text in a 6 cm width column
        
    $this->MultiCell(60,5,$txt);
        
    $this->Ln();
        
    //Mention
        
    $this->SetFont('','I');
        
    $this->Cell(0,5,'(end of excerpt)');
        
    //Go back to first column
        
    $this->SetCol(0);
    }

    function
    PrintChapter($num,$title,$file)
    {
        
    //Add chapter
        
    $this->AddPage();
        
    $this->ChapterTitle($num,$title);
        
    $this->ChapterBody($file);
    }
    }

    $pdf=new PDF();
    $title='20000 Leagues Under the Seas';
    $pdf->SetTitle($title);
    $pdf->SetAuthor('Jules Verne');
    $pdf->PrintChapter(1,'A RUNAWAY REEF','20k_c1.txt');
    $pdf->PrintChapter(2,'THE PROS AND CONS','20k_c2.txt');
    $pdf->Output();
    ?> +
    +

    + +The key method used is AcceptPageBreak(). It allows to accept or not an automatic page +break. By refusing it and altering the margin and current position, the desired column layout +is achieved. +
    +For the rest, not much change; two properties have been added to the class to save the current +column number and the position where columns begin, and the MultiCell() call specifies a +6 centimeter width. + + diff --git a/include/pdf/tutorial/tuto4.php b/include/pdf/tutorial/tuto4.php new file mode 100644 index 000000000..41d6ff6fb --- /dev/null +++ b/include/pdf/tutorial/tuto4.php @@ -0,0 +1,114 @@ +SetFont('Arial','B',15); + $w=$this->GetStringWidth($title)+6; + $this->SetX((210-$w)/2); + $this->SetDrawColor(0,80,180); + $this->SetFillColor(230,230,0); + $this->SetTextColor(220,50,50); + $this->SetLineWidth(1); + $this->Cell($w,9,$title,1,1,'C',1); + $this->Ln(10); + //Save ordinate + $this->y0=$this->GetY(); +} + +function Footer() +{ + //Page footer + $this->SetY(-15); + $this->SetFont('Arial','I',8); + $this->SetTextColor(128); + $this->Cell(0,10,'Page '.$this->PageNo(),0,0,'C'); +} + +function SetCol($col) +{ + //Set position at a given column + $this->col=$col; + $x=10+$col*65; + $this->SetLeftMargin($x); + $this->SetX($x); +} + +function AcceptPageBreak() +{ + //Method accepting or not automatic page break + if($this->col<2) + { + //Go to next column + $this->SetCol($this->col+1); + //Set ordinate to top + $this->SetY($this->y0); + //Keep on page + return false; + } + else + { + //Go back to first column + $this->SetCol(0); + //Page break + return true; + } +} + +function ChapterTitle($num,$label) +{ + //Title + $this->SetFont('Arial','',12); + $this->SetFillColor(200,220,255); + $this->Cell(0,6,"Chapter $num : $label",0,1,'L',1); + $this->Ln(4); + //Save ordinate + $this->y0=$this->GetY(); +} + +function ChapterBody($fichier) +{ + //Read text file + $f=fopen($fichier,'r'); + $txt=fread($f,filesize($fichier)); + fclose($f); + //Font + $this->SetFont('Times','',12); + //Output text in a 6 cm width column + $this->MultiCell(60,5,$txt); + $this->Ln(); + //Mention + $this->SetFont('','I'); + $this->Cell(0,5,'(end of excerpt)'); + //Go back to first column + $this->SetCol(0); +} + +function PrintChapter($num,$title,$file) +{ + //Add chapter + $this->AddPage(); + $this->ChapterTitle($num,$title); + $this->ChapterBody($file); +} +} + +$pdf=new PDF(); +$title='20000 Leagues Under the Seas'; +$pdf->SetTitle($title); +$pdf->SetAuthor('Jules Verne'); +$pdf->PrintChapter(1,'A RUNAWAY REEF','20k_c1.txt'); +$pdf->PrintChapter(2,'THE PROS AND CONS','20k_c2.txt'); +$pdf->Output(); +?> diff --git a/include/pdf/tutorial/tuto5.htm b/include/pdf/tutorial/tuto5.htm new file mode 100644 index 000000000..b0263003e --- /dev/null +++ b/include/pdf/tutorial/tuto5.htm @@ -0,0 +1,43 @@ + + + +Tables + + + +

    Tables

    +This tutorial shows how to make tables easily. +
    +
    +
    + +<?php
    define('FPDF_FONTPATH','font/');
    require(
    'fpdf.php');

    class
    PDF extends FPDF
    {
    //Load data
    function LoadData($file)
    {
        
    //Read file lines
        
    $lines=file($file);
        
    $data=array();
        foreach(
    $lines as $line)
            
    $data[]=explode(';',chop($line));
        return
    $data;
    }

    //Simple table
    function BasicTable($header,$data)
    {
        
    //Header
        
    foreach($header as $col)
            
    $this->Cell(40,7,$col,1);
        
    $this->Ln();
        
    //Data
        
    foreach($data as $row)
        {
            foreach(
    $row as $col)
                
    $this->Cell(40,6,$col,1);
            
    $this->Ln();
        }
    }

    //Better table
    function ImprovedTable($header,$data)
    {
        
    //Column widths
        
    $w=array(40,35,40,45);
        
    //Header
        
    for($i=0;$i<count($header);$i++)
            
    $this->Cell($w[$i],7,$header[$i],1,0,'C');
        
    $this->Ln();
        
    //Data
        
    foreach($data as $row)
        {
            
    $this->Cell($w[0],6,$row[0],'LR');
            
    $this->Cell($w[1],6,$row[1],'LR');
            
    $this->Cell($w[2],6,number_format($row[2]),'LR',0,'R');
            
    $this->Cell($w[3],6,number_format($row[3]),'LR',0,'R');
            
    $this->Ln();
        }
        
    //Closure line
        
    $this->Cell(array_sum($w),0,'','T');
    }

    //Colored table
    function FancyTable($header,$data)
    {
        
    //Colors, line width and bold font
        
    $this->SetFillColor(255,0,0);
        
    $this->SetTextColor(255);
        
    $this->SetDrawColor(128,0,0);
        
    $this->SetLineWidth(.3);
        
    $this->SetFont('','B');
        
    //Header
        
    $w=array(40,35,40,45);
        for(
    $i=0;$i<count($header);$i++)
            
    $this->Cell($w[$i],7,$header[$i],1,0,'C',1);
        
    $this->Ln();
        
    //Color and font restoration
        
    $this->SetFillColor(224,235,255);
        
    $this->SetTextColor(0);
        
    $this->SetFont('');
        
    //Data
        
    $fill=0;
        foreach(
    $data as $row)
        {
            
    $this->Cell($w[0],6,$row[0],'LR',0,'L',$fill);
            
    $this->Cell($w[1],6,$row[1],'LR',0,'L',$fill);
            
    $this->Cell($w[2],6,number_format($row[2]),'LR',0,'R',$fill);
            
    $this->Cell($w[3],6,number_format($row[3]),'LR',0,'R',$fill);
            
    $this->Ln();
            
    $fill=!$fill;
        }
        
    $this->Cell(array_sum($w),0,'','T');
    }
    }

    $pdf=new PDF();
    //Column titles
    $header=array('Country','Capital','Area (sq km)','Pop. (thousands)');
    //Data loading
    $data=$pdf->LoadData('countries.txt');
    $pdf->SetFont('Arial','',14);
    $pdf->AddPage();
    $pdf->BasicTable($header,$data);
    $pdf->AddPage();
    $pdf->ImprovedTable($header,$data);
    $pdf->AddPage();
    $pdf->FancyTable($header,$data);
    $pdf->Output();
    ?> +
    +

    + +A table being just a collection of cells, it is natural to build one from them. The first +example is achieved in the most basic way possible: simple framed cells, all of the same size +and left aligned. The result is rudimentary but very quick to obtain. +
    +
    +The second table brings some improvements: each column has its own width, titles are centered +and figures right aligned. Moreover, horizontal lines have been removed. This is done by means +of the border parameter of the Cell() method, which specifies which sides of the +cell must be drawn. Here we want the left (L) and right (R) ones. It remains +the problem of the horizontal line to finish the table. There are two possibilities: either +check for the last line in the loop, in which case we use LRB for the border +parameter; or, as done here, add the line once the loop is over. +
    +
    +The third table is similar to the second one but uses colors. Fill, text and line colors are +simply specified. Alternate coloring for rows is obtained by using alternatively transparent +and filled cells. + + diff --git a/include/pdf/tutorial/tuto5.php b/include/pdf/tutorial/tuto5.php new file mode 100644 index 000000000..4b6c4535b --- /dev/null +++ b/include/pdf/tutorial/tuto5.php @@ -0,0 +1,102 @@ +Cell(40,7,$col,1); + $this->Ln(); + //Data + foreach($data as $row) + { + foreach($row as $col) + $this->Cell(40,6,$col,1); + $this->Ln(); + } +} + +//Better table +function ImprovedTable($header,$data) +{ + //Column widths + $w=array(40,35,40,45); + //Header + for($i=0;$iCell($w[$i],7,$header[$i],1,0,'C'); + $this->Ln(); + //Data + foreach($data as $row) + { + $this->Cell($w[0],6,$row[0],'LR'); + $this->Cell($w[1],6,$row[1],'LR'); + $this->Cell($w[2],6,number_format($row[2]),'LR',0,'R'); + $this->Cell($w[3],6,number_format($row[3]),'LR',0,'R'); + $this->Ln(); + } + //Closure line + $this->Cell(array_sum($w),0,'','T'); +} + +//Colored table +function FancyTable($header,$data) +{ + //Colors, line width and bold font + $this->SetFillColor(255,0,0); + $this->SetTextColor(255); + $this->SetDrawColor(128,0,0); + $this->SetLineWidth(.3); + $this->SetFont('','B'); + //Header + $w=array(40,35,40,45); + for($i=0;$iCell($w[$i],7,$header[$i],1,0,'C',1); + $this->Ln(); + //Color and font restoration + $this->SetFillColor(224,235,255); + $this->SetTextColor(0); + $this->SetFont(''); + //Data + $fill=0; + foreach($data as $row) + { + $this->Cell($w[0],6,$row[0],'LR',0,'L',$fill); + $this->Cell($w[1],6,$row[1],'LR',0,'L',$fill); + $this->Cell($w[2],6,number_format($row[2]),'LR',0,'R',$fill); + $this->Cell($w[3],6,number_format($row[3]),'LR',0,'R',$fill); + $this->Ln(); + $fill=!$fill; + } + $this->Cell(array_sum($w),0,'','T'); +} +} + +$pdf=new PDF(); +//Column titles +$header=array('Country','Capital','Area (sq km)','Pop. (thousands)'); +//Data loading +$data=$pdf->LoadData('countries.txt'); +$pdf->SetFont('Arial','',14); +$pdf->AddPage(); +$pdf->BasicTable($header,$data); +$pdf->AddPage(); +$pdf->ImprovedTable($header,$data); +$pdf->AddPage(); +$pdf->FancyTable($header,$data); +$pdf->Output(); +?> diff --git a/include/pdf/tutorial/tuto6.htm b/include/pdf/tutorial/tuto6.htm new file mode 100644 index 000000000..e94043ddc --- /dev/null +++ b/include/pdf/tutorial/tuto6.htm @@ -0,0 +1,68 @@ + + + +Links and flowing text + + + +

    Links and flowing text

    +This tutorial explains how to insert links (internal and external) and shows a new text writing +mode. It also contains a rudimentary HTML parser. +
    +
    +
    + +<?php
    define('FPDF_FONTPATH','font/');
    require(
    'fpdf.php');

    class
    PDF extends FPDF
    {
    var
    $B;
    var
    $I;
    var
    $U;
    var
    $HREF;

    function
    PDF($orientation='P',$unit='mm',$format='A4')
    {
        
    //Call parent constructor
        
    $this->FPDF($orientation,$unit,$format);
        
    //Initialization
        
    $this->B=0;
        
    $this->I=0;
        
    $this->U=0;
        
    $this->HREF='';
    }

    function
    WriteHTML($html)
    {
        
    //HTML parser
        
    $html=str_replace("\n",' ',$html);
        
    $a=preg_split('/<(.*)>/U',$html,-1,PREG_SPLIT_DELIM_CAPTURE);
        foreach(
    $a as $i=>$e)
        {
            if(
    $i%2==0)
            {
                
    //Text
                
    if($this->HREF)
                    
    $this->PutLink($this->HREF,$e);
                else
                    
    $this->Write(5,$e);
            }
            else
            {
                
    //Tag
                
    if($e{0}=='/')
                    
    $this->CloseTag(strtoupper(substr($e,1)));
                else
                {
                    
    //Extract attributes
                    
    $a2=explode(' ',$e);
                    
    $tag=strtoupper(array_shift($a2));
                    
    $attr=array();
                    foreach(
    $a2 as $v)
                        if(
    ereg('^([^=]*)=["\']?([^"\']*)["\']?$',$v,$a3))
                            
    $attr[strtoupper($a3[1])]=$a3[2];
                    
    $this->OpenTag($tag,$attr);
                }
            }
        }
    }

    function
    OpenTag($tag,$attr)
    {
        
    //Opening tag
        
    if($tag=='B' or $tag=='I' or $tag=='U')
            
    $this->SetStyle($tag,true);
        if(
    $tag=='A')
            
    $this->HREF=$attr['HREF'];
        if(
    $tag=='BR')
            
    $this->Ln(5);
    }

    function
    CloseTag($tag)
    {
        
    //Closing tag
        
    if($tag=='B' or $tag=='I' or $tag=='U')
            
    $this->SetStyle($tag,false);
        if(
    $tag=='A')
            
    $this->HREF='';
    }

    function
    SetStyle($tag,$enable)
    {
        
    //Modify style and select corresponding font
        
    $this->$tag+=($enable ? 1 : -1);
        
    $style='';
        foreach(array(
    'B','I','U') as $s)
            if(
    $this->$s>0)
                
    $style.=$s;
        
    $this->SetFont('',$style);
    }

    function
    PutLink($URL,$txt)
    {
        
    //Put a hyperlink
        
    $this->SetTextColor(0,0,255);
        
    $this->SetStyle('U',true);
        
    $this->Write(5,$txt,$URL);
        
    $this->SetStyle('U',false);
        
    $this->SetTextColor(0);
    }
    }

    $html='You can now easily print text mixing different
    styles : <B>bold</B>, <I>italic</I>, <U>underlined</U>, or
    <B><I><U>all at once</U></I></B>!<BR>You can also insert links
    on text, such as <A HREF="http://www.fpdf.org">www.fpdf.org</A>,
    or on an image: click on the logo.'
    ;

    $pdf=new PDF();
    //First page
    $pdf->AddPage();
    $pdf->SetFont('Arial','',20);
    $pdf->Write(5,'To find out what\'s new in this tutorial, click ');
    $pdf->SetFont('','U');
    $link=$pdf->AddLink();
    $pdf->Write(5,'here',$link);
    $pdf->SetFont('');
    //Second page
    $pdf->AddPage();
    $pdf->SetLink($link);
    $pdf->Image('logo.png',10,10,30,0,'','http://www.fpdf.org');
    $pdf->SetLeftMargin(45);
    $pdf->SetFontSize(14);
    $pdf->WriteHTML($html);
    $pdf->Output();
    ?> +
    +

    + +The new method to print text is Write(). It is very close to MultiCell(); the differences +are: +
      +
    • The end of line is at the right margin and the next line begins at the left one +
    • The current position moves at the end of the text +
    +So it allows to write a chunk of text, alter the font style, then continue from the exact +place we left it. On the other hand, you cannot full justify it. +
    +
    +The method is used on the first page to put a link pointing to the second one. The beginning of +the sentence is written in regular style, then we switch to underline and finish it. The link +is created with AddLink(), which returns a link identifier. The identifier is +passed as third parameter of Write(). Once the second page is created, we use SetLink() to +make the link point to the beginning of the current page. +
    +
    +Then we put an image with a link on it. An external link points to an URL (HTTP, mailto...). +The URL is simply passed as last parameter of Image(). +Note that external links do not work when the PDF is displayed inside Netscape's plug-in. +
    +
    +Finally, the left margin is moved after the image with SetLeftMargin() and some text in +HTML format is output. An HTML parser is used for this, based on the regular expression splitting +function preg_split() and the option PREG_SPLIT_DELIM_CAPTURE (introduced in PHP 4.0.5) which +allows to fetch the separators as well (in this case the tags). If you use an older version of +PHP, replace the line with this one: +
    +
    +
    + +$a=preg_split('/[<>]/',$html);
    +
    +

    +which is less strict but gives the same results with valid HTML. +
    +Recognized tags are <B>, <I>, <U>, <A> and <BR>; the others are +ignored. The parser also makes use of the Write() method. An external link is put the same way as +an internal one (third parameter of Write()). +
    +Note that Cell() also allows to put links. + + diff --git a/include/pdf/tutorial/tuto6.php b/include/pdf/tutorial/tuto6.php new file mode 100644 index 000000000..5d9436c31 --- /dev/null +++ b/include/pdf/tutorial/tuto6.php @@ -0,0 +1,123 @@ +FPDF($orientation,$unit,$format); + //Initialization + $this->B=0; + $this->I=0; + $this->U=0; + $this->HREF=''; +} + +function WriteHTML($html) +{ + //HTML parser + $html=str_replace("\n",' ',$html); + $a=preg_split('/<(.*)>/U',$html,-1,PREG_SPLIT_DELIM_CAPTURE); + foreach($a as $i=>$e) + { + if($i%2==0) + { + //Text + if($this->HREF) + $this->PutLink($this->HREF,$e); + else + $this->Write(5,$e); + } + else + { + //Tag + if($e{0}=='/') + $this->CloseTag(strtoupper(substr($e,1))); + else + { + //Extract attributes + $a2=explode(' ',$e); + $tag=strtoupper(array_shift($a2)); + $attr=array(); + foreach($a2 as $v) + if(ereg('^([^=]*)=["\']?([^"\']*)["\']?$',$v,$a3)) + $attr[strtoupper($a3[1])]=$a3[2]; + $this->OpenTag($tag,$attr); + } + } + } +} + +function OpenTag($tag,$attr) +{ + //Opening tag + if($tag=='B' or $tag=='I' or $tag=='U') + $this->SetStyle($tag,true); + if($tag=='A') + $this->HREF=$attr['HREF']; + if($tag=='BR') + $this->Ln(5); +} + +function CloseTag($tag) +{ + //Closing tag + if($tag=='B' or $tag=='I' or $tag=='U') + $this->SetStyle($tag,false); + if($tag=='A') + $this->HREF=''; +} + +function SetStyle($tag,$enable) +{ + //Modify style and select corresponding font + $this->$tag+=($enable ? 1 : -1); + $style=''; + foreach(array('B','I','U') as $s) + if($this->$s>0) + $style.=$s; + $this->SetFont('',$style); +} + +function PutLink($URL,$txt) +{ + //Put a hyperlink + $this->SetTextColor(0,0,255); + $this->SetStyle('U',true); + $this->Write(5,$txt,$URL); + $this->SetStyle('U',false); + $this->SetTextColor(0); +} +} + +$html='You can now easily print text mixing different +styles : bold, italic, underlined, or +all at once!
    You can also insert links +on text, such as www.fpdf.org, +or on an image: click on the logo.'; + +$pdf=new PDF(); +//First page +$pdf->AddPage(); +$pdf->SetFont('Arial','',20); +$pdf->Write(5,'To find out what\'s new in this tutorial, click '); +$pdf->SetFont('','U'); +$link=$pdf->AddLink(); +$pdf->Write(5,'here',$link); +$pdf->SetFont(''); +//Second page +$pdf->AddPage(); +$pdf->SetLink($link); +$pdf->Image('logo.png',10,10,30,0,'','http://www.fpdf.org'); +$pdf->SetLeftMargin(45); +$pdf->SetFontSize(14); +$pdf->WriteHTML($html); +$pdf->Output(); +?> diff --git a/include/pdf/tutorial/tuto7.htm b/include/pdf/tutorial/tuto7.htm new file mode 100644 index 000000000..69aef60fb --- /dev/null +++ b/include/pdf/tutorial/tuto7.htm @@ -0,0 +1,316 @@ + + + +Adding new fonts and encoding support + + + +

    Adding new fonts and encoding support

    +This tutorial explains how to use TrueType or Type1 fonts so that you are not limited to the standard +fonts any more. The other interest is that you can choose the font encoding, which allows you to +use other languages than the Western ones (the standard fonts having too few available characters). +
    +
    +There are two ways to use a new font: embedding it in the PDF or not. When a font is not +embedded, it is sought in the system. The advantage is that the PDF file is lighter; on the other +hand, if it is not available, a substitution font is used. So it is preferable to ensure that the +needed font is installed on the client systems. If the file is to be viewed by a large audience, +it is better to embed. +
    +
    +Adding a new font requires three steps for TrueTypes: +
      +
    • Generation of the metric file (.afm) +
    • Generation of the font definition file (.php) +
    • Declaration of the font in the script +
    +For Type1, the first one is theoretically not necessary because the AFM file is usually shipped +with the font. In case you have only a metric file in PFM format, use the convertor available +here. +

    Generation of the metric file

    +The first step for a TrueType consists in generating the AFM file. A utility exists to do this +task: ttf2pt1. The Windows binary +is available here. The command line to use is +the following: +
    +
    +ttf2pt1 -a font.ttf font +
    +
    +For example, for Comic Sans MS Regular: +
    +
    +ttf2pt1 -a c:\windows\fonts\comic.ttf comic +
    +
    +Two files are created; the one we are interested in is comic.afm. +

    Generation of the font definition file

    +The second step consists in generating a PHP file containing all the information needed by FPDF; +in addition, the font file is compressed. To do this, a helper script is provided in the font/makefont/ +directory of the package: makefont.php. It contains the following function: +
    +
    +MakeFont(string fontfile, string afmfile [, string enc [, array patch [, string type]]]) +
    +
    +fontfile +
    +Path to the .ttf or .pfb file. +
    +afmfile +
    +Path to the .afm file. +
    +enc +
    +Name of the encoding to use. Default value: cp1252. +
    +patch +
    +Optional modification of the encoding. Empty by default. +
    +type +
    +Type of the font (TrueType or Type1). Default value: TrueType. +
    +
    +The first parameter is the name of the font file. The extension must be either .ttf or .pfb and +determines the font type. If you own a Type1 font in ASCII format (.pfa), you can convert it to +binary format with t1utils. +
    +If you don't want to embed the font, pass an empty string. In this case, type is given by the +type parameter. +
    +Note: in the case of a font with the same name as a standard one, for instance arial.ttf, it is +mandatory to embed. If you don't, Acrobat will use its own font. +
    +
    +The AFM file is the one previously generated. +
    +
    +The encoding defines the association between a code (from 0 to 255) and a character. The first +128 are fixed and correspond to ASCII; the following are variable. The encodings are stored in +.map files. Those available are: +
      +
    • cp1250 (Central Europe) +
    • cp1251 (Cyrillic) +
    • cp1252 (Western Europe) +
    • cp1253 (Greek) +
    • cp1254 (Turkish) +
    • cp1255 (Hebrew) +
    • cp1257 (Baltic) +
    • cp1258 (Vietnamese) +
    • cp874 (Thai) +
    • ISO-8859-1 (Western Europe) +
    • ISO-8859-2 (Central Europe) +
    • ISO-8859-4 (Baltic) +
    • ISO-8859-5 (Cyrillic) +
    • ISO-8859-7 (Greek) +
    • ISO-8859-9 (Turkish) +
    • ISO-8859-11 (Thai) +
    • ISO-8859-15 (Western Europe) +
    • ISO-8859-16 (Central Europe) +
    • KOI8-R (Russian) +
    • KOI8-U (Ukrainian) +
    +Of course, the font must contain the characters corresponding to the chosen encoding. +
    +In the particular case of a symbolic font (that is to say which does not contain letters, such +as Symbol or ZapfDingbats), pass an empty string. +
    +The encodings which begin with cp are those used by Windows; Linux systems usually use ISO. +
    +Remark: the standard fonts use cp1252. +
    +
    +The fourth parameter gives the possibility to alter the encoding. Sometimes you may want to add +some characters. For instance, ISO-8859-1 does not contain the euro symbol. To add it at position +164, pass array(164=>'Euro'). +
    +
    +The last parameter is used to give the type of the font in case it is not embedded (that is to +say the first parameter is empty). +
    +
    +After you have called the function (create a new file for this and include makefont.php, or +simply add the call directly inside), a .php file is created, with the same name as the .afm one. +You may rename it if you wish. If the case of embedding, the font file is compressed and gives a +second file with .z as extension (except if the compression function is not available, it +requires Zlib). You may rename it too, but in this case you have to alter the variable $file +in the .php file accordingly. +
    +
    +Example: +
    +
    +MakeFont('c:\\windows\\fonts\\comic.ttf','comic.afm','cp1252'); +
    +
    +which gives the files comic.php and comic.z. +
    +
    +Then you have to copy the generated file(s) either in the directory of the script which will use +the font, or in the directory given by FPDF_FONTPATH if the constant is defined. If the font file +could not be compressed, copy the .ttf or .pfb instead of the .z. +

    Declaration of the font in the script

    +The last step is the most simple. You just need to call the AddFont() method. For instance: +
    +
    +
    + +$pdf->AddFont('Comic','','comic.php');
    +
    +

    +or simply: +
    +
    +
    + +$pdf->AddFont('Comic');
    +
    +

    +And the font is now available (in regular and underlined styles), usable like the others. If we +had worked with Comic Sans MS Bold (comicbd.ttf), we would have put: +
    +
    +
    + +$pdf->AddFont('Comic','B','comicbd.php');
    +
    +

    +

    Example

    +Let's now see a small complete example. The font used is Calligrapher, available at +www.abstractfonts.com (a site +offering numerous free TrueType fonts). The first step is the generation of the AFM file: +
    +
    +ttf2pt1 -a calligra.ttf calligra +
    +
    +which gives calligra.afm (and calligra.t1a that we can delete). Then we generate the definition +file: +
    +
    +
    + +<?php
    require('../font/makefont/makefont.php');

    MakeFont('calligra.ttf','calligra.afm');
    ?> +
    +

    +The function call gives the following report: +
    +
    +Warning: character Euro is missing
    +Warning: character Zcaron is missing
    +Warning: character zcaron is missing
    +Warning: character eth is missing
    +Font file compressed (calligra.z)
    +Font definition file generated (calligra.php)
    +
    +The euro character is not present in the font (it is too old). Three other characters are missing +too, but we are not interested in them anyway. +
    +We can now copy the two files in the font directory and write the script: +
    +
    +
    + +<?php
    define('FPDF_FONTPATH','font/');
    require(
    'fpdf.php');

    $pdf=new FPDF();
    $pdf->AddFont('Calligrapher','','calligra.php');
    $pdf->AddPage();
    $pdf->SetFont('Calligrapher','',35);
    $pdf->Cell(0,10,'Enjoy new fonts with FPDF!');
    $pdf->Output();
    ?> +
    +

    + +

    About the euro symbol

    +The euro character is not present in all encodings, and is not always placed at the same position: +
    +
    + + + + + + + + + + + + + + + + + + + + + + + +
    EncodingPosition
    cp1250128
    cp1251136
    cp1252128
    cp1253128
    cp1254128
    cp1255128
    cp1257128
    cp1258128
    cp874128
    ISO-8859-1absent
    ISO-8859-2absent
    ISO-8859-4absent
    ISO-8859-5absent
    ISO-8859-7absent
    ISO-8859-9absent
    ISO-8859-11absent
    ISO-8859-15164
    ISO-8859-16164
    KOI8-Rabsent
    KOI8-Uabsent
    +
    +ISO-8859-1 is widespread but does not include the euro sign. If you need it, the simplest thing +to do is using cp1252 or ISO-8859-15 instead, which are nearly identical but contain the precious +symbol. +
    +As for ISO-8859-2, it is possible to use ISO-8859-16 instead, but it contains many differences. +It is therefore simpler to patch the encoding to add the symbol to it, as explained above. The +same is true for the other encodings. +

    Font synthesis under Windows

    +When a TrueType font is not available in a given style, Windows is able to synthesize it from the +regular version. For instance, there is no Comic Sans MS Italic, but it can be built from Comic +Sans MS Regular. This feature can be used in a PDF file, but unfortunately requires that the +regular font be present in the system (you must not embed it). Here is how to do it: +
      +
    • Generate the definition file for the regular font without embedding (you may rename it to +reflect the desired style) +
    • Open it and append to the variable $name a comma followed by the desired style +(Italic, Bold or BoldItalic) +
    +For instance, for the file comici.php: +
    +
    +$name='ComicSansMS,Italic'; +
    +
    +It can then be used normally: +
    +
    +
    + +$pdf->AddFont('Comic','I','comici.php');
    +
    +

    +

    Reducing the size of TrueType fonts

    +Font files are often quite voluminous (more than 100, even 200KB); this is due to the fact that +they contain the characters corresponding to many encodings. Zlib compression reduces them but +they remain fairly big. A technique exists to reduce them further. It consists in converting the +font to the Type1 format with ttf2pt1 by specifying the encoding you are interested in; all other +characters will be discarded. +
    +For instance, the arial.ttf font shipped with Windows 98 is 267KB (it contains 1296 characters). +After compression it gives 147. Let's convert it to Type1 by keeping only cp1250 characters: +
    +
    +ttf2pt1 -b -L cp1250.map c:\windows\fonts\arial.ttf arial +
    +
    +The .map files are located in the font/makefont/ directory of the package. The command produces +arial.pfb and arial.afm. The arial.pfb file is only 35KB, and 30KB after compression. +
    +
    +It is possible to go even further. If you are interested only by a subset of the encoding (you +probably don't need all 217 characters), you can open the .map file and remove the lines you are +not interested in. This will reduce the file size accordingly. + + diff --git a/include/pdf/tutorial/tuto7.php b/include/pdf/tutorial/tuto7.php new file mode 100644 index 000000000..38caf9394 --- /dev/null +++ b/include/pdf/tutorial/tuto7.php @@ -0,0 +1,10 @@ +AddFont('Calligrapher','','calligra.php'); +$pdf->AddPage(); +$pdf->SetFont('Calligrapher','',35); +$pdf->Cell(0,10,'Enjoy new fonts with FPDF!'); +$pdf->Output(); +?> diff --git a/include/person.class.php b/include/person.class.php new file mode 100644 index 000000000..3440df800 --- /dev/null +++ b/include/person.class.php @@ -0,0 +1,194 @@ +false wenn Fehler auftritt und schreiben + * die Fehlermeldung in diese Variable + * @var string enthält Fehlermeldung + */ + var $errormsg; + /** + * @var boolean true=Person neu anlegen (INSERT), false=UPDATE + */ + var $new=true; + /** + * @var person Person (todo: wozu?) + */ + var $person; + /** + * @var resource + */ + var $conn; + var $updateamum; + var $updatevon; + + function person($conn) + { + $this->conn = $conn; + } + + + /** + * Verbindung zur Datenbank herstellen + * @return PostgreSQL-Connection oder NULL + */ + function getConnection() { + return $this->conn; + } + + /** + * Speichert die Person in die Datenbank. INSERT oder DELETE wird durch 'new' + * bestimmt. + * @return boolean false, wenn's nicht funtkioniert hat (Fehlermeldung steht + * in errormsg) + */ + function save() + { + if (is_null($conn=$this->getConnection())) { + return false; + } + if (strlen($this->uid)==0) + { + $this->errormsg="uid nicht gesetzt"; + return false; + } + if ($this->new) + { + $qry="insert into tbl_person(uid,titel,vornamen,nachname,gebdatum,". + "gebort,gebzeit,anmerkungen,aktiv,". + "email,alias,homepage) ". + "values('".$this->uid."','".$this->titel."',". + "'".$this->vornamen."','".$this->nachname."',". + (strlen($this->gebdatum)>0?"'".$this->gebdatum."'":'NULL'). + ",'".$this->gebort."',". + (strlen($this->gebzeit)>0?"'".$this->gebzeit."'":'NULL'). + ",'".$this->anmerkungen."',".($this->aktiv?'true':'false').",". + "'".$this->email."',".($this->alias==''?'null':"'$this->alias'").",'".$this->homepage."'". + ")"; + } + else + { + $qry="update tbl_person set ". + "titel='".$this->titel."',". + "vornamen='".$this->vornamen."',". + "nachname='".$this->nachname."',". + "gebdatum=".(strlen($this->gebdatum)>0?"'".$this->gebdatum."'":'NULL').",". + "gebort='".$this->gebort."',". + "gebzeit=".(strlen($this->gebzeit)>0?"'".$this->gebzeit."'":'NULL').",". + "anmerkungen='".$this->anmerkungen."',". + "aktiv=".($this->aktiv?'true':'false').",". + "email='".$this->email."',alias=".($this->alias==''?'null':"'$this->alias'").",". + "homepage='".$this->homepage."' ". + "where uid='".$this->uid."'"; + } + $qry="set datestyle to german;".$qry; + //echo $qry; + if(!($erg=pg_exec($conn, $qry))) + { + $this->errormsg=pg_errormessage($conn); + return false; + } + return true; + } + + /** + * Ladet die Attribute der Person aus der Datenbank. Bei Fehler ist der + * Rueckgabewert 'false' und die Fehlermeldung steht in 'errormsg'. + * @return boolean true, wenn's funktioniert hat; false bei Fehler + */ + function load($uid='') + { + // optional: uid setzen + if (strlen($uid)>0) + $this->uid=$uid; + // uid vorhanden? + if (strlen($this->uid)==0) { + $this->errormsg='uid nicht gesetzt'; + return false; + } + if (is_null($conn=$this->getConnection())) { + return false; + } + $sql_query="set datestyle to german;SELECT tbl_person.* ". + "FROM tbl_person ". + "WHERE uid='".addslashes($this->uid)."'"; + if(!($erg=pg_exec($conn, $sql_query))) { + $this->errormsg=pg_errormessage($conn); + return false; + } + $num_rows=pg_numrows($erg); + if($num_rows!=1) + { + $this->errormsg="Zuwenige oder zuviele Ergebnisse (Anzahl: $num_rows)!"; + return false; + } + $row=pg_fetch_object($erg,0); + + $this->titel=$row->titel; + $this->vornamen=$row->vornamen; + $this->nachname=$row->nachname; + $this->gebdatum=$row->gebdatum; + $this->gebort=$row->gebort; + $this->gebzeit=$row->gebzeit; + $this->foto=$row->foto; + $this->anmerkungen=$row->anmerkungen; + $this->aktiv=$row->aktiv=='t'?true:false; + $this->email=$row->email; + $this->alias=$row->alias; + $this->homepage=$row->homepage; + $this->updateamum=$row->updateamum; + $this->updatevon=$row->updatevon; + $this->new=false; + return true; + } + + /** + * Löscht die Person aus der Datenbank. Bei Fehler ist der Rueckgabewert 'false' + * und die Fehlermeldung steht in 'errormsg'. + * @return boolean true bei Erfolg, false bei Fehler + */ + function delete() + { + if (is_null($conn=$this->getConnection())) + { + return false; + } + $qry="delete from tbl_person where uid='".$this->uid."'"; + if(!($erg=pg_exec($conn, $sql_query))) + { + $this->errormsg=pg_errormessage($conn); + return false; + } + return true; + } + + + +} +?> \ No newline at end of file diff --git a/include/pgRS.class.php b/include/pgRS.class.php new file mode 100644 index 000000000..f8adfffea --- /dev/null +++ b/include/pgRS.class.php @@ -0,0 +1,62 @@ + + * date: 2004-06-26 + * date-modified: 2004-10-28 + * title: pgRS.class.php +*/ + +class pgRS +{ + var $arr = array(); + var $num = 0; + var $CONN = 0; + var $iid = 0; + + function pgRS($conn,$sql) + { + //echo $sql; + $this->CONN=$conn; + return $this->query($sql); + } + +/* function pgRS($sql, $dbname = "vilesci") { + if (!$this->CONN) + $this->CONN = ConnectDB($dbname); + return $this->query($sql); + } + + function pgRS($sql, $dbname = "vilesci", $user = "", $pw = "") + { + if (!$this->CONN) + $this->CONN = ConnectDB($dbname, $user, $pw); + return $this->query($sql); + } +*/ + function query($sql) + { + static $selects = 0; + //echo $sql; + $result = pg_exec($this->CONN, $sql); + if (strtolower(substr($sql,0,6))=="select") + { + $arr = array(); + ++$selects; + $row = 0; + if (($num = pg_numrows($result)) > 0) + $this->num = $num; + + while ($row < $this->num) + $arr[] = pg_fetch_array($result,$row++, + PGSQL_ASSOC); + + $this->arr = $arr; + + } + //else if (strtolower(substr($sql,0,6))=="insert"){ + $this->iid = pg_last_oid($result); + //} + } +} + +?> diff --git a/include/raumtyp.class.php b/include/raumtyp.class.php new file mode 100644 index 000000000..4fcb26ebf --- /dev/null +++ b/include/raumtyp.class.php @@ -0,0 +1,69 @@ +conn = $conn; + } + + + /** + * Alle Raumtypen zurückgeben + * @return array mit Raumtypen oder false=fehler + */ + function getAll() + { + if (is_null($this->conn)) + { + return false; + } + $qry = "select raumtyp_kurzbz,beschreibung from tbl_raumtyp order by raumtyp_kurzbz"; + //echo $qry; + if (!($erg = pg_exec($this->conn, $qry))) + { + $this->errormsg = pg_errormessage($this->conn); + return false; + } + $result = array(); + $num_rows = pg_numrows($erg); + for ($i = 0; $i < $num_rows; $i ++) + { + // Record holen + $row = pg_fetch_object($erg, $i); + // Instanz erzeugen + $rt = new raumtyp($this->conn); + $rt->kurzbz = $row->raumtyp_kurzbz; + $rt->beschreibung = $row->beschreibung; + // in array speichern + $result[] = $rt; + } + return $result; + } + + function test() + { + $bla= new test(); + } +} +?> \ No newline at end of file diff --git a/include/reservierung.class.php b/include/reservierung.class.php new file mode 100644 index 000000000..0a4e96758 --- /dev/null +++ b/include/reservierung.class.php @@ -0,0 +1,354 @@ +conn = $conn; + if (strlen($id)>0) { + $this->id=$id; + $this->load(); + } + } + + /** + * Verbindung zur Datenbank herstellen + * @return PostgreSQL-Connection oder NULL + + function getConnection() { + if (!$conn = @pg_pconnect(CONN_STRING)) { + $this->errormsg="Es konnte keine Verbindung zum Server ". + "aufgebaut werden."; + return null; + } + return $conn; + } */ + + function load($id='') + { + if (is_null($this->conn)) + { + return false; + } + $sql_query="select * from tbl_reservierung where reservierung_id=".$this->id; + if(!($erg=@pg_exec($this->conn, $sql_query))) { + $this->errormsg=pg_errormessage($this->conn); + return false; + } + $num_rows=pg_numrows($erg); + if($num_rows!=1) { + $this->errormsg="Zuwenige oder zuviele Ergebnisse (Anzahl: $num_rows)!"; + return false; + } + $row=pg_fetch_object($erg,0); + + $this->new=false; + $this->id=$row->reservierung_id; + $this->ort_kurzbz=$row->ort_kurzbz; + $this->studiengang_kz=$row->studiengang_kz; + $this->uid=$row->uid; + $this->stunde=$row->stunde; + $this->datum=$this->unixDate($row->datum); + $this->titel=$row->titel; + $this->beschreibung=$row->beschreibung; + $this->semester=$row->semester; + $this->verband=$row->verband; + $this->gruppe=$row->gruppe; + $this->einheit_kurzbz=$row->einheit_kurzbz; + return true; + } + + function save() + { + if (is_null($this->conn)) + { + return false; + } + if ($this->new) + { + // Kollision-Check + $r=$this->exists($this->datum,$this->stunde,$this->ort_kurzbz); + if ($r!==false) + { + $this->errormsg("Kollision mit bereits bestehender Reservierung: ".$r->titel." (".$r->uid.")"); + return false; + } + // Stundenplan-Kollision? + $kollisionen=$this->collisionStundenplan($this->datum,$this->stunde,$this->ort_kurzbz); + if ($kollisionen>0) + { + $this->errormsg="Kollisionen mit Stundenplan: $kollisionen"; + return false; + } + $qry="insert into tbl_reservierung(ort_kurzbz,studiengang_kz,uid,stunde,datum,titel,beschreibung,semester,verband,gruppe,einheit_kurzbz)". + "values('".$this->ort_kurzbz."',". + $this->studiengang_kz.",'". + $this->uid."',".$this->stunde.",'". + date("d.m.Y",$this->datum)."','". + $this->titel."','".$this->beschreibung."',". + (ctype_digit($this->semester)?$this->semester:'NULL').",". + (strlen($this->verband)>0?"'".$this->verband."'":'NULL').",". + (strlen($this->gruppe)>0?"'".$this->gruppe."'":'NULL').",". + (strlen($this->einheit_kurzbz)>0?"'".$this->einheit_kurzbz."'":'NULL'). + ")"; + } else + { + $qry="update tbl_reservierung set ". + "ort_kurzbz='".$this->ort_kurzbz."',". + "studiengang_kz='".$this->studiengang_kz."',". + "uid='".$this->uid."',". + "stunde=".$this->stunde.",". + "datum='".date("d.m.Y",$this->datum)."',". + "titel='".$this->titel."',". + "beschreibung='".$this->beschreibung."',". + "semester=".(ctype_digit($this->semester)?$this->semester:'NULL').",". + "verband=".(strlen($this->verband)>0?"'".$this->verband."'":'NULL').",". + "gruppe=".(strlen($this->gruppe)>0?"'".$this->gruppe."'":'NULL').",". + "einheit_kurzbz=".(strlen($this->einheit_kurzbz)>0?"'".$this->einheit_kurzbz."'":'NULL'). + "WHERE reservierung_id=".$this->reservierung_id; + + } + $qry="set datestyle to german;".$qry; + //echo $qry; + if(!($erg=pg_exec($this->conn, $qry))) + { + $this->errormsg=pg_errormessage($this->conn); + return false; + } + return true; + } + + /** + * Überprüfen ob eine Kollision mit dem Stundenplan besteht + * @param integer $datum datum im unix-format + * @param integer $stunde id der stunde + * @param string $ort_kurzbz ort-ID + * @return integer anzahl der Kollisionen, -1 bei fehler + */ + function collisionStundenplan($datum,$stunde,$ort_kurzbz) + { + if (is_null($this->conn)) { + return -1; + } + $qry="SELECT uid, lehrfach_nr, studiengang_kz, stundenplan_id, unr, datum, stunde, ort_kurzbz, semester, verband, gruppe, einheit_kurzbz, titel, anmerkung, fix, stg_kurzbz, stg_kurzbzlang, stg_bezeichnung, fachbereich_id, lehrfach, farbe, lehrform, aktiv, lektor, fixangestellt ". + "FROM vw_stundenplan ". + "WHERE datum='".date('d.m.Y',$datum)."' ". + "AND stunde=".$stunde." ". + "AND ort_kurzbz='".$ort_kurzbz."' ". + "order by semester,verband,gruppe"; + if(!($erg=pg_exec($this->conn, $qry))) + { + $this->errormsg=pg_errormessage($this->conn); + return -1; + } + $num_rows=pg_numrows($erg); + return $num_rows; + } + + /** + * Überprüfen, ob bereits eine Reservierung existiert + * @param integer $datum datum im unix-format + * @param integer $stunde id der stunde + * @param string $ort_kurzbz ort-ID + * @return reservierung reservierung die bereits existiert + */ + function exists($datum,$stunde,$ort_kurzbz) + { + if (is_null($this->conn)) { + return false; + } + $qry="SELECT reservierung_id from tbl_reservierung ". + "WHERE datum='".date('d.m.Y',$datum)."' ". + "AND stunde=".$stunde." ". + "AND ort_kurzbz='".$ort_kurzbz."' ". + "ORDER BY semester,verband,gruppe"; + if(!($erg=pg_exec($this->conn, $qry))) + { + $this->errormsg=pg_errormessage($this->conn); + return false; + } + $num_rows=pg_numrows($erg); + $row=pg_fetch_object($erg,0); + $id=$row->reservierung_id; + $r=new reservierung($id); + // bereits vorhandene reservierung zurückgeben + if ($r!==false) return $r; + // reservierung konnte nicht geladen werden + $this->errormsg='Reservierung konnte nicht geladen werden'; + return false; + } + + + + /** + * reservierung löschen + */ + function delete() + { + if (is_null($conn=$this->getConnection())) { + return false; + } + $sql_query="DELETE FROM tbl_reservierung WHERE reservierung_id=".$this->id; + $result=pg_exec($this->conn, $sql_query); + $num_rows=pg_numrows($result); + if ($result) + { + print_r($result); + return true; + } + $this->errormsg=pg_errormessage($this->conn); + return false; + } + + /** + * Alle mehrfach Reservierungen holen + * @return array(datum,stunde,ort) + */ + function getAllMehrfach() + { + if (is_null($this->conn)) + { + return false; + } + $sql_query="set datestyle to german;". + "SELECT count(reservierung_id), datum, stunde, ort_kurzbz ". + "FROM tbl_reservierung GROUP BY datum, stunde, ort_kurzbz ". + "HAVING (count(reservierung_id)>1) ". + "ORDER BY datum, stunde, ort_kurzbz"; + if(!($erg=@pg_exec($this->conn, $sql_query))) { + $this->errormsg=pg_errormessage($this->conn); + return false; + } + $num_rows=pg_numrows($erg); + $result=array(); + for($i=0;$i<$num_rows;$i++) + { + $row=pg_fetch_object($erg,$i); + $result[]=array('datum'=>$this->unixDate($row->datum), + 'stunde'=>$row->stunde, + 'ort'=>$row->ort_kurzbz); + + } + return $result; + } + + /** + * mehrfach vorkommende Reservierungen laden + * @param string $datum + * @param integer $stunde + * @return array + */ + function getMehrfach($datum,$stunde,$ort_kurzbz) { + if (is_null($this->conn)) { + return false; + } + $sql_query="set datestyle to german;". + "SELECT tbl_reservierung.*, tbl_ort.ort_kurzbz AS ortkurzbz, tbl_mitarbeiter.kurzbz AS lektorkurzbz ". + "FROM tbl_reservierung, tbl_ort, tbl_person,tbl_mitarbeiter ". + "WHERE datum='$datum' AND tbl_reservierung.stunde=$stunde ". + "AND tbl_reservierung.ort_kurzbz='$ort_kurzbz' AND ". + "tbl_reservierung.ort_kurzbz=tbl_ort.ort_kurzbz ". + "AND tbl_person.uid=tbl_mitarbeiter.uid ". + "and tbl_mitarbeiter.lektor=true;"; + if(!($erg=@pg_exec($this->conn, $sql_query))) { + $this->errormsg=pg_errormessage($this->conn); + return false; + } + $num_rows=pg_numrows($erg); + $result=array(); + for($i=0;$i<$num_rows;$i++) + { + $row=pg_fetch_object($erg,$i); + $l=new reservierung(); + $l->new=false; + $l->id=$row->reservierung_id; + $l->ort_kurzbz=$row->ort_kurzbz; + $l->studiengang_kz=$row->studiengang_kz; + $l->uid=$row->uid; + $l->stunde=$row->stunde; + $l->datum=$this->unixDate($row->datum); + $l->titel=$row->titel; + $l->beschreibung=$row->beschreibung; + $l->semester=$row->semester; + $l->verband=$row->verband; + $l->gruppe=$row->gruppe; + $l->einheit_kurzbz=$row->einheit_kurzbz; + $result[]=$l; + } + return $result; + } + + function unixDate($date) + { + if (strlen($date)>0) + { + $_d1 = explode(".", $date); + $d1 = $_d1[0]; + $m1 = $_d1[1]; + $y1 = $_d1[2]; + $unixDate=mktime(0,0,0,$d1,$m1,$y1); + } else + { + return null; + } + return $unixDate; + } + +} + +?> \ No newline at end of file diff --git a/include/student.class.php b/include/student.class.php new file mode 100644 index 000000000..928d7b2c8 --- /dev/null +++ b/include/student.class.php @@ -0,0 +1,345 @@ +conn = $conn; + if (strlen($uid)>0) { + $this->uid=$uid; + $this->load(); + } + } + + + /** + * Speichert den Studenten in die Datenbank. Bei Fehler ist der Rueckgabewert + * 'false' und die Fehlermeldung steht in 'errormsg'. INSERT oder DELETE wird + * durch 'new' bestimmt. + * @return boolean true=ok, false=fehler + */ + function save() + { + // uid vorhanden? + if (strlen($this->uid)==0) { + $this->errormsg='uid nicht gesetzt.'; + return false; + } + // Connection holen + if (is_null($conn=person::getConnection())) { + return false; + } + // Daten zur Person speichern + + if (!person::save()) { + $this->errormsg.="
    Daten zur Person konnten nicht gespeichert werden."; + return false; + } + if ($this->new) { + $qry="INSERT INTO tbl_student(uid,studiengang_kz,matrikelnr,". + "semester,verband,gruppe,updateamum,updatevon)". + "values(". + "'".$this->uid."',". + (ctype_digit($this->studiengang_kz)?$this->studiengang_kz:'NULL').",". + "'".$this->matrikelnr."',". + (ctype_digit($this->semester)?$this->semester:'NULL').",". + "'".$this->verband."','".$this->gruppe."',". + "now(),'".$_SERVER['PHP_AUTH_USER']."'". + ")"; + } else + { + $qry="UPDATE tbl_student ". + "SET studiengang_kz=".$this->studiengang_kz.",". + "matrikelnr='".$this->matrikelnr."',". + "semester=".(ctype_digit($this->semester)?$this->semester:'NULL').",". + "verband='".$this->verband."',". + "gruppe='".$this->gruppe."',". + "updateamum=now(),updatevon='".$_SERVER['PHP_AUTH_USER']."' ". + "WHERE uid='".$this->uid."'"; + } + //echo "
    ".$qry; + if(!($erg=pg_exec($conn, $qry))) + { + $this->errormsg=pg_errormessage($conn); + return false; + } + return true; + } + + /** + * Ladet die Attribute des Studenten aus der Datenbank. Bei Fehler ist der + * Rueckgabewert 'false' und die Fehlermeldung steht in 'errormsg'. + * @return boolean true=ok, false=fehler + */ + function load($uid='') + { + // optional: uid setzen + if (strlen($uid)>0) + $this->uid=$uid; + // uid vorhanden? + if (strlen($this->uid)==0) { + $this->errormsg='uid nicht gesetzt.'; + return false; + } + // Connection holen + if (is_null($conn=person::getConnection())) { + return false; + } + // Daten zur Person laden + if (!person::load()) { + $this->errormsg.="
    Daten zur Person konnten nicht geladen werden."; + return false; + } + // Studentendaten holen + $sql_query="SELECT s.studiengang_kz,s.matrikelnr,s.semester,s.verband,s.gruppe ". + "FROM tbl_student as s ". + "WHERE uid='".$this->uid."'"; + $sql_query="set datestyle to german; + SELECT tbl_person.*, m.studiengang_kz,m.matrikelnr,m.semester,m.verband,m.gruppe, + tbl_studiengang.studiengang_kz,tbl_studiengang.bezeichnung + FROM tbl_person join tbl_student as m using(uid) join + tbl_studiengang on (m.studiengang_kz=tbl_studiengang.studiengang_kz) + WHERE uid='".$this->uid."'"; + if(!($erg=pg_exec($conn, $sql_query))) + die(pg_errormessage($conn)); + $num_rows=pg_numrows($erg); + if($num_rows!=1) + { + $this->errormsg="Zuwenige oder zuviele Ergebnisse (Anzahl: $num_rows)!"; + return false; + } + $row=pg_fetch_object($erg,0); + + $this->studiengang_kz=$row->studiengang_kz; + $this->matrikelnr=$row->matrikelnr; + $this->semester=$row->semester; + $this->verband=$row->verband; + $this->gruppe=$row->gruppe; + $this->uid=$row->uid; + $this->titel=$row->titel; + $this->vornamen=$row->vornamen; + $this->nachname=$row->nachname; + $this->gebdatum=$row->gebdatum; + $this->gebort=$row->gebort; + $this->gebzeit=$row->gebzeit; + $this->foto=$row->foto; + $this->anmerkungen=$row->anmerkungen; + $this->aktiv=$row->aktiv=='t'?true:false; + $this->email=$row->email; + $this->homepage=$row->homepage; + $this->updateamum=$row->updateamum; + $this->updatevon=$row->updatevon; + $this->stg_bezeichnung=$row->bezeichnung; + + // todo: einheit + + $result[]=$this; + return $result; + //return true; + } + + /** + * Loescht den Studenten aus der Datenbank. Bei Fehler ist der Rueckgabewert + * 'false' und die Fehlermeldung steht in 'errormsg'. + * @return boolean true=ok, false=fehler + */ + function delete() + { + return false; + } + + /** + * Rueckgabewert ist die Anzahl der Ergebnisse. Bei Fehler negativ und die + * Fehlermeldung liegt in errormsg. + * Wenn der Parameter stg_kz NULL ist tritt einheit_kurzbzb in Kraft. + * @param string $einheit_kurzbz Einheit + * @param string grp Gruppe + * @param string ver Verband + * @param integer sem Semester + * @param integer stg_kz Kennzahl des Studiengangs + * @return integer Anzahl der gefundenen Einträge; negativ bei Fehler + */ + function getStudents($einheit_kurzbz, $grp, $ver, $sem, $stg_kz) + { + if (is_null($conn=person::getConnection())) { + return false; + } + $join = ''; + $where = ''; + if (strlen($einheit_kurzbz)>0) + { + // einheit? + $join=" join tbl_einheitstudent on (m.uid=tbl_einheitstudent.uid) "; + $where=" tbl_einheitstudent.einheit_kurzbz='".$einheit_kurzbz."'"; + } else + { + if (strlen($grp)>0) + { + // Gruppe + $where.=(strlen($where)>0?' and ':'')." m.gruppe='".$grp."' "; + } + if (strlen($ver)>0) + { + // Verband + $where.=(strlen($where)>0?' and ':'')." m.verband='".$ver."' "; + } + if (strlen($sem)>0) + { + // Semester + $where.=(strlen($where)>0?' and ':'')." m.semester=".$sem." "; + } + if (strlen($stg_kz)>0) + { + // Studiengang + $where.=(strlen($where)>0?' and ':'')." m.studiengang_kz='".$stg_kz."' "; + } + } + + + $sql_query="set datestyle to german;SELECT tbl_person.*,". + "m.studiengang_kz,m.matrikelnr,m.semester,m.verband,m.gruppe, ". + "tbl_studiengang.studiengang_kz,tbl_studiengang.bezeichnung ". + "FROM tbl_person join tbl_student as m using(uid) join ". + "tbl_studiengang on (m.studiengang_kz=tbl_studiengang.studiengang_kz) $join ". + (strlen($where)>1?'WHERE '.$where:''). + "ORDER by upper(tbl_person.nachname),upper(tbl_person.vornamen)"; + //echo $sql_query; + if(!($erg=@pg_exec($conn, $sql_query))) { + $this->errormsg=pg_errormessage($conn); + return false; + } + $num_rows=pg_numrows($erg); + $result=array(); + for($i=0;$i<$num_rows;$i++) + { + $row=pg_fetch_object($erg,$i); + $l=new student($conn); + // Personendaten + $l->uid=$row->uid; + $l->titel=$row->titel; + $l->vornamen=$row->vornamen; + $l->nachname=$row->nachname; + $l->gebdatum=$row->gebdatum; + $l->gebort=$row->gebort; + $l->gebzeit=$row->gebzeit; + $l->foto=$row->foto; + $l->anmerkungen=$row->anmerkungen; + $l->aktiv=$row->aktiv=='t'?true:false; + $l->email=$row->email; + $l->homepage=$row->homepage; + $l->updateamum=(isset($row->updateamum)?$row->updateamum:''); + $l->updatevon=(isset($row->updatevon)?$row->updatevon:''); + // Studentendaten + $l->matrikelnr=$row->matrikelnr; + $l->gruppe=$row->gruppe; + $l->verband=$row->verband; + $l->semester=$row->semester; + $l->studiengang_kz=$row->studiengang_kz; + $l->stg_bezeichnung=$row->bezeichnung; + // student in Array speichern + $result[]=$l; + } + return $result; + } + + /** + * gibt array mit allen Studenten zurück + * @return array Studenten + */ + function getAll() { + if (is_null($conn=person::getConnection())) { + return false; + } + $sql_query="set datestyle to german;SELECT tbl_person.*,". + "m.matrikelnr,m.semester,m.verband,m.gruppe, ". + "tbl_studiengang.studiengang_kz,tbl_studiengang.bezeichnung ". + "FROM tbl_person join tbl_student as m using(uid) ". + " join tbl_studiengang on (m.studiengang_kz=tbl_studiengang.studiengang_kz) ". + "ORDER by upper(tbl_person.nachname),upper(tbl_person.vornamen)"; + //echo $sql_query; + if(!($erg=@pg_exec($conn, $sql_query))) { + $this->errormsg=pg_errormessage($conn); + return false; + } + $num_rows=pg_numrows($erg); + $result=array(); + for($i=0;$i<$num_rows;$i++) + { + $row=pg_fetch_object($erg,$i); + $l=new student($conn); + // Personendaten + $l->uid=$row->uid; + $l->titel=$row->titel; + $l->vornamen=$row->vornamen; + $l->nachname=$row->nachname; + $l->gebdatum=$row->gebdatum; + $l->gebort=$row->gebort; + $l->gebzeit=$row->gebzeit; + $l->foto=$row->foto; + $l->anmerkungen=$row->anmerkungen; + $l->aktiv=$row->aktiv=='t'?true:false; + $l->email=$row->email; + $l->homepage=$row->homepage; + $l->updateamum=$row->updateamum; + $l->updatevon=$row->updatevon; + // Studentendaten + $l->matrikelnummer=$row->matrikelnummer; + $l->gruppe=$row->gruppe; + $l->verband=$row->verband; + $l->semester=$row->semester; + $l->studiengang_kz=$row->studiengang_kz; + $l->stg_bezeichnung=$row->bezeichnung; + // student in Array speichern + $result[]=$l; + } + return $result; + } + + + + +} + +?> \ No newline at end of file diff --git a/include/studiengang.class.php b/include/studiengang.class.php new file mode 100644 index 000000000..e0b63b912 --- /dev/null +++ b/include/studiengang.class.php @@ -0,0 +1,152 @@ +conn = $conn; + } + + /** + * Verbindung zur Datenbank herstellen + * @return PostgreSQL-Connection oder NULL + + function getConnection() + { + if (!$conn = @pg_pconnect(CONN_STRING)) { + $this->errormsg="Es konnte keine Verbindung zum Server ". + "aufgebaut werden."; + return null; + } + return $conn; + }*/ + + + /** + * @return array Array mit allen Studiengängen, oder false bei Fehler + */ + function getAll($order='kurzbz') + { + if (is_null($this->conn)) { + $this->errormsg = "Connection failed"; + return false; + } + $qry="select * from tbl_studiengang order by $order"; + if(!($erg=pg_exec($this->conn, $qry))) + { + $this->errormsg=pg_errormessage($this->conn); + return false; + } + $result=array(); + $num_rows=pg_numrows($erg); + for ($i=0;$i<$num_rows;$i++) + { + $row=pg_fetch_object($erg,$i); + $p=new studiengang($this->conn); + $p->studiengang_kz=$row->studiengang_kz; + $p->kurzbz=$row->kurzbz; + $p->kurzbzlang=$row->kurzbzlang; + $p->bezeichnung=$row->bezeichnung; + $p->max_semester=$row->max_semester; + $p->typ=$row->typ; + $p->farbe=$row->farbe; + $p->email=$row->email; + $result[]=$p; + } + return $result; + } + + function load($stgkz) + { + if (is_null($this->conn)) { + $this->errormsg = "Connection failed"; + return false; + } + $qry="select * from tbl_studiengang where studiengang_kz=$stgkz"; + if(!($erg=pg_exec($this->conn, $qry))) + { + $this->errormsg=pg_errormessage($this->conn); + return false; + } + else + { + if(pg_num_rows($erg)>0) + { + $row=pg_fetch_object($erg); + $this->studiengang_kz = $row->studiengang_kz; + $this->kurzbz = $row->kurzbz; + $this->kurzbzlang = $row->kurzbzlang; + $this->bezeichnung = $row->bezeichnung; + $this->typ = $row->typ; + $this->farbe = $row->farbe; + $this->email = $row->email; + $this->max_semester = $row->max_semester; + $this->max_verband = $row->max_verband; + $this->max_gruppe = $row->max_gruppe; + return true; + } + else + { + $this->errormsg = "Studiengang konnte nicht aufgeloest werden"; + return false; + } + } + } + +} +?> \ No newline at end of file diff --git a/include/studiensemester.class.php b/include/studiensemester.class.php new file mode 100644 index 000000000..38302fa80 --- /dev/null +++ b/include/studiensemester.class.php @@ -0,0 +1,154 @@ +conn=$conn; + } + + /** + * Verbindung zur Datenbank herstellen + * @return PostgreSQL-Connection oder NULL + + function getConnection() + { + if (!$conn = @ pg_pconnect(CONN_STRING)) + { + $this->errormsg = "Es konnte keine Verbindung zum Server "."aufgebaut werden."; + return null; + } + return $conn; + }*/ + + function load() + { + + } + + /** + * Alle Studiensemester zurückgeben + * @return array mit Studiensemester oder false=fehler + */ + function getAll($order='studiensemester_kurzbz') + { + if (is_null($this->conn)) + { + return false; + } + $qry = "select * from tbl_studiensemester ". + "order by $order"; + //echo $qry; + if (!($erg = pg_exec($this->conn, $qry))) + { + $this->errormsg = pg_errormessage($this->conn); + return false; + } + $result = array(); + $num_rows = pg_numrows($erg); + for ($i = 0; $i < $num_rows; $i ++) + { + // Record holen + $row = pg_fetch_object($erg, $i); + // Instanz erzeugen + $lf = new studiensemester($this->conn); + $lf->kurzbz = $row->studiensemester_kurzbz; + $lf->start = $row->start; + $lf->ende = $row->ende; + // in array speichern + $result[] = $lf; + } + return $result; + } + + /** + * Liefert das Aktuelle Studiensemester + * @return aktuelles Studiensemester oder false wenn es keines gibt + */ + function getakt() + { + $qry = "Select studiensemester_kurzbz from tbl_studiensemester where start <= now() and ende >= now()"; + if(!$res=pg_exec($this->conn,$qry)) + { + $this->errormsg = pg_errormessage($this->conn); + return false; + } + + if(pg_num_rows($res)>0) + { + $erg = pg_fetch_object($res); + return $erg->studiensemester_kurzbz; + } + else + { + $this->errormsg = "Kein aktuelles Studiensemester vorhanden"; + return false; + } + } + + /** + * Liefert das Aktuelle Studiensemester oder das darauffolgende + * @return Studiensemester oder false wenn es keines gibt + */ + function getaktorNext() + { + if($stsem=$this->getakt()) + return $stsem; + else + { + $qry = "Select studiensemester_kurzbz from tbl_studiensemester where ende >= now() ORDER BY ende"; + if(!$res=pg_exec($this->conn,$qry)) + { + $this->errormsg = pg_errormessage($this->conn); + return false; + } + + if(pg_num_rows($res)>0) + { + $erg = pg_fetch_object($res); + return $erg->studiensemester_kurzbz; + } + else + { + $this->errormsg = "Kein aktuelles Studiensemester vorhanden"; + return false; + } + } + } + + function save() + { + + } + + function delete() + { + + } + +} +?> \ No newline at end of file diff --git a/include/stundenplan.class.php b/include/stundenplan.class.php new file mode 100644 index 000000000..58973d83a --- /dev/null +++ b/include/stundenplan.class.php @@ -0,0 +1,1567 @@ +type=$type; + $this->conn=$conn; + $this->link='stpl_week.php?type='.$type; + $this->kal_link='stpl_kalender.php?type='.$type; + $this->datum=mktime(); + $this->init_stdplan(); + } + + function init_stdplan() + { + //Stundenplan Array initialisieren (Anzahl auf 0 setzten) + unset($this->std_plan); + for ($i=1; $i<7; $i++) + for ($j=0; $j<20; $j++) + { + $this->std_plan[$i][$j][0]->anz=0; + $this->std_plan[$i][$j][0]->unr=0; + } + } + + /************************************************************************** + * @brief Funktion load_data ladet alle Zusatzinformationen fuer die Darstellung + * und ueberprueft die Daten + * + * @param datum Datum eines Tages in der angeforderten Woche + * + * @return einheit_kurzbz + * + */ + function load_data($type, $uid, $ort_kurzbz=NULL, $studiengang_kz=NULL, $sem=NULL, $ver=NULL, $grp=NULL, $einheit_kurzbz=NULL) + { + /////////////////////////////////////////////////////////////////////// + // Parameter Checken + // Typ des Stundenplans + if ($type=='student' || $type=='lektor' || $type=='verband' || $type=='einheit' || $type=='ort') + $this->type=$type; + else + { + $this->errormsg='Error: type is not defined!'; + return false; + } + // Person + if (($type=='student' || $type=='lektor') && ($uid==NULL || $uid=='')) + { + $this->errormsg='Fehler: uid der Person ist nicht gesetzt'; + return false; + } + else + $this->pers_uid=$uid; + + // Ort + if ($type=='ort' && $ort_kurzbz==NULL) + { + $this->errormsg='Fehler: Kurzbezeichnung des Orts ist nicht gesetzt'; + return false; + } + elseif ($type=='ort') + $this->ort_kurzbz=$ort_kurzbz; + else + $this->ort_kurzbz=''; + + // Lehrverband + if ($type=='verband' && $studiengang_kz==NULL) + { + $this->errormsg='Fehler: Kennzahl des Studiengangs ist nicht gesetzt'; + return false; + } + elseif($type=='verband') + { + $this->stg_kz=$studiengang_kz; + $this->sem=$sem; + $this->ver=$ver; + $this->grp=$grp; + } + + // Einheit + if ($type=='einheit' && $einheit_kurzbz==NULL) + { + $this->errormsg='Fehler: Kurzbezeichnung der Einheit ist nicht gesetzt'; + return false; + } + elseif ($type=='einheit') + $this->einheit_kurzbz=$einheit_kurzbz; + + + /////////////////////////////////////////////////////////////////////// + // Zusaetzliche Daten ermitteln + //personendaten + if ($this->type=='student' || $this->type=='lektor') + { + $this->link.='&pers_uid='.$this->pers_uid; //Link erweitern + if ($this->type=='student') + $sql_query="SELECT uid, titel, nachname, vornamen, studiengang_kz, semester, verband, gruppe FROM vw_student WHERE uid='$this->pers_uid'"; + else + $sql_query="SELECT uid, titel, nachname, vornamen FROM vw_lektor WHERE uid='$this->pers_uid'"; + //echo $sql_query; + if (!($result=pg_exec($this->conn, $sql_query))) + { + $this->errormsg=pg_last_error($this->conn); + return false; + } + if (pg_num_rows($result)!=1) + { + $this->errormsg='Error: Cannot identify UID "'.$this->pers_uid.'"!'; + return false; + } + $this->pers_uid=pg_result($result,0,'"uid"'); + $this->pers_titel=pg_result($result,0,'"titel"'); + $this->pers_nachname=pg_result($result,0,'"nachname"'); + $this->pers_vornamen=pg_result($result,0,'"vornamen"'); + if ($this->type=='student') + { + $this->stg_kz=pg_result($result,0,'"studiengang_kz"'); + $this->sem=pg_result($result,0,'"semester"'); + $this->ver=pg_result($result,0,'"verband"'); + $this->grp=pg_result($result,0,'"gruppe"'); + } + } + + //ortdaten ermitteln + if ($this->type=='ort') + { + $sql_query="SELECT bezeichnung, ort_kurzbz FROM tbl_ort WHERE ort_kurzbz='$this->ort_kurzbz'"; + //echo $sql_query; + if (!$result=pg_query($this->conn, $sql_query)) + $this->errormsg=pg_last_error($this->conn); + $this->ort_bezeichnung=pg_result($result,0,'"bezeichnung"'); + $this->ort_kurzbz=pg_result($result,0,'"ort_kurzbz"'); + $this->link.='&ort_kurzbz='.$this->ort_kurzbz; //Link erweitern + } + + // Studiengangsdaten ermitteln + if ($this->type=='student' || $this->type=='verband') + { + $sql_query="SELECT bezeichnung, kurzbz, kurzbzlang FROM tbl_studiengang WHERE studiengang_kz=$this->stg_kz"; + //echo $sql_query; + if(!($result=pg_exec($this->conn, $sql_query))) + die(pg_last_error($this->conn)); + $this->stg_bez=pg_result($result,0,'"bezeichnung"'); + $this->stg_kurzbz=pg_result($result,0,'"kurzbz"'); + $this->stg_kurzbzlang=pg_result($result,0,'"kurzbzlang"'); + } + + // Stundentafel abfragen + $sql_query="SELECT stunde, beginn, ende FROM tbl_stunde ORDER BY stunde"; + if(!$this->stunde=pg_exec($this->conn, $sql_query)) + die(pg_last_error($this->conn)); + + // Studiensemesterdaten ermitteln + $sql_query="SELECT * FROM tbl_studiensemester WHERE now()conn, $sql_query)) + die(pg_last_error($this->conn)); + else + { + $row=pg_fetch_object($result); + $this->studiensemester_now->name=$row->studiensemester_kurzbz; + $this->studiensemester_now->start=mktime(0,0,0,substr($row->start,5,2),substr($row->start,8,2),substr($row->start,0,4)); + $this->studiensemester_now->ende=mktime(0,0,0,substr($row->ende,5,2),substr($row->ende,8,2),substr($row->ende,0,4)); + $row=pg_fetch_object($result); + $this->studiensemester_next->name=$row->studiensemester_kurzbz; + $this->studiensemester_next->start=mktime(0,0,0,substr($row->start,5,2),substr($row->start,8,2),substr($row->start,0,4)); + $this->studiensemester_next->ende=mktime(0,0,0,substr($row->ende,5,2),substr($row->ende,8,2),substr($row->ende,0,4)); + } + return true; + } + + /************************************************************************** + * @brief Funktion load_week ladet die Stundenplandaten einer Woche + * + * @param datum Datum eines Tages in der angeforderten Woche + * + * @return true oder false + * + */ + function load_week($datum, $stpl_view='stundenplan') + { + // Pruefung der Attribute + if (!isset($this->type)) + { + $this->errormsg='$type is not set in stundenplan.load_week!'; + return false; + } + + //Kalenderdaten setzen + $this->datum=montag($datum); + $this->datum_begin=$this->datum; + $this->datum_end=jump_week($this->datum_begin, 1); + $this->datum_nextweek=$this->datum_end; + $this->datum_prevweek=jump_week($this->datum_begin, -1); + $this->datum_next4week=jump_week($this->datum_begin, 4); + $this->datum_prev4week=jump_week($this->datum_begin, -4); + // Formatieren fuer Datenbankabfragen + $this->datum_begin=date("Y-m-d",$this->datum_begin); + $this->datum_end=date("Y-m-d",$this->datum_end); + $this->kalenderwoche=kalenderwoche($this->datum); + + // Stundenplandaten ermittlen + $this->wochenplan=new lehrstunde($this->conn); + $anz=$this->wochenplan->load_lehrstunden($this->type,$this->datum_begin,$this->datum_end,$this->pers_uid,$this->ort_kurzbz,$this->stg_kz,$this->sem,$this->ver,$this->grp,$this->einheit_kurzbz, $stpl_view); + if ($anz<0) + { + $this->errormsg=$this->wochenplan->errormsg; + return false; + } + + // Stundenplandaten aufbereiten + for($i=0;$i<$anz;$i++) + { + $idx=0; + $mtag=substr($this->wochenplan->lehrstunden[$i]->datum, 8,2); + $month=substr($this->wochenplan->lehrstunden[$i]->datum, 5,2); + $jahr=substr($this->wochenplan->lehrstunden[$i]->datum, 0,4); + $tag=date("w",mktime(12,0,0,$month,$mtag,$jahr)); + //echo $tag.':'.$this->wochenplan->lehrstunden[$i]->datum.'
    '; + $stunde=$this->wochenplan->lehrstunden[$i]->stunde; + // naechste freie Stelle im Array suchen + while (isset($this->std_plan[$tag][$stunde][$idx]->lektor_uid)) + $idx++; + //echo $idx.'
    '; + $this->std_plan[$tag][$stunde][$idx]->unr=$this->wochenplan->lehrstunden[$i]->unr; + if ($this->wochenplan->lehrstunden[$idx]->reservierung) + $this->std_plan[$tag][$stunde][$idx]->lehrfach=$this->wochenplan->lehrstunden[$i]->titel; + else + { + $this->std_plan[$tag][$stunde][$idx]->lehrfach=$this->wochenplan->lehrstunden[$i]->lehrfach; + $this->std_plan[$tag][$stunde][$idx]->lehrform=$this->wochenplan->lehrstunden[$i]->lehrform; + $this->std_plan[$tag][$stunde][$idx]->lehrfach_nr=$this->wochenplan->lehrstunden[$i]->lehrfach_nr; + $this->std_plan[$tag][$stunde][$idx]->farbe=$this->wochenplan->lehrstunden[$i]->farbe; + $this->std_plan[$tag][$stunde][$idx]->titel=$this->wochenplan->lehrstunden[$i]->titel; + } + $this->std_plan[$tag][$stunde][$idx]->stundenplan_id=$this->wochenplan->lehrstunden[$i]->stundenplan_id; + $this->std_plan[$tag][$stunde][$idx]->lektor_uid=$this->wochenplan->lehrstunden[$i]->lektor_uid; + $this->std_plan[$tag][$stunde][$idx]->lektor=$this->wochenplan->lehrstunden[$i]->lektor_kurzbz; + $this->std_plan[$tag][$stunde][$idx]->ort=$this->wochenplan->lehrstunden[$i]->ort_kurzbz; + $this->std_plan[$tag][$stunde][$idx]->stg=$this->wochenplan->lehrstunden[$i]->studiengang; + $this->std_plan[$tag][$stunde][$idx]->stg_kz=$this->wochenplan->lehrstunden[$i]->studiengang_kz; + $this->std_plan[$tag][$stunde][$idx]->sem=$this->wochenplan->lehrstunden[$i]->sem; + $this->std_plan[$tag][$stunde][$idx]->ver=$this->wochenplan->lehrstunden[$i]->ver; + $this->std_plan[$tag][$stunde][$idx]->grp=$this->wochenplan->lehrstunden[$i]->grp; + $this->std_plan[$tag][$stunde][$idx]->einheit_kurzbz=$this->wochenplan->lehrstunden[$i]->einheit_kurzbz; + $this->std_plan[$tag][$stunde][$idx]->anmerkung=$this->wochenplan->lehrstunden[$i]->anmerkung; + $this->std_plan[$tag][$stunde][$idx]->updateamum=$this->wochenplan->lehrstunden[$i]->updateamum; + $this->std_plan[$tag][$stunde][$idx]->updatevon=$this->wochenplan->lehrstunden[$i]->updatevon; + //echo $tag.' '.$stunde.' '.$this->std_plan[$tag][$stunde][$idx]->lektor_uid.'
    '; + } + unset($this->wochenplan); + return true; + } + + function draw_header() + { + echo ''; + echo ''; + echo ''; + + // Kalenderjump + echo ''; + echo ''; + echo '

    '; + if ($this->type=='student' || $this->type=='lektor') + echo 'Person: '.$this->pers_titel.' '.$this->pers_vornamen.' '.$this->pers_nachname.' - '.$this->pers_uid.'
    '; + if ($this->type=='student' || $this->type=='verband') + { + echo 'Studiengang: '.$this->stg_kurzbzlang.' - '.$this->stg_bez.'
    '; + echo 'Semester: '.$this->sem.'
    '; + if ($this->ver!='0' && $this->ver!='' && $this->ver!=null) + echo 'Verband: '.$this->ver.'
    '; + if ($this->grp!='0' && $this->grp!='' && $this->grp!=null) + echo 'Gruppe: '.$this->grp.'
    '; + $this->link.='&stg_kz='.$this->stg_kz.'&sem='.$this->sem.'&ver='.$this->ver.'&grp='.$this->grp; + } + if ($this->type=='ort') + echo 'Ort: '.$this->ort_kurzbz.' - '.$this->ort_bezeichnung.'
    '; + echo '

    '; + + //Kalender + $this->kal_link.='&pers_uid='.$this->pers_uid.'&ort_kurzbz='.$this->ort_kurzbz.'&stg_kz='.$this->stg_kz.'&sem='.$this->sem.'&ver='.$this->ver.'&grp='.$this->grp.'&einheit_kurzbz='.$this->einheit_kurzbz; + //global $kalender_begin_ws, $kalender_ende_ws, $kalender_begin_ss, $kalender_ende_ss; + $kal_link_ws=$this->kal_link.'&begin='.$this->studiensemester_now->start.'&ende='.$this->studiensemester_now->ende; + $kal_link_ss=$this->kal_link.'&begin='.$this->studiensemester_next->start.'&ende='.$this->studiensemester_next->ende; + echo '       Kalender:    '; + echo ''.$this->studiensemester_now->name.' '; + echo ' + HTML'; + echo ' + CSV'; + echo ' + CSV-Outlook'; + echo ' + vCal Version 1.0'; + echo ' + vCal Version 2.0'; + echo '    '.$this->studiensemester_next->name.' '; + echo ' + HTML'; + echo ' + CSV'; + echo ' + CSV-Outlook'; + echo ' + iCal Version 1.0'; + echo ' + iCal Version 2.0'; + echo '
    '; + jahreskalenderjump($this->link); + echo '

    '; + + // Jump Wochenweise + if ($this->type=='verband') + $link_parameter='&stg_kz='.$this->stg_kz.'&sem='.$this->sem.'&ver='.$this->ver.'&grp='.$this->grp; + if ($this->type=='student' || $this->type=='lektor') + $link_parameter='&pers_uid='.$this->pers_uid; + + // Ort Jump + if ($this->type=='ort') + { + // Orte abfragen + $sql_query="SELECT * FROM tbl_ort WHERE aktiv AND lehre ORDER BY ort_kurzbz"; + if(!$result_ort=pg_exec($this->conn, $sql_query)) + die(pg_last_error($this->conn)); + $num_rows_ort=pg_numrows($result_ort); + + // vorigen Ort bestimmen + for ($i=0;$i<($num_rows_ort-1);$i++) + if (pg_result($result_ort,$i+1,'"ort_kurzbz"')==$this->ort_kurzbz) + $prev_ort=pg_fetch_object($result_ort,$i); + // naechsten Ort bestimmen + for ($i=1;$i<$num_rows_ort;$i++) + if (pg_result($result_ort,$i-1,'"ort_kurzbz"')==$this->ort_kurzbz) + $next_ort=pg_fetch_object($result_ort,$i); + + // Ort Jump + echo '

    '; + //$datum=mktime($this->datum[hours], $this->datum[minutes], $this->datum[seconds], $this->datum[mon], $this->datum[mday], $this->datum[year]); + if (isset($prev_ort)) + { + echo ''; + } + echo "'; + if (isset($next_ort)) + { + echo ''; + } + echo '

    '; + $link_parameter='&ort_kurzbz='.$this->ort_kurzbz; + } + echo '

    '; + // 4 Wochen zurueck + echo ''; + // 1 Woche zurueck + echo ' KW '.$this->kalenderwoche; + // 1 Woche nach vor + echo ''; + // 4 Wochen nach vor + echo ''; + echo '

    '; + return true; + } + + /************************************************************************** + * Zeichnen der Stundenplanwoche in HTML + */ + function draw_week($user_uid='pam') + { + // Stundentafel abfragen + $sql_query="SELECT stunde, beginn, ende FROM tbl_stunde ORDER BY stunde"; + if(!$result_stunde=pg_exec($this->conn, $sql_query)) + die(pg_last_error($this->conn)); + $num_rows_stunde=pg_numrows($result_stunde); + + // Formularbeginn wenn Lektor + if ($this->user=='lektor' && $this->type=='ort') + echo ''; + + //Tabelle zeichnen + echo ''; + // Kopfzeile darstellen + echo ''; + echo ''; + for ($i=0;$i<$num_rows_stunde; $i++) + { + $beginn=pg_result($result_stunde,$i,'"beginn"'); + $beginn=substr($beginn,0,5); + $ende=pg_result($result_stunde,$i,'"ende"'); + $ende=substr($ende,0,5); + $stunde=pg_result($result_stunde,$i,'"stunde"'); + echo ''; + } + echo ''; + // Von Montag bis Samstag + $datum_now=mktime(); + $datum_res_lektor_start=jump_day($datum_now,RES_TAGE_LEKTOR_MIN); + $datum_res_lektor_ende=jump_day($datum_now,RES_TAGE_LEKTOR_MAX); + if (!date("w",$this->datum)) + $this->datum=jump_day($this->datum,1); + $datum=$this->datum; + for ($i=1; $i<7; $i++) + { + echo ''; //.strftime("%A %d %B %Y",$this->datum) + for ($k=0; $k<$num_rows_stunde; $k++) + { + $j=pg_result($result_stunde,$k,'"stunde"'); + // Stunde aufbereiten + if (isset($this->std_plan[$i][$j][0]->lehrfach)) + { + // Anzahl der Felder + + // Daten aufbereiten + $kollision=-1; + unset($unr); + unset($lektor); + unset($lehrverband); + unset($lehrfach); + foreach ($this->std_plan[$i][$j] as $lehrstunde) + { + $unr[]=$lehrstunde->unr; + // Lektoren + $lektor[]=$lehrstunde->lektor; + // Lehrverband + $lvb=$lehrstunde->stg.'-'.$lehrstunde->sem; + if ($lehrstunde->ver!=null && $lehrstunde->ver!='0' && $lehrstunde->ver!='') + { + $lvb.=$lehrstunde->ver; + if ($lehrstunde->grp!=null && $lehrstunde->grp!='0' && $lehrstunde->grp!='') + $lvb.=$lehrstunde->grp; + } + if (count($lehrstunde->einheit_kurzbz)>0) + $lvb=$lehrstunde->einheit_kurzbz; + $lehrverband[]=$lvb; + // Lehrfach + $lf=$lehrstunde->lehrfach; + if (isset($lehrstunde->lehrform)) + $lf.='-'.$lehrstunde->lehrform; + $lehrfach[]=$lf; + $titel=$lehrstunde->titel; + $anmerkung=$lehrstunde->anmerkung; + } + + + // Unterrichtsnummer (Kollision?) + $unr=array_unique($unr); + $kollision+=count($unr); + + // Lektoren + if ($this->type!='lektor') + { + $lektor=array_unique($lektor); + sort($lektor); + $lkt=''; + foreach ($lektor as $l) + $lkt.=$l.'
    '; + } + else + $lkt=$lektor[0].'
    '; + //echo $lkt; + + // Lehrverband + if ($this->type!='verband') + { + $lehrverband=array_unique($lehrverband); + sort($lehrverband); + $lvb=''; + foreach ($lehrverband as $l) + $lvb.=$l.'
    '; + } + else + $lvb=$lehrverband[0].'
    '; + + // Lehrfach + if ($this->type=='verband') + { + $lehrfach=array_unique($lehrfach); + sort($lehrfach); + $lf=''; + foreach ($lehrfach as $l) + $lf.=$l.'
    '; + } + else + $lf=$lehrfach[0].'
    '; + + //$lkt=$this->std_plan[$i][$j][0]->lektor.'
    '; + //$lvb=$this->std_plan[$i][$j][0]->stg.'-'.$this->std_plan[$i][$j][0]->sem.$this->std_plan[$i][$j][0]->ver.$this->std_plan[$i][$j][0]->grp.'
    '; + + + // Blinken oder nicht ? + if ($kollision) + { + $blink_ein=''.$kollision; + $blink_aus=''; + } + else + { + $blink_ein=''; + $blink_aus=''; + } + + // Ausgabe einer Stunde im Raster (HTML) + echo ''; + } + else + { + echo ''; + } + } + echo ""; + $datum=jump_day($datum, 1); + } + echo '
    Stunde 
    Beginn 
    Ende 
    '.$stunde.'
     '.$beginn .' 
     '.$ende.' 
    '.date("l",$datum).'
    '.date("j. M y",$datum).'
    std_plan[$i][$j][0]->farbe)) + echo 'style="background-color: #'.$this->std_plan[$i][$j][0]->farbe.';"'; + echo '>'.$blink_ein.''.$blink_aus.'
    '; + if ($this->user=='lektor' && $this->type=='ort' && (($datum>$datum_res_lektor_start && $datum<=$datum_res_lektor_ende) || $user_uid=='wagner')) + echo ''; //&& $datum>=$datum_now + echo '
    '; + if ($this->user=='lektor' && $this->type=='ort' && (($datum>=$datum_now && $datum>$datum_res_lektor_start && $datum<=$datum_res_lektor_ende) || $user_uid=='wagner' )) + { + echo '
    Titel: '; + echo ' Beschreibung: '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo ' '; + echo '
    '; + } + } + + /************************************************************************** + * @brief Funktion draw_week_xul Stundenplan im XUL-Format + * + * @param datum Datum eines Tages in der angeforderten Woche + * + * @return true oder false + * + */ + function draw_week_xul($semesterplan,$uid, $wunsch=null) + { + echo $wunsch; + global $cfgStdBgcolor; + $count=0; + $berechtigung=new berechtigung($this->conn); + $berechtigung->getBerechtigungen($uid); + // Stundentafel abfragen + $sql_query="SELECT * FROM tbl_stunde ORDER BY stunde"; + if(!$result_stunde=pg_query($this->conn, $sql_query)) + $this->errormsg=pg_last_error($this->conn); + $num_rows_stunde=pg_numrows($result_stunde); + + // Kontext Menue + echo ' + + + + + '; + + //Tabelle zeichnen + echo ''; + echo ''; + echo ' '; + for ($i=0;$i<$num_rows_stunde; $i++) + echo ' '; + echo ''; + echo ''; + + // Kopfzeile darstellen + echo ''.$this->crlf; + echo ' + + + '.$this->crlf; //BeginnEnde + for ($i=0;$i<$num_rows_stunde; $i++) + { + $row=pg_fetch_object($result_stunde,$i); + $beginn=substr($row->beginn,0,5); + $ende=substr($row->ende,0,5); + $stunde=$row->stunde; + echo ' + '.$this->crlf; + } + echo ''; + + // Von Montag bis Samstag + if (!date("w",$this->datum)) + $this->datum=jump_day($this->datum,1); + $datum=$this->datum; + + // Ferien holen + $ferien=new ferien($this->conn); + if ($this->type=='verband') + $ferien->getAll($this->stg_kz); + else + $ferien->getAll(0); + for ($i=1; $i<7; $i++) + { + $isferien=$ferien->isferien($datum); + echo ''; + echo ''.date("l",$datum).''.date("j.m y",$datum).''; + echo ''; + for ($k=0; $k<$num_rows_stunde; $k++) + { + $j=pg_result($result_stunde,$k,'"stunde"'); + if (isset($wunsch[$i][$j])) + $index=$wunsch[$i][$j]; + else + $index=1; + if ($index=='') + $index=1; + $bgcolor=$cfgStdBgcolor[$index+3]; + if ($isferien) + $bgcolor='#FFFF55'; + echo ''; + + if (isset($this->std_plan[$i][$j][0]->lehrfach)) + { + // Daten aufbereiten + $kollision=-1; + unset($a_unr); + foreach ($this->std_plan[$i][$j] as $lehrstunde) + { + $a_unr[]=$lehrstunde->unr; + $a_lvb[$lehrstunde->unr][]=$lehrstunde->sem.$lehrstunde->ver.$lehrstunde->grp; + } + // Unterrichtsnummer (Kollision?) + $a_unr=array_unique($a_unr); + $kollision+=count($a_unr); + // Ist es bei LVB-Ansicht wirklich eine Kollision? + if ($kollision>0 && $this->type=='verband') + { + $kollision=0; + $a=0; + foreach ($a_unr as $unr) + { + array_unique($a_lvb[$unr]); + $lvb[$a++]=$a_lvb[$unr]; + } + for ($a=0;$astd_plan[$i][$j] as $lehrstunde) + if ($lehrstunde->unr==$unr) + { + // Lektoren + $lektor[]=$lehrstunde->lektor; + // Lehrverband + $lvb=$lehrstunde->stg.'-'.$lehrstunde->sem; + if ($lehrstunde->ver!=null && $lehrstunde->ver!='0' && $lehrstunde->ver!='') + { + $lvb.=$lehrstunde->ver; + if ($lehrstunde->grp!=null && $lehrstunde->grp!='0' && $lehrstunde->grp!='') + $lvb.=$lehrstunde->grp; + } + if (count($lehrstunde->einheit_kurzbz)>0) + $lvb=$lehrstunde->einheit_kurzbz; + $lehrverband[]=$lvb; + // Lehrfach + $lf=$lehrstunde->lehrfach; + if (isset($lehrstunde->lehrform)) + $lf.='-'.$lehrstunde->lehrform; + $lehrfach[]=$lf; + $ort[]=$lehrstunde->ort; + $stg_kz=$lehrstunde->stg_kz; + $updateamum[]=substr($lehrstunde->updateamum,0,16); + $updatevon[]=$lehrstunde->updatevon; + $paramList.='&stundenplan_id'.$z++.'='.$lehrstunde->stundenplan_id; + $farbe=$lehrstunde->farbe; + $titel=$lehrstunde->titel; + $anmerkung=$lehrstunde->anmerkung; + } + + // Lektoren + //if ($this->type!='lektor') + $lektor=array_unique($lektor); + sort($lektor); + $lkt=''; + foreach ($lektor as $l) + $lkt.=$l.''; + + // Lehrverband + //if ($this->type!='verband') + $lehrverband=array_unique($lehrverband); + sort($lehrverband); + $lvb=''; + foreach ($lehrverband as $l) + $lvb.=$l.''; + + // Lehrfach + //if ($this->type=='verband') + $lehrfach=array_unique($lehrfach); + sort($lehrfach); + $lf=''; + foreach ($lehrfach as $l) + $lf.=$l.''; + + // Ort + //if ($this->type=='verband') + $ort=array_unique($ort); + sort($ort); + $orte=''; + foreach ($ort as $o) + $orte.=$o.''; + + // Update Von + $updatevon=array_unique($updatevon); + sort($updatevon); + $updatevonam='Ge??ndert von '; + foreach ($updatevon as $u) + $updatevonam.=$u.', '; + + // Update Am + $updateamum=array_unique($updateamum); + sort($updateamum); + $updatevonam.='am '; + foreach ($updateamum as $u) + $updatevonam.=$u.' '; + //$updatevonam='Ge??ndert von '.$updatevon.', am '.$updateamum; + + // Blinken oder nicht ? + if ($kollision) + { + $blink_ein='';// .$kollision; + $blink_aus=''; + } + else + { + $blink_ein=''; + $blink_aus=''; + } + + // Ausgabe + echo ''; + } + } + if (isset($this->std_plan[$i][$j][0]->frei_orte)) + foreach ($this->std_plan[$i][$j][0]->frei_orte as $f_ort) + { + echo ''.$this->crlf; + } + echo ""; + $datum=jump_day($datum, 1); + } + + // Fuszzeile darstellen + if (!$semesterplan) + { + echo ''.$this->crlf; + echo ' + + + '.$this->crlf; //BeginnEnde + for ($i=0;$i<$num_rows_stunde; $i++) + { + $row=pg_fetch_object($result_stunde,$i); + $beginn=substr($row->beginn,0,5); + $ende=substr($row->ende,0,5); + $stunde=$row->stunde; + echo ' + '.$this->crlf; + } + echo ''; + } + echo ''; + echo ''; + } + + + + /************************************************************************** + * @brief Funktion load_stpl_search sucht Vorschlag fuer Stundenverschiebung + * + * @param datum der Aktuellen Woche + * @param stpl_id Array der stundenplan_id's + * @param db_stpl_table Name der DB-Tabelle + * + * @return true oder false + * + */ + function load_stpl_search($datum,$stpl_id,$db_stpl_table, $block=1) + { + // Name der View + $stpl_view=VIEW_BEGIN.$db_stpl_table; + $stpl_view_id=$db_stpl_table.TABLE_ID; + //Kalenderdaten setzen + $this->datum=montag($datum); + $this->datum_begin=$this->datum; + $this->datum_end=jump_week($this->datum_begin, 1); + // Formatieren fuer Datenbankabfragen + $this->datum_begin=date("Y-m-d",$this->datum_begin); + $this->datum_end=date("Y-m-d",$this->datum_end); + // Stundentafel abfragen + $sql_query='SELECT min(stunde),max(stunde)FROM tbl_stunde'; + if(!$result_stunde=pg_exec($this->conn, $sql_query)) + die(pg_last_error($this->conn)); + $min_stunde=pg_result($result_stunde,0,'min'); + $max_stunde=pg_result($result_stunde,0,'max'); + // Stundenplaneintraege holen + $sql_query="SELECT * FROM $stpl_view WHERE"; + $stplids=''; + foreach ($stpl_id as $id) + $stplids.=" OR $stpl_view_id=$id"; + $stplids=substr($stplids,3); + $sql_query.=$stplids; + //echo $sql_query; + if(!$result_stpl=pg_exec($this->conn, $sql_query)) + die(pg_last_error($this->conn)); + $num_rows_stpl=pg_numrows($result_stpl); + // Daten aufbereiten + for ($i=0;$i<$num_rows_stpl;$i++) + { + $row=pg_fetch_object($result_stpl,$i); + //$block=$row->stundenblockung; + //$raumtyp[$i]=$row->raumtyp; + //$raumtypalt[$i]=$row->raumtypalternativ; + if ($row->einheit_kurzbz!=null) + $einheit[]=$row->einheit_kurzbz; + else + $einheit[]=''; + $lehrverband[$i]->stg_kz=$row->studiengang_kz; + $lehrverband[$i]->sem=$row->semester; + $lehrverband[$i]->ver=$row->verband; + $lehrverband[$i]->grp=$row->gruppe; + $lektor[$i]=$row->uid; + $unr=$row->unr; + } + // Raumtypen + //$raumtyp=array_unique($raumtyp); + //$rtype=''; + //foreach ($raumtyp as $r) + // $rtype.=" OR raumtyp_kurzbz='$r'"; + //$raumtypalt=array_unique($raumtypalt); + //foreach ($raumtypalt as $r) + // $rtype.=" OR raumtyp_kurzbz='$r'"; + //$rtype=substr($rtype,3); + //Lektor + $lektor=array_unique($lektor); + $lkt=''; + foreach ($lektor as $l) + $lkt.=" OR uid='$l'"; + $lkt=substr($lkt,3); + // Einheiten + $einheit=array_unique($einheit); + $einheiten=''; + foreach ($einheit as $e) + if ($e!='') + $einheiten.=" OR einheit_kurzbz='$e'"; + //$einheiten=substr($einheiten,3); + //Lehrverband + //$lehrverband=array_unique($lehrverband); + $lvb=''; + foreach ($lehrverband as $l) + { + $lvb.=' OR (studiengang_kz='.$l->stg_kz.' AND semester='.$l->sem; + if ($l->ver!='' && $l->ver!=' ' && $l->ver!=null) + { + $lvb.=" AND (verband='$l->ver' OR verband IS NULL OR verband='')"; + if ($l->grp!='' && $l->grp!=' ' && $l->grp!=null) + $lvb.=" AND (gruppe='$l->grp' OR gruppe IS NULL OR gruppe='')"; + } + //if ($einheiten=='') + // $lvb.=' AND einheit_kurzbz IS NULL'; + $lvb.=')'; + } + $lvb=substr($lvb,3); + + // Raeume die in Frage kommen, aufgrund der Raumtypen + $sql_query="SELECT DISTINCT ort_kurzbz FROM tbl_ort + WHERE aktiv AND ort_kurzbz NOT LIKE '\\\\_%' ORDER BY ort_kurzbz"; // NATURAL JOIN tbl_ortraumtyp WHERE $rtype hierarchie + //echo $sql_query; + if(!$result=pg_exec($this->conn, $sql_query)) + die(pg_last_error($this->conn)); + $num_orte=pg_numrows($result); + for ($i=0;$i<$num_orte;$i++) + $orte[]=pg_fetch_result($result,$i,"ort_kurzbz"); + + // Raster vorbereiten + for ($t=1;$t<7;$t++) + for ($s=$min_stunde;$s<=$max_stunde;$s++) + { + $raster[$t][$s]->ort=array(); + $raster[$t][$s]->kollision=false; + } + + // Stundenplanabfrage bauen (Wo ist Kollision?) + $sql_query="SELECT DISTINCT datum, stunde FROM $stpl_view + WHERE datum>='$this->datum_begin' AND datum<'$this->datum_end' AND + ($lkt $einheiten OR ($lvb) ) AND unr!=$unr"; //AND unr!=$unr" + //echo $sql_query; + if(!$result_kollision=pg_exec($this->conn, $sql_query)) + die(pg_last_error($this->conn)); + $num_k=pg_numrows($result_kollision); + for ($i=0;$i<$num_k;$i++) + { + $row=pg_fetch_object($result_kollision,$i); + $mtag=substr($row->datum, 8,2); + $month=substr($row->datum, 5,2); + $jahr=substr($row->datum, 0,4); + $tag=date("w",mktime(12,0,0,$month,$mtag,$jahr)); + $raster[$tag][$row->stunde]->kollision=true; + } + + // Stundenplanabfrage bauen (Wo ist besetzt?) + $sql_query="SELECT DISTINCT datum, stunde, ort_kurzbz FROM $stpl_view + WHERE datum>='$this->datum_begin' AND datum<'$this->datum_end' AND unr!=$unr"; + //echo $sql_query; NATURAL JOIN tbl_ortraumtyp AND ($rtype) " + if(!$result_besetzt=pg_exec($this->conn, $sql_query)) + die(pg_last_error($this->conn)); + $num_b=pg_numrows($result_besetzt); + for ($i=0;$i<$num_b;$i++) + { + $row=pg_fetch_object($result_besetzt,$i); + $mtag=substr($row->datum, 8,2); + $month=substr($row->datum, 5,2); + $jahr=substr($row->datum, 0,4); + $tag=date("w",mktime(12,0,0,$month,$mtag,$jahr)); + $raster[$tag][$row->stunde]->ort[]=$row->ort_kurzbz; + } + + // freie Plaetze in den Stundenplan eintragen. + for ($t=1;$t<7;$t++) + for ($s=1;$s<=$max_stunde;$s++) + if (!$raster[$t][$s]->kollision && ($s+$block)<=($max_stunde+1)) + { + if (count($raster[$t][$s]->ort)>0) + $this->std_plan[$t][$s][0]->frei_orte=array_diff($orte,$raster[$t][$s]->ort); + else + $this->std_plan[$t][$s][0]->frei_orte=$orte; + for ($b=1;$b<$block && ($s+$block)<=($max_stunde+1);$b++) + $this->std_plan[$t][$s][0]->frei_orte=array_diff($this->std_plan[$t][$s][0]->frei_orte,$raster[$t][$s+$b]->ort); + } + return true; + } + + /************************************************************************** + * @brief Funktion load_lva_search sucht Vorschlag fuer LVAs + * + * @param datum der Aktuellen Woche + * @param lva_id Array der lvaIDs + * @param db_stpl_table Name der DB-Tabelle + * + * @return true oder false + * + */ + function load_lva_search($datum,$lva_id,$db_stpl_table,$type) + { + // Name der View + $stpl_view=VIEW_BEGIN.$db_stpl_table; + $lva_stpl_view=VIEW_BEGIN.'lva_'.$db_stpl_table; + $stpl_table=TABLE_BEGIN.$db_stpl_table; + //Kalenderdaten setzen + $this->datum=montag($datum); + $this->datum_begin=$this->datum; + $this->datum_end=jump_week($this->datum_begin, 1); + // Formatieren fuer Datenbankabfragen + $this->datum_begin=date("Y-m-d",$this->datum_begin); + $this->datum_end=date("Y-m-d",$this->datum_end); + // Stundentafel abfragen + $sql_query='SELECT min(stunde),max(stunde) FROM tbl_stunde'; + if(!$result_stunde=pg_exec($this->conn, $sql_query)) + die(pg_last_error($this->conn)); + $min_stunde=pg_result($result_stunde,0,'min'); + $max_stunde=pg_result($result_stunde,0,'max'); + + // LVAs holen + $sql_query='SELECT *, (semesterstunden-verplant::smallint) AS offenestunden FROM '.$lva_stpl_view.' WHERE'; + $lvas=''; + foreach ($lva_id as $id) + $lvas.=' OR lehrveranstaltung_id='.$id; + $lvas=substr($lvas,3); + $sql_query.=$lvas; + //$this->errormsg.=$sql_query; + //return false; + if(!$result_lva=pg_exec($this->conn, $sql_query)) + die(pg_last_error($this->conn)); + $num_rows_lva=pg_numrows($result_lva); + // Arrays setzen + //$wochenrythmus=array(); + $verplant=array(); + $block=array(); + $semesterstunden=array(); + $offenestunden=array(); + // Daten aufbereiten + for ($i=0;$i<$num_rows_lva;$i++) + { + $row=pg_fetch_object($result_lva,$i); + $raumtyp[$i]=$row->raumtyp; + $raumtypalt[$i]=$row->raumtypalternativ; + if ($row->einheit_kurzbz!=null && $row->einheit_kurzbz!='') + $einheit[$i]=$row->einheit_kurzbz; + $lehrverband[$i]->stg_kz=$row->studiengang_kz; + $lehrverband[$i]->sem=$row->semester; + $lehrverband[$i]->ver=$row->verband; + $lehrverband[$i]->grp=$row->gruppe; + $lektor[$i]=$row->lektor_uid; + $verplant[$i]=$row->verplant; + $offenestunden[]=$row->offenestunden; + $unr=$row->unr; + $block[$i]=$row->stundenblockung; + $wochenrythmus[$i]=$row->wochenrythmus; + $semesterstunden[$i]=(integer)$row->semesterstunden; + //$this->errormsg.='SS:'.$semesterstunden[$i]; + } + /*// verplante Stunden eindeutig? + $verpl=$verplant[0]; + $verplant=array_unique($verplant); + if (count($verplant)==1) + $verplant=$verpl; //verplant[0]; + else + { + $this->errormsg.='Verplante Stunden sind nicht eindeutig!'; + return false; + } + //$this->errormsg.='Verplant:'.$verplant; + // Semesterstunden eindeutig? + $semstd=$semesterstunden[0]; + $semesterstunden=array_unique($semesterstunden); + //$this->errormsg.='SS:'.$semesterstunden[0]; + if (count($semesterstunden)==1) + $semesterstunden=$semstd;//semesterstunden[0]; + else + { + $this->errormsg.='Semesterstunden sind nicht eindeutig!'; + return false; + } + //$this->errormsg.='SS:'.$semesterstunden;*/ + // Blockung eindeutig? + $blck=$block[0]; + $block=array_unique($block); + if (count($block)==1) + $block=$blck; //block[0]; + else + { + $this->errormsg.='Blockung ist nicht eindeutig!'; + return false; + } + //$this->errormsg.='Block:'.$block; + // Offene Stunden eindeutig? + $os=$offenestunden[0]; + $offenestunden=array_unique($offenestunden); + if ($type=='lva_single_search') + $offenestunden=$block; + elseif (count($offenestunden)==1) + $offenestunden=$os; + else + { + $this->errormsg.='Offene Stunden sind nicht eindeutig!'; + return false; + } + // Wochenrythmus eindeutig? + $wr=$wochenrythmus[0]; + $wochenrythmus=array_unique($wochenrythmus); + if (count($wochenrythmus)==1) + $wr=$wr; + else + { + $this->errormsg.='Wochenrythmus ist nicht eindeutig!'; + return false; + } + // Raumtypen + $raumtyp=array_unique($raumtyp); + $rtype=''; + foreach ($raumtyp as $r) + $rtype.=" OR raumtyp_kurzbz='$r'"; + $raumtypalt=array_unique($raumtypalt); + foreach ($raumtypalt as $r) + $rtype.=" OR raumtyp_kurzbz='$r'"; + $rtype=substr($rtype,3); + //Lektor + $lektor=array_unique($lektor); + $lkt=''; + foreach ($lektor as $l) + $lkt.=" OR uid='$l'"; + $lkt=substr($lkt,3); + //Dummy Lektor kollidiert nicht + $lkt='(('.$lkt.") AND uid!='_DummyLektor')"; + // Einheiten + $einheit=array_unique($einheit); + $einheiten=''; + foreach ($einheit as $e) + $einheiten.=" OR einheit_kurzbz='$e'"; + //$einheiten=substr($einheiten,3); + //Lehrverband + //$lehrverband=array_unique($lehrverband); + $lvb=''; + foreach ($lehrverband as $l) + { + $lvb.=' OR (studiengang_kz='.$l->stg_kz.' AND semester='.$l->sem; + if ($l->ver!='' && $l->ver!=' ' && $l->ver!=null) + { + $lvb.=" AND (verband='$l->ver' OR verband IS NULL OR verband='' OR verband=' ')"; + if ($l->grp!='' && $l->grp!=' ' && $l->grp!=null) + $lvb.=" AND (gruppe='$l->grp' OR gruppe IS NULL OR gruppe='' OR gruppe=' ')"; + } + if ($einheiten=='') + $lvb.=' AND einheit_kurzbz IS NULL'; + $lvb.=')'; + } + $lvb=substr($lvb,3); + + // Raeume die in Frage kommen aufgrund der Raumtypen + $sql_query="SELECT DISTINCT ort_kurzbz, hierarchie FROM tbl_ort + NATURAL JOIN tbl_ortraumtyp WHERE ($rtype) AND aktiv AND ort_kurzbz NOT LIKE '\\\\_%' ORDER BY hierarchie,ort_kurzbz"; // + //echo $sql_query; + if(!$result=pg_exec($this->conn, $sql_query)) + die(pg_last_error($this->conn)); + $num_orte=pg_numrows($result); + for ($i=0;$i<$num_orte;$i++) + $orte[]=pg_fetch_result($result,$i,"ort_kurzbz"); + + // Suche nach freien Orten. Bei 'lva_multi_search' wird die Schleife (do) aktiv + $count=0; + $rest=$offenestunden; + if ($rest<=0 && $type=='lva_multi_search') + { + $this->errormsg.='Es sind bereits alle Stunden verplant!'; + return false; + } + $datum=$this->datum; + $datum_begin=$this->datum_begin; + $datum_end=$this->datum_end; + do + { + // Raster vorbereiten + for ($t=1;$t<7;$t++) + for ($s=$min_stunde;$s<=$max_stunde;$s++) + { + unset($raster[$t][$s]); + $raster[$t][$s]->ort=array(); + $raster[$t][$s]->kollision=false; + } + + // Stundenplanabfrage bauen (Wo ist Kollision?) + $sql_query="SELECT DISTINCT datum, stunde FROM $stpl_table + WHERE datum>='$datum_begin' AND datum<'$datum_end' AND + ($lkt $einheiten OR ($lvb) ) AND unr!=$unr"; + //$this->errormsg.=htmlspecialchars($sql_query); + //return false; + if(!$result_kollision=pg_exec($this->conn, $sql_query)) + { + $this->errormsg=pg_last_error($this->conn); + return false; + } + $num_k=pg_numrows($result_kollision); + // Kollisionen ins Raster eintragen + for ($i=0;$i<$num_k;$i++) + { + $row=pg_fetch_object($result_kollision,$i); + $mtag=substr($row->datum, 8,2); + $month=substr($row->datum, 5,2); + $jahr=substr($row->datum, 0,4); + $tag=date("w",mktime(12,0,0,$month,$mtag,$jahr)); + $raster[$tag][$row->stunde]->kollision=true; + } + + // Stundenplanabfrage bauen (Wo ist besetzt?) + $sql_query="SELECT DISTINCT datum, stunde, ort_kurzbz FROM $stpl_view + NATURAL JOIN tbl_ortraumtyp + WHERE datum>='$datum_begin' AND datum<'$datum_end' AND + ($rtype) AND unr!=$unr"; // + //echo $sql_query; + if(!$result_besetzt=pg_query($this->conn, $sql_query)) + { + $this->errormsg=pg_last_error($this->conn); + return false; + } + $num_b=pg_numrows($result_besetzt); + + // Besetzte Orte ins Raster eintragen + for ($i=0;$i<$num_b;$i++) + { + $row=pg_fetch_object($result_besetzt,$i); + $mtag=substr($row->datum, 8,2); + $month=substr($row->datum, 5,2); + $jahr=substr($row->datum, 0,4); + $tag=date("w",mktime(12,0,0,$month,$mtag,$jahr)); + $raster[$tag][$row->stunde]->ort[]=$row->ort_kurzbz; + //if ($row->ort_kurzbz=='EDV6.10' && $tag==2 && $row->stunde==8) + // $this->errormsg.=htmlspecialchars($row->ort_kurzbz).'/'.$mtag.'/'.$month; + } + + // freie Plaetze in den Stundenplan eintragen. + for ($t=1;$t<7;$t++) + for ($s=1;$s<=$max_stunde;$s++) + if (!$raster[$t][$s]->kollision && ($s+$block)<=($max_stunde+1)) + { + // Besetzte Orte von den freien abziehen + if (count($raster[$t][$s]->ort)>0 && $count==0) + $this->std_plan[$t][$s][0]->frei_orte=array_diff($orte,$raster[$t][$s]->ort); + elseif ($count==0) + $this->std_plan[$t][$s][0]->frei_orte=$orte; + elseif (count($raster[$t][$s]->ort)>0) + $this->std_plan[$t][$s][0]->frei_orte=array_diff($this->std_plan[$t][$s][0]->frei_orte,$raster[$t][$s]->ort); + // Blockung beruecksichtigen + for ($b=1;$b<$block && ($s+$block)<=($max_stunde+1);$b++) + if (!$raster[$t][$s+$b]->kollision) + $this->std_plan[$t][$s][0]->frei_orte=array_diff($this->std_plan[$t][$s][0]->frei_orte,$raster[$t][$s+$b]->ort); + else + $this->std_plan[$t][$s][0]->frei_orte=array(); + } + elseif($raster[$t][$s]->kollision) + $this->std_plan[$t][$s][0]->frei_orte=array(); + + // Variablen abgleichen + $rest-=$block; + if ($block>$rest) + $block=$rest; + $datum=jump_week($datum,$wr); + $datum_begin=$datum; + $datum_end=jump_week($datum_begin, 1); + // Formatieren fuer Datenbankabfragen + $datum_begin=date("Y-m-d",$datum_begin); + $datum_end=date("Y-m-d",$datum_end); + $count++; + } while($type=='lva_multi_search' && $rest>0); + return true; + } + + + /************************************************************************** + * @brief Funktion draw_week_csv Stundenplan im XUL-Format + * + * @param target Ziel-System zB Outlook + * + * @return true oder false + * + */ + function draw_week_csv($target) + { + if (!date("w",$this->datum)) + $this->datum=jump_day($this->datum,1); + $num_rows_stunde=pg_numrows($this->stunde); + for ($i=1; $i<7; $i++) + { + for ($k=0; $k<$num_rows_stunde; $k++) + { + $j=pg_result($this->stunde,$k,'"stunde"'); // get id of hour + if (isset($this->std_plan[$i][$j][0]->lehrfach)) + { + // Daten aufbereiten + unset($unr); + unset($lektor); + unset($lehrverband); + unset($lehrfach); + foreach ($this->std_plan[$i][$j] as $lehrstunde) + { + $unr[]=$lehrstunde->unr; + // Lektoren + $lektor[]=$lehrstunde->lektor; + // Lehrverband + $lvb=$lehrstunde->stg.'-'.$lehrstunde->sem; + if ($lehrstunde->ver!=null && $lehrstunde->ver!='0' && $lehrstunde->ver!='') + { + $lvb.=$lehrstunde->ver; + if ($lehrstunde->grp!=null && $lehrstunde->grp!='0' && $lehrstunde->grp!='') + $lvb.=$lehrstunde->grp; + } + if (count($lehrstunde->einheit_kurzbz)>0) + $lvb=$lehrstunde->einheit_kurzbz; + $lehrverband[]=$lvb; + // Lehrfach + $lf=$lehrstunde->lehrfach; + if (isset($lehrstunde->lehrform)) + $lf.='-'.$lehrstunde->lehrform; + $lehrfach[]=$lf; + $titel=$lehrstunde->titel; + $anmerkung=$lehrstunde->anmerkung; + } + + // Unterrichtsnummer (Kollision?) + $unr=array_unique($unr); + if(!isset($kollision)) + $kollision=0; + $kollision+=count($unr); + + // Lektoren + if ($this->type!='lektor') + { + $lektor=array_unique($lektor); + sort($lektor); + $lkt=''; + foreach ($lektor as $l) + $lkt.=$l.' '; + } + else + $lkt=$lektor[0]; + //echo $lkt; + + // Lehrverband + if ($this->type!='verband') + { + $lehrverband=array_unique($lehrverband); + sort($lehrverband); + $lvb=''; + foreach ($lehrverband as $l) + $lvb.=$l.' '; + } + else + $lvb=$lehrverband[0]; + + + $start_time=pg_result($this->stunde,$k,'"beginn"'); + // Blockungen erkennen + if (($this->std_plan[$i][$j][0]->unr == $this->std_plan[$i][$j+1][0]->unr) && $this->std_plan[$i][$j][0]!=0 && $k<($num_rows_stunde-1)) + { + $end_time=pg_result($this->stunde,++$k,'"ende"'); + if (($this->std_plan[$i][$j][0]->unr == $this->std_plan[$i][$j+2][0]->unr) && $k<($num_rows_stunde-2)) + { + $end_time=pg_result($this->stunde,++$k,'"ende"'); + if (($this->std_plan[$i][$j][0]->unr == $this->std_plan[$i][$j+3][0]->unr) && $k<($num_rows_stunde-3)) + $end_time=pg_result($this->stunde,++$k,'"ende"'); + } + } + else + $end_time=pg_result($this->stunde,$k,'"ende"'); + //$start_time=substr($start_time,0,5); + //$end_time=substr($end_time,0,5); + //$start_date=$this->datum[year].'/'.$this->datum[mon].'/'.$this->datum[mday]; + + $start_date=date("d.m.Y",$this->datum); + $end_date=$start_date; + if ($target=='outlook') + { + echo $this->crlf.'"'.$this->std_plan[$i][$j][0]->lehrfach.'","'.$start_date.'","'.$start_time.'","'.$end_date.'","'.$end_time.'","Aus","Aus",,,,,,,,"Stundenplan'; + echo $this->crlf.$this->std_plan[$i][$j][0]->lehrfach.$this->crlf.$this->std_plan[$i][$j][0]->lektor.$this->crlf.$lvb.$this->crlf.$this->std_plan[$i][$j][0]->ort.'","StundenplanFH","'.$this->std_plan[$i][$j][0]->ort.'","Normal","Aus",,"Normal","2"'; + } + else if ($target=='ical') + { + $sda = explode(".",$start_date); //sda start date array + $sta = explode(":",$start_time); //sta start time array + $eda = explode(".",$end_date); //eda end date array + $eta = explode(":",$end_time); //eta end time array + + $start_date_time_ical = $sda[2].$sda[1].$sda[0].'T'.$sta[0].$sta[1].$sta[2]; //.'Z'; //neu gruppieren der Startzeit und des Startdatums + $end_date_time_ical = $eda[2].$eda[1].$eda[0].'T'.$eta[0].$eta[1].$eta[2]; //.'Z'; //neu gruppieren der Startzeit und des Startdatums + + echo $this->crlf.'BEGIN:VEVENT'.$this->crlf + .'UID:'.'TW'.$lvb.$this->std_plan[$i][$j][0]->ort.$this->std_plan[$i][$j][0]->lektor.$lehrfach[0].$start_date_time_ical.$this->crlf + .'SUMMARY:'.$lehrfach[0].' '.$this->std_plan[$i][$j][0]->ort.' - '.$lvb.$this->crlf + .'DESCRIPTION:'.$lehrfach[0].'\n'.$this->std_plan[$i][$j][0]->lektor.'\n'.$lvb.'\n'.$this->std_plan[$i][$j][0]->ort.$this->crlf + .'LOCATION:'.$this->std_plan[$i][$j][0]->ort.$this->crlf + .'CATEGORIES:StundenplanTW'.$this->crlf + .'DTSTART:'.$start_date_time_ical.$this->crlf + .'DTEND:'.$end_date_time_ical.$this->crlf + .'END:VEVENT'; + } + else + { + echo $this->crlf.'"'.$lehrfach[0].'","StundenplanTW","'.$this->std_plan[$i][$j][0]->ort.'","Stundenplan'.$this->crlf.$this->std_plan[$i][$j][0]->lehrfach.$this->crlf; + echo $this->std_plan[$i][$j][0]->lektor.$this->crlf.$lvb.$this->crlf.$this->std_plan[$i][$j][0]->ort.'","Stundenplan",'; + echo '"'.$start_date.'","'.$start_time.'","'.$end_date.'","'.$end_time.'",,,,,'; + } + } + } + $this->datum=jump_day($this->datum, 1); + } + return true; + } + +} + +?> \ No newline at end of file diff --git a/include/test.php b/include/test.php new file mode 100644 index 000000000..ecfa68b70 --- /dev/null +++ b/include/test.php @@ -0,0 +1,9 @@ + diff --git a/include/zeitwunsch.class.php b/include/zeitwunsch.class.php new file mode 100644 index 000000000..f5483d79e --- /dev/null +++ b/include/zeitwunsch.class.php @@ -0,0 +1,96 @@ +conn=$conn; + } + + /** + * Zeitwunsch einer Person laden + * @return boolean Ergebnis steht in Array $zeitwunsch wenn true + */ + function loadPerson($uid) + { + // Zeitwuensche abfragen + if(!$result=@pg_query($this->conn, "SELECT * FROM tbl_zeitwunsch WHERE uid='$uid'")) + { + $this->errormsg=pg_last_error($this->conn); + return false; + } + else + { + while ($row=@pg_fetch_object($result)) + $this->zeitwunsch[$row->tag][$row->stunde]=$row->gewicht; + return true; + } + } + + + /** + * Zeitwunsch der Personen in Lehrveranstaltungen laden + * @return array mit Fachbereichen oder false=fehler + */ + function loadLVA($lva_id) + { + // SUB-Select fuer LVAs + $sql_query_lva='SELECT DISTINCT lektor FROM tbl_lehrveranstaltung WHERE '; + for ($i=0;$iconn, $sql_query)) + { + $this->errormsg=pg_last_error($this->conn); + return false; + } + else + { + while ($row=@pg_fetch_object($result)) + $this->zeitwunsch[$row->tag][$row->stunde]=$row->gewicht; + return true; + } + } + +} +?> \ No newline at end of file diff --git a/index.cis.html b/index.cis.html new file mode 100644 index 000000000..229e853d1 --- /dev/null +++ b/index.cis.html @@ -0,0 +1,23 @@ + + + + CIS - FH Technikum Wien + + + + + + + + + + + + + + <body> + <p>Diese Seite verwendet Frames. Frames werden von Ihrem Browser aber nicht unterstützt.</p> + </body> + + + diff --git a/index.cis2.html b/index.cis2.html new file mode 100644 index 000000000..c64d5567c --- /dev/null +++ b/index.cis2.html @@ -0,0 +1,22 @@ + + + + CIS - FH Technikum Wien + + + + + + + + + + + + + <body> + <p>Diese Seite verwendet Frames. Frames werden von Ihrem Browser aber nicht unterstützt.</p> + </body> + + + diff --git a/index.vilesci.html b/index.vilesci.html new file mode 100644 index 000000000..7e2e57415 --- /dev/null +++ b/index.vilesci.html @@ -0,0 +1,17 @@ + + + +VileSci + + + + + + + +<body bgcolor="#FFFFFF"> + +</body> + + diff --git a/locale/contents.rdf b/locale/contents.rdf new file mode 100644 index 000000000..b4d9f650d --- /dev/null +++ b/locale/contents.rdf @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/locale/de-AT/contents.rdf b/locale/de-AT/contents.rdf new file mode 100644 index 000000000..b4d9f650d --- /dev/null +++ b/locale/de-AT/contents.rdf @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/locale/de-AT/fas.dtd b/locale/de-AT/fas.dtd new file mode 100644 index 000000000..509add4b3 --- /dev/null +++ b/locale/de-AT/fas.dtd @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/locale/de-AT/tempus.dtd b/locale/de-AT/tempus.dtd new file mode 100644 index 000000000..33d99ba68 --- /dev/null +++ b/locale/de-AT/tempus.dtd @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/locale/en-US/contents.rdf b/locale/en-US/contents.rdf new file mode 100644 index 000000000..a5fd2e813 --- /dev/null +++ b/locale/en-US/contents.rdf @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/locale/en-US/tempus.dtd b/locale/en-US/tempus.dtd new file mode 100644 index 000000000..bddf5465f --- /dev/null +++ b/locale/en-US/tempus.dtd @@ -0,0 +1,7 @@ + + + + + + + diff --git a/locale/tempus.dtd b/locale/tempus.dtd new file mode 100644 index 000000000..05fae9f44 --- /dev/null +++ b/locale/tempus.dtd @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/phpinfo.php b/phpinfo.php new file mode 100644 index 000000000..c18f4c6d5 --- /dev/null +++ b/phpinfo.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/rdf/einheiten.rdf.php b/rdf/einheiten.rdf.php new file mode 100644 index 000000000..382ee5c93 --- /dev/null +++ b/rdf/einheiten.rdf.php @@ -0,0 +1,65 @@ +'; +// DAO +include('../vilesci/config.inc.php'); +include_once('../include/einheit.class.php'); + +// Datenbank Verbindung +if (!$conn = @pg_pconnect(CONN_STRING)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + + +// Einheiten holen +$einheitenDAO=new einheit($conn); +$einheiten=$einheitenDAO->getAll(); + + + +$rdf_url='http://www.technikum-wien.at/tempus/einheiten'; + +?> + + + + + + + + + + kurzbz ?> + stg_kz ?> + stg_kurzbz ?> + bezeichnung ?> + semester ?> + typ ?> + + + + + + + + \ No newline at end of file diff --git a/rdf/fachbereich.rdf.php b/rdf/fachbereich.rdf.php new file mode 100644 index 000000000..79f692e9c --- /dev/null +++ b/rdf/fachbereich.rdf.php @@ -0,0 +1,83 @@ +'; +// DAO +include('../vilesci/config.inc.php'); +include_once('../include/fachbereich.class.php'); + +// Datenbank Verbindung +if (!$conn = @pg_pconnect(CONN_STRING)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + + +// test + +$einheit_kurzbz=''; +$grp='1'; +//$ver='A'; +$sem=5; +$stg_kz=145; + + +/* +$einheit_kurzbz=''; +$grp=$_GET['grp']; +$ver=$_GET['ver']; +$sem=$_GET['sem']; +$stg_kz=$_GET['stg_kz']; */ + +// fachbereiche holen +$fachbereichDAO=new fachbereich($conn); +$fachbereiche=$fachbereichDAO->getAll(); + + + +$rdf_url='http://www.technikum-wien.at/tempus/fachbereich'; + +?> + + + + + + + + + id ?> + kurzbz ?> + bezeichnung ?> + farbe ?> + studiengang_kz ?> + studiengang_kurzbz ?> + + + + + + + \ No newline at end of file diff --git a/rdf/fas/adressen.rdf.php b/rdf/fas/adressen.rdf.php new file mode 100644 index 000000000..d42553ef3 --- /dev/null +++ b/rdf/fas/adressen.rdf.php @@ -0,0 +1,100 @@ +'; +// DAO +include('../../vilesci/config.inc.php'); +include_once('../../include/fas/adresse.class.php'); + +// Datenbank Verbindung +if (!$conn = @pg_pconnect(CONN_STRING_FAS)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + +$rdf_url='http://www.technikum-wien.at/adressen'; + +?> + + + + + +load_pers($pers_id); + + + foreach ($adressenDAO->result as $adressen) + { + ?> + + + adresse_id; ?> + bismeldeadresse?'Ja':'Nein'); ?> + gemeinde; ?> + name; ?> + nation; ?> + ort; ?> + person_id; ?> + plz; ?> + strasse; ?> + typ; ?> + zustelladresse?'Ja':'Nein'); ?> + + + load($adress_id) + + ?> + + + adresse_id; ?> + bismeldeadresse?'Ja':'Nein'); ?> + gemeinde; ?> + name; ?> + nation; ?> + ort; ?> + person_id; ?> + plz; ?> + strasse; ?> + typ; ?> + zustelladresse?'Ja':'Nein'); ?> + + + + + + + + \ No newline at end of file diff --git a/rdf/fas/ausbildung.rdf.php b/rdf/fas/ausbildung.rdf.php new file mode 100644 index 000000000..ac2abcd52 --- /dev/null +++ b/rdf/fas/ausbildung.rdf.php @@ -0,0 +1,90 @@ +'; + +$rdf_url='http://www.technikum-wien.at/ausbildung'; +?> + + + + + + 1 + Universitätsabschluss mit Doktorat als Zweit- oder Dritt- oder PhD-Abschluss + + + + + 2 + Universitäts- oder Hochschulabschluss auf Diplom oder Magisterebene, Doktor als Erstabschluss + + + + + 3 + Fachhochschulabschluss auf Diplom- oder Magisterebene + + + + + 4 + Universitätsabschluss auf Bakkalaureatsebene + + + + + 5 + Fachhochschulabschluss auf Bakkalaureatsebene + + + + + 6 + Diplom einer Akademie + + + + + 7 + Anderer tertiärer Bildungsabschluss + + + + + 8 + Reifeprüfung einer allgemeinbildenden höheren Schule + + + + + 9 + Reifeprüfung einer berufsbildenden höheren Schule + + + + + 10 + Lehrabschlussprüfung + + + + + 11 + Pflichtschule + + + + \ No newline at end of file diff --git a/rdf/fas/ausbildungssemester.rdf.php b/rdf/fas/ausbildungssemester.rdf.php new file mode 100644 index 000000000..808f4baab --- /dev/null +++ b/rdf/fas/ausbildungssemester.rdf.php @@ -0,0 +1,61 @@ +'; +// DAO +include('../../vilesci/config.inc.php'); +include_once('../../include/fas/ausbildungssemester.class.php'); + +// Datenbank Verbindung +if (!$conn = @pg_pconnect(CONN_STRING_FAS)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + +$rdf_url='http://www.technikum-wien.at/ausbildungssemester'; + +?> + + + + + +load_stg($_GET['stg']); + + foreach ($ausbsem_obj->result as $ausbsem) + { + ?> + + + ausbildungssemester_id; ?> + studiengang_id; ?> + semester; ?> + name; ?> + + + + + + + \ No newline at end of file diff --git a/rdf/fas/ausmass.rdf.php b/rdf/fas/ausmass.rdf.php new file mode 100644 index 000000000..325549f52 --- /dev/null +++ b/rdf/fas/ausmass.rdf.php @@ -0,0 +1,61 @@ +'; +// DAO +include('../../vilesci/config.inc.php'); + +$rdf_url='http://www.technikum-wien.at/ausmass'; + +?> + + + + + + + + 1 + Vollzeit + + + + + 2 + + + + + + 3 + 16 - 25 Wochenstunden + + + + + 4 + 26 - 35 Wochenstunden + + + + + 5 + Karenz + + + + \ No newline at end of file diff --git a/rdf/fas/bankverbindungen.rdf.php b/rdf/fas/bankverbindungen.rdf.php new file mode 100644 index 000000000..1f8d80e61 --- /dev/null +++ b/rdf/fas/bankverbindungen.rdf.php @@ -0,0 +1,98 @@ +'; +// DAO +include('../../vilesci/config.inc.php'); +include_once('../../include/fas/bankverbindung.class.php'); + +// Datenbank Verbindung +if (!$conn = @pg_pconnect(CONN_STRING_FAS)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + +$rdf_url='http://www.technikum-wien.at/bankverbindungen'; + +?> + + + + + +load_pers($pers_id); + + + foreach ($bankverbindungenDAO->result as $bankverbindungen) + { + ?> + + + bankverbindung_id; ?> + person_id; ?> + name; ?>]]> + anschrift; ?>]]> + blz; ?> + bic; ?> + kontonr; ?> + iban; ?> + typ,10); ?> + getTypBezeichnung(fmod($bankverbindungen->typ,10)); ?> + typ>10?'Ja':'Nein'); ?> + + + load($bankverbindung_id); + ?> + + + bankverbindung_id; ?> + person_id; ?> + name; ?>]]> + anschrift; ?>]]> + blz; ?> + bic; ?> + kontonr; ?> + iban; ?> + typ,10); ?> + typ>10?'Ja':'Nein'); ?> + + + + + + + + + \ No newline at end of file diff --git a/rdf/fas/beschaeftigungsart1.rdf.php b/rdf/fas/beschaeftigungsart1.rdf.php new file mode 100644 index 000000000..0d14bb547 --- /dev/null +++ b/rdf/fas/beschaeftigungsart1.rdf.php @@ -0,0 +1,70 @@ +'; +// DAO +include('../../vilesci/config.inc.php'); + +$rdf_url='http://www.technikum-wien.at/beschaeftigungsart1'; + +?> + + + + + + + + 1 + Dienstverhältnis zum Bund + + + + + 2 + Dienstverhältnis zu einer anderen Gebietskörperschaft + + + + + 3 + Dienstverhältnis zur Bildungseinrichtung oder deren Träger ("Echter" Dienstvertrag) + + + + + 4 + Dienstverhältnis zur Bildungseinrichtung oder deren Träger (Freier Dienstvertrag) + + + + + 5 + Lehr- oder Ausbildungsverhältnis + + + + + 6 + Sonstiges Beschäftigungsverhältnis + + + + + + + \ No newline at end of file diff --git a/rdf/fas/db_dml.rdf.php b/rdf/fas/db_dml.rdf.php new file mode 100644 index 000000000..23e70b04a --- /dev/null +++ b/rdf/fas/db_dml.rdf.php @@ -0,0 +1,1156 @@ +'; + $rdf_url='http://www.technikum-wien.at/dbdml'; + $error=false; + $errormsg = 'Funktion noch nicht implementiert'; + $return = 'false'; + + //UID holen + $user=get_uid(); + + //Sollte eigentlich nie vorkommen + if($user=='') + { + $error = true; + $return = 'false'; + $errormsg = 'User konnte nicht ermittelt werden'; + } + + //VILESCI Datenbankverbindung herstellen + if(!$conn = pg_pconnect(CONN_STRING)) + { + $error = true; + $return = 'false'; + $errormsg = 'Verbindung zur Datenbank fehlgeschlagen'; + } + + //FAS Datenbankverbindung herstellen + if(!$conn_fas = pg_pconnect(CONN_STRING_FAS)) + { + $error = true; + $return = 'false'; + $errormsg = 'Verbindung zur Datenbank fehlgeschlagen'; + } + $rechte = new berechtigung($conn); + $rechte->getBerechtigungen($user); + $benutzer = new benutzer($conn); + $benutzer->loadVariables($user); +?> + + + + +isBerechtigt('admin', 0, 'i') + || $rechte->isBerechtigt('admin', 0, 'u') + || $rechte->isBerechtigt('mitarbeiter', 0, 'i') + || $rechte->isBerechtigt('mitarbeiter', 0, 'u')) + { + $mitarbeiter = new mitarbeiter($conn_fas); + //Werte holen und zuweisen + $mitarbeiter->new = ($_POST['new']=='true'?true:false); + $mitarbeiter->person_id = $_POST['person_id']; + $mitarbeiter->mitarbeiter_id = $_POST['mitarbeiter_id']; + $mitarbeiter->anrede = $_POST['anrede']; + $mitarbeiter->titelpre = $_POST['titelpre']; + $mitarbeiter->titelpost = $_POST['titelpost']; + $mitarbeiter->familienname = $_POST['nachname']; + $mitarbeiter->vorname = $_POST['vorname']; + $mitarbeiter->vornamen = $_POST['vornamen']; + $mitarbeiter->uid = $_POST['uid']; + $mitarbeiter->svnr = $_POST['svnr']; + $mitarbeiter->ersatzkennzeichen = $_POST['ersatzkennzeichen']; + $mitarbeiter->gebort = $_POST['geburtsort']; + if($_POST['geburtsdatum']!='') + $mitarbeiter->gebdat = convertdate($_POST['geburtsdatum']); + else + $mitarbeiter->gebdat = ''; + $mitarbeiter->bemerkung = $_POST['bemerkung']; + $mitarbeiter->anzahlderkinder = $_POST['anzahlderkinder']; + $mitarbeiter->geschlecht = $_POST['geschlecht']; + $mitarbeiter->bismelden = ($_POST['bismelden']=='true'?true:false); + $mitarbeiter->familienstand = $_POST['familienstand']; + $mitarbeiter->staatsbuergerschaft = $_POST['staatsbuergerschaft']; + $mitarbeiter->gebnation = $_POST['geburtsnation']; + $mitarbeiter->persnr = $_POST['personal_nr']; + $mitarbeiter->kurzbez = $_POST['kurzbezeichnung']; + if($_POST['beginndatum']!='') + $mitarbeiter->beginndatum = convertdate($_POST['beginndatum']); + else + $mitarbeiter->beginndatum = ''; + $mitarbeiter->stundensatz = $_POST['stundensatz']; + $mitarbeiter->habilitation = ($_POST['habilitation']=='true'?true:false); + $mitarbeiter->ausgeschieden = ($_POST['ausgeschieden']=='true'?true:false); + if($_POST['beendigungsdatum']!='') + $mitarbeiter->beendigungsdatum = convertdate($_POST['beendigungsdatum']); + else + $mitarbeiter->beendigungsdatum = ''; + $mitarbeiter->ausbildung = $_POST['ausbildung']; + $mitarbeiter->aktstatus = $_POST['aktstatus']; + $mitarbeiter->aktiv = $_POST['aktiv']; + $mitarbeiter->updatevon = $benutzer->variable->fas_id; + + if($mitarbeiter->save()) //Datensatz speichern + { + $return = 'true'; + $errormsg = 'Datensatz erfolgreich gespeichert'; + } + else + { + $return = 'false'; + $errormsg = $mitarbeiter->errormsg; + } + } + else + { + $return = 'false'; + $errormsg = 'Sie haben keine Berechtigung zum Speichern'; + } + } + elseif(isset($_POST['type']) && $_POST['type']=='delmitarbeiter') //Person und Mitarbeiter loeschen + { + /** + * Beim loeschen wird eine variable Anzahl an IDs uebergeben die Anzahl wird + * in $_POST['anz'] gespeichert die einzelnen IDS heissen dann x1, x2, x3, ... + */ + if($rechte->isBerechtigt('admin', 0, 'd') + || $rechte->isBerechtigt('mitarbeiter', 0, 'd')) + { + $errormsg = ''; + $mitarbeiter = new mitarbeiter($conn_fas); + $mitarbeiter->updatevon = $benutzer->variable->fas_id; + for($i=0;$i<$_POST['anz'];$i++) + { + if(!$mitarbeiter->delete($_POST['x'.$i])) + { + $var = 'x'.$i; + $errormsg .= "\n\rFehler beim loeschen des Datensatzes mit der ID ".$_POST[$var]." Meldung: ".$mitarbeiter->errormsg; + $return = 'false'; + } + } + if($errormsg=='') + { + $return = 'true'; + $errormsg = 'Datensatz erfolgreich gespeichert'; + } + } + else + { + $return = 'false'; + $errormsg = 'Sie haben keine Berechtigung zum Löschen'; + } + } + elseif(isset($_POST['type']) && $_POST['type']=='newmitarbeiter') //Neuen,leeren Mitarbeiterdatensatz anlegen + { + if($rechte->isBerechtigt('admin', 0, 'i') + || $rechte->isBerechtigt('mitarbeiter', 0, 'i')) + { + $mitarbeiter = new mitarbeiter($conn_fas); + $mitarbeiter->new=true; + $mitarbeiter->aktstatus=100; + $mitarbeiter->aktiv=true; + $mitarbeiter->staatsbuergerschaft ='A'; + $mitarbeiter->gebnation = 'A'; + $mitarbeiter->bismelden = true; + $mitarbeiter->ausbildung = 1; + $mitarbeiter->svnr = '0000000000'; + $mitarbeiter->updatevon = $benutzer->variable->fas_id; + $mitarbeiter->persnr = $mitarbeiter->getNextPersonalnr(); + + if($mitarbeiter->save()) + { + $return = 'true'; + $errormsg = $mitarbeiter->mitarbeiter_id; + //Funktion anlegen falls noetig + if(isset($_POST['art']) && $_POST['art']=='fix') //Fixangestellt - Echter Dienstvertrag + { + $fkt_obj = new funktion($conn_fas); + $fkt_obj->new=true; + $fkt_obj->mitarbeiter_id = $mitarbeiter->mitarbeiter_id; + $fkt_obj->studiensemester_id = $_POST['studiensemester_id']; + $fkt_obj->erhalter_id = 1; + $fkt_obj->studiengang_id = null; + $fkt_obj->fachbereich_id = null; + $fkt_obj->name = null; + $fkt_obj->funktion = null; + $fkt_obj->beschart1 = 3; + $fkt_obj->beschart2 = null; + $fkt_obj->verwendung = null; + $fkt_obj->hauptberuf = null; + $fkt_obj->hauptberuflich = true; + $fkt_obj->entwicklungsteam = false; + $fkt_obj->besonderequalifikation = 0; + $fkt_obj->ausmass = 0; + $fkt_obj->updatevon = $benutzer->variable->fas_id; + if($fkt_obj->save()) + { + $return = 'true'; + $errormsg = $mitarbeiter->mitarbeiter_id; + } + else + { + $return = 'false'; + $errormsg = 'funktion konnte nicht angelegt werden:'.$fkt_obj->errormsg; + } + } + elseif(isset($_POST['art']) && $_POST['art']=='frei') //Freier Mitarbeiter - Freier Dienstvertrag + { + $fkt_obj = new funktion($conn_fas); + $fkt_obj->new=true; + $fkt_obj->mitarbeiter_id = $mitarbeiter->mitarbeiter_id; + $fkt_obj->studiensemester_id = $_POST['studiensemester_id']; + $fkt_obj->erhalter_id = 1; + $fkt_obj->studiengang_id = null; + $fkt_obj->fachbereich_id = null; + $fkt_obj->name = null; + $fkt_obj->funktion = null; + $fkt_obj->beschart1 = 4; + $fkt_obj->beschart2 = null; + $fkt_obj->verwendung = null; + $fkt_obj->hauptberuf = null; + $fkt_obj->hauptberuflich = true; + $fkt_obj->entwicklungsteam = false; + $fkt_obj->besonderequalifikation = 0; + $fkt_obj->ausmass = 0; + $fkt_obj->updatevon = $benutzer->variable->fas_id; + if($fkt_obj->save()) + { + $return = 'true'; + $errormsg = $mitarbeiter->mitarbeiter_id; + } + else + { + $return = 'false'; + $errormsg = 'funktion konnte nicht angelegt werden:'.$fkt_obj->errormsg; + } + } + + } + else + { + $return = 'false'; + $errormsg = 'Datensatz konnte nicht angelegt werden: '.$mitarbeiter->errormsg; + } + } + else + { + $return = 'false'; + $errormsg = 'Sie haben keine Berechtigung zum einfuegen'; + } + } + elseif(isset($_POST['type']) && $_POST['type']=='funktion') /***********FUNKTIONEN***********/ + { + //Speichert eine Funktion + if($rechte->isBerechtigt('admin', 0, 'i') + || $rechte->isBerechtigt('mitarbeiter', 0, 'i')) + { + //Parameter holen und zuweisen + $funktion_obj = new funktion($conn_fas); + $funktion_obj->new = ($_POST['new']=='true'?true:false); + $funktion_obj->funktion_id = $_POST['funktion_id']; + $funktion_obj->mitarbeiter_id = $_POST['mitarbeiter_id']; + $funktion_obj->studiensemester_id = $_POST['studiensemester_id']; + $funktion_obj->erhalter_id = $_POST['erhalter_id']; + $funktion_obj->studiengang_id = $_POST['studiengang_id']; + $funktion_obj->fachbereich_id = $_POST['fachbereich_id']; + $funktion_obj->name = $_POST['name']; + $funktion_obj->funktion = $_POST['funktion']; + $funktion_obj->beschart1 = $_POST['beschart1']; + $funktion_obj->beschart2 = $_POST['beschart2']; + $funktion_obj->verwendung = $_POST['verwendung']; + $funktion_obj->hauptberuf = $_POST['hauptberuf']; + $funktion_obj->hauptberuflich = ($_POST['hauptberuflich']=='true'?true:false); + $funktion_obj->entwicklungsteam = ($_POST['entwicklungsteam']=='true'?true:false); + $funktion_obj->besonderequalifikation = $_POST['qualifikation']; + $funktion_obj->ausmass = $_POST['ausmass']; + $funktion_obj->updatevon = $benutzer->variable->fas_id; + + if($funktion_obj->save()) //Funktion Speichern + { + $return = 'true'; + $errormsg = $funktion_obj->status; // aktstatus der Person nach dem Speichern + } + else + { + $return = 'false'; + $errormsg = $funktion_obj->errormsg; + } + } + else + { + $return = 'false'; + $errormsg = 'Sie haben keine Berechtigung zum einfuegen'; + } + } + elseif(isset($_POST['type']) && $_POST['type']=='delfunktion') + { + /** + * Beim loeschen wird eine variable Anzahl an IDs uebergeben die Anzahl wird + * in $_POST['anz'] gespeichert die einzelnen IDS heissen dann x1, x2, x3, ... + */ + if($rechte->isBerechtigt('admin', 0, 'd') + || $rechte->isBerechtigt('mitarbeiter', 0, 'd')) + { + $errormsg = ''; + $funktion_obj = new funktion($conn_fas); + $funktion_obj->updatevon = $benutzer->variable->fas_id; + for($i=0;$i<$_POST['anz'];$i++) + { + if(!$funktion_obj->delete($_POST['x'.$i])) + { + $var = 'x'.$i; + $errormsg .= "\n\rFehler beim loeschen des Datensatzes mit der ID ".$_POST[$var]." Meldung: ".$funktion_obj->errormsg; + $return = 'false'; + } + } + if($errormsg=='') + { + $return = 'true'; + $errormsg = $funktion_obj->status; //aktstatus der Person nach dem loeschen + } + } + else + { + $return = 'false'; + $errormsg = 'Sie haben keine Berechtigung zum Löschen'; + } + } + elseif(isset($_POST['type']) && $_POST['type']=='adresse') /***********Adressen***********/ + { + //Speichern eines Adressdatensatzes + if($rechte->isBerechtigt('admin', 0, 'i') + || $rechte->isBerechtigt('mitarbeiter', 0, 'i')) + { + $adresse = new adresse($conn_fas); + $adresse->adresse_id = $_POST['adress_id']; + $adresse->person_id = $_POST['person_id']; + $adresse->typ = $_POST['adresstyp']; + $adresse->name = $_POST['name']; + $adresse->nation = $_POST['nation']; + $adresse->new = ($_POST['new']=='true'?true:false); + $adresse->strasse = $_POST['strasse']; + $adresse->plz = $_POST['plz']; + $adresse->ort = $_POST['ort']; + $adresse->gemeinde = $_POST['gemeinde']; + $adresse->bismeldeadresse = ($_POST['bismeldeadresse']=='true'?true:false); + $adresse->zustelladresse = ($_POST['zustelladresse']=='true'?true:false); + $adresse->updatevon = $benutzer->variable->fas_id; + + if($adresse->save()) + { + $return = 'true'; + $errormsg = 'Datensatz wurde erfolgreich gespeichert'; + } + else + { + $return = 'false'; + $errormsg = $adresse->errormsg; + } + } + else + { + $return = 'false'; + $errormsg = 'Sie haben keine Berechtigung zum einfuegen'; + } + } + elseif(isset($_POST['type']) && $_POST['type']=='deladresse') //Loescht Adressen + { + /** + * Beim loeschen wird eine variable Anzahl an IDs uebergeben die Anzahl wird + * in $_POST['anz'] gespeichert die einzelnen IDS heissen dann x1, x2, x3, ... + */ + if($rechte->isBerechtigt('admin', 0, 'd') + || $rechte->isBerechtigt('mitarbeiter', 0, 'd')) + { + $errormsg = ''; + $adresse = new adresse($conn_fas); + $adresse->updatevon = $benutzer->variable->fas_id; + for($i=0;$i<$_POST['anz'];$i++) + { + if(!$adresse->delete($_POST['x'.$i])) + { + $var = 'x'.$i; + $errormsg .= "\n\rFehler beim loeschen des Datensatzes mit der ID ".$_POST[$var]." Meldung: ".$adresse->errormsg; + $return = 'false'; + } + } + if($errormsg=='') + { + $return = 'true'; + $errormsg = 'Datensatz erfolgreich gespeichert'; + } + } + else + { + $return = 'false'; + $errormsg = 'Sie haben keine Berechtigung zum Löschen'; + } + } + elseif(isset($_POST['type']) && $_POST['type']=='email') /***********EMAIL***********/ + { + //Speichert eine Email + if($rechte->isBerechtigt('admin', 0, 'i') + || $rechte->isBerechtigt('mitarbeiter', 0, 'i')) + { + $email = new email($conn_fas); + $email->email_id = $_POST['email_id']; + $email->person_id = $_POST['person_id']; + $email->name = $_POST['name']; + $email->email = $_POST['email']; + $email->typ = $_POST['typ']; + $email->new = ($_POST['new']=='true'?true:false); + $email->zustelladresse = ($_POST['zustelladresse']=='true'?true:false); + $email->updatevon = $benutzer->variable->fas_id; + + if($email->save()) + { + $return = 'true'; + $errormsg = 'Datensatz wurde erfolgreich gespeichert'; + } + else + { + $return = 'false'; + $errormsg = $email->errormsg; + } + } + else + { + $return = 'false'; + $errormsg = 'Sie haben keine Berechtigung zum einfuegen'; + } + } + elseif(isset($_POST['type']) && $_POST['type']=='delemail') //Loescht Emails + { + /** + * Beim loeschen wird eine variable Anzahl an IDs uebergeben die Anzahl wird + * in $_POST['anz'] gespeichert die einzelnen IDS heissen dann x1, x2, x3, ... + */ + if($rechte->isBerechtigt('admin', 0, 'd') + || $rechte->isBerechtigt('mitarbeiter', 0, 'd')) + { + $errormsg = ''; + $email = new email($conn_fas); + $email->updatevon = $benutzer->variable->fas_id; + for($i=0;$i<$_POST['anz'];$i++) + { + if(!$email->delete($_POST['x'.$i])) + { + $var = 'x'.$i; + $errormsg .= "\n\rFehler beim loeschen des Datensatzes mit der ID ".$_POST[$var]." Meldung: ".$email->errormsg; + $return = 'false'; + } + } + if($errormsg=='') + { + $return = 'true'; + $errormsg = 'Datensatz erfolgreich gespeichert'; + } + } + else + { + $return = 'false'; + $errormsg = 'Sie haben keine Berechtigung zum Loeschen'; + } + } + elseif(isset($_POST['type']) && $_POST['type']=='telefonnummer') /***********TELEFONNUMMER***********/ + { + //Speichert eine Telefonnummer + if($rechte->isBerechtigt('admin', 0, 'i') + || $rechte->isBerechtigt('mitarbeiter', 0, 'i')) + { + $telefon = new telefonnummer($conn_fas); + $telefon->telefonnummer_id = $_POST['telefonnummer_id']; + $telefon->person_id = $_POST['person_id']; + $telefon->name = $_POST['name']; + $telefon->nummer = $_POST['nummer']; + $telefon->typ = $_POST['typ']; + $telefon->new = ($_POST['new']=='true'?true:false); + $telefon->updatevon = $benutzer->variable->fas_id; + + if($telefon->save()) + { + $return = 'true'; + $errormsg = 'Datensatz wurde erfolgreich gespeichert'; + } + else + { + $return = 'false'; + $errormsg = $telefon->errormsg; + } + } + else + { + $return = 'false'; + $errormsg = 'Sie haben keine Berechtigung zum einfuegen'; + } + } + elseif(isset($_POST['type']) && $_POST['type']=='deltelefonnummer') + { + /** + * Beim loeschen wird eine variable Anzahl an IDs uebergeben die Anzahl wird + * in $_POST['anz'] gespeichert die einzelnen IDS heissen dann x1, x2, x3, ... + */ + if($rechte->isBerechtigt('admin', 0, 'd') + || $rechte->isBerechtigt('mitarbeiter', 0, 'd')) + { + $errormsg = ''; + $telefon = new telefonnummer($conn_fas); + $telefon->updatevon = $benutzer->variable->fas_id; + for($i=0;$i<$_POST['anz'];$i++) + { + if(!$telefon->delete($_POST['x'.$i])) + { + $var = 'x'.$i; + $errormsg .= "\n\rFehler beim loeschen des Datensatzes mit der ID ".$_POST[$var]." Meldung: ".$telefon->errormsg; + $return = 'false'; + } + } + if($errormsg=='') + { + $return = 'true'; + $errormsg = 'Datensatz erfolgreich gespeichert'; + } + } + else + { + $return = 'false'; + $errormsg = 'Sie haben keine Berechtigung zum Löschen'; + } + } + elseif(isset($_POST['type']) && $_POST['type']=='bankverbindung') /***********BANKVERBINDUNG***********/ + { + //Speichert eine Bankverbindung + if($rechte->isBerechtigt('admin', 0, 'i') + || $rechte->isBerechtigt('mitarbeiter', 0, 'i')) + { + $bankverbindung = new bankverbindung($conn_fas); + $bankverbindung->bankverbindung_id = $_POST['bankverbindung_id']; + $bankverbindung->person_id = $_POST['person_id']; + $bankverbindung->name = $_POST['name']; + $bankverbindung->anschrift = $_POST['anschrift']; + $bankverbindung->blz = $_POST['blz']; + $bankverbindung->bic = $_POST['bic']; + $bankverbindung->kontonr = $_POST['kontonr']; + $bankverbindung->iban = $_POST['iban']; + $typ = ($_POST['verrechnungskonto']=='true'?10:0) + $_POST['typ']; + $bankverbindung->typ = $typ; + $bankverbindung->new = ($_POST['new']=='true'?true:false); + $bankverbindung->updatevon = $benutzer->variable->fas_id; + + if($bankverbindung->save()) + { + $return = 'true'; + $errormsg = 'Datensatz wurde erfolgreich gespeichert'; + } + else + { + $return = 'false'; + $errormsg = $bankverbindung->errormsg; + } + } + else + { + $return = 'false'; + $errormsg = 'Sie haben keine Berechtigung zum einfuegen'; + } + } + elseif(isset($_POST['type']) && $_POST['type']=='delbankverbindung') + { + /** + * Beim loeschen wird eine variable Anzahl an IDs uebergeben die Anzahl wird + * in $_POST['anz'] gespeichert die einzelnen IDS heissen dann x1, x2, x3, ... + */ + if($rechte->isBerechtigt('admin', 0, 'd') + || $rechte->isBerechtigt('mitarbeiter', 0, 'd')) + { + $errormsg = ''; + $bankverbindung = new bankverbindung($conn_fas); + $bankverbindung->updatevon = $benutzer->variable->fas_id; + for($i=0;$i<$_POST['anz'];$i++) + { + if(!$bankverbindung->delete($_POST['x'.$i])) + { + $var = 'x'.$i; + $errormsg .= "\n\rFehler beim loeschen des Datensatzes mit der ID ".$_POST[$var]." Meldung: ".$bankverbindung->errormsg; + $return = 'false'; + } + } + if($errormsg=='') + { + $return = 'true'; + $errormsg = 'Datensatz erfolgreich gespeichert'; + } + } + else + { + $return = 'false'; + $errormsg = 'Sie haben keine Berechtigung zum Löschen'; + } + } + elseif(isset($_POST['type']) && $_POST['type']=='lva_save') /*********** LEHRVERANSTALTUNGEN ***********/ + { + /** + * Speichert eine Lehreinheit + */ + + if(isset($_POST['studiengang_id']) && is_numeric($_POST['studiengang_id'])) + { + $qry = "SELECT kennzahl FROM studiengang WHERE studiengang_pk=".$_POST['studiengang_id']; + if($row=pg_fetch_object(pg_query($conn_fas,$qry))) + { + $studiengang = $row->kennzahl; + //Ueberpruefen der Berechtigung fuer diesen Studiengang + if($rechte->isBerechtigt('admin', $studiengang, 'u') + || $rechte->isBerechtigt('lva-verwaltung', $studiengang, 'u')) + { + $lva = new lehreinheit($conn_fas); + //Werte zuweisen + $lva->new=false; + $lva->lehreinheit_id = (isset($_POST['lehreinheit_id'])?urldecode($_POST['lehreinheit_id']):''); + $lva->studiengang_id = (isset($_POST['studiengang_id'])?urldecode($_POST['studiengang_id']):''); + $lva->studiensemester_id = (isset($_POST['studiensemester_id'])?urldecode($_POST['studiensemester_id']):''); + $lva->lehrveranstaltung_id = (isset($_POST['lehrveranstaltung_id'])?urldecode($_POST['lehrveranstaltung_id']):''); + $lva->fachbereich_id = (isset($_POST['fachbereich_id'])?urldecode($_POST['fachbereich_id']):''); + $lva->ausbildungssemester_id = (isset($_POST['ausbildungssemester_id'])?urldecode($_POST['ausbildungssemester_id']):''); + $lva->lehreinheit_fk = (isset($_POST['lehreinheit_fk'])?urldecode($_POST['lehreinheit_fk']):''); + $lva->lehrform_id = (isset($_POST['lehrform_id'])?urldecode($_POST['lehrform_id']):''); + $lva->gruppe_id = (isset($_POST['gruppe_id'])?urldecode($_POST['gruppe_id']):''); + $lva->nummer = (isset($_POST['nummer'])?urldecode($_POST['nummer']):''); + $lva->bezeichnung = (isset($_POST['bezeichnung'])?urldecode($_POST['bezeichnung']):''); + $lva->kurzbezeichnung = (isset($_POST['kurzbezeichnung'])?urldecode($_POST['kurzbezeichnung']):''); + $lva->semesterwochenstunden = (isset($_POST['semesterwochenstunden'])?urldecode($_POST['semesterwochenstunden']):''); + $lva->gesamtstunden = (isset($_POST['gesamtstunden'])?urldecode($_POST['gesamtstunden']):''); + $lva->wochenrythmus = (isset($_POST['wochenrythmus'])?urldecode($_POST['wochenrythmus']):''); + $lva->start_kw = (isset($_POST['kalenderwoche'])?urldecode($_POST['kalenderwoche']):''); + $lva->stundenblockung = (isset($_POST['stundenblockung'])?urldecode($_POST['stundenblockung']):''); + $lva->koordinator_id = (isset($_POST['koordinator_id'])?urldecode($_POST['koordinator_id']):''); + $lva->plankostenprolektor = (isset($_POST['plankostenprolektor'])?urldecode($_POST['plankostenprolektor']):''); + $lva->planfaktor = (isset($_POST['planfaktor'])?urldecode($_POST['planfaktor']):''); + $lva->planlektoren = (isset($_POST['planlektoren'])?urldecode($_POST['planlektoren']):''); + $lva->raumtyp_id = (isset($_POST['raumtyp_id'])?urldecode($_POST['raumtyp_id']):''); + $lva->raumtypalternativ_id = (isset($_POST['raumtypalternativ_id'])?urldecode($_POST['raumtypalternativ_id']):''); + $lva->bemerkungen = (isset($_POST['bemerkungen'])?urldecode($_POST['bemerkungen']):''); + + //Speichern + if($lva->save()) + { + $return = 'true'; + $errormsg = 'Datensatz erfolgreich gespeichert'; + } + else + { + $return = 'false'; + $errormsg = $lva->errormsg; + } + } + else + { + $return = 'false'; + $errormsg = 'Sie haben keine Berechtigung um diesen Datensatz zu ändern'; + } + } + else + { + $return = 'false'; + $errormsg = 'Studiengang konnte nicht ermittelt werden'; + } + } + else + { + $return = 'false'; + $errormsg = 'Fehlerhafte Parameteruebergabe'; + } + } + elseif(isset($_POST['type']) && $_POST['type']=='lva_delete') + { + /** + * Loescht eine Lehreinheit + */ + + if(isset($_POST['lehreinheit_id']) && is_numeric($_POST['lehreinheit_id'])) + { + $qry = "SELECT kennzahl FROM studiengang WHERE studiengang_pk = (SELECT studiengang_fk FROM lehreinheit WHERE lehreinheit_pk='".$_POST['lehreinheit_id']."')"; + if($row=pg_fetch_object(pg_query($conn_fas,$qry))) + { + $studiengang = $row->kennzahl; + //Ueberpruefen der Berechtigung fuer diesen Studiengang + if($rechte->isBerechtigt('admin', $studiengang, 'd') + || $rechte->isBerechtigt('lva-verwaltung', $studiengang, 'd')) + { + $lva = new lehreinheit($conn_fas); + + //Loeschen + if($lva->delete($_POST['lehreinheit_id'])) + { + $return = 'true'; + $errormsg = 'Datensatz erfolgreich gespeichert'; + } + else + { + $return = 'false'; + $errormsg = $lva->errormsg; + } + } + else + { + $return = 'false'; + $errormsg = 'Sie haben keine Berechtigung um diesen Datensatz zu loeschen'; + } + } + else + { + $return = 'false'; + $errormsg = 'Studiengang konnte nicht ermittelt werden'; + } + } + else + { + $return = 'false'; + $errormsg = 'Fehlerhafte Parameteruebergabe'; + } + } + elseif(isset($_POST['type']) && $_POST['type']=='lva_neu') + { + /** + * Loescht eine Lehreinheit + */ + + if(isset($_POST['lehrveranstaltung_id']) && is_numeric($_POST['lehrveranstaltung_id'])) + { + $qry = "SELECT kennzahl FROM studiengang WHERE studiengang_pk = (SELECT studiengang_fk FROM lehrveranstaltung WHERE lehrveranstaltung_pk='".$_POST['lehrveranstaltung_id']."')"; + if($row=pg_fetch_object(pg_query($conn_fas,$qry))) + { + $studiengang = $row->kennzahl; + //Ueberpruefen der Berechtigung fuer diesen Studiengang + if($rechte->isBerechtigt('admin', $studiengang, 'i') + || $rechte->isBerechtigt('lva-verwaltung', $studiengang, 'i')) + { + //LVA Laden + $lva = new lehrveranstaltung($conn_fas); + $lva->load($_POST['lehrveranstaltung_id']); + + //Daten Übernehmen + $lehreinheit = new lehreinheit($conn_fas); + $lehreinheit->new=true; + $lehreinheit->lehrveranstaltung_id = $_POST['lehrveranstaltung_id']; + $lehreinheit->studiengang_id = $lva->studiengang_id; + $lehreinheit->fachbereich_id = $lva->fachbereich_id; + $lehreinheit->ausbildungssemester_id = $lva->ausbildungssemester_id; + $lehreinheit->kurzbezeichnung = $lva->kurzbezeichnung; + $lehreinheit->bezeichnung = $lva->name; + $lehreinheit->studiensemester_id = $lva->studiensemester_id; + $lehreinheit->lehrform_id = 2; + $lehreinheit->gesamtstunden = 0; + $lehreinheit->faktor = 0; + $lehreinheit->wochenrythmus = 1; + $lehreinheit->start_kw = 0; + $lehreinheit->stundenblockung = 0; + $lehreinheit->planlektoren = 1; + + $lehreinheit->updatevon = $benutzer->variable->fas_id; + + //Speichern + if($lehreinheit->save()) + { + $return = 'true'; + $errormsg = $lehreinheit->lehreinheit_id; + } + else + { + $return = 'false'; + $errormsg = $lehreinheit->errormsg; + } + } + else + { + $return = 'false'; + $errormsg = 'Sie haben keine Berechtigung um diesen Datensatz zu loeschen'; + } + } + else + { + $return = 'false'; + $errormsg = 'Studiengang konnte nicht ermittelt werden'; + } + } + else + { + $return = 'false'; + $errormsg = 'Fehlerhafte Parameteruebergabe'; + } + } + elseif(isset($_POST['type']) && $_POST['type']=='lva_partizipierung') + { + /** + * Teilt eine Partizipierung zu + */ + + if(isset($_POST['quell_lehreinheit_id']) && is_numeric($_POST['quell_lehreinheit_id']) + && isset($_POST['ziel_lehreinheit_id']) && is_numeric($_POST['ziel_lehreinheit_id'])) + { + + $qry = "SELECT kennzahl FROM studiengang WHERE studiengang_pk = (SELECT studiengang_fk FROM lehreinheit WHERE lehreinheit_pk='".$_POST['quell_lehreinheit_id']."')"; + if($row=pg_fetch_object(pg_query($conn_fas,$qry))) + { + $studiengang = $row->kennzahl; + //Ueberpruefen der Berechtigung fuer diesen Studiengang + if($rechte->isBerechtigt('admin', $studiengang, 'u') + || $rechte->isBerechtigt('lva-verwaltung', $studiengang, 'u')) + { + $lva = new lehreinheit($conn_fas); + + if($lva->setPartizipierung($_POST['quell_lehreinheit_id'], $_POST['ziel_lehreinheit_id'])) + { + $return = 'true'; + $errormsg = 'Datensatz erfolgreich gespeichert'; + } + else + { + $return = 'false'; + $errormsg = $lva->errormsg; + } + } + else + { + $return = 'false'; + $errormsg = 'Sie haben keine Berechtigung und diese Aktion durchzufuehren'; + } + } + else + { + $return = 'false'; + $errormsg = 'Studiengang konnte nicht ermittelt werden'; + } + } + else + { + $return = 'false'; + $errormsg = 'Fehlerhafte Parameteruebergabe'; + } + } + elseif(isset($_POST['type']) && $_POST['type']=='lva_mitarbeiter_lehreinheit_zuteilung') + { + /** + * Speichert die Zuteilung eines Mitarbeiters zu einer Lehreinheit + */ + + //Ermitteln des Studienganges zu dem diese Zuteilung gehoert + if(isset($_POST['mitarbeiter_lehreinheit_id']) && is_numeric($_POST['mitarbeiter_lehreinheit_id'])) + { + $qry = "SELECT kennzahl FROM studiengang WHERE studiengang_pk = (SELECT studiengang_fk FROM mitarbeiter_lehreinheit JOIN lehreinheit ON (mitarbeiter_lehreinheit.lehreinheit_fk=lehreinheit_pk) WHERE mitarbeiter_lehreinheit_pk='".$_POST['mitarbeiter_lehreinheit_id']."')"; + if($row=pg_fetch_object(pg_query($conn_fas,$qry))) + { + $studiengang = $row->kennzahl; + //Ueberpruefen der Berechtigung fuer diesen Studiengang + if($rechte->isBerechtigt('admin', $studiengang, 'u') + || $rechte->isBerechtigt('lva-verwaltung', $studiengang, 'u')) + { + $lva = new lehreinheit($conn_fas); + //Werte zuweisen + $lva->new=false; + $lva->mitarbeiter_id = isset($_POST['mitarbeiter_id'])?$_POST['mitarbeiter_id']:''; + $lva->faktor = isset($_POST['faktor'])?$_POST['faktor']:''; + $lva->gesamtstunden_mitarbeiter = isset($_POST['gesamtstunden'])?$_POST['gesamtstunden']:''; + $lva->kosten = isset($_POST['kosten'])?$_POST['kosten']:''; + $lva->lehrfunktion_id = isset($_POST['lehrfunktion_id'])?$_POST['lehrfunktion_id']:''; + $lva->lehreinheit_fk = isset($_POST['lehreinheit_id'])?$_POST['lehreinheit_id']:''; + $lva->updatevon = $benutzer->variable->fas_id; + $lva->mitarbeiter_lehreinheit_id = isset($_POST['mitarbeiter_lehreinheit_id'])?$_POST['mitarbeiter_lehreinheit_id']:''; + + //Speichern + if($lva->save_zuteilung()) + { + $return = 'true'; + $errormsg = 'Datensatz erfolgreich gespeichert'; + } + else + { + $return = 'false'; + $errormsg = $lva->errormsg; + } + } + else + { + $return = 'false'; + $errormsg = 'Sie haben keine Berechtigung um diesen Datensatz zu ändern'; + } + } + else + { + $return = 'false'; + $errormsg = 'Studiengang konnte nicht ermittelt werden'.$qry; + } + } + else + { + $return = 'false'; + $errormsg = 'Fehlerhafte Parameteruebergabe'; + } + } + elseif(isset($_POST['type']) && $_POST['type']=='lva_mitarbeiter_lehreinheit_add') + { + /** + * Fuegt einen Dummy Lektor zu einer Lehreinheit hinzu + */ + + //Ermitteln des Studienganges zu dem diese Zuteilung gehoert + if(isset($_POST['lehreinheit_id']) && is_numeric($_POST['lehreinheit_id'])) + { + $qry = "SELECT kennzahl FROM studiengang WHERE studiengang_pk = (SELECT studiengang_fk FROM lehreinheit WHERE lehreinheit_pk='".$_POST['lehreinheit_id']."')"; + if($row=pg_fetch_object(pg_query($conn_fas,$qry))) + { + $studiengang = $row->kennzahl; + //Ueberpruefen der Berechtigung fuer diesen Studiengang + if($rechte->isBerechtigt('admin', $studiengang, 'i') + || $rechte->isBerechtigt('lva-verwaltung', $studiengang, 'i')) + { + $lva = new lehreinheit($conn_fas); + //Werte zuweisen + $lva->new=true; + $lva->mitarbeiter_id = 2701; //= Dr. Dieter Dummy + $lva->faktor = 1; + $lva->kosten = 0; + $lva->gesamtstunden_mitarbeiter = 0; + $lva->lehrfunktion_id = 2; + $lva->lehreinheit_fk = isset($_POST['lehreinheit_id'])?$_POST['lehreinheit_id']:''; + $lva->updatevon = $benutzer->variable->fas_id; + + //Speichern + if($lva->save_zuteilung()) + { + $return = 'true'; + $errormsg = $lva->mitarbeiter_lehreinheit_id; + } + else + { + $return = 'false'; + $errormsg = $lva->errormsg; + } + } + else + { + $return = 'false'; + $errormsg = 'Sie haben keine Berechtigung um diesen Datensatz zu ändern'; + } + } + else + { + $return = 'false'; + $errormsg = 'Studiengang konnte nicht ermittelt werden'; + } + } + else + { + $return = 'false'; + $errormsg = 'Fehlerhafte Parameteruebergabe'; + } + } + elseif(isset($_POST['type']) && $_POST['type']=='lva_mitarbeiter_lehreinheit_del') + { + /** + * Loescht die zuteilung eines Lektors zu einer Lehrveranstaltung + */ + + //Ermitteln des Studienganges zu dem diese Zuteilung gehoert + if(isset($_POST['mitarbeiter_lehreinheit_id']) && is_numeric($_POST['mitarbeiter_lehreinheit_id'])) + { + $qry = "SELECT kennzahl FROM studiengang WHERE studiengang_pk = (SELECT studiengang_fk FROM mitarbeiter_lehreinheit JOIN lehreinheit ON (mitarbeiter_lehreinheit.lehreinheit_fk=lehreinheit_pk) WHERE mitarbeiter_lehreinheit_pk='".$_POST['mitarbeiter_lehreinheit_id']."')"; + if($row=pg_fetch_object(pg_query($conn_fas,$qry))) + { + $studiengang = $row->kennzahl; + //Ueberpruefen der Berechtigung fuer diesen Studiengang + if($rechte->isBerechtigt('admin', $studiengang, 'u') + || $rechte->isBerechtigt('lva-verwaltung', $studiengang, 'u')) + { + $lva = new lehreinheit($conn_fas); + + //Loeschen des DS + if($lva->delete_zuteilung($_POST['mitarbeiter_lehreinheit_id'])) + { + $return = 'true'; + $errormsg = 'Datensatz erfolgreich gespeichert'; + } + else + { + $return = 'false'; + $errormsg = $lva->errormsg; + } + } + else + { + $return = 'false'; + $errormsg = 'Sie haben keine Berechtigung um diesen Datensatz zu ändern'; + } + } + else + { + $return = 'false'; + $errormsg = 'Studiengang konnte nicht ermittelt werden'; + } + } + else + { + $return = 'false'; + $errormsg = 'Fehlerhafte Parameteruebergabe'; + } + } + elseif(isset($_POST['type']) && $_POST['type']=='lva_mitarbeiter_lehreinheit_auswahladd') + { + /** + * Fuegt eine Funktion zu einem Mitarbeiter hinzu + */ + + //Ermitteln des Studienganges zu dem diese Zuteilung gehoert + if(isset($_POST['lehreinheit_id']) && is_numeric($_POST['lehreinheit_id']) + && isset($_POST['mitarbeiter_id']) && is_numeric($_POST['mitarbeiter_id']) ) + { + $qry = "SELECT kennzahl, studiengang_pk, fachbereich_fk FROM studiengang JOIN lehreinheit ON (studiengang_fk=studiengang_pk) WHERE lehreinheit_pk = '".$_POST['lehreinheit_id']."'"; + if($row=pg_fetch_object(pg_query($conn_fas,$qry))) + { + $studiengang_kz = $row->kennzahl; + $studiengang_id = $row->studiengang_pk; + $fachbereich_id = $row->fachbereich_fk; + $studiensemester_id = getStudiensemesterIdFromName($conn_fas, $benutzer->variable->semester_aktuell); + //Ueberpruefen der Berechtigung fuer diesen Studiengang + if($rechte->isBerechtigt('admin', $studiengang_kz, 'u') + || $rechte->isBerechtigt('lva-verwaltung', $studiengang_kz, 'u')) + { + $fkt = new funktion($conn_fas); + //Nachschauen ob diese Funktion bereits existiert + if($fkt->FunktionExists($_POST['mitarbeiter_id'], $studiengang_id, $fachbereich_id, $studiensemester_id, 1)) + { + $return = 'false'; + $errormsg = 'Dieser Lektor befindet sich bereits in der Liste'; + } + else + { + if($fkt->errormsg!='') //Falls ein Fehler aufgetreten ist + { + $return = 'false'; + $errormsg = $fkt->errormsg; + } + else + { + //Funktion anlegen + $fkt->new = true; + $fkt->mitarbeiter_id = $_POST['mitarbeiter_id']; + $fkt->studiensemester_id = $studiensemester_id; + $fkt->studiengang_id = $studiengang_id; + $fkt->fachbereich_id = $fachbereich_id; + $fkt->funktion = 1; //Lektor + $fkt->erhalter_id = 1; //TW + + if($fkt->save()) + { + $return = 'true'; + $errormsg = 'Datensatz erfolgreich angelegt'; + } + else + { + $return = 'false'; + $errormsg = $fkt->errormsg; + } + + } + } + } + else + { + $return = 'false'; + $errormsg = 'Sie haben keine Berechtigung um diesen Datensatz zu ändern'; + } + } + else + { + $return = 'false'; + $errormsg = 'Studiengang konnte nicht ermittelt werden'; + } + } + else + { + $return = 'false'; + $errormsg = 'Fehlerhafte Parameteruebergabe'; + } + } + elseif(isset($_POST['type']) && $_POST['type']=='variablechange') /**********************SONSTIGES*****************/ + { + /** + * Aendert die Variable Studiensemester + */ + if(isset($_POST['stsem'])) + { + if($benutzer->setVariableStudiensemester($user,$_POST['stsem'])) + { + $return = 'true'; + $errormsg = getStudiensemesterIdFromName($conn_fas, $_POST['stsem']); + } + else + { + $return = 'false'; + $errormsg = $benutzer->errormsg; + } + } + else + { + $return = 'false'; + $errormsg = 'Falsche Paramenteruebergabe'; + } + } + } +?> + + + + ]]> + + + + \ No newline at end of file diff --git a/rdf/fas/email.rdf.php b/rdf/fas/email.rdf.php new file mode 100644 index 000000000..ea9f5bb8d --- /dev/null +++ b/rdf/fas/email.rdf.php @@ -0,0 +1,86 @@ +'; +// DAO +include('../../vilesci/config.inc.php'); +include_once('../../include/fas/email.class.php'); + +// Datenbank Verbindung +if (!$conn = @pg_pconnect(CONN_STRING_FAS)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + +$rdf_url='http://www.technikum-wien.at/email'; + +?> + + + + + +load_pers($pers_id); + + + foreach ($emailDAO->result as $email) + { + ?> + + + email_id; ?> + person_id; ?> + email; ?>]]> + name; ?> + typ; ?> + zustelladresse?'Ja':'Nein'); ?> + + + load($email_id); +?> + + + email_id; ?> + person_id; ?> + email; ?>]]> + name; ?> + typ; ?> + zustelladresse?'Ja':'Nein'); ?> + + + + + + + + \ No newline at end of file diff --git a/rdf/fas/fachbereich.rdf.php b/rdf/fas/fachbereich.rdf.php new file mode 100644 index 000000000..c6db9030c --- /dev/null +++ b/rdf/fas/fachbereich.rdf.php @@ -0,0 +1,54 @@ +'; +// DAO +include('../../vilesci/config.inc.php'); +include('../../include/fas/fachbereich.class.php'); + +// Datenbank Verbindung +if (!$conn = @pg_pconnect(CONN_STRING_FAS)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + +$rdf_url='http://www.technikum-wien.at/fachbereich'; + +?> + + + + + +getAll(); + + foreach ($fachbereichDAO->result as $fachbereich) + { + ?> + + + fachbereich_id; ?> + name; ?> + + + + + + + + \ No newline at end of file diff --git a/rdf/fas/funktion_id.rdf.php b/rdf/fas/funktion_id.rdf.php new file mode 100644 index 000000000..8061da81d --- /dev/null +++ b/rdf/fas/funktion_id.rdf.php @@ -0,0 +1,80 @@ +'; +// DAO +include('../../vilesci/config.inc.php'); +include('../../include/fas/studiensemester.class.php'); + +// Datenbank Verbindung +if (!$conn = @pg_pconnect(CONN_STRING_FAS)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + +$rdf_url='http://www.technikum-wien.at/funktion_id'; + +?> + + + + + + + + + 0 + Mitarbeiter + + + + + 1 + Lektor + + + + + 2 + Fachbereichskoordinator + + + + + 3 + Assistenz + + + + + 4 + Rektor + + + + + 5 + Studiengangsleiter + + + + + 6 + Fachbereichsleiter + + + + + + \ No newline at end of file diff --git a/rdf/fas/funktionen.rdf.php b/rdf/fas/funktionen.rdf.php new file mode 100644 index 000000000..95b4f08ef --- /dev/null +++ b/rdf/fas/funktionen.rdf.php @@ -0,0 +1,255 @@ +'; +// DAO +include('../../vilesci/config.inc.php'); +include('../../include/functions.inc.php'); +include('../../include/fas/funktion.class.php'); +include('../../include/fas/studiensemester.class.php'); +include('../../include/fas/studiengang.class.php'); +include('../../include/fas/fachbereich.class.php'); +include('../../include/fas/benutzer.class.php'); + + +// Datenbank Verbindung +if (!$conn = @pg_pconnect(CONN_STRING_FAS)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + +if (!$conn_calva = @pg_pconnect(CONN_STRING)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + +$user = get_uid(); + +$rdf_url='http://www.technikum-wien.at/funktionen'; + +function addCDATA($str) +{ + return ($str==' '?' ':''); +} +?> + + + + + +loadVariables($user)) + die("error:".$benutzer->errormsg); + + $stsem = $benutzer->variable->semester_aktuell; + + $qry = "SELECT studiensemester_pk from studiensemester where art="; + if(substr($stsem,0,2)=='WS') + $qry .="1"; + else + $qry .="2"; + $qry .= " AND jahr="; + $qry .= substr($stsem,2,4); + $stsem_id=''; + + if($result=pg_query($conn,$qry)) + if($row=pg_fetch_object($result)) + $stsem_id=$row->studiensemester_pk; + } + else + $stsem_id=''; + + // Funktionen holen + $funktionenDAO=new funktion($conn); + $funktionenDAO->load_pers($mitarbeiter_id, $stsem_id); + + foreach ($funktionenDAO->result as $funktionen) + { + + if($leerzeichencodierung) + { + if ($funktion->studiensemester_id=='') $funktion->studiensemester_id=' '; + if ($funktion->studiengang_id=='') $funktion->studiengang_id=' '; + if ($funktion->studiengang_id=='') $funktion->studiengang_id=' '; + if ($funktion->fachbereich_id=='') $funktion->fachbereich_id=' '; + if ($funktion->name=='') $funktion->name=' '; + if ($funktion->funktion=='') $funktion->funktion=' '; + if ($funktion->beschart1=='') $funktion->beschart1=' '; + if ($funktion->beschart2='') $funktion->beschart2=' '; + if ($funktion->verwendung='') $funktion->verwendung=' '; + if ($funktion->hauptberuf='') $funktion->hauptberuf=' '; + if ($funktion->hauptberuflich='') $funktion->hauptberuflich=' '; + if ($funktion->entwicklungsteam='') $funktion->entwicklungsteam=' '; + if ($funktion->besonderequalifikation='') $funktion->besonderequalifikation=' '; + if ($funktion->ausmass='') $funktion->ausmass=' '; + + } +?> + + + funktion_id; ?> + mitarbeiter_id; ?> + studiensemester_id; ?> +load($funktionen->studiensemester_id)) + echo $stsem_obj->errormsg; + $bezeichnung = ($stsem_obj->art=='1'?'WS':'SS').$stsem_obj->jahr; + if($leerzeichencodierung && $bezeichnung =='') + $bezeichnung = ' '; +?> + + erhalter_id=='1'?'Technikum Wien':'unbekannt'); ?> + studiengang_id; ?> +load($funktionen->studiengang_id); + $bezeichnung = $stg_obj->kuerzel; + if($stg_obj->studiengangsart==1) + $bezeichnung = '(B)'.$bezeichnung; + elseif($stg_obj->studiengangsart==2) + $bezeichnung = '(M)'.$bezeichnung; + elseif($stg_obj->studiengangsart==3) + $bezeichnung = '(D)'.$bezeichnung; + if($leerzeichencodierung && $bezeichnung =='') + $bezeichnung = ' '; +?> + + fachbereich_id; ?> +load($funktionen->fachbereich_id); + $bezeichnung = $fachb_obj->name; + if($leerzeichencodierung && $bezeichnung =='') + $bezeichnung = ' '; +?> + + name; ?> + funktion; ?> +getNameFunktion($funktionen->funktion); + if($leerzeichencodierung && $bezeichnung =='') + $bezeichnung = ' '; +?> + + beschart1; ?> +getNameBeschart1($funktionen->beschart1); + if($leerzeichencodierung && $bezeichnung =='') + $bezeichnung = ' '; +?> + + beschart2; ?> +getNameBeschart2($funktionen->beschart2); + if($leerzeichencodierung && $bezeichnung =='') + $bezeichnung = ' '; +?> + + verwendung; ?> +getNameVerwendung($funktionen->verwendung); + if($leerzeichencodierung && $bezeichnung =='') + $bezeichnung = ' '; +?> + + hauptberuf; ?> +getNameHauptberuf($funktionen->hauptberuf); + if($leerzeichencodierung && $bezeichnung =='') + $bezeichnung = ' '; +?> + + hauptberuflich?'Ja':'Nein'); ?> + entwicklungsteam?'Ja':'Nein'); ?> + besonderequalifikation; ?> +getNameBesonderequalifikation($funktionen->besonderequalifikation); + if($leerzeichencodierung && $bezeichnung =='') + $bezeichnung = ' '; +?> + + ausmass; ?> +getNameAusmass($funktionen->ausmass); + if($leerzeichencodierung && $bezeichnung =='') + $bezeichnung = ' '; +?> + + + +load($funktion_id); + ?> + + + funktion_id; ?> + mitarbeiter_id; ?> + studiensemester_id; ?> + erhalter_id; ?> + studiengang_id; ?> + fachbereich_id; ?> + name; ?> + funktion; ?> + beschart1; ?> + beschart2; ?> + verwendung; ?> + hauptberuf; ?> + hauptberuflich?'Ja':'Nein'); ?> + entwicklungsteam?'Ja':'Nein'); ?> + besonderequalifikation; ?> + ausmass; ?> + + + + + \ No newline at end of file diff --git a/rdf/fas/generate_kuerzel.rdf.php b/rdf/fas/generate_kuerzel.rdf.php new file mode 100644 index 000000000..dddcaf306 --- /dev/null +++ b/rdf/fas/generate_kuerzel.rdf.php @@ -0,0 +1,155 @@ +'; + + // Clean stuff from a string + function clean_string($string) + { + $trans = array("ä" => "ae", + "Ä" => "Ae", + "ö" => "oe", + "Ö" => "Oe", + "ü" => "ue", + "Ü" => "Ue", + "á" => "a", + "à" => "a", + "é" => "e", + "è" => "e", + "ó" => "o", + "ò" => "o", + "í" => "i", + "ì" => "i", + "ú" => "u", + "ù" => "u", + "ß" => "ss"); + $string = strtr($string, $trans); + return ereg_replace("[^a-zA-Z0-9]", "", $string); + //[:space:] + } + + $return=false; + $msg='unbekannter Fehler'; + + //Connection zu FAS DB herstellen + if(!$conn = pg_connect(CONN_STRING_FAS)) + { + $return = 'false'; + $msg = 'Datenbankverbindung konnte nicht hergestellt werden'; + } + + if(isset($_GET['type'])) + $type=$_GET['type']; + else + $type=null; + + if(isset($_GET['vorname'])) + $vorname = $_GET['vorname']; + else + $vorname = null; + + if(isset($_GET['nachname'])) + $nachname = $_GET['nachname']; + else + $nachname = null; + + if($type!=null && $vorname!=null && $nachname!=null) + { + if($type=='kurzbz') + { + $kurzbz=''; + $mitarbeiter = new mitarbeiter($conn); + $nachname = clean_string($nachname); + $vorname = clean_string($vorname); + for($nn=6,$vn=2;$nn!=0;$nn--,$vn++) + { + $kurzbz = substr($nachname,0,$nn); + $kurzbz .= substr($vorname,0,$vn); + + if(!$mitarbeiter->kurzbz_exists($kurzbz)) + if($mitarbeiter->errormsg=='') + break; + } + + if($mitarbeiter->kurzbz_exists($kurzbz)) + { + $return = 'false'; + $msg = 'Es konnte keine Kurzbezeichnung ermittelt werden'; + } + else + { + $return = 'true'; + $msg = $kurzbz; + } + } + if($type=='uid') + { + $return = 'true'; + $nachname = strtolower(clean_string($nachname)); + $vorname = strtolower(clean_string($vorname)); + $uid=''; + $mitarbeiter = new mitarbeiter($conn); + + for($nn=8,$vn=0;$nn!=0;$nn--,$vn++) + { + $uid = substr($nachname,0,$nn); + $uid .= substr($vorname,0,$vn); + + if(!$mitarbeiter->uid_exists($uid)) + if($mitarbeiter->errormsg=='') + break; + //echo "
    $uid"; + } + + if($mitarbeiter->uid_exists($uid)) + { + $return = 'false'; + $msg = 'Es konnte keine UID ermittelt werden'; + } + else + { + $return = 'true'; + $msg = $uid; + } + } + } + else + { + $return = false; + $msg = 'Fehler bei der Parameteruebergabe'; + } + + $rdf_url='http://www.technikum-wien.at/generate_kurzbz'; +?> + + + + + + + + + + + \ No newline at end of file diff --git a/rdf/fas/gruppen.rdf.php b/rdf/fas/gruppen.rdf.php new file mode 100644 index 000000000..22781399a --- /dev/null +++ b/rdf/fas/gruppen.rdf.php @@ -0,0 +1,82 @@ +'; +// DAO +require('../../vilesci/config.inc.php'); +require('../../include/fas/gruppe.class.php'); +require('../../include/fas/benutzer.class.php'); +require('../../include/functions.inc.php'); +require('../../include/fas/functions.inc.php'); + +// Datenbank Verbindung +if (!$conn = pg_pconnect(CONN_STRING_FAS)) + die('Es konnte keine Verbindung zum Server aufgebaut werden!'); + +if(!$conn_vilesci = pg_pconnect(CONN_STRING)) + die('Es konnte keine Verbindung zur Datenbank hergestellt werden!'); + +$rdf_url='http://www.technikum-wien.at/gruppen'; + +$user = get_uid(); +$benutzer = new benutzer($conn_vilesci); +if(!$benutzer->loadVariables($user)) + die($benutzer->errormsg); + +?> + + + + + +load_gruppen($_GET['stg'], getStudiensemesterIdFromName($conn, $benutzer->variable->semester_aktuell), $_GET['ausbsem']); + $arr = array(); + foreach ($gruppen_obj->result as $grp) + { + $arr['id'][] = $grp->gruppe_id; + $arr['fullname'][] = $grp->fullname; + } + if(isset($arr['id'])) + { + array_multisort($arr['fullname'],$arr['id']); + for($i=0;$i + + + + + + + + + + + + \ No newline at end of file diff --git a/rdf/fas/hauptberuf.rdf.php b/rdf/fas/hauptberuf.rdf.php new file mode 100644 index 000000000..f00a6dc07 --- /dev/null +++ b/rdf/fas/hauptberuf.rdf.php @@ -0,0 +1,114 @@ +'; +// DAO +include('../../vilesci/config.inc.php'); + +$rdf_url='http://www.technikum-wien.at/hauptberuf'; + +?> + + + + + + + + + 0 + Universität + + + + + 1 + Fachhochschule + + + + + 2 + Andere postsekundäre Bildungseinrichtung + + + + + 3 + Allgemeinbildende höhere Schule + + + + + 4 + Berufsbildende höhere Schule + + + + + 5 + Andere Schule + + + + + 6 + Öffentlicher Sektor + + + + + 7 + Unternehmenssektor + + + + + 8 + Freiberuflich tätig + + + + + 9 + Privater gemeinnütziger Sektor + + + + + 10 + Ausserhochschulische Forschungseinrichtung + + + + + 11 + Internationale Organisation + + + + + 12 + Sonstiges + + + + + + + + \ No newline at end of file diff --git a/rdf/fas/lehreinheiten.rdf.php b/rdf/fas/lehreinheiten.rdf.php new file mode 100644 index 000000000..3f3aa5d15 --- /dev/null +++ b/rdf/fas/lehreinheiten.rdf.php @@ -0,0 +1,177 @@ +'; +// DAO +include('../../vilesci/config.inc.php'); +include('../../include/functions.inc.php'); +include('../../include/fas/functions.inc.php'); +include('../../include/fas/benutzer.class.php'); +include('../../include/fas/lehreinheit.class.php'); +include('../../include/fas/raumtyp.class.php'); + +error_reporting(E_ALL); +ini_set('display_errors','1'); +// Datenbank Verbindung +if (!$conn = @pg_pconnect(CONN_STRING)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + +if (!$conn_fas = @pg_pconnect(CONN_STRING_FAS)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + +$studiengang_id = isset($_GET['studiengang_id'])?$_GET['studiengang_id']:''; +$lehreinheit_id = isset($_GET['lehreinheit_id'])?$_GET['lehreinheit_id']:''; +$gruppe_id = isset($_GET['gruppe_id'])?$_GET['gruppe_id']:''; + +$user = get_uid(); +$benutzer = new benutzer($conn); +if(!$benutzer->loadVariables($user)) + die("error:".$benutzer->errormsg); + +// LVAs holen +$lvaDAO=new lehreinheit($conn_fas); +if($lehreinheit_id!='') +{ + if(!$lvaDAO->getLehreinheiten(null,null,null,$lehreinheit_id)) + die("error:".$lvaDAO->errormsg); +} +elseif($gruppe_id!='') +{ + if(!$lvaDAO->getLehreinheitenfromGruppe($gruppe_id, getStudiensemesterIdFromName($conn_fas, $benutzer->variable->semester_aktuell))) + die("error:".$lvaDAO->errormsg); +} +else +{ + if(!$lvaDAO->getLehreinheiten($studiengang_id, null, getStudiensemesterIdFromName($conn_fas, $benutzer->variable->semester_aktuell),null,true)) + die("error:".$lvaDAO->errormsg); +} + +$lehreinheiten = $lvaDAO->result; +$raumtyp_obj = new raumtyp($conn_fas); + +$rdf_url='http://www.technikum-wien.at/lehreinheiten'; + +?> + + + +lehreinheit_fk; + $currentLPK=$lva->lehreinheit_id; + $descr.=" + lehreinheit_id."\" about=\"".$rdf_url.'/'.$lva->lehreinheit_id."\" > + ".$lva->lehreinheit_id." + ".$lva->studiengang_id." + studiengang_kurzbz."]]> + ".$lva->studiensemester_id." + ".$lva->studiensemester_kurzbz." + ".$lva->lehrveranstaltung_id." + ".$lva->fachbereich_id." + fachbereich_bezeichnung."]]> + ".$lva->ausbildungssemester_id." + ".$lva->ausbildungssemester_semester." + ".$lva->ausbildungssemester_kurzbz." + ".$lva->lehreinheit_fk." + ".$lva->lehrform_id." + ".$lva->lehrform_kurzbz." + ".$lva->gruppe_id." + ".$lva->gruppe_kurzbz." + ".$lva->nummer." + bezeichnung."]]> + kurzbezeichnung."]]> + ".$lva->semesterwochenstunden." + ".$lva->gesamtstunden." + ".$lva->plankostenprolektor." + ".$lva->planfaktor." + ".$lva->planlektoren." + ".$lva->raumtyp_id.""; + if($raumtyp_obj->load($lva->raumtyp_id)) + $bezeichnung = $raumtyp_obj->bezeichnung; + else + $bezeichnung = ''; + $descr.=" + + ".$lva->raumtypalternativ_id.""; + if($raumtyp_obj->load($lva->raumtypalternativ_id)) + $bezeichnung = $raumtyp_obj->bezeichnung; + else + $bezeichnung = ''; + $descr.=" + + bemerkungen."]]> + ".$lva->wochenrythmus." + ".$lva->start_kw." + ".$lva->stundenblockung." + ".$lva->koordinator_id." + ".$lva->koordinator_nachname." + ".$lva->koordinator_vorname." + ".$lva->updateamum." + ".$lva->updatevon." + + "; + + if($currentLFK!=0 && $currentLFK!=-1) + { + $hier_arr[$currentLFK][] = $currentLPK; + } + else + { + if(!array_key_exists($currentLPK,$hier_arr)) + $hier_arr[$currentLPK]=''; + } + } + + foreach ($hier_arr as $hkey=>$hval) + { + if(is_array($hier_arr[$hkey])) + { + $hier.=" + + "; + foreach ($hier_arr[$hkey] as $elem) + $hier .= " + "; + $hier.= " + + "; + } + else + $hier.=" + "; + } + + $hier=" + ".$hier." + "; + echo $descr; + echo $hier; +} +?> + + + diff --git a/rdf/fas/lehrform.rdf.php b/rdf/fas/lehrform.rdf.php new file mode 100644 index 000000000..a9a64c3d7 --- /dev/null +++ b/rdf/fas/lehrform.rdf.php @@ -0,0 +1,53 @@ +'; +// DAO +include('../../vilesci/config.inc.php'); +include('../../include/fas/lehrform.class.php'); + +// Datenbank Verbindung +if (!$conn = @pg_pconnect(CONN_STRING_FAS)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + +$rdf_url='http://www.technikum-wien.at/lehrform'; + +?> + + + + + +getAll(); + + foreach ($lehrformDAO->result as $lehrform) + { + ?> + + + lehrform_id; ?> + bezeichnung; ?> + kurzbezeichnung; ?> + standardfaktor; ?> + + + + + \ No newline at end of file diff --git a/rdf/fas/lehrveranstaltungen.rdf.php b/rdf/fas/lehrveranstaltungen.rdf.php new file mode 100644 index 000000000..7c1ff14c4 --- /dev/null +++ b/rdf/fas/lehrveranstaltungen.rdf.php @@ -0,0 +1,95 @@ +'; +// DAO +error_reporting(E_ALL); +ini_set('display_errors','1'); + +require('../../vilesci/config.inc.php'); +require('../../include/fas/lehrveranstaltung.class.php'); +require('../../include/functions.inc.php'); +require('../../include/fas/benutzer.class.php'); +require('../../include/fas/functions.inc.php'); +require('../../include/fas/fachbereich.class.php'); +require('../../include/fas/ausbildungssemester.class.php'); + +// Datenbank Verbindung +if (!$conn_fas = @pg_pconnect(CONN_STRING_FAS)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + +if (!$conn = @pg_pconnect(CONN_STRING)) +$error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + +$studiengang_id = isset($_GET['studiengang_id'])?$_GET['studiengang_id']:''; +$ausbildungssemester_id = isset($_GET['ausbildungssemester_id'])?$_GET['ausbildungssemester_id']:null; + +$user = get_uid(); +$benutzer = new benutzer($conn); +$benutzer->loadVariables($user); +$studiensemester_id = getStudiensemesterIdFromName($conn_fas, $benutzer->variable->semester_aktuell); + +$rdf_url='http://www.technikum-wien.at/lehrveranstaltung'; +?> + + + + + +load_lva($studiengang_id, $studiensemester_id, $ausbildungssemester_id); + + foreach ($lehrveranstaltungDAO->result as $lehrveranstaltung) + { + ?> + + + lehrveranstaltung_id; ?> + art; ?> + ausbildungssemester_id; ?> +load($lehrveranstaltung->ausbildungssemester_id); +?> + name; ?> + beschreibung; ?> + ectspunkte; ?> + fachbereich_id; ?> +load($lehrveranstaltung->fachbereich_id); +?> + name; ?> + kategorie; ?> + kurzbezeichnung; ?> + name; ?> + notenlektor_id; ?> + nummer; ?> + nummerintern; ?> + sortierung; ?> + studentenwochenstunden; ?> + studiengang_id; ?> + studiensemester_id; ?> + updateamum; ?> + updatevon; ?> + + + + + \ No newline at end of file diff --git a/rdf/fas/mitarbeiter.rdf.php b/rdf/fas/mitarbeiter.rdf.php new file mode 100644 index 000000000..dc64b9646 --- /dev/null +++ b/rdf/fas/mitarbeiter.rdf.php @@ -0,0 +1,209 @@ +'; +// DAO +include('../../vilesci/config.inc.php'); +include_once('../../include/fas/person.class.php'); +include_once('../../include/fas/mitarbeiter.class.php'); +require('../../include/fas/benutzer.class.php'); +require('../../include/fas/functions.inc.php'); +require('../../include/functions.inc.php'); +$error_msg=''; +// Datenbank Verbindung + if (!$conn = @pg_pconnect(CONN_STRING_FAS)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + + if(!$conn_vilesci = @pg_pconnect(CONN_STRING)) + $error_msg.='Es konnte keine Verbindung zum Server aufgebaut werden!'; +/** + * Fuegt CDATA String hinzu falls String nicht leerzeichencodiert ist + */ +function addCDATA($str) +{ + return ($str==' '?' ':''); +} + +function convdate($date) +{ + list($y,$m,$d) = explode('-',$date); + return $d.'.'.$m.'.'.$y; +} + +//Parameter holen +if (isset($_GET['mitarbeiter_id'])) + $mitarbeiter_id = $_GET['mitarbeiter_id']; +else + $mitarbeiter_id=null; + +if (isset($_GET['fix'])) + $fix = $_GET['fix']; +else + $fix=null; + +if (isset($_GET['stgl'])) + $stgl = $_GET['stgl']; +else + $stgl=null; + +if (isset($_GET['fbl'])) + $fbl = $_GET['fbl']; +else + $fbl=null; + +if (isset($_GET['aktiv'])) + $aktiv = $_GET['aktiv']; +else + $aktiv=null; + +if (isset($_GET['karenziert'])) + $karenziert = $_GET['karenziert']; +else + $karenziert=null; + +if (isset($_GET['ausgeschieden'])) + $ausgeschieden = $_GET['ausgeschieden']; +else + $ausgeschieden=null; + +if (isset($_GET['leerzeichencodierung'])) + $leerzeichencodierung=true; +else + $leerzeichencodierung=false; + +$user = get_uid(); +$benutzer = new benutzer($conn_vilesci); +if(!$benutzer->loadVariables($user)) + die($benutzer->errormsg); + +// Mitarbeiter holen +$mitarbeiterDAO=new mitarbeiter($conn); +$mitarbeiterDAO->getMitarbeiter($mitarbeiter_id, $fix, $stgl, $fbl, $aktiv, $karenziert, $ausgeschieden,false,getStudiensemesterIdFromName($conn, $benutzer->variable->semester_aktuell)); + +$rdf_url='http://www.technikum-wien.at/mitarbeiter'; + +?> + + + + + +result as $mitarbeiter) +{ + //if ($mitarbeiter->titelpre=='') $mitarbeiter->titelpre='​'; + //Konvertierung der Leerzeichen damit die Sortierung funktioniert + //Wird nur konvertier wenn die Daten in den tree geladen werden + //Nicht wenn die Details fuer einen Mitarbeiter geladen werden + //Funktioniert NICHT zusammen mit CDATA -> addCDATA() verwenden + if($leerzeichencodierung) + { + if ($mitarbeiter->familienname=='') $mitarbeiter->familienname=' '; + if ($mitarbeiter->vorname=='') $mitarbeiter->vorname=' '; + if ($mitarbeiter->vornamen=='') $mitarbeiter->vornamen=' '; + if ($mitarbeiter->anrede=='') $mitarbeiter->anrede=' '; + if ($mitarbeiter->geschlecht=='') $mitarbeiter->geschlecht=' '; + if ($mitarbeiter->gebort=='') $mitarbeiter->gebort=' '; + if ($mitarbeiter->staatsbuergerschaft=='') $mitarbeiter->staatsbuergerschaft=' '; + if ($mitarbeiter->familienstand=='') $mitarbeiter->familienstand=' '; + if ($mitarbeiter->svnr=='') $mitarbeiter->svnr=' '; + if ($mitarbeiter->anzahlderkinder=='') $mitarbeiter->anzahlderkinder=' '; + if ($mitarbeiter->ersatzkennzeichen=='') $mitarbeiter->ersatzkennzeichen=' '; + if ($mitarbeiter->bemerkung=='') $mitarbeiter->bemerkung=' '; + if ($mitarbeiter->aktstatus=='') $mitarbeiter->aktstatus=' '; + if ($mitarbeiter->titelpost=='') $mitarbeiter->titelpost=' '; + if ($mitarbeiter->titelpre=='') $mitarbeiter->titelpre=' '; + if ($mitarbeiter->uid=='') $mitarbeiter->uid=' '; + if ($mitarbeiter->gebnation=='') $mitarbeiter->gebnation=' '; + if ($mitarbeiter->qualifikation=='') $mitarbeiter->qualifikation=' '; + if ($mitarbeiter->hauptberuf=='') $mitarbeiter->hauptberuf=' '; + if ($mitarbeiter->persnr=='') $mitarbeiter->persnr=' '; + if ($mitarbeiter->kurzbez=='') $mitarbeiter->kurzbez=' '; + if ($mitarbeiter->stundensatz=='') $mitarbeiter->stundensatz=' '; + if ($mitarbeiter->ausbildung=='') $mitarbeiter->ausbildung=' '; + } + + ?> + + + person_id; ?> + familienname); ?> + vorname; ?> + vornamen; ?> + anrede; ?> + geschlecht; ?> + gebdat!=''?convdate($mitarbeiter->gebdat):''); ?> + gebdat; ?> + gebort; ?> + staatsbuergerschaft; ?> + familienstand; ?> + familienstand_bezeichnung; ?> + svnr; ?> + anzahlderkinder; ?> + ersatzkennzeichen; ?> + bemerkung); ?> + aktstatus; ?> + aktstatus_bezeichnung; ?> + bismelden?'Ja':'Nein'); ?> + titelpre); ?> + titelpost); ?> + uid; ?> + gebnation; ?> + mitarbeiter_id; ?> + beginndatum!=''?date('d.m.Y',strtotime($mitarbeiter->beginndatum)):''); ?> + beginndatum; ?> + akadgrad_bezeichnung; ?> + habilitation_bezeichnung; ?> + mitgliedentwicklungsteam?'Ja':'Nein'); ?> + qualifikation; ?> + hauptberuflich?'Ja':'Nein'); ?> + hauptberuf; ?> + semesterwochenstunden; ?> + persnr; ?> + beendigungsdatum)>0?date('d.m.Y',strtotime($mitarbeiter->beendigungsdatum)):''); ?> + beendigungsdatum; ?> + ausgeschieden_bezeichnung; ?> + kurzbez); ?> + stundensatz ?> + ausbildung ?> + ausbildung_bezeichnung ?> + aktiv_bezeichnung; ?> + updateamum))<7*24*60*60) + { + $qry = "Select uid from tbl_variable where name='fas_id' AND wert='$mitarbeiter->updatevon'"; + if($result=pg_query($conn_vilesci,$qry)) + if($row=pg_fetch_object($result)) + echo $row->uid; + } + ?> + + + + + + + + \ No newline at end of file diff --git a/rdf/fas/mitarbeiterlehreinheiten.rdf.php b/rdf/fas/mitarbeiterlehreinheiten.rdf.php new file mode 100644 index 000000000..cdc381366 --- /dev/null +++ b/rdf/fas/mitarbeiterlehreinheiten.rdf.php @@ -0,0 +1,103 @@ +'; +// DAO +include('../../vilesci/config.inc.php'); +include('../../include/functions.inc.php'); +include('../../include/fas/benutzer.class.php'); +include('../../include/fas/lehreinheit.class.php'); +include('../../include/fas/person.class.php'); +include('../../include/fas/mitarbeiter.class.php'); + +error_reporting(E_ALL); +ini_set('display_errors','1'); + +// Datenbank Verbindung +if (!$conn = @pg_pconnect(CONN_STRING)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + +if (!$conn_fas = @pg_pconnect(CONN_STRING_FAS)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + +$lehreinheit_id = isset($_GET['lehreinheit_id'])?$_GET['lehreinheit_id']:''; +$mitarbeiter_id = isset($_GET['mitarbeiter_id'])?$_GET['mitarbeiter_id']:''; +$mitarbeiter_lehreinheit_id = isset($_GET['mitarbeiter_lehreinheit_id'])?$_GET['mitarbeiter_lehreinheit_id']:''; + +$user = get_uid(); +$benutzer = new benutzer($conn); +if(!$benutzer->loadVariables($user)) + die("error:".$benutzer->errormsg); + +// LVAs holen +$lvaDAO=new lehreinheit($conn_fas); + +if($lehreinheit_id!='') +{ + if($mitarbeiter_id!='') + { + //Lade einen bestimmten zugeteilten Mitarbeiter + if(!$lvaDAO->load_zuteilung($lehreinheit_id,$mitarbeiter_id)) + die($lvaDAO->errormsg); + } + else + { + //Lade alle zugeteilten Mitarbeiter + if(!$lvaDAO->load_zuteilung($lehreinheit_id)) + die($lvaDAO->errormsg); + } +} +elseif($mitarbeiter_lehreinheit_id!='') +{ + if(!$lvaDAO->load_mitarbeiterzuteilung($mitarbeiter_lehreinheit_id)) + die($lvaDAO->errormsg); +} +$malehreinheiten = $lvaDAO->result; + + +$rdf_url='http://www.technikum-wien.at/mitarbeiterlehreinheiten'; + +?> + + + + +load_mitarbeiter($maleh->mitarbeiter_id); + + echo " + mitarbeiter_lehreinheit_id."\" about=\"".$rdf_url.'/'.$maleh->mitarbeiter_lehreinheit_id."\" > + ".$maleh->mitarbeiter_lehreinheit_id." + ".$maleh->mitarbeiter_id." + ".$maleh->lehreinheit_fk." + ".$maleh->lehrfunktion_id." + ".$maleh->kosten." + ".$maleh->faktor." + ".$maleh->gesamtstunden_mitarbeiter." + ".$mitarbeiter->familienname." + ".$mitarbeiter->vorname." + + "; +} +?> + + + + diff --git a/rdf/fas/mitarbeiterlehreinheitenauswahl.rdf.php b/rdf/fas/mitarbeiterlehreinheitenauswahl.rdf.php new file mode 100644 index 000000000..33a7f0d01 --- /dev/null +++ b/rdf/fas/mitarbeiterlehreinheitenauswahl.rdf.php @@ -0,0 +1,105 @@ +'; +// Klassen inkludieren +include('../../vilesci/config.inc.php'); +include('../../include/functions.inc.php'); +include('../../include/fas/benutzer.class.php'); +include('../../include/fas/person.class.php'); +include('../../include/fas/mitarbeiter.class.php'); +include('../../include/fas/funktion.class.php'); + +error_reporting(E_ALL); +ini_set('display_errors','1'); + +// Datenbank Verbindung herstellen +if (!$conn = @pg_pconnect(CONN_STRING)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + +if (!$conn_fas = @pg_pconnect(CONN_STRING_FAS)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + +$stg = isset($_GET['stg'])?$_GET['stg']:''; +$fb = isset($_GET['fb'])?$_GET['fb']:''; + +$user = get_uid(); + +//Aktuelles Studiensemester holen +$benutzer = new benutzer($conn); +if(!$benutzer->loadVariables($user)) + die("error:".$benutzer->errormsg); + +// Mitarbeiter holen +$fkt_obj = new funktion($conn_fas); +if($stg!='' && $fb !='') +{ + //Alle laden die eine Funktion in diesem Bereich haben + if(!$fkt_obj->getMitarbeiter($stg,$fb,$benutzer->variable->semester_aktuell)) + die("Error: $fkt_obj->errormsg"); + +} + +$rdf_url='http://www.technikum-wien.at/mitarbeiterlehreinheitenauswahl'; + +?> + + + + + + + 2701 + Dieter + Dummy + +result as $elem) + { + if($elem->mitarbeiter_id!=2701) //Dummy nicht nochmal in die Liste schreiben + { + //Namen der Lektoren holen + $mitarbeiter = new mitarbeiter($conn_fas); + $mitarbeiter->load_mitarbeiter($elem->mitarbeiter_id); + $arr['id'][]=$mitarbeiter->mitarbeiter_id; + $arr['vn'][]=$mitarbeiter->vorname; + $arr['nn'][]=$mitarbeiter->familienname; + } + } + //Nach Nachname sortieren + array_multisort($arr['nn'],$arr['vn'],$arr['id']); + for($i=0;$i + ".$arr['id'][$i]." + ".$arr['vn'][$i]." + ".$arr['nn'][$i]." + + "; + } +} +?> + + + diff --git a/rdf/fas/mitarbeiterlehreinheitenfunktionen.rdf.php b/rdf/fas/mitarbeiterlehreinheitenfunktionen.rdf.php new file mode 100644 index 000000000..d58614e13 --- /dev/null +++ b/rdf/fas/mitarbeiterlehreinheitenfunktionen.rdf.php @@ -0,0 +1,44 @@ +'; +// DAO + +$rdf_url='http://www.technikum-wien.at/mitarbeiterlehreinheitenfunktionen'; + +?> + + + + + + + 1 + Betreuer + + + 2 + Lehrveranstaltungsleiter + + + 3 + Zweitbetreuer + + + + \ No newline at end of file diff --git a/rdf/fas/nation.rdf.php b/rdf/fas/nation.rdf.php new file mode 100644 index 000000000..a8c1b8f94 --- /dev/null +++ b/rdf/fas/nation.rdf.php @@ -0,0 +1,56 @@ +'; +// DAO +include('../../vilesci/config.inc.php'); +include_once('../../include/fas/nation.class.php'); + +// Datenbank Verbindung +if (!$conn = pg_pconnect(CONN_STRING_FAS)) + die('Es konnte keine Verbindung zum Server aufgebaut werden!'); + +if(isset($_GET['ohnesperre']) && $_GET['ohnesperre']=='true') + $ohnesperre=true; +else + $ohnesperre=false; + +$nationDAO=new nation($conn); +if(!$nationDAO->getAll($ohnesperre)) + die("$nationDAO->errormsg"); + +$rdf_url='http://www.technikum-wien.at/nation'; +?> + + + +result as $nation) +{ +?> + + + code; ?> + kurztext; ?> + + + + + \ No newline at end of file diff --git a/rdf/fas/qualifikation.rdf.php b/rdf/fas/qualifikation.rdf.php new file mode 100644 index 000000000..f97b3ea71 --- /dev/null +++ b/rdf/fas/qualifikation.rdf.php @@ -0,0 +1,58 @@ +'; +// DAO +include('../../vilesci/config.inc.php'); + +$rdf_url='http://www.technikum-wien.at/qualifikation'; + +?> + + + + + + + + + 0 + keine + + + + + 1 + Habilitation + + + + + 2 + der Habilitation gleichwertige Qualifikation + + + + + 3 + berufliche Tätigkeit + + + + + + \ No newline at end of file diff --git a/rdf/fas/raumtyp.rdf.php b/rdf/fas/raumtyp.rdf.php new file mode 100644 index 000000000..a74c069d7 --- /dev/null +++ b/rdf/fas/raumtyp.rdf.php @@ -0,0 +1,51 @@ +'; +// DAO +include('../../vilesci/config.inc.php'); +include('../../include/fas/raumtyp.class.php'); + +// Datenbank Verbindung +if (!$conn = @pg_pconnect(CONN_STRING_FAS)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + +$rdf_url='http://www.technikum-wien.at/raumtyp'; + +?> + + + + + +getAll(); + + foreach ($raumtypDAO->result as $raumtyp) + { + ?> + + + raumtyp_id; ?> + bezeichnung; ?> + + + + + \ No newline at end of file diff --git a/rdf/fas/student-verbaende.rdf.php b/rdf/fas/student-verbaende.rdf.php new file mode 100644 index 000000000..84f1a5008 --- /dev/null +++ b/rdf/fas/student-verbaende.rdf.php @@ -0,0 +1,203 @@ +'; +// DAO +include('../../vilesci/config.inc.php'); +include('../../include/functions.inc.php'); +include('../../include/fas/functions.inc.php'); +include('../../include/fas/benutzer.class.php'); +include('../../include/berechtigung.class.php'); + +error_reporting(E_ALL); +ini_set('display_errors','1'); + +// Datenbank Verbindung +if (!$conn = @pg_pconnect(CONN_STRING)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + +if (!$conn_fas = @pg_pconnect(CONN_STRING_FAS)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + +$sem = isset($_GET['sem'])?$_GET['sem']:''; +$stg = isset($_GET['stg'])?$_GET['stg']:''; + +$user = get_uid(); + +$benutzer = new benutzer($conn); +if(!$benutzer->loadVariables($user)) + die("error:".$benutzer->errormsg); +$stsem = getStudiensemesterIdFromName($conn_fas, $benutzer->variable->semester_aktuell); + +$rechte = new berechtigung($conn); +$rechte->getBerechtigungen($user); +$rdf_url='http://www.technikum-wien.at/gruppen'; + +?> + + + +isBerechtigt('admin', $row->kennzahl) || $rechte->isBerechtigt('lva-verwaltung',$row->kennzahl)) + { + if($laststg!=$row->studiengang_fk) + { + $laststg=$row->studiengang_fk; + $descr.=" + studiengang_fk."\" > + $row->studiengang_fk + 0 + (".$row->art_bez.") ".$row->kuerzel." + ($row->art_bez) $row->kuerzel + 0 + "; + } + $descr.=" + studiengang_fk.'/'.$row->gruppe_id."\" > + $row->studiengang_fk + $row->gruppe_id + (".$row->art_bez.") ".$row->kuerzel." + (".$row->art_bez.") ".$row->kuerzel." - $row->grpname + $row->ausbildungssemester_fk + + "; + if($row->obergruppe_id==0) + { + array_push($grps,$row->gruppe_id); + array_push($stgs,$row->studiengang_fk); + } + $i++; + } + } + + function myfkt($gid,$conn_fas,$rdf_url,$einr,$stg) + { + $qry = "Select * from gruppe where obergruppe_fk=$gid"; + if($result=pg_query($conn_fas,$qry)) + { + if(pg_num_rows($result)>1) + { + $row=pg_fetch_object($result,0); + //echo "\n$einr
  • studiengang_fk.'/'.$gid."\" />"; + echo "\n$einr\n$einr studiengang_fk.'/'.$gid."\" >"; + while($row=pg_fetch_object($result)) + { + myfkt($row->gruppe_pk,$conn_fas,$rdf_url,$einr.' ',$row->studiengang_fk); + } + echo "\n$einr \n$einr"; + } + else + { + if(pg_num_rows($result)>0) + { + $row=pg_fetch_object($result); + $qry = "Select count(*) as anz from gruppe where obergruppe_fk=$row->gruppe_pk"; + + if($result1=pg_query($conn_fas,$qry)) + { + if($row1=pg_fetch_object($result1)) + { + if($row1->anz>0) + { + //echo "\n$einr
  • studiengang_fk.'/'.$gid."\" />"; + echo "\n$einr\n$einr studiengang_fk.'/'.$gid."\" >"; + myfkt($row->gruppe_pk, $conn_fas,$rdf_url,$einr.' ',$row->studiengang_fk); + echo "\n$einr \n$einr"; + } + else + echo "\n$einr studiengang_fk.'/'.$row->gruppe_pk."\" />"; + } + else + echo "\nFAIL2\n"; + } + else + echo "\nFAIL1\n"; + } + else + { + echo "\n$einr "; + } + } + } + } + + echo $descr; + echo "\n"; + $laststg=0; + for ($i=0;$i"; + echo "\n "; + } + $laststg=$stgs[$i]; + echo "\n \n "; + + } + myfkt($grp,$conn_fas,$rdf_url,' ',0); + } + echo "\n "; + echo "\n "; + echo "\n"; + +?> + + + diff --git a/rdf/fas/studiengang.rdf.php b/rdf/fas/studiengang.rdf.php new file mode 100644 index 000000000..d4f719caf --- /dev/null +++ b/rdf/fas/studiengang.rdf.php @@ -0,0 +1,62 @@ +'; +// DAO +include('../../vilesci/config.inc.php'); +include('../../include/fas/studiengang.class.php'); + +// Datenbank Verbindung +if (!$conn = @pg_pconnect(CONN_STRING_FAS)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + +$rdf_url='http://www.technikum-wien.at/studiengang'; + +?> + + + + + +getAll(); + + foreach ($studiengangDAO->result as $studiengang) + { + ?> + + + studiengang_id; ?> + studiengangsart==1) + $art='(B) '; + if($studiengang->studiengangsart==2) + $art='(M) '; + if($studiengang->studiengangsart==3) + $art='(D) '; + echo $art.$studiengang->name; ?> + + + + + + + + \ No newline at end of file diff --git a/rdf/fas/studiensemester.rdf.php b/rdf/fas/studiensemester.rdf.php new file mode 100644 index 000000000..83cadd8de --- /dev/null +++ b/rdf/fas/studiensemester.rdf.php @@ -0,0 +1,57 @@ +'; +// DAO +include('../../vilesci/config.inc.php'); +include('../../include/fas/studiensemester.class.php'); + +// Datenbank Verbindung +if (!$conn = @pg_pconnect(CONN_STRING_FAS)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + +$rdf_url='http://www.technikum-wien.at/studiensemester'; + +?> + + + + + +getAll(); + + foreach ($studiensemesterDAO->result as $studiensemester) + { + ?> + + + studiensemester_id; ?> + aktuell?'Ja':'Nein'); ?> + art; ?> + jahr; ?> + art==1?'WS':'SS').$studiensemester->jahr; ?> + + + + + + + + \ No newline at end of file diff --git a/rdf/fas/telefonnummern.rdf.php b/rdf/fas/telefonnummern.rdf.php new file mode 100644 index 000000000..fe1e69edb --- /dev/null +++ b/rdf/fas/telefonnummern.rdf.php @@ -0,0 +1,83 @@ +'; +// DAO +include('../../vilesci/config.inc.php'); +include_once('../../include/fas/telefonnummer.class.php'); + +// Datenbank Verbindung +if (!$conn = @pg_pconnect(CONN_STRING_FAS)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + +$rdf_url='http://www.technikum-wien.at/telefonnummern'; + +?> + + + + + +load_pers($pers_id); + + foreach ($telefonnummernDAO->result as $telefonnummern) + { + ?> + + + telefonnummer_id; ?> + name; ?> + nummer; ?> + person_id; ?> + typ; ?> + + + load($telefonnummer_id); + ?> + + + telefonnummer_id; ?> + name; ?> + nummer; ?> + person_id; ?> + typ; ?> + + + + + + + + \ No newline at end of file diff --git a/rdf/fas/telefonnummerntyp.rdf.php b/rdf/fas/telefonnummerntyp.rdf.php new file mode 100644 index 000000000..ffa14c48a --- /dev/null +++ b/rdf/fas/telefonnummerntyp.rdf.php @@ -0,0 +1,51 @@ +'; +// DAO +include('../../vilesci/config.inc.php'); + +// Datenbank Verbindung +if (!$conn = pg_pconnect(CONN_STRING_FAS)) + die('Es konnte keine Verbindung zum Server aufgebaut werden!'); + +$rdf_url='http://www.technikum-wien.at/telefonnummerntyp'; +?> + + + + + + + name; ?> + typ; ?> + + + + + \ No newline at end of file diff --git a/rdf/fas/verwendung.rdf.php b/rdf/fas/verwendung.rdf.php new file mode 100644 index 000000000..6118c49f3 --- /dev/null +++ b/rdf/fas/verwendung.rdf.php @@ -0,0 +1,90 @@ +'; +// DAO +include('../../vilesci/config.inc.php'); + +$rdf_url='http://www.technikum-wien.at/verwendung'; + +?> + + + + + + + + + 1 + Lehr- und Forschungspersonal (Academic staff) + + + + + 2 + Lehr- und Forschungshilfspersonal (Teaching and Research assistants) + + + + + 3 + Akademische Dienste für Studierende (Academic Support) + + + + + 4 + Soziale Dienste und Gesundheitsdienste (Health and Social Support) + + + + + 5 + Studiengangsleiter/in + + + + + 6 + Leiter/in FH-Kollegium + + + + + 7 + Management (School Level Management) + + + + + 8 + Verwaltung (School Level Administrative Personnel) + + + + + 9 + Hauspersonal, Gebäude- / Haustechnik (Maintenance and Operations Personnel) + + + + + + + + \ No newline at end of file diff --git a/rdf/fas/wochenrythmus.rdf.php b/rdf/fas/wochenrythmus.rdf.php new file mode 100644 index 000000000..758a1fd29 --- /dev/null +++ b/rdf/fas/wochenrythmus.rdf.php @@ -0,0 +1,63 @@ +'; +// DAO +include('../../vilesci/config.inc.php'); + +$rdf_url='http://www.technikum-wien.at/wochenrythmus'; + +?> + + + + + + + + + 0 + Geblockt + + + + + 1 + 1 Wöchentlich + + + + + 2 + 2 Wöchentlich + + + + + 3 + 3 Wöchentlich + + + + + 4 + 4 Wöchentlich + + + + + \ No newline at end of file diff --git a/rdf/index.html b/rdf/index.html new file mode 100644 index 000000000..3c2db98fc --- /dev/null +++ b/rdf/index.html @@ -0,0 +1,100 @@ + + + + + +

    RDF-Spezifikationen am Technikum Wien

    +
    +Diese Seite beschreibt den Inhalt und die Verwendung aller vorhandenen +RDF-Files am Technikum Wien. Die gesamte RDF-Struktur ist gerade im +Aufbau und kann sich deshalb jederzeit ändern. Es sei darauf +hingewiesen, dass die RDF-Files von heute, morgen vielleicht gar nicht +mehr oder anders zu verwenden sind.
    +
    +

    Student

    +Aufruf: +student.rdf.php?stg_kz=...&sem=...&ver=...&grp=...&einheit=...&uid=...
    +Beispiel: student.rdf.php?stg_kz=227&sem=2
    +
    +Parameter
    :
    +
      +
    • stg_kz: Studiengangskennzahl
      +
    • +
    • sem: Semester (optional)
      +
    • +
    • ver: Verband (optional)
    • +
    • grp: Gruppe (optional)
    • +
    • einheit: Spezialgruppen, Module, ... (optional)
    • +
    • uid: UID eines bestimmten Studenten (Wenn gesetzt werden alle anderen Parameter nicht verwendet)
    • +
    +
    +Attribute:

    +
      +
    • uid
    • +
    • titel
    • +
    • vornamen
    • +
    • nachname
    • +
    • matrikelnummer
    • +
    • geburtsdatum
    • +
    • email
    • +
    • homepage
    • +
    • aktiv
    • +
    • gebort
    • +
    • gebzeit
    • +
    • foto
    • +
    • anmerkungen
    • +
    • updateamum
    • +
    • updatevon
    • +
    • gruppe
    • +
    • verband
    • +
    • semester
    • +
    • studiengang_kz
    • +
    • stg_bezeichnung
    • +
    +
    +

    Lehrstunde

    +Aufruf: +lehrstunde.rdf.php?datum=...&datum_bis=...stg_kz=...&sem=...&ver=...&grp=...&einheit=...
    +Beispiel: lehrstunde.rdf.php?datum=2006-03-20&stg_kz=258
    +
    +Parameter
    :
    +
      +
    • datum
    • +
    • datum_bis: Endedatum (optional)
      +
    • +
    • stunde
    • +
    • type
    • +
    • stg_kz
    • +
    • sem
    • +
    • ver
    • +
    • grp
    • +
    • einheit
    • +
    • pers_uid
    • +
    • ort_kurzbz
      +
    • +
    +
    +Attribute:

    +
      +
    • datum
    • +
    • stunde
    • +
    • unr
    • +
    • ort_kurzbz
    • +
    • lehrfach
    • +
    • lehrfach_bez
    • +
    • lehrform
    • +
    • lektor
    • +
    • semester
    • +
    • verband
    • +
    • gruppe
    • +
    • einheit
    • +
    • lehrform
    • +
    • studiengang
    • +
    • farbe
    • +
    • anmerkung
      +
    • +
    + + diff --git a/rdf/lehrfach.rdf.php b/rdf/lehrfach.rdf.php new file mode 100644 index 000000000..f2bb9dbe6 --- /dev/null +++ b/rdf/lehrfach.rdf.php @@ -0,0 +1,69 @@ +'; +// DAO +include('../vilesci/config.inc.php'); +include_once('../include/lehrfach.class.php'); + +// Datenbank Verbindung +if (!$conn = @pg_pconnect(CONN_STRING)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + +// Einheiten holen +$lehrfachDAO=new lehrfach($conn); +$lehrfaecher=$lehrfachDAO->getAll(); + + + +$rdf_url='http://www.technikum-wien.at/tempus/lehrfach'; + +?> + + + + + + + + + + + lehrfach_nr ?> + bezeichnung ?> ]]> + fachbereich_id ?> + kurzbz ?> + lehrelink ?> + farbe ?> + lehrform_kurzbz ?> + aktiv ?> + studiengang_kz ?> + ects ?> + + + + + + + + \ No newline at end of file diff --git a/rdf/lehrform.rdf.php b/rdf/lehrform.rdf.php new file mode 100644 index 000000000..f47806e3d --- /dev/null +++ b/rdf/lehrform.rdf.php @@ -0,0 +1,55 @@ +'; +// DAO +include('../vilesci/config.inc.php'); +include_once('../include/lehrform.class.php'); + +// Datenbank Verbindung +if (!$conn = @pg_pconnect(CONN_STRING)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + +// Lehrformen holen +$lehrformDAO=new lehrform($conn); +$lehrform=$lehrformDAO->getAll(); + +$rdf_url='http://www.technikum-wien.at/lehrform'; + +?> + + + + + + + + + kurzbz ?> + bezeichnung ?> + + + + + \ No newline at end of file diff --git a/rdf/lehrstunde.rdf.php b/rdf/lehrstunde.rdf.php new file mode 100644 index 000000000..e05c0a63b --- /dev/null +++ b/rdf/lehrstunde.rdf.php @@ -0,0 +1,130 @@ +'; + +include('../cis/config.inc.php'); +include('../include/functions.inc.php'); +include('../include/lehrstunde.class.php'); + +function checkID($needle) +{ + global $id_list; + //echo "checkID $needle \n"; + reset($id_list); + foreach($id_list as $v) + if ($v==$needle) + return true; + return false; +} + +$id_list=array(); +while(list($k,$v)=each($_GET)) + if (strpos($k,'stundenplan_id')!==false) + $id_list[]=$v; + +//print_r($id_list); + +if (!isset($REMOTE_USER)) + $REMOTE_USER='pam'; +$uid=$REMOTE_USER; + +if (isset($_GET[datum])) + $datum=$_GET[datum]; +if (isset($_GET[datum_bis])) + $datum_bis=$_GET[datum_bis]; +if (isset($_GET[stunde])) + $stunde=$_GET[stunde]; +if (isset($_GET[type])) + $type=$_GET[type]; +if (isset($_GET[stg_kz])) + $stg_kz=$_GET[stg_kz]; +if (isset($_GET[sem])) + $sem=$_GET[sem]; +if (isset($_GET[ver])) + $ver=$_GET[ver]; +if (isset($_GET[grp])) + $grp=$_GET[grp]; +if (isset($_GET[einheit])) + $einheit=$_GET[einheit]; +if (isset($_GET[pers_uid])) + $pers_uid=$_GET[pers_uid]; +if (isset($_GET[ort_kurzbz])) + $ort_kurzbz=$_GET[ort_kurzbz]; + + +$error_msg=''; +if (!$conn = @pg_pconnect(CONN_STRING)) + $error_msg.='Es konnte keine Verbindung zum Server aufgebaut werden!'; +$error_msg.=loadVariables($conn,$REMOTE_USER); + +if (!isset($datum_bis)) + $datum_bis=date('Y-m-d',(mktime(0,0,1,substr($datum,5,2),substr($datum,8),substr($datum,0,4))+86400)); + +$lehrstunden=new lehrstunde($conn); +$anz=$lehrstunden->load_lehrstunden($type,$datum,$datum_bis,$pers_uid,$ort_kurzbz,$stg_kz,$sem,$ver,$grp,$einheit,$db_stpl_table); +if ($anz<0) +{ + $errormsg=$lehrstunden->errormsg; + echo "Fehler: ".$errormsg; + exit(); +} + +$rdf_url='http://www.technikum-wien.at/tempus/lehrstunde'; +?> + + + + +lehrstunden)) + foreach ($lehrstunden->lehrstunden as $ls) + { + //var_dump($ls); + //echo $ls->stunde.";"; + //if ($ls->stunde == $stunde && checkID($ls->stundenplan_id)) + //{ + ?> + + + stundenplan_id ?> + datum ?> + stunde ?> + unr ?> + ort_kurzbz ?> + lehrfach ?> + lehrfach_bez ?> + lehrform ?> + lektor_kurzbz ?> + sem ?> + ver ?> + grp ?> + einheit_kurzbz ?> + lehrform ?> + studiengang ?> + farbe ?> + anmerkung ?>]]> + + + + + + \ No newline at end of file diff --git a/rdf/lehrveranstaltung.rdf.php b/rdf/lehrveranstaltung.rdf.php new file mode 100644 index 000000000..274c5cb22 --- /dev/null +++ b/rdf/lehrveranstaltung.rdf.php @@ -0,0 +1,214 @@ +'; +// DAO +include_once('../vilesci/config.inc.php'); +include_once('../include/functions.inc.php'); +include_once('../include/lehrveranstaltung.class.php'); +include_once('../include/berechtigung.class.php'); + +// Testumgebung +if (!isset($REMOTE_USER)) + $REMOTE_USER='pam'; +$uid=$REMOTE_USER; +$error_msg=''; + +if (!$conn = @pg_pconnect(CONN_STRING)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; +$berechtigung=new berechtigung($conn); +$berechtigung->getBerechtigungen($uid); +$error_msg.=loadVariables($conn,$uid); + +if (isset($semester_aktuell)) + $studiensemester=$semester_aktuell; +else + echo $error_msg='studiensemester is not set!'; +if (isset($_GET['type'])) + $type=$_GET['type']; +else + $type='lektor'; +if (isset($_GET['stg_kz'])) + $stg_kz=$_GET['stg_kz']; +else + $stg_kz=0; +if (isset($_GET['sem'])) + $sem=$_GET['sem']; +else + $sem=0; +if (isset($_GET['lektor'])) + $lektor=$_GET['lektor']; +else + $lektor=$uid; +if (isset($_GET['ver'])) + $ver=$_GET['ver']; +else + $ver=null; +if (isset($_GET['grp'])) + $grp=$_GET['grp']; +else + $grp=null; +if (isset($_GET['einheit'])) + $einheit_kurzbz=$_GET['einheit']; +else + $einheit_kurzbz=null; + +// LVA holen +$lva=array(); +$lehrveranstaltung=new lehrveranstaltung($conn); +if (!$error_msg) + $lva=$lehrveranstaltung->getLehrveranstaltungSTPL($db_stpl_table,$studiensemester,$type,$stg_kz,$sem,$lektor,$ver,$grp,$einheit_kurzbz); +$rdf_url='http://www.technikum-wien.at/tempus/lehrveranstaltung/'; +?> + + + + + +errormsg; +$anz=count($lva); +if ($anz>0) +foreach ($lva as $l) +{ + $lva_ids=''; + $lehrverband=''; + $lvnr=''; + $lektor=''; + $einheit=''; + $i=0; + // IDs der Lehrveranstaltungen + foreach($l->lehrveranstaltung_id as $lva_id) + $lva_ids.='&lva_id'.$i++.'='.$lva_id; + // Lektoren + $lektor=''; + $l->lektor=array_unique($l->lektor); + sort($l->lektor); + foreach($l->lektor as $lv) + $lektor.=$lv.' '; + // Lehrverbaende + $l->lehrverband=array_unique($l->lehrverband); + sort($l->lehrverband); + foreach($l->lehrverband as $lv) + $lehrverband.=$lv.' '; + // LVNRs + foreach($l->lvnr as $lv) + $lvnr.=$lv.' '; + foreach($l->einheit as $lv) + $einheit.=$lv.' '; + // Stundenblockung + $stundenblockung=''; + $l->stundenblockung=array_unique($l->stundenblockung); + sort($l->stundenblockung); + foreach($l->stundenblockung as $sb) + $stundenblockung.=$sb.' '; + if (count($l->stundenblockung)>1) + $stundenblockung.=' ?'; + // Start KW + $start_kw=''; + $l->start_kw=array_unique($l->start_kw); + sort($l->start_kw); + foreach($l->start_kw as $kw) + $start_kw.=$kw.' '; + if (count($l->start_kw)>1) + $start_kw.=' ?'; + // Wochenrythmus + $wochenrythmus=''; + $l->wochenrythmus=array_unique($l->wochenrythmus); + sort($l->wochenrythmus); + foreach($l->wochenrythmus as $wr) + $wochenrythmus.=$wr.' '; + if (count($l->wochenrythmus)>1) + $wochenrythmus.=' ?'; + // Lehrfach + $lehrfach=''; + $l->lehrfach=array_unique($l->lehrfach); + sort($l->lehrfach); + foreach($l->lehrfach as $lf) + $lehrfach.=$lf.' '; + if (count($l->lehrfach)>1) + $lehrfach.=' ?'; + // Lehrform + $lehrform=''; + $l->lehrform=array_unique($l->lehrform); + sort($l->lehrform); + foreach($l->lehrform as $lf) + $lehrform.=$lf.' '; + if (count($l->lehrform)>1) + $lehrform.=' ?'; + // Semesterstunden + $semesterstunden=''; + $l->semesterstunden=array_unique($l->semesterstunden); + sort($l->semesterstunden); + foreach($l->semesterstunden as $lf) + $semesterstunden.=$lf.' '; + if (count($l->semesterstunden)>1) + $semesterstunden.=' ?'; + // Verplant + $verplant=''; + $l->verplant=array_unique($l->verplant); + sort($l->verplant); + foreach($l->verplant as $lf) + $verplant.=$lf.' '; + if (count($l->verplant)>1) + $verplant.=' ?'; + // Offene Stunden + $offenestunden=''; + $l->offenestunden=array_unique($l->offenestunden); + sort($l->offenestunden); + foreach($l->offenestunden as $os) + $offenestunden.=$os.' '; + if (count($l->offenestunden)>1) + $offenestunden.=' ?'; + + if ($berechtigung->isBerechtigt('lvaVerplanung',$l->stg_kz[0]) || $berechtigung->isBerechtigt('admin',0) || $berechtigung->isBerechtigt('admin',$l->stg_kz[0])) + echo' + + '.$lvnr.' + '.$l->unr.' + '.$einheit.' + '.$lektor.' + '.$l->lehrfach_nr.' + '.$l->studiengang_kz.' + '.$l->fachbereich_id.' + '.$l->semester[0].' + '.$l->verband[0].' + '.$l->gruppe[0].' + '.$l->einheit[0].' + '.$l->raumtyp.' + '.$l->raumtypalternativ.' + '.$semesterstunden.' + '.$stundenblockung.' + '.$wochenrythmus.' + '.$verplant.' + '.$offenestunden.' + '.$start_kw.' + '.$l->anmerkung[0].' + '.$l->studiensemester_kurzbz.' + '.$lehrfach.' + '.$lehrform.' + lehrfach_bez[0].']]> + #'.$l->lehrfach_farbe[0].' + '.$lva_ids.' + '.$lehrverband.' + + '; +} +?> + + \ No newline at end of file diff --git a/rdf/lfvt.rdf.php b/rdf/lfvt.rdf.php new file mode 100644 index 000000000..e70973e83 --- /dev/null +++ b/rdf/lfvt.rdf.php @@ -0,0 +1,135 @@ +'; +// DAO +include('../vilesci/config.inc.php'); +include_once('../include/lfvt.class.php'); + +// Datenbank Verbindung +if (!$conn = @pg_pconnect(CONN_STRING)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + + +// test + +//$einheit_kurzbz=''; +//$grp='1'; +//$ver='A'; +//$sem=5; +//$stg_kz=145; + + + +$einheit_kurzbz=$_GET['einheit']; +$grp=$_GET['grp']; +$ver=$_GET['ver']; +$sem=$_GET['sem']; +$stg_kz=$_GET['stg_kz']; +$lektor=$_GET['lektor']; + +// LVAs holen +$lvaDAO=new lfvt($conn); +$lvas=$lvaDAO->getLVAs($einheit_kurzbz, $grp, $ver, $sem, + $stg_kz,$lektor); + + + +$rdf_url='http://www.technikum-wien.at/tempus/lva'; + +?> + + + +unr; + $lastUNR=($i>0?$lvas[$i-1]->unr:''); + $nextUNR=($i<(count($lvas)-1)?$lvas[$i+1]->unr:''); + $descr.=" + lehrveranstaltung_id."\" about=\"".$rdf_url.'/'.$lva->lehrveranstaltung_id."\" > + ".$lva->lvnr." + ".$lva->unr." + ".$lva->einheit_kurzbz." + ".$lva->lektor." + ".utf8_encode($lva->lektorPrettyPrint)." + ".$lva->lehrfach_nr." + ".$lva->studiengang_kz." + ".$lva->fachbereich_id." + ".$lva->semester."". + (strlen(trim($lva->verband))>0?" ".$lva->verband."":""). + ($lva->gruppe>0?" ".$lva->gruppe."":"")." + ".$lva->raumtyp." + ".$lva->raumtypalternativ." + ".$lva->semesterstunden." + ".$lva->stundenblockung." + ".$lva->wochenrythmus." + ".$lva->start_kw." + ".$lva->anmerkung." + ".$lva->studiensemester_kurzbz." + lehrfach)."]]> + ".$lva->lehrveranstaltung_id." + "; + + $subClose=false; + if (($lastUNR!=$currentUNR && $currentUNR==$nextUNR) || count($lvas)==$i) { + $inSub=true; + $hier.=" + + + lehrveranstaltung_id."\" >"; + } + + if ($nextUNR!=$currentUNR && $inSub) { + $inSub=false; + $subClose=true; + $hier.=" + lehrveranstaltung_id."\" /> + + + "; + } + + if (($inSub && $lastUNR==$currentUNR) || (count($lvas)==1) || (!$inSub && $currentUNR!=nextUNR && !$subClose)) { + $hier.=" + lehrveranstaltung_id."\" /> "; + + } + + + + } + + $hier=" + ".$hier." + "; + echo $descr; + echo $hier; + //print_r($lvas); +} +?> + + + diff --git a/rdf/mitarbeiter.rdf.php b/rdf/mitarbeiter.rdf.php new file mode 100644 index 000000000..4fa07ee58 --- /dev/null +++ b/rdf/mitarbeiter.rdf.php @@ -0,0 +1,75 @@ +'; +// DAO +include('../vilesci/config.inc.php'); +include_once('../include/person.class.php'); +include_once('../include/mitarbeiter.class.php'); + +if (!$conn = @pg_pconnect(CONN_STRING)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + +// test +/* +$einheit_kurzbz=''; +$grp='1'; +$ver='A'; +$sem=3; +$stg_kz=145; +*/ + +$einheit_kurzbz=''; +if (isset($_GET['lektor'])) + $lektor=$_GET['lektor']; +else + $lektor=true; +$fixangestellt=$_GET['fixangestellt']; +$stg_kz=$_GET['stg_kz']; +$fachbereich_id=$_GET['fachbereich_id']; + +// Mitarbeiter holen +$mitarbeiter=new mitarbeiter($conn); +$ma=$mitarbeiter->getMitarbeiter($lektor,$fixangestellt,$stg_kz,$fachbereich_id); + +$rdf_url='http://www.technikum-wien.at/tempus/mitarbeiter/'; +?> + + + + + + + + + + uid; ?> + titel; ?> + vornamen; ?> + nachname; ?> + kurzbz; ?> + + + + + \ No newline at end of file diff --git a/rdf/ort.rdf.php b/rdf/ort.rdf.php new file mode 100644 index 000000000..af9840dfd --- /dev/null +++ b/rdf/ort.rdf.php @@ -0,0 +1,81 @@ +'; +// DAO +include('../vilesci/config.inc.php'); + +if (!$conn = @pg_pconnect(CONN_STRING)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; +// Orte holen +$sql_query="SELECT * FROM (tbl_ort NATURAL JOIN tbl_ortraumtyp) JOIN tbl_raumtyp USING (raumtyp_kurzbz) + WHERE aktiv AND raumtyp_kurzbz!='LM' ORDER BY raumtyp_kurzbz, hierarchie,ort_kurzbz"; +if(!$result=pg_query($conn, $sql_query)) + $error_msg.=pg_errormessage($conn); +else + $num_rows=@pg_numrows($result); + +$rdf_url='http://www.technikum-wien.at/tempus/ort'; +?> + + + +0?pg_fetch_object($result,$i-1):null); + $ort=pg_fetch_object($result,$i); + $ortNEXT=(($i<$num_rows-1)?pg_fetch_object($result,$i+1):null); + $currentTYP=$ort->raumtyp_kurzbz; + $lastTYP=$ortLAST->raumtyp_kurzbz; + $nextTYP=$ortNEXT->raumtyp_kurzbz; + //echo "current:$currentTYP last:$lastTYP next:$nextTYP"; + if ($lastTYP!=$currentTYP || $i==0) + $descr.=' + '.$ort->raumtyp_kurzbz.' + + + + + '; + $descr.=' + '.$ort->ort_kurzbz." + ".$ort->hierarchie." + ".$ort->ort_kurzbz." + ".$ort->bezeichnung." + ".$ort->max_person.' + '."\n"; + + if ($lastTYP!=$currentTYP) + $sequenz.=' + + '."\n"; + if ($nextTYP!=$currentTYP || $i==$num_rows-1) + $sequenz.=' + + '."\n"; + elseif ($lastTYP==$currentTYP || $nextTYP==$currentTYP || $num_rows==1) + $sequenz.=''."\n"; +} +$sequenz=''."\n".$sequenz.' + '; +echo $descr; +echo $sequenz; +?> + \ No newline at end of file diff --git a/rdf/orte.rdf.php b/rdf/orte.rdf.php new file mode 100644 index 000000000..b28584ee8 --- /dev/null +++ b/rdf/orte.rdf.php @@ -0,0 +1,80 @@ +'; +// DAO +include('../vilesci/config.inc.php'); + +if (!$conn = @pg_pconnect(CONN_STRING)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; +// Orte holen +$sql_query="SELECT * FROM (tbl_ort NATURAL JOIN tbl_ortraumtyp) JOIN tbl_raumtyp USING (raumtyp_kurzbz) + WHERE aktiv AND raumtyp_kurzbz!='LM' ORDER BY raumtyp_kurzbz, hierarchie,ort_kurzbz"; +if(!$result=pg_query($conn, $sql_query)) + $error_msg.=pg_errormessage($conn); +else + $num_rows=@pg_numrows($result); + +$rdf_url='http://www.technikum-wien.at/tempus/ort'; +?> + + + +0?pg_fetch_object($result,$i-1):null); + $ort=pg_fetch_object($result,$i); + $ortNEXT=(($i<$num_rows-1)?pg_fetch_object($result,$i+1):null); + $currentTYP=$ort->raumtyp_kurzbz; + $lastTYP=$ortLAST->raumtyp_kurzbz; + $nextTYP=$ortNEXT->raumtyp_kurzbz; + //echo "current:$currentTYP last:$lastTYP next:$nextTYP"; + if ($lastTYP!=$currentTYP || $i==0) + $descr.=' + '.$ort->raumtyp_kurzbz.' + + + + + '; + $descr.=' + '.$ort->ort_kurzbz." + ".$ort->hierarchie." + ".$ort->ort_kurzbz." + ".$ort->bezeichnung." + ".$ort->max_person.' + '."\n"; + + if ($lastTYP!=$currentTYP) + $sequenz.=' + + '."\n"; + if ($nextTYP!=$currentTYP || $i==$num_rows-1) + $sequenz.=' + + '."\n"; + elseif ($lastTYP==$currentTYP || $nextTYP==$currentTYP || $num_rows==1) + $sequenz.=''."\n"; +} +$sequenz=''."\n".$sequenz.' + '; +echo $descr; +echo $sequenz; +?> + \ No newline at end of file diff --git a/rdf/orte2.rdf.php b/rdf/orte2.rdf.php new file mode 100644 index 000000000..ca936fb11 --- /dev/null +++ b/rdf/orte2.rdf.php @@ -0,0 +1,75 @@ +'; +// DAO +include('../vilesci/config.inc.php'); + +if (!$conn = @pg_pconnect(CONN_STRING)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; +// ORT holen +if(!($result=pg_query($conn, 'SELECT * FROM (tbl_ort NATURAL JOIN tbl_ortraumtyp) + JOIN tbl_raumtyp USING (raumtyp_kurzbz) WHERE aktiv + ORDER BY raumtyp_kurzbz, hierarchie,ort_kurzbz'))) + $error_msg.=pg_errormessage($conn); +else + $num_rows=@pg_numrows($result); + +$rdf_url='http://www.technikum-wien.at/tempus/ort'; +?> + + + +0?pg_fetch_object($result,$i-1):null); + $ort=pg_fetch_object($result,$i); + $ortNEXT=(($i<$num_rows-1)?pg_fetch_object($result,$i+1):null); + $currentTYP=$ort->raumtyp_kurzbz; + $lastTYP=$ortLAST->raumtyp_kurzbz; + $nextTYP=$ortNEXT->raumtyp_kurzbz; + //echo "current:$currentTYP last:$lastTYP next:$nextTYP"; + $descr.=' + + '.$ort->raumtyp_kurzbz." + ".$ort->hierarchie." + ".$ort->ort_kurzbz." + ".$ort->bezeichnung." + ".$ort->max_person.' + '; + + if ($lastTYP!=$currentTYP) + $sequenz.=' + '; + if ($nextTYP!=$currentTYP || $i==$num_rows-1) + $sequenz.=' + + '; + if ($lastTYP==$currentTYP || $nextTYP==$currentTYP || $num_rows==1) + $sequenz.=''; +} +$sequenz=''.$sequenz.' + '; +echo $descr; +echo $sequenz; +?> + \ No newline at end of file diff --git a/rdf/orte_liste.rdf.php b/rdf/orte_liste.rdf.php new file mode 100644 index 000000000..ba1bd7f21 --- /dev/null +++ b/rdf/orte_liste.rdf.php @@ -0,0 +1,58 @@ +'; +// DAO +include('../vilesci/config.inc.php'); + +if (!$conn = @pg_pconnect(CONN_STRING)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; +// ORT holen +if(!($result=pg_query($conn, 'SELECT * FROM (tbl_ort NATURAL JOIN tbl_ortraumtyp) + JOIN tbl_raumtyp USING (raumtyp_kurzbz) WHERE aktiv + ORDER BY raumtyp_kurzbz, hierarchie,ort_kurzbz'))) + $error_msg.=pg_errormessage($conn); +else + $num_rows=@pg_numrows($result); + +$rdf_url='http://www.technikum-wien.at/tempus/ort/'; +?> + + + + + + + + + raumtyp_kurzbz; ?> + hierarchie; ?> + ort_kurzbz; ?> + bezeichnung; ?> + max_person; ?> + + + + + \ No newline at end of file diff --git a/rdf/raumtyp.rdf.php b/rdf/raumtyp.rdf.php new file mode 100644 index 000000000..23d735f41 --- /dev/null +++ b/rdf/raumtyp.rdf.php @@ -0,0 +1,61 @@ +'; +// DAO +include('../vilesci/config.inc.php'); +include_once('../include/raumtyp.class.php'); + +// Datenbank Verbindung +if (!$conn = @pg_pconnect(CONN_STRING)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + + +// raumtypen holen +$raumtypDAO=new raumtyp($conn); +$raumtypen=$raumtypDAO->getAll(); + +$rdf_url='http://www.technikum-wien.at/tempus/raumtyp'; + +?> + + + + + + + + + kurzbz ?> + beschreibung ?> + + + + + + + \ No newline at end of file diff --git a/rdf/student-verbaende.rdf.php b/rdf/student-verbaende.rdf.php new file mode 100644 index 000000000..1cf93962f --- /dev/null +++ b/rdf/student-verbaende.rdf.php @@ -0,0 +1,200 @@ +'; +include('../vilesci/config.inc.php'); +include('../include/berechtigung.class.php'); + +$rdf_url='http://www.tempus-student-verbaende.at/'; + +if (!isset($REMOTE_USER)) + $REMOTE_USER='pam'; +$uid=$REMOTE_USER; + +if (!$conn = @pg_pconnect(CONN_STRING)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + +// Berechtigungen ermitteln +$berechtigung=new berechtigung($conn); +$berechtigung->getBerechtigungen($uid); +$berechtigt_studiengang=$berechtigung->getStgKz(); +$stg_kz_query=''; +if ($berechtigt_studiengang[0]!=0 && count($berechtigt_studiengang)>0) +{ + foreach ($berechtigt_studiengang as $b_stg) + $stg_kz_query.=' OR studiengang_kz='.$b_stg; + $stg_kz_query='AND ('.substr($stg_kz_query,3).')'; +} + +$sql_query="SELECT studiengang_kz, bezeichnung, kurzbz FROM tbl_studiengang WHERE studiengang_kz>=0 $stg_kz_query ORDER BY bezeichnung"; +//echo $sql_query; +if(!$result_stg=pg_query($conn, $sql_query)) + $error_msg.=pg_errormessage($conn); +else + $num_rows_stg=@pg_numrows($result_stg); +?> + + + + + + kurzbz.' - '.$row_stg->bezeichnung; ?> + kurzbz; ?> + studiengang_kz; ?> + + studiengang_kz ORDER BY semester"; + if(!($result_sem=pg_query($conn, $sql_query))) + die(pg_errormessage($conn)); + $num_rows_sem=pg_numrows($result_sem); + for ($j=0; $j<$num_rows_sem; $j++) + { + $row_sem=pg_fetch_object($result_sem, $j); + ?> + + kurzbz.'-'.$row_sem->semester; ?> + kurzbz; ?> + studiengang_kz; ?> + semester; ?> + + studiengang_kz AND semester=$row_sem->semester ORDER BY verband"; + if(!($result_ver=pg_exec($conn, $sql_query))) + die(pg_errormessage($conn)); + $num_rows_ver=pg_numrows($result_ver); + for ($k=0; $k<$num_rows_ver; $k++) + { + $row_ver=pg_fetch_object($result_ver, $k); + ?> + + kurzbz.'-'.$row_sem->semester.$row_ver->verband; ?> + kurzbz; ?> + studiengang_kz; ?> + semester; ?> + verband; ?> + + studiengang_kz AND semester=$row_sem->semester AND verband='$row_ver->verband' ORDER BY gruppe"; + if(!($result_grp=pg_exec($conn, $sql_query))) die(pg_errormessage($conn)); + $num_rows_grp=pg_numrows($result_grp); + for ($l=0; $l<$num_rows_grp; $l++) + { + $row_grp=pg_fetch_object($result_grp, $l); + ?> + + kurzbz.'-'.$row_sem->semester.$row_ver->verband.$row_grp->gruppe; ?> + kurzbz; ?> + studiengang_kz; ?> + semester; ?> + verband; ?> + gruppe; ?> + + studiengang_kz AND semester=$row_sem->semester ORDER BY bezeichnung"; + //echo $sql_query; + if(!($result_einh=pg_exec($conn, $sql_query))) + die(pg_errormessage($conn)); + $num_rows_einh=pg_numrows($result_einh); + for ($m=0; $m<$num_rows_einh; $m++) + { + $row_einh=pg_fetch_object($result_einh, $m); + ?> + + einheit_kurzbz.'-'.$row_einh->bezeichnung; ?> + kurzbz; ?> + studiengang_kz; ?> + semester; ?> + einheit_kurzbz; ?> + + + + + + + + + studiengang_kz ORDER BY semester"; + if(!($result_sem=pg_query($conn, $sql_query))) + die(pg_errormessage($conn)); + $num_rows_sem=pg_numrows($result_sem); + for ($j=0; $j<$num_rows_sem; $j++) + { + $row_sem=pg_fetch_object($result_sem, $j); + ?> + + + + studiengang_kz AND semester=$row_sem->semester ORDER BY verband"; + if(!($result_ver=pg_exec($conn, $sql_query))) + die(pg_errormessage($conn)); + $num_rows_ver=pg_numrows($result_ver); + for ($k=0; $k<$num_rows_ver; $k++) + { + $row_ver=pg_fetch_object($result_ver, $k); + ?> + + + + studiengang_kz AND semester=$row_sem->semester AND verband='$row_ver->verband' ORDER BY gruppe"; + if(!($result_grp=pg_exec($conn, $sql_query))) + die(pg_errormessage($conn)); + $num_rows_grp=pg_numrows($result_grp); + for ($l=0; $l<$num_rows_grp; $l++) + { + $row_grp=pg_fetch_object($result_grp, $l); + ?> + + + + + studiengang_kz AND semester=$row_sem->semester ORDER BY bezeichnung"; + //echo $sql_query; + if(!($result_einh=pg_exec($conn, $sql_query))) + die(pg_errormessage($conn)); + $num_rows_einh=pg_numrows($result_einh); + for ($m=0; $m<$num_rows_einh; $m++) + { + $row_einh=pg_fetch_object($result_einh, $m); + ?> + + + + + + + + + + + + diff --git a/rdf/student.rdf.php b/rdf/student.rdf.php new file mode 100644 index 000000000..1a772e764 --- /dev/null +++ b/rdf/student.rdf.php @@ -0,0 +1,102 @@ +'; +// DAO +include('../vilesci/config.inc.php'); +include_once('../include/person.class.php'); +include_once('../include/student.class.php'); + +// Datenbank Verbindung +if (!$conn = @pg_pconnect(CONN_STRING)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + +// test +/* +$einheit_kurzbz=''; +$grp='1'; +$ver='A'; +$sem=3; +$stg_kz=145; +*/ +function convdate($date) +{ + list($d,$m,$y) = explode('.',$date); + return $y.'-'.$m.'-'.$d; +} +$einheit_kurzbz=(isset($_GET['einheit'])?$_GET['einheit']:''); +$grp=(isset($_GET['grp'])?$_GET['grp']:''); +$ver=(isset($_GET['ver'])?$_GET['ver']:''); +$sem=(isset($_GET['sem'])?$_GET['sem']:''); +$stg_kz=(isset($_GET['stg_kz'])?$_GET['stg_kz']:''); +if(isset($_GET['uid'])) + $uid=$_GET['uid']; + +// Studenten holen +$studentenDAO=new student($conn); +if (isset($uid)) + $studenten=$studentenDAO->load($uid); +else + $studenten=$studentenDAO->getStudents($einheit_kurzbz, $grp, $ver, $sem,$stg_kz); + +$rdf_url='http://www.technikum-wien.at/tempus/studenten'; + +?> + + + + + + + + + + uid ?> + titel ?> + vornamen ?> + nachname ?> + matrikelnr ?> + gebdatum ?> + gebdatum); ?> + email ?> + homepage ?> + aktiv?'True':'False') ?> + gebort ?> + gebzeit ?> + foto ?> + anmerkungen ?> + updateamum ?> + updatevon ?> + semester ?> + verband ?> + gruppe ?> + studiengang_kz ?> + stg_bezeichnung ?> + + + + + + + + \ No newline at end of file diff --git a/rdf/studenten.rdf.php b/rdf/studenten.rdf.php new file mode 100644 index 000000000..d467843bd --- /dev/null +++ b/rdf/studenten.rdf.php @@ -0,0 +1,97 @@ +'; +// DAO +include('../vilesci/config.inc.php'); +include_once('../include/person.class.php'); +include_once('../include/student.class.php'); + +// Datenbank Verbindung +if (!$conn = @pg_pconnect(CONN_STRING)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + +// test +/* +$einheit_kurzbz=''; +$grp='1'; +$ver='A'; +$sem=3; +$stg_kz=145; +*/ +function convdate($date) +{ + list($d,$m,$y) = explode('.',$date); + return $y.'-'.$m.'-'.$d; +} +$einheit_kurzbz=$_GET['einheit']; +$grp=$_GET['grp']; +$ver=$_GET['ver']; +$sem=$_GET['sem']; +$stg_kz=$_GET['stg_kz']; + +// Studenten holen +$studentenDAO=new student($conn); +$studenten=$studentenDAO->getStudents($einheit_kurzbz, $grp, $ver, $sem,$stg_kz); + +$rdf_url='http://www.technikum-wien.at/tempus/studenten'; + +?> + + + + + + + + + + uid ?> + titel ?> + vornamen ?> + nachname ?> + matrikelnr ?> + gebdatum ?> + gebdatum); ?> + email ?> + homepage ?> + aktiv?'True':'False') ?> + gebort ?> + gebzeit ?> + foto ?> + anmerkungen ?> + updateamum ?> + updatevon ?> + gruppe ?> + verband ?> + semester ?> + studiengang_kz ?> + stg_bezeichnung ?> + + + + + + + + \ No newline at end of file diff --git a/rdf/studiengang.rdf.php b/rdf/studiengang.rdf.php new file mode 100644 index 000000000..d498ab26f --- /dev/null +++ b/rdf/studiengang.rdf.php @@ -0,0 +1,66 @@ +'; +// DAO +include('../vilesci/config.inc.php'); +include_once('../include/studiengang.class.php'); + +// Datenbank Verbindung +if (!$conn = @pg_pconnect(CONN_STRING)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + +// raumtypen holen +$studiengangDAO=new studiengang($conn); +$studiengaenge=$studiengangDAO->getAll(); + +$rdf_url='http://www.technikum-wien.at/tempus/studiengang'; + +?> + + + + + + + + + studiengang_kz ?> + kurzbz ?> + kurzbzlang ?> + bezeichnung ?> + max_semester ?> + typ ?> + farbe ?> + email ?> + + + + + + + \ No newline at end of file diff --git a/rdf/studiensemester.rdf.php b/rdf/studiensemester.rdf.php new file mode 100644 index 000000000..a29eaf0c0 --- /dev/null +++ b/rdf/studiensemester.rdf.php @@ -0,0 +1,60 @@ +'; +// DAO +include('../vilesci/config.inc.php'); +include_once('../include/studiensemester.class.php'); + +// Datenbank Verbindung +if (!$conn = @pg_pconnect(CONN_STRING)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; + +// studiensemester holen +$studiensemesterDAO=new studiensemester($conn); +$studiensemesterAll=$studiensemesterDAO->getAll(); + +$rdf_url='http://www.technikum-wien.at/tempus/studiensemester'; + +?> + + + + + + + + + + + kurzbz ?> + start ?> ]]> + ende ?> + + + + + + + + diff --git a/rdf/xxxstpl-lehrstunde.rdf.php b/rdf/xxxstpl-lehrstunde.rdf.php new file mode 100644 index 000000000..e6cbee098 --- /dev/null +++ b/rdf/xxxstpl-lehrstunde.rdf.php @@ -0,0 +1,101 @@ +'; +echo ''; +include('../vilesci/config.inc.php'); +include('../include/functions.inc.php'); +include('../include/lehrstunde.class.php'); +include('../include/stundenplan.class.php'); + +// Testumgebung +if (!isset($REMOTE_USER)) + $REMOTE_USER='pam'; + +$uid=$REMOTE_USER; + +// Variablen uebernehmen +if (isset($_GET[aktion])) + $aktion=$_GET[aktion]; +if (isset($_GET[new_stunde])) + $new_stunde=$_GET[new_stunde]; +if (isset($_GET[new_datum])) + $new_datum=$_GET[new_datum]; +if (isset($_GET[type])) + $type=$_GET[type]; +if (isset($_GET[ort_kurzbz])) + $ort_kurzbz=$_GET[ort_kurzbz]; +else + $ort_kurzbz='EDV6.08'; +$i=0; +$name_stpl_id='stundenplan_id'.$i; +while ($i<100 && isset($_GET[$name_stpl_id])) +{ + $stpl_id[]=$_GET[$name_stpl_id]; + //echo $stpl_id[$i]; + $name_stpl_id='stundenplan_id'.++$i; + +} + + +if (!$conn = @pg_pconnect(CONN_STRING)) + $error_msg='Es konnte keine Verbindung zum Server aufgebaut werden!'; +$error_msg.=loadVariables($conn,$REMOTE_USER); + +// Authentifizierung +if ($uid=check_student($REMOTE_USER, $conn)) + $user='student'; +elseif ($uid=check_lektor($REMOTE_USER, $conn)) + $user='lektor'; +else + die("Cannot set usertype!"); + + // User bestimmen +if (!isset($type)) + $type=$user; +if (!isset($pers_uid)) + $pers_uid=$uid; + + // Datums Format +$erg_std=pg_query($conn, "SET datestyle TO ISO;") + or die(pg_last_error($conn)); + + +// Aktionen durchfuehren +if ($aktion=='stplverschieben') +{ + foreach ($stpl_id as $stundenplan_id) + { + $lehrstunde=new lehrstunde($conn); + $lehrstunde->load($stundenplan_id,$db_stpl_table); + $lehrstunde->datum=$new_datum; + $lehrstunde->stunde=$new_stunde; + $lehrstunde->save($db_stpl_table); + } +} +// Stundenplan abfragen +$stdplan=new stundenplan($type,$conn); +if (!isset($datum)) + $datum=mktime(); + +// Benutzergruppe +$stdplan->user=$user; +// aktueller Benutzer +$stdplan->user_uid=$uid; + +// Zusaetzliche Daten laden +if (! $stdplan->load_data($type,$pers_uid,$ort_kurzbz,$stg_kz,$sem,$ver,$grp,$einheit_kurzbz,$db_table) ) + die($stdplan->errormsg); +// Stundenplan einer Woche laden +if (! $stdplan->load_week($datum,$db_stpl_table)) + die($stdplan->errormsg); +// Kopfbereich drucken + +// Stundenplan der Woche in RDF drucken +$stdplan->draw_week_rdf(); +?> \ No newline at end of file diff --git a/skin/cis.css b/skin/cis.css new file mode 100644 index 000000000..82ba86ae8 --- /dev/null +++ b/skin/cis.css @@ -0,0 +1,273 @@ +body +{ + background-color: White; + font-family: Arial, Helvetica, sans-serif; + font-size: x-small; + /*IE hack*/ + voice-family: "\"}\""; + voice-family: inherit; + font-size: small; + /*IE hack end*/ +} + +a +{ + color: #008381; text-decoration: none; + cursor: pointer; +} + +a.HyperItem +{ + color: Black; text-decoration: none; + font-weight: bold; +} + +a.Item2 +{ + color: Black; text-decoration: none; +} + +a[onClick]:hover.Item +{ + color: Black; text-decoration: none; +} + +a:hover.Item +{ + color: Black; text-decoration: none; +} + +a:hover.Item +{ + color: Black; text-decoration: none; +} + +a:hover.Item2 +{ + color: #008381; text-decoration: none; +} + +a.MenuItem +{ + color: #008381; text-decoration: none; + font-weight: bold; +} + +a:hover.MenuItem +{ + color: Black; text-decoration: none; + font-weight: bold; +} + +img +{ + border: 0; +} + +td.ContentHeader +{ + background-color: #008381; + font-weight: bold; + height: 19px; +} + +td.ContentHeader2 +{ + background-color: #CCCCCC; + font-weight: normal; + height: 19px +} + +td.ContentHeader3 +{ + background-color: #CCCCCC; + font-weight: bold; + height: 19px +} + +td.MarkLine +{ + background-color: #F2F2F2; +} + +TR.liste +{ + background-color: #D3DCE3; +} +TR.liste0 +{ + background-color: #FFFFFF; +} +TR.liste1 +{ + background-color: #EEEEEE; +} +TABLE.stdplan +{ + border: 1; + cellspacing: 0; + cellpadding: 0; + font-size: small; +} + +TABLE.stdplan TH +{ + background-color: #DDDDDD; +} + +TABLE.stdplan TD +{ + background-color: #EEEEEE +} + + +input.TextBox +{ + background-color: White; +} + +font.headline +{ + font-size: 20px; + line-height: 24px; + color: #003399; + font-family: Verdana, Arial, Helvetica, sans-serif; + margin-bottom: 0px; + margin-top: 0px; +} + +font.subline +{ + font-size: 17px; + line-height: 20px; + color: #003399; + font-family: Verdana, Arial, Helvetica, sans-serif; + margin-bottom: 0px; + margin-top: 0px; +} + +font.ContentHeader +{ + color: #FFFFFF; +} + +.row-even { + background-color:#f2f2f2; +} + +.row-odd { + background-color:#ffffff; +} +A.stpl_detail +{ + font-size:x-small; + color:#000000; + text-decoration:none; +} +A.stpl_detail:hover +{ + font-size:x-small; + color:#000000; + text-decoration:underline; + cursor:hand; +} +A.hilfe +{ + text-decoration:none; +} +A.hilfe:hover +{ + text-decoration:none; + cursor:help; +} +#bgcolor0 +{ + background-color: #FF0000; +} +#bgcolor1 +{ + background-color: #FF4444; +} +#bgcolor2 +{ + background-color: #FF7777; +} +#bgcolor3 +{ + background-color: #C0EEC0; +} +#bgcolor4 +{ + background-color: #77FF77; +} +#bgcolor5 +{ + background-color: #44FF44; +} +#bgcolor6 +{ + background-color: #00FF00; +} + +h1 +{ + font-size: medium; + color: #ffffff; + background-color: #009e84; +} +h1 td +{ + font-size: medium; + color: #ffffff; + background-color: #009e84; +} +h1 a +{ + color: #dddddd; +} +h1 a:hover +{ + color: #ffffff; + text-decoration:none; +} + +h2 +{ + font-size: small; + color: #ffffff; + background-color: #00a4d2; +} +h2 td +{ + font-size: small; + color: #ffffff; + background-color: #00a4d2; +} +h2 a +{ + color: #dddddd; +} +h2 a:hover +{ + color: #ffffff; + text-decoration:none; +} + +h3 +{ + font-size: small; + font-weight: bold; + color: #008E74; +} +h4 +{ + font-size: x-small; + font-style: normal; + line-height: normal; + font-weight: bold; + font-variant: normal; + text-transform: none; + color: #008E74; + cursor: hand; + text-decoration: none; +} \ No newline at end of file diff --git a/skin/fas.css b/skin/fas.css new file mode 100644 index 000000000..783689abf --- /dev/null +++ b/skin/fas.css @@ -0,0 +1,43 @@ +@import url("chrome://navigator/skin/"); +tree treecol +{ + background-color: #82DCFF; /*F2F2FC*/ +} + +treechildren::-moz-tree-row(selected) { background-color: #50D1E1; } +treechildren::-moz-tree-row(odd) { background-color: #EEEEEE; } +treechildren::-moz-tree-row(odd, selected) { background-color: #50D1E1; } +treechildren::-moz-tree-row(even, selected) { background-color: #50D1E1; } +treechildren::-moz-tree-cell-text(selected) { color: #000000; } +treechildren::-moz-tree-cell-text(odd, selected) { color: #000000; } + +menubar,menulist,toolbar,tabpanels,tabbox,iframe,box,hbox,vbox,tree,description +{ + border-width: 0px; + border-color: #AAAAAA; + padding: 0px; +} + + +button.change +{ + border-style:solid; + padding:0px; + margin: 0px; +} + +.hbox-tree +{ + padding: 5px; +} + +.style-groupbox +{ + padding-bottom: 5px; +} + +.pflichtfeld +{ + /*Formatierungen fuer die Pflichtfelder*/ +} + diff --git a/skin/images/1st_floor.gif b/skin/images/1st_floor.gif new file mode 100644 index 000000000..e297e1934 Binary files /dev/null and b/skin/images/1st_floor.gif differ diff --git a/skin/images/2nd_floor.gif b/skin/images/2nd_floor.gif new file mode 100644 index 000000000..957f94a45 Binary files /dev/null and b/skin/images/2nd_floor.gif differ diff --git a/skin/images/3rd_floor.gif b/skin/images/3rd_floor.gif new file mode 100644 index 000000000..9306507c3 Binary files /dev/null and b/skin/images/3rd_floor.gif differ diff --git a/skin/images/4th_floor.gif b/skin/images/4th_floor.gif new file mode 100644 index 000000000..8d3202939 Binary files /dev/null and b/skin/images/4th_floor.gif differ diff --git a/skin/images/5th_floor.gif b/skin/images/5th_floor.gif new file mode 100644 index 000000000..ba2480ee7 Binary files /dev/null and b/skin/images/5th_floor.gif differ diff --git a/skin/images/6th_floor.gif b/skin/images/6th_floor.gif new file mode 100644 index 000000000..9b7c2c823 Binary files /dev/null and b/skin/images/6th_floor.gif differ diff --git a/skin/images/DeleteIcon.png b/skin/images/DeleteIcon.png new file mode 100644 index 000000000..9db040b43 Binary files /dev/null and b/skin/images/DeleteIcon.png differ diff --git a/skin/images/ExcelIcon.png b/skin/images/ExcelIcon.png new file mode 100644 index 000000000..72057f6f1 Binary files /dev/null and b/skin/images/ExcelIcon.png differ diff --git a/skin/images/FAS.ico b/skin/images/FAS.ico new file mode 100644 index 000000000..7ab8e913c Binary files /dev/null and b/skin/images/FAS.ico differ diff --git a/skin/images/Hauptmenue.png b/skin/images/Hauptmenue.png new file mode 100644 index 000000000..2d2258177 Binary files /dev/null and b/skin/images/Hauptmenue.png differ diff --git a/skin/images/NeuDokument.png b/skin/images/NeuDokument.png new file mode 100644 index 000000000..3e3a02ecc Binary files /dev/null and b/skin/images/NeuDokument.png differ diff --git a/skin/images/OutlookImpDuplikate.png b/skin/images/OutlookImpDuplikate.png new file mode 100644 index 000000000..41bc65f24 Binary files /dev/null and b/skin/images/OutlookImpDuplikate.png differ diff --git a/skin/images/OutlookImpImport.png b/skin/images/OutlookImpImport.png new file mode 100644 index 000000000..bb917e624 Binary files /dev/null and b/skin/images/OutlookImpImport.png differ diff --git a/skin/images/OutlookImpKalender.png b/skin/images/OutlookImpKalender.png new file mode 100644 index 000000000..4a6acc2cf Binary files /dev/null and b/skin/images/OutlookImpKalender.png differ diff --git a/skin/images/OutlookImpKomma.png b/skin/images/OutlookImpKomma.png new file mode 100644 index 000000000..fbb24c4d4 Binary files /dev/null and b/skin/images/OutlookImpKomma.png differ diff --git a/skin/images/OutlookImpMenu.gif b/skin/images/OutlookImpMenu.gif new file mode 100644 index 000000000..1f3a4672a Binary files /dev/null and b/skin/images/OutlookImpMenu.gif differ diff --git a/skin/images/OutlookImpSmbol.gif b/skin/images/OutlookImpSmbol.gif new file mode 100644 index 000000000..b9ebbe080 Binary files /dev/null and b/skin/images/OutlookImpSmbol.gif differ diff --git a/skin/images/Outlookimport.png b/skin/images/Outlookimport.png new file mode 100644 index 000000000..911795e30 Binary files /dev/null and b/skin/images/Outlookimport.png differ diff --git a/skin/images/Saalplan_mit_Legende.png b/skin/images/Saalplan_mit_Legende.png new file mode 100644 index 000000000..4539a481f Binary files /dev/null and b/skin/images/Saalplan_mit_Legende.png differ diff --git a/skin/images/TWLogo_klein.gif b/skin/images/TWLogo_klein.gif new file mode 100644 index 000000000..fc0abc637 Binary files /dev/null and b/skin/images/TWLogo_klein.gif differ diff --git a/skin/images/TWLogo_klein.jpg b/skin/images/TWLogo_klein.jpg new file mode 100644 index 000000000..39b278f98 Binary files /dev/null and b/skin/images/TWLogo_klein.jpg differ diff --git a/skin/images/TWLogo_klein.png b/skin/images/TWLogo_klein.png new file mode 100644 index 000000000..0b834921b Binary files /dev/null and b/skin/images/TWLogo_klein.png differ diff --git a/skin/images/TW_Logo_klein.jpg b/skin/images/TW_Logo_klein.jpg new file mode 100644 index 000000000..096cb6539 Binary files /dev/null and b/skin/images/TW_Logo_klein.jpg differ diff --git a/skin/images/Tempus.ico b/skin/images/Tempus.ico new file mode 100644 index 000000000..d7e8312b4 Binary files /dev/null and b/skin/images/Tempus.ico differ diff --git a/skin/images/TempusGruen.ico b/skin/images/TempusGruen.ico new file mode 100644 index 000000000..f06a51a35 Binary files /dev/null and b/skin/images/TempusGruen.ico differ diff --git a/skin/images/background_linie.jpg b/skin/images/background_linie.jpg new file mode 100644 index 000000000..9654eeef8 Binary files /dev/null and b/skin/images/background_linie.jpg differ diff --git a/skin/images/background_main.jpg b/skin/images/background_main.jpg new file mode 100644 index 000000000..0424d7ada Binary files /dev/null and b/skin/images/background_main.jpg differ diff --git a/skin/images/bg.gif b/skin/images/bg.gif new file mode 100644 index 000000000..425749db0 Binary files /dev/null and b/skin/images/bg.gif differ diff --git a/skin/images/bg_.gif b/skin/images/bg_.gif new file mode 100644 index 000000000..381325e5c Binary files /dev/null and b/skin/images/bg_.gif differ diff --git a/skin/images/bg_anwesenheit.gif b/skin/images/bg_anwesenheit.gif new file mode 100644 index 000000000..783a1097b Binary files /dev/null and b/skin/images/bg_anwesenheit.gif differ diff --git a/skin/images/bg_cut.jpg b/skin/images/bg_cut.jpg new file mode 100644 index 000000000..541c01de8 Binary files /dev/null and b/skin/images/bg_cut.jpg differ diff --git a/skin/images/bgq.gif b/skin/images/bgq.gif new file mode 100644 index 000000000..10d7496cc Binary files /dev/null and b/skin/images/bgq.gif differ diff --git a/skin/images/blank.gif b/skin/images/blank.gif new file mode 100644 index 000000000..35d42e808 Binary files /dev/null and b/skin/images/blank.gif differ diff --git a/skin/images/bugtracking-01.jpg b/skin/images/bugtracking-01.jpg new file mode 100644 index 000000000..ac757aab1 Binary files /dev/null and b/skin/images/bugtracking-01.jpg differ diff --git a/skin/images/bugtracking-02.jpg b/skin/images/bugtracking-02.jpg new file mode 100644 index 000000000..83db3d48f Binary files /dev/null and b/skin/images/bugtracking-02.jpg differ diff --git a/skin/images/bugtracking-03.jpg b/skin/images/bugtracking-03.jpg new file mode 100644 index 000000000..2b1d8e54c Binary files /dev/null and b/skin/images/bugtracking-03.jpg differ diff --git a/skin/images/bugtracking-04.jpg b/skin/images/bugtracking-04.jpg new file mode 100644 index 000000000..b6d3aeba0 Binary files /dev/null and b/skin/images/bugtracking-04.jpg differ diff --git a/skin/images/bugtracking-05.jpg b/skin/images/bugtracking-05.jpg new file mode 100644 index 000000000..a013009d4 Binary files /dev/null and b/skin/images/bugtracking-05.jpg differ diff --git a/skin/images/bugtracking-06.jpg b/skin/images/bugtracking-06.jpg new file mode 100644 index 000000000..496e36ce9 Binary files /dev/null and b/skin/images/bugtracking-06.jpg differ diff --git a/skin/images/button_dl.jpg b/skin/images/button_dl.jpg new file mode 100644 index 000000000..6e6f3b4df Binary files /dev/null and b/skin/images/button_dl.jpg differ diff --git a/skin/images/button_fb.jpg b/skin/images/button_fb.jpg new file mode 100644 index 000000000..1dce09417 Binary files /dev/null and b/skin/images/button_fb.jpg differ diff --git a/skin/images/button_i.jpg b/skin/images/button_i.jpg new file mode 100644 index 000000000..26477534d Binary files /dev/null and b/skin/images/button_i.jpg differ diff --git a/skin/images/button_kt.jpg b/skin/images/button_kt.jpg new file mode 100644 index 000000000..1751fc504 Binary files /dev/null and b/skin/images/button_kt.jpg differ diff --git a/skin/images/button_lb.jpg b/skin/images/button_lb.jpg new file mode 100644 index 000000000..02c3e24e6 Binary files /dev/null and b/skin/images/button_lb.jpg differ diff --git a/skin/images/button_lv-info.jpg b/skin/images/button_lv-info.jpg new file mode 100644 index 000000000..f9b15ea14 Binary files /dev/null and b/skin/images/button_lv-info.jpg differ diff --git a/skin/images/button_lv.jpg b/skin/images/button_lv.jpg new file mode 100644 index 000000000..5f7aa0cb6 Binary files /dev/null and b/skin/images/button_lv.jpg differ diff --git a/skin/images/button_ng.jpg b/skin/images/button_ng.jpg new file mode 100644 index 000000000..d8b97e8f6 Binary files /dev/null and b/skin/images/button_ng.jpg differ diff --git a/skin/images/button_semplan.jpg b/skin/images/button_semplan.jpg new file mode 100644 index 000000000..ee7307120 Binary files /dev/null and b/skin/images/button_semplan.jpg differ diff --git a/skin/images/button_termplan.jpg b/skin/images/button_termplan.jpg new file mode 100644 index 000000000..02c3e24e6 Binary files /dev/null and b/skin/images/button_termplan.jpg differ diff --git a/skin/images/button_test.jpg b/skin/images/button_test.jpg new file mode 100644 index 000000000..a4ef3fc65 Binary files /dev/null and b/skin/images/button_test.jpg differ diff --git a/skin/images/button_ul.jpg b/skin/images/button_ul.jpg new file mode 100644 index 000000000..0fcf74f38 Binary files /dev/null and b/skin/images/button_ul.jpg differ diff --git a/skin/images/cdmenue01.JPG b/skin/images/cdmenue01.JPG new file mode 100644 index 000000000..0a851aa05 Binary files /dev/null and b/skin/images/cdmenue01.JPG differ diff --git a/skin/images/crossline_l.gif b/skin/images/crossline_l.gif new file mode 100644 index 000000000..de48e8041 Binary files /dev/null and b/skin/images/crossline_l.gif differ diff --git a/skin/images/crossline_r.gif b/skin/images/crossline_r.gif new file mode 100644 index 000000000..c0c94fca2 Binary files /dev/null and b/skin/images/crossline_r.gif differ diff --git a/skin/images/csv-symbol.gif b/skin/images/csv-symbol.gif new file mode 100644 index 000000000..a4891ad5e Binary files /dev/null and b/skin/images/csv-symbol.gif differ diff --git a/skin/images/csv.gif b/skin/images/csv.gif new file mode 100644 index 000000000..8579a565d Binary files /dev/null and b/skin/images/csv.gif differ diff --git a/skin/images/csv.ico b/skin/images/csv.ico new file mode 100644 index 000000000..9100c46bc Binary files /dev/null and b/skin/images/csv.ico differ diff --git a/skin/images/csv.png b/skin/images/csv.png new file mode 100644 index 000000000..74a80de87 Binary files /dev/null and b/skin/images/csv.png differ diff --git a/skin/images/dotpic.gif b/skin/images/dotpic.gif new file mode 100644 index 000000000..a090d6a4c Binary files /dev/null and b/skin/images/dotpic.gif differ diff --git a/skin/images/drucken.png b/skin/images/drucken.png new file mode 100644 index 000000000..1ca98938b Binary files /dev/null and b/skin/images/drucken.png differ diff --git a/skin/images/dummy.gif b/skin/images/dummy.gif new file mode 100644 index 000000000..d36072c6a Binary files /dev/null and b/skin/images/dummy.gif differ diff --git a/skin/images/einstellungen01.JPG b/skin/images/einstellungen01.JPG new file mode 100644 index 000000000..3bddb5f61 Binary files /dev/null and b/skin/images/einstellungen01.JPG differ diff --git a/skin/images/empty_picture.jpg b/skin/images/empty_picture.jpg new file mode 100644 index 000000000..16059b465 Binary files /dev/null and b/skin/images/empty_picture.jpg differ diff --git a/skin/images/entry.gif b/skin/images/entry.gif new file mode 100644 index 000000000..424b6dfa6 Binary files /dev/null and b/skin/images/entry.gif differ diff --git a/skin/images/excel.gif b/skin/images/excel.gif new file mode 100644 index 000000000..c6f8412f9 Binary files /dev/null and b/skin/images/excel.gif differ diff --git a/skin/images/false.gif b/skin/images/false.gif new file mode 100644 index 000000000..6b4b0f920 Binary files /dev/null and b/skin/images/false.gif differ diff --git a/skin/images/fentry.gif b/skin/images/fentry.gif new file mode 100644 index 000000000..3f6f6b679 Binary files /dev/null and b/skin/images/fentry.gif differ diff --git a/skin/images/file.gif b/skin/images/file.gif new file mode 100644 index 000000000..dfff3a484 Binary files /dev/null and b/skin/images/file.gif differ diff --git a/skin/images/flagge-aut.gif b/skin/images/flagge-aut.gif new file mode 100644 index 000000000..7d93a9a07 Binary files /dev/null and b/skin/images/flagge-aut.gif differ diff --git a/skin/images/flagge-eng.gif b/skin/images/flagge-eng.gif new file mode 100644 index 000000000..54ce4508a Binary files /dev/null and b/skin/images/flagge-eng.gif differ diff --git a/skin/images/folder.gif b/skin/images/folder.gif new file mode 100644 index 000000000..28394894e Binary files /dev/null and b/skin/images/folder.gif differ diff --git a/skin/images/folderup.gif b/skin/images/folderup.gif new file mode 100644 index 000000000..9aa857953 Binary files /dev/null and b/skin/images/folderup.gif differ diff --git a/skin/images/gline.gif b/skin/images/gline.gif new file mode 100644 index 000000000..9def2ded9 Binary files /dev/null and b/skin/images/gline.gif differ diff --git a/skin/images/green_point.gif b/skin/images/green_point.gif new file mode 100644 index 000000000..171374a0d Binary files /dev/null and b/skin/images/green_point.gif differ diff --git a/skin/images/haken.gif b/skin/images/haken.gif new file mode 100644 index 000000000..de8648a16 Binary files /dev/null and b/skin/images/haken.gif differ diff --git a/skin/images/header_line.gif b/skin/images/header_line.gif new file mode 100644 index 000000000..9def2ded9 Binary files /dev/null and b/skin/images/header_line.gif differ diff --git a/skin/images/hline.gif b/skin/images/hline.gif new file mode 100644 index 000000000..5e9893fe3 Binary files /dev/null and b/skin/images/hline.gif differ diff --git a/skin/images/hline_tl.gif b/skin/images/hline_tl.gif new file mode 100644 index 000000000..bc7ead4ce Binary files /dev/null and b/skin/images/hline_tl.gif differ diff --git a/skin/images/hlinie_tr.gif b/skin/images/hlinie_tr.gif new file mode 100644 index 000000000..277553376 Binary files /dev/null and b/skin/images/hlinie_tr.gif differ diff --git a/skin/images/icon_delete.gif b/skin/images/icon_delete.gif new file mode 100644 index 000000000..cdbc15a69 Binary files /dev/null and b/skin/images/icon_delete.gif differ diff --git a/skin/images/icon_voransicht.gif b/skin/images/icon_voransicht.gif new file mode 100644 index 000000000..b213f90ee Binary files /dev/null and b/skin/images/icon_voransicht.gif differ diff --git a/skin/images/image_legend0.gif b/skin/images/image_legend0.gif new file mode 100644 index 000000000..e6fac5a12 Binary files /dev/null and b/skin/images/image_legend0.gif differ diff --git a/skin/images/image_map.gif b/skin/images/image_map.gif new file mode 100644 index 000000000..d3f2b51fc Binary files /dev/null and b/skin/images/image_map.gif differ diff --git a/skin/images/image_overview.gif b/skin/images/image_overview.gif new file mode 100644 index 000000000..7923a9592 Binary files /dev/null and b/skin/images/image_overview.gif differ diff --git a/skin/images/ko.gif b/skin/images/ko.gif new file mode 100644 index 000000000..16075a465 Binary files /dev/null and b/skin/images/ko.gif differ diff --git a/skin/images/left.gif b/skin/images/left.gif new file mode 100644 index 000000000..8beaaa4c9 Binary files /dev/null and b/skin/images/left.gif differ diff --git a/skin/images/left.png b/skin/images/left.png new file mode 100644 index 000000000..71b79cfd5 Binary files /dev/null and b/skin/images/left.png differ diff --git a/skin/images/left_end_blue.jpg b/skin/images/left_end_blue.jpg new file mode 100644 index 000000000..aca72d962 Binary files /dev/null and b/skin/images/left_end_blue.jpg differ diff --git a/skin/images/left_end_green.jpg b/skin/images/left_end_green.jpg new file mode 100644 index 000000000..afa769af2 Binary files /dev/null and b/skin/images/left_end_green.jpg differ diff --git a/skin/images/login.gif b/skin/images/login.gif new file mode 100644 index 000000000..7d7e54da1 Binary files /dev/null and b/skin/images/login.gif differ diff --git a/skin/images/logout.gif b/skin/images/logout.gif new file mode 100644 index 000000000..b538d8ef0 Binary files /dev/null and b/skin/images/logout.gif differ diff --git a/skin/images/lvaMulti.png b/skin/images/lvaMulti.png new file mode 100644 index 000000000..0398d0a7d Binary files /dev/null and b/skin/images/lvaMulti.png differ diff --git a/skin/images/lvaMultiDel.png b/skin/images/lvaMultiDel.png new file mode 100644 index 000000000..929ec2748 Binary files /dev/null and b/skin/images/lvaMultiDel.png differ diff --git a/skin/images/lvaSingle.png b/skin/images/lvaSingle.png new file mode 100644 index 000000000..8de4a81e4 Binary files /dev/null and b/skin/images/lvaSingle.png differ diff --git a/skin/images/lvaSingleDel.png b/skin/images/lvaSingleDel.png new file mode 100644 index 000000000..7013dd2b7 Binary files /dev/null and b/skin/images/lvaSingleDel.png differ diff --git a/skin/images/mailverteiler.jpg b/skin/images/mailverteiler.jpg new file mode 100644 index 000000000..15dcfbc51 Binary files /dev/null and b/skin/images/mailverteiler.jpg differ diff --git a/skin/images/medienkasten_mikrofonempfaenger.JPG b/skin/images/medienkasten_mikrofonempfaenger.JPG new file mode 100644 index 000000000..4f6ea17d1 Binary files /dev/null and b/skin/images/medienkasten_mikrofonempfaenger.JPG differ diff --git a/skin/images/medienkasten_mikrofonempfaenger01.JPG b/skin/images/medienkasten_mikrofonempfaenger01.JPG new file mode 100644 index 000000000..1e6f02d2e Binary files /dev/null and b/skin/images/medienkasten_mikrofonempfaenger01.JPG differ diff --git a/skin/images/menu_bg.jpg b/skin/images/menu_bg.jpg new file mode 100644 index 000000000..f75787dbe Binary files /dev/null and b/skin/images/menu_bg.jpg differ diff --git a/skin/images/menu_item.gif b/skin/images/menu_item.gif new file mode 100644 index 000000000..2dbc675fa Binary files /dev/null and b/skin/images/menu_item.gif differ diff --git a/skin/images/moreleft.gif b/skin/images/moreleft.gif new file mode 100644 index 000000000..2ad2dd0ad Binary files /dev/null and b/skin/images/moreleft.gif differ diff --git a/skin/images/moreleft.png b/skin/images/moreleft.png new file mode 100644 index 000000000..e679ea04d Binary files /dev/null and b/skin/images/moreleft.png differ diff --git a/skin/images/moremoreleft.png b/skin/images/moremoreleft.png new file mode 100644 index 000000000..ee83460b8 Binary files /dev/null and b/skin/images/moremoreleft.png differ diff --git a/skin/images/moremoreright.png b/skin/images/moremoreright.png new file mode 100644 index 000000000..a14e3c7e6 Binary files /dev/null and b/skin/images/moremoreright.png differ diff --git a/skin/images/moreright.gif b/skin/images/moreright.gif new file mode 100644 index 000000000..487d38a1a Binary files /dev/null and b/skin/images/moreright.gif differ diff --git a/skin/images/moreright.png b/skin/images/moreright.png new file mode 100644 index 000000000..e1c737d05 Binary files /dev/null and b/skin/images/moreright.png differ diff --git a/skin/images/nopic.gif b/skin/images/nopic.gif new file mode 100644 index 000000000..c1fce52cb Binary files /dev/null and b/skin/images/nopic.gif differ diff --git a/skin/images/ok.gif b/skin/images/ok.gif new file mode 100644 index 000000000..9315b8f9e Binary files /dev/null and b/skin/images/ok.gif differ diff --git a/skin/images/open.gif b/skin/images/open.gif new file mode 100644 index 000000000..6f7d09531 Binary files /dev/null and b/skin/images/open.gif differ diff --git a/skin/images/org-2004-17-A3.jpg b/skin/images/org-2004-17-A3.jpg new file mode 100644 index 000000000..4f256029e Binary files /dev/null and b/skin/images/org-2004-17-A3.jpg differ diff --git a/skin/images/org-2005-03-A5.jpg b/skin/images/org-2005-03-A5.jpg new file mode 100644 index 000000000..23d45825a Binary files /dev/null and b/skin/images/org-2005-03-A5.jpg differ diff --git a/skin/images/org-2005-03-A6.jpg b/skin/images/org-2005-03-A6.jpg new file mode 100644 index 000000000..c3c5cc8f9 Binary files /dev/null and b/skin/images/org-2005-03-A6.jpg differ diff --git a/skin/images/outlook.gif b/skin/images/outlook.gif new file mode 100644 index 000000000..e75ff495a Binary files /dev/null and b/skin/images/outlook.gif differ diff --git a/skin/images/outlook.ico b/skin/images/outlook.ico new file mode 100644 index 000000000..bc136896c Binary files /dev/null and b/skin/images/outlook.ico differ diff --git a/skin/images/outlook.png b/skin/images/outlook.png new file mode 100644 index 000000000..b209e362b Binary files /dev/null and b/skin/images/outlook.png differ diff --git a/skin/images/p.gif b/skin/images/p.gif new file mode 100644 index 000000000..dc4c02039 Binary files /dev/null and b/skin/images/p.gif differ diff --git a/skin/images/pc_steckfeld_audio.JPG b/skin/images/pc_steckfeld_audio.JPG new file mode 100644 index 000000000..832fe97fb Binary files /dev/null and b/skin/images/pc_steckfeld_audio.JPG differ diff --git a/skin/images/pdf.gif b/skin/images/pdf.gif new file mode 100644 index 000000000..ecb0f08ae Binary files /dev/null and b/skin/images/pdf.gif differ diff --git a/skin/images/pdf.ico b/skin/images/pdf.ico new file mode 100644 index 000000000..43f10900c Binary files /dev/null and b/skin/images/pdf.ico differ diff --git a/skin/images/pdfpic.gif b/skin/images/pdfpic.gif new file mode 100644 index 000000000..426c34648 Binary files /dev/null and b/skin/images/pdfpic.gif differ diff --git a/skin/images/person.gif b/skin/images/person.gif new file mode 100644 index 000000000..cc6e92f1c Binary files /dev/null and b/skin/images/person.gif differ diff --git a/skin/images/picpic.gif b/skin/images/picpic.gif new file mode 100644 index 000000000..4ee3202d6 Binary files /dev/null and b/skin/images/picpic.gif differ diff --git a/skin/images/pptpic.gif b/skin/images/pptpic.gif new file mode 100644 index 000000000..5f340d343 Binary files /dev/null and b/skin/images/pptpic.gif differ diff --git a/skin/images/qm.gif b/skin/images/qm.gif new file mode 100644 index 000000000..01bfb87cc Binary files /dev/null and b/skin/images/qm.gif differ diff --git a/skin/images/red_point.gif b/skin/images/red_point.gif new file mode 100644 index 000000000..e370d3e62 Binary files /dev/null and b/skin/images/red_point.gif differ diff --git a/skin/images/refresh.png b/skin/images/refresh.png new file mode 100644 index 000000000..771f8a5df Binary files /dev/null and b/skin/images/refresh.png differ diff --git a/skin/images/right.gif b/skin/images/right.gif new file mode 100644 index 000000000..a94e97ad3 Binary files /dev/null and b/skin/images/right.gif differ diff --git a/skin/images/right.png b/skin/images/right.png new file mode 100644 index 000000000..6bbd64c92 Binary files /dev/null and b/skin/images/right.png differ diff --git a/skin/images/right_end_blue.jpg b/skin/images/right_end_blue.jpg new file mode 100644 index 000000000..27ed9297c Binary files /dev/null and b/skin/images/right_end_blue.jpg differ diff --git a/skin/images/right_end_green.jpg b/skin/images/right_end_green.jpg new file mode 100644 index 000000000..ade30c58f Binary files /dev/null and b/skin/images/right_end_green.jpg differ diff --git a/skin/images/room_background_blue.jpg b/skin/images/room_background_blue.jpg new file mode 100644 index 000000000..9a580a041 Binary files /dev/null and b/skin/images/room_background_blue.jpg differ diff --git a/skin/images/room_background_green.jpg b/skin/images/room_background_green.jpg new file mode 100644 index 000000000..1eeea053b Binary files /dev/null and b/skin/images/room_background_green.jpg differ diff --git a/skin/images/seperator.gif b/skin/images/seperator.gif new file mode 100644 index 000000000..2dbc675fa Binary files /dev/null and b/skin/images/seperator.gif differ diff --git a/skin/images/stdpl_main.jpg b/skin/images/stdpl_main.jpg new file mode 100644 index 000000000..049c53d02 Binary files /dev/null and b/skin/images/stdpl_main.jpg differ diff --git a/skin/images/stdplan_menue.gif b/skin/images/stdplan_menue.gif new file mode 100644 index 000000000..217666342 Binary files /dev/null and b/skin/images/stdplan_menue.gif differ diff --git a/skin/images/stdplan_menue_pfeile.gif b/skin/images/stdplan_menue_pfeile.gif new file mode 100644 index 000000000..21254d2d3 Binary files /dev/null and b/skin/images/stdplan_menue_pfeile.gif differ diff --git a/skin/images/stdplan_ort_lektor.gif b/skin/images/stdplan_ort_lektor.gif new file mode 100644 index 000000000..1b140e7d9 Binary files /dev/null and b/skin/images/stdplan_ort_lektor.gif differ diff --git a/skin/images/stdplan_ort_lektor_pfeile.gif b/skin/images/stdplan_ort_lektor_pfeile.gif new file mode 100644 index 000000000..19e8d1d19 Binary files /dev/null and b/skin/images/stdplan_ort_lektor_pfeile.gif differ diff --git a/skin/images/stdplan_pers_student.gif b/skin/images/stdplan_pers_student.gif new file mode 100644 index 000000000..883f0b192 Binary files /dev/null and b/skin/images/stdplan_pers_student.gif differ diff --git a/skin/images/steckfeld01.JPG b/skin/images/steckfeld01.JPG new file mode 100644 index 000000000..c37c0854a Binary files /dev/null and b/skin/images/steckfeld01.JPG differ diff --git a/skin/images/steckfeld_audio.JPG b/skin/images/steckfeld_audio.JPG new file mode 100644 index 000000000..129c2b576 Binary files /dev/null and b/skin/images/steckfeld_audio.JPG differ diff --git a/skin/images/steckfeld_vga_laptop.JPG b/skin/images/steckfeld_vga_laptop.JPG new file mode 100644 index 000000000..b45675632 Binary files /dev/null and b/skin/images/steckfeld_vga_laptop.JPG differ diff --git a/skin/images/steckfeld_vga_visualizer.JPG b/skin/images/steckfeld_vga_visualizer.JPG new file mode 100644 index 000000000..311a20ceb Binary files /dev/null and b/skin/images/steckfeld_vga_visualizer.JPG differ diff --git a/skin/images/sunbird.png b/skin/images/sunbird.png new file mode 100644 index 000000000..df0a4e5cf Binary files /dev/null and b/skin/images/sunbird.png differ diff --git a/skin/images/technikum_logo.gif b/skin/images/technikum_logo.gif new file mode 100644 index 000000000..771015974 Binary files /dev/null and b/skin/images/technikum_logo.gif differ diff --git a/skin/images/texpic.jpg b/skin/images/texpic.jpg new file mode 100644 index 000000000..542235972 Binary files /dev/null and b/skin/images/texpic.jpg differ diff --git a/skin/images/ton.JPG b/skin/images/ton.JPG new file mode 100644 index 000000000..85803a7f0 Binary files /dev/null and b/skin/images/ton.JPG differ diff --git a/skin/images/ton_mikrofon_ea.JPG b/skin/images/ton_mikrofon_ea.JPG new file mode 100644 index 000000000..06a99eea0 Binary files /dev/null and b/skin/images/ton_mikrofon_ea.JPG differ diff --git a/skin/images/true.gif b/skin/images/true.gif new file mode 100644 index 000000000..9787addd0 Binary files /dev/null and b/skin/images/true.gif differ diff --git a/skin/images/tw_logo.gif b/skin/images/tw_logo.gif new file mode 100644 index 000000000..771015974 Binary files /dev/null and b/skin/images/tw_logo.gif differ diff --git a/skin/images/tw_logo.jpg b/skin/images/tw_logo.jpg new file mode 100644 index 000000000..3d7fe6815 Binary files /dev/null and b/skin/images/tw_logo.jpg differ diff --git a/skin/images/tw_logo_01.jpg b/skin/images/tw_logo_01.jpg new file mode 100644 index 000000000..096cb6539 Binary files /dev/null and b/skin/images/tw_logo_01.jpg differ diff --git a/skin/images/tw_logo_02.jpg b/skin/images/tw_logo_02.jpg new file mode 100644 index 000000000..08dfc75bb Binary files /dev/null and b/skin/images/tw_logo_02.jpg differ diff --git a/skin/images/upload.jpg b/skin/images/upload.jpg new file mode 100644 index 000000000..8c28e33ea Binary files /dev/null and b/skin/images/upload.jpg differ diff --git a/skin/images/vcal_v1.png b/skin/images/vcal_v1.png new file mode 100644 index 000000000..230cf57c0 Binary files /dev/null and b/skin/images/vcal_v1.png differ diff --git a/skin/images/vcal_v2.png b/skin/images/vcal_v2.png new file mode 100644 index 000000000..2167cb50e Binary files /dev/null and b/skin/images/vcal_v2.png differ diff --git a/skin/images/vcrmenue01.JPG b/skin/images/vcrmenue01.JPG new file mode 100644 index 000000000..9740158be Binary files /dev/null and b/skin/images/vcrmenue01.JPG differ diff --git a/skin/images/video_dvd01.JPG b/skin/images/video_dvd01.JPG new file mode 100644 index 000000000..b1a9c143d Binary files /dev/null and b/skin/images/video_dvd01.JPG differ diff --git a/skin/images/video_dvd02.JPG b/skin/images/video_dvd02.JPG new file mode 100644 index 000000000..1963f322a Binary files /dev/null and b/skin/images/video_dvd02.JPG differ diff --git a/skin/images/video_dvd03.JPG b/skin/images/video_dvd03.JPG new file mode 100644 index 000000000..ece6aa275 Binary files /dev/null and b/skin/images/video_dvd03.JPG differ diff --git a/skin/images/visualizer_lampe.JPG b/skin/images/visualizer_lampe.JPG new file mode 100644 index 000000000..0e2b0a9b5 Binary files /dev/null and b/skin/images/visualizer_lampe.JPG differ diff --git a/skin/images/visualizer_light.JPG b/skin/images/visualizer_light.JPG new file mode 100644 index 000000000..ad12a2975 Binary files /dev/null and b/skin/images/visualizer_light.JPG differ diff --git a/skin/images/visualizer_power.JPG b/skin/images/visualizer_power.JPG new file mode 100644 index 000000000..5132d6138 Binary files /dev/null and b/skin/images/visualizer_power.JPG differ diff --git a/skin/images/visualizer_zoom.JPG b/skin/images/visualizer_zoom.JPG new file mode 100644 index 000000000..5552f39eb Binary files /dev/null and b/skin/images/visualizer_zoom.JPG differ diff --git a/skin/images/vline.gif b/skin/images/vline.gif new file mode 100644 index 000000000..897068ea4 Binary files /dev/null and b/skin/images/vline.gif differ diff --git a/skin/images/web_s_org-2004-17-A3.jpg b/skin/images/web_s_org-2004-17-A3.jpg new file mode 100644 index 000000000..208a972d5 Binary files /dev/null and b/skin/images/web_s_org-2004-17-A3.jpg differ diff --git a/skin/images/web_s_org-2005-03-A5.jpg b/skin/images/web_s_org-2005-03-A5.jpg new file mode 100644 index 000000000..beab4c4d0 Binary files /dev/null and b/skin/images/web_s_org-2005-03-A5.jpg differ diff --git a/skin/images/web_s_org-2005-03-A6.jpg b/skin/images/web_s_org-2005-03-A6.jpg new file mode 100644 index 000000000..d42ea5c26 Binary files /dev/null and b/skin/images/web_s_org-2005-03-A6.jpg differ diff --git a/skin/images/website.gif b/skin/images/website.gif new file mode 100644 index 000000000..83f4aef1d Binary files /dev/null and b/skin/images/website.gif differ diff --git a/skin/images/website.ico b/skin/images/website.ico new file mode 100644 index 000000000..41a62594e Binary files /dev/null and b/skin/images/website.ico differ diff --git a/skin/images/website.png b/skin/images/website.png new file mode 100644 index 000000000..f88b6ccd6 Binary files /dev/null and b/skin/images/website.png differ diff --git a/skin/images/website3D.gif b/skin/images/website3D.gif new file mode 100644 index 000000000..83f4aef1d Binary files /dev/null and b/skin/images/website3D.gif differ diff --git a/skin/images/winscp2.jpg b/skin/images/winscp2.jpg new file mode 100644 index 000000000..ee789010a Binary files /dev/null and b/skin/images/winscp2.jpg differ diff --git a/skin/images/winscp2_dir_com.jpg b/skin/images/winscp2_dir_com.jpg new file mode 100644 index 000000000..0460f60aa Binary files /dev/null and b/skin/images/winscp2_dir_com.jpg differ diff --git a/skin/images/winscp2_dir_exp.jpg b/skin/images/winscp2_dir_exp.jpg new file mode 100644 index 000000000..dc6f71d9b Binary files /dev/null and b/skin/images/winscp2_dir_exp.jpg differ diff --git a/skin/images/winscp_browse.jpg b/skin/images/winscp_browse.jpg new file mode 100644 index 000000000..e596b0327 Binary files /dev/null and b/skin/images/winscp_browse.jpg differ diff --git a/skin/images/winscp_login.jpg b/skin/images/winscp_login.jpg new file mode 100644 index 000000000..aa9b9dcb6 Binary files /dev/null and b/skin/images/winscp_login.jpg differ diff --git a/skin/images/xlspic.gif b/skin/images/xlspic.gif new file mode 100644 index 000000000..000c5f17c Binary files /dev/null and b/skin/images/xlspic.gif differ diff --git a/skin/images/xml.png b/skin/images/xml.png new file mode 100644 index 000000000..b823f8013 Binary files /dev/null and b/skin/images/xml.png differ diff --git a/skin/images/zippic.jpg b/skin/images/zippic.jpg new file mode 100644 index 000000000..09608727a Binary files /dev/null and b/skin/images/zippic.jpg differ diff --git a/skin/tempus.css b/skin/tempus.css new file mode 100644 index 000000000..df39602c4 --- /dev/null +++ b/skin/tempus.css @@ -0,0 +1,48 @@ +@import url("chrome://communicator/skin/"); + +label.kalenderwoche +{ + font-size: medium; +} +button +{ + font-size: x-small; + min-width: 10px; +} +menubar,menupopup,toolbar,tabpanels,tabbox,iframe,box,hbox,vbox,tree,label,description +{ + border: 0px; + border-top: 0px; + border-bottom: 0px; + border-left: 0px; + border-right: 0px; + border-top-width: 0px; + border-bottom-width: 0px; + border-left-width: 0px; + border-right-width: 0px; + padding-top: 0px; + padding-bottom: 0px; + padding-left: 0px; + padding-right: 0px; +} +grid.lvaStundenplan +{ + font-size: x-small; +} +grid.lvaStundenplan button +{ + font-size: x-small; + border: 0px; + border-top: 0px; + border-bottom: 0px; + border-left: 0px; + border-right: 0px; + border-top-width: 0px; + border-bottom-width: 0px; + border-left-width: 0px; + border-right-width: 0px; + padding-top: 0px; + padding-bottom: 0px; + padding-left: 0px; + padding-right: 0px; +} \ No newline at end of file diff --git a/skin/vilesci.css b/skin/vilesci.css new file mode 100644 index 000000000..2be3ef6b9 --- /dev/null +++ b/skin/vilesci.css @@ -0,0 +1,307 @@ +body +{ + font-family: Verdana, Arial, Helvetica, Geneva, Swiss, SunSans-Regular; + font-size: small; + color: #000000; + background-color: #F6F7FF; +} + +TABLE +{ + font-size: small; +} + +TABLE.liste +{ + border: 1; + cellspacing: 0; + cellpadding: 0; + font-size: small; +} + +TR.liste +{ + background-color: #D3DCE3; +} +TR.liste0 +{ + background-color: #CCCCCC; +} +TR.liste1 +{ + background-color: #DDDDDD; +} +A.stpl_detail +{ + font-size:x-small; + color:#000000; + text-decoration:none; +} +A.stpl_detail:hover +{ + font-size:x-small; + color:#000000; + text-decoration:underline; + cursor:help; +} +a.linkgreen +{ + font-size:x-small; + color:#008E74; + text-decoration:none; +} +a.linkblue +{ + font-size:x-small; + color:#00A4D2; + text-decoration:none; +} +a.linkblue:hover +{ + font-size:x-small; + color:#00A4D2; + text-decoration:underline; + cursor:hand; +} +a +{ + color:#00A4D2; + text-decoration:none; +} +a:hover +{ + color:#00A4D2; + text-decoration:underline; + cursor:hand; +} +a.h1:hover +{ + color:#FFFFFF; + text-decoration:none; + cursor:hand; +} +img +{ + border:0; +} + +h1 { font-size: 14px; font-style: normal; line-height: normal; font-weight: normal; font-variant: normal; color: #ffffff; background-color: #009e84; text-decoration: none;} +h2 { font-size: 12px; font-style: normal; line-height: normal; font-weight: normal; font-variant: normal; color: #ffffff; background-color: #00a4d2; text-decoration: none;} +h3 { font-size: x-small; font-style: normal; line-height: normal; font-weight: bold; font-variant: normal; text-transform: none; color: #008E74; cursor: hand; text-decoration: none; } +h4 { font-size: medium; font-style: normal; line-height: normal; font-weight: bold; font-variant: normal; text-transform: none; color: #008E74; cursor: hand; text-decoration: none; } +p.littleblack { font-size: x-small; color: #000000;} + +.h1 { font-family: "Bookman Old Style"; font-size: 12px; font-style: normal; line-height: normal; font-weight: normal; font-variant: normal; color: #ffffff; background-color: #009e84; text-decoration: none} +.h2 { font-family: "Bookman Old Style"; font-size: 12px; font-style: normal; line-height: normal; font-weight: normal; font-variant: normal; color: #ffffff; background-color: #00a4d2; text-decoration: none} +body +{ + font-family: Verdana, Arial, Helvetica, Geneva, Swiss, SunSans-Regular; + font-size: small; + color: #000000; + background-color: #F6F7FF; +} + +TABLE +{ + font-size: small; +} + +TABLE.stdplan +{ + border: 1; + cellspacing: 0; + cellpadding: 0; + font-size: small; +} + +TABLE.stdplan TH +{ + background-color: #DDDDDD; +} + +TABLE.stdplan TD +{ + background-color: #EEEEEE +} + +TABLE.liste +{ + border: 1; + cellspacing: 0; + cellpadding: 0; + font-size: small; +} + +TR.liste +{ + background-color: #D3DCE3; +} +TR.liste0 +{ + background-color: #CCCCCC; +} +TR.liste1 +{ + background-color: #DDDDDD; +} + + + +FONT.beschriftung +{ + color:#666666; +} +P.little +{ + font-size: xx-small; +} + +A +{ + color:#00A4D2; + text-decoration:none; +} +A:hover +{ + color:#00A4D2; + text-decoration:underline; + cursor:hand; +} + +A.stpl_detail +{ + font-size:x-small; + color:#000000; + text-decoration:none; +} +A.stpl_detail:hover +{ + font-size:x-small; + color:#000000; + text-decoration:underline; + cursor:hand; +} +A.hilfe +{ + text-decoration:none; +} +A.hilfe:hover +{ + text-decoration:none; + cursor:help; +} +A.MenuItem1 +{ + color:#008E74; + text-decoration:none; +} +A.MenuItem1:hover +{ + color:#008E74; + text-decoration:underline; + cursor:hand; +} + +A.MenuItem2 +{ + color:#00A4D2; + text-decoration:none; +} +A.MenuItem2:hover +{ + color:#00A4D2; + text-decoration:underline; + cursor:hand; +} + +h1 +{ + font-size: medium; + color: #ffffff; + background-color: #009e84; +} +h1 td +{ + font-size: medium; + color: #ffffff; + background-color: #009e84; +} +h1 a +{ + color: #dddddd; +} +h1 a:hover +{ + color: #ffffff; + text-decoration:none; +} + +h2 +{ + font-size: small; + color: #ffffff; + background-color: #00a4d2; +} +h2 td +{ + font-size: small; + color: #ffffff; + background-color: #00a4d2; +} +h2 a +{ + color: #dddddd; +} +h2 a:hover +{ + color: #ffffff; + text-decoration:none; +} + +h3 +{ + font-size: x-small; + font-weight: bold; + color: #008E74; +} +h4 +{ + font-size: x-small; + font-style: normal; + line-height: normal; + font-weight: bold; + font-variant: normal; + text-transform: none; + color: #008E74; + cursor: hand; + text-decoration: none; } +#bgcolor0 +{ + background-color: #FF0000; +} +#bgcolor1 +{ + background-color: #FF4444; +} +#bgcolor2 +{ + background-color: #FF7777; +} +#bgcolor3 +{ + background-color: #C0EEC0; +} +#bgcolor4 +{ + background-color: #77FF77; +} +#bgcolor5 +{ + background-color: #44FF44; +} +#bgcolor6 +{ + background-color: #00FF00; +} + + diff --git a/vilesci/.htaccess b/vilesci/.htaccess new file mode 100644 index 000000000..83aef73ba --- /dev/null +++ b/vilesci/.htaccess @@ -0,0 +1,36 @@ +AuthName "Technikum-Wien" +AuthType Basic +AuthLDAPURL ldap://bdc1.technikum-wien.at/ou=People,dc=technikum-wien,dc=at?uid?one?objectClass=posixAccount +require group cn=fhadmin,ou=Group,dc=technikum-wien,dc=at +require user trob +require user wahl +require user drabek +require user elgner +require user schaaf +require user kofler +require user esberger +require user kollmitz +require user schmoe +require user trattner +require user naglr +require user patai +require user tw01e061 +require user docsek +require user teschl +require user oesi +require user adams +require user weisss +require user moserp +require user moehring +require user skritek +require user kroesl +require user ffe +require user kindlm +require user schmuderm +require user sagmeister +require user masik +require user kubicka +require user lehner +require user schwarzl +require user horauer +require user me diff --git a/vilesci/index.html b/vilesci/index.html new file mode 100644 index 000000000..cb5470477 --- /dev/null +++ b/vilesci/index.html @@ -0,0 +1,15 @@ + + +VileSci + + + + + + + +<body bgcolor="#FFFFFF"> + +</body> + + diff --git a/vilesci/kommunikation/kontakt.php b/vilesci/kommunikation/kontakt.php new file mode 100644 index 000000000..efaf22111 --- /dev/null +++ b/vilesci/kommunikation/kontakt.php @@ -0,0 +1,127 @@ + + + + +Kontakte - eMail-Verteiler + + + + + +

    Kontakte - eMail-Verteiler

    +
    +

    Module

    + + +$row->kurzbz
    $row->bezeichnung"; + } +?> + + +"; + $row=pg_fetch_object($erg, $i); + $stg_id=$row->studiengang_kz; + $stg_kzbz=$row->kurzbz; + $sql_query="SELECT * FROM tbl_einheit WHERE studiengang_kz=$stg_id ORDER BY einheit_kurzbz"; + //echo $sql_query; + if(!($result=pg_exec($conn, $sql_query))) + die(pg_errormessage($conn)); + $nr_sem=pg_numrows($result); + for ($j=0; $j<$nr_sem; $j++) + { + $row_sem=pg_fetch_object($result, $j); + if(strlen($row_sem->mailgrp_kurzbz)>0) + echo "mailgrp_kurzbz@technikum-wien.at\">$row_sem->einheit_kurzbz
    "; + else + echo "$row_sem->einheit_kurzbz
    "; + echo "einheit_kurzbz\">    (Liste)
    "; + } + echo""; + } +?> + +
    +

    Studenten

    + + +$row->kurzbz
    $row->bezeichnung"; + } +?> + + +"; + $row=pg_fetch_object($erg, $i); + $stg_id=$row->studiengang_kz; + $stg_kzbz=$row->kurzbz; + $sql_query="SELECT DISTINCT semester FROM tbl_student WHERE studiengang_kz=$stg_id ORDER BY semester"; + //echo $sql_query; + if(!($result_sem=pg_exec($conn, $sql_query))) + die(pg_errormessage($conn)); + $nr_sem=pg_numrows($result_sem); + for ($j=0; $j<$nr_sem; $j++) + { + $row_sem=pg_fetch_object($result_sem, $j); + $stg_kzbz_lo=strtolower($stg_kzbz); + echo "semester@technikum-wien.at\">$stg_kzbz-$row_sem->semester
    "; + + $sql_query="SELECT DISTINCT verband FROM tbl_student WHERE studiengang_kz=$stg_id AND semester=$row_sem->semester ORDER BY verband"; + //echo $sql_query; + if(!($result_ver=pg_exec($conn, $sql_query))) + die(pg_errormessage($conn)); + $nr_ver=pg_numrows($result_ver); + for ($k=0; $k<$nr_ver; $k++) + { + $row_ver=pg_fetch_object($result_ver, $k); + $ver_lo=strtolower($row_ver->verband); + echo " - semester$ver_lo@technikum-wien.at\">$stg_kzbz-$row_sem->semester$row_ver->verband
    "; + + $sql_query="SELECT DISTINCT gruppe FROM tbl_student WHERE studiengang_kz=$stg_id AND semester=$row_sem->semester AND verband='$row_ver->verband' ORDER BY gruppe"; + //echo $sql_query; + if(!($result_grp=pg_exec($conn, $sql_query))) + die(pg_errormessage($conn)); + $nr_grp=pg_numrows($result_grp); + for ($l=0; $l<$nr_grp; $l++) + { + $row_grp=pg_fetch_object($result_grp, $l); + echo "  - semester$ver_lo$row_grp->gruppe@technikum-wien.at\">$stg_kzbz-$row_sem->semester$row_ver->verband$row_grp->gruppe
    "; + echo "semester&ver=$ver_lo&grp=$row_grp->gruppe\">    (Liste)
    "; + } + } + } + echo""; + } +?> + +
    + + + diff --git a/vilesci/kommunikation/mlists/index.html b/vilesci/kommunikation/mlists/index.html new file mode 100644 index 000000000..4165536aa --- /dev/null +++ b/vilesci/kommunikation/mlists/index.html @@ -0,0 +1,19 @@ + + + Mailinglisten + + + + +

    MailingListen

    +

    Gruppen

    + + +
      +
    • Check UIDs
    • +
    + + diff --git a/vilesci/kommunikation/mlists/lektor_mlists_create.php b/vilesci/kommunikation/mlists/lektor_mlists_create.php new file mode 100644 index 000000000..650816f42 --- /dev/null +++ b/vilesci/kommunikation/mlists/lektor_mlists_create.php @@ -0,0 +1,45 @@ + + + +Mailinglisten + + + + + +

    MailingListen

    + + +nachname.' '.$row->vornamen.$crlf.$row->uid.$crlf); +} +fclose($fp); +echo $name.' created
    '; + +?> +


    + Die Mailinglisten der Lektoren wurden erstellt.
    + Sie können nun die erstellten Datein auf den Mail-Server kopieren (Copy + Lists).

    +

    << Zurück

    + + \ No newline at end of file diff --git a/vilesci/kommunikation/mlists/mlists_copy.php b/vilesci/kommunikation/mlists/mlists_copy.php new file mode 100644 index 000000000..463045093 --- /dev/null +++ b/vilesci/kommunikation/mlists/mlists_copy.php @@ -0,0 +1,31 @@ + + +Copy mLists + + + + + +

    Copy mLists

    +&1","r"))) + { + return 126; + } + + while (!feof($p)) + { + $line=fgets($p,1000); + $out .= $line; + } + pclose($p); + return $out; + } + $var="../../../../mlists/copymlists.sh"; + echo mysystem($var); +?> +Verarbeitung erledigt! + + \ No newline at end of file diff --git a/vilesci/kommunikation/mlists/mlists_create.php b/vilesci/kommunikation/mlists/mlists_create.php new file mode 100644 index 000000000..cb1a82a03 --- /dev/null +++ b/vilesci/kommunikation/mlists/mlists_create.php @@ -0,0 +1,92 @@ + + + +Mailinglisten + + + + + +

    MailingListen

    + + +studiengang_kz; + $stg_kzbz=$row->kurzbz; + $sql_query="SELECT * FROM tbl_mailgrp WHERE studiengang_kz=$stg_id ORDER BY mailgrp_kurzbz"; + //echo $sql_query; + if(!($result_mg=pg_exec($conn, $sql_query))) + die(pg_errormessage($conn)); + $nr_mg=pg_numrows($result_mg); + + // Mailgroups + for ($j=0; $j<$nr_mg; $j++) + { + $row_mg=pg_fetch_object($result_mg, $j); + $mg_kurzbz=$row_mg->mailgrp_kurzbz; + $sql_query='SELECT uid, nachname, vornamen '. + 'FROM tbl_person as p join tbl_personmailgrp using(uid) '. + 'WHERE tbl_personmailgrp.mailgrp_kurzbz=\''.$mg_kurzbz.'\' '."AND p.uid NOT LIKE '\\\\_%'". + 'ORDER BY nachname'; + //echo $sql_query; + if(!($result_person=pg_exec($conn, $sql_query))) + die(pg_errormessage($conn)); + + // File Operations + $name=$mg_kurzbz.'.txt'; + $name=strtolower($name); + $fp=fopen('../../../../mlists/'.$name,"w"); + //$fp=fopen('../../../../mlists/'.$name,"w"); + + $nr_person=pg_numrows($result_person); + for ($p=0; $p<$nr_person; $p++) + { + $row=pg_fetch_object($result_person, $p); + fwrite($fp, '#'.$row->nachname.' '.$row->vornamen.$crlf.$row->uid.$crlf); + } + fclose($fp); + echo $name.' created
    '; + flush(); + } + } + + $qry = "SELECT vornamen, nachname, uid, alias FROM tbl_person where alias<>'' ORDER BY nachname, vornamen"; + if($result = pg_query($conn, $qry)) + { + $fp=fopen('../../../../mlists/tw_alias.txt',"w"); + while($row=pg_fetch_object($result)) + { + fwrite($fp,"# ".$row->nachname." ".$row->vornamen.$crlf); + fwrite($fp,$row->alias.": ".$row->uid.$crlf); + } + fclose($fp); + echo 'tw_alias.txt created
    '; + } + else + { + echo 'tw_alias.txt failed
    '; + } + +?> +


    + Die Mailinglisten wurden erstellt.
    + Sie können nun die erstellten Datein auf den Mail-Server kopieren (Copy + Lists).

    +

    << Zurück

    + + \ No newline at end of file diff --git a/vilesci/kommunikation/mlists/mlists_det.php b/vilesci/kommunikation/mlists/mlists_det.php new file mode 100644 index 000000000..ade02abfb --- /dev/null +++ b/vilesci/kommunikation/mlists/mlists_det.php @@ -0,0 +1,99 @@ + + + + +Detail Studenten + + + + + +

    Mailing Gruppen

    +<< Back
    +
    +@technikum-wien.at +
    +Anzahl: + +
    +
    +generiert!='t') + { +?> +
    + + + + + +
    + + + + + + + + + + + +
    NachnameVornamenuid
    Delete
    + + + diff --git a/vilesci/kommunikation/mlists/mlists_generate.php b/vilesci/kommunikation/mlists/mlists_generate.php new file mode 100644 index 000000000..174f41bac --- /dev/null +++ b/vilesci/kommunikation/mlists/mlists_generate.php @@ -0,0 +1,217 @@ + + + + + Mailinglisten + + + + +

    MailingListen abgleich

    + studiensemester_kurzbz; + else + $error_msg.=pg_errormessage($conn).$sql_query; + + // ************************************************************** + // LektorenVerteiler abgleichen + $mlist_name='tw_lkt'; + // Lektoren holen die nicht mehr in den Verteiler gehoeren + echo $mlist_name.' wird abgeglichen!
    '; + flush(); + $sql_query="SELECT uid FROM tbl_personmailgrp WHERE mailgrp_kurzbz='$mlist_name' AND uid NOT IN (SELECT uid FROM tbl_mitarbeiter WHERE lektor)"; + if(!($result=pg_query($conn, $sql_query))) + $error_msg.=pg_errormessage($conn); + while($row=pg_fetch_object($result)) + { + $sql_query="DELETE FROM tbl_personmailgrp WHERE mailgrp_kurzbz='$mlist_name' AND uid='$row->uid'"; + if(!pg_query($conn, $sql_query)) + $error_msg.=pg_errormessage($conn).$sql_query; + echo '-'; + flush(); + } + // Lektoren holen die nicht im Verteiler sind + echo '
    '; + $sql_query="SELECT uid FROM tbl_mitarbeiter WHERE lektor AND uid NOT LIKE '\\\\_%' AND uid NOT IN (SELECT uid FROM tbl_personmailgrp WHERE mailgrp_kurzbz='$mlist_name')"; + if(!($result=pg_query($conn, $sql_query))) + $error_msg.=pg_errormessage($conn); + while($row=pg_fetch_object($result)) + { + $sql_query="INSERT INTO tbl_personmailgrp VALUES ('$row->uid','$mlist_name', now(), 'mlists_generate.php')"; + if(!pg_query($conn, $sql_query)) + $error_msg.=pg_errormessage($conn).$sql_query; + echo '-'; + flush(); + } + + // ************************************************************** + // Verteiler fuer alle fixAngestellten abgleichen + $mlist_name='tw_fix'; + // Lektoren holen die nicht mehr in den Verteiler gehoeren + echo '
    '.$mlist_name.' wird abgeglichen!
    '; + flush(); + $sql_query="SELECT uid FROM tbl_personmailgrp WHERE mailgrp_kurzbz='$mlist_name' AND uid NOT IN (SELECT uid FROM tbl_mitarbeiter WHERE fixangestellt)"; + if(!($result=pg_query($conn, $sql_query))) + $error_msg.=pg_errormessage($conn); + while($row=pg_fetch_object($result)) + { + $sql_query="DELETE FROM tbl_personmailgrp WHERE mailgrp_kurzbz='$mlist_name' AND uid='$row->uid'"; + if(!pg_query($conn, $sql_query)) + $error_msg.=pg_errormessage($conn).$sql_query; + echo '-'; + flush(); + } + // Lektoren holen die nicht im Verteiler sind + echo '
    '; + $sql_query="SELECT uid FROM tbl_mitarbeiter WHERE fixangestellt AND uid NOT LIKE '\\\\_%' AND uid NOT IN (SELECT uid FROM tbl_personmailgrp WHERE mailgrp_kurzbz='$mlist_name')"; + if(!($result=pg_query($conn, $sql_query))) + $error_msg.=pg_errormessage($conn); + while($row=pg_fetch_object($result)) + { + $sql_query="INSERT INTO tbl_personmailgrp VALUES ('$row->uid','$mlist_name', now(), 'mlists_generate.php')"; + if(!pg_query($conn, $sql_query)) + $error_msg.=pg_errormessage($conn).$sql_query; + echo '-'; + flush(); + } + + // ************************************************************** + // Verteiler fuer alle fixen Lektoren abgleichen + $mlist_name='tw_fix_lkt'; + // Lektoren holen die nicht mehr in den Verteiler gehoeren + echo '
    '.$mlist_name.' wird abgeglichen!
    '; + flush(); + $sql_query="SELECT uid FROM tbl_personmailgrp WHERE mailgrp_kurzbz='$mlist_name' AND uid NOT IN (SELECT uid FROM tbl_mitarbeiter WHERE fixangestellt AND lektor)"; + if(!($result=pg_query($conn, $sql_query))) + $error_msg.=pg_errormessage($conn); + while($row=pg_fetch_object($result)) + { + $sql_query="DELETE FROM tbl_personmailgrp WHERE mailgrp_kurzbz='$mlist_name' AND uid='$row->uid'"; + if(!pg_query($conn, $sql_query)) + $error_msg.=pg_errormessage($conn).$sql_query; + echo '-'; + flush(); + } + // Lektoren holen die nicht im Verteiler sind + echo '
    '; + $sql_query="SELECT uid FROM tbl_mitarbeiter WHERE fixangestellt AND lektor AND uid NOT LIKE '\\\\_%' AND uid NOT IN (SELECT uid FROM tbl_personmailgrp WHERE mailgrp_kurzbz='$mlist_name')"; + if(!($result=pg_query($conn, $sql_query))) + $error_msg.=pg_errormessage($conn); + while($row=pg_fetch_object($result)) + { + $sql_query="INSERT INTO tbl_personmailgrp VALUES ('$row->uid','$mlist_name', now(), 'mlists_generate.php')"; + if(!pg_query($conn, $sql_query)) + $error_msg.=pg_errormessage($conn).$sql_query; + echo '-'; + flush(); + } + + + // ************************************************************** + // Lektoren-Verteiler innerhalb der Studiengaenge abgleichen + // Lektoren holen die nicht mehr in den Verteiler gehoeren + echo '
    Lektoren-Verteiler der Studiengaenge werden abgeglichen!
    '; + flush(); + $sql_query="SELECT uid,mailgrp_kurzbz FROM tbl_personmailgrp + WHERE mailgrp_kurzbz LIKE '%\\\\_lkt' AND mailgrp_kurzbz!='tw_lkt' AND mailgrp_kurzbz!='tw_fix_lkt' + AND (uid,mailgrp_kurzbz) NOT IN + (SELECT lektor,lower(kurzbz || '_lkt') + FROM tbl_lehrveranstaltung NATURAL JOIN tbl_studiengang + WHERE studiensemester_kurzbz='$studiensemester' AND lektor NOT LIKE '\\\\_%')"; + //echo $sql_query; + if(!($result=@pg_query($conn, $sql_query))) + $error_msg.=pg_errormessage($conn).$sql_query; + while($row=pg_fetch_object($result)) + { + $sql_query="DELETE FROM tbl_personmailgrp WHERE mailgrp_kurzbz='$row->mailgrp_kurzbz' AND uid='$row->uid'"; + if(!@pg_query($conn, $sql_query)) + $error_msg.=pg_errormessage($conn).$sql_query; + echo '-'; + flush(); + } + // Lektoren holen die noch nicht im Verteiler sind + echo '
    '; + $sql_query="SELECT lektor,lower(kurzbz || '_lkt') AS mlist_name FROM tbl_lehrveranstaltung NATURAL JOIN tbl_studiengang + WHERE studiensemester_kurzbz='$studiensemester' + AND lektor NOT LIKE '\\\\_%' AND kurzbz!='TW' AND (lektor,lower(kurzbz || '_lkt')) NOT IN + (SELECT uid,mailgrp_kurzbz FROM tbl_personmailgrp + WHERE mailgrp_kurzbz LIKE '%\\\\_lkt' AND mailgrp_kurzbz!='tw_lkt' AND mailgrp_kurzbz!='tw_fix_lkt')"; + //echo $sql_query; + if(!($result=pg_query($conn, $sql_query))) + $error_msg.=pg_errormessage($conn).$sql_query; + while($row=pg_fetch_object($result)) + { + $sql_query="INSERT INTO tbl_personmailgrp VALUES ('$row->lektor','$row->mlist_name', now(), 'mlists_generate.php')"; + if(!pg_query($conn, $sql_query)) + $error_msg.=pg_errormessage($conn).$sql_query; + echo '-'; + flush(); + } + + + // ************************************************************** + // Studentenverteiler abgleichen + // Studenten holen die nicht mehr in den Verteiler gehoeren + echo '
    Studenten-Verteiler werden abgeglichen!
    '; + flush(); + $sql_query="SELECT mailgrp_kurzbz,uid FROM tbl_personmailgrp NATURAL JOIN tbl_einheit WHERE (uid, mailgrp_kurzbz) NOT IN (SELECT uid, mailgrp_kurzbz FROM tbl_einheitstudent NATURAL JOIN tbl_einheit WHERE mailgrp_kurzbz IS NOT NULL)"; + + + //echo $sql_query; + if(!($result=@pg_query($conn, $sql_query))) + $error_msg.=pg_errormessage($conn).$sql_query; + while($row=pg_fetch_object($result)) + { + $sql_query="DELETE FROM tbl_personmailgrp WHERE mailgrp_kurzbz='$row->mailgrp_kurzbz' AND uid='$row->uid'"; + if(!@pg_query($conn, $sql_query)) + $error_msg.=pg_errormessage($conn).$sql_query; + echo '-'; + flush(); + } + // Studenten holen die noch nicht im Verteiler sind + echo '
    '; + $sql_query="SELECT * FROM tbl_einheitstudent NATURAL JOIN tbl_einheit WHERE mailgrp_kurzbz IS NOT NULL + AND (uid,mailgrp_kurzbz) NOT IN (SELECT uid,mailgrp_kurzbz FROM tbl_personmailgrp)"; + //echo $sql_query; + if(!($result=pg_query($conn, $sql_query))) + $error_msg.=pg_errormessage($conn).$sql_query; + while($row=pg_fetch_object($result)) + { + $sql_query="INSERT INTO tbl_personmailgrp VALUES ('$row->uid','$row->mailgrp_kurzbz', now(), 'mlists_generate.php')"; + if(!pg_query($conn, $sql_query)) + $error_msg.=pg_errormessage($conn).$sql_query; + echo '-'; + flush(); + } + + + echo $error_msg; + ?> +
    +

    + Die Mailinglisten wurden abgeglichen.
    +

    + + \ No newline at end of file diff --git a/vilesci/kommunikation/mlists/mlists_index.php b/vilesci/kommunikation/mlists/mlists_index.php new file mode 100644 index 000000000..62f101bc8 --- /dev/null +++ b/vilesci/kommunikation/mlists/mlists_index.php @@ -0,0 +1,105 @@ +"; + $result_stg=pg_exec($conn, $sql_query); + if(!$result_stg) + error ("studiengang not found!"); + $sql_query="SELECT mailgrp_kurzbz AS mailgrpkurzbz, tbl_studiengang.kurzbz AS stgkurzbz, tbl_mailgrp.beschreibung, generiert FROM tbl_mailgrp join tbl_studiengang using(studiengang_kz) ORDER BY stgkurzbz, mailgrpkurzbz"; + if(!($erg=pg_exec($conn, $sql_query))) + die(pg_errormessage($conn)); + $num_rows=pg_numrows($erg); +?> + + + +Detail Studenten + + + + + +

    Mailing Gruppen

    +<< Back
    +
    Anzahl: + +
    +
    + + +"; + echo ""; + echo ""; + if($generiert=='f') + { + echo ""; + echo ""; + } + else + { + echo ""; + echo ""; + } + echo ""; + + } +?> +
    AliasStgBeschreibung
    Details$mgkurzbz$stgkurzbz$beschreibung$stgkurzbz$beschreibung
    + + +
    + Neu:
    + + Alias: + + Stg: + + Beschreibung: + + +
    +
    Fuer neue Mail-Verteiler, wenden sie sich bitte an die Administration'; + } +?> + + diff --git a/vilesci/kommunikation/mlists/student_lists_copy.php b/vilesci/kommunikation/mlists/student_lists_copy.php new file mode 100644 index 000000000..b5516b77c --- /dev/null +++ b/vilesci/kommunikation/mlists/student_lists_copy.php @@ -0,0 +1,32 @@ + + +Copy mLists + + + + + +

    Copy mLists

    +&1","r"))) + { + return 126; + } + + while (!feof($p)) + { + $line=fgets($p,1000); + $out .= $line; + } + pclose($p); + return $out; + } + $var="../../../../mlists/student/copymlists.sh"; + echo mysystem($var); +?> +Verarbeitung erledigt!
    +<<Zurück + + \ No newline at end of file diff --git a/vilesci/kommunikation/mlists/student_lists_create.php b/vilesci/kommunikation/mlists/student_lists_create.php new file mode 100644 index 000000000..554b24e16 --- /dev/null +++ b/vilesci/kommunikation/mlists/student_lists_create.php @@ -0,0 +1,89 @@ + + + +Mailinglisten + + + + + +

    MailingListen

    + + +studiengang_kz; + $stg_kzbz=$row->kurzbz; + $sql_query="SELECT DISTINCT semester FROM tbl_student WHERE studiengang_kz=$stg_id AND uid NOT LIKE '\\\\_%' ORDER BY semester"; + //echo $sql_query; + if(!($result_sem=pg_exec($conn, $sql_query))) + die(pg_errormessage($conn)); + $nr_sem=pg_numrows($result_sem); + for ($j=0; $j<$nr_sem; $j++) + { + $row_sem=pg_fetch_object($result_sem, $j); + echo $stg_kzbz.'-'.$row_sem->semester.'
    '; + + $sql_query="SELECT DISTINCT verband FROM tbl_student WHERE studiengang_kz=$stg_id AND semester=$row_sem->semester AND uid NOT LIKE '\\\\_%' ORDER BY verband"; + //echo $sql_query; + if(!($result_ver=pg_exec($conn, $sql_query))) + die(pg_errormessage($conn)); + $nr_ver=pg_numrows($result_ver); + for ($k=0; $k<$nr_ver; $k++) + { + $row_ver=pg_fetch_object($result_ver, $k); + $sql_query="SELECT DISTINCT gruppe FROM tbl_student WHERE gruppe!='' AND gruppe IS NOT NULL AND studiengang_kz=$stg_id AND semester=$row_sem->semester AND verband='$row_ver->verband' AND uid NOT LIKE '\\\\_%' ORDER BY gruppe"; + //echo $sql_query; + if(!($result_grp=pg_exec($conn, $sql_query))) + die(pg_errormessage($conn)); + $nr_grp=pg_numrows($result_grp); + for ($l=0; $l<$nr_grp; $l++) + { + $row_grp=pg_fetch_object($result_grp, $l); + $stgid=$stg_id; + $sem=$row_sem->semester; + $ver=$row_ver->verband; + $grp=$row_grp->gruppe; + $sql_query='SELECT p.uid, p.nachname, p.vornamen FROM tbl_student join tbl_person as p using(uid) WHERE studiengang_kz='.$stgid.' AND semester='.$sem.' AND verband=\''.strtoupper($ver).'\' AND gruppe='.$grp." AND p.uid NOT LIKE '\\\\_%' ORDER BY p.nachname"; + //echo $sql_query; + if(!($result_student=pg_exec($conn, $sql_query))) + die(pg_errormessage($conn)); + // File Operations + $name=$stg_kzbz.$sem.$ver.$grp.'.txt'; + $name=strtolower($name); + $fp=fopen('../../../../mlists/student/'.$name,"w"); + //$fp=fopen('../../../../mlists/student/'.$name,"w"); + $crlf="\n"; + + $numrows_student=pg_numrows($result_student); + for ($s=0; $s<$numrows_student; $s++) + { + $row=pg_fetch_object($result_student, $s); + fwrite($fp, '#'.$row->nachname.' '.$row->vornamen.$crlf.$row->uid.$crlf); + } + fclose($fp); + echo $name.', '; + flush(); + } + echo 'created
    '; + } + } + } +?> +Finished!!!
    +<<Zurück + + \ No newline at end of file diff --git a/vilesci/kommunikation/studenten_liste_export.php b/vilesci/kommunikation/studenten_liste_export.php new file mode 100644 index 000000000..1cec84981 --- /dev/null +++ b/vilesci/kommunikation/studenten_liste_export.php @@ -0,0 +1,43 @@ +nachname.' '.$row->vornamen.$crlf.$row->uid.$crlf; + } +?> \ No newline at end of file diff --git a/vilesci/left.php b/vilesci/left.php new file mode 100644 index 000000000..52f2dec53 --- /dev/null +++ b/vilesci/left.php @@ -0,0 +1,195 @@ + + + + + + + + +VileSci Menü + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
     
     Personen
    + + + + + + + + + + + + + + + + + + + + + + + +
      Suche
      Funtionen
      +  Studenten + + + + + + + + + + +
      Lektoren
      + + + + + + + + + + +
    +
     Kommunikation
    + + + + + + + + + + +
      Kontakte
      Mail-Verteiler
     
    +
     Stundenplan
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Cis Stundenplan
      Zeitwünsche
      LV-Verteilung
      Stundenplan
      Delete
      Einheiten
      + +  Lehrfach + + + + + + + + + + + +
      Checken
      Import
      Export
    +
    + +
    + + \ No newline at end of file diff --git a/vilesci/main.php b/vilesci/main.php new file mode 100644 index 000000000..9095b0f9b --- /dev/null +++ b/vilesci/main.php @@ -0,0 +1,21 @@ + + + +Vilesci Content + + + + + +

    VileSci 1.3 dev

    + + + + \ No newline at end of file diff --git a/vilesci/personen/funktion.php b/vilesci/personen/funktion.php new file mode 100644 index 000000000..db2521db3 --- /dev/null +++ b/vilesci/personen/funktion.php @@ -0,0 +1,74 @@ +"; +} +$sql_query="SELECT funktion_kurzbz, bezeichnung FROM tbl_funktion ORDER BY funktion_kurzbz"; +$result_funktion=pg_exec($conn, $sql_query); +if(!$result_funktion) + error("funktion not found!"); +?> + + + + Funktionen + + + + + +

    Funktionen

    +

    Übersicht

    + + +'; + for ($i=0;$i<$num_fields; $i++) + echo ""; + echo ''; + for ($j=0; $j<$num_rows;$j++) + { + $row=pg_fetch_row($result_funktion,$j); + + echo ""; + echo ""; + for ($i=0; $i<$num_fields; $i++) + echo ""; + //echo "\n"; + $foo++; + } +} +else + echo "Kein Eintrag gefunden!"; +?> +
    ".pg_fieldname($result_funktion,$i)."
    Details$row[$i]Edit"; + //echo "Delete"; + echo "
    +
    +
    +

    Neue Funktion: + Kurzbezeichnung + + Beschreibung + + + +

    +
    + + \ No newline at end of file diff --git a/vilesci/personen/funktion_det.php b/vilesci/personen/funktion_det.php new file mode 100644 index 000000000..68d0f5e53 --- /dev/null +++ b/vilesci/personen/funktion_det.php @@ -0,0 +1,255 @@ +kurzbz=$_POST['kurzbz']; + if (isset($_POST['stg_id']) && $_POST['stg_id']!=-1) + { + $studiengang_kz=$_POST['stg_id']; + } else + { + $studiengang_kz=null; + } + if (isset($_POST['fb_id']) && $_POST['fb_id']!=-1) + { + $fachbereich_id=$_POST['fb_id']; + } else + { + $fachbereich_id=null; + } + if (!$funktion->addPerson($uid,$studiengang_kz,$fachbereich_id)) + { + echo "Fehler: ".$funktion->errormsg; + } + +} + +// Funktionszuweisung updaten +if ($_POST['type']=='editsave') +{ + //print_r($_POST); + //Einfügen in die Datenbank + $funktion=new funktion($conn); + $personfunktion_id=$_POST['personfunktion_id']; + $uid=$_POST['pers_id']; + if (isset($_POST['stg_id']) && $_POST['stg_id']!=-1) + { + $studiengang_kz=$_POST['stg_id']; + } else + { + $studiengang_kz=null; + } + if (isset($_POST['fb_id']) && $_POST['fb_id']!=-1) + { + $fachbereich_id=$_POST['fb_id']; + } else + { + $fachbereich_id=null; + } + + if (!$funktion->updatePerson($personfunktion_id,$uid,$studiengang_kz, + $fachbereich_id)) + { + echo "Fehler: ".$funktion->errormsg; + } + /* + $sql_query="UPDATE personfunktion SET person_id=$pers_id, funktion_id=$id, studiengang_id=$stg_id"; + $sql_query.=" WHERE id=$funkpers_id"; + $result=pg_exec($conn, $sql_query); + if(!$result) + echo pg_errormessage()."
    "; + */ +} + +// Eine Funktionszuweisung loeschen +if ($_GET['type']=="delete") +{ + + $funktion=new funktion($conn); + $personfunktion_id=$_GET['funkpers_id']; + if (!is_numeric($personfunktion_id)) + { + echo "personfunktion_id ist keine Zahl"; + } + if (!$funktion->removePerson($personfunktion_id) ) + { + echo "Fehler: ".$funktion->errormsg; + } + +} + +// Daten für Personenauswahl +$sql_query="SELECT nachname, vornamen, uid FROM tbl_person ORDER BY upper(nachname), vornamen, uid"; +$result_person=pg_exec($conn, $sql_query); +if(!$result_person) + die (pg_errormessage($conn)); +// Daten für Studiengangauswahl +$sql_query="SELECT studiengang_kz, kurzbz, bezeichnung FROM tbl_studiengang ORDER BY kurzbz"; +$result_stg=pg_exec($conn, $sql_query); +if(!$result_stg) + die (pg_errormessage($conn)); + +// Instanz von Funktion-Klasse erzeugen +$funktion=new funktion($conn); +//print_r($_GET); +if (!$funktion->load($_POST['kurzbz'])) +{ + if (!$funktion->load($_GET['kurzbz'])) + { + echo "Fehler: ".$funktion->errormsg; + exit(); + } +} + +?> + + + + Funktion Details + + + + +

    Funktion: bezeichnung ?>

    + + + getPersonen(); + if (is_array($personen)) + { + echo ""; + $j=0; + while(list($k,$v)=each($personen)) + { + $bgcolor = $cfgBgcolorOne; + $j++; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + + } + } else + { + echo "Fehler: ".$funktion->errormsg; + } + } + else if ($_GET['type']!='edit') + echo "Kein Eintrag gefunden!"; + ?> +
    NameUser-IDStudiengangFachbereichAktion
    ".$v['person']->nachname.", ".$v['person']->titel." ".$v['person']->vornamen."".$v['person']->uid."".(isset($v['studiengang_kurzbz'])?$v['studiengang_kurzbz']:' ')."".(isset($v['fachbereich_kurzbz'])?$v['fachbereich_kurzbz']:' ')."uid."\">Edituid."\">Delete
    +
    +
    +

    + '; + echo ''; + } + else + echo ''; + + if (isset($_POST['kurzbz'])) + { + $kurzbz=$_POST['kurzbz']; + + } else if (isset($_GET['kurzbz'])) + { + $kurzbz=$_GET['kurzbz']; + } + ?> + + + + + + +
    Lektor: +
    Studiengang: +
    Fachbereich: +
    + +

    +
    + + diff --git a/vilesci/personen/index.html b/vilesci/personen/index.html new file mode 100644 index 000000000..c3f6af5b1 --- /dev/null +++ b/vilesci/personen/index.html @@ -0,0 +1,23 @@ + + +Untitled Document + + + + + + +

    Personensuche

    +
    + Bitte Suchbegriff eingeben: + + (mind. 3 Zeichen) + + (Groß-/Kleinschreibung wird unterschieden!) +
    +


    +
    + - Studentenübersicht +

    + + diff --git a/vilesci/personen/lektor_edit.php b/vilesci/personen/lektor_edit.php new file mode 100644 index 000000000..c74c42a80 --- /dev/null +++ b/vilesci/personen/lektor_edit.php @@ -0,0 +1,157 @@ + + + +Lektor Edit + + + + +window.location.href='lektor_uebersicht.php';"; + } + else if (isset($_GET['new'])) + { + doEDIT($conn,null,true); + + } + else + { + if (!isset ($_GET['id'])) + { + echo "benötige ID für Lektor"; + } + doEDIT($conn,$_GET['id']); + } + +/** + * Lektor speichern/anlegen + */ +function doSAVE($conn) +{ + $lektor = new mitarbeiter($conn); + if ($_POST['new']==1) + { + $lektor->new=true; + } else + { + $lektor->new=false; + } + // person + $lektor->uid=$_POST['uid']; + $lektor->titel=$_POST['titel']; + $lektor->vornamen=$_POST['vornamen']; + $lektor->nachname=$_POST['nachname']; + $lektor->gebdatum=$_POST['gebdatum']; + $lektor->gebort=$_POST['gebort']; + $lektor->gebzeit=$_POST['gebzeit']; + $lektor->anmerkungen=$_POST['anmerkungen']; + $lektor->aktiv=($_POST['aktiv']=='1'?true:false); + $lektor->email=$_POST['email']; + $lektor->alias=$_POST['alias']; + $lektor->kurzbz=$_POST['kurzbz']; + $lektor->homepage=$_POST['homepage']; + // mitarbeiter + $lektor->personalnummer=$_POST['personalnummer']; + $lektor->lektor=($_POST['lektor']=='1'?true:false); + $lektor->fixangestellt=($_POST['fixangestellt']=='t'?true:false); + $lektor->telefonklappe=$_POST['telefonklappe']; + $lektor->ort_kurzbz=$_POST['raumnr']; + //print_r($_POST); + + + if ($lektor->save()) + { + $msg="

    Datensatz gespeichert.

    "; + } else + { + $msg="

    ".$lektor->errormsg."

    "; + } + + doEDIT($lektor->uid,false,$msg); +} + + + +/** + * MA bearbeiten/anlegen + * @param string $id optional; wenn nicht angegeben -> neuer datensatz + */ +function doEDIT($conn,$id='',$new=false,$msg='') +{ + // Mitarbeiterdaten holen + $lektor = new mitarbeiter($conn); + if (!$new) + { + $status_ok=$lektor->load(addslashes($id)); + } + if (!$status_ok && !$new) + { + // Laden fehlgeschlagen + echo $lektor->errormsg; + } else + { +?> + +

    Lektor/Mitarbeiter

    +0) echo $msg."
    "; +?> +
    + + + + + + + + + + + + + + + + + +
    UID
    Personalnummer
    Titel
    Vornamen
    Nachname
    Lektorlektor?'checked':'') ?> >
    Aktivaktiv?'checked':'') ?> >
    Geburtsdatum (TT.MM.JJJJ)
    Geburtsort
    eMail Alias
    eMail Privat
    Homepage
    Kurzbezeichnung
    Telefon Technikum
    Fix angestellt
    Raum Nr: + +
    + + + +
    + + + \ No newline at end of file diff --git a/vilesci/personen/lektor_edit_save.php b/vilesci/personen/lektor_edit_save.php new file mode 100644 index 000000000..ba2f01b9d --- /dev/null +++ b/vilesci/personen/lektor_edit_save.php @@ -0,0 +1,29 @@ + + + + +Lektor Speichern + + + + + +

    Lektor Speichern

    + +Speichern erfolgreich! + + + diff --git a/vilesci/personen/lektor_new.php b/vilesci/personen/lektor_new.php new file mode 100644 index 000000000..7c8652f12 --- /dev/null +++ b/vilesci/personen/lektor_new.php @@ -0,0 +1,41 @@ + + + + +Lektor Edit + + + + + +

    Lektor Neu

    +
    + + + + + + + + + + + + + + + +
    UID*
    Titel
    Vornamen
    Nachname
    Geburtsdatum*
    gebort
    eMail Technikum
    eMail Forward
    eMail Alias
    Kurzbezeichnung
    Telefon Technikum
    Fix Angestellt
    + + + +
    + + \ No newline at end of file diff --git a/vilesci/personen/lektor_new_save.php b/vilesci/personen/lektor_new_save.php new file mode 100644 index 000000000..858ecac08 --- /dev/null +++ b/vilesci/personen/lektor_new_save.php @@ -0,0 +1,23 @@ + + + + +Lektor Speichern + + + + +

    Lektor Speichern

    +Speichern erfolgreich! + + diff --git a/vilesci/personen/lektor_uebersicht.php b/vilesci/personen/lektor_uebersicht.php new file mode 100644 index 000000000..074ea3b52 --- /dev/null +++ b/vilesci/personen/lektor_uebersicht.php @@ -0,0 +1,105 @@ +"; + } + + if(isset($fix) && isset($uid)) + { + $sql_query = "UPDATE tbl_mitarbeiter SET fixangestellt=". ($fix=='true'?'false':'true') ." WHERE uid='$uid'"; + //echo $sql_query; + pg_exec($conn,$sql_query); + + } + + if(isset($lek) && isset($uid)) + { + + $sql_query = "UPDATE tbl_mitarbeiter SET lektor=". ($lek=='true'?'false':'true') ." WHERE uid='$uid'"; + //echo $sql_query; + pg_exec($conn,$sql_query); + } + + $f_temp=new mitarbeiter($conn); + if(isset($order)) + $lektoren=$f_temp->getAll($order); + else + $lektoren=$f_temp->getAll(); + + +?> + + + +Mitarbeiter Übersicht + + + + + + +

    Mitarbeiter Übersicht


    + + + + +"; + if((isset($fix) || isset($lek))&& isset($uid) && $uid==$lektoren[$i]->uid) //Anker setzen + echo ""; + else + echo ""; + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + echo ""; + echo ""; + //echo ""; + //echo ""; + + $email=$lektoren[$i]->uid.'@technikum-wien.at'; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + echo "
    UIDTitelVornamenNachnameFixLktRaumTeleMailAktion
    ".$lektoren[$i]->uid."".$lektoren[$i]->uid."".$lektoren[$i]->titel."".$lektoren[$i]->vornamen."".$lektoren[$i]->nachname."".$lektoren[$i]->ort_kurzbz."".$lektoren[$i]->telefonklappe."$emailEdit"; + if ($lektoren[$i]->lektor) + { + echo "Zeitwunsch"; + } + echo "Delete
    "; + + if(isset($fix) || isset($lek)) //Zum Anker hüpfen + { + echo ""; + } +?> + + + diff --git a/vilesci/personen/lektor_uebersicht_Anktest.php b/vilesci/personen/lektor_uebersicht_Anktest.php new file mode 100644 index 000000000..c8e8750aa --- /dev/null +++ b/vilesci/personen/lektor_uebersicht_Anktest.php @@ -0,0 +1,85 @@ +0 && isset($uid) && strlen($uid)) + { + $sql_query = "UPDATE tbl_mitarbeiter SET fixangestellt=". ($fix=='true'?'false':'true') ." WHERE uid='$uid'"; + //echo $sql_query; + pg_exec($conn,$sql_query); + + } + + if(isset($lek) && strlen($lek)>0 && isset($uid) && strlen($uid)>0) + { + + $sql_query = "UPDATE tbl_mitarbeiter SET lektor=". ($lek=='true'?'false':'true') ." WHERE uid='$uid'"; + //echo $sql_query; + pg_exec($conn,$sql_query); + } + + $f_temp=new mitarbeiter(); + if(isset($order) && strlen($order)>0) + $lektoren=$f_temp->getAll($order); + else + $lektoren=$f_temp->getAll(); + + +?> + + + +Mitarbeiter Übersicht + + + + + +

    Mitarbeiter Übersicht


    +
    + + + + + + + +"; + + if($uid == $lektoren[$i]->uid) + echo ""; + else + echo ""; + + echo ""; + echo ""; + echo ""; + //echo ""; + //echo ""; + + echo ""; + echo ""; + + $email=$lektoren[$i]->uid.'@technikum-wien.at'; + echo ""; + echo ""; + echo ""; + } +?> +
    UIDTitelVornamenNachnameFixLektoreMailAktion
    ".$lektoren[$i]->uid."".$lektoren[$i]->uid."".$lektoren[$i]->titel."".$lektoren[$i]->vornamen."".$lektoren[$i]->nachname."$emailEdit"; + if ($lektoren[$i]->lektor) + { + echo "Zeitwunsch"; + } + echo "
    +
    + + diff --git a/vilesci/personen/lektor_uebersicht_ankertest.php b/vilesci/personen/lektor_uebersicht_ankertest.php new file mode 100644 index 000000000..3804f5c2e --- /dev/null +++ b/vilesci/personen/lektor_uebersicht_ankertest.php @@ -0,0 +1,79 @@ +getAll($order); + else + $lektoren=$f_temp->getAll(); + + +?> + + + +Mitarbeiter Übersicht + + + + + +

    Mitarbeiter Übersicht


    + + + + +"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + //echo ""; + //echo ""; + + $email=$lektoren[$i]->uid.'@technikum-wien.at'; + echo ""; + echo ""; + echo ""; + } +?> +
    UIDTitelVornamenNachnameFixLektoreMailAktion
    ".$lektoren[$i]->uid."".$lektoren[$i]->titel."".$lektoren[$i]->vornamen."".$lektoren[$i]->nachname."$emailEdit"; + if ($lektoren[$i]->lektor) + { + echo "Zeitwunsch"; + } + echo "
    + + diff --git a/vilesci/personen/lektorzuteilung_edit.php b/vilesci/personen/lektorzuteilung_edit.php new file mode 100644 index 000000000..bad9d6337 --- /dev/null +++ b/vilesci/personen/lektorzuteilung_edit.php @@ -0,0 +1,144 @@ + + + + +Zuteilung der Lektoren + + + + + + +

    Lektoren - Lehrfach Zuteilung

    +Anzahl: + +
    +
    + + + + + + + + + > + + + + + + + + + +
    NachnameVornamenuidLehrfachStudiengangSemester
    Deletenachname; ?>vornamen; ?>uid; ?>lfkurzbz; ?>stgkurzbz; ?>semester; ?>
    +
    + + Lektor: + +
    + Lehrfach: + +
    + Studiengang: + + Semester: + + +
    + + diff --git a/vilesci/personen/modulzuteilung_edit.php b/vilesci/personen/modulzuteilung_edit.php new file mode 100644 index 000000000..5b3b9da8b --- /dev/null +++ b/vilesci/personen/modulzuteilung_edit.php @@ -0,0 +1,122 @@ + + + + +Zuteilung der Lektoren + + + + + + +

    Lektoren - Modul Zuteilung

    +Anzahl: + +
    +
    + + + + + + + > + + + + + + + +
    NachnameVornamenuidModul
    Deletenachname; ?>vornamen; ?>uid; ?>mdkurzbz; ?>
    +
    + + Lektor: + +
    + Modul: + +   + Semester:  + +
    + + \ No newline at end of file diff --git a/vilesci/personen/search_go.php b/vilesci/personen/search_go.php new file mode 100644 index 000000000..a11e2ed09 --- /dev/null +++ b/vilesci/personen/search_go.php @@ -0,0 +1,72 @@ + + + + +Suchergebnis + + + + + +

    Suchergebnisse

    +Results:
    +
    + + + + > + + + + + + +
    TitelVornamenNachnameeMail
    + + diff --git a/vilesci/personen/student_edit.php b/vilesci/personen/student_edit.php new file mode 100644 index 000000000..47bbb9c9a --- /dev/null +++ b/vilesci/personen/student_edit.php @@ -0,0 +1,203 @@ + + + +Student Edit + + + + + +Student '; +if (isset($_GET['new'])) + echo 'Neu'; +else + echo 'Edit'; + +if (isset($_POST['Save'])) +{ + doSAVE($conn); +} +else if (isset($_GET['new'])) +{ + doEDIT($conn,null,true); + +} +else +{ + if (!isset ($_GET['id'])) + { + echo "benötige UID für Student"; + } + doEDIT($conn,$_GET['id']); +} + +/** + * Daten speichern + */ +function doSAVE($conn) +{ + + $student = new student($conn); + $student->new=$_POST['new']; + // person + $student->uid=$_POST['uid']; + if (isset($_POST['new_uid'])) + $student->uid=$_POST['new_uid']; + $student->titel=$_POST['titel']; + $student->vornamen=$_POST['vornamen']; + $student->nachname=$_POST['nachname']; + $student->gebdatum=$_POST['gebdatum']; + $student->gebort=$_POST['gebort']; + $student->gebzeit=$_POST['gebzeit']; + $student->anmerkungen=$_POST['anmerkungen']; + $student->aktiv=($_POST['aktiv']=='1'?true:false); + $student->email=$_POST['email']; + $student->alias=$_POST['alias']; + $student->homepage=$_POST['homepage']; + //echo "

    aktiv=".($student->aktiv?'true':'false').'

    '; + // student + if (is_numeric($_POST['studiengang_kz'])) + { + $student->studiengang_kz=$_POST['studiengang_kz']; + } + else + { + echo "

    Studiengang-KZ ist keine Zahl (".$_POST['studiengang_kz'].").

    "; + return; + } + $student->matrikelnr=$_POST['matrikelnr']; + if (is_numeric($_POST['semester'])) + { + $student->semester=$_POST['semester']; + } + else + { + echo "

    Semester ist keine Zahl"; + return; + } + $student->verband=$_POST['verband']; + $student->gruppe=$_POST['gruppe']; + + if ($student->save()) + { + echo "

    Datensatz gespeichert.

    "; + } + else + { + echo "

    ".$student->errormsg."

    "; + } + + doEDIT($conn,$student->uid); +} + +/** + * Edit-Formular + */ +function doEDIT($conn,$id,$new=false) +{ + + // Studentendaten holen + $student = new student($conn); + if (!$new) + { + $status_ok=$student->load(addslashes($id)); + } + if (!$status_ok && !$new) + { + // Laden fehlgeschlagen + echo $student->errormsg; + } + else + { + // Eingabeformular anzeigen + ?> +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    UID* + +
    Titel
    Vornamen
    Nachname
    Aktivaktiv?'checked':''; + ?>>
    Geburtsdatum (TT.MM.JJJJ)
    Gebort
    eMail Alias
    eMail Technikum
    Homepage
    Matrikelnr*
    Studiengang-KZ + + +
    Semester
    Verband
    Gruppe
    + + + +
    + + + + + diff --git a/vilesci/personen/student_neu_save.php b/vilesci/personen/student_neu_save.php new file mode 100644 index 000000000..023312a8c --- /dev/null +++ b/vilesci/personen/student_neu_save.php @@ -0,0 +1,107 @@ +'; + } + else + { + $uid='?'; + $titel='?'; + $anrede='Herr'; + $vornamen='?'; + $nachname='?'; + $gebdatum='24.08.1980'; + $gebort='?'; + $adresse='?'; + $plz='?'; + $ort='?'; + $teltw='?'; + $telpriv='?'; + $telfirma='?'; + $telmobil='?'; + $emailtw='?'; + $emailpriv='?'; + $emailfirm='?'; + $homedir='/home01/?'; + $emailalias='?'; + $matrikelnr='?'; + $studiengang_id='1'; + $sem='1'; + $ver='A'; + $grp='1'; + } + + + +?> + + + +Student Neu + + + + + +

    Student Neu

    +
    + + + + + + + + + + + + + + + + + + + + +
    UIDAccount Name (Bei Studenten ist das der erste Teil der Mail-Adresse)
    Titel
    Vornamen
    Nachname
    GeburtsdatumFormat: TT.MM.JJJJ
    Geburtsort
    eMail Technikum
    eMail Alias
    Homepage
    matrikelnr
    Studiengang + +
    Semester
    VerbandA B oder C
    GruppeWerden keine Aufteilungen in Gruppen verwendet (zb:EW) einfach 0 eingeben
    + + +
    + + diff --git a/vilesci/personen/studenten_uebersicht.php b/vilesci/personen/studenten_uebersicht.php new file mode 100644 index 000000000..3e8a4f5d7 --- /dev/null +++ b/vilesci/personen/studenten_uebersicht.php @@ -0,0 +1,81 @@ + + + + +Studenten Uebersicht + + + + + +

    Studenten Übersicht

    + + + +$row->kurzbz
    $row->bezeichnung"; + } +?> + + +"; + $row=pg_fetch_object($erg, $i); + $stg_kzbz=$row->kurzbz; + $stg_kz=$row->studiengang_kz; + $sql_query="SELECT DISTINCT semester FROM tbl_student WHERE studiengang_kz=$stg_kz ORDER BY semester"; + //echo $sql_query; + if(!($result_sem=pg_exec($conn, $sql_query))) + die(pg_errormessage($conn)); + $nr_sem=pg_numrows($result_sem); + for ($j=0; $j<$nr_sem; $j++) + { + $row_sem=pg_fetch_object($result_sem, $j); + echo "semester\">$stg_kzbz-$row_sem->semester
    "; + + $sql_query="SELECT DISTINCT verband FROM tbl_student WHERE studiengang_kz=$stg_kz AND semester=$row_sem->semester ORDER BY verband"; + //echo $sql_query; + if(!($result_ver=pg_exec($conn, $sql_query))) + die(pg_errormessage($conn)); + $nr_ver=pg_numrows($result_ver); + for ($k=0; $k<$nr_ver; $k++) + { + $row_ver=pg_fetch_object($result_ver, $k); + echo " - semester&ver=$row_ver->verband\">$stg_kzbz-$row_sem->semester$row_ver->verband
    "; + + $sql_query="SELECT DISTINCT gruppe FROM tbl_student WHERE studiengang_kz=$stg_kz AND semester=$row_sem->semester AND verband='$row_ver->verband' ORDER BY gruppe"; + //echo $sql_query; + if(!($result_grp=pg_exec($conn, $sql_query))) + die(pg_errormessage($conn)); + $nr_grp=pg_numrows($result_grp); + for ($l=0; $l<$nr_grp; $l++) + { + $row_grp=pg_fetch_object($result_grp, $l); + echo "  - semester&ver=$row_ver->verband&grp=$row_grp->gruppe\">$stg_kzbz-$row_sem->semester$row_ver->verband$row_grp->gruppe
    "; + + } + } + } + echo""; + } +?> + +
    + + diff --git a/vilesci/personen/studenten_uebersicht_det.php b/vilesci/personen/studenten_uebersicht_det.php new file mode 100644 index 000000000..2d40d64fb --- /dev/null +++ b/vilesci/personen/studenten_uebersicht_det.php @@ -0,0 +1,71 @@ + + + + +Detail Studenten + + + + + +

    Detailansicht

    +Results:
    +
    + + + + + + + + + + + + + + + + +
    TitelVornamenNachnameSTGSem.VerbandGruppeMatrikelnr.eMail
    Edit
    + + diff --git a/vilesci/personen/zeitwunsch.php b/vilesci/personen/zeitwunsch.php new file mode 100644 index 000000000..b63511c6d --- /dev/null +++ b/vilesci/personen/zeitwunsch.php @@ -0,0 +1,196 @@ + + + + +Profil + + + + + +

    Zeitwünsche von titel.' '.$person->vornamen.' '.$person->nachname; ?>

    + +
    + + + Stunde
    Beginn
    Ende'; + for ($i=0;$i<$num_rows_stunde; $i++) + { + $beginn=pg_result($result_stunde,$i,'"beginn"'); + $beginn=substr($beginn,0,5); + $ende=pg_result($result_stunde,$i,'"ende"'); + $ende=substr($ende,0,5); + $stunde=pg_result($result_stunde,$i,'"stunde"'); + echo ""; + } + ?> + + '; + for ($i=0;$i<$num_rows_stunde;$i++) + { + $index=$wunsch[$j][$i+1]; + if ($index=="") + $index=1; + $bgcolor=$cfgStdBgcolor[$index+3]; + echo ''; + } + echo ''; + } + ?> +
    $stunde
    $beginn
    $ende
    '.$tagbez[$j].'
    +
    + + +
    +
    +
    +

    Erklärung:

    +

    Bitte kontrollieren/ändern Sie Ihre Zeitwünsche und klicken Sie anschließend + auf "Speichern"!
    +
    +

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Wert +
    Bedeutung
    +
    +
    2
    +
    Hier möchte ich Unterrichten
    +
    1
    +
    Hier kann ich Unterrichten
    +
    0
    +
    keine Bedeutung
    +
    -1
    +
    Hier möchte ich eher nicht
    +
    -2
    +
    Hier nur in extremen Notfällen
    +
    -3
    +
    Hier auf gar keinen Fall !!!
    +

     

    +

    Folgende Punkte sind zu beachten:

    +
      +
    1. Verwenden Sie den Wert -3 nur wenn Sie zu dieser Stunde wirklich nicht + können, um eine bessere Optimierung zu ermöglichen.
    2. +
    3. Es muß für jede Stunde die tatsächlich unterrichtet wird, + mindestens das 2-fache an positiven Zeitwünschen angegeben werden.
      + Beispiel: Sie unterrichten 4 Stunden/Woche, dann müssen Sie mindesten + 8 Stunden im Raster mit positiven Werten ausfüllen.
    4. +
    +

    Bei Problemen wenden Sie sich bitte an die Stundenplanstelle.

    +

     

    + + diff --git a/vilesci/personen/zeitwunsch_save.php b/vilesci/personen/zeitwunsch_save.php new file mode 100644 index 000000000..7378161b0 --- /dev/null +++ b/vilesci/personen/zeitwunsch_save.php @@ -0,0 +1,56 @@ + + + + +Profil + + + + + + +

    Zeitwünsche von + + sind aktualisiert!

    +<< +Zurück
    + + + + diff --git a/vilesci/stundenplan/check/index.html b/vilesci/stundenplan/check/index.html new file mode 100644 index 000000000..57a7b14c9 --- /dev/null +++ b/vilesci/stundenplan/check/index.html @@ -0,0 +1,12 @@ + + +Stundenplan-Check + + + + + +

    Stundenplan Check

    +

    Reservierungen auf Kollisionen überprüfen.

    + + diff --git a/vilesci/stundenplan/check/res_check.php b/vilesci/stundenplan/check/res_check.php new file mode 100644 index 000000000..30d7414e8 --- /dev/null +++ b/vilesci/stundenplan/check/res_check.php @@ -0,0 +1,104 @@ + + + + +Stundenplan Check + + + + +

    Mehrfachbelegungen in Reservierung

    +

    Doppelbelegungen

    + + +1) ORDER BY datum, stunde, ort_kurzbz LIMIT 20"; + //echo $sql_query."
    "; + $result=pg_exec($conn, $sql_query); + $num_rows=pg_numrows($result); + if ($num_rows>0) + { + $num_fields=pg_numfields($result); + $foo = 0; + for ($i=0;$i<$num_fields; $i++) + echo ""; + for ($j=0; $j<$num_rows;$j++) + { + $row=pg_fetch_row($result,$j); + $bgcolor = $cfgBgcolorOne; + $foo % 2 ? 0: $bgcolor = $cfgBgcolorTwo; + echo ""; + for ($i=0; $i<$num_fields; $i++) + echo ""; + echo ""; + echo "\n"; + $foo++; + } + } + else + echo "Keine Doppelbelegungen gefunden!"; +?> +
    ".pg_fieldname($result,$i)."
    $row[$i]Details
    +

    Kollisionen mit Stundenplan

    +"; + $result_res=pg_exec($conn, $sql_query); + $num_rows_res=pg_numrows($result_res); + if ($num_rows_res>0) + { + echo $num_rows_res.' Einträge werden überprüft .'; + $foo = 0; + for ($r=0;$r<$num_rows_res;$r++) + { + $row_res=pg_fetch_object($result_res,$r); + $sql_query="SELECT * FROM vw_stundenplan WHERE datum='$row_res->datum' AND stunde=$row_res->stunde AND ort_kurzbz='$row_res->ort_kurzbz'"; + //echo $sql_query."
    "; + $result=pg_exec($conn, $sql_query); + $num_rows=pg_numrows($result); + //echo $num_rows; + if ($num_rows>0) + { + echo ''; + $num_fields=pg_numfields($result); + echo ""; + for ($i=0;$i<$num_fields; $i++) + echo ""; + echo "\n"; + for ($j=0; $j<$num_rows;$j++) + { + $row=pg_fetch_row($result,$j); + $rowo=pg_fetch_object($result,$j); + $bgcolor = $cfgBgcolorOne; + $foo % 2 ? 0: $bgcolor = $cfgBgcolorTwo; + echo ""; + echo ""; + for ($i=0; $i<$num_fields; $i++) + echo ""; + echo "\n"; + $foo++; + } + echo '
    ".pg_fieldname($result,$i)."
    datum&stunde=$rowo->stunde&ort_kurzbz=$rowo->ort_kurzbz\">Reservierung$row[$i]
    '; + flush(); + } + if ($r%500==0) + echo '
    '.$r; + if ($r%10==0) + { + echo '.'; + flush(); + } + } + } + else + echo "Kein Eintrag gefunden!"; +?> + + + \ No newline at end of file diff --git a/vilesci/stundenplan/check/res_check_delete.php b/vilesci/stundenplan/check/res_check_delete.php new file mode 100644 index 000000000..0924de8f3 --- /dev/null +++ b/vilesci/stundenplan/check/res_check_delete.php @@ -0,0 +1,30 @@ +"; + $result=pg_exec($conn, $sql_query); + $num_rows=pg_numrows($result); +?> + + + +Reservierung Check Delete + + + + +

    Mehrfachbelegungen in Reservierung löschen

    +
    +
    +
    +Zurück zu Übersicht
    + + \ No newline at end of file diff --git a/vilesci/stundenplan/check/res_check_det.php b/vilesci/stundenplan/check/res_check_det.php new file mode 100644 index 000000000..03199eff4 --- /dev/null +++ b/vilesci/stundenplan/check/res_check_det.php @@ -0,0 +1,49 @@ +"; + $result=pg_exec($conn, $sql_query); + $num_rows=pg_numrows($result); +?> + + + +Reservierung Check Details + + + + +

    Mehrfachbelegungen in Reservierungen Detailansicht

    + + +".pg_fieldname($result,$i).""; + for ($j=0; $j<$num_rows;$j++) + { + $row=pg_fetch_row($result,$j); + $bgcolor = $cfgBgcolorOne; + $foo % 2 ? 0: $bgcolor = $cfgBgcolorTwo; + echo ""; + for ($i=0; $i<$num_fields; $i++) + echo ""; + echo ""; + echo ""; + + echo "\n"; + $foo++; + } +} +else + echo "Kein Eintrag gefunden!"; +?> +
    $row[$i]DeleteMail&Delete
    + + \ No newline at end of file diff --git a/vilesci/stundenplan/check/res_check_mail.php b/vilesci/stundenplan/check/res_check_mail.php new file mode 100644 index 000000000..6b02f3112 --- /dev/null +++ b/vilesci/stundenplan/check/res_check_mail.php @@ -0,0 +1,53 @@ +"; + $result=pg_exec($conn, $sql_query); + $num_rows=pg_numrows($result); + if ($num_rows==1) + { + $row=pg_fetch_object($result,0); + $text="Dies ist eine automatische eMail!\r\rAufgrund einer Stundenplankollision wurde folgende Reservierung gelöscht:\r\r"; + $text.="Datum:\t$row->datum\rStunde:\t$row->stunde_id\rOrt:\t$row->ortkurzbz\rTitel:\t$row->titel\r\r"; + $text.="Wir bitten um Verständnis."; + $adress=$row->uid.'@technikum-wien.at'; + if (mail($adress,"Stundenplankollision",$text,"From: stpl@technikum-wien.at")) + $sendmail=true; + else + $sendmail=false; + } + else + $sendmail=false; + //Stundenplandaten ermitteln welche mehrfach vorkommen + $sql_query="DELETE FROM reservierung WHERE id=$id"; + //echo $sql_query."
    "; + $result=pg_exec($conn, $sql_query); + $num_rows=pg_numrows($result); +?> + + + +Reservierung Check Delete + + + + +

    Mehrfachbelegungen in Reservierung löschen

    +'; +else + echo "Mail konnte nicht verschickt werden!
    "; + +if ($result) + echo "Datensatz wurde erfolgreich gelöscht!"; +else + echo "Es ist ein Fehler aufgetreten!"; +?>
    +
    +
    +Zurück zu Übersicht
    + + \ No newline at end of file diff --git a/vilesci/stundenplan/check/stdplan_check.php b/vilesci/stundenplan/check/stdplan_check.php new file mode 100644 index 000000000..46b73f3c7 --- /dev/null +++ b/vilesci/stundenplan/check/stdplan_check.php @@ -0,0 +1,46 @@ +1) ORDER BY datum, stunde_id, ort_id LIMIT 20"; + //echo $sql_query."
    "; + $result=pg_exec($conn, $sql_query); + $num_rows=pg_numrows($result); +?> + + + +Stundenplan Check + + + +

    Mehrfachbelegungen

    + + +".pg_fieldname($result,$i).""; + for ($j=0; $j<$num_rows;$j++) + { + $row=pg_fetch_row($result,$j); + $bgcolor = $cfgBgcolorOne; + $foo % 2 ? 0: $bgcolor = $cfgBgcolorTwo; + echo ""; + for ($i=0; $i<$num_fields; $i++) + echo ""; + echo "\n"; + $foo++; + } +} +else + echo "Kein Eintrag gefunden!"; +?> +
    $row[$i]Details"; + echo "
    + + \ No newline at end of file diff --git a/vilesci/stundenplan/check/stdplan_check_delete.php b/vilesci/stundenplan/check/stdplan_check_delete.php new file mode 100644 index 000000000..d3cfb86c2 --- /dev/null +++ b/vilesci/stundenplan/check/stdplan_check_delete.php @@ -0,0 +1,31 @@ +"; + $result=pg_exec($conn, $sql_query); + $num_rows=pg_numrows($result); +?> + + + +Stundenplan Check Details + + + +

    Mehrfachbelegungen Löschen

    + + +
    +
    +
    +Zurück zu Übersicht
    + + \ No newline at end of file diff --git a/vilesci/stundenplan/check/stdplan_check_det.php b/vilesci/stundenplan/check/stdplan_check_det.php new file mode 100644 index 000000000..c04947b70 --- /dev/null +++ b/vilesci/stundenplan/check/stdplan_check_det.php @@ -0,0 +1,46 @@ +"; + $result=pg_exec($conn, $sql_query); + $num_rows=pg_numrows($result); +?> + + + +Stundenplan Check Details + + + +

    Mehrfachbelegungen Detailansicht

    + + +".pg_fieldname($result,$i).""; + for ($j=0; $j<$num_rows;$j++) + { + $row=pg_fetch_row($result,$j); + $bgcolor = $cfgBgcolorOne; + $foo % 2 ? 0: $bgcolor = $cfgBgcolorTwo; + echo ""; + for ($i=0; $i<$num_fields; $i++) + echo ""; + echo "\n"; + $foo++; + } +} +else + echo "Kein Eintrag gefunden!"; +?> +
    $row[$i]Delete"; + echo "
    + + \ No newline at end of file diff --git a/vilesci/stundenplan/einheit_det.php b/vilesci/stundenplan/einheit_det.php new file mode 100644 index 000000000..2f91d5fbc --- /dev/null +++ b/vilesci/stundenplan/einheit_det.php @@ -0,0 +1,88 @@ +kurzbz=addslashes($kurzbz); + $e->addStudent($_POST['student_id']); + +} else if ($_GET['type']=='delete') +{ + + $e=new einheit($conn); + $e->kurzbz=addslashes($kurzbz); + $e->deleteStudent($_GET['uid']); +} + +?> + + + +Einheit Details + + + + +

    Einheit

    + +kurzbz=addslashes($kurzbz); +$studenten=$e->getStudenten(); + +$student=new student($conn); +$studentenAlle=$student->getAll(); + +?> + +
    + + + + + + +
    +
    + + + +"; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + } + +?> +
    UIDVornamenNachname
    ".$studenten[$j]->uid."".$studenten[$j]->vornamen."".$studenten[$j]->nachname."uid."&type=delete&kurzbz=$kurzbz\">Delete
    + + \ No newline at end of file diff --git a/vilesci/stundenplan/einheit_import.php b/vilesci/stundenplan/einheit_import.php new file mode 100644 index 000000000..4f15884dc --- /dev/null +++ b/vilesci/stundenplan/einheit_import.php @@ -0,0 +1,63 @@ + + +'; + $enduid=strpos($field[$i],'"',1); + //echo $enduid.'
    '; + $uid=substr($field[$i],1,$enduid-1); + //echo $uid.'
    '; + $begineinh=strpos($field[$i],'"',$enduid+2)+1; + //echo $begineinh.'
    '; + $endeinh=strpos($field[$i],'"',$begineinh); + //echo $endeinh.'
    '; + $einheit=substr($field[$i],$begineinh,$endeinh-$begineinh); + //echo $einheit.'
    '; + + $sql_query="SELECT * FROM einheit WHERE kurzbz='$einheit'"; + $result=pg_exec($conn, $sql_query); + $rows=pg_numrows($result); + if ($rows==0) + { + $result_ins=pg_exec($conn, "INSERT INTO einheit (kurzbz) VALUES ('$einheit')"); + if(!$result_ins) + error(pg_errormessage()); + $sql_query="SELECT * FROM einheit WHERE kurzbz='$einheit'"; + $result=pg_exec($conn, $sql_query); + } + $row=pg_fetch_object($result,0); + $einheit_id=$row->id; + + $sql_query="SELECT * FROM student WHERE uid='$uid'"; + //echo $sql_query.'
    '; + $result=pg_exec($conn, $sql_query); + if(!$result) + error(pg_errormessage()); + $rows=pg_numrows($result); + if ($rows==0) + die("Student $uid not found!"); + $row=pg_fetch_object($result,0); + $student_id=$row->id; + + $sql_query="SELECT * FROM einheitstudent WHERE einheit_id=$einheit_id AND student_id=$student_id"; + $result=pg_exec($conn, $sql_query); + $rows=pg_numrows($result); + if ($rows==0) + { + $result_ins=pg_exec($conn, "INSERT INTO einheitstudent (einheit_id, student_id) VALUES ($einheit_id, $student_id)"); + if(!$result_ins) + error(pg_errormessage()); + $result=pg_exec($conn, $sql_query); + } + } +?> +Finished
    +Zurück + + \ No newline at end of file diff --git a/vilesci/stundenplan/einheit_menu.php b/vilesci/stundenplan/einheit_menu.php new file mode 100644 index 000000000..13969626e --- /dev/null +++ b/vilesci/stundenplan/einheit_menu.php @@ -0,0 +1,219 @@ + + +Einheiten Verwaltung + + + + +

    Einheiten Verwaltung

    +
    + +kurzbz=addslashes($_GET['einheit_id']); + $e->delete(); + getUebersicht(); + +} +else +{ + getUebersicht(); +} + + +function doSave() +{ + global $conn; + $e=new einheit($conn); + if ($_POST['new']) + { + $e->kurzbz=$_POST['kurzbz']; + $e->bezeichnung=$_POST['bezeichnung']; + $e->stg_kz=$_POST['studiengang_kz']; + $e->semester=$_POST['semester']; + $e->typ=$_POST['typ']; + $e->mailgrp_kurzbz=$_POST['mailgrp_kurzbz']; + $e->new=true; + $e->save(); + } + else + { + $e->kurzbz=$_POST['pk']; + $e->bezeichnung=$_POST['bezeichnung']; + $e->stg_kz=$_POST['studiengang_kz']; + $e->semester=$_POST['semester']; + $e->typ=$_POST['typ']; + $e->mailgrp_kurzbz=$_POST['mailgrp_kurzbz']; + $e->new=false; + if (!$e->save($_POST['kurzbz'])) + echo $e->errormsg; + } + +} + + + +function doEdit($conn,$kurzbz,$new=false) +{ + if (!$new) + { + $e=new einheit($conn,$kurzbz); + } + ?> +
    +

    Einheit : + + + + + + + + + + +
    Name +
    Kurzbezeichnung +
    Studiengang + + + +
    Semester
    Typ
    Mailgrp Kurzbz + +
    + + + + + + + +

    +
    +
    + +getAll(); + //print_r($einheiten); + ?> +
    +

    Import von Untis (Kurswahl der Studenten) + + +

    +
    +
    + +
    +
    +
    + +

    Übersicht

    + + + +"; + + for ($i=0; $i<$num_rows; $i++) + { + $e=$einheiten[$i]; + $c=$i%2; + + echo ''; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + } +?> +
    Kurzbz.BezeichnungStg.Sem.TypMailgrpAnzahlAktion
    $e->kurzbz $e->bezeichnung $e->stg_kurzbz $e->semester $e->typ $e->mailgrp_kurzbz".$einheit->countStudenten($e->kurzbz)."kurzbz\">Detailskurzbz\">Editkurzbz&type=delete\">Delete
    + + + + \ No newline at end of file diff --git a/vilesci/stundenplan/export/index.html b/vilesci/stundenplan/export/index.html new file mode 100644 index 000000000..9428df57c --- /dev/null +++ b/vilesci/stundenplan/export/index.html @@ -0,0 +1,14 @@ + + +Untitled Document + + + + + +

    Räume

    +

    Lektoren - Zeitwünsche

    +

    Studenten

    +

     

    + + diff --git a/vilesci/stundenplan/export/lektoren.php b/vilesci/stundenplan/export/lektoren.php new file mode 100644 index 000000000..b9dc863f6 --- /dev/null +++ b/vilesci/stundenplan/export/lektoren.php @@ -0,0 +1,31 @@ +kurzbz.'","'.$row->nachname.'",,,,,,,,,,,,,,,,,,,,,,,,,,,"'.$row->vornamen.'","'.$row->titel.'",,'.$crlf; + } +?> \ No newline at end of file diff --git a/vilesci/stundenplan/export/raum.php b/vilesci/stundenplan/export/raum.php new file mode 100644 index 000000000..cc2638c7e --- /dev/null +++ b/vilesci/stundenplan/export/raum.php @@ -0,0 +1,31 @@ +kurzbz.'","'.$row->bezeichnung.'",,,,,,'.$row->max_person.',,,,,,,,,,'.$crlf; + } +?> \ No newline at end of file diff --git a/vilesci/stundenplan/export/studenten.php b/vilesci/stundenplan/export/studenten.php new file mode 100644 index 000000000..434e3e9ab --- /dev/null +++ b/vilesci/stundenplan/export/studenten.php @@ -0,0 +1,31 @@ +uid.'","'.$row->nachname.'",,,,,,"'.$row->vornamen.'","'.$row->matrikelnr.'","'.$row->kurzbz.'-'.$row->semester.$row->verband.$row->gruppe.'","2",'.$crlf; + } +?> \ No newline at end of file diff --git a/vilesci/stundenplan/export/zeitwunsch.php b/vilesci/stundenplan/export/zeitwunsch.php new file mode 100644 index 000000000..376f995a8 --- /dev/null +++ b/vilesci/stundenplan/export/zeitwunsch.php @@ -0,0 +1,31 @@ +kurzbz.'",'.$row->tag.','.$row->stunde_id.','.$row->gewicht.$crlf; + } +?> \ No newline at end of file diff --git a/vilesci/stundenplan/import/index.html b/vilesci/stundenplan/import/index.html new file mode 100644 index 000000000..56c331f19 --- /dev/null +++ b/vilesci/stundenplan/import/index.html @@ -0,0 +1,23 @@ + + +Stundenplan Import + + + + + +
    +

    Import von Untis (lesson.txt) + + +

    +
    +
    +

    Check IDs (UPDATE untis SET ort='DUMMY' + WHERE ort='')

    +

    Send Mails

    +

    Send Mails Modul

    +

    Take Over (DELETE FROM tbl_stundenplan WHERE datum>='2005-02-14')

    +

    Take Over Einheiten

    + + diff --git a/vilesci/stundenplan/import/stdplan_import.php b/vilesci/stundenplan/import/stdplan_import.php new file mode 100644 index 000000000..943d740d8 --- /dev/null +++ b/vilesci/stundenplan/import/stdplan_import.php @@ -0,0 +1,57 @@ + + +'; + $endpos=strpos($field[$i],9); + $lektor=substr($field[$i],0,$endpos); + //echo $lektor.'
    '; + $beginpos=$endpos+1; + $endpos=strpos($field[$i],9,$beginpos); + $wochentag=substr($field[$i],$beginpos,$endpos-$beginpos); + //echo $wochentag.'
    '; + $beginpos=$endpos+1; + $endpos=strpos($field[$i],9,$beginpos); + $stunde_id=substr($field[$i],$beginpos,$endpos-$beginpos); + //echo $stunde_id.'
    '; + $beginpos=$endpos+1; + $endpos=strpos($field[$i],9,$beginpos); + $lehrfach=substr($field[$i],$beginpos,$endpos-$beginpos); + //echo $lehrfach.'
    '; + $beginpos=$endpos+1; + $endpos=strpos($field[$i],9,$beginpos); + $ort=substr($field[$i],$beginpos,$endpos-$beginpos); + //echo $ort.'
    '; + $beginpos=$endpos+1; + $endpos=strpos($field[$i],9,$beginpos); + $unr=substr($field[$i],$beginpos,$endpos-$beginpos); + //echo $unr.'
    '; + $beginpos=$endpos+1; + $endpos=strpos($field[$i],9,$beginpos); + $keineahnung=substr($field[$i],$beginpos,$endpos-$beginpos); + //echo $keineahnung.'
    '; + $beginpos=$endpos+1; + $endpos=strpos($field[$i],9,$beginpos); + $klassenbez=substr($field[$i],$beginpos,$endpos-$beginpos); + //echo $klassenbez.'
    '; + $beginpos=$endpos+1; + $endpos=strlen($field[$i]); + $jahreswochen=trim(substr($field[$i],$beginpos,$endpos-$beginpos)); + //echo $jahreswochen.'
    '; + + $sql_query="INSERT INTO untis (lektor,wochentag,stunde,lehrfach,ort,unr,jahreswochen,klassenbez) VALUES ('$lektor','$wochentag','$stunde_id','$lehrfach','$ort','$unr','$jahreswochen','$klassenbez')"; + $result=pg_exec($conn, $sql_query); + if(!$result) + die(pg_errormessage().'
    '.$i.'
    '.$sql_query); + } +?> +Finished
    +Zurück + + \ No newline at end of file diff --git a/vilesci/stundenplan/import/stdplan_import_check_ID.php b/vilesci/stundenplan/import/stdplan_import_check_ID.php new file mode 100644 index 000000000..bcac80225 --- /dev/null +++ b/vilesci/stundenplan/import/stdplan_import_check_ID.php @@ -0,0 +1,169 @@ + + + + +Check ID + + + + +

    ID's werden überprüft

    +0) + { + for ($i=0; $i<$num_rows; $i++) + { + $row=pg_fetch_object($result,$i); + $sql_query="UPDATE untis SET lektor_uid=(SELECT uid FROM tbl_mitarbeiter WHERE kurzbz='$row->lektor') WHERE lektor='$row->lektor'"; + //echo $sql_query; + $result_update=pg_exec($conn, $sql_query); + if (pg_cmdtuples($result_update)==0) + echo 'UID fuer Lektoren Kurzbezeichnung '.$row->lektor.' konnte nicht gefunden werden!
    '; + else + { + echo pg_cmdtuples($result_update).' Einträge für '.$row->lektor.' wurden upgedatet!
    '; + $countok++; + } + } + echo $countok.' Lektoren UIDs wurden erfolgreich vergeben!
    '; + echo $num_rows-$countok.' Lektoren IDs konnten nicht gefunden werden!

    '; + } + else + echo 'Keine nicht vergebenen UIDs bei Lektor gefunden!

    '; + flush(); + + //***************************************************************************************** + // Ort + + // Tabelle Untis nach nichtvergebenen IDs abfragen + $sql_query="SELECT ort FROM untis WHERE ort_kurzbz IS NULL GROUP BY ort"; + $result=pg_exec($conn, $sql_query); + $num_rows=pg_numrows($result); + + if ($num_rows>0) + { + for ($i=0; $i<$num_rows;$i++) + { + $row=pg_fetch_object($result,$i); + $sql_query="UPDATE untis SET ort_kurzbz=(SELECT ort_kurzbz FROM tbl_ort WHERE ort_kurzbz='$row->ort') WHERE ort='$row->ort'"; + $result_update=pg_exec($conn, $sql_query); + if (pg_cmdtuples($result_update)==0) + echo 'ID fuer Ort Kurzbezeichnung '.$row->ort.' konnte nicht gefunden werden!
    '; + else + echo pg_cmdtuples($result_update).' Einträge für '.$row->ort.' wurden upgedatet!
    '; + } + echo 'Ort kurzbzs wurden erfolgreich vergeben!

    '; + } + else + echo 'Keine nicht vergebenen kurzbzs bei Ort gefunden!

    '; + flush(); + + //***************************************************************************************** + // Lehrfach + + // Tabelle Untis nach nichtvergebenen IDs abfragen + $sql_query="SELECT DISTINCT lehrfach FROM untis WHERE (lehrfach_nr IS NULL OR lehrfach_nr=0) AND lehrfach NOT LIKE '\\\\_%'"; + $result=pg_exec($conn, $sql_query); + $num_rows=pg_numrows($result); + + if ($num_rows>0) + { + for ($i=0; $i<$num_rows;$i++) + { + $row=pg_fetch_object($result,$i); + $sql_query="UPDATE untis SET lehrfach_nr= + (SELECT lehrfach_nr FROM tbl_lehrfach WHERE kurzbz='".substr($row->lehrfach,0,3)."' + AND lehrform_kurzbz='".substr($row->lehrfach,3)."') + WHERE lehrfach='$row->lehrfach'"; + $result_update=pg_exec($conn, $sql_query); + if (pg_cmdtuples($result_update)==0) + echo 'ID fuer Lehrfach Kurzbezeichnung '.$row->lehrfach.' konnte nicht gefunden werden!
    '; + else + echo pg_cmdtuples($result_update).' Einträge für '.$row->lehrfach.' wurden upgedatet!
    '; + } + echo 'Lehrfach Nr wurden erfolgreich vergeben!

    '; + } + else + echo 'Keine nicht vergebenen Nummern bei Lehrfach gefunden!

    '; + flush(); + + //***************************************************************************************** + // Module + + // Tabelle Untis nach nichtvergebenen IDs abfragen + $sql_query="SELECT DISTINCT lehrfach FROM untis WHERE (lehrfach_nr IS NULL OR einheit_kurzbz='' OR einheit_kurzbz IS NULL) AND lehrfach LIKE '\\\\_%'"; + $result=pg_exec($conn, $sql_query); + $num_rows=pg_numrows($result); + + if ($num_rows>0) + { + for ($i=0; $i<$num_rows;$i++) + { + $row=pg_fetch_object($result,$i); + $sql_query="UPDATE untis SET einheit_kurzbz=(SELECT einheit_kurzbz FROM tbl_einheit + WHERE einheit_kurzbz='".trim(substr($row->lehrfach,1))."') + ,lehrfach_nr=0 WHERE lehrfach='$row->lehrfach'"; + //echo $sql_query; + $result_update=pg_exec($conn, $sql_query); + if (pg_cmdtuples($result_update)==0) + echo 'Einheit Kurzbezeichnung '.$row->lehrfach.' konnte nicht gefunden werden!
    '; + else + echo pg_cmdtuples($result_update).' Einträge für '.$row->lehrfach.' wurden upgedatet!
    '; + } + echo 'Einheiten wurden erfolgreich vergeben!

    '; + } + else + echo 'Keine nicht vergebenen Einheiten gefunden!

    '; + flush(); + + //***************************************************************************************** + // Lehrverband + + // Tabelle Untis nach nichtvergebenen IDs abfragen + $sql_query="SELECT DISTINCT klassenbez FROM untis WHERE studiengang_kz IS NULL"; + $result=pg_exec($conn, $sql_query); + $num_rows=pg_numrows($result); + + if ($num_rows>0) + { + for ($i=0; $i<$num_rows;$i++) + { + $row=pg_fetch_object($result,$i); + $stgkz=substr($row->klassenbez,0,3); + $semester=substr($row->klassenbez,4,1); + $verband=substr($row->klassenbez,5,1); + $gruppe=substr($row->klassenbez,6,1); + $sql_query="UPDATE untis SET studiengang_kz=(SELECT studiengang_kz FROM tbl_studiengang WHERE kurzbz='$stgkz'), semester='$semester', verband='$verband', gruppe='$gruppe' WHERE klassenbez='$row->klassenbez'"; + //echo $sql_query; + $result_update=pg_query($conn, $sql_query); + if (pg_cmdtuples($result_update)==0) + echo 'Klassenbezeichnung '.$row->klassenbez.' konnte nicht gefunden werden!
    '; + else + echo pg_cmdtuples($result_update).' Einträge für '.$row->klassenbez.' wurden upgedatet!
    '; + } + echo 'Klassen IDs wurden erfolgreich vergeben!

    '; + } + else + echo 'Keine nicht vergebenen Klassenbez gefunden!

    '; +?> + + + \ No newline at end of file diff --git a/vilesci/stundenplan/import/stdplan_import_sendmail.php b/vilesci/stundenplan/import/stdplan_import_sendmail.php new file mode 100644 index 000000000..0f9a6c585 --- /dev/null +++ b/vilesci/stundenplan/import/stdplan_import_sendmail.php @@ -0,0 +1,103 @@ + + + + +Send Mails + + + + +

    eMails werden verschickt

    +0 AND lehrfach_id>0 AND lektor_id>0 AND studiengang_id>0 AND lehrfach NOT LIKE '\\\\_%' ORDER BY lektor"; + //echo $sql_query; + $result=pg_exec($conn, $sql_query); + $num_rows=pg_numrows($result); + echo $num_rows.' Eintraege in der Tabelle Untis fuer den Stundenplan

    Verarbeitung laeuft (0) '; + flush(); + $lektor_id=0; + $text=""; + $sendmail=0; + $stundenanzahl=0; + + for ($i=0; $i<$num_rows; $i++) + { + if ($i%10==0) + { + echo '.'; + flush(); + } + $row=pg_fetch_object($result,$i); + if ($lektor_id!=$row->lektor_id) + { + if (($lektor_id!=0) && $sendmail) + { + $text.="\nhttp://cis.technikum-wien.at\n\nFehler und Feedback bitte an mailto:stpl@technikum-wien.at"; + $sql_query="SELECT emailtw FROM lektor WHERE id=$lektor_id"; + $result_sendto=pg_exec($conn, $sql_query); + $row_sendto=pg_fetch_object($result_sendto,0); + $sendto=$row_sendto->emailtw; + if (!mail($sendto, "Stundenplan Aenderung ($stundenanzahl Stunden)", $text, "From: stpl@technikum-wien.at\r\n"."Reply-To: stpl@technikum-wien.at\r\n"."X-Mailer: PHP/".phpversion() ) ) + die ("
    Mail an $sendto konnte nicht verschickt werden.
    "); + echo '
    Mail verschickt an '.$sendto.'
    Verarbeitung laeuft ('.$i.') '; + flush(); + $stundenanzahl=0; + $sendmail=0; + } + $lektor_id=$row->lektor_id; + $text="Dies ist eine automatische eMail!\nFolgende Aenderungen sind in ihrem Stundenplan vorgenommen worden\n\n"; + $text.="Datum\t\tStunde\tVerband\n"; + } + for ($w=1; $w<=53; $w++) + { + if (substr($row->jahreswochen,$w-1,1)=='1') + { + $date=$week_date[$w]+($tagsek*($row->wochentag-1)); + $date=getdate($date); + $tag=$date[mday]; + $monat=$date[mon]; + $jahr=$date[year]; + $date=$jahr.'-'.$monat.'-'.$tag; + $sql_query="SELECT * FROM stundenplan WHERE studiengang_id=$row->studiengang_id AND semester=$row->semester AND "; + $sql_query.="verband='$row->verband' AND gruppe='$row->gruppe' AND ort_id=$row->ort_id AND datum='$date' AND "; + $sql_query.="stunde_id=$row->stunde_id AND lehrfach_id=$row->lehrfach_id AND lektor_id=$row->lektor_id"; + $result_checkmail=pg_exec($conn, $sql_query); + $num_checkmail=pg_numrows($result_checkmail); + if ($num_checkmail==0) + { + //$row_checkmail=pg_fetch_object($result_checkmail,0); + $text.="$date\t$row->stunde_id\t$row->semester$row->verband$row->gruppe\r\n"; + //$text.="$row_checkmail->datum\t$row_checkmail->stunde_id\t$row_checkmail->semester$row_checkmail->verband$row_checkmail->gruppe\t$row_checkmail->ortkurzbz\t$row_checkmail->stgkurzbz\t$row_checkmail->lehrfachkurzbz lektor_id lektorkurzbz + $stundenanzahl++; + $sendmail=1; + } + } + } + $sql_query="UPDATE untis SET checkmail='t' WHERE id=$row->id"; + $result_insert=pg_exec($conn, $sql_query); + } + if ($sendmail) + { + $text.="\nhttp://cis.technikum-wien.at\n\nFehler und Feedback bitte an mailto:stpl@technikum-wien.at"; + $sql_query="SELECT emailtw FROM lektor WHERE id=$lektor_id"; + $result_sendto=pg_exec($conn, $sql_query); + $row_sendto=pg_fetch_object($result_sendto,0); + $sendto=$row_sendto->emailtw; + $sendto=$row_sendto->emailtw; + if (!mail($sendto, "Stundenplan Aenderung ($stundenanzahl Stunden)", $text, "From: stpl@technikum-wien.at\r\n"."Reply-To: stpl@technikum-wien.at\r\n"."X-Mailer: PHP/".phpversion() ) ) + die ("
    Mail an $sendto konnte nicht verschickt werden."); + echo 'Mail verschickt an '.$sendto.'
    '; + } + echo '
    Verarbeitung erfolgreich abgeschlossen!'; + +?> + + + \ No newline at end of file diff --git a/vilesci/stundenplan/import/stdplan_import_takeover.php b/vilesci/stundenplan/import/stdplan_import_takeover.php new file mode 100644 index 000000000..56a7d82ed --- /dev/null +++ b/vilesci/stundenplan/import/stdplan_import_takeover.php @@ -0,0 +1,56 @@ + + + + +Check ID + + + + +

    Stundenplan wird übertragen

    + +0 AND lektor_uid IS NOT NULL AND studiengang_kz IS NOT NULL AND lehrfach NOT LIKE '\\\\_%'"; + //echo $sql_query; + $result=pg_exec($conn, $sql_query); + $num_rows=pg_numrows($result); + echo $num_rows.' Rows will be moved
    '; + flush(); + + for ($i=0; $i<$num_rows; $i++) + { + if (($i%50)==0) + echo '
    '.$i; + echo '.'; + flush(); + $row=pg_fetch_object($result,$i); + for ($w=1; $w<=53; $w++) + { + if (substr($row->jahreswochen,$w-1,1)=='1') + { + $date=$week_date[$w]+($tagsek*($row->wochentag-1)); + $date=getdate($date); + $tag=$date[mday]; + $monat=$date[mon]; + $jahr=$date[year]; + $date=$jahr.'-'.$monat.'-'.$tag; + $sql_query="INSERT INTO tbl_stundenplan (unr, studiengang_kz, semester, verband, gruppe, ort_kurzbz, datum, stunde, lehrfach_nr, uid) + VALUES ('$row->unr',$row->studiengang_kz,$row->semester,'$row->verband','$row->gruppe', '$row->ort_kurzbz', '$date', $row->stunde, $row->lehrfach_nr, '$row->lektor_uid')"; + $result_insert=pg_exec($conn, $sql_query); + } + } + $sql_query="DELETE FROM untis WHERE id=$row->id"; + $result_insert=pg_exec($conn, $sql_query); + } +?> +
    Finished! + + \ No newline at end of file diff --git a/vilesci/stundenplan/import/stdplan_import_takeover_modul.php b/vilesci/stundenplan/import/stdplan_import_takeover_modul.php new file mode 100644 index 000000000..0e6f8b6e1 --- /dev/null +++ b/vilesci/stundenplan/import/stdplan_import_takeover_modul.php @@ -0,0 +1,54 @@ + + + + +Check ID + + + + +

    Einheitenplan wird übertragen

    + +'; + flush(); + for ($i=0; $i<$num_rows; $i++) + { + if (($i%50)==0) + echo '
    '.$i; + echo '.'; + flush(); + $row=pg_fetch_object($result,$i); + for ($w=1; $w<=53; $w++) + { + if (substr($row->jahreswochen,$w-1,1)=='1') + { + $date=$week_date[$w]+($tagsek*($row->wochentag-1)); + $date=getdate($date); + $tag=$date[mday]; + $monat=$date[mon]; + $jahr=$date[year]; + $date=$jahr.'-'.$monat.'-'.$tag; + $sql_query="INSERT INTO tbl_stundenplan (unr, ort_kurzbz, datum, stunde, lehrfach_nr, einheit_kurzbz, uid, studiengang_kz, semester, verband, gruppe) VALUES + ('$row->unr', '$row->ort_kurzbz', '$date', $row->stunde, $row->lehrfach_nr,'$row->einheit_kurzbz','$row->lektor_uid',$row->studiengang_kz,$row->semester,NULL,NULL)"; + $result_insert=pg_exec($conn, $sql_query); + } + } + $sql_query="DELETE FROM untis WHERE id=$row->id"; + $result_insert=pg_exec($conn, $sql_query); + } +?> +
    Finished! + + diff --git a/vilesci/stundenplan/import/wochendatum.inc.php b/vilesci/stundenplan/import/wochendatum.inc.php new file mode 100644 index 000000000..dac2e4efc --- /dev/null +++ b/vilesci/stundenplan/import/wochendatum.inc.php @@ -0,0 +1,46 @@ + diff --git a/vilesci/stundenplan/lehrfach.php b/vilesci/stundenplan/lehrfach.php new file mode 100644 index 000000000..a2492ebf5 --- /dev/null +++ b/vilesci/stundenplan/lehrfach.php @@ -0,0 +1,284 @@ +getAll(); +$s=new studiengang($conn); +$studiengang=$s->getAll(); + +if (isset($_GET[stg_kz]) || isset($_POST[stg_kz])) + $stg_kz=(isset($_GET[stg_kz])?$_GET[stg_kz]:$_POST[stg_kz]); +else + $stg_kz=0; +if (isset($_GET[semester]) || isset($_POST[semester])) + $semester=(isset($_GET[semester])?$_GET[semester]:$_POST[semester]); +else + $semester=0; + +if (isset($_POST['neu'])) +{ + //Einf?gen in die Datenbank + $sql_query="INSERT INTO tbl_lehrfach (fachbereich_id,bezeichnung, kurzbz, lehrevz,farbe, aktiv, studiengang_kz,semester,sprache) ". + "VALUES (".($_POST['fachbereich_id']==-1?'NULL':$_POST['fachbereich_id'])." ,'". + $_POST['bezeichnung']."','". + $_POST['kurzbz']."', '".$_POST['lehrevz']."', '".$_POST['farbe']."',true,$stg_kz,$semester,'".$_POST['sprache']."')"; + //echo $sql_query; + $result=pg_exec($conn, $sql_query); + if(!$result) + echo pg_errormessage()."
    "; +} +if ($type=="editsave") +{ + //Einf?gen in die Datenbank + $sql_query="UPDATE tbl_lehrfach SET bezeichnung='".$_POST['bezeichnung']."', ". + "kurzbz='".$_POST['kurzbz']."', lehrevz='".$_POST['lehrevz']."',fachbereich_id='".$_POST['fachbereich_id']."',". + "farbe='".$_POST['farbe']."',". + "sprache='".$_POST['sprache']."',". + 'aktiv='.($_POST['aktiv']==1?'true':'false'). + ', lehre='.($_POST['lehre']==1?'true':'false'). + " WHERE lehrfach_nr=".$_POST['lehrfach_nr']; + //echo $sql_query; + $result=pg_exec($conn, $sql_query); + if(!$result) + echo pg_errormessage()."
    "; +} + +if(isset($_GET['type']) && $_GET['type']=="lehre" && isset($_GET['lehrfach_nr'])) +{ + if($_GET['lehrfach_nr']!='') + { + $sql_qry="Update tbl_lehrfach set lehre= NOT lehre where lehrfach_nr=".$_GET['lehrfach_nr']; + $result=pg_exec($conn, $sql_qry); + if(!$result) + echo pg_errormessage()."
    "; + + } + else + echo "Lehrfachnummer wurde nicht übergeben, Bitte nochmals versuchen"; + +} + +/*if ($type=="delete") +{ + $sql_query="DELETE FROM lehrfach WHERE id=$lehrfach_id"; + $result=pg_exec($conn, $sql_query); + if(!$result) + echo pg_errormessage()."
    "; + $sql_query="DELETE FROM einheitstudent WHERE einheit_id=$einheit_id"; + $result=pg_exec($conn, $sql_query); + if(!$result) + echo pg_errormessage()."
    "; + $sql_query="DELETE FROM einheit WHERE id=$einheit_id"; + $result=pg_exec($conn, $sql_query); + if(!$result) + echo pg_errormessage()."
    "; +}*/ + +$sql_query="SELECT tbl_lehrfach.lehrfach_nr AS Nummer, tbl_lehrfach.kurzbz AS Fach, tbl_lehrfach.bezeichnung AS Bezeichnung, + tbl_lehrfach.lehrevz AS Lehrevz, tbl_lehrfach.farbe AS Farbe, + tbl_lehrfach.aktiv,tbl_lehrfach.ects,tbl_fachbereich.kurzbz AS Fachbereich ,tbl_lehrfach.lehre as lehre, tbl_lehrfach.sprache AS Sprache + FROM tbl_lehrfach JOIN tbl_fachbereich USING (fachbereich_id) + WHERE tbl_lehrfach.studiengang_kz=$stg_kz AND semester=$semester ORDER BY tbl_lehrfach.kurzbz"; +//echo $sql_query; +$result_lehrfach=pg_exec($conn, $sql_query); +if(!$result_lehrfach) error("Lehrfach not found!"); + +$s=array(); +foreach ($studiengang as $stg) +{ + $outp.= ''.$stg->kurzbzlang.' - '; + $s[$stg->studiengang_kz]->max_sem=$stg->max_semester; + $s[$stg->studiengang_kz]->kurzbz=$stg->kurzbzlang; +} +$outp.= '
    -- '; +for ($i=0;$i<=$s[$stg_kz]->max_sem;$i++) + $outp.= ''.$i.' -- '; +?> + + + +Lehrfach Verwaltung + + + + +

    Lehrfach Verwaltung (kurzbz.' - '.$semester; ?>)

    + +'; + echo '

    Edit Lehrfach: '.$_GET['lehrfach_nr'].''; + echo ''; + //echo ''; + ?> + +'; + echo ''; + echo ''; + echo ''; + + echo ''; + echo ''; + echo '
    Nr.
    Fachbereich
    Name
    Kurzbezeichnung'; + echo '
    Lehre Vz'; + echo '
    Farbe'; + echo '
    Aktivaktiv=='t'?'checked':'').' />'; + echo '
    Lehrelehre=='t'?'checked':'').'>
    Sprache
    '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo '


    '; +} else +{ +?> + + +
    +

    Neues Lehrfach:
    + '; + echo '

  • Nr.
    Fachbereich
    Name
    Kurzbezeichnung'; + echo '
    Lehre Vz'; + echo '
    Farbe'; + echo '
    Lehrelehre=='t'?'checked':'').'>
    Sprache
    '; + echo ''; + echo ''; + +?> + + + + + +

    + +
    + +

    Übersicht

    + + +id\n"; + + for($i=0;$i<$num_rows;$i++) + { + $row=pg_fetch_object($result_lehrfach); + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + } + + /* + $num_fields=pg_numfields($result_lehrfach); + $foo = 0; + for ($i=0;$i<$num_fields; $i++) + echo ""; + for ($j=0; $j<$num_rows;$j++) + { + $row=pg_fetch_row($result_lehrfach,$j); + $bgcolor = $cfgBgcolorOne; + $foo % 2 ? 0: $bgcolor = $cfgBgcolorTwo; + echo ""; + for ($i=0; $i<$num_fields; $i++) + echo ""; + //echo ""; + echo ""; + //echo "\n"; + $foo++; + } + */ +} +else + echo "Kein Eintrag gefunden!"; +?> +
    kurzbzbezeichnunglehrevzfarbeaktivectsfachbereichsprachelehre
    $row->nummer$row->fach$row->bezeichnung$row->lehrevz$row->farbe$row->aktiv$row->ects$row->fachbereich$row->sprachelehre=='t'?'checked':'').">nummer&type=edit&stg_kz=$stg_kz&semester=$semester\">Edit
    ".pg_fieldname($result_lehrfach,$i)."
    $row[$i]Details"; + //echo "EditEditDelete"; + echo "
    + + +
    + + \ No newline at end of file diff --git a/vilesci/stundenplan/lehrfach/wartung.php b/vilesci/stundenplan/lehrfach/wartung.php new file mode 100644 index 000000000..ecf4efd0e --- /dev/null +++ b/vilesci/stundenplan/lehrfach/wartung.php @@ -0,0 +1,232 @@ +18) + return substr($string,0,15)."..."; + else + return $string; + } + + if(isset($radio_1) && isset($radio_2)) + { + if($radio_1==$radio_2) + $msg="Die Datensätze dürfen nicht die gleiche id haben"; + else + { + $sql_query_upd1="UPDATE tbl_stundenplan Set lehrfach_nr='$radio_2' WHERE lehrfach_nr='$radio_1';"; + $sql_query_upd1.=" UPDATE tbl_stundenplandev Set lehrfach_nr='$radio_2' WHERE lehrfach_nr='$radio_1';"; + $sql_query_upd1.=" UPDATE tbl_lehrveranstaltung Set lehrfach_nr='$radio_2' WHERE lehrfach_nr='$radio_1';"; + $sql_query_upd1.=" UPDATE tbl_lvinfo Set lehrfach_nr='$radio_2' WHERE lehrfach_nr='$radio_1';"; + $sql_query_upd1.=" DELETE FROM tbl_lehrfach WHERE lehrfach_nr='$radio_1';"; + + if(pg_exec($conn,$sql_query_upd1)) + { + $msg = "Daten Erfolgreich gespeichert
    "; + } + $msg .= $sql_query_upd1 ."
    "; + + } + } + + if((isset($radio_1) && !isset($radio_2))||(!isset($radio_1) && isset($radio_2))) + { + $msg="Es müssen beide Radio Buttons angeklickt werden"; + } +?> + + + + + + +LV-Verteilung + + + +

    Lehrfach - Wartung

    + + + +"; + echo ""; + + //Drop Down Menü für Stg Tab1 + echo "  "; + + //Drop Down Menü für Sem Tab1 + echo "  "; + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; +?> + +
     "; + echo "
    "; + + //Drop Down Menü für Stg Tab2 + echo "  "; + + //Drop Down Menü für Sem Tab2 + echo "  "; + + echo ""; + echo "
    "; + echo "
    +
    +

    +
    + +"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "
    Das wird geloescht:"; + + //Tabelle 1 + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + $lf = new lehrfach($conn); + $lf->getTab($stg_1,$sem_1, $order_1); + $i=0; + foreach($lf->fkterg as $l) + { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + $i++; + } + echo "
     LFNrKurzbzFormBezeichnungLVZECTS
    lehrfach_nr)?'checked':'').">$l->lehrfach_nr$l->kurzbz$l->lehrform_kurzbz".kuerze($l->bezeichnung)."$l->lehrevz$l->ects
    "; + echo "
    Das bleibt"; + + //Tabelle 2 + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + $lf = new lehrfach($conn); + $lf->getTab($stg_2,$sem_2, $order_2); + $i=0; + foreach($lf->fkterg as $l) + { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + $i++; + } + echo "
     LFNrKurzbzFormBezeichnungLVZECTS
    lehrfach_nr)?'checked':'').">$l->lehrfach_nr$l->kurzbz$l->lehrform_kurzbz".kuerze($l->bezeichnung)."$l->lehrevz$l->ects
    "; + echo "
    "; + echo ""; + +?> + + + + + + + + diff --git a/vilesci/stundenplan/lehrfach_verteilung.php b/vilesci/stundenplan/lehrfach_verteilung.php new file mode 100644 index 000000000..9a45dee68 --- /dev/null +++ b/vilesci/stundenplan/lehrfach_verteilung.php @@ -0,0 +1,214 @@ +0 ORDER BY kurzbz"; + //echo $sql_query."
    "; + $result_stg=pg_exec($conn, $sql_query); + if(!$result_stg) error ("studiengang not found!"); + $sql_query="SELECT id, kurzbz FROM lehrfach ORDER BY kurzbz"; + $result_lehrf=pg_exec($conn, $sql_query); + if(!$result_lehrf) echo "lehrfach not found!"; + $sql_query="SELECT id, kurzbz FROM ort ORDER BY kurzbz"; + $result_ort=pg_exec($conn, $sql_query); + if(!$result_ort) echo "ort not found!"; + if (!isset($stgid)) + $stgid=1; + $sql_query="SELECT kurzbz FROM studiengang WHERE id=$stgid"; + $result_stgbz=pg_exec($conn, $sql_query); + if(!$result_stgbz) + echo "lehrfach not found!"; + else + $stgbz=pg_result($result_stgbz,0,'kurzbz'); + if (!isset($semester)) + $semester=0; + if (!isset($verband)) + $verband='0'; + if (!isset($gruppe)) + $gruppe=0; + if (!isset($tag)) + $tag=1; + if (!isset($monat)) + $monat=1; + if (!isset($jahr)) + $jahr=2002; + $datum=" AND datum<='2002-07-01' AND datum>='2002-02-05'"; +?> + + + +Lehrfachverteilung + + + + +

    Lehrfachverteilung

    +
    +
    +

    Studiengang + + Semester + +

    +

    + + +

    +
    +
    + + + + + + + + + + + + + + + + + lehrfach_id; + $bgcolor = $cfgBgcolorOne; + $foo % 2 ? 0: $bgcolor = $cfgBgcolorTwo; + echo ""; + + $sql_query="SELECT kurzbz FROM lehrfach WHERE id='$lehrfachid'"; + $result=pg_exec($conn, $sql_query); + $row_lfbz=pg_fetch_object ($result, 0); + echo ""; + + $sql_query="SELECT count(*) AS stunden FROM stundenplan WHERE studiengang_id='$stgid' AND semester='$semester' AND lehrfach_id='$lehrfachid'".$datum." GROUP BY lehrfach_id"; + $result=pg_exec($conn, $sql_query); + if (pg_numrows($result)>0) + $row=pg_fetch_object ($result, 0); + else + $row->stunden=0; + echo ""; + + $sql_query="SELECT count(*) AS stunden FROM stundenplan WHERE studiengang_id='$stgid' AND semester='$semester' AND verband='0' AND gruppe='0' AND lehrfach_id='$lehrfachid'".$datum." GROUP BY lehrfach_id"; + $result=pg_exec($conn, $sql_query); + if (pg_numrows($result)>0) + $row=pg_fetch_object ($result, 0); + else + $row->stunden=0; + echo ""; + + $sql_query="SELECT count(*) AS stunden FROM stundenplan WHERE studiengang_id='$stgid' AND semester='$semester' AND verband='A' AND gruppe='0' AND lehrfach_id='$lehrfachid'".$datum." GROUP BY lehrfach_id"; + $result=pg_exec($conn, $sql_query); + if (pg_numrows($result)>0) + $row=pg_fetch_object ($result, 0); + else + $row->stunden=0; + echo ""; + + $sql_query="SELECT count(*) AS stunden FROM stundenplan WHERE studiengang_id='$stgid' AND semester='$semester' AND verband='A' AND gruppe='1' AND lehrfach_id='$lehrfachid'".$datum." GROUP BY lehrfach_id"; + $result=pg_exec($conn, $sql_query); + if (pg_numrows($result)>0) + $row=pg_fetch_object ($result, 0); + else + $row->stunden=0; + echo ""; + + $sql_query="SELECT count(*) AS stunden FROM stundenplan WHERE studiengang_id='$stgid' AND semester='$semester' AND verband='A' AND gruppe='2' AND lehrfach_id='$lehrfachid'".$datum." GROUP BY lehrfach_id"; + $result=pg_exec($conn, $sql_query); + if (pg_numrows($result)>0) + $row=pg_fetch_object ($result, 0); + else + $row->stunden=0; + echo ""; + + $sql_query="SELECT count(*) AS stunden FROM stundenplan WHERE studiengang_id='$stgid' AND semester='$semester' AND verband='B' AND gruppe='0' AND lehrfach_id='$lehrfachid'".$datum." GROUP BY lehrfach_id"; + $result=pg_exec($conn, $sql_query); + if (pg_numrows($result)>0) + $row=pg_fetch_object ($result, 0); + else + $row->stunden=0; + echo ""; + + $sql_query="SELECT count(*) AS stunden FROM stundenplan WHERE studiengang_id='$stgid' AND semester='$semester' AND verband='B' AND gruppe='1' AND lehrfach_id='$lehrfachid'".$datum." GROUP BY lehrfach_id"; + $result=pg_exec($conn, $sql_query); + if (pg_numrows($result)>0) + $row=pg_fetch_object ($result, 0); + else + $row->stunden=0; + echo ""; + + $sql_query="SELECT count(*) AS stunden FROM stundenplan WHERE studiengang_id='$stgid' AND semester='$semester' AND verband='B' AND gruppe='2' AND lehrfach_id='$lehrfachid'".$datum." GROUP BY lehrfach_id"; + $result=pg_exec($conn, $sql_query); + if (pg_numrows($result)>0) + $row=pg_fetch_object ($result, 0); + else + $row->stunden=0; + echo ""; + + $sql_query="SELECT count(*) AS stunden FROM stundenplan WHERE studiengang_id='$stgid' AND semester='$semester' AND verband='C' AND gruppe='0' AND lehrfach_id='$lehrfachid'".$datum." GROUP BY lehrfach_id"; + $result=pg_exec($conn, $sql_query); + if (pg_numrows($result)>0) + $row=pg_fetch_object ($result, 0); + else + $row->stunden=0; + echo ""; + + $sql_query="SELECT count(*) AS stunden FROM stundenplan WHERE studiengang_id='$stgid' AND semester='$semester' AND verband='C' AND gruppe='1' AND lehrfach_id='$lehrfachid'".$datum." GROUP BY lehrfach_id"; + $result=pg_exec($conn, $sql_query); + if (pg_numrows($result)>0) + $row=pg_fetch_object ($result, 0); + else + $row->stunden=0; + echo ""; + + $sql_query="SELECT count(*) AS stunden FROM stundenplan WHERE studiengang_id='$stgid' AND semester='$semester' AND verband='C' AND gruppe='2' AND lehrfach_id='$lehrfachid'".$datum." GROUP BY lehrfach_id"; + $result=pg_exec($conn, $sql_query); + if (pg_numrows($result)>0) + $row=pg_fetch_object ($result, 0); + else + $row->stunden=0; + echo ""; + + echo "\n"; + $foo++; + } + +} +?> +
    LehrfachGesamt
    $row_lfbz->kurzbz$row->stunden$row->stunden$row->stunden$row->stunden$row->stunden$row->stunden$row->stunden$row->stunden$row->stunden$row->stunden$row->stunden
    + + \ No newline at end of file diff --git a/vilesci/stundenplan/lv_verteilung.php b/vilesci/stundenplan/lv_verteilung.php new file mode 100644 index 000000000..ecf95f5c9 --- /dev/null +++ b/vilesci/stundenplan/lv_verteilung.php @@ -0,0 +1,61 @@ +='$datum_beginn' AND datum<='$datum_ende'"; + $sql_query.=" GROUP BY unr, semester, lehrfach_id, lehrfachkurzbz, lektor_id, lektorkurzbz"; + $sql_query.=" ORDER BY semester,unr,lektor_id"; + //echo $sql_query."
    "; + $result=pg_exec($conn, $sql_query); + $num_rows=pg_numrows($result); + // Daten in Array übernehmen + for ($i=0;$i<$num_rows;$i++) + { + $row=pg_fetch_object ($result, $i); + $unterricht[$i]->lektor_kbz=$row->lektorkurzbz; + $unterricht[$i]->lektor_id=$row->lektor_id; + $unterricht[$i]->lehrfach_kbz=$row->lehrfachkurzbz; + $unterricht[$i]->lehrfach_id=$row->lehrfach_id; + $unterricht[$i]->unr=$row->unr; + $unterricht[$i]->sem=$row->semester; + $unterricht[$i]->stunden=$row->stunden; + } +?> + + +<?PHP echo $stg_bez; ?> - Lehrfachverteilung + + + +

    - Überblick des Stundenplans

    +

    Von bis

    +
    + + +"; + echo ''; + echo ''; + echo ''; + } +?> +
    SemesterUNrLehrfachLektor(en) [Stunden]
    '.$unterricht[$i]->sem.''.$unterricht[$i]->unr.''.$unterricht[$i]->lehrfach_kbz.''.$unterricht[$i]->lektor_kbz.' ['.$unterricht[$i]->stunden.']'; + while ($unterricht[$i]->unr==$unterricht[$i+1]->unr) + echo ', '.$unterricht[++$i]->lektor_kbz.' ['.$unterricht[$i]->stunden.']'; + echo '
    + + \ No newline at end of file diff --git a/vilesci/stundenplan/lv_verteilung/lv_edit.php b/vilesci/stundenplan/lv_verteilung/lv_edit.php new file mode 100644 index 000000000..6cbce1896 --- /dev/null +++ b/vilesci/stundenplan/lv_verteilung/lv_edit.php @@ -0,0 +1,340 @@ + + + + + + + +LV-Verteilung + +lehrveranstaltung_id = $lv_id; + $lv->lvnr = $lvnr; + $lv->lehrform = $lehrform; + $lv->einheit_kurzbz = $einheit_kurzbz; + $lv->lektor = $lektor1; + $lv->lehrfach_nr = $lehrfach; + $lv->studiengang_kz=$studiengang; + $lv->fachbereich_id = $fachbereich; + $lv->semester = $semester; + $lv->verband= $verband; + $lv->gruppe = $gruppe; + $lv->raumtyp = $raumtyp; + $lv->raumtypalternativ = $raumtypalternativ; + $lv->semesterstunden = $semesterstunden; + $lv->stundenblockung = $stundenblockung; + $lv->wochenrythmus = $wochenrythmus; + $lv->start_kw = $startkw; + $lv->anmerkung = $anmerkung; + $lv->studiensemester_kurzbz = $studiensemester; + $lv->unr = $unr; + $lv->fas_id = $fasid; + $lv->lehre= $lehre; + $lv->new = $new; + if($status==1) + { + + if($lv->save()) + echo ""; + else + { + echo ""; + echo ""; + if(isset($new) && $new) + echo "

    LV Verteilung - NEW


    "; + else + echo "

    LV Verteilung - EDIT


    "; + echo "\n"; + echo "

    $lv->errormsg


    "; + } + + } + else if($status==3) + { + echo ""; + echo ""; + if(isset($new) && $new) + echo "

    LV Verteilung - NEW


    "; + else + echo "

    LV Verteilung - EDIT


    "; + echo "\n"; + if($lv->save()) + echo "

    Daten wurden gespeichert

    "; + else + echo "

    $lv->errormsg


    "; + } + else + { + echo ""; + echo ""; + if(isset($new) && $new) + echo "

    LV Verteilung - NEW


    "; + else + echo "

    LV Verteilung - EDIT


    "; + echo "\n"; + + } + } + else + { + echo ""; + echo ""; + if(isset($new) && $new) + echo "

    LV Verteilung - NEW


    "; + else + echo "

    LV Verteilung - EDIT


    "; + echo "\n"; + + if(!isset($new)) + { + if(isset($lvid)) + $lv->load($lvid); + else + die("Fehler bei der Parameterübergabe"); + } + else + { + if($new) + { + $lv->new=true; + + $lv->studiengang_kz = ($stg!=-1?$stg:'227'); + $lv->semester=$sem; + $lv->lvnr=0; + $lv->semesterstunden = 0; + $lv->stundenblockung = 0; + $lv->wochenrythmus = 1; + $lv->start_kw = 1; + $lv->unr = 0; + $lv->lehre = "on"; + + $sql_query="select studiensemester_kurzbz from tbl_studiensemester where startstudiensemester_kurzbz=$row->studiensemester_kurzbz; + else + $lv->studiensemester_kurzbz=-1; + + } + } + } + //Formular anzeigen + echo "<- Zurück zur Übersicht
    "; + echo ''; + echo "\n"; + echo ""; + echo "\n"; + //echo ""; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + + echo "\n"; + echo ""; + + // echo ""; + echo "\n"; + echo ""; + + echo "\n"; + echo ""; + + echo "\n"; + echo ""; + + + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo "\n"; + //echo ""; + echo "\n"; + echo ""; + echo "\n"; + if($lv->lehre=='t') + $lv->lehre='on'; + echo ""; + echo ""; + echo "\n"; + echo ""; + echo "
    Lehrveranstaltungs ID
    Lvnr
    Lektor
    Studiengang
    Semester
    Verband
    Gruppe
    Einheit kurzbz
    einheit_kurzbz
    Lehrfach
    Lehrform
    Fachbereich
    Raumtyp
    Raumtyp Alternativ
    Semesterstunden
    Stundenblockung
    Wochenrythmus
    StartKW
    Anmerkung
    Studiensemester
    FasId
    UNr
    Lehrelehre=='on'?'checked':'').">
     
     "; + if(isset($new) && $new) + echo "
    "; + echo ""; +?> + \ No newline at end of file diff --git a/vilesci/stundenplan/lv_verteilung/lv_verteilung.php b/vilesci/stundenplan/lv_verteilung/lv_verteilung.php new file mode 100644 index 000000000..95ceb0773 --- /dev/null +++ b/vilesci/stundenplan/lv_verteilung/lv_verteilung.php @@ -0,0 +1,249 @@ + + + + + + + +LV-Verteilung + + + +

    LV Verteilung

    +studiensemester_kurzbz; + else + $stsem=-1; + } + if(!isset($stg)) + { + $stg=227; + } + if(!isset($lektor)) + { + $lektor=-1; + } + if(!isset($sem)) + { + $sem=-1; + } + + if(isset($saved)) + { + echo "

    Daten wurden gespeichert


    "; + } + + if(isset($lfnr) && isset($lvz)) //ändern des LVZ + { + $sql_query = "Update tbl_lehrfach SET lehrevz='$lvz' WHERE lehrfach_nr='$lfnr' "; + pg_exec($conn,$sql_query); + echo "

    Update durchgeführt


    "; + } + + if(isset($lfnr) && isset($_POST['stb']) && isset($_GET['lvnr'])) //ändern der Stundenblockung + { + $sql_query = "Update tbl_lehrveranstaltung SET stundenblockung='". $_POST['stb']."' WHERE lvnr='". $_GET['lvnr']."'"; + if(pg_exec($conn,$sql_query)) + echo "

    Update durchgeführt


    "; + else + echo "

    Update Fehlgeschlagen, Bitte erneut versuchen


    "; + } + + if(isset($lvid) && isset($lehre)) //ändern von Lehre + { + $sql_query = "Update tbl_lehrveranstaltung SET lehre=not lehre WHERE lehrveranstaltung_id ='$lvid'"; + if(pg_exec($conn,$sql_query)) + echo "

    Update durchgeführt


    "; + else + echo "

    Fehler beim Update


    "; + } + + if(isset($del) && isset($lvid)) + { + + $sql_query = "DELETE FROM tbl_lehrveranstaltung WHERE lehrveranstaltung_id='$lvid'"; + pg_exec($conn,$sql_query); + echo "

    DELETE durchgeführt


    "; + + } + $sql_query = "SELECT studiensemester_kurzbz FROM public.tbl_studiensemester order by start DESC"; + $result = pg_exec($conn, $sql_query); + $numrows = pg_num_rows($result); + $aktrows=0; + echo '
    '; + //Ausgeben der Studiensemester zb WS2005, SS2006 etc + echo "Alle -"; + while($row=pg_fetch_object($result)) + { + $aktrows++; + if($aktrows==$numrows) + echo " $row->studiensemester_kurzbz "; + else + echo " $row->studiensemester_kurzbz -"; + } + echo ""; + echo "
    "; + echo "
    "; + $sql_query = "SELECT studiengang_kz, kurzbz FROM public.tbl_studiengang ORDER BY kurzbz"; + $result = pg_exec($conn,$sql_query); + echo "\n"; + echo ''; + echo ""; + echo ""; + echo "\n"; + + $sql_query = "SELECT a.uid, nachname, vornamen FROM public.tbl_mitarbeiter a, public.tbl_person b where a.uid=b.uid AND a.lektor='true' ORDER BY b.nachname"; + $result = pg_exec($conn,$sql_query); + echo "\n"; + echo ""; + echo "
    Studiengang:Lektor:
    "; + echo "
    "; + echo "
    "; + echo "\n"; + + if($stg!=-1) //Wenn ein Studiengang ausgewählt wurde + { + //Anzeigen der Semester + echo "Semester:Alle "; + + $sql_query = "SELECT max_semester FROM public.tbl_studiengang WHERE studiengang_kz='$stg' LIMIT 1"; + //echo $sql_query; + $result = pg_exec($conn,$sql_query); + if($row=pg_fetch_object($result)) + { + for($i=1;$i<($row->max_semester+1);$i++) + { + echo "- $i "; + } + } + + } + echo " 

    "; + + echo "Aktuelle Auswahl:"; + if($stsem!=-1) + echo " Studiensemester: $stsem"; + if($stg!=-1) + { + $sql_query = "SELECT kurzbz FROM tbl_studiengang where studiengang_kz='$stg'"; + $result=pg_exec($conn,$sql_query); + $row = pg_fetch_object($result); + echo " Studiengang: $row->kurzbz"; + } + if($sem!=-1) + echo " Semester: $sem"; + if($lektor!=-1) + echo " Lektor: $lektor"; + + echo "
    "; + //Tabelle aufbauen + + //Daten holen + $lvobj = new lv_verteilung($conn); + + + if($lvobj->getTab($stsem,$sem,$stg,$lektor,$order)) + { + echo "\n"; + echo ''; + echo "\n"; + echo ' '; + //Kopfzeile der Tabelle + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + + + //Tabellenelemente rausschreiben + for($i=0;$i<$lvobj->anz;$i++) + { + $fe = $lvobj->retwert[$i]; + echo "\n"; + echo ' '; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + //echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + } + else + { + echo "
    Keine Daten mit diesen Kriterien Vorhanden"; + } + +?> + + \ No newline at end of file diff --git a/vilesci/stundenplan/modulplan_insert.php b/vilesci/stundenplan/modulplan_insert.php new file mode 100644 index 000000000..e49729cca --- /dev/null +++ b/vilesci/stundenplan/modulplan_insert.php @@ -0,0 +1,234 @@ + + + + +Modulplan Eingabe + + + +

    Eingabe in Modulplan

    +
    + +

    Einheit + + Lehrfach + + Ort + +

    + Tag + + Monat + + Jahr + + 1. Stunde + +

    +

    Stunden/Block + + Stunden/Semester + + Rythmus + + wöchig +

    +

    + + +

    +
    + +"; + echo "Kontrolle auf Doppelbelegungen! ... "; + + // checken auf Ort + $date[mday]=$tag; $date[mon]=$monat; $date[year]=$jahr; + $datum=$jahr."-".$monat."-".$tag; + for ($i=0; ($i<$stdsemester)&&!$error; $i++) + { + $std=$stunde+($i % $stdblock); + if ( ($std==$stunde) && (($i>0)||($stdblock==1)) ) + { + $time=mktime(0, 0, 0, $date[mon], $date[mday], $date[year]); + $date=getdate($time+(604800*$rythmus)); + $datum=$date[year]."-".$date[mon]."-".$date[mday]; + } + $sql_query="SELECT id FROM stundenplan WHERE datum='$datum' AND stunde_id='$std' AND ort_id='$ortid'"; + $result=pg_exec($conn, $sql_query); + if($result && (pg_numrows($result)>0)) + { + echo "error!
    Doppelbelegung gefunden auf Ort=$ortid Datum=$datum Stunde=$stunde!
    "; + $error=true; + } + } + // checken auf Lehrfach + $date[mday]=$tag; $date[mon]=$monat; $date[year]=$jahr; + $datum=$jahr."-".$monat."-".$tag; + for ($i=0; ($i<$stdsemester)&&!$error; $i++) + { + $std=$stunde+($i % $stdblock); + if ( ($std==$stunde) && (($i>0)||($stdblock==1)) ) + { + $time=mktime(0, 0, 0, $date[mon], $date[mday], $date[year]); + $date=getdate($time+(604800*$rythmus)); + $datum=$date[year]."-".$date[mon]."-".$date[mday]; + } + $sql_query="SELECT id FROM stundenplan WHERE datum='$datum' AND stunde_id='$std' AND lehrfach_id='$lehrfachid'"; + $result=pg_exec($conn, $sql_query); + if($result && (pg_numrows($result)>0)) + { + echo "error!
    Doppelbelegung gefunden auf Lehrfach=$lehrfachid Datum=$datum Stunde=$stunde!
    "; + $error=true; + } + } + + // checken auf Ort im Einheitenplan + $date[mday]=$tag; $date[mon]=$monat; $date[year]=$jahr; + $datum=$jahr."-".$monat."-".$tag; + for ($i=0; ($i<$stdsemester)&&!$error; $i++) + { + $std=$stunde+($i % $stdblock); + if ( ($std==$stunde) && (($i>0)||($stdblock==1)) ) + { + $time=mktime(0, 0, 0, $date[mon], $date[mday], $date[year]); + $date=getdate($time+(604800*$rythmus)); + $datum=$date[year]."-".$date[mon]."-".$date[mday]; + } + $sql_query="SELECT id FROM einheiten WHERE datum='$datum' AND stunde_id='$std' AND ort_id='$ortid'"; + $result=pg_exec($conn, $sql_query); + if($result && (pg_numrows($result)>0)) + { + echo "error!
    Doppelbelegung gefunden im Einheitenplan auf Ort=$ortid Datum=$datum Stunde=$stunde!
    "; + $error=true; + } + } + // checken auf Lehrfach im Einheitenplan + $date[mday]=$tag; $date[mon]=$monat; $date[year]=$jahr; + $datum=$jahr."-".$monat."-".$tag; + for ($i=0; ($i<$stdsemester)&&!$error; $i++) + { + $std=$stunde+($i % $stdblock); + if ( ($std==$stunde) && (($i>0)||($stdblock==1)) ) + { + $time=mktime(0, 0, 0, $date[mon], $date[mday], $date[year]); + $date=getdate($time+(604800*$rythmus)); + $datum=$date[year]."-".$date[mon]."-".$date[mday]; + } + $sql_query="SELECT id FROM einheitenplan WHERE datum='$datum' AND stunde_id='$std' AND lehrfach_id='$lehrfachid'"; + $result=pg_exec($conn, $sql_query); + if($result && (pg_numrows($result)>0)) + { + echo "error!
    Doppelbelegung gefunden im Einheitenplan auf Lehrfach=$lehrfachid Datum=$datum Stunde=$stunde!
    "; + $error=true; + } + } + + //Einfügen in die Datenbank + if (!$error) + { + echo "OK!
    "; + $date[mday]=$tag; $date[mon]=$monat; $date[year]=$jahr; + $datum=$jahr."-".$monat."-".$tag; + for ($i=0; ($i<$stdsemester)&&!$error; $i++) + { + $std=$stunde+($i % $stdblock); + if ( ($std==$stunde) && (($i>0)||($stdblock==1)) ) + { + $time=mktime(0, 0, 0, $date[mon], $date[mday], $date[year]); + $date=getdate($time+(604800*$rythmus)); + $datum=$date[year]."-".$date[mon]."-".$date[mday]; + } + $sql_query="INSERT INTO einheitenplan (einheit_id, lehrfach_id, ort_id, datum, stunde_id) VALUES ('$einheitid', '$lehrfachid', '$ortid', '$datum', '$std')"; + //echo $sql_query; + $result=pg_exec($conn, $sql_query); + if(!$result) + { + echo pg_errormessage()."
    "; + $error=true; + } + else + echo "Einheit_ID: $stgid - Lehrfach_ID: $lehrfachid - Ort_ID: $ortid - Datum: $datum - Stunde: $std -- Eingefuegt!
    "; + + } + if (!$error) + echo "Einfügen erfolgreich abgeschlossen!
    "; + else + echo "Es ist ein Fehler aufgetreten!
    "; + } +} +?> + + \ No newline at end of file diff --git a/vilesci/stundenplan/ort.php b/vilesci/stundenplan/ort.php new file mode 100644 index 000000000..7dc3290d1 --- /dev/null +++ b/vilesci/stundenplan/ort.php @@ -0,0 +1,10 @@ + + +Untitled Document + + + + + + + diff --git a/vilesci/stundenplan/ort_edit_save.php b/vilesci/stundenplan/ort_edit_save.php new file mode 100644 index 000000000..c73a635b7 --- /dev/null +++ b/vilesci/stundenplan/ort_edit_save.php @@ -0,0 +1,39 @@ +; + //echo $sql_query; + } + +?> + + + +Ort ändern + + + + + +

    Ort ändern

    + + + ID: + + + + + + + diff --git a/vilesci/stundenplan/stdplan_clean_check.php b/vilesci/stundenplan/stdplan_clean_check.php new file mode 100644 index 000000000..28522345a --- /dev/null +++ b/vilesci/stundenplan/stdplan_clean_check.php @@ -0,0 +1,74 @@ + + + Stundenplan säubern + + +

    Stundenplan säubern

    +

    Folgende Einträge kommen doppelt vor:

    +

    +"; + if (!$equl) + { + $equl=true; + echo $stdplan_table[$i][1],"
    "; + $anz++; + } + } + else + $equl=false; +} +echo "$anz doppelte Einträge wurden gefunden und gelöscht.
    $num_rows Einträge gesamt."; +/*$foo = 0; +for ($j=0; $j<$num_rows; $j++) +{ + $bestell_id=mysql_result($result, $j, "ID"); + $bestell_nr=mysql_result($result, $j, "BestellNr"); + $bgcolor = $cfgBgcolorOne; + $foo % 2 ? 0: $bgcolor = $cfgBgcolorTwo; + echo "

    "; + echo ""; + echo ""; + echo ""; + $body.="$bestell_nr: \t http://data.technikum-wien.at/bestellungen/bestell_det_ueb.php3?bestellid=$bestell_id\n"; + echo "\n"; + $foo++; +} */ +?> +

    +
    +Erstellt am 28. Mai 2001 von Christian Humer
    +Letzte Änderung: 28. Mai 2001 von Christian Humer + + diff --git a/vilesci/stundenplan/stdplan_clean_go.php b/vilesci/stundenplan/stdplan_clean_go.php new file mode 100644 index 000000000..a0293ee90 --- /dev/null +++ b/vilesci/stundenplan/stdplan_clean_go.php @@ -0,0 +1,54 @@ + + + + Stundenplan säubern + + +

    Stundenplan säubern

    +

    Folgende Einträge kommen doppelt vor:

    +

    +helpstr=".$help_str." - table0=".$stdplan_table[$i][0]." - table1=".$stdplan_table[$i][1]; +} + +//Sortieren +for ($i=1; $i<$num_rows; $i++) + { + $erg=strcmp($stdplan_table[$i-1][1],$stdplan_table[$i][1]); + if ($erg==0) + { + echo $stdplan_table[$i][1]."
    "; + $mysql_query="DELETE FROM stundenplan WHERE id=".$stdplan_table[$i][0]; + $result=mysql_query($mysql_query); + $anz++; + } + } + +echo "$anz doppelte Einträge wurden gefunden und gelöscht.
    $num_rows Einträge gesamt."; + +?> +

    +
    +Erstellt am 28. Mai 2001 von Christian Humer
    +Letzte Änderung: 18. Juni 2001 von Christian Humer + + diff --git a/vilesci/stundenplan/stdplan_delete.php b/vilesci/stundenplan/stdplan_delete.php new file mode 100644 index 000000000..9b62b385f --- /dev/null +++ b/vilesci/stundenplan/stdplan_delete.php @@ -0,0 +1,231 @@ +0 ORDER BY kurzbz"; + $result_stg=pg_exec($conn, $sql_query); + if(!$result_stg) + error ("studiengang not found!"); + if ($mode=='del') + { + $sql_query="DELETE FROM tbl_stundenplan WHERE studiengang_kz=$stg_kz AND datum>='$jahrv-$monatv-$tagv' AND datum<='$jahrb-$monatb-$tagb'"; + //echo $sql_query.'
    '; + $result=pg_query($conn, $sql_query); + $anz=pg_numrows($result); + echo $anz.' Records deleted!
    '; + } + if (!isset($stg_kz)) + $stg_kz=0; + if (!isset($tagv)) + $tag=1; + if (!isset($monatv)) + $monat=1; + if (!isset($jahrv)) + $jahr=2002; + if (!isset($tagb)) + $tag=1; + if (!isset($monatb)) + $monat=1; + if (!isset($jahrb)) + $jahr=2002; + + //echo '
    Beginn:'.mktime(0,0,0,2,23,2004).'
    '; + //echo '
    Ende:'.mktime(0,0,0,6,17,2004).'
    '; +?> + + + +Delete Stundenplan + + + +

    Delete from Stundenplan

    +
    + +

    Studiengang + +

    +

    Von (inkl): Tag + + Monat + + Jahr + +

    +

    Bis (inkl): Tag + + Monat + + Jahr + +

    +

    + + +

    +
    + +"; + echo "Kontrolle auf Doppelbelegungen! ... "; + + // checken auf Ort + $date[mday]=$tag; $date[mon]=$monat; $date[year]=$jahr; + $datum=$jahr."-".$monat."-".$tag; + for ($i=0; ($i<$stdsemester)&&!$error; $i++) + { + $std=$stunde+($i % $stdblock); + if ( ($std==$stunde) && (($i>0)||($stdblock==1)) ) + { + $time=mktime(0, 0, 0, $date[mon], $date[mday], $date[year]); + $date=getdate($time+(604800*$rythmus)); + $datum=$date[year]."-".$date[mon]."-".$date[mday]; + } + $sql_query="SELECT id FROM stundenplan WHERE datum='$datum' AND stunde_id='$std' AND ort_id='$ortid'"; + $result=pg_exec($conn, $sql_query); + if($result && (pg_numrows($result)>0)) + { + echo "error!
    Doppelbelegung gefunden auf Ort=$ortid Datum=$datum Stunde=$stunde!
    "; + $error=true; + } + } + // checken auf Lehrfach + $date[mday]=$tag; $date[mon]=$monat; $date[year]=$jahr; + $datum=$jahr."-".$monat."-".$tag; + for ($i=0; ($i<$stdsemester)&&!$error; $i++) + { + $std=$stunde+($i % $stdblock); + if ( ($std==$stunde) && (($i>0)||($stdblock==1)) ) + { + $time=mktime(0, 0, 0, $date[mon], $date[mday], $date[year]); + $date=getdate($time+(604800*$rythmus)); + $datum=$date[year]."-".$date[mon]."-".$date[mday]; + } + $sql_query="SELECT id FROM stundenplan WHERE datum='$datum' AND stunde_id='$std' AND lehrfach_id='$lehrfachid'"; + $result=pg_exec($conn, $sql_query); + if($result && (pg_numrows($result)>0)) + { + echo "error!
    Doppelbelegung gefunden auf Lehrfach=$lehrfachid Datum=$datum Stunde=$stunde!
    "; + $error=true; + } + } + // checken auf Verband + $date[mday]=$tag; $date[mon]=$monat; $date[year]=$jahr; + $datum=$jahr."-".$monat."-".$tag; + for ($i=0; ($i<$stdsemester)&&!$error; $i++) + { + $std=$stunde+($i % $stdblock); + if ( ($std==$stunde) && (($i>0)||($stdblock==1)) ) + { + $time=mktime(0, 0, 0, $date[mon], $date[mday], $date[year]); + $date=getdate($time+(604800*$rythmus)); + $datum=$date[year]."-".$date[mon]."-".$date[mday]; + } + $sql_query="SELECT semester, verband, gruppe, studiengang_kz FROM tbl_stundenplan WHERE datum='$datum' AND stunde_id='$std' AND studiengang_kz='$stg_kz' AND semester='$semester' AND (verband='$verband' OR verband=NULL) AND (gruppe='$gruppe' OR gruppe=NULL)"; + $result=pg_exec($conn, $sql_query); + if($result && (pg_numrows($result)>0)) + { + $row=pg_fetch_object($result,0); + echo "error!
    Doppelbelegung gefunden auf Datum=$datum - Stunde=$stunde - StudiengangID=$row->studiengang_id - Semester=$row->semester Verband=$row->verband Gruppe=$row->gruppe!
    "; + $error=true; + } + } + + // checken auf Ort im Einheitenplan + $date[mday]=$tag; $date[mon]=$monat; $date[year]=$jahr; + $datum=$jahr."-".$monat."-".$tag; + for ($i=0; ($i<$stdsemester)&&!$error; $i++) + { + $std=$stunde+($i % $stdblock); + if ( ($std==$stunde) && (($i>0)||($stdblock==1)) ) + { + $time=mktime(0, 0, 0, $date[mon], $date[mday], $date[year]); + $date=getdate($time+(604800*$rythmus)); + $datum=$date[year]."-".$date[mon]."-".$date[mday]; + } + $sql_query="SELECT id FROM einheitenplan WHERE datum='$datum' AND stunde_id='$std' AND ort_id='$ortid'"; + $result=pg_exec($conn, $sql_query); + if($result && (pg_numrows($result)>0)) + { + echo "error!
    Doppelbelegung gefunden im Einheitenplan auf Ort=$ortid Datum=$datum Stunde=$stunde!
    "; + $error=true; + } + } + // checken auf Lehrfach im Einheitenplan + $date[mday]=$tag; $date[mon]=$monat; $date[year]=$jahr; + $datum=$jahr."-".$monat."-".$tag; + for ($i=0; ($i<$stdsemester)&&!$error; $i++) + { + $std=$stunde+($i % $stdblock); + if ( ($std==$stunde) && (($i>0)||($stdblock==1)) ) + { + $time=mktime(0, 0, 0, $date[mon], $date[mday], $date[year]); + $date=getdate($time+(604800*$rythmus)); + $datum=$date[year]."-".$date[mon]."-".$date[mday]; + } + $sql_query="SELECT id FROM einheitenplan WHERE datum='$datum' AND stunde_id='$std' AND lehrfach_id='$lehrfachid'"; + $result=pg_exec($conn, $sql_query); + if($result && (pg_numrows($result)>0)) + { + echo "error!
    Doppelbelegung gefunden im Einheitenplan auf Lehrfach=$lehrfachid Datum=$datum Stunde=$stunde!
    "; + $error=true; + } + } + + //Einfügen in die Datenbank + if (!$error) + { + echo "OK!
    "; + $date[mday]=$tag; $date[mon]=$monat; $date[year]=$jahr; + $datum=$jahr."-".$monat."-".$tag; + for ($i=0; ($i<$stdsemester)&&!$error; $i++) + { + $std=$stunde+($i % $stdblock); + if ( ($std==$stunde) && (($i>0)||($stdblock==1)) ) + { + $time=mktime(0, 0, 0, $date[mon], $date[mday], $date[year]); + $date=getdate($time+(604800*$rythmus)); + $datum=$date[year]."-".$date[mon]."-".$date[mday]; + } + if (($verband=='0') && ($gruppe==0)) + $sql_query="INSERT INTO stundenplan (studiengang_id, semester, verband, gruppe, lehrfach_id, ort_id, datum, stunde_id) VALUES ('$stgid', '$semester', NULL, NULL, '$lehrfachid', '$ortid', '$datum', '$std')"; + elseif ($gruppe=0) + $sql_query="INSERT INTO stundenplan (studiengang_id, semester, verband, gruppe, lehrfach_id, ort_id, datum, stunde_id) VALUES ('$stgid', '$semester', '$verband', NULL, '$lehrfachid', '$ortid', '$datum', '$std')"; + else + $sql_query="INSERT INTO stundenplan (studiengang_id, semester, verband, gruppe, lehrfach_id, ort_id, datum, stunde_id) VALUES ('$stgid', '$semester', '$verband', '$gruppe', '$lehrfachid', '$ortid', '$datum', '$std')"; + //echo $sql_query; + $result=pg_exec($conn, $sql_query); + if(!$result) + { + echo pg_errormessage()."
    "; + $error=true; + } + else + echo "Studiengang_ID: $stgid - Semester: $semester - Verband: $verband - Gruppe: $gruppe - Lehrfach_ID: $lehrfachid - Ort_ID: $ortid - Datum: $datum - Stunde: $std -- Eingefuegt!
    "; + + } + if (!$error) + echo "Einfügen erfolgreich abgeschlossen!
    "; + else + echo "Es ist ein Fehler aufgetreten!
    "; + } +} +?> + + diff --git a/vilesci/stundenplan/stdplan_insert.php b/vilesci/stundenplan/stdplan_insert.php new file mode 100644 index 000000000..55e3a6f3c --- /dev/null +++ b/vilesci/stundenplan/stdplan_insert.php @@ -0,0 +1,347 @@ +0 ORDER BY kurzbz"; + //echo $sql_query."
    "; + $result_stg=pg_exec($conn, $sql_query); + if(!$result_stg) + error ("studiengang not found!"); + $sql_query="SELECT lehrfach_nr, kurzbz,bezeichnung FROM tbl_lehrfach where aktiv=true or aktiv is null ORDER BY kurzbz"; + $result_lehrf=pg_exec($conn, $sql_query); + if(!$result_lehrf) + error ("lehrfach not found!"); + $sql_query="SELECT tbl_person.uid, kurzbz FROM tbl_person join tbl_mitarbeiter using(uid) where lektor=true ORDER BY kurzbz"; + $result_lektor=pg_exec($conn, $sql_query); + if(!$result_lektor) + error ("lektor not found!"); + $sql_query="SELECT ort_kurzbz FROM tbl_ort ORDER BY ort_kurzbz"; + $result_ort=pg_exec($conn, $sql_query); + $sql_query="SELECT einheit_kurzbz,bezeichnung FROM tbl_einheit ORDER BY einheit_kurzbz"; + $result_einheit=pg_exec($conn, $sql_query); + if(!$result_einheit) error("Einheit not found!"); + if(!$result_ort) + error ("ort not found!"); + + $sql_query="SELECT lehrform_kurzbz,bezeichnung FROM tbl_lehrform where verplanen=true ORDER BY lehrform_kurzbz"; + $result_lehrform=pg_exec($conn, $sql_query); + if(!$result_lehrform) error("Lehrform not found!"); + + if (!isset($stgid)) + $stgid=1; + if (!isset($lektorid)) + $lektorid=1; + if (!isset($semester)) + $semester=0; + if (!isset($verband)) + $verband='0'; + if (!isset($gruppe)) + $gruppe=0; + if (!isset($tag)) + $tag=1; + if (!isset($monat)) + $monat=1; + if (!isset($jahr)) + $jahr=2002; + if (!isset($stdbegin)) + $stdbegin=1; + if (!isset($stdblock)) + $stdblock=1; + if (!isset($stdsemester)) + $stdsemester=1; + if (!isset($lehrformid)) + $lehrformid=''; +?> + + + +Stundenplan Check + + + + +

    Eingabe in Stundenplan

    +
    + +

    Studiengang +

    +

    Semester + + Verband + + Gruppe + +

    +

    + [ Einheit + ] + + + Lehrfach + + +

    + Unterrichtsnummer + +

    + + + Lektor + + + + Lehrform + + +

    +

    + Ort + + + + Tag + + Monat + + Jahr + + 1. Stunde + +

    +

    Stunden/Block + + Stunden/Semester + + Rythmus + + wöchig +

    +

    + + +

    +
    + +"; + echo "Kontrolle auf Doppelbelegungen! ... "; + + // checken auf Ort + $date[mday]=$_POST['tag']; $date[mon]=$_POST['monat']; $date[year]=$_POST['jahr']; + $datum=$tag.".".$monat.".".$jahr; + for ($i=0; ($i<$stdsemester)&&!$error; $i++) + { + $std=$stunde+($i % $stdblock); + if ( ($std==$stunde) && (($i>0)||($stdblock==1)) ) + { + $time=mktime(0, 0, 0, $date[mon], $date[mday], $date[year]); + $date=getdate($time+(604800*$_POST['rythmus'])); + $datum=$date[mday].".".$date[mon].".".$date[year]; + } + $sql_query="set datestyle to german;SELECT stundenplandev_id FROM tbl_stundenplandev WHERE datum='$datum' AND stunde='$std' AND ort_kurzbz='".$_POST['ortid']."'"; + if ($_POST['unr']=='') + $sql_query.=" AND unr IS NOT NULL"; + else + $sql_query.=" AND unr!=".$_POST['unr']; + echo $sql_query; + $result=pg_exec($conn, $sql_query); + if($result && (pg_numrows($result)>0)) + { + echo "error!
    Doppelbelegung gefunden auf Ort=".$_POST['ortid']." Datum=$datum Stunde=$stunde!
    "; + $error=true; + } + } + + // checken auf Lektor im Stundenplan + $date[mday]=$_POST['tag']; $date[mon]=$_POST['monat']; $date[year]=$_POST['jahr']; + $datum=$tag.".".$monat.".".$jahr; + for ($i=0; ($i<$stdsemester)&&!$error; $i++) + { + $std=$stunde+($i % $stdblock); + if ( ($std==$stunde) && (($i>0)||($stdblock==1)) ) + { + $time=mktime(0, 0, 0, $date[mon], $date[mday], $date[year]); + $date=getdate($time+(604800*$_POST['rythmus'])); + $datum=$date[mday].".".$date[mon].".".$date[year]; + } + $sql_query="SELECT stundenplandev_id FROM tbl_stundenplandev WHERE datum='$datum' AND stunde='$std' AND uid='".$_POST['$lektorid']."'"; + $result=pg_exec($conn, $sql_query); + if($result && (pg_numrows($result)>0)) + { + echo "error!
    Doppelbelegung gefunden auf Lektor=".$_POST['$lektorid']." Datum=$datum Stunde=$stunde!
    "; + $error=true; + } + } + + // checken auf Verband + $date[mday]=$_POST['tag']; $date[mon]=$_POST['monat']; $date[year]=$_POST['jahr']; + $datum=$tag.".".$monat.".".$jahr; + for ($i=0; ($i<$stdsemester)&&!$error; $i++) + { + $std=$stunde+($i % $stdblock); + if ( ($std==$stunde) && (($i>0)||($stdblock==1)) ) + { + $time=mktime(0, 0, 0, $date[mon], $date[mday], $date[year]); + $date=getdate($time+(604800*$_POST['rythmus'])); + $datum=$date[mday].".".$date[mon].".".$date[year]; + } + $sql_query="SELECT semester, verband, gruppe, tbl_stundenplandev.studiengang_kz,tbl_studiengang.kurzbz FROM tbl_stundenplandev JOIN tbl_studiengang using(studiengang_kz) WHERE datum='$datum' AND stunde='$std' AND studiengang_kz='".$_POST['stgid']."' AND semester='$semester' AND (verband='".$_POST['verband']."' OR verband=NULL) AND (gruppe='".$_POST['gruppe']."' OR gruppe=NULL)"; + $result=pg_exec($conn, $sql_query); + if($result && (pg_numrows($result)>0)) + { + $row=pg_fetch_object($result,0); + echo "error!
    Doppelbelegung gefunden auf Datum=$datum - Stunde=$stunde - Studiengang=$row->kurzbz - Semester=$row->semester Verband=$row->verband Gruppe=$row->gruppe!
    "; + $error=true; + } + } + + //Einfuegen in die Datenbank + if (!$error) + { + echo "OK!
    "; + $date[mday]=$_POST['tag']; $date[mon]=$_POST['monat']; $date[year]=$_POST['jahr']; + $datum=$tag.".".$monat.".".$jahr; + for ($i=0; ($i<$stdsemester)&&!$error; $i++) + { + $std=$stunde+($i % $stdblock); + if ( ($std==$stunde) && (($i>0)||($stdblock==1)) ) + { + $time=mktime(0, 0, 0, $date[mon], $date[mday], $date[year]); + $date=getdate($time+(604800*$_POST['rythmus'])); + $datum=$date[mday].".".$date[mon].".".$date[year]; + } + // todo: unr als string? + $sql_query="INSERT INTO tbl_stundenplandev (studiengang_kz, semester, verband, gruppe, lehrfach_nr, uid, ort_kurzbz, datum, stunde,einheit_kurzbz,unr,updateamum,updatevon, lehrform_kurzbz) ". + "VALUES ('".$_POST['stgid']."', '".$_POST['semester']."', '".$_POST['verband']."', '".$_POST['gruppe']."', '".$_POST['lehrfachid']."', '".$_POST['lektorid']."', '".$_POST['ortid']."', '$datum', $std,".($_POST['einheit_kurzbz']==-1?'NULL':"'".$_POST['einheit_kurzbz']."'").",".($_POST['unr']==-1?'NULL':$_POST['unr']).",now(),'".$_SERVER['PHP_AUTH_USER']."','".$_POST['lehrformid']."')"; + echo $sql_query; + $result=pg_exec($conn, $sql_query); + if(!$result) + { + echo pg_errormessage()."
    "; + $error=true; + } + else + echo "Studiengang_ID: ".$_POST['stgid']." - Semester: ".$_POST['semester']." - Verband: ".$_POST['verband']." - Gruppe: ".$_POST['gruppe']." - Lehrfach_Nr: ".$_POST['lehrfachid']." - Lektor_ID: ".$_POST['lektorid']." - Lehrform: ".$_POST['lehrformid']." - Ort_ID: ".$_POST['ortid']." - Datum: $datum - Stunde: $std -- Eingefuegt!
    "; + + } + if (!$error) + echo "Einfuegen erfolgreich abgeschlossen!
    "; + else + echo "Es ist ein Fehler aufgetreten!
    "; + } +} +?> + + diff --git a/vilesci/stundenplan/stundenplan_info.html b/vilesci/stundenplan/stundenplan_info.html new file mode 100644 index 000000000..b1e132d3e --- /dev/null +++ b/vilesci/stundenplan/stundenplan_info.html @@ -0,0 +1,10 @@ + + +Untitled Document + + + + + + + diff --git a/vilesci/stundenplan/zeitwuensche.php b/vilesci/stundenplan/zeitwuensche.php new file mode 100644 index 000000000..730dcfca3 --- /dev/null +++ b/vilesci/stundenplan/zeitwuensche.php @@ -0,0 +1,108 @@ +tag][$row->stunde][$row->gewicht]=$row->anz; + } + +?> + + + +Profil + + + + + +

    Statistik der Zeitwünsche

    +Anzahl der Lektoren: +
      SVGEinheitLektorRaumtypSSBlockungWRLFKZLehreLVZLehrfachbezeichnung
    editdelete$fe->semester$fe->verband$fe->gruppe$fe->einheit_kurzbz$fe->lektor$fe->raumtyp / $fe->raumtypalternativ$fe->semesterstunden$fe->stundenblockung
    $fe->wochenrythmus$fe->lehrfach_kurzbz
    $fe->lehrfach_bz
    $bestell_id
    $bestell_nr
    Details
    + + Stunde
    Beginn
    Ende'; + for ($i=0;$i<$num_rows_stunde; $i++) + { + $beginn=pg_result($result_stunde,$i,'"beginn"'); + $beginn=substr($beginn,0,5); + $ende=pg_result($result_stunde,$i,'"ende"'); + $ende=substr($ende,0,5); + $stunde=pg_result($result_stunde,$i,'"stunde"'); + echo ""; + } + ?> + + '; + for ($i=0;$i<$num_rows_stunde;$i++) + { + $pos=$wunsch[$j][$i+1][4]+$wunsch[$j][$i+1][5]; + $neg=$wunsch[$j][$i+1][3]+$wunsch[$j][$i+1][2]+$wunsch[$j][$i+1][1]+$wunsch[$j][$i+1][0]; + $bgcolor=$cfgStdBgcolor[round(14/$anz_lektoren*$pos)-4]; + echo ''; + } + echo ''; + } + ?> +
    $stunde
    $beginn
    $ende
    '.$tagbez[$j].''; + echo '+:'.round(100/$anz_lektoren*$pos).'%
    '; + echo '-:'.round(100/$anz_lektoren*$neg).'%'; + echo '
    +Details + + + Stunde
    Beginn
    Ende'; + for ($i=0;$i<$num_rows_stunde; $i++) + { + $beginn=pg_result($result_stunde,$i,'"beginn"'); + $beginn=substr($beginn,0,5); + $ende=pg_result($result_stunde,$i,'"ende"'); + $ende=substr($ende,0,5); + $stunde=pg_result($result_stunde,$i,'"stunde"'); + echo ""; + } + ?> + + '; + for ($i=0;$i<$num_rows_stunde;$i++) + { + echo ''; + } + echo ''; + } + ?> +
    $stunde
    $beginn
    $ende
    '.$tagbez[$j].''; + for ($g=5;$g>=0;$g--) + if (isset($wunsch[$j][$i+1][$g])) + echo ($g-3).':'.round(100/$anz_lektoren*$wunsch[$j][$i+1][$g]).'%
    '; + echo '
    + + diff --git a/wap/index.php b/wap/index.php new file mode 100644 index 000000000..82629ca43 --- /dev/null +++ b/wap/index.php @@ -0,0 +1,10 @@ + \ No newline at end of file