$rc=$db->query("BEGIN");
$sql = "select articlenumber from defaults";
$rs=$db->getAll($sql);
- $number=$rs[0]["articlenumber"]+1;
+ if ($rs[0]["articlenumber"]) {
+ preg_match("/([^0-9]+)?([0-9]+)([^0-9]+)?/", $rs[0]["articlenumber"] , $regs);
+ $number=$regs[1].($regs[2]+1).$regs[3];
+ }
$sql = "update defaults set articlenumber = '$number'";
$rc=$db->query($sql);
$rc=$db->query("COMMIT");
}
function getBuchungsgruppe($db, $income, $expense) {
-
+
$income_id = getAccnoId($db, $income);
$expense_id = getAccnoId($db, $expense);
//$accno0_id = getAccnoId($db, $accno0);
/*
* read first line with table descriptions
*/
- show( $show, "<table border='1'><tr>\n");
+ show( $show, "<table border='1'><tr><td>#</td>\n");
$infld=fgetcsv($f,1200,$trenner);
foreach ($infld as $fld) {
$fld = strtolower(trim(strtr($fld,array("\""=>"","'"=>""))));
$income_accno = "";
$expense_accno = "";
while ( ($zeile=fgetcsv($f,1200,$trenner)) != FALSE) {
-
$i=0; /* column */
$m++; /* increase line */
$keys="(";
$vals=" values (";
- show( $show, "<tr>\n");
+ show( $show, "<tr><td>$m</td>\n");
/* for each column */
$dienstleistung=false;
continue;
};
$data=trim($data);
- $data=addslashes($data);
+ //$data=addslashes($data);
$key=$in_fld[$i];
/* add key and data */
if ($data==false or empty($data) or !$data) {
//show( $show, "<td>$partnumber</td>\n");
}
} else if ($key == "description") {
+ $data=mb_convert_encoding($data,"ISO-8859-15","auto");
$data=addslashes($data);
} else if ($key == "notes") {
+ $data=mb_convert_encoding($data,"ISO-8859-15","auto");
$data=addslashes($data);
} else if ($key == "unit") {
/* convert stück and Stunde */
if ($maske["bugrufix"]==1) {
$bg = $maske["bugru"];
} else {
- /* search for buchungsgruppe */
- $bg = getBuchungsgruppe($db, $income_accno, $expense_accno);
- }
- /* nothing found? user must create one */
- if ($bg == "") {
- if ($maske["bugrufix"]==2) {
+ if ($income_accno<>"" and $expense_accno<>"") {
+ /* search for buchungsgruppe */
+ $bg = getBuchungsgruppe($db, $income_accno, $expense_accno);
+ if ($bg == "" and $maske["bugrufix"]==2 and $maske["bugru"]<>"") {
+ $bg = $maske["bugru"];
+ }
+ } else if ($maske["bugru"]<>"" and $maske["bugrufix"]==2) {
$bg = $maske["bugru"];
} else {
+ /* nothing found? user must create one */
echo "Error in line $m: ";
echo "Keine Buchungsgruppe gefunden für <br>";
echo "Erlöse Inland: $income_accno<br>";
- //echo "Erlöse EU: $income_accno_1<br>";
- //echo "Erlöse Ausland: $income_accno_3<br>";
- echo "Bitte legen Sie eine an<br>";
+ echo "Bitte legen Sie eine an oder geben Sie eine vor.<br>";
echo "<br>";
$errors++;
}
- }
+ }
if ($bg > 0) {
/* found one, add income_accno_id etc from buchungsgr.
*/
show( $show, "<td>");
$db->showErr = TRUE;
$rc=$db->query($sql);
- if (!$rc)
+ if (!$rc) {
echo "Fehler";
+ $fehler++;
+ }
show( $show, "</td>\n");
}
show( $show, "</table>\n");
fclose($f);
+ echo "$m Zeilen bearbeitet. ($fehler : Fehler) ";
return $errors;
}