212 |
212 |
213 echo "<div align='center'>"; |
213 echo "<div align='center'>"; |
214 if ($infid) $text = "editieren"; else $text = "erfassen"; |
214 if ($infid) $text = "editieren"; else $text = "erfassen"; |
215 if ($copy) $duptext = " (Kopie)"; |
215 if ($copy) $duptext = " (Kopie)"; |
216 echo "<h3>Geschäftsverteilungsplan $text$duptext<h3>"; |
216 echo "<h3>Geschäftsverteilungsplan $text$duptext<h3>"; |
|
217 |
|
218 if ($_FILES["ifile"]["error"] == 1 || $_FILES["ifile"]["error"] == 2) |
|
219 { |
|
220 if ($_FILES["ifile"]["error"] == 2) |
|
221 echo "<p class='red'><b>Uploadfile > 10 MByte!</b></p>\n"; |
|
222 $ok = 0; |
|
223 } |
217 |
224 |
218 echo "</div>\n"; |
225 echo "</div>\n"; |
219 |
226 |
220 if (!$ok || (!$sub && !$del && !$dup)) |
227 if (!$ok || (!$sub && !$del && !$dup)) |
221 { |
228 { |
222 if ($infid && (!$sub || !$del) && !isset($inf)) |
229 if ($infid && (!$sub || !$del) && !isset($inf)) |
223 { // update |
230 { // update |
224 $sql = "SELECT info_ID,info_name_s,info_name_l,info_date,info_valid_from,info_valid_to,infotyp_ID, |
231 $sql = "SELECT info_ID,info_name_s,info_name_l,info_date,info_valid_from,info_valid_to,infotyp_ID, |
225 i.persknr,lang,info_file,info_rel_ID,info_freigabe_ID,info_sort, |
232 i.persknr,lang,info_file,info_rel_ID,info_freigabe_ID,info_sort,betrag, |
226 CONCAT(nachname,', ',vorname) AS aname |
233 CONCAT(nachname,', ',vorname) AS aname |
227 FROM fhiiqm.Info i LEFT OUTER JOIN fhiiqm.Mitarbeiter m |
234 FROM fhiiqm.Info i LEFT OUTER JOIN fhiiqm.Mitarbeiter m |
228 ON i.persknr=m.persknr |
235 ON i.persknr=m.persknr |
229 WHERE info_ID = $infid"; |
236 WHERE info_ID = $infid"; |
230 if ($result = $dbc -> queryObjectArray($sql)) |
237 if ($result = $dbc -> queryObjectArray($sql)) |
242 $inf["pers"] = $row->persknr; |
249 $inf["pers"] = $row->persknr; |
243 $inf["infrel"] = $row->info_rel_ID; |
250 $inf["infrel"] = $row->info_rel_ID; |
244 $inf["ifname"] = $row->info_file; |
251 $inf["ifname"] = $row->info_file; |
245 $inf["lang"] = $row->lang; |
252 $inf["lang"] = $row->lang; |
246 $inf["fg"] = $row->info_freigabe_ID; |
253 $inf["fg"] = $row->info_freigabe_ID; |
247 $inf["sort"] = $row->info_sort; |
254 $inf["sort"] = $row->info_sort; |
|
255 $inf["betr"] = str_replace('.',',',$row->betrag); |
248 } |
256 } |
249 } |
257 } |
250 // Produkt |
258 // Produkt |
251 $sql = "SELECT produkt_ID FROM Info_Produkt WHERE info_ID = $infid"; |
259 $sql = "SELECT produkt_ID FROM Info_Produkt WHERE info_ID = $infid"; |
252 if ($result = $dbc -> queryObjectArray($sql)) |
260 if ($result = $dbc -> queryObjectArray($sql)) |
369 |
377 |
370 if ($inf["cdat"] == "") $inf["cdat"] = null; |
378 if ($inf["cdat"] == "") $inf["cdat"] = null; |
371 if ($inf["vdat"] == "") $inf["vdat"] = null; |
379 if ($inf["vdat"] == "") $inf["vdat"] = null; |
372 if ($inf["bdat"] == "") $inf["bdat"] = null; |
380 if ($inf["bdat"] == "") $inf["bdat"] = null; |
373 if ($inf["fg"] == -1) $inf["fg"] = null; |
381 if ($inf["fg"] == -1) $inf["fg"] = null; |
374 |
382 if (isset($inf['betr']) && $inf['betr']) $betrag = dbformat_wert($inf['betr']); else $betrag = null; |
|
383 |
375 if (!isset($dbc) || !$dbc) $dbc = new dbconnection(); |
384 if (!isset($dbc) || !$dbc) $dbc = new dbconnection(); |
376 |
385 |
377 $stmt = $dbc -> stmtinit(); |
386 $stmt = $dbc -> stmtinit(); |
378 if (is_object($stmt)) |
387 if (is_object($stmt)) |
379 { |
388 { |
392 infotyp_ID = ?, |
401 infotyp_ID = ?, |
393 persknr = ?, |
402 persknr = ?, |
394 lang = ?, |
403 lang = ?, |
395 info_freigabe_ID = ?, |
404 info_freigabe_ID = ?, |
396 info_sort = ?, |
405 info_sort = ?, |
397 info_rel_ID = ? WHERE info_ID = $infid"); |
406 info_rel_ID = ?, |
398 $stmt -> bind_param('sssssiisisi',$inf["iname"],$inf["ilong"],$inf["cdat"],$inf["vdat"],$inf["bdat"],$inf["ityp"],$inf["pers"],$inf["lang"],$inf["fg"],$inf["sort"],$inf["infrel"]); |
407 betrag = ? WHERE info_ID = $infid"); |
|
408 $stmt -> bind_param('sssssiisisid',$inf["iname"],$inf["ilong"],$inf["cdat"],$inf["vdat"],$inf["bdat"],$inf["ityp"],$inf["pers"],$inf["lang"],$inf["fg"],$inf["sort"],$inf["infrel"],$betrag); |
399 $result = $stmt -> execute(); |
409 $result = $stmt -> execute(); |
400 if ($stmt->error) echo "error UPDATE Info: " . $stmt->error . "<br><br>\n"; |
410 if ($stmt->error) echo "error UPDATE Info: " . $stmt->error . "<br><br>\n"; |
401 } |
411 } |
402 else |
412 else |
403 { //INSERT |
413 { //INSERT |
404 $stmt -> prepare ("INSERT INTO Info (info_name_s,info_name_l,info_date,info_valid_from,info_valid_to, |
414 $stmt -> prepare ("INSERT INTO Info (info_name_s,info_name_l,info_date,info_valid_from,info_valid_to, |
405 infotyp_ID,persknr,lang,info_freigabe_ID,info_sort,info_rel_ID) VALUES (?,?,?,?,?,?,?,?,?,?,?)"); |
415 infotyp_ID,persknr,lang,info_freigabe_ID,info_sort,info_rel_ID,betrag) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)"); |
406 $stmt -> bind_param('sssssiisisi', $inf["iname"],$inf["ilong"],$inf["cdat"],$inf["vdat"],$inf["bdat"],$inf["ityp"],$inf["pers"],$inf["lang"],$inf["fg"],$inf["sort"],$inf["infrel"]); |
416 $stmt -> bind_param('sssssiisisid', $inf["iname"],$inf["ilong"],$inf["cdat"],$inf["vdat"],$inf["bdat"],$inf["ityp"],$inf["pers"],$inf["lang"],$inf["fg"],$inf["sort"],$inf["infrel"],$betrag); |
407 $result = $stmt -> execute(); |
417 $result = $stmt -> execute(); |
408 |
418 |
409 if ($stmt->error) echo "error INSERT Info: " . $stmt->error . "<br><br>\n"; |
419 if ($stmt->error) echo "error INSERT Info: " . $stmt->error . "<br><br>\n"; |
410 if ($result) |
420 if ($result) |
411 { // INSERT o.k. |
421 { // INSERT o.k. |
420 include ("inc/info_tab_ins.inc.php"); |
430 include ("inc/info_tab_ins.inc.php"); |
421 |
431 |
422 // upload File |
432 // upload File |
423 if (is_uploaded_file($_FILES["ifile"]["tmp_name"]) && isset($_FILES["ifile"]["name"]) && $_FILES["ifile"]["name"] ) |
433 if (is_uploaded_file($_FILES["ifile"]["tmp_name"]) && isset($_FILES["ifile"]["name"]) && $_FILES["ifile"]["name"] ) |
424 { |
434 { |
425 include ("inc/file_upload.inc.php"); |
435 include_once ("inc/file_upload.inc.php"); |
426 $fname = gen_filename($inf['ifname'],"ifile",$infid); |
436 $fname = gen_filename($inf['ifname'],"ifile",$infid); |
427 $retdf = mod_file("/var/www/fhiiqm/infos",$infid,"","del"); // Loeschen alte Datei |
437 $retdf = mod_file("/var/www/fhiiqm/infos",$infid,"","del"); // Loeschen alte Datei |
428 $retf = upload("ifile", $fname, $infid, "infos"); // Datei prüfen und in Dokumentenverzeichnis verschieben |
438 $retf = upload("ifile", $fname, $infid, "infos"); // Datei prüfen und in Dokumentenverzeichnis verschieben |
429 |
439 |
430 if ($retf) |
440 if ($retf) |
439 } |
449 } |
440 else |
450 else |
441 {// nur Aenderung Dateiname |
451 {// nur Aenderung Dateiname |
442 if ($inf["ifname"]) // Dateiname vergeben |
452 if ($inf["ifname"]) // Dateiname vergeben |
443 { |
453 { |
444 include ("inc/file_upload.inc.php"); |
454 include_once ("inc/file_upload.inc.php"); |
445 $fname = gen_filename($inf["ifname"],$ifile_old,$infid,0); |
455 $fname = gen_filename($inf["ifname"],$ifile_old,$infid,0); |
446 $len = strlen($infid)+1; |
456 $len = strlen($infid)+1; |
447 if (substr($fname,0,$len) != "$infid" . "_") $fname = $infid . "_" . $fname; |
457 if (substr($fname,0,$len) != "$infid" . "_") $fname = $infid . "_" . $fname; |
448 if ($inf["ifname"] != $ifile_old) |
458 if ($inf["ifname"] != $ifile_old) |
449 { |
459 { |
464 if (substr($fname,0,$len) == "$infid" . "_") $fname = substr($fname,$len,50); |
474 if (substr($fname,0,$len) == "$infid" . "_") $fname = substr($fname,$len,50); |
465 $retf=1; $reti=1; |
475 $retf=1; $reti=1; |
466 } |
476 } |
467 } |
477 } |
468 else // kein Dateiname angegeben |
478 else // kein Dateiname angegeben |
469 {$retf=1; $reti=1;} |
479 { |
|
480 $retf=1; $reti=1; |
|
481 if ($ifile_old) |
|
482 { // Loeschen alte Datei |
|
483 include_once ("inc/file_upload.inc.php"); |
|
484 $retf = mod_file("/var/www/fhiiqm/infos",$infid,"","del"); |
|
485 if ($retf) |
|
486 { |
|
487 $sql = "UPDATE Info SET info_file = null WHERE info_ID=$infid"; |
|
488 $reti=$dbc->execute($sql); |
|
489 if (!$reti) |
|
490 echo $dbc -> error . "<br>\n"; |
|
491 } |
|
492 } |
|
493 } |
470 } |
494 } |
471 } |
495 } |
472 if ($result && $retf && $reti && $reta && $retp && $retv) // INSERT/UPDATE Info |
496 if ($result && $retf && $reti && $reta && $retp && $retv) // INSERT/UPDATE Info |
473 { |
497 { |
474 //Eingabe Daten, Upload File erfolgreich |
498 //Eingabe Daten, Upload File erfolgreich |