<?php
include_once('phplibrary/artikelquerys.php'); Querys sind I.O.
include_once('phplibrary/functions.inc.php'); Auch OK.
$link = db_connect();
$vk1 = $vk1 * 100; // Verkaufspreise sind Cent werden zu Euro (unwichtig)
$vk2 = $vk2 * 100;
$vk3 = $vk3 * 100;
if($killbild == "1") // Löscht das Artikelbild und ersetzt es mit dem Standard
{
global $oldbild;
if($oldbild !== "/images/bild.gif")
{
unlink(PFAD.$oldbild);
Print PFAD.$oldbild.' Altes Bild';
}
$oldbild = "/images/bild.gif";
}
else
{
if($_FILES[bild][error] == 0)
{
if($oldbild !== "/images/blank.gif")
{
unlink(PFAD.$oldbild);
Print PFAD.$oldbild.' Altes Bild';
}
$oldbild = imagesave();
}
}
if($killsdl == "1")
{
if(!eregi("#" , $oldsdl))
{
unlink(PFAD.$oldsdl);
}
$oldsdl = '#';
}
else
{
if($_FILES[sdl][error] == 0)
{
if($_FILES['sdl']['type'] == "application/pdf" | $_FILES['sdl']['type'] == "application/msexcel" | $_FILES['sdl']['type'] == "application/msword" | $_FILES['sdl']['type'] == "text/plain")
{
$filename = PFAD.$oldsdl;
if (file_exists($filename))
{
unlink($filename);
}
if($_FILES['sdl']['type'] == "application/pdf")
{
$ext = 'pdf';
}
if($_FILES['sdl']['type'] == "application/msexcel")
{
$ext = 'xls';
}
if($_FILES['sdl']['type'] == "application/msword")
{
$ext = 'doc';
}
if($_FILES['sdl']['type'] == "text/plain")
{
$ext = 'txt';
}
$sdlbezeichnung = str_replace(" ", "_", $bezeichnung);
$sdlbezeichnung = strtolower($sdlbezeichnung);
$sdlbezeichnung = str_replace("ö", "oe", $sdlbezeichnung);
$sdlbezeichnung = str_replace("ä", "ae", $sdlbezeichnung);
$sdlbezeichnung = str_replace("ü", "ue", $sdlbezeichnung);
$sdlbezeichnung = str_replace("ß", "ss", $sdlbezeichnung);
$sdlartikelnummer = str_replace(" ", "_", $artikelnummer);
$sdlartikelnummer = strtolower($sdlartikelnummer);
$sdlartikelnummer = str_replace("ö", "oe", $sdlartikelnummer);
$sdlartikelnummer = str_replace("ä", "ae", $sdlartikelnummer);
$sdlartikelnummer = str_replace("ü", "ue", $sdlartikelnummer);
$sdlartikelnummer = str_replace("ß", "ss", $sdlartikelnummer);
$filename = 'sdl_'.$sdlartikelnummer.'_'.$sdlbezeichnung.'.'.$ext;
move_uploaded_file($_FILES['sdl']['tmp_name'], "../docs/".$filename);
$oldsdl= '/docs/'.$filename;
}
}
}
if($killpdl == "1") //Produktdatenblatt
{
if(!eregi("#" , $oldpdl))
{
unlink(PFAD.$oldpdl);
}
$oldpdl = '#';
}
else
{
if($_FILES[pdl][error] == 0)
{
if($_FILES['pdl']['type'] == "application/pdf" | $_FILES['pdl']['type'] == "application/msexcel" | $_FILES['pdl']['type'] == "application/msword" | $_FILES['pdl']['type'] == "text/plain")
{
$filename = PFAD.$oldpdl;
if (file_exists($filename)) { unlink($filename); }
if($_FILES['pdl']['type'] == "application/pdf")
{
$ext = 'pdf';
}
if($_FILES['pdl']['type'] == "application/msexcel")
{
$ext = 'xls';
}
if($_FILES['pdl']['type'] == "application/msword")
{
$ext = 'doc';
}
if($_FILES['pdl']['type'] == "text/plain")
{
$ext = 'txt';
}
$pdlbezeichnung = str_replace(" ", "_", $bezeichnung);
$pdlbezeichnung = strtolower($sdlbezeichnung);
$pdlbezeichnung = str_replace("ö", "oe", $pdlbezeichnung);
$pdlbezeichnung = str_replace("ä", "ae", $pdlbezeichnung);
$pdlbezeichnung = str_replace("ü", "ue", $pdlbezeichnung);
$pdlbezeichnung = str_replace("ß", "ss", $pdlbezeichnung);
$pdlartikelnummer = str_replace(" ", "_", $artikelnummer);
$pdlartikelnummer = strtolower($sdlartikelnummer);
$pdlartikelnummer = str_replace("ö", "oe", $pdlartikelnummer);
$pdlartikelnummer = str_replace("ä", "ae", $pdlartikelnummer);
$pdlartikelnummer = str_replace("ü", "ue", $pdlartikelnummer);
$pdlartikelnummer = str_replace("ß", "ss", $pdlartikelnummer);
$filename = 'pdl_'.$pdlartikelnummer.'_'.$pdlbezeichnung.'.'.$ext;
move_uploaded_file($_FILES['pdl']['tmp_name'], "../docs/".$filename);
$oldpdl= '/docs/'.$filename;
}
}
}
if($neu == 'neu') //wird ein neuer Artikel angelegt der sich Freigaben (eine Art Warengruppen teilt)
{
if(freeposition("NULL", $position, 'artikel') == "done")
{
$ptextcontent = str_replace('\n', "", $ptextcontent);
(Sequenz gekürzt)
$ptextcontent = str_replace("'", ''', $ptextcontent);
$btextcontent = str_replace("'", ''', $btextcontent);
$query2 = "INSERT INTO `artikel` (
`PRIMARY` ,
`bezeichnung` ,
`artikelnummer` ,
`position` ,
`bild`,
`hersteller` ,
`warengruppe` ,
`erstellt`,
`geaendert`,
`produktbeschreibung` ,
`gebinde` ,
`freigabe` ,
`bestellt` ,
`verkauft` ,
`sdl` ,
`pdl` ,
`bemerkungen` ,
`vk1` ,
`vk2` ,
`vk3` ,
`aktivlieferant` ,
`shop`
)
VALUES (
NULL , '".$bezeichnung."', '".$artikelnummer."', '".$position."', '/images/blank.gif', '".$hersteller."', '".$warengruppe."', NOW(), NOW(), '".$ptextcontent."', '".$gebindeid."', '".$freigabe."', '".$bestellt."', '".$verkauft."', '".$oldsdl."', '".$oldpdl."', '".$btextcontent."', '".$vk1."', '".$vk2."', '".$vk3."', '".$aktivlieferant."', '".$shop."')";
Print 'Query2<br>'.$query2.'<br>';
$result = mysql_query($query2);
orderposition('artikel'); //Funktion die die Positionen ordnet. Geprüft geht.
$lastinsertid = mysql_insert_id();
global $fgquery;
fginsert($freigabe);
Print 'fgqueryneu<br>'.$fgquery.'<br>';
$result = mysql_query($fgquery);
/* ausführen einer SQL Anfrage */
#mysql_free_result($result);
}
}
elseif($neu == 'complete') //Neuer Artikel mit eigenen Warenfreigaben
{
if(freeposition("NULL", $position, 'artikel') == "done") //Freeposition ist auch getestet und geht
{
$ptextcontent = str_replace('\n', "", $ptextcontent);
$ptextcontent = str_replace('\r', "", $ptextcontent);
$ptextcontent = str_replace('<font', "", $ptextcontent);
$ptextcontent = str_replace('<a', "", $ptextcontent);
$ptextcontent = str_replace('<P class', "", $ptextcontent);
$ptextcontent = str_replace('style=', "", $ptextcontent);
$ptextcontent = str_replace('<SPAN', "", $ptextcontent);
$btextcontent = str_replace('\n', "", $btextcontent);
$btextcontent = str_replace('\r', "", $btextcontent);
$btextcontent = str_replace('<font', "", $btextcontent);
$btextcontent = str_replace('<a', "", $btextcontent);
$btextcontent = str_replace('<P class', "", $btextcontent);
$btextcontent = str_replace('style=', "", $btextcontent);
$btextcontent = str_replace('<SPAN', "", $btextcontent);
$ptextcontent = str_replace('<FONT face=Arial size=2>', "", $ptextcontent);
$btextcontent = str_replace('<FONT face=Arial size=2>', "", $btextcontent);
$ptextcontent = str_replace('<FONT face=Arial size=2>', "", $ptextcontent);
$btextcontent = str_replace('<FONT face=Arial size=2>', "", $btextcontent);
$ptextcontent = str_replace('</FONT>', "", $ptextcontent);
$btextcontent = str_replace('</FONT>', "", $btextcontent);
$ptextcontent = str_replace('</font>', "", $ptextcontent);
$btextcontent = str_replace('</font>', "", $btextcontent);
$ptextcontent = str_replace('<FONT class=normal>', "", $ptextcontent);
$btextcontent = str_replace('<FONT class=normal>', "", $btextcontent);
$ptextcontent = str_replace('"', '"', $ptextcontent);
$btextcontent = str_replace('"', '"', $btextcontent);
$ptextcontent = str_replace("'", ''', $ptextcontent);
$btextcontent = str_replace("'", ''', $btextcontent);
$freigabenquery = "INSERT INTO `db219262`.`freigaben` (Query gekürzt) ";
mysql_query($freigabenquery) or die("Anfrage fehlgeschlagen: " . mysql_error());
$lastid = mysql_insert_id();
Print '<br><br>'.$freigabenquery.'<br>'.$lastinsertid.'<br>';
$query2 = "INSERT INTO `artikel` (
`PRIMARY` ,
`bezeichnung` ,
`artikelnummer` ,
`position` ,
`bild`,
`hersteller` ,
`warengruppe` ,
`erstellt`,
`geaendert`,
`produktbeschreibung` ,
`gebinde` ,
`freigabe` ,
`bestellt` ,
`verkauft` ,
`sdl` ,
`pdl` ,
`bemerkungen` ,
`vk1` ,
`vk2` ,
`vk3` ,
`aktivlieferant` ,
`shop`
)
VALUES (
NULL , '".$bezeichnung."', '".$artikelnummer."', '".$position."', '/images/blank.gif', '".$hersteller."', '".$warengruppe."', NOW(), NOW(), '".$ptextcontent."', '".$gebindeid."', '".$lastid."', '".$bestellt."', '".$verkauft."', '".$oldsdl."', '".$oldpdl."', '".$btextcontent."', '".$vk1."', '".$vk2."', '".$vk3."', '".$aktivlieferant."', '".$shop."')";
$result = mysql_query($query2);
orderposition('artikel');
Print 'Query2<br>'.$query2.'<br>';
}
}
#if else neu=neu
elseif($neu == 'speichern') // Das probiere ich immer und es bereitet den Fehler 500. Die anderen beiden (neu und complete)verursachen den 500 bei den gleichen Artikeln auch.
{
if(freeposition($PRIMARY, $position, 'artikel') == "done")
{
$ptextcontent = str_replace('\n', "", $ptextcontent);
(Sequenz gekürzt wegen Postlimit, ist wie oben)
$ptextcontent = str_replace('"', '"', $ptextcontent);
$btextcontent = str_replace('"', '"', $btextcontent);
$ptextcontent = str_replace("'", ''', $ptextcontent);
$btextcontent = str_replace("'", ''', $btextcontent);
$query = 'UPDATE `artikel`
SET
`bezeichnung` = "'.$bezeichnung.'",
`artikelnummer` = "'.$artikelnummer.'",
`position` = '.$position.',
`bild` = "'.$oldbild.'",
`hersteller` = "'.$hersteller.'",
`warengruppe` = "'.$warengruppe.'",
`geaendert` = NOW(),
`produktbeschreibung` = "'.$ptextcontent.'",
`gebinde` = "'.$gebindeid.'",
`freigabe` = '.$freigabe.',
`bestellt` = '.$bestellt.',
`verkauft` = '.$verkauft.',
`sdl` = "'.$oldsdl.'",
`pdl` = "'.$oldpdl.'",
`bemerkungen` = "'.$btextcontent.'",
`vk1` = '.$vk1.',
`vk2` = '.$vk2.',
`vk3` = '.$vk3.',
`aktivlieferant` = "'.$aktivlieferant.'",
`shop` = '.$shop.' WHERE `PRIMARY` = '.$PRIMARY;
Print 'Query Update<br>'.$query.'<br>';
$result = mysql_query($query);
/* ausführen einer SQL Anfrage */
global $fgquery;
fginsert($freigabe);
Print 'fgquery Update<br>'.$fgquery.'<br>';
$result = mysql_query($fgquery);
/* ausführen einer SQL Anfrage */
#mysql_free_result($result);
foreach($lieferanten as $name=>$value)
{
global $PRIMARY;
$lieferquery = 'SELECT artikel2preise.lieferbedingungen from artikel2preise JOIN lieferbedingungen ON lieferbedingungen.PRIMARY = artikel2preise.lieferbedingungen WHERE lieferbedingungen.lieferantenid = '.$value;
$result = mysql_query($lieferquery) or die("Anfrage fehlgeschlagen: " . mysql_error());
$lieferbed = mysql_fetch_row($result);
$preis = 'lnettopreis'.$value;
$preis = $$preis;
$preis = $preis * 100;
$artikel2preiseupdate = 'UPDATE `artikel2preise` SET `nettopreis` = '.$preis.' WHERE `artikelid` = '.$PRIMARY.' AND lieferbedingungen = '.$lieferbed[0];
Print 'art2preis Update<br>'.$artikel2preiseupdate.'<br>';
mysql_query($artikel2preiseupdate);
$fracht = 'lfracht'.$value;
$fracht = $$fracht;
$fracht = $fracht * 100;
$lieferbedupdate = 'UPDATE `lieferbedingungen` SET `fracht` = '.$fracht.' WHERE PRIMARY = '.$lieferbed[0];
Print 'lieferbed Update<br>'.$lieferbedupdate.'<br>';
mysql_query($lieferbedupdate);
}
}
}
Print "<br>gespeichert<br>";
db_close($link);
Print '<br><br><a href="artikeledit.php?key='.$position.'" class="link">Artikeledit</a> <a href="artikel.php" class="link">Artikel Liste</a>';
orderposition('artikel');
optimize('artikel');
?>