Commit de3322f8 authored by Gerd Schachtschneider's avatar Gerd Schachtschneider
Browse files

initial

parents
../master/.htaccess
\ No newline at end of file
## Einleitung ##
Die Datenbank Gefahrenklassen ist eine uebergeordnete Datenbank, in der fuer alle Chemiedatenbanken gemeinsam die Lagerklassen und Gefahrenmerkmale gefuehrt werden. Im Idealfall werden diese Tabellen von der verantwortlichen Person fuer Arbeitssicherheit gepflegt<br>
Die abgesetzten Chemiedatenbanken (bei uns vier) greifen per View auf diese Taebllen lesbar zurueck.<br>
Gleichzeitig hat diese DB lesbaren Zugriff auf alle Chemiestoffe zur moeglichen Wahrung der Arbeitssicherheit<br>
<br>
Inhalte:
* Gefahrenmerkmale
* Lagerklassen mit Priorisierung
## Projekt downloaden ##
**Evtl. vorh. DB und Filesystem vorher sichern**<br>
<br>
Entweder von common/db_export das tar-File herunterladen oder per Befehl
~~~bash
git clone https://gitlab.mpcdf.mpg.de/mpidb/mpg_gfk.git
~~~
in das Wurzelverzeichnis des Webserver klonen.
## Installation ##
siehe LIEMICH.txt in Folder install<br>
Dort liegen auch alle noch notwendigen SQL-Skripte fuer die DB-Erstellung und weitere Verknuepfungen.
## Screenshot ##
<a href="db_export/images/db_gfk.png" title="Ueberblick Datenbanken"><img src="db_export/images/db_gfk.png" align="left" height="100" width="100"></a>
<br><br><br><br>
## Lizenzbedingungen ##
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.<br>
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.<br>
See the GNU General Public License for more details.<br>
See also the file LICENSE.txt here
../master/Web.config
\ No newline at end of file
../master/actions
\ No newline at end of file
../master/actions.ini
\ No newline at end of file
../master/conf2/
\ No newline at end of file
; File: conf.ini
; Description:
; ------------
; This file contains configuration information for the dataface framework.
; Configuration options include such things as database connection information
; tables to be displayed in the menu, and behavioral and display characteristics
; of the dataface application (like whether to display the menu).
;
title = "Gefahrenmerkmale"
#debug = 1
default_language = de
#default_browse_action = edit
#default_table = mpi_users#
#usage_mode = edit
disable_session_ip_check = 1
disable_g2 = 1
[_modules]
modules_depselect=modules/depselect/depselect.php
modules_datepicker=modules/datepicker/datepicker.php
[languages]
en = English
de = German
[_database]
host = "localhost"
user = "mpg_gfk"
password = "Z8XwcFJmxepr4KL9"
name = "mpidb_mpg_gfk"
[_own]
dn = "mpi-magdeburg.mpg.de"
notify = 30
version = 1.0.00
mailto = "db-responsable@<domain>.mpg.de"
mailname = "db-admin"
[_tables]
list_gefahr = "Gefahrenmerkmale"
list_lgk = "Lagerklasse"
view_gefahr = "Gefahrenst. MPI"
view_chemAll = "Chemiest. MPI"
view_favorit = "Favorit"
list_reiter = "mehr .."
[_auth]
users_table = "mpi_users"
username_column = "username"
session_timeout = 86400
# Autorisierung ueber db
auth_type = basic
password_column = "password"
# Autorisierung ueber ldap
#auth_type = ldap
ldap_host = "ldap"
ldap_port = "389"
ldap_base = "dc=mpi-magdeburg,dc=mpg,dc=de"
[_prefs]
hide_updated = 0
hide_posted_by = 1
#horizontal_tables_menu = 1
[history]
enabled = 1
<?php
// Cronjob Skript fuer Aktionen ausserhalb der DB
// z.B. Mailbenachrichtigung, Loeschen verwaister Ablagen etc.
// Beispiele folgend
// schachi 2016-02-15
// stelle sicher das dieses Skript in einem Subdir liegt, normalerweise im Ordner cronjobs, sonst gibt es kausale Problem :-(
chdir(__DIR__);
chdir('../');
if (!is_readable('conf.ini') ) die ('Error loading config file from here '.getcwd()."\n");
$conf = array();
// $conf = array_merge(parse_ini_file('conf.ini', true), $conf);
$conf = parse_ini_file('conf.ini', true);
if ( !isset( $conf['_database'] ) ) {
die ('Error loading config file. No database specified.');
}
$dbinfo =& $conf['_database'];
//print_r ($dbinfo['host'].' '.$dbinfo['user'].' '.$dbinfo['password']);
if ( !is_array( $dbinfo ) || !isset($dbinfo['host']) || !isset( $dbinfo['user'] ) || !isset( $dbinfo['password'] ) || !isset( $dbinfo['name'] ) ) {
die ('Error loading config file. The database information was not entered correctly.');
}
if ( @$dbinfo['persistent'] ) {
$db = mysql_pconnect( $dbinfo['host'], $dbinfo['user'], $dbinfo['password'] );
} else {
$db = mysql_connect( $dbinfo['host'], $dbinfo['user'], $dbinfo['password'] );
}
if ( !$db ) {
die ('Error connecting to the database' . mysql_error());
}
$mysqlVersion = mysql_get_server_info($db);
mysql_select_db( $dbinfo['name'] ) or die("Could not select DB: ".mysql_error($db));
// loesche alle <table>__history, welche nicht erwuenscht sind
// Xataface hat nur einen globalen Schalter ON/OFF fuer history, aber wer braucht denn alle histories?
$sql = "SELECT reiter FROM view_reiter WHERE reiter IN (SELECT CONCAT(lst.reiter, '__history') AS table_his FROM list_reiter AS lst LEFT JOIN view_reiter AS vReit ON lst.reiter = vReit.reiter WHERE lst.history = '0' AND vReit.table_type = 'BASE TABLE' AND lst.reiter NOT LIKE '%__history') AND table_type = 'BASE TABLE';";
$query = mysql_query($sql) or die(mysql_error());
$count = mysql_num_rows($query);
if ( $count >= 1 ) {
while($row = mysql_fetch_assoc($query)) {
$table = $row['reiter'];
$sql = "DROP TABLE IF EXISTS $table;";
//echo $sql."\n";
mysql_query($sql) or die(mysql_error($db));
}
}
mysql_close($db);
?>
/* indiv. table background colors */
td.Dataface_QuickForm-label-cell.list_gefahr,
td.Dataface_QuickForm-label-cell.gefahr { background-color: #b0cfb2; }
td#dataface-sections-main-column.list_gefahr,
td#dataface-sections-left-column.list_gefahr,
#table_selection_tabs li.nav.list_gefahr:hover,
#table_selection_tabs li.selected.list_gefahr,
#status-bar.list_gefahr,
td.Dataface_QuickForm-widget-cell.list_gefahr,
td.Dataface_QuickForm-widget-cell.gefahr,
div.dataface-view-section.gefahr,
a#record-tabs-gefahr-link:hover,
.contentViews .selected a#record-tabs-gefahr-link,
tr.listing.odd.list_gefahr td { background-color: #dfece0; }
tr.listing.even.list_gefahr td { background-color: #eff5f0; }
td.Dataface_QuickForm-label-cell.list_lgk,
td.Dataface_QuickForm-label-cell.lgk { background-color: #a4a4c1; }
td#dataface-sections-main-column.list_lgk,
td#dataface-sections-left-column.list_lgk,
#table_selection_tabs li.nav.list_lgk:hover,
#table_selection_tabs li.selected.list_lgk,
#status-bar.list_lgk,
td.Dataface_QuickForm-widget-cell.list_lgk,
td.Dataface_QuickForm-widget-cell.lgk,
div.dataface-view-section.lgk,
a#record-tabs-lgk-link:hover,
.contentViews .selected a#record-tabs-lgk-link,
tr.listing.odd.list_lgk td { background-color: #e1e1ea; }
tr.listing.even.list_lgk td { background-color: #f0f0f5; }
td.Dataface_QuickForm-label-cell.view_gefahr,
td.Dataface_QuickForm-label-cell.vGefahr{ background-color: #df9fc0; }
td#dataface-sections-main-column.view_gefahr,
td#dataface-sections-left-column.view_gefahr,
#table_selection_tabs li.nav.view_gefahr:hover,
#table_selection_tabs li.selected.view_gefahr,
#status-bar.view_gefahr,
td.Dataface_QuickForm-widget-cell.view_gefahr,
td.Dataface_QuickForm-widget-cell.vGefahr,
div.dataface-view-section.key,
a#record-tabs-key-link:hover,
.contentViews .selected a#record-tabs-vGefahr-link,
tr.listing.odd.view_gefahr td { background-color: #f2d9e6; }
tr.listing.even.view_gefahr td { background-color: #f9ecf2; }
td.Dataface_QuickForm-label-cell.view_chemAll,
td.Dataface_QuickForm-label-cell.chemAll { background-color: #78a6d3; }
td#dataface-sections-main-column.view_chemAll,
td#dataface-sections-left-column.view_chemAll,
#table_selection_tabs li.nav.view_chemAll:hover,
#table_selection_tabs li.selected.view_chemAll,
#status-bar.view_chemAll,
td.Dataface_QuickForm-widget-cell.view_chemAll,
td.Dataface_QuickForm-widget-cell.chemAll,
div.dataface-view-section.chemAll,
a#record-tabs-chemAll-link:hover,
.contentViews .selected a#record-tabs-chemAll-link,
tr.listing.odd.view_chemAll td { background-color: #d9e6f2; }
tr.listing.even.view_chemAll td { background-color: #ecf2f9; }
/* ueberschreibt vorherige listenfarbe links */
tr.listing.odd.sand td.row-actions-cell,
tr.listing.even.sand td.row-actions-cell { background-color: #FFFCED; }
tr.listing.odd.viol td.row-actions-cell,
tr.listing.even.viol td.row-actions-cell { background-color: #ccf; }
tr.listing.odd.rot td.row-actions-cell,
tr.listing.even.rot td.row-actions-cell { background-color: #fcc; }
tr.listing.odd.gruen td.row-actions-cell,
tr.listing.even.gruen td.row-actions-cell { background-color: #cfc; }
tr.listing.odd.gelb td.row-actions-cell,
tr.listing.even.gelb td.row-actions-cell { background-color: #ffdc99; }
tr.listing.odd.cyan td.row-actions-cell,
tr.listing.even.cyan td.row-actions-cell { background-color: #cff; }
tr.listing.odd.lineY td.row-actions-cell,
tr.listing.even.lineY td.row-actions-cell { background-color: #ffc !important; }
../master/images/
\ No newline at end of file
<?php
/**
* File: index.php
* Description:
* -------------
*
* This is an entry file for this Dataface Application. To use your application
* simply point your web browser to this file.
*/
// Limit veraendern
if ( !isset($_REQUEST['-limit']) ) {
$_REQUEST['-limit'] = $_GET['-limit'] = '20';
}
// Sortierreihenfolge in Listenansicht aendern
//if ( !isset($_REQUEST['-sort']) and @$_REQUEST['-table'] == 'mpi_lieferant' ) {
// $_REQUEST['-sort'] = $_GET['-sort'] = 'firma';
//}
// disbale table views in db - sonst kommt immer Fehlermeldung in apache
define('XATAFACE_DISABLE_PROXY_VIEWS',true);
require_once '../xataface/dataface-public-api.php';
df_init(__FILE__, "../xataface")->display();
###
Was muss ich anpassen:
!!! Vorhandene DB oder FileSystem immer vorher sichern !!!
1. DB-User anlegen mit sql Skript install/create_DB_User.sql
Initialer Login ist admin mit Passwort admin
sollte man irgendwann aendern
2. Datenbank anlegen mit sql Skript install/mpidb_mpg_user.sql
bei Update install/updateDB_<version>.sql
3. domain, hostname, ssl, user, password unbedingt anpassen in
conf.ini aendern
user, pass in mysql-DB anpassen
4. ggf. cronjobs anlegen
5 6 * * * php /var/www/mpg_gfk/cronjobs/cronDatabase.php
5. wenn es eine seperate User-Datenbank gibt, dann folgende SQL-Skripte ausfuehren
mysql -p -u root < install/joinGfk2User.sql
6. Verbindung zu Chemie-Datenbanken herstellen und folgende SQL-Skripte ausfuehren
mysql -p -u root < install/joinGfk2Chem.sql
mysql -p -u root < install/joinChem2Gfk.sql
8. Autorisierung auf ldap umstellen
Eintrag #auth_type = basic disable per Raute
Eintrag auth_type = ldap enable Raute entfernen
Wie starte ich sql-Skripte?
- per import in phpmyadmin oder
- INITIAL: per Konsole mit 'mysql -p -u root < irgendEinName.sql
- UPDATE: per Konsole mit 'mysql -p -u root <datenbankname> < irgendEinName.sql
-- lege user fuer die db an
GRANT USAGE ON *.* TO 'mpg_gfk'@'localhost' IDENTIFIED BY 'password';
DROP USER 'mpg_gfk'@'localhost';
CREATE USER 'mpg_gfk'@'localhost' IDENTIFIED BY '***';
GRANT USAGE ON *.* TO 'mpg_gfk'@'localhost' IDENTIFIED BY '***' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
SET PASSWORD FOR 'mpg_gfk'@'localhost' = PASSWORD( 'Z8XwcFJmxepr4KL9' );
GRANT ALL PRIVILEGES ON `mpidb\_mpg\_gfk` . * TO 'mpg_gfk'@'localhost' WITH GRANT OPTION ;
../../mpg_user/install/joinGfk2User.sql
\ No newline at end of file
This diff is collapsed.
-- run: mysql -u root -p mpidb_mech_inv < updateDB_0500.sql
-- UPDATES immer von der niefrigsten bis zur hoechsten version ausfuehren
-- damit IF benutzt werden kann, wird eine prozedur erzeugt und am ende ausgefuehrt
--
-- views, funcs, procs nach moeglichkeit nur einmal in der max version ausfuehren
-- USE mpidb_mpg_licman;
DROP PROCEDURE IF EXISTS proc_update;
DELIMITER $$
CREATE PROCEDURE proc_update()
proc_label: BEGIN
-- initial value
IF ( SELECT MAX(version) FROM dataface__version ) = '0' THEN
TRUNCATE dataface__version;
INSERT INTO dataface__version (version) VALUES ('1000');
END IF;
-- mindest version vorhanden
IF ( SELECT MAX(version) FROM dataface__version ) < '1000' THEN
LEAVE proc_label;
END IF;
IF ( SELECT MAX(version) FROM dataface__version ) < '1000' THEN
-- CHANGES V1.0.00 :
-- ****************
-- fs::rsync - mpg_lgk initial
TRUNCATE dataface__version;
INSERT INTO dataface__version (version) VALUES ('1000');
END IF;
END;
$$
DELIMITER ;
-- execute updates
CALL proc_update();
../master/global.css
\ No newline at end of file
[view_merkmal]
label="Details Merkmal [{$record->val('autoID')}]"
icon = "images/show.png"
url="{$site_href}?-action=browse&-table=list_gefahr&autoID={$record->val('autoID')}"
url_condition="$record"
condition="$record and $query['-table'] == 'list_gefahr'"
permission=view
category=list_row_actions
order = 10
[edit_merkmal]
label="Bearbeite Merkmal [{$record->val('autoID')}]"
icon = "images/edit.png"
url="{$site_href}?-action=edit&-table=list_gefahr&autoID={$record->val('autoID')}"
url_condition="$record"
condition="$record and $query['-table'] == 'list_gefahr'"
permission=edit
category=list_row_actions
order = 20
# sortierung nach software, statt in index.php
__sql__ = "SELECT * FROM list_gefahr ORDER BY hsatz"
[__global__]
noLinkFromListView = 1
[autoID]
#widget:type = "hidden"
visibility:list = "hidden"
#visibility:browse = "hidden"
#visibility:find = "hidden"
[kategorie]
widget:label = "Gefahrenklasse"
[hsatz]
widget:label = "H-Satz"
filter = 1
[merkmal]
widget:label = "Gefahrenhinweis"
widget:type = "textarea"
display = inline
[anweisung]
# Typ: tinyint(1)
widget:type = checkbox
vocabulary = anweisung
filter = 1
[lgk]
widget:label = "Lagerklasse"
widget:type = "select"
vocabulary= "lagerklasse"
filter = 1
<?php
class tables_list_gefahr {
function block__before_fineprint() {
$app = Dataface_Application::getInstance();
$fs_ver = $app->_conf['_own']['version'];
$mailto = $app->_conf['_own']['mailto'];
$mname = $app->_conf['_own']['mailname'];
$sql = "SELECT MAX(version) FROM dataface__version";
list($db_ver) = mysql_fetch_row(mysql_query($sql, df_db()));
$db_ver = str_pad($db_ver, 4, 0, STR_PAD_LEFT);
$fs_rep = str_replace('.','',$fs_ver);
if ( $fs_rep == $db_ver )
echo 'Version <span style="color: green">FS: '.$fs_ver.'</span> = <span style="color: green">DB: '.$db_ver.'</span> &copy;<a href="mailto:'.$mailto.'">'.$mname.'</a>';
}
function block__before_body() {
$app = Dataface_Application::getInstance();
$fs_ver = $app->_conf['_own']['version'];
$sql = "SELECT MAX(version) FROM dataface__version";
list($db_ver) = mysql_fetch_row(mysql_query($sql, df_db()));
$db_ver = str_pad($db_ver, 4, 0, STR_PAD_LEFT);
$fs_rep = str_replace('.','',$fs_ver);
if ( $fs_rep != $db_ver ) {
if ( $fs_rep > $db_ver ) {
echo 'Version <span style="color: green">FS: '.$fs_ver.'</span> &ne; <span style="color: red">DB: '.$db_ver.'</span>';
} else {
echo 'Version <span style="color: red">FS: '.$fs_ver.'</span> &ne; <span style="color: green">DB: '.$db_ver.'</span>';
}
}
}
// setze indiv. Farbe in listenansicht fuer tabelle
function css__tableRowClass( &$record ) {
$query = Dataface_Application::getInstance()->getQuery();
$table = $query['-table'].' ';
// return $table.'normal'; //mit color
if ($record->val('anweisung') == '1') return $table.'lineY';
return $table;
}
// Anzeige in liste aendern
function lgk__renderCell(&$record) {
return $record->val('lgk');
}
// mache aus 0 und 1 = ja und nein
function anweisung__renderCell(&$record) {
if ($record->val('anweisung') == '1') return 'ja';
return 'nein';
}
function valuelist__anweisung() {
return array(0=>'nein', 1=>'ja');
}
}
?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment