Revision 7141c353
Von Holger Lindemann vor etwa 18 Jahren hinzugefügt
lxo-import/parts_import.php | ||
---|---|---|
40 | 40 |
$rc=$db->query("BEGIN"); |
41 | 41 |
$sql = "select articlenumber from defaults"; |
42 | 42 |
$rs=$db->getAll($sql); |
43 |
$number=$rs[0]["articlenumber"]+1; |
|
43 |
if ($rs[0]["articlenumber"]) { |
|
44 |
preg_match("/([^0-9]+)?([0-9]+)([^0-9]+)?/", $rs[0]["articlenumber"] , $regs); |
|
45 |
$number=$regs[1].($regs[2]+1).$regs[3]; |
|
46 |
} |
|
44 | 47 |
$sql = "update defaults set articlenumber = '$number'"; |
45 | 48 |
$rc=$db->query($sql); |
46 | 49 |
$rc=$db->query("COMMIT"); |
... | ... | |
52 | 55 |
} |
53 | 56 |
|
54 | 57 |
function getBuchungsgruppe($db, $income, $expense) { |
55 |
|
|
58 |
|
|
56 | 59 |
$income_id = getAccnoId($db, $income); |
57 | 60 |
$expense_id = getAccnoId($db, $expense); |
58 | 61 |
//$accno0_id = getAccnoId($db, $accno0); |
... | ... | |
101 | 104 |
/* |
102 | 105 |
* read first line with table descriptions |
103 | 106 |
*/ |
104 |
show( $show, "<table border='1'><tr>\n"); |
|
107 |
show( $show, "<table border='1'><tr><td>#</td>\n");
|
|
105 | 108 |
$infld=fgetcsv($f,1200,$trenner); |
106 | 109 |
foreach ($infld as $fld) { |
107 | 110 |
$fld = strtolower(trim(strtr($fld,array("\""=>"","'"=>"")))); |
... | ... | |
116 | 119 |
$income_accno = ""; |
117 | 120 |
$expense_accno = ""; |
118 | 121 |
while ( ($zeile=fgetcsv($f,1200,$trenner)) != FALSE) { |
119 |
|
|
120 | 122 |
$i=0; /* column */ |
121 | 123 |
$m++; /* increase line */ |
122 | 124 |
|
... | ... | |
124 | 126 |
$keys="("; |
125 | 127 |
$vals=" values ("; |
126 | 128 |
|
127 |
show( $show, "<tr>\n"); |
|
129 |
show( $show, "<tr><td>$m</td>\n");
|
|
128 | 130 |
|
129 | 131 |
/* for each column */ |
130 | 132 |
$dienstleistung=false; |
... | ... | |
137 | 139 |
continue; |
138 | 140 |
}; |
139 | 141 |
$data=trim($data); |
140 |
$data=addslashes($data); |
|
142 |
//$data=addslashes($data);
|
|
141 | 143 |
$key=$in_fld[$i]; |
142 | 144 |
/* add key and data */ |
143 | 145 |
if ($data==false or empty($data) or !$data) { |
... | ... | |
175 | 177 |
//show( $show, "<td>$partnumber</td>\n"); |
176 | 178 |
} |
177 | 179 |
} else if ($key == "description") { |
180 |
$data=mb_convert_encoding($data,"ISO-8859-15","auto"); |
|
178 | 181 |
$data=addslashes($data); |
179 | 182 |
} else if ($key == "notes") { |
183 |
$data=mb_convert_encoding($data,"ISO-8859-15","auto"); |
|
180 | 184 |
$data=addslashes($data); |
181 | 185 |
} else if ($key == "unit") { |
182 | 186 |
/* convert st?ck and Stunde */ |
... | ... | |
224 | 228 |
if ($maske["bugrufix"]==1) { |
225 | 229 |
$bg = $maske["bugru"]; |
226 | 230 |
} else { |
227 |
/* search for buchungsgruppe */ |
|
228 |
$bg = getBuchungsgruppe($db, $income_accno, $expense_accno); |
|
229 |
} |
|
230 |
/* nothing found? user must create one */ |
|
231 |
if ($bg == "") { |
|
232 |
if ($maske["bugrufix"]==2) { |
|
231 |
if ($income_accno<>"" and $expense_accno<>"") { |
|
232 |
/* search for buchungsgruppe */ |
|
233 |
$bg = getBuchungsgruppe($db, $income_accno, $expense_accno); |
|
234 |
if ($bg == "" and $maske["bugrufix"]==2 and $maske["bugru"]<>"") { |
|
235 |
$bg = $maske["bugru"]; |
|
236 |
} |
|
237 |
} else if ($maske["bugru"]<>"" and $maske["bugrufix"]==2) { |
|
233 | 238 |
$bg = $maske["bugru"]; |
234 | 239 |
} else { |
240 |
/* nothing found? user must create one */ |
|
235 | 241 |
echo "Error in line $m: "; |
236 | 242 |
echo "Keine Buchungsgruppe gefunden f?r <br>"; |
237 | 243 |
echo "Erl?se Inland: $income_accno<br>"; |
238 |
//echo "Erl?se EU: $income_accno_1<br>"; |
|
239 |
//echo "Erl?se Ausland: $income_accno_3<br>"; |
|
240 |
echo "Bitte legen Sie eine an<br>"; |
|
244 |
echo "Bitte legen Sie eine an oder geben Sie eine vor.<br>"; |
|
241 | 245 |
echo "<br>"; |
242 | 246 |
$errors++; |
243 | 247 |
} |
244 |
}
|
|
248 |
} |
|
245 | 249 |
if ($bg > 0) { |
246 | 250 |
/* found one, add income_accno_id etc from buchungsgr. |
247 | 251 |
*/ |
... | ... | |
276 | 280 |
show( $show, "<td>"); |
277 | 281 |
$db->showErr = TRUE; |
278 | 282 |
$rc=$db->query($sql); |
279 |
if (!$rc) |
|
283 |
if (!$rc) {
|
|
280 | 284 |
echo "Fehler"; |
285 |
$fehler++; |
|
286 |
} |
|
281 | 287 |
show( $show, "</td>\n"); |
282 | 288 |
} |
283 | 289 |
|
... | ... | |
286 | 292 |
|
287 | 293 |
show( $show, "</table>\n"); |
288 | 294 |
fclose($f); |
295 |
echo "$m Zeilen bearbeitet. ($fehler : Fehler) "; |
|
289 | 296 |
return $errors; |
290 | 297 |
} |
291 | 298 |
|
Auch abrufbar als: Unified diff
Umlaute, Buchungsgruppe, ...