X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=lxo-import%2Fparts_import.php;h=d147a2ffa4f667070664f9ca3bf8f37cb4f2839b;hb=e7733e090dda0753271bbe3a554d05dbe9af3904;hp=19e0f257d9252a1b1a94eaa665ed40c3a44855c5;hpb=bd10a269df8a3de2653d02b8771459a4e34165a9;p=kivitendo-erp.git diff --git a/lxo-import/parts_import.php b/lxo-import/parts_import.php index 19e0f257d..d147a2ffa 100644 --- a/lxo-import/parts_import.php +++ b/lxo-import/parts_import.php @@ -40,7 +40,10 @@ function chkPartNumber($db,$number,$check) { $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"); @@ -52,7 +55,7 @@ function chkPartNumber($db,$number,$check) { } function getBuchungsgruppe($db, $income, $expense) { - + $income_id = getAccnoId($db, $income); $expense_id = getAccnoId($db, $expense); //$accno0_id = getAccnoId($db, $accno0); @@ -101,7 +104,7 @@ function import_parts($db, $file, $trenner, $fields, $check, $insert, $show,$mas /* * read first line with table descriptions */ - show( $show, "\n"); + show( $show, "
\n"); $infld=fgetcsv($f,1200,$trenner); foreach ($infld as $fld) { $fld = strtolower(trim(strtr($fld,array("\""=>"","'"=>"")))); @@ -116,7 +119,6 @@ function import_parts($db, $file, $trenner, $fields, $check, $insert, $show,$mas $income_accno = ""; $expense_accno = ""; while ( ($zeile=fgetcsv($f,1200,$trenner)) != FALSE) { - $i=0; /* column */ $m++; /* increase line */ @@ -124,7 +126,7 @@ function import_parts($db, $file, $trenner, $fields, $check, $insert, $show,$mas $keys="("; $vals=" values ("; - show( $show, "\n"); + show( $show, "\n"); /* for each column */ $dienstleistung=false; @@ -137,7 +139,7 @@ function import_parts($db, $file, $trenner, $fields, $check, $insert, $show,$mas 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) { @@ -175,8 +177,10 @@ function import_parts($db, $file, $trenner, $fields, $check, $insert, $show,$mas //show( $show, "\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 */ @@ -224,24 +228,24 @@ function import_parts($db, $file, $trenner, $fields, $check, $insert, $show,$mas 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
"; echo "Erlöse Inland: $income_accno
"; - //echo "Erlöse EU: $income_accno_1
"; - //echo "Erlöse Ausland: $income_accno_3
"; - echo "Bitte legen Sie eine an
"; + echo "Bitte legen Sie eine an oder geben Sie eine vor.
"; echo "
"; $errors++; } - } + } if ($bg > 0) { /* found one, add income_accno_id etc from buchungsgr. */ @@ -276,8 +280,10 @@ function import_parts($db, $file, $trenner, $fields, $check, $insert, $show,$mas show( $show, "\n"); } @@ -286,6 +292,7 @@ function import_parts($db, $file, $trenner, $fields, $check, $insert, $show,$mas show( $show, "
#
$m$partnumber"); $db->showErr = TRUE; $rc=$db->query($sql); - if (!$rc) + if (!$rc) { echo "Fehler"; + $fehler++; + } show( $show, "
\n"); fclose($f); + echo "$m Zeilen bearbeitet. ($fehler : Fehler) "; return $errors; }