$rs=$db->getAll($sql);
return $rs;
}
+
function getAllUnits($db,$type) {
$sql = "select * from units where type = '$type' order by sortkey";
$rs=$db->getAll($sql);
return $rs;
}
-function anmelden() {
+function anmelden($login=false,$pwd=false) {
ini_set("gc_maxlifetime","3600");
$tmp = @file_get_contents("../config/authentication.pl");
preg_match("/'db'[ ]*=> '(.+)'/",$tmp,$hits);
preg_match("/[ ]*\\\$self->\{cookie_name\}[ ]*=[ ]*'(.+)'/",$tmp,$hits);
$cookiename=$hits[1];
if (!$cookiename) $cookiename='lx_office_erp_session_id';
- $cookie=$_COOKIE[$cookiename];
- if (!$cookie) header("location: ups.html");
- $auth=authuser($dbhost,$dbport,$dbuser,$dbpasswd,$dbname,$cookie);
+ if ($login) {
+ $auth=authuser($dbhost,$dbport,$dbuser,$dbpasswd,$dbname,false,$login,$pwd);
+ } else {
+ $cookie=$_COOKIE[$cookiename];
+ if (!$cookie) header("location: ups.html");
+ $auth=authuser($dbhost,$dbport,$dbuser,$dbpasswd,$dbname,$cookie,false,false);
+ };
if (!$auth) { return false; };
$_SESSION["sessid"]=$cookie;
$_SESSION["cookie"]=$cookiename;
$sql="select * from defaults";
$rs=$_SESSION["db"]->getAll($sql);
$_SESSION["ERPver"]=$rs[0]["version"];
- return true;
+ return true;$_SESSION;
} else {
return false;
}
}
}
-function authuser($dbhost,$dbport,$dbuser,$dbpasswd,$dbname,$cookie) {
+function authuser($dbhost,$dbport,$dbuser,$dbpasswd,$dbname,$cookie,$login,$pwd) {
$db=new myDB($dbhost,$dbuser,$dbpasswd,$dbname,$dbport,true);
- $sql="select sc.session_id,u.id from auth.session_content sc left join auth.user u on ";
- $sql.="u.login=sc.sess_value left join auth.session s on s.id=sc.session_id ";
- $sql.="where session_id = '$cookie' and sc.sess_key='login'";// order by s.mtime desc";
- $rs=$db->getAll($sql,"authuser_1");
- if (!$rs) return false;
- $stmp="";
- if (count($rs)>1) {
- header("location:../login.pl?action=logout");
- /*foreach($rs as $row) {
- $stmp.=$row["session_id"].",";
- }
- $sql1="delete from session where id in (".substr($stmp,-1).")";
- $sql2="delete from session_content where session_id in (".substr($stmp,-1).")";
- $db->query($sql1,"authuser_A");
- $db->query($sql2,"authuser_B");
- $sql3="insert into session ";*/
+ if ($cookie) {
+ $sql="select sc.session_id,u.id from auth.session_content sc left join auth.user u on ";
+ $sql.="u.login=sc.sess_value left join auth.session s on s.id=sc.session_id ";
+ $sql.="where session_id = '$cookie' and sc.sess_key='login'";// order by s.mtime desc";
+ $rs=$db->getAll($sql,"authuser_1");
+ if (!$rs) return false;
+ $stmp="";
+ if (count($rs)>1) {
+ foreach($rs as $row) {
+ $stmp.=$row["session_id"].",";
+ }
+ $sql1="delete from session where id in (".substr($stmp,-1).")";
+ $sql2="delete from session_content where session_id in (".substr($stmp,-1).")";
+ $db->query($sql1,"authuser_A");
+ $db->query($sql2,"authuser_B");
+ header("location:../login.pl?action=logout");
+ };
+ $sql="update auth.session set mtime = '".date("Y-M-d H:i:s.100001")."' where id = '".$rs[0]["session_id"]."'";
+ $db->query($sql,"authuser_3");
+ $sql="select * from auth.user where id=".$rs[0]["id"];
+ } else {
+ $sql = "select * from auth.user where login = '$login' and password = '$pwd'";
}
- $sql="select * from auth.user where id=".$rs[0]["id"];
$rs1=$db->getAll($sql,"authuser_1");
if (!$rs1) return false;
$auth=array();
$auth["login"]=$rs1[0]["login"];
- $sql="select * from auth.user_config where user_id=".$rs[0]["id"];
+ $sql="select * from auth.user_config where user_id=".$rs1[0]["id"];
$rs1=$db->getAll($sql,"authuser_2");
$keys=array("dbname","dbpasswd","dbhost","dbport","dbuser");
foreach ($rs1 as $row) {
$auth[$row["cfg_key"]]=$row["cfg_value"];
}
}
- $sql="update auth.session set mtime = '".date("Y-M-d H:i:s.100001")."' where id = '".$rs[0]["session_id"]."'";
- $db->query($sql,"authuser_3");
return $auth;
}
+
/**
* Zeichencode übersetzen
*
+<?php session_start(); ?>
<html>
<LINK REL="stylesheet" HREF="../css/lx-office-erp.css" TYPE="text/css" TITLE="Lx-Office stylesheet">
<body>
}
require ("import_lib.php");
-if (!anmelden()) ende("Anmeldung fehlgeschlagen.");
+if ($_GET["login"]) {
+ $db = anmelden($_GET["login"],$_GET["passwd"]);
+} else {
+ $db = anmelden();
+}
+//if (!$_SESSION["db"]) ende("Anmeldung fehlgeschlagen.");
+if (!$db) ende("Anmeldung fehlgeschlagen.");
/* get DB instance */
$db=$_SESSION["db"]; //new myDB($login);
-
/* just display page or do real import? */
-if ($_POST["ok"]) {
+if ($_POST["ok"] || $_GET["cron"]=="1") {
require ("parts_import.php");
//Zeichencodierung des Servers
clearstatcache ();
- $test = $_POST["test"];
- $lager = $_POST["lager"];
- $TextUpd = $_POST["TextUpd"];
- $trenner = ($_POST["trenner"])?$_POST["trenner"]:",";
- $trennzeichen = ($_POST["trennzeichen"])?$_POST["trennzeichen"]:"";
- $precision = $_POST["precision"];
- $quotation = $_POST["quotation"];
- $quottype = $_POST["quottype"];
$file = "parts";
- /* no data? */
- if (empty($_FILES["Datei"]["name"]))
- ende ("Kein Datenfile angegeben");
-
- /* copy file */
- if (substr($_FILES["Datei"]["name"],-2)=="gz") {
- if (move_uploaded_file($_FILES["Datei"]["tmp_name"],$dir.$file.".csv.gz")) {
- echo $gz_bin.$dir.$file.".csv.gz";
+ if ($_GET["cron"]==1) {
+ $Cron = True;
+ if (file_exists($dir.$file.".zip")) {
+ exec ($zip_bin.$dir.$file.".zip");
+ } else if (file_exists($dir.$file.".gz")) {
exec ($gz_bin.$dir.$file.".csv.gz");
- } else {
- ende ("Upload von Datei fehlerhaft.".$_FILES["Datei"]["error"]);
- };
- } else if (substr($_FILES["Datei"]["name"],-3)=="zip") {
- if (move_uploaded_file($_FILES["Datei"]["tmp_name"],$dir.$file.".zip")) {
- exec ($zip_bin.$dir.$file.".zip");
- } else {
+ } else if (!file_exists($dir.$file.".csv")) {
+ ende($dir.$file.".csv nicht gefunden");
+ }
+ $_POST["trenner"] = "#9"; // Tabulator
+ $_POST["trennzeichen"] = ";"; // Anderes Trennzeichen
+ $_POST["dimensionunit"] = "Stck"; // Artikeleinheit
+ $_POST["serviceunit"] = "Std"; // Dienstleistungseinheit
+ $_POST["bugru"] = "1600"; // Std-Bugru
+ $_POST["bugrufix"] = "2"; // Nur wenn keine Passende angegeben
+ $_POST["shop"] = "f"; // Shopartikel
+ $_POST["show"] = ""; // Kontrollausgabe
+ $_POST["test"] = ""; // Testlauf == 1
+ $_POST["lager"] = ""; // Nicht gebraucht
+ $_POST["lagerplatz"] = "";
+ $_POST["precision"] = "2"; // Runden auf nn Stellen
+ $_POST["quotation"] = ""; // Preisaufschlag
+ $_POST["quottype"] = "P"; // Prozent?
+ $_POST["wgtrenner"] = "!"; // Trennzeichen der Warengruppen
+ $_POST["TextUpd"] = "1"; // Textupdate durchführen
+ $_POST["update"] = "U"; // Bei vorhandenen Nummer updaten
+ $_POST["ware"] = "W"; // Ist ein Artikel
+ $_POST["encoding"] = "";
+ } else {
+
+ /* no data? */
+ if (empty($_FILES["Datei"]["name"]))
+ ende ("Kein Datenfile angegeben");
+
+ /* copy file */
+ if (substr($_FILES["Datei"]["name"],-2)=="gz") {
+ if (move_uploaded_file($_FILES["Datei"]["tmp_name"],$dir.$file.".csv.gz")) {
+ echo $gz_bin.$dir.$file.".csv.gz";
+ exec ($gz_bin.$dir.$file.".csv.gz");
+ } else {
+ ende ("Upload von Datei fehlerhaft.".$_FILES["Datei"]["error"]);
+ };
+ } else if (substr($_FILES["Datei"]["name"],-3)=="zip") {
+ if (move_uploaded_file($_FILES["Datei"]["tmp_name"],$dir.$file.".zip")) {
+ exec ($zip_bin.$dir.$file.".zip");
+ } else {
+ ende ("Upload von Datei fehlerhaft.".$_FILES["Datei"]["error"]);
+ };
+ } else if (!move_uploaded_file($_FILES["Datei"]["tmp_name"],$dir.$file.".csv")) {
ende ("Upload von Datei fehlerhaft.".$_FILES["Datei"]["error"]);
- };
- } else if (!move_uploaded_file($_FILES["Datei"]["tmp_name"],$dir.$file.".csv")) {
- ende ("Upload von Datei fehlerhaft.".$_FILES["Datei"]["error"]);
- };
+ };
+ }
/* check if file is really there */
if (!file_exists($dir.$file.'.csv') or filesize($dir.$file.'.csv')==0)
if (!$db->chkcol($file))
ende("Importspalte konnte nicht angelegt werden");
- /* first check all elements */
- $_test=$_POST;
- $_test["precision"]=-1;
- $_test["quotation"]=0;
- $_test["lager"]=$_POST["lager"];
- $_test["lagerplatz"]=$_POST["lagerplatz"];
-
/* just print data or insert it, if test is false */
- import_parts($db, $dir.$file, $trenner, $trennzeichen, $parts, FALSE, !$test, $_POST["show"],$_POST);
+ import_parts($_SESSION["db"], $dir.$file, $parts, FALSE, $_POST);
} else {
$bugrus=getAllBG($db);
return true;
}
-function import_parts($db, $file, $trenner, $trennzeichen, $fields, $check, $insert, $show ,$maske) {
+/**
+ * TODO: short description.
+ *
+ * @param double $db
+ * @param mixed $file
+ * @param mixed $fields
+ * @param mixed $check
+ * @param int $insert
+ * @param string $show
+ * @param mixed $maske
+ *
+ * @return TODO
+ */
+function import_parts($db, $file, $fields, $check, $maske) {
+ $insert = !$maske["test"];
+ $show = $maske["show"];
+ $trennzeichen = ($maske["trennzeichen"])?$maske["trennzeichen"]:"";
+ $trenner = ($maske["trenner"])?$maske["trenner"]:",";
$precision=$maske["precision"];
$quotation=$maske["quotation"];
$quottype=$maske["quottype"];