* @version 1.1 */ class HTMLConvert{ var $filename = "temp.html"; var $HTMLTEXTxml; var $HTMLTEXausgabe; var $HTMLTEXstatus=array(); var $HTMLTEXstatus_name=""; /** * Konvertiert HTMLText zu Text * * @param string html * @return string text */ function HTML2Text($HTML){ $HTML = strip_tags($HTML); $HTML = html_entity_decode($HTML); $HTML = trim(str_replace("€","",$HTML)); return $HTML; } /** * Konvertiert einen Text zum HTML Zeichen * @param string $text * @return string $HTML */ function Text2HTML($text){ $text = str_replace("","ä",$text); $text = str_replace("","ü",$text); $text = str_replace("","ö",$text); $text = str_replace("","Ä",$text); $text = str_replace("","Ü",$text); $text = str_replace("","Ö",$text); $text = str_replace("","ß",$text); return $text; } /** * Entfernt HTML Tags * * @param String html * @param String tag * @return String bereingtes HTML */ function DeleteTag($html,$tag){ $Status=0; $TempHTML=""; if ($tag == "*"){ /* $html = preg_replace("/\<(.*?)\>/si", "", $html); $html = preg_replace("/\<\/(.*?)\>/si", "", $html); */ $TempHTML=strip_tags($html); }else{ $html = preg_replace("/<$tag(.*?)>/si", "", $html); $html = preg_replace("/<\/$tag(.*?)>/si", "", $html); $TempHTML=$html; /* for ($i=0 ; $i<=strlen($html); $i++){ if (strtolower(substr($html,$i,strlen($tag) + 1)) == "<" . strtolower($tag)){$Status=1;$i=$i+strlen($tag) + 1;} if (strtolower(substr($html,$i,strlen($tag) + 2)) == ""){$Status=0;} } } */ } return $TempHTML; } /** * Liefert den Inhalt eines Tags * * TODO: Muss noch besser ausgebaut werden */ function getHTMLTag($html, $tag){ $Inhalt=""; for ($i = 0 ; $i <= strlen($html) ; $i++){ if (strtolower(substr($html,$i,(strlen($tag)+2) )) == "<" . strtolower($tag) . ">"){$status=1;$i=$i+strlen($tag)+2;} if (strtolower(substr($html,$i,(strlen($tag)+3) )) == ""){$status=0;break;} if ($status==1){$Inhalt .= substr($html,$i,1);} } return $Inhalt; } /** * Konvertiert Text zu HTML Konformen Text * * @param String wert * @return String html **/ function HTMLencode($wert){ $Sonderzeichen = get_html_translation_table(HTML_ENTITIES); $Sonderzeichen["<"]="<"; $Sonderzeichen[">"]=">"; return strtr($wert,$Sonderzeichen); } /** * Konvertiert HTML zu Text * * @param String wert * @return String text **/ function HTMLdecode($wert){ $Sonderzeichen = get_html_translation_table(HTML_ENTITIES); $Sonderzeichen["<"]="<"; $Sonderzeichen[">"]=">"; foreach ($Sonderzeichen as $id => $value){ $SonderzeichenAnders[$value]=$id; } return strtr($wert,$SonderzeichenAnders); } function FlashHTMLencode($wert){ $Sonderzeichen["\""]="""; $$Sonderzeichen["/"]="/"; $Sonderzeichen[";"]=";"; $Sonderzeichen["<"]="<"; $Sonderzeichen[">"]=">"; $Sonderzeichen[";"]=";"; $Sonderzeichen["="]="="; $Sonderzeichen["#"]="#"; $Sonderzeichen["&"]="&"; $Sonderzeichen["!"]="!"; $Sonderzeichen["$"]="$"; $Sonderzeichen["%"]="%"; $Sonderzeichen["'"]="'"; $Sonderzeichen["("]="("; $Sonderzeichen[")"]=")"; $Sonderzeichen["*"]="*"; $Sonderzeichen["+"]="+"; $Sonderzeichen[","]=","; $Sonderzeichen["-"]="-"; $Sonderzeichen["."]="."; $Sonderzeichen[":"]=":"; $Sonderzeichen["?"]="?"; $Sonderzeichen["@"]="@"; $Sonderzeichen["["]="["; $Sonderzeichen["\\"]="\"; $Sonderzeichen["]"]="]"; $Sonderzeichen["^"]="^"; $Sonderzeichen["_"]="_"; $Sonderzeichen["`"]="`"; $Sonderzeichen[""]="€"; $Sonderzeichen["-"]="­"; $Sonderzeichen["'"]="´"; $Sonderzeichen[","]="¸"; $temp = $wert; foreach ($Sonderzeichen as $id => $value){ $temp = str_replace($id,$value,$temp); } return $temp; } function FlashHTMLdecode($wert){ $Sonderzeichen["\""]="""; $$Sonderzeichen["/"]="/"; $Sonderzeichen[";"]=";"; $Sonderzeichen["<"]="<"; $Sonderzeichen[">"]=">"; $Sonderzeichen[";"]=";"; $Sonderzeichen["="]="="; $Sonderzeichen["#"]="#"; $Sonderzeichen["&"]="&"; $Sonderzeichen["!"]="!"; $Sonderzeichen["$"]="$"; $Sonderzeichen["%"]="%"; $Sonderzeichen["'"]="'"; $Sonderzeichen["("]="("; $Sonderzeichen[")"]=")"; $Sonderzeichen["*"]="*"; $Sonderzeichen["+"]="+"; $Sonderzeichen[","]=","; $Sonderzeichen["-"]="-"; $Sonderzeichen["."]="."; $Sonderzeichen[":"]=":"; $Sonderzeichen["?"]="?"; $Sonderzeichen["@"]="@"; $Sonderzeichen["["]="["; $Sonderzeichen["\\"]="\"; $Sonderzeichen["]"]="]"; $Sonderzeichen["^"]="^"; $Sonderzeichen["_"]="_"; $Sonderzeichen["`"]="`"; $Sonderzeichen[""]="€"; $Sonderzeichen["|"]="¦"; $Sonderzeichen["-"]="­"; $Sonderzeichen["'"]="´"; $Sonderzeichen[","]="¸"; $temp = $wert; foreach ($Sonderzeichen as $id => $value){ $temp = str_replace($value,$id,$temp); } return $temp; } } ?> * @version 1.1 */ class HTMLObjekte{ var $db; /** * Konstruktor */ function __construct(){$this->HTMLObjekte();} function HTMLObjekte(){ $c = new Connection(); $this->db=$c->get(); $this->db->SetFetchMode(ADODB_FETCH_BOTH); } /** * getSelectBySQL */ function getSelectBySQL($name,$sql,$selected,$size=1,$addData=array()){ $HTML=""; if ($sql){ $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ $HTML=""; } } return $HTML; } function getSelectByArray($name,$daten=array(),$selected,$size=1){ $html=""; return $html; } /** * Liefert einen Wert aus der Datenbank zurueck */ function getWert($sql){ $wert=""; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ $wert = $rs->fields(0); } return $wert; } /** * Liefert eine STab View zurueck * * @param $elemente * @return string $html */ function getSTab($elemente){ } /** * Erzeugt eine Tabelle, die farbliche Zeilen hat * @return unknown_type */ function getTable($header=array(),$daten=array(),$optionen=array()){ // Header $HTML=""; foreach ($header as $id => $value){ $HTML.=""; } $HTML.=""; // Daten $Zaehler=0; $HTML.=""; foreach ($daten as $id => $value){ foreach ($value as $id1 => $value1){ $HTML.=""; if ($Zaehler >= 1){$Zaehler=0;} } } $HTML.=""; } } ?> * @version 1.1 */ class HTMLTemplate{ /** * Konstruktor */ function HTMLTemplate(){ } /** * get - Liefert ein geparstes Template */ function get($filename,$austauschen=array()){ $HTML=""; if (file_exists($filename)){ $F=new Filesystem(); $HTML=$F->fread($filename); if (is_array($austauschen)){ foreach ($austauschen as $id => $value){ $HTML=str_replace("{\$".$id."}",$value,$HTML); $HTML=str_replace($id,$value,$HTML); } } } return $HTML; } } ?>widths=$w; } function SetAligns($a){ //Set the array of column alignments $this->aligns=$a; } function Header($line=0){ global $MyXStarConf; // Nettorechnung?? if ($this->Netto){ $TempFilename = DIR_FS_CATALOG . "includes/modules/XStar/images/rechnung_bg_netto.jpg"; if (file_exists($TempFilename)){ $this->Image($TempFilename,-5,50); } } if ($this->Leer==true){ }else{ // Header Logo setzten if ($this->Grafik){ $TempFilename = DIR_FS_CATALOG . "templates/" . CURRENT_TEMPLATE . "/img/fpdf_head.jpg"; if (file_exists($TempFilename)){ $this->image($TempFilename,-5,0,220); } if ($this->page == 1){ $this->SetFont($MyXStarConf["xstar_pdfrechnung_fontfamiliy_absender"],'U',$MyXStarConf["xstar_pdfrechnung_fontsize_absender"]); $this->text(25,53,$this->Absender); //$this->text(25,40,$this->Absender); NEU TODO: NACH ISO if ($MyXStarConf["xstar_pdfrechnung_anrede_in_anschriftbox"] == 1){ $this->SetFont($MyXStarConf["xstar_pdfrechnung_fontfamiliy_absender"],'',$MyXStarConf["xstar_pdfrechnung_fontsize_absender"]); $this->text(25,57,"Herr / Frau / Firma"); //$this->text(25,44,"Herr / Frau / Firma"); NEU TODO: NACH ISO } } } // Anschrift Platzieren $this->SetFont($MyXStarConf["xstar_pdfrechnung_fontfamiliy_anschrift"],'',$MyXStarConf["xstar_pdfrechnung_fontsize_anschrift"]); if ($line >= 1){ $this->Ln($line); }else{ if ($this->page == 1){ //$this->Ln(37); NEU TODO: NACH ISO $this->Ln(50); $this->MultiCell(100,5,$this->Empfaenger); //$this->Ln(10); NEU TODO: NACH ISO }else{ $this->Ln(30); } } // Falzmarken setzten $this->SetDrawColor(0); $this->Line(3,95,0,95); $this->Line(5,150,0,150); } } function Footer($line=0){ global $MyXStarConf; // Sonstige FooterInformationen setzten if ($this->Grafik){ $TempFilename = DIR_FS_CATALOG . "templates/" . CURRENT_TEMPLATE . "/img/fpdf_foot.jpg"; if (file_exists($TempFilename)){ $this->image($TempFilename,-5,260,220); } $Elemente=0; if ($MyXStarConf["xstar_pdfrechnung_fuss_1_1"]){$Elemente++;} if ($MyXStarConf["xstar_pdfrechnung_fuss_2_1"]){$Elemente++;} if ($MyXStarConf["xstar_pdfrechnung_fuss_3_1"]){$Elemente++;} if ($MyXStarConf["xstar_pdfrechnung_fuss_4_1"]){$Elemente++;} //print $Elemente;exit(); switch ($Elemente){ case 1: $Left1=10; break; case 2: $Left1=10; $Left2=$Left1+110; break; case 3: $Left1=10; $Left2=$Left1+50; $Left3=$Left2+50; break; case 4: $Left1=10; $Left2=$Left1+50; $Left3=$Left2+50; $Left4=$Left3+50; break; } $Top=278; if ($MyXStarConf["xstar_pdfrechnung_fuss_top"]>0){$Top=$MyXStarConf["xstar_pdfrechnung_fuss_top"];} if ($MyXStarConf["xstar_pdfrechnung_fuss_1_1"]){ $this->SetFont($MyXStarConf["xstar_pdfrechnung_fontfamiliy_fusszeile"],'',$MyXStarConf["xstar_pdfrechnung_fontsize_fusszeile"]); $this->text ($Left1,$Top,$MyXStarConf["xstar_pdfrechnung_fuss_1_1"]); $this->text ($Left1,$Top+3,$MyXStarConf["xstar_pdfrechnung_fuss_1_2"]); $this->text ($Left1,$Top+3+3,$MyXStarConf["xstar_pdfrechnung_fuss_1_3"]); $this->text ($Left1,$Top+3+3+3,$MyXStarConf["xstar_pdfrechnung_fuss_1_4"]); } if ($MyXStarConf["xstar_pdfrechnung_fuss_2_1"]){ $this->SetFont($MyXStarConf["xstar_pdfrechnung_fontfamiliy_fusszeile"],'',$MyXStarConf["xstar_pdfrechnung_fontsize_fusszeile"]); $this->text ($Left2,$Top,$MyXStarConf["xstar_pdfrechnung_fuss_2_1"]); $this->text ($Left2,$Top+3,$MyXStarConf["xstar_pdfrechnung_fuss_2_2"]); $this->text ($Left2,$Top+3+3,$MyXStarConf["xstar_pdfrechnung_fuss_2_3"]); $this->text ($Left2,$Top+3+3+3,$MyXStarConf["xstar_pdfrechnung_fuss_2_4"]); } if ($MyXStarConf["xstar_pdfrechnung_fuss_3_1"]){ $this->SetFont($MyXStarConf["xstar_pdfrechnung_fontfamiliy_fusszeile"],'',$MyXStarConf["xstar_pdfrechnung_fontsize_fusszeile"]); $this->text ($Left3,$Top,$MyXStarConf["xstar_pdfrechnung_fuss_3_1"]); $this->text ($Left3,$Top+3,$MyXStarConf["xstar_pdfrechnung_fuss_3_2"]); $this->text ($Left3,$Top+3+3,$MyXStarConf["xstar_pdfrechnung_fuss_3_3"]); $this->text ($Left3,$Top+3+3+3,$MyXStarConf["xstar_pdfrechnung_fuss_3_4"]); } if ($MyXStarConf["xstar_pdfrechnung_fuss_4_1"]){ $this->SetFont($MyXStarConf["xstar_pdfrechnung_fontfamiliy_fusszeile"],'',$MyXStarConf["xstar_pdfrechnung_fontsize_fusszeile"]); $this->text ($Left4,$Top,$MyXStarConf["xstar_pdfrechnung_fuss_4_1"]); $this->text ($Left4,$Top+3,$MyXStarConf["xstar_pdfrechnung_fuss_4_2"]); $this->text ($Left4,$Top+3+3,$MyXStarConf["xstar_pdfrechnung_fuss_4_3"]); $this->text ($Left4,$Top+3+3+3,$MyXStarConf["xstar_pdfrechnung_fuss_4_4"]); } } // Seitenummer setzten if ($line){ }else{ if(!$this->footerset[$this->page]) { $this->SetY(-25); $this->Ln(7); //$this->Cell(175,5,$this->page,0,0,C); } } } function Row($data){ //Calculate the height of the row $nb=0; for($i=0;$iNbLines($this->widths[$i], $data[$i])); $h=(4*$nb); if (isset($this->Config->Conf["descriptioninorder"])){ if ($this->Config->Conf["descriptioninorder"] == "true"){ //$h=(2.5*$nb); $h=(4*$nb); }else{ $h=(5*$nb); } } $h=(5*$nb); //Issue a page break first if needed $this->CheckPageBreak($h); //Draw the cells of the row // Hintergrund $this->SetFillColor(227, 227, 227); for($i=0;$iwidths[$i]; $a=isset($this->aligns[$i]) ? $this->aligns[$i] : 'L'; //Save the current position $x=$this->GetX(); $y=$this->GetY(); //Draw the border if($this->TabellenRahmen == 1){ $this->Rect($x, $y, $w, $h); } //Print the text $this->MultiCell($w, 5, $data[$i], 0, $a, 0); //Put the position to the right of the cell $this->SetXY($x+$w, $y); } if ($this->StatusZeileFarbe==true){ $this->StatusZeileFarbe=false; }else{ $this->StatusZeileFarbe=true; } //Go to the next line $this->Ln($h); } function CheckPageBreak($h){ //If the height h would cause an overflow, add a new page immediately if($this->GetY()+$h>$this->PageBreakTrigger) $this->AddPage($this->CurOrientation); } function NbLines($w, $txt){ //Computes the number of lines a MultiCell of width w will take $cw=&$this->CurrentFont['cw']; if($w==0) $w=$this->w-$this->rMargin-$this->x; $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; $s=str_replace("\r", '', $txt); $nb=strlen($s); if($nb>0 and $s[$nb-1]=="\n") $nb--; $sep=-1; $i=0; $j=0; $l=0; $nl=1; while($i<$nb) { $c=$s[$i]; if($c=="\n") { $i++; $sep=-1; $j=$i; $l=0; $nl++; continue; } if($c==' ') $sep=$i; $l+=$cw[$c]; if($l>$wmax) { if($sep==-1) { if($i==$j) $i++; } else $i=$sep+1; $sep=-1; $j=$i; $l=0; $nl++; } else $i++; } return $nl; } var $B=0; var $I=0; var $U=0; var $HREF=''; var $ALIGN=''; function WriteHTML($html){ //HTML parser $html=str_replace("\n", ' ', $html); $a=preg_split('/<(.*)>/U', $html, -1, PREG_SPLIT_DELIM_CAPTURE); foreach($a as $i=>$e) { if($i%2==0) { //Text if($this->HREF) $this->PutLink($this->HREF, $e); elseif($this->ALIGN == 'center') $this->Cell(0, 5, $e, 0, 1, 'C'); else $this->Write(5, $e); } else { //Tag if($e{0}=='/') $this->CloseTag(strtoupper(substr($e, 1))); else { //Extract properties $a2=split(' ', $e); $tag=strtoupper(array_shift($a2)); $prop=array(); foreach($a2 as $v) if(ereg('^([^=]*)=["\']?([^"\']*)["\']?$', $v, $a3)) $prop[strtoupper($a3[1])]=$a3[2]; $this->OpenTag($tag, $prop); } } } } function OpenTag($tag, $prop){ //Opening tag if($tag=='STRONG'){ $this->SetStyle('B', true); } if($tag=='B' or $tag=='I' or $tag=='U') $this->SetStyle($tag, true); if($tag=='A') $this->HREF=$prop['HREF']; if($tag=='BR') $this->Ln(5); if($tag=='P') $this->Ln(5); $this->ALIGN=$prop['ALIGN']; if($tag=='HR') { if( $prop['WIDTH'] != '' ) $Width = $prop['WIDTH']; else $Width = $this->w - $this->lMargin-$this->rMargin; $this->Ln(2); $x = $this->GetX(); $y = $this->GetY(); $this->SetLineWidth(0.4); $this->Line($x, $y, $x+$Width, $y); $this->SetLineWidth(0.2); $this->Ln(2); } } function CloseTag($tag){ //Closing tag if($tag=='STRONG'){ $this->SetStyle('B', false); } if($tag=='B' or $tag=='I' or $tag=='U') $this->SetStyle($tag, false); if($tag=='A') $this->HREF=''; if($tag=='P') $this->ALIGN=''; } function SetStyle($tag, $enable){ //Modify style and select corresponding font $this->$tag+=($enable ? 1 : -1); $style=''; foreach(array('B', 'I', 'U') as $s) if($this->$s>0) $style.=$s; $this->SetFont('', $style); } function PutLink($URL, $txt){ //Put a hyperlink $this->SetTextColor(0, 0, 255); $this->SetStyle('U', true); $this->Write(5, $txt, $URL); $this->SetStyle('U', false); $this->SetTextColor(0); } } ?> * @version 1.5 * * Anpassungen SQL: * * Die categorie_id und parent_id muss von int auf bigint in den Tabellen (categories, categories_description und products_to_categories) angepasst werden * * Version 1.4 * - Bilder werden auf veraenderung geprueft und nicht grundsaetzlich neu erzeugt * - Nach einem Import werden restliche Bilder geloescht * - loeschen.xml - ALLESLOESCHEN wird beruecksichtigt * * Version 1.5 * - komplette Startmethode wurde angepasst (Parameter: START, TODO, INFO) * * Version 1.5.1 * - Preismenge wird im XTC angelegt und auch befuellt. Beim Datenexport wird die Preismenge mit exportiert. * * Version 1.5.2 * - Produktfilter im __construct angepasst, so dass nicht immer alles komplett aktualisiert wird * - cleanDatabase hinzugef�gt **/ /* error_reporting(E_ALL & ~E_NOTICE); ini_set("display_errors", 1); */ class SyncMercator{ var $Programmname="Synchronisationsmodul Mercator - XTCommerce v 1.5.3"; var $TODID=0; var $Counts=array(); var $Debug=false; var $db; var $fs; var $Meldungen=array(); var $PathImport=""; var $PathExport=""; var $Status_PRODUCTS_TO_CATEGORIES=false; var $TimeFileOrder=""; var $TimeFileCron=""; var $ArtikelKinder=array(); var $DeleteFiles=false; var $Config; var $SendStatusEmail=false; var $StdKundengruppe=0; var $ModulMindesbestellmenge=false; var $CSSFileLink; function __construct($leise=false, $cron=false){$this->SyncMercator($leise,$cron);} function __destruct(){ if ($this->Debug){$this->setStatus(date("r",time()));} } function SyncMercator($leise=false, $cron=false){ if (isset($_GET["DEBUG"])){$this->Debug=true;} if ($this->Debug){$this->setStatus(date("r",time()));} // Datenbankverbindung $temp = new Connection(); $this->db = $temp->get(); //$this->db->debug=true; $this->createTables(); // erstmal einiges definieren $this->fs = new Filesystem(); $this->Config = new Config(); // Optimierungen durchfuerhen, wenn noch nicht geschehen $TempSyncOpt=$this->Config->get("xstar_sync_mercator_opt"); if ($TempSyncOpt<1){ $sql = "CREATE INDEX syncwawi_idx USING BTREE ON syncwawi (sort , erledigt, in_bearbeitung);"; $this->db->Execute($sql); $sql = "CREATE INDEX products_idx USING BTREE ON products (products_model);"; $this->db->Execute($sql); $sql = "CREATE INDEX products_vpe_idx USING BTREE ON products_vpe (products_vpe_id, products_vpe_name);"; $this->db->Execute($sql); $sql = "CREATE INDEX products_options_values_idx USING BTREE ON products_options_values (products_options_values_name);"; $this->db->Execute($sql); $sql = "CREATE INDEX products_options_idx USING BTREE ON products_options (products_options_name);"; $this->db->Execute($sql); $sql = "CREATE INDEX products_options_values_to_products_options_idx USING BTREE ON products_options_values_to_products_options (products_options_id, products_options_values_id);"; $this->db->Execute($sql); $sql = "CREATE INDEX temp_xtc_warnhinweise_idx USING BTREE ON temp_xtc_warnhinweise (products_id);"; $this->db->Execute($sql); for ($i=0; $i<=15; $i++){ $sql = "CREATE INDEX personal_offers_by_customers_status_" . $i . "_idx USING BTREE ON personal_offers_by_customers_status_" . $i . " ( products_id , quantity);"; $this->db->Execute($sql); } $sql = "CREATE INDEX products_images_idx USING BTREE ON products_images (products_id);"; $this->db->Execute($sql); $this->Config->set("xstar_sync_mercator_opt",1); } // Stylen $this->CSSFileLink=DIR_WS_DOCUMENT_ROOT_XSTAR."/style/SyncMercator.css"; // Verzeichnisse definieren if ($_SERVER["HTTP_HOST"] == "mobabau.de" || $_SERVER["HTTP_HOST"] == "www.mobabau.de" || $_SERVER["HTTP_HOST"] == "www.mobabau.com" || $_SERVER["HTTP_HOST"] == "mobabau.com" || $_SERVER["HTTP_HOST"] == "www.hmw-teich.de" || $_SERVER["HTTP_HOST"] == "hmw-teich.de"){ $this->PathImport=DIR_FS_DOCUMENT_ROOT."/mercator/import/"; $this->PathExport=DIR_FS_DOCUMENT_ROOT."/mercator/export/"; $this->TimeFileOrder=DIR_FS_DOCUMENT_ROOT_XSTAR."/includes/modules/sync_mercator_ordertime.txt"; $this->TimeFileCron=DIR_FS_DOCUMENT_ROOT."/mercator/import/status.txt"; }else{ $this->PathImport=DIR_FS_DOCUMENT_ROOT."/import/mercator/"; $this->PathExport=DIR_FS_DOCUMENT_ROOT."/export/mercator/"; $this->TimeFileOrder=DIR_FS_DOCUMENT_ROOT_XSTAR."/includes/modules/sync_mercator_ordertime.txt"; $this->TimeFileCron=DIR_FS_DOCUMENT_ROOT."/import/mercator/status.txt"; } // Sind alle Verzeichnisse vorhanden if (!is_dir($this->PathImport)){mkdir($this->PathImport,0777);} if (!is_dir($this->PathImport."/daten/")){mkdir($this->PathImport."/daten/",0777);} if (!is_dir($this->PathImport."/bilder/")){mkdir($this->PathImport."/bilder/",0777);} if (!is_dir($this->PathExport)){mkdir($this->PathExport,0777);} if (!is_dir($this->PathExport."/daten/")){mkdir($this->PathExport."/daten/",0777);} if (!is_dir($this->PathExport."/logs/")){mkdir($this->PathExport."/logs/",0777);} // HTML Startkopf $HTMLStartkopf=$this->getCSS(); $HTMLStartkopf.="

" . $this->Programmname . "
copyright by WEBDESIGN-RÜSTMANN 2009 - " . date("Y",time()) . "

"; // Los geht es - Neustart? if (isset($_GET["START"])){ $this->TODOID=time(); print $HTMLStartkopf; $this->setStatus("Sync wurde gestartet"); // Datenbank bereinigen $sql = "DELETE FROM syncwawi"; $this->db->Execute($sql); $this->addTODO("ID",$this->TODOID,0); // Was ist zu tun - Dateien lesen $PathInhalt=$this->fs->readDir($this->PathImport."/daten/"); if (count($PathInhalt) > 0){ // Neu sortieren $CountArtikelDatei=0; $CountLoeschDatei=0; $CountHerstellerDatei=0; $CountKundenDatei=0; $CountKategorienDatei=0; $TempPathInhalt=array(); foreach ($PathInhalt as $id => $value){ $TempZahl=explode("_",$value["name"]); $TempPathInhalt[$TempZahl[0].str_pad($TempZahl[1], 10 ,'0', STR_PAD_LEFT)]=$value; } ksort ($TempPathInhalt); $PathInhalt=$TempPathInhalt; // existiert eine komplett Loeschdatei und Dateien durchzählen foreach ($PathInhalt as $id => $value){ if (substr($value["name"],0,8)=="loeschen"){ $CountLoeschDatei++; $filename=$this->PathImport."daten/" . $value["name"]; if (file_exists($filename)){ $temp=$this->readXML($filename); if ($temp->ALLE_LOESCHEN == 1){ $this->setStatus("!!! ALLE ARTIKEL WERDEN GELÖSCHT","Fehler"); $this->addTODO("DELETEALL",1,-1); } } } // Hersteller if (substr($value["name"],0,14) == "temphersteller" || substr($value["name"],0,10) == "hersteller"){ $CountHerstellerDatei++; $this->addTODO("FILE",$value["name"],30); } // Lieferanten if (preg_match("/lieferanten/",$value["name"])){ $CountHerstellerDatei++; $this->addTODO("FILE",$value["name"],30); } // Katgeorien if (preg_match("/kategorien/",$value["name"])){ $this->addTODO("FILE",$value["name"],40); $CountKategorienDatei++; } // Artikel if (preg_match("/artikel/",$value["name"])){ $this->addTODO("FILE",$value["name"],10); $CountArtikelDatei++; } // Auftragstati if (preg_match("/auftraege/",$value["name"])){ $this->addTODO("FILE",$value["name"],10); $CountAuftragstatuDatei++; } // Kunden if (preg_match("/kunden/",$value["name"])){ $this->addTODO("FILE",$value["name"],20); $CountKundenDatei++; } // Loeschen if (preg_match("/loeschen/",$value["name"])){ $this->addTODO("FILE",$value["name"],-1); $CountLoeschDatei++; } } $this->setStatus("Anzahl Herstellerdateien: " . $CountHerstellerDatei); $this->setStatus("Anzahl Artikeldateien: " . $CountArtikelDatei); $this->setStatus("Anzahl Kundendateien: " . $CountKundenDatei); $this->setStatus("Anzahl Kategoriendateien: " . $CountKategorienDatei); $this->setStatus("Anzahl Loeschdateien: " . $CountKategorienDatei); $this->setStatus("Anzahl Auftragstati: " . $CountAuftragstatuDatei); } // Weitere TODOS erstellen if ($this->Config->get("xstar_syncmercator_bestellexport_separat") != 1){$this->addTODO("ORDER_EXPORT", "1",1);} $this->addTODO("ADDON", "addVarianten",900); $this->addTODO("ADDON", "sortVarianten",901); $this->addTODO("ADDON", "checkKategorien",902); $this->addTODO("ADDON", "sortKategorien",903); $this->addTODO("ADDON", "checkKundengruppen",904); $this->addTODO("ADDON", "deleteBildVerzeichnisse",905); $this->addTODO("ADDON", "checkImages",906); $this->addTODO("ADDON", "checkImagesDuplikate",907); $this->addTODO("ADDON", "clearDatabase",908); // Statusmeldung, dass CRON uebernimmt print ""; exit(); } // Infos zeigen if (isset($_GET["INFO"])){ print $HTMLStartkopf; $sql = "SELECT * FROM syncwawi WHERE erledigt = 0 AND art <> 'ID' ORDER BY sort, wert"; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ print "

 

"; print "

Folgende Aufgaben müssen noch durchgeführt werden.

"; print ""; }else{ print "

Keine Aufgaben vorhanden. Laden Sie mit Hilfe Ihrer Warenwirtschaft Dateien hoch und führen den Start Befehl aus.

"; } exit(); } // Protokoll anzeigen if (isset($_GET["PROTOKOLL"])){ print $HTMLStartkopf; $sql = "SELECT sync_id FROM syncwawi_log ORDER BY sync_id DESC LIMIT 1"; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ $sql = "SELECT * FROM syncwawi_log WHERE sync_id = '" . $rs->fields("sync_id") . "' ORDER BY datumuhrzeit"; print "

 

"; print "

Folgende Aufgaben wurden durchgeführt.

"; print ""; }else{ print "

Keine Aufgaben vorhanden.

"; print "

Laden Sie mit Hilfe Ihrer Warenwirtschaft Dateien auf Ihren Webserver führen den Start Befehl aus ([domain]/admin/sync_mercatro.php?START).

"; } exit(); } // Orderexport if (isset($_GET["ORDEREXPORT"])){ $this->OrderExport(); } // Test starten if (isset($_GET["TEST"])){ $filename=$this->PathImport."daten/artikel_178.xml"; $this->addArtikel($this->readXML($filename));$Status=true; $filename=$this->PathImport."daten/kategorien_1.xml"; $this->addKategorien($this->readXML($filename));$Status=true; //$this->OrderExport(1117); exit(); } // Aufgaben abarbeiten if (isset($_GET["TODO"])){ // Limit pruefen if ($this->Config->get("xstar_syncmercator_limit_gleichzeitige_verbindungen")>0){$limit=$this->Config->get("xstar_syncmercator_limit_gleichzeitige_verbindungen");}else{$limit=2;} $sql = "SELECT COUNT(*) AS anzahl FROM syncwawi WHERE in_bearbeitung=1"; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ if ($rs->fields("anzahl")>=$limit){exit();} } // Daten verarbeiten $sql = "SELECT id, art, wert FROM syncwawi WHERE erledigt=0 AND in_bearbeitung=0 AND art<>'ID' ORDER BY sort, id"; if (!isset($_GET["NOBREAK"])){$sql.=" LIMIT 1";} $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ while (!$rs->EOF){ $Status=false; require_once ('includes/classes/'.FILENAME_IMAGEMANIPULATOR); require_once (DIR_FS_INC.'xtc_get_products_mo_images.inc.php'); // Bearbeitungszustand setzten if (strtoupper($rs->fields("art")) != "ADDON"){ $sql = "UPDATE syncwawi SET in_bearbeitung=1 WHERE id = " . $rs->fields("id"); $this->db->Execute($sql); } // Los geht es switch (strtoupper($rs->fields("art"))){ case "ORDER_EXPORT": $this->OrderExport(); $Status=true; break; case "DELETEALL": $this->delArtikelAll(); $Status=true; break; case "FILE": $TempWert=strtolower($rs->fields("wert")); $filename=$this->PathImport."daten/".$rs->fields("wert"); // Artikel if (preg_match("/artikel/",$TempWert)){ $this->addArtikel($this->readXML($filename));$Status=true; } // Auftrag if (preg_match("/auftraege/",$TempWert)){ $this->setAuftragStatus($this->readXML($filename));$Status=true; } // Kategorien if (preg_match("/kategorien/",$TempWert)){ $this->addKategorien($this->readXML($filename));$Status=true; } // Hersteller if (preg_match("/hersteller/",$TempWert)){ $this->addHersteller($this->readXML($filename));$Status=true; } // Lieferanten if (preg_match("/lieferanten/",$TempWert)){ $this->addHersteller($this->readXML($filename));$Status=true; } // Kunden if (preg_match("/kunden/",$TempWert)){ $this->addKunden($this->readXML($filename));$Status=true; } // Loeschen if (preg_match("/loeschen/",$TempWert)){ $this->delArtikel($this->readXML($filename));$Status=true; } $this->deleteXML($filename); break; case "ADDON": $sql = "SELECT COUNT(*) AS anzahl FROM syncwawi WHERE art IN ('ORDER_EXPORT','FILE') AND erledigt = 0"; $rsspeicher = $this->db->Execute($sql); if (!$rsspeicher->EOF && $rsspeicher){ if ($rsspeicher->fields("anzahl")>0){exit();} } // Bearbeitungszustand setzten $sql = "UPDATE syncwawi SET in_bearbeitung=1 WHERE id = " . $rs->fields("id"); $this->db->Execute($sql); // Daten verarbeiten if ($rs->fields("wert") == "addVarianten"){$this->addVarianten();$Status=true;} if ($rs->fields("wert") == "sortVarianten"){$this->sortVarianten();$Status=true;} if ($rs->fields("wert") == "checkKategorien"){$this->checkKategorien();$Status=true;} if ($rs->fields("wert") == "sortKategorien"){$this->sortKategorien();$Status=true;} if ($rs->fields("wert") == "checkKundengruppen"){$this->checkKundengruppen();$Status=true;} if ($rs->fields("wert") == "deleteBildVerzeichnisse"){$this->deleteImportImages();$Status=true;} if ($rs->fields("wert") == "checkImages"){$this->checkImages();$Status=true;} if ($rs->fields("wert") == "checkImagesDuplikate"){$this->checkImagesDuplikate();$Status=true;} if ($rs->fields("wert") == "clearDatabase"){$this->clearDatabase();$Status=true;} break; } if ($Status == true){ $sql = "UPDATE syncwawi SET erledigt=1, in_bearbeitung=0 WHERE id = " . $rs->fields("id"); $this->db->Execute($sql); } $rs->MoveNext(); } }else{ $sql = "SELECT COUNT(*) AS anzahl FROM `syncwawi` WHERE erledigt = 0 AND art <> 'ID'"; $rs = $this->db->Execute($sql); if ($rs->fields("anzahl")==0){ $sql = "SELECT COUNT(*) AS anzahl FROM syncwawi WHERE art='ID'"; $rs = $this->db->Execute($sql); if ($rs->fields("anzahl")>0){ // Nicht mehr zu tun - Email versenden if ($this->Config->get("xstar_syncmercator_bestaetigungsemail") == 1){$this->sendMail();} // Sync ToDo leeren $sql = "DELETE FROM syncwawi"; $this->db->Execute($sql); } } } } } /** * Exportiert die benoetigten XML Dateien fuer Mercator **/ function OrderExport($orderid=0){ $this->setStatus("Bestellungen werden exportiert.","SubHeader"); // Existiert schon abfragefeld $sql = "SELECT sync_date FROM orders LIMIT 1"; $rs = $this->db->Execute($sql); if (!$rs){ $sql = "ALTER TABLE `orders` ADD `sync_date` DATETIME NULL DEFAULT NULL"; $this->db->Execute($sql); } // Steuersatz ermitteln $sql = "SELECT * FROM " . TABLE_TAX_RATES. " WHERE tax_rates_id = 1"; $rsspeichertax = $this->db->Execute($sql); $TAX=1.19; $TAXText="19,00"; if (!$rsspeichertax->EOF && $rsspeichertax){ $TAX=("1.".str_replace(".0000","",$rsspeichertax->fields("tax_rate"))); $TAXText=number_format ($rsspeichertax->fields("tax_rate"), 2 , "." , ""); } // Letzten Export ermitteln $TempTime = $this->fs->fread($this->TimeFileOrder); $ExportDatum = time(); $sql = "SELECT " . TABLE_ORDERS . ".*, " . TABLE_CUSTOMERS . ".customers_gender, " . TABLE_CUSTOMERS . ".customers_newsletter, " . TABLE_CUSTOMERS . ".customers_dob FROM " . TABLE_ORDERS . " INNER JOIN " . TABLE_CUSTOMERS . " ON " . TABLE_CUSTOMERS . ".customers_id = " . TABLE_ORDERS . ".customers_id "; if ($orderid > 0){ $sql .= "WHERE orders_id = " . $orderid . ""; }else{ $sql .= "WHERE sync_date IS NULL"; } // Zaehler ermitteln $temp=$this->fs->readDir($this->PathExport."/daten/"); if (count($temp)>0){ $TempZaehler=array(); foreach ($temp as $id => $value){ array_push($TempZaehler,str_replace(".xml","",str_replace("bestellungen_","",$id))); } sort($TempZaehler); $Zaehler=$TempZaehler[count($TempZaehler)-1]+1; }else{ $Zaehler=1; } $rs=$this->db->Execute($sql); if (!$rs->EOF && $rs){ while (!$rs->EOF){ $XML =""; $XML.="\n"; $XML.="\n"; $XML.="\t1\n"; $XML.="\t\n"; $XML.="\t\t\n"; if (trim($rs->fields("orders_cid"))){ $XML.=$this->getXMLNode(2,"NUMMER",$rs->fields("orders_cid")); }else{ $XML.=$this->getXMLNode(2,"NUMMER",$rs->fields("orders_id")); } $XML.=$this->getXMLNode(2,"DATUM",date("d.m.Y",strtotime($rs->fields("date_purchased")))); $XML.="\t\t\t\n"; $XML.=$this->getXMLNode(3,"KD_NR",$rs->fields("customers_id")); // Kundengruppen ausgeben $TempKundengruppe=$this->getKundengruppenNameSchnittstelle($rs->fields("customers_status")); /* $XML.=$this->getXMLNode(3,"PGR",$TempKundengruppe); $XML.=$this->getXMLNode(3,"KUNDENGRUPPE",$TempKundengruppe); * * 07.03.2011: In Schnittstelle Version 1.6 nicht mehr vorhanden */ switch ($rs->fields("customers_gender")){ case "m": $XML.=$this->getXMLNode(3,"ANREDE","Herr"); break; case "w": $XML.=$this->getXMLNode(3,"ANREDE","Frau"); break; default: $XML.=$this->getXMLNode(3,"ANREDE","Herr"); break; } $XML.=$this->getXMLNode(3,"VORNAME",$rs->fields("customers_firstname")); $XML.=$this->getXMLNode(3,"NAME1",$rs->fields("customers_lastname")); $XML.=$this->getXMLNode(3,"NAME2",$rs->fields("customers_company")); $XML.=$this->getXMLNode(3,"STRASSE",$rs->fields("customers_street_address")); if ($rs->fields("delivery_country_iso_code_2")){ $XML.=$this->getXMLNode(3,"LKZ",$rs->fields("delivery_country_iso_code_2")); }else{ $XML.=$this->getXMLNode(3,"LKZ","DE"); } $XML.=$this->getXMLNode(3,"PLZ",$rs->fields("customers_postcode")); $XML.=$this->getXMLNode(3,"ORT",$rs->fields("customers_city")); $XML.=$this->getXMLNode(3,"TEL1",$rs->fields("customers_telephone")); $XML.=$this->getXMLNode(3,"TEL2",""); $XML.=$this->getXMLNode(3,"FAX",""); $XML.=$this->getXMLNode(3,"EMAIL",$rs->fields("customers_email_address")); $XML.=$this->getXMLNode(3,"KTO_INHABER",""); $XML.=$this->getXMLNode(3,"KTO_KONTO",""); $XML.=$this->getXMLNode(3,"KTO_BLZ",""); $XML.=$this->getXMLNode(3,"KTO_BANK",""); $XML.=$this->getXMLNode(3,"UST_ID",$rs->fields("customers_vat_id")); if ($rs->fields("customers_dob")){ $TempDatum=date("d.m.Y",strtotime($rs->fields("customers_dob"))); $TempDatumArray=explode(".",$TempDatum); if (isset($TempDatumArray[2])){ if ($TempDatumArray[2]>1900){ $XML.=$this->getXMLNode(3,"GEB_TAG",$TempDatum); }else{ $XML.=$this->getXMLNode(3,"GEB_TAG",""); } }else{ $XML.=$this->getXMLNode(3,"GEB_TAG",""); } }else{ $XML.=$this->getXMLNode(3,"GEB_TAG",""); } // Newsletter if ($rs->fields("customers_newsletter") == 1){ $XML.=$this->getXMLNode(3,"NEWSLETTER",1); }else{ $XML.=$this->getXMLNode(3,"NEWSLETTER",0); } $XML.=$this->getXMLNode(3,"BONITAET",""); $XML.="\t\t\t\n"; $XML.="\t\t\t\n"; // Lieferanschift nur ausgeben wenn unterschiedlich if ($rs->fields("customers_firstname") != $rs->fields("delivery_firstname") || $rs->fields("customers_lastname") != $rs->fields("delivery_lastname") || $rs->fields("customers_company") != $rs->fields("delivery_company") || $rs->fields("customers_street_address") != $rs->fields("delivery_street_address") || $rs->fields("customers_state") != $rs->fields("delivery_state") || $rs->fields("customers_postcode") != $rs->fields("delivery_postcode") || $rs->fields("customers_city") != $rs->fields("delivery_city") ){ switch ($rs->fields("customers_gender")){ case "m": $XML.=$this->getXMLNode(3,"LI_ANREDE","Herr"); break; case "w": $XML.=$this->getXMLNode(3,"LI_ANREDE","Frau"); break; default: $XML.=$this->getXMLNode(3,"LI_ANREDE","Herr"); break; } $XML.=$this->getXMLNode(3,"LI_VORNAME",$rs->fields("delivery_firstname")); $XML.=$this->getXMLNode(3,"LI_NAME1",$rs->fields("delivery_lastname")); $XML.=$this->getXMLNode(3,"LI_NAME2",$rs->fields("delivery_company")); $XML.=$this->getXMLNode(3,"LI_STRASSE",$rs->fields("delivery_street_address")); // Land ermitteln $sql = "SELECT countries_iso_code_2 FROM " . TABLE_COUNTRIES . " WHERE countries_name = '" . $rs->fields("delivery_state") . "'"; $rsspeicher = $this->db->Execute($sql); if (!$rsspeicher->EOF && $rsspeicher){ $XML.=$this->getXMLNode(3,"LI_LKZ",$rsspeicher->fields("countries_iso_code_2")); }else{ $XML.=$this->getXMLNode(3,"LI_LKZ","DE"); } $XML.=$this->getXMLNode(3,"LI_PLZ",$rs->fields("delivery_postcode")); $XML.=$this->getXMLNode(3,"LI_ORT",$rs->fields("delivery_city")); $XML.="\t\t\t\n"; }else{ $XML.=$this->getXMLNode(3,"LI_ANREDE",""); $XML.=$this->getXMLNode(3,"LI_VORNAME",""); $XML.=$this->getXMLNode(3,"LI_NAME1",""); $XML.=$this->getXMLNode(3,"LI_NAME2",""); $XML.=$this->getXMLNode(3,"LI_STRASSE",""); $XML.=$this->getXMLNode(3,"LI_LKZ",""); $XML.=$this->getXMLNode(3,"LI_PLZ",""); $XML.=$this->getXMLNode(3,"LI_ORT",""); $XML.="\t\t\t\n"; } $XML.=$this->getXMLNode(2,"MWST_KZ",1); // NETTO Preise $XML.=$this->getXMLNode(2,"VERSANDART",$rs->fields("shipping_method")); $XML.=$this->getXMLNode(2,"ZAHLART",$rs->fields("payment_method")); $XML.=$this->getXMLNode(2,"PGR",$TempKundengruppe); // 07.03.2011: Laut Schnittstelle 1.6 von oben verschoben $XML.=$this->getXMLNode(2,"MITTEILUNG",$rs->fields("comments")); $sql = "SELECT * FROM " . TABLE_ORDERS_TOTAL . " WHERE orders_id = " . $rs->fields("orders_id") . " AND class = 'ot_shipping'"; $rsspeicher = $this->db->Execute($sql); if (!$rsspeicher->EOF && $rsspeicher){ $sql = "SELECT * FROM " . TABLE_TAX_RATES. " WHERE tax_class_id = 1"; $rsspeichertax = $this->db->Execute($sql); $TempPreis=$rsspeicher->fields("value"); if ($rs->fields("payment_method") == "cod"){ // Nachnahme $sql = "SELECT * FROM " . TABLE_ORDERS_TOTAL . " WHERE orders_id = " . $rs->fields("orders_id") . " AND class = 'ot_cod_fee'"; $rsspeicher = $this->db->Execute($sql); if (!$rsspeicher->EOF && $rsspeicher){ $TempPreis=$TempPreis + $rsspeicher->fields("value"); } } $XML.=$this->getXMLNode(2,"VERSAND_N",number_format (($TempPreis/$TAX), 2 , "," , "")); $XML.=$this->getXMLNode(2,"VERSAND_B",number_format ($TempPreis, 2 , "," , "")); }else{ $XML.=$this->getXMLNode(2,"VERSAND_N","0,00"); $XML.=$this->getXMLNode(2,"VERSAND_B","0,00"); } $XML.=$this->getXMLNode(2,"RABATT","0"); $XML.="\t\t\n"; $sql = "SELECT * FROM " . TABLE_ORDERS_PRODUCTS . " LEFT JOIN " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " ON (" . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . ".orders_products_id = " . TABLE_ORDERS_PRODUCTS . ".orders_products_id AND " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . ".orders_id = " . TABLE_ORDERS_PRODUCTS . ".orders_id) WHERE " . TABLE_ORDERS_PRODUCTS . ".orders_id = " . $rs->fields("orders_id") . ""; $rsspeicher = $this->db->Execute($sql); if (!$rsspeicher->EOF && $rsspeicher){ while (!$rsspeicher->EOF){ $XML.="\t\t\n"; // Wurde ein Kindartikel ausgewaehlt? $sql = "SELECT " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . ".products_options_values_id, " . TABLE_PRODUCTS_OPTIONS . ".products_options_id " . "FROM " . TABLE_PRODUCTS_OPTIONS . " " . "INNER JOIN " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " ON " . TABLE_PRODUCTS_OPTIONS . ".products_options_id = products_options.products_options_id " . "INNER JOIN " . TABLE_PRODUCTS_OPTIONS_VALUES . " ON " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . ".products_options_values_id = products_options_values.products_options_values_id " . "WHERE products_options_name = '" . $rsspeicher->fields("products_options") . "' AND products_options_values_name = '" . $rsspeicher->fields("products_options_values") . "'"; $rsattr = $this->db->Execute($sql); if(!$rsattr->EOF && $rsattr){ $sql = "SELECT * FROM products_attributes WHERE options_id = " . $rsattr->fields("products_options_id") . " AND options_values_id = " . $rsattr->fields("products_options_values_id") . " AND products_id = " . $rsspeicher->fields("products_id") . " "; $rsattr = $this->db->Execute($sql); if(!$rsattr->EOF && $rsattr){ $XML.=$this->getXMLNode(2,"ARTCODE",$rsattr->fields("attributes_model")); // Kindtext holen $sql = "SELECT products_name FROM " . TABLE_PRODUCTS . " INNER JOIN " . TABLE_PRODUCTS_DESCRIPTION . " ON " . TABLE_PRODUCTS . ".products_id = " . TABLE_PRODUCTS_DESCRIPTION . ".products_id WHERE products_model = '" . $rsattr->fields("attributes_model") . "'"; $rsattr = $this->db->Execute($sql); if(!$rsattr->EOF && $rsattr){ $XML.=$this->getXMLNode(2,"TEXT",$rsattr->fields("products_name")); }else{ $XML.=$this->getXMLNode(2,"TEXT",$rsspeicher->fields("products_name")); } }else{ $XML.=$this->getXMLNode(2,"ARTCODE",$rsspeicher->fields("products_model")); $XML.=$this->getXMLNode(2,"TEXT",$rsspeicher->fields("products_name")); } }else{ $XML.=$this->getXMLNode(2,"ARTCODE",$rsspeicher->fields("products_model")); $XML.=$this->getXMLNode(2,"TEXT",$rsspeicher->fields("products_name")); } $XML.=$this->getXMLNode(2,"LANGTEXT",""); $XML.=$this->getXMLNode(2,"MENGE",$rsspeicher->fields("products_quantity")); // Einheit ermitteln $sql = "SELECT products_vpe_name FROM " . TABLE_PRODUCTS_VPE . " INNER JOIN " . TABLE_PRODUCTS . " ON " . TABLE_PRODUCTS_VPE . ".products_vpe_id = " . TABLE_PRODUCTS . ".products_vpe WHERE products_id = " . $rsspeicher->fields("products_id") . " AND products_vpe_name > '' "; $rseinheit = $this->db->Execute($sql); if (!$rseinheit->EOF && $rseinheit){ $XML.=$this->getXMLNode(2,"EINHEIT",$rseinheit->fields("products_vpe_name")); }else{ $XML.=$this->getXMLNode(2,"EINHEIT",utf8_decode("Stück")); } // Preismenge ermitteln $sql = "SELECT * FROM " . TABLE_PRODUCTS . " WHERE products_id = " . $rsspeicher->fields("products_id"); $rspe = $this->db->Execute($sql); if (!$rspe->EOF && $rspe){ $XML.=$this->getXMLNode(2,"PREISMENGE",$rspe->fields("products_price_quantity")); }else{ $XML.=$this->getXMLNode(2,"PREISMENGE",1); } $XML.=$this->getXMLNode(2,"MWST_PROZ",str_replace(".",",",$TAXText)); $XML.=$this->getXMLNode(2,"EP_NETTO",number_format (($rsspeicher->fields("products_price")/$TAX), 2 , "," , "")); $XML.=$this->getXMLNode(2,"EP_BRUTTO",number_format (($rsspeicher->fields("products_price")), 2 , "," , "")); $XML.=$this->getXMLNode(2,"POS_RABATT","0"); $XML.=$this->getXMLNode(2,"GP_NETTO",number_format (($rsspeicher->fields("final_price")/$TAX), 2 , "," , "")); $XML.=$this->getXMLNode(2,"GP_BRUTTO",number_format (($rsspeicher->fields("final_price")), 2 , "," , "")); $XML.="\t\t\n"; $rsspeicher->MoveNext(); } } $XML.="\t\n"; $XML.=''; $filename=$this->PathExport."/daten/bestellungen_" . $Zaehler . ".xml"; $this->fs->fwrite($filename,$XML); $Zaehler++; // Bestellung aktualisieren $sql = "UPDATE orders SET sync_date = now() WHERE " . $rs->fields("orders_id"); $this->db->Execute($sql); $rs->MoveNext(); } // Exporttime schreiben $this->fs->fwrite($this->TimeFileOrder,$ExportDatum); $this->setStatus("Bestellungen koennen nun per FTP heruntergeladen werden."); $this->SendStatusEmail=true; }else{ $this->setStatus("Keine Bestellungen zum exportieren."); } } /** * Fuegt einen Artikel hinzu bzw. modifiziert diesen * * @param String xml **/ function addArtikel($xml){ $CrossID=0; $this->Counts["Artikel"]=0; if (count($xml->ARTIKEL) > 0){ //Crossselling Gruppe anlegen, wenn nicht schon erledigt $sql = "SELECT * FROM " . TABLE_PRODUCTS_XSELL_GROUPS . " WHERE groupname = 'Mercator'"; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ $CrossID=$rs->fields("products_xsell_grp_name_id"); }else{ $Mapping=array(); //Mapping["products_xsell_grp_name_id"]= $Mapping["xsell_sort_order"]=0; $Mapping["language_id"]=$this->getSprachenID("d"); $Mapping["groupname"]="Mercator"; $sql = $this->db->GetInsertSQL($rs,$Mapping); $this->db->Execute($sql); // Nummer ermitteln $sql = "SELECT * FROM " . TABLE_PRODUCTS_XSELL_GROUPS . " WHERE groupname = 'Mercator'"; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ $CrossID=$rs->fields("products_xsell_grp_name_id"); } } // Artikel anlegen $this->setStatus("Artikel werden angelegt bzw. modifiziert."); foreach ($xml->ARTIKEL as $id => $value){ $this->Counts["Artikel"]++; // MWST $Temp=explode(",",$value->MWST); if(strlen($Temp[0]) == 1){ $TAX = "1.0" . $Temp[0]; }else{ $TAX = "1." . $Temp[0]; } // Mapping erzeugen $Mapping=array(); //$Mapping["products_id"]=(string)$value->ARTCODE; --> Wird automatisch vergeben $Mapping["products_ean"]=(string)$value->EAN; $Mapping["products_quantity"]=(string)$value->BESTAND; $Mapping["products_shippingtime"]=""; $Mapping["products_model"]=(string)$value->ARTCODE; $Mapping["group_permission_0"]=0; $Mapping["group_permission_1"]=0; $Mapping["group_permission_2"]=0; $Mapping["group_permission_3"]=0; $Mapping["products_sort"]=0; //$Mapping["products_image"]=""; --> Wird unten nochmal gesetzt $Mapping["products_price"]=(str_replace(",",".",(string)$value->PREIS) / $TAX); //$Mapping["products_price"]=(str_replace(",",".",(string)$value->PREIS)); // Laut Schnittstelle wird entsprechend geliefert als Netto $Mapping["products_discount_allowed"]=""; $Mapping["products_date_added"]=date("d.m.Y",time()); $Mapping["products_last_modified"]=date("d.m.Y",time()); $Mapping["products_date_available"]=""; $Mapping["products_weight"]=(string)$value->GEWICHT; if ($value->AKTIV == 1){ $Mapping["products_status"]=1; // Artikel wird angezeigt; }else{ $Mapping["products_status"]=0; // Artikel wird nicht angezeigt; } $Mapping["products_tax_class_id"]=$this->getMWSTID((string)$value->MWST); $Mapping["product_template"]="default"; $Mapping["options_template"]="product_options_dropdown.html"; $Mapping["manufacturers_id"]=$this->getHerstellerID($value->HERSTELLER); $Mapping["products_ordered"]=(string)$value->BESTAND; $Mapping["products_fsk18"]=0; $Mapping["products_price_quantity"]=(string)$value->PREISMENGE; // VPE anlegen $sql = "SELECT products_vpe_id FROM " . TABLE_PRODUCTS_VPE . " WHERE products_vpe_name = '" . $this->ConvertText2DB((string)$value->SPRACHDATEN->EINHEIT) . "'"; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){}else{ $sql = "SELECT MAX(products_vpe_id) anzahl FROM " . TABLE_PRODUCTS_VPE . ""; $rs = $this->db->Execute($sql); if ($rs->fields("anzahl") > 0){$TempAnzahl=$rs->fields("anzahl")+1;}else{$TempAnzahl=1;} $sql = "INSERT INTO " . TABLE_PRODUCTS_VPE . " (products_vpe_id , language_id, products_vpe_name) VALUES (" . $TempAnzahl . "," . $this->getSprachenID("d") . ",'" . $this->ConvertText2DB((string)$value->SPRACHDATEN->EINHEIT) . "')"; $this->db->Execute($sql); $sql = "SELECT products_vpe_id FROM " . TABLE_PRODUCTS_VPE . " WHERE products_vpe_name = '" . $this->ConvertText2DB((string)$value->SPRACHDATEN->EINHEIT) . "'"; $rs = $this->db->Execute($sql); } $Mapping["products_vpe"]=$rs->fields("products_vpe_id"); $Mapping["products_vpe_status"]=1; // Modul Mindestbestellmengen installiert? if ($this->ModulMindesbestellmenge == true){ $Mapping["products_vpe_value"]=0; $Mapping["products_min_quantity"]=(string)$value->SPEZIAL->VPE_MENGE; $Mapping["products_min_quantity_value"]=$rs->fields("products_vpe_id"); }else{ $Mapping["products_vpe_value"]=(string)$value->SPEZIAL->VPE_MENGE; } // Artikel auf Auslauf?? if ($value->AUSLAUF == 1){ $Mapping["products_vpe"]=-1; } $Mapping["products_startpage"]=0; $Mapping["products_startpage_sort"]=0; $Mapping["products_valid_from"]=NULL; $Mapping["products_valid_to"]=NULL; $sql = "SELECT * FROM " . TABLE_PRODUCTS . " WHERE products_model = '" . $Mapping["products_model"] . "'"; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ $sql = $this->db->GetUpdateSQL($rs,$Mapping); }else{ $sql = $this->db->GetInsertSQL($rs,$Mapping); } if ($sql){$this->db->Execute($sql);} // Kindartikel if ((string)$value->VARIANTEN->VAR_VATER){ // Normale Speicherung $this->ArtikelKind[(string)$value->ARTCODE]["vater"]=(string)$value->VARIANTEN->VAR_VATER; $this->ArtikelKind[(string)$value->ARTCODE]["text"]=(string)$value->VARIANTEN->VAR_TEXT; // Spezielle Speicherung in Session $_SESSION["ArtikelKind"][(string)$value->ARTCODE]["vater"]=(string)$value->VARIANTEN->VAR_VATER; $_SESSION["ArtikelKind"][(string)$value->ARTCODE]["text"]=(string)$value->VARIANTEN->VAR_TEXT; } // XTC Artikelnummern ermitteln $sql = "SELECT products_id FROM " . TABLE_PRODUCTS . " WHERE products_model = '" . $Mapping["products_model"] . "'"; $rs = $this->db->Execute($sql); $Artikelnummer=0; if (!$rs->EOF && $rs){ $Artikelnummer=$rs->fields("products_id"); } // weitere Attribute foreach ($value->SPRACHDATEN->ATTRIBUT as $sprachkey => $sprachvalue){ $TempBezeichnung=(string)$sprachvalue->NAME; $TempWert=(string)$sprachvalue->INHALT; $TempSort=(string)$sprachvalue->POS; // Attribut gegeben falls anlegen $sql = "SELECT products_options_id FROM " . TABLE_PRODUCTS_OPTIONS . " WHERE products_options_name = '" . $TempBezeichnung . "'"; $rs = $this->db->Execute($sql); if ($rs->EOF){ $sql = "SELECT max(products_options_id) as id FROM " . TABLE_PRODUCTS_OPTIONS . ""; $rs = $this->db->Execute($sql); $sql = "INSERT INTO " . TABLE_PRODUCTS_OPTIONS . " (products_options_id, products_options_name, language_id) VALUES (" . ($rs->fields("id")+1) . ",'" . $TempBezeichnung . "',2)"; $this->db->Execute($sql); $sql = "SELECT products_options_id FROM " . TABLE_PRODUCTS_OPTIONS . " WHERE products_options_name = '" . $TempBezeichnung . "'"; $rs = $this->db->Execute($sql); $TempPO_ID=$rs->fields("products_options_id"); }else{ $TempPO_ID=$rs->fields("products_options_id"); } // Wert anlegen, wenn noch nicht vorhanden $sql = "SELECT products_options_values_id FROM " . TABLE_PRODUCTS_OPTIONS_VALUES . " WHERE products_options_values_name = '" . $TempWert . "'"; $rs = $this->db->Execute($sql); if ($rs->EOF){ $sql = "SELECT max(products_options_values_id) as id FROM " . TABLE_PRODUCTS_OPTIONS_VALUES . ""; $rs = $this->db->Execute($sql); $sql = "INSERT INTO " . TABLE_PRODUCTS_OPTIONS_VALUES . " (products_options_values_id, products_options_values_name, language_id) VALUES (" . ($rs->fields("id")+1) . ",'" . $TempWert . "',2)"; $this->db->Execute($sql); $sql = "SELECT products_options_values_id FROM " . TABLE_PRODUCTS_OPTIONS_VALUES . " WHERE products_options_values_name = '" . $TempWert . "'"; $rs = $this->db->Execute($sql); $TempPOV_ID=$rs->fields("products_options_values_id"); }else{ $TempPOV_ID=$rs->fields("products_options_values_id"); } // Attributszuweisung durchfuehren $sql = "SELECT * FROM products_options_values_to_products_options WHERE products_options_id = " . $TempPO_ID . " AND products_options_values_id = " . $TempPOV_ID . ""; $rs = $this->db->Execute($sql); if ($rs->EOF){ $sql = "INSERT INTO products_options_values_to_products_options (products_options_id,products_options_values_id) VALUES (" . $TempPO_ID . "," . $TempPOV_ID . ")"; $this->db->Execute($sql); } // Artikelzuweisung $sql = "INSERT INTO products_attributes ( products_id, options_id, options_values_id, options_values_price, price_prefix, attributes_model, attributes_stock, options_values_weight, weight_prefix, sortorder, products_shippingtime) VALUES (" . $Artikelnummer . ", " . $TempPO_ID . ", " . $TempPOV_ID . ", 0, '+', '', 0, 0, '+', " . $TempSort . ", 0)"; $this->db->Execute($sql); } // Kinderschutzinfo / Warnhinweise if (isset($value->SPRACHDATEN->DOKTITEL1) || isset($value->SPRACHDATEN->DOKTITEL2) || isset($value->SPRACHDATEN->DOKTITEL3)){ // Tabelle erstellen, wenn noch nicht vorhanden $sql = "CREATE TABLE IF NOT EXISTS temp_xtc_warnhinweise ( products_id int(11) NOT NULL, doktitel1 varchar(255) NOT NULL, doktitel2 varchar(255) NOT NULL, doktitel3 varchar(255) NOT NULL )"; $this->db->Execute($sql); // Daten speichern $TempDaten=array(); $TempDaten["products_id"]=$Artikelnummer; $TempDaten["doktitel1"]=utf8_decode($value->SPRACHDATEN->DOKTITEL1); $TempDaten["doktitel2"]=utf8_decode($value->SPRACHDATEN->DOKTITEL2); $TempDaten["doktitel3"]=utf8_decode($value->SPRACHDATEN->DOKTITEL3); $sql = "SELECT * FROM temp_xtc_warnhinweise WHERE products_id = " . $Artikelnummer; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ $sql = $this->db->GetUpdateSQL($rs,$TempDaten); }else{ $sql = $this->db->GetInsertSQL($rs,$TempDaten); } if ($sql){$this->db->Execute($sql);} } // Cross Selling Product if (isset($value->CROSS_SELLER->CS)){ foreach ($value->CROSS_SELLER->CS as $crosskey => $crossvalue){ $sql = "SELECT products_id FROM " . TABLE_PRODUCTS . " WHERE products_model = '" . $crossvalue . "'"; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ $CrossArtikelnummer=$rs->fields("products_id"); $sql = "SELECT * FROM " . TABLE_PRODUCTS_XSELL . " WHERE products_id = " .$CrossArtikelnummer . " AND xsell_id = " . $Artikelnummer . " AND products_xsell_grp_name_id = " . $CrossID . ""; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ // OK - schon vorhanden }else{ $Mapping=array(); $Mapping["products_id"]=$CrossArtikelnummer; $Mapping["products_xsell_grp_name_id"]=$CrossID; $Mapping["xsell_id"]=$Artikelnummer; $Mapping["sort_order"]=0; $sql = "SELECT * FROM " . TABLE_PRODUCTS_XSELL . " "; $rs = $this->db->Execute($sql); $sql = $this->db->GetInsertSQL($rs,$Mapping); if ($sql){$this->db->Execute($sql);} } } } } // Preisgruppen abbilden $PreisgruppenMapping=array(); for ($i=0 ; $i<=8 ; $i++){$PreisgruppenMapping["VK".$i]="";} for ($i=0 ; $i<=8 ; $i++){ if ($this->Config->get("xstar_syncmercator_pgr_kundengruppe_vk" . $i) > 0){ $PreisgruppenMapping["VK".$i]=$this->Config->get("xstar_syncmercator_pgr_kundengruppe_vk" . $i); } } foreach (get_object_vars($value->SPEZIAL) as $Preisgruppe => $Preis){ if ($Preis){ $TempGruppenID=$PreisgruppenMapping[$Preisgruppe]; if ($TempGruppenID > 0){ // Preisgruppe und Staffelpreise fuer Artikel leeren $sql = "DELETE FROM personal_offers_by_customers_status_" . $TempGruppenID . " WHERE products_id = " . $Artikelnummer; $rs = $this->db->Execute($sql); // Preisgruppe anlegen $Mapping=array(); $Mapping["products_id"]=$Artikelnummer; $Mapping["quantity"]=1; $Mapping["personal_offer"]=str_replace(",",".",$Preis); $sql = "SELECT * FROM personal_offers_by_customers_status_" . $TempGruppenID . " WHERE products_id = " . $Artikelnummer; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ $sql = $this->db->GetUpdateSQL($rs,$Mapping); }else{ $sql = $this->db->GetInsertSQL($rs,$Mapping); } if ($sql){$this->db->Execute($sql);} } } } // Staffelpreise bei Preisgruppen abbilden if (count($value->SPEZIAL->STAFFELPREIS)>0){ foreach ($value->SPEZIAL->STAFFELPREIS as $staffelpreis => $feld_staffelpreis){ $TempDaten=get_object_vars($feld_staffelpreis); if ($PreisgruppenMapping["VK" . $TempDaten["PGR"]]){ $TempGruppenID=$PreisgruppenMapping["VK".$TempDaten["PGR"]]; if ($TempGruppenID > 0){ $Mapping=array(); $Mapping["products_id"]=$Artikelnummer; $Mapping["quantity"]=$TempDaten["M_AB"]; $StatusStaffelpreis=false; if ($TempDaten["PREIS"] > 0){ $Mapping["personal_offer"]=str_replace(",",".",$TempDaten["PREIS"]); $StatusStaffelpreis=true; } if ($TempDaten["RABATT"] > 0){ $sql = "SELECT * FROM personal_offers_by_customers_status_" . $TempGruppenID . " WHERE products_id = " . $Artikelnummer . " AND quantity = 1"; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ $TempPreis=str_replace(",",".",$rs->fields("personal_offer")); $TempPreis=(100-($TempDaten["RABATT"]))*$TempPreis/100; $Mapping["personal_offer"]=$TempPreis; $StatusStaffelpreis=true; } } // Preis oder Rabatt vorhanden vorhanden, dann anlegen if ($StatusStaffelpreis){ $sql = "SELECT * FROM personal_offers_by_customers_status_" . $TempGruppenID . " WHERE products_id = " . $Artikelnummer . " AND quantity = " . $Mapping["quantity"]; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ $sql = $this->db->GetUpdateSQL($rs,$Mapping); }else{ $sql = $this->db->GetInsertSQL($rs,$Mapping); } if ($sql){$this->db->Execute($sql);} } } } } } // Product zur Kategorie zuordnen if (count($value->KATEGORIE) > 0){ foreach ($value->KATEGORIE as $id1 => $value1){ $Mapping=array(); $Mapping["products_id"]=$Artikelnummer; if ((string)$value->VARIANTEN->VAR_VATER){ $Mapping["categories_id"]=-1; }else{ $Mapping["categories_id"]=$this->changeKategorienID((string)$value1->KAT_ID); } $sql = "SELECT * FROM " . TABLE_PRODUCTS_TO_CATEGORIES . " WHERE products_id = " . $Artikelnummer . " AND categories_id = " . $Mapping["categories_id"]; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ $sql = "SELECT count(*) AS anzahl FROM " . TABLE_PRODUCTS_TO_CATEGORIES . " WHERE products_id = " . $Artikelnummer . ""; $rsspeicher = $this->db->Execute($sql); if ($rsspeicher->fields("anzahl") == 1){ $sql = $this->db->GetUpdateSQL($rs,$Mapping); } }else{ $sql = "SELECT * FROM " . TABLE_PRODUCTS_TO_CATEGORIES . " WHERE products_id = " . $Artikelnummer . ""; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ $sql = "SELECT count(*) AS anzahl FROM " . TABLE_PRODUCTS_TO_CATEGORIES . " WHERE products_id = " . $Artikelnummer . ""; $rsspeicher = $this->db->Execute($sql); if ($rsspeicher->fields("anzahl") == 1){ $sql = $this->db->GetUpdateSQL($rs,$Mapping); } }else{ $sql = $this->db->GetInsertSQL($rs,$Mapping); } } if ($sql){$this->db->Execute($sql);} } }else{ $Mapping=array(); $Mapping["products_id"]=$Artikelnummer; if ((string)$value->VARIANTEN->VAR_VATER){ $Mapping["categories_id"]=-1; }else{ $Mapping["categories_id"]=1; } $sql = "SELECT * FROM " . TABLE_PRODUCTS_TO_CATEGORIES . " WHERE products_id = " . $Artikelnummer . ""; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ $sql = $this->db->GetUpdateSQL($rs,$Mapping); }else{ $sql = $this->db->GetInsertSQL($rs,$Mapping); } if ($sql){$this->db->Execute($sql);} } // Langtexte vorhanden? if (count($value->SPRACHDATEN) > 0){ foreach ($value->SPRACHDATEN as $id1 => $value1){ if($this->getSprachenID($value1->SPRACH_KZ)>0){ $Mapping=array(); $Mapping["products_id"]=$Artikelnummer; $Mapping["language_id"]=$this->getSprachenID($value1->SPRACH_KZ); $Mapping["products_name"]=$this->ConvertText2DB((string)$value1->TEXT . " (" . (string)$value->HERSTELLER->ART_NR . ")"); $Mapping["products_description"]=$this->ConvertText2DB((string)$value1->LANGTEXT); if ((string)$value1->LANGTEXT_2){ if ($this->Config->get("xstar_syncmercator_langtext2_leerzeile_langtext1") == 1){ $Mapping["products_description"].="

".$this->ConvertText2DB((string)$value1->LANGTEXT_2); }else{ $Mapping["products_description"].="
".$this->ConvertText2DB((string)$value1->LANGTEXT_2); } $Mapping["products_short_description"]=$this->ConvertText2DB((string)$value1->LANGTEXT_2 . (string)$value1->ZUSATZ . (string)$value1->ZUSATZ_OPT); }else{ $Mapping["products_short_description"]=$this->ConvertText2DB((string)$value1->ZUSATZ . (string)$value1->ZUSATZ_OPT); } $Mapping["products_keywords"]=(string)$value->ARTCODE . " " . (string)$value1->SUCHBEGRIFFE; //SEO vorhanden? if (count($value->SEO)){ $Mapping["products_meta_title"]=(string)$value->SEO->TITLE; $Mapping["products_meta_description"]=(string)$value->SEO->DESCR; $Mapping["products_meta_keywords"]=(string)$value->SEO->KEYW; $Mapping["products_url"]=""; $Mapping["products_viewed"]=0; } $sql = "SELECT * FROM " . TABLE_PRODUCTS_DESCRIPTION . " WHERE products_id = " . $Artikelnummer . " AND language_id = " . $this->getSprachenID($value1->SPRACH_KZ); $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ $sql = $this->db->GetUpdateSQL($rs,$Mapping); }else{ $sql = $this->db->GetInsertSQL($rs,$Mapping); } if ($sql){$this->db->Execute($sql);} } } }else{ // Leeren Langtext anlegen $Mapping=array(); $Mapping["products_id"]=$Artikelnummer; $Mapping["language_id"]=$this->getSprachenID("D"); $Mapping["products_name"]=(string)$value->ARTCODE; $Mapping["products_description"]=""; $Mapping["products_short_description"]=""; $Mapping["products_keywords"]=(string)$value->ARTCODE; $sql = "SELECT * FROM " . TABLE_PRODUCTS_DESCRIPTION . " WHERE products_id = " . $Artikelnummer; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ $sql = $this->db->GetUpdateSQL($rs,$Mapping); }else{ $sql = $this->db->GetInsertSQL($rs,$Mapping); } if ($sql){$this->db->Execute($sql);} } // Attriute vorhanden? if ((string)$value->SPRACHDATEN->ATTRIBUT){ foreach ($value->SPRACHDATEN->ATTRIBUT as $attribute => $werte){ $TempOption=trim((string)$werte->NAME); $TempOptionValue=trim((string)$werte->INHALT); $TempOptionSort=trim((string)$werte->POS); // existiert Option? $sql = "SELECT products_options_id, products_options_name FROM products_options WHERE products_options_name = '" . $TempOption . "' AND language_id = 2"; $rsspeicher = $this->db->Execute($sql); if ($rsspeicher->EOF){ $sql = "SELECT MAX(products_options_id)+1 AS anzahl FROM products_options"; $rsspeicher = $this->db->Execute($sql); $TempOptionsID = $rsspeicher->fields("anzahl"); // Option anlegen if ($TempOptionsID > 0){ $sql = "INSERT INTO products_options (products_options_id, language_id, products_options_name) VALUES (" . $TempOptionsID . ",2,'" . $TempOption . "')"; $this->db->Execute($sql); } }else{ $TempOptionsID = $rsspeicher->fields("products_options_id"); } // existiert Options Value? $sql = "SELECT pv.products_options_values_id FROM products_options_values pv INNER JOIN products_options_values_to_products_options pvo ON pv.products_options_values_id = pvo.products_options_values_id WHERE products_options_id = " . $TempOptionsID . " AND products_options_values_name = '" . $TempOptionValue . "'"; $rsspeicher = $this->db->Execute($sql); if ($rsspeicher->EOF){ $sql = "SELECT MAX(products_options_values_id)+1 AS anzahl FROM products_options_values"; $rsspeicher = $this->db->Execute($sql); $TempOptionsID = $rsspeicher->fields("anzahl"); if ($TempOptionsID > 0){ // Option Value anlegen $sql = "INSERT INTO products_options_values (products_options_values, language_id, products_options_values_name) VALUES (" . $TempOptionsValueID . ",2,'" . $TempOptionValue . "')"; $this->db->Execute($sql); // Beziehung herstellen $sql = "INSERT INTO products_options_values_to_products_options (products_options_id, products_options_values_id) VALUES (" . $TempOptionsID . "," . $TempOptionValueID . ")"; $this->db->Execute($sql); } }else{ $TempOptionValueID=$rsspeicher->fields("products_options_values_id"); } // Attribut anlegen if ($TempOptionsID > 0 && $TempOptionValueID > 0){ $sql = "INSERT INTO products_attributes (products_id, options_id, options_values_id, sortorder) VALUES ('" . $Artikelnummer . "', '" . $TempOptionsID . "', '" . $TempOptionValueID . "', '" . $TempOptionSort . "')"; $this->db->Execute($sql); } } } // Produktfilter erzeugen $PF = new ProduktFilter($Artikelnummer); $PF->setBezeichnungKurz($Artikelnummer); // Bilder vorhanden? $BildVerzeichnisse=array("original_images","info_images","popup_images","thumbnail_images"); if ((string)$value->BILD_01){ $filename=$this->PathImport."bilder/" . (string)$value->BILD_01; if (file_exists($filename)){ foreach ($BildVerzeichnisse as $id1 => $bildpath){ $filename_neu=DIR_FS_DOCUMENT_ROOT."/images/product_images/" . $bildpath . "/" . $Artikelnummer . "_0.jpg"; $products_image_name = $Artikelnummer . "_0.jpg"; // Pruefen ob Datei unterschiedlich bzw. existiert if (!file_exists($filename_neu)){ copy ($filename, $filename_neu); if ($bildpath != "original_images"){ require (DIR_WS_INCLUDES.'product_' . $bildpath . '.php'); $sql = "UPDATE " . TABLE_PRODUCTS . " SET products_image = '" . $products_image_name . "' WHERE products_id = " . $Artikelnummer; $this->db->Execute($sql); } }else{ $MD5_1=hash_file('md5', $filename); $MD5_2=hash_file('md5', $filename_neu); if ($MD5_1 != $MD5_2){ copy ($filename, $filename_neu); if ($bildpath != "original_images"){ require (DIR_WS_INCLUDES.'product_' . $bildpath . '.php'); $sql = "UPDATE " . TABLE_PRODUCTS . " SET products_image = '" . $products_image_name . "' WHERE products_id = " . $Artikelnummer; $this->db->Execute($sql); } } } } // Bild loeschen, wenn alles erledigt if ($this->Config->get("xstar_syncmercator_importbilder_loeschen")!=1){ unlink($filename); } } } // Weitere Bilder hinterlegt? foreach (get_object_vars($value) as $feld => $wert){ if (substr($feld,0,4) == "BILD"){ $filename=$this->PathImport."bilder/" . $wert; if (file_exists($filename)){ $BildID=str_replace("BILD_","",$feld)-1; if ($BildID > 0){ foreach ($BildVerzeichnisse as $id1 => $bildpath){ $filename_neu=DIR_FS_DOCUMENT_ROOT."/images/product_images/" . $bildpath . "/" . $Artikelnummer . "_" . $BildID. ".jpg"; $products_image_name = $Artikelnummer . "_" . $BildID . ".jpg"; // Pruefen ob Datei unterschiedlich if (!file_exists($filename_neu)){ copy ($filename, $filename_neu); if ($bildpath != "original_images"){ require (DIR_WS_INCLUDES.'product_' . $bildpath . '.php'); } }else{ $MD5_1=hash_file('md5', $filename); $MD5_2=hash_file('md5', $filename_neu); if ($MD5_1 != $MD5_2){ copy ($filename, $filename_neu); if ($bildpath != "original_images"){ require (DIR_WS_INCLUDES.'product_' . $bildpath . '.php'); } } } // Bild zum Artikel speichern $Mapping=array(); $Mapping["products_id"]=$Artikelnummer; $Mapping["image_nr"]=$BildID; $Mapping["image_name"]=$products_image_name; $sql = "SELECT * FROM " . TABLE_PRODUCTS_IMAGES . " WHERE products_id = " . $Artikelnummer . " AND image_nr = " . $BildID; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ $sql = $this->db->GetUpdateSQL($rs,$Mapping,true); }else{ $sql = $this->db->GetInsertSQL($rs,$Mapping); } if ($sql){$this->db->Execute($sql);} } // Bild loeschen, wenn alles erledigt if ($this->Config->get("xstar_syncmercator_importbilder_loeschen")!=1){ unlink($filename); } } } } } // Bildduplikate entfernen $this->checkImagesDuplikate($Artikelnummer); } }else{ $this->showMeldung(0,3); } } /** * Loescht einen Artikel aus dem Artikelstamm * * @param String xml **/ function delArtikel($xml){ if (count($xml->LOESCHEN) > 0){ $this->setStatus("Artikel werden gelöscht."); foreach ($xml->LOESCHEN as $id => $value){ // Artikelnummer ermitteln $sql = "SELECT products_id, products_model FROM " . TABLE_PRODUCTS . " WHERE products_model = '" . $value . "'"; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ $Artikelnummer=$rs->fields("products_id"); $sql = "DELETE FROM " . TABLE_PRODUCTS_DESCRIPTION . " WHERE products_id = " . $Artikelnummer; $this->db->Execute($sql); $sql = "DELETE FROM " . TABLE_PRODUCTS_ATTRIBUTES . " WHERE products_id = " . $Artikelnummer; $this->db->Execute($sql); $sql = "DELETE FROM " . TABLE_PRODUCTS_TO_CATEGORIES . " WHERE products_id = " . $Artikelnummer; $this->db->Execute($sql); $sql = "DELETE FROM products_kurzebezeichnungen WHERE products_id NOT IN (SELECT products_id FROM products)"; $this->db->Execute($sql); $sql = "DELETE FROM " . TABLE_PRODUCTS . " WHERE products_id = " . $Artikelnummer; $this->db->Execute($sql); } } } } /** * Loescht alle Artikel */ function delArtikelAll(){ $sql = "DELETE FROM " . TABLE_CATEGORIES_DESCRIPTION . ""; $this->db->Execute($sql); $sql = "DELETE FROM " . TABLE_CATEGORIES . ""; $this->db->Execute($sql); $sql = "DELETE FROM " . TABLE_PRODUCTS_DESCRIPTION . ""; $this->db->Execute($sql); $sql = "DELETE FROM " . TABLE_PRODUCTS_ATTRIBUTES . ""; $this->db->Execute($sql); $sql = "DELETE FROM " . TABLE_PRODUCTS_TO_CATEGORIES . ""; $this->db->Execute($sql); $sql = "DELETE FROM " . TABLE_PRODUCTS . ""; $this->db->Execute($sql); } /** * Bereinigt die Datenbank */ function clearDatabase(){ $sql = "DELETE FROM " . TABLE_PRODUCTS_DESCRIPTION . " WHERE products_id NOT IN (SELECT products_id FROM " . TABLE_PRODUCTS . ")"; $this->db->Execute($sql); $sql = "DELETE FROM " . TABLE_PRODUCTS_ATTRIBUTES . " WHERE products_id NOT IN (SELECT products_id FROM " . TABLE_PRODUCTS . ")"; $this->db->Execute($sql); $sql = "DELETE FROM " . TABLE_PRODUCTS_TO_CATEGORIES . " WHERE products_id NOT IN (SELECT products_id FROM " . TABLE_PRODUCTS . ")"; $this->db->Execute($sql); $sql = "DELETE FROM products_kurzebezeichnungen WHERE products_id NOT IN (SELECT products_id FROM products)"; $this->db->Execute($sql); } /** * Erzeugt basierend auf Kinderartikel Attribute */ function addVarianten(){ $this->setStatus("Varianten werden erzeugt."); // Pruefen, ob Variante Gruppe Allgemein vorhanden ist $sql = "SELECT * FROM " . TABLE_PRODUCTS_OPTIONS . " WHERE products_options_name = 'Allgemein'"; $rs = $this->db->Execute($sql); if ($rs->EOF){ $sql = "INSERT INTO " . TABLE_PRODUCTS_OPTIONS . " (products_options_name, language_id ) VALUES ('Allgemein',2)"; $this->db->Execute($sql); $sql = "SELECT * FROM " . TABLE_PRODUCTS_OPTIONS . " WHERE products_options_name = 'Allgemein'"; $rs = $this->db->Execute($sql); } $GruppenID=$rs->fields("products_options_id"); $this->ArtikelKind=$_SESSION["ArtikelKind"]; // Attribute anlegen if (count($this->ArtikelKind) > 0){ foreach ($this->ArtikelKind as $id => $value){ $sql = "SELECT * FROM " . TABLE_PRODUCTS_OPTIONS_VALUES . " WHERE products_options_values_name = '" . $this->ConvertText2DB($value["text"]) . "'"; $rs = $this->db->Execute($sql); if ($rs->EOF){ $sql = "SELECT MAX(products_options_values_id) as products_options_values_id FROM " . TABLE_PRODUCTS_OPTIONS_VALUES; $rsspeicher = $this->db->Execute($sql); $products_options_values_id=$rsspeicher->fields("products_options_values_id")+1; $sql = "INSERT INTO " . TABLE_PRODUCTS_OPTIONS_VALUES . " (products_options_values_id, language_id, products_options_values_name ) VALUES (" . $products_options_values_id . ",2,'" . $this->ConvertText2DB($value["text"]) . "')"; $this->db->Execute($sql); $sql = "SELECT * FROM " . TABLE_PRODUCTS_OPTIONS_VALUES . " WHERE products_options_values_name = '" . $this->ConvertText2DB($value["text"]) . "'"; $rs = $this->db->Execute($sql); $VariantenID=$rs->fields("products_options_values_id"); $sql = "INSERT INTO " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " (products_options_id ,products_options_values_id) VALUES (" . $GruppenID . "," . $VariantenID . ")"; $this->db->Execute($sql); } } } // Vaterartikel um Attribute erweitern und Kinder ausblenden if (count($this->ArtikelKind) > 0){ $Vater=array(); $Kind=array(); $VariantenID=0; foreach ($this->ArtikelKind as $id => $value){ // Daten vom Vater holen $sql = "SELECT * FROM " . TABLE_PRODUCTS . " WHERE products_model = '" . $value["vater"] . "'"; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ $Vater=$rs->fields; // Daten vom Kind holen $sql = "SELECT * FROM " . TABLE_PRODUCTS . " WHERE products_model = '" . $id . "'"; $rs = $this->db->Execute($sql); $Kind=$rs->fields; // Variantennummer holen $sql = "SELECT products_options_values_id FROM " . TABLE_PRODUCTS_OPTIONS_VALUES . " WHERE products_options_values_name = '" . $this->ConvertText2DB($value["text"]) . "'"; $rs = $this->db->Execute($sql); $VariantenID=$rs->fields("products_options_values_id"); // Attribut anlegen $Mapping=array(); //$Mapping["products_attributes_id"]=""; $Mapping["products_id"]=$Vater["products_id"]; $Mapping["options_id"]=$GruppenID; $Mapping["options_values_id"]=$VariantenID; if ($Vater["products_price"] > $Kind["products_price"]){ $Mapping["options_values_price"]=$Vater["products_price"] - $Kind["products_price"]; $Mapping["price_prefix"]="-"; }else{ $Mapping["options_values_price"]=$Kind["products_price"] - $Vater["products_price"]; $Mapping["price_prefix"]="+"; } $Mapping["attributes_model"]=$Kind["products_model"]; $Mapping["attributes_stock"]=0; $Mapping["options_values_weight"]=0.0000; $Mapping["weight_prefix"]="+"; $Mapping["sortorder"]=0; $sql = "SELECT * FROM " . TABLE_PRODUCTS_ATTRIBUTES . " WHERE products_id = " . $Vater["products_id"] . " AND options_id = " . $GruppenID . " AND options_values_id = " . $VariantenID . ""; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ $sql = $this->db->GetUpdateSql($rs,$Mapping); }else{ $sql = $this->db->GetInsertSql($rs,$Mapping); } if ($sql){$this->db->Execute($sql);} // Kind Artikel unsichtbar machen $sql = "UPDATE " . TABLE_PRODUCTS . " SET products_status = 0 WHERE products_model = '" . $Kind["products_model"] . "'"; $this->db->Execute($sql); }else{ $this->setStatus("-- Vaterartikel '" . $value["vater"] . "' fuer Kindartikel '" . $id . "' existiert nicht.","Fehler"); } } } } /** * Sortiert die Varianten der Grsuppe Allgemein **/ function sortVarianten(){ $this->setStatus("Varianten werden sortiert."); $sql = "SELECT sortorder, products_options_values_name, products_id, products_attributes_id FROM products_attributes INNER JOIN products_options_values ON products_attributes.options_values_id = products_options_values.products_options_values_id WHERE products_attributes.options_id = 0 ORDER BY products_id, products_options_values_name"; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ $i=0; $tempArtikelnummer=$rs->fields("products_id"); while (!$rs->EOF){ if ($tempArtikelnummer != $rs->fields("products_id")){$tempArtikelnummer=$rs->fields("products_id");$i=0;} $sql = "UPDATE products_attributes SET sortorder = " . $i . " WHERE products_id = " . $rs->fields("products_id") . " AND products_attributes_id = " . $rs->fields("products_attributes_id") . ""; $this->db->Execute($sql); $i++; $rs->MoveNext(); } } } /** * legt Kunden an anhand von einer XML Datei * * @param String xml **/ function addKunden($xml){ if (count($xml->KUNDE) > 0){ $this->setStatus("Kunden werden angelegt bzw. modifiziert (" . time() . ")."); foreach ($xml->KUNDE as $id => $value){ if ($this->checkEmail((string)$value->EMAIL)){ $Mapping=array(); // Wird ausgelassen automatische hochzaehlen -- $Mapping["customers_id"]=""; $Mapping["customers_cid"]=(string)$value->NR; if ( (string)$value->UST_ID ){ $Mapping["customers_vat_id"]=(string)$value->UST_ID; $Mapping["customers_vat_id_status"]=1; }else{ $Mapping["customers_vat_id"]=NULL; $Mapping["customers_vat_id_status"]=0; } $Mapping["customers_warning"]=""; $Mapping["customers_status"]=$this->getKundengruppenID((string)$value->PGR); switch ((string)$value->ANREDE){ case "Herr": $Mapping["customers_gender"]="m"; break; case "Frau": $Mapping["customers_gender"]="w"; break; default: break; } $Mapping["customers_firstname"]=$this->ConvertText2DB((string)$value->VORNAME); $Mapping["customers_lastname"]=$this->ConvertText2DB((string)$value->NAME1); //$Mapping["customers_dob"]=""; $Mapping["customers_email_address"]=$this->ConvertText2DB((string)$value->EMAIL); $Mapping["customers_default_address_id"]=1; $Mapping["customers_telephone"]=$this->ConvertText2DB((string)$value->TEL1); $Mapping["customers_fax"]=$this->ConvertText2DB((string)$value->FAX); $Mapping["customers_password"]=md5("START".(string)$value->NR); $Mapping["customers_newsletter"]=""; $Mapping["customers_newsletter_mode"]=0; $Mapping["member_flag"]=0; $Mapping["delete_user"]=0; $Mapping["account_type"]=0; $Mapping["password_request_key"]=""; $Mapping["payment_unallowed"]=""; $Mapping["shipping_unallowed"]=""; $Mapping["refferers_id"]=0; $Mapping["customers_date_added"]=date("d.m.Y",time()); $Mapping["customers_last_modified"]=date("d.m.Y",time()); $sql = "SELECT * FROM " . TABLE_CUSTOMERS . " WHERE customers_cid = '" . (string)$value->NR . "'"; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ $sql = $this->db->GetUpdateSQL($rs,$Mapping); }else{ $sql = $this->db->GetInsertSQL($rs,$Mapping); } if ($sql){$this->db->Execute($sql);} // XTC Adressen ID ermitteln $sql = "SELECT customers_id FROM " . TABLE_CUSTOMERS . " WHERE customers_cid = '" . (string)$value->NR . "'"; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ $XTCKundennummer=$rs->fields("customers_id"); // Adresse $Mapping=array(); //$Mapping["address_book_id"]=""; $Mapping["customers_id"]=$XTCKundennummer; $Mapping["entry_gender"]=""; $Mapping["entry_company"]=$this->ConvertText2DB((string)$value->NAME2); $Mapping["entry_firstname"]=$this->ConvertText2DB((string)$value->VORNAME); $Mapping["entry_lastname"]=$this->ConvertText2DB((string)$value->NAME1); $Mapping["entry_street_address"]=$this->ConvertText2DB((string)$value->STRASSE); $Mapping["entry_suburb"]=""; $Mapping["entry_postcode"]=(string)$value->PLZ; $Mapping["entry_city"]=$this->ConvertText2DB((string)$value->ORT); $Mapping["entry_state"]=""; // Land ermitteln $sql = "SELECT countries_id FROM " . TABLE_COUNTRIES . " WHERE countries_iso_code_2 = '" . $this->ConvertText2DB((string)$value->LKZ) . "'"; $rsspeicher = $this->db->Execute($sql); if (!$rsspeicher->EOF && $rsspeicher){ $Mapping["entry_country_id"]=$rsspeicher->fields("countries_id"); }else{ $sql = "SELECT countries_id FROM " . TABLE_COUNTRIES . " WHERE countries_iso_code_2 = 'DE'"; $rsspeicher = $this->db->Execute($sql); $Mapping["entry_country_id"]=$rsspeicher->fields("countries_id");; } $Mapping["entry_zone_id"]=0; $Mapping["address_date_added"]=date("d.m.Y",time()); $Mapping["address_last_modified"]=date("d.m.Y",time()); $sql = "SELECT * FROM " . TABLE_ADDRESS_BOOK . " WHERE customers_id = " . $XTCKundennummer . ""; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ $sql = $this->db->GetUpdateSQL($rs,$Mapping); }else{ $sql = $this->db->GetInsertSQL($rs,$Mapping); } if ($sql){$this->db->Execute($sql);} // Adressbuch Nummer ermitteln, um Kundendatensatz zu aktualisieren $sql = "SELECT address_book_id FROM " . TABLE_ADDRESS_BOOK . " WHERE customers_id = " . $XTCKundennummer . ""; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ $sql = "UPDATE ". TABLE_CUSTOMERS . " SET customers_default_address_id = " . $rs->fields("address_book_id") . " WHERE customers_id = " . $XTCKundennummer . ""; $this->db->Execute($sql); }else{ } // Zusatz Tabelle $sql = "SELECT * FROM " . TABLE_CUSTOMERS_INFO . " WHERE customers_info_id = " . $XTCKundennummer; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ // }else{ $sql = "INSERT INTO " . TABLE_CUSTOMERS_INFO . " (customers_info_id) VALUES (" . $XTCKundennummer . ")"; } if ($sql){$this->db->Execute($sql);} }else{ } }else{ //$this->Log("Adresse (" . (string)$value->NR . ") hat keine Gültige Email Adresse."); } } } } /** * Liest eine Auftragsdatei und hinterlegt einen entsprechenden Status und sendet * gegeben falls ein Status per Email * @param String $xml */ function setAuftragStatus($xml){ foreach ($xml as $id => $value){ $TempOrderID=$value->SHOP_NR; $StatusVersendet=3; $StatusEmailVersendet=0; // Bestellung vorhanden? $sql = "SELECT customers_name, customers_email_address, orders_status, date_purchased FROM ".TABLE_ORDERS." WHERE orders_id = '".xtc_db_input($TempOrderID)."'"; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ $TempComments ="Versandatum: " . $value->VERSANDDATUM . "\n"; $TempComments.="Zahlungsdatum: " . $value->ZAHLUNGSDATUM . "\n"; $TempComments.="Paketnummer: " . trim($value->PAKETNUMMER) . ""; } // Email versenden if ($value->VERSANDMAIL == 1){ require_once (DIR_FS_CATALOG.DIR_WS_CLASSES.'class.phpmailer.php'); require_once (DIR_FS_INC.'xtc_php_mail.inc.php'); // Text erzeugen $smarty = new Smarty; $smarty->assign('language', $_SESSION['language']); $smarty->caching = false; $smarty->template_dir = DIR_FS_CATALOG.'templates'; $smarty->compile_dir = DIR_FS_CATALOG.'templates_c'; $smarty->config_dir = DIR_FS_CATALOG.'lang'; $smarty->assign('tpl_path', 'templates/'.CURRENT_TEMPLATE.'/'); $smarty->assign('logo_path', HTTP_SERVER.DIR_WS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/img/'); $smarty->assign('NAME', $check_status['customers_name']); $smarty->assign('ORDER_NR', $TempOrderID); $smarty->assign('ORDER_ID', $TempOrderID); $smarty->assign('ORDER_LINK', xtc_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id='.$TempOrderID, 'SSL')); $smarty->assign('ORDER_DATE', xtc_date_long($check_status['date_purchased'])); $smarty->assign('NOTIFY_COMMENTS', nl2br($TempComments)); // Tomcraft - 2009-10-10 - Fixed wordwrap in notify_comments $smarty->assign('ORDER_STATUS', $orders_status_array[$StatusVersendet]); $html_mail = $smarty->fetch(DIR_FS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/admin/mail/german/change_order_mail.html'); $txt_mail = $smarty->fetch(DIR_FS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/admin/mail/german/change_order_mail.txt'); xtc_php_mail(EMAIL_BILLING_ADDRESS, EMAIL_BILLING_NAME, $rs->fields("customers_email_address"), $rs->fields("customers_name"), '', EMAIL_BILLING_REPLY_ADDRESS, EMAIL_BILLING_REPLY_ADDRESS_NAME, $TempFilename, '', EMAIL_BILLING_SUBJECT, $html_mail, $txt_mail); $StatusEmailVersendet=1; } // Notiz speichern xtc_db_query("INSERT INTO ".TABLE_ORDERS_STATUS_HISTORY." (orders_id, orders_status_id, date_added, customer_notified, comments) values ('".xtc_db_input($TempOrderID)."', '".xtc_db_input($StatusVersendet)."', now(), '".$StatusEmailVersendet."', '".xtc_db_input($TempComments)."')"); } } /** * Liefert den MWST Schluessel * * @param String mwst * @return Integer id **/ function getMWSTID($mwst){ $sql = "SELECT tax_class_id FROM " . TABLE_TAX_RATES . " WHERE tax_rate = " . number_format(str_replace(",",".",$mwst),4,".","") . ""; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ return $rs->fields("tax_class_id"); }else{ return 1; } } /** * Liefert die Sprachen ID * * @param String sprache * @return Integer id **/ function getSprachenID($sprache){ if (strlen($sprache) != 2){ switch (strtolower($sprache)){ case "d": $sprache="DE";break; case "e": $sprache="EN";break; case "f": $sprache="FR";break; case "i": $sprache="IT";break; case "n": $sprache="NO";break; case "s": $sprache="SE";break; } } $sql = "SELECT languages_id FROM " . TABLE_LANGUAGES . " WHERE LOWER(code) = '" . strtolower($sprache) . "'"; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ return $rs->fields("languages_id"); }else{ return 0; } } /** * Liefert die Kundengruppen ID zurueck * * @param Integer id * @return Integer KundengruppenID */ function getKundengruppenID($id){ $Kundengruppe=$this->StdKundengruppe; if ($id > 0){ /* $sql = "SELECT customers_status_id FROM " . TABLE_CUSTOMERS_STATUS . " WHERE customers_status_name = 'VK" . $id . "'"; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ $Kundengruppe = $rs->fields("customers_status_id"); } */ if ($this->Config->get("xstar_syncmercator_pgr_kundengruppe_vk" . $id) > 0){ $Kundengruppe=$this->Config->get("xstar_syncmercator_pgr_kundengruppe_vk" . $id); } } return $Kundengruppe; } /** * Liefert den Namen der Kundengruppe * @param unknown_type $customers_status_id * @return unknown_type */ function getKundengruppenNameSchnittstelle($customers_status_id){ $Kundengruppenname="VK4"; for ($i=0 ; $i<=8 ; $i++){ if($this->Config->get("xstar_syncmercator_pgr_kundengruppe_vk" . $i) == $customers_status_id){ $Kundengruppenname="VK" . $i; } } return $Kundengruppenname; } /** * Prüft die bestehenden Kunden */ function checkKundengruppen(){ $this->setStatus("Kundengruppen werden geprueft."); $sql = "SELECT customers_id FROM `customers` LEFT JOIN customers_status ON customers.customers_status = customers_status.customers_status_id WHERE customers_status.customers_status_id IS NULL"; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ while (!$rs->EOF){ $sql = "UPDATE " . TABLE_CUSTOMERS . " SET customers_status = " . $this->StdKundengruppe . " WHERE customers_id = " . $rs->fields("customers_id") . ""; $this->db->Execute(sql); $rs->MoveNext(); } } } /** * Aktualisiert die Herstellerliste * * @param String xml **/ function addHersteller($xml){ if (count($xml->HERSTELLER) > 0){ $this->setStatus("Hersteller werden angelegt bzw. modifiziert."); foreach ($xml->HERSTELLER as $id => $value){ $Maping=array(); if ((string)$value->NR > 0){ $Mapping["manufacturers_id"]=(string)$value->NR; $Mapping["manufacturers_name"]=$this->ConvertText2DB((string)$value->NAME1); $Mapping["manufacturers_image"]=""; $Mapping["date_added"]=date("d.m.Y",time()); $Mapping["last_modified"]=date("d.m.Y",time()); $sql = "SELECT * FROM " . TABLE_MANUFACTURERS . " WHERE manufacturers_id = " . $Mapping["manufacturers_id"] . ""; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ $sql = $this->db->GetUpdateSQL($rs,$Mapping); //$this->Log("Hersteller '" . $Mapping["manufacturers_name"] . "' wird modifziert."); }else{ $sql = $this->db->GetInsertSQL($rs,$Mapping); //$this->Log("Hersteller '" . $Mapping["manufacturers_name"] . "' wird angelegt."); } if ($sql){$this->db->Execute($sql);} } } } } /** * Liefert die Hersteller ID zurueck * * @param String herstellerxml * @return Integer herstellerid **/ function getHerstellerID($herstellerxml){ $Maping=array(); if ((string)$herstellerxml->NR > 0){ $Mapping["manufacturers_id"]=(string)$herstellerxml->NR; $Mapping["manufacturers_name"]=(string)$herstellerxml->NAME1; $Mapping["manufacturers_image"]=""; $Mapping["date_added"]=date("d.m.Y",time()); $Mapping["last_modified"]=date("d.m.Y",time()); $sql = "SELECT * FROM " . TABLE_MANUFACTURERS . " WHERE manufacturers_id = " . $Mapping["manufacturers_id"] . ""; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ // Hersteller werden durch Herstellerliste angelegt //$sql = $this->db->GetUpdateSQL($rs,$Mapping); }else{ $sql = $this->db->GetInsertSQL($rs,$Mapping); } if ($sql){$this->db->Execute($sql);} return $Mapping["manufacturers_id"]; }else{ return 0; } } /** * Erzeugt und aktualsiert die Kategorien * * @param String xml **/ function addKategorien($xml){ if (count($xml->KATEGORIE) > 0){ $this->setStatus("Kategorien werden angelegt (" . time() . ")."); // BESTEHENDE KATEGORIEN LOESCHEN $sql = "DELETE FROM " . TABLE_CATEGORIES . ";"; $this->db->Execute($sql); $sql = "DELETE FROM " . TABLE_CATEGORIES_DESCRIPTION . ";"; $this->db->Execute($sql); // Standardkategorie anlegen $Mapping=array(); $Mapping["categories_id"]=1; $Mapping["categories_image"]=""; $Mapping["parent_id"]=0; $Mapping["categories_status"]=0; $Mapping["categories_template"]="default"; $Mapping["group_permission_0"]=0; $Mapping["group_permission_1"]=0; $Mapping["group_permission_2"]=0; $Mapping["group_permission_3"]=0; $Mapping["listing_template"]="default"; $Mapping["sort_order"]=0; $Mapping["products_sorting"]="p.products_modell"; $Mapping["products_sorting2"]="ASC"; $Mapping["date_added"]=date("d.m.Y",time()); $Mapping["last_modified"]=date("d.m.Y",time()); $sql = "SELECT * FROM " . TABLE_CATEGORIES . " WHERE categories_id = " . $Mapping["categories_id"] . ""; $rs = $this->db->Execute($sql); $sql = $this->db->GetInsertSQL($rs,$Mapping); if ($sql){$this->db->Execute($sql);} // Varianten - Kategorien $Mapping=array(); $Mapping["categories_id"]=-1; $Mapping["categories_image"]=""; $Mapping["parent_id"]=0; $Mapping["categories_status"]=0; $Mapping["categories_template"]="default"; $Mapping["group_permission_0"]=0; $Mapping["group_permission_1"]=0; $Mapping["group_permission_2"]=0; $Mapping["group_permission_3"]=0; $Mapping["listing_template"]="default"; $Mapping["sort_order"]=0; $Mapping["products_sorting"]="p.products_modell"; $Mapping["products_sorting2"]="ASC"; $Mapping["date_added"]=date("d.m.Y",time()); $Mapping["last_modified"]=date("d.m.Y",time()); $sql = "SELECT * FROM " . TABLE_CATEGORIES . " WHERE categories_id = " . $Mapping["categories_id"] . ""; $rs = $this->db->Execute($sql); $sql = $this->db->GetInsertSQL($rs,$Mapping); if ($sql){$this->db->Execute($sql);} // STD - Kategorie Beschreibung $Mapping=array(); $Mapping["categories_id"]=1; $Mapping["language_id"]=2; $Mapping["categories_name"]="Nicht zuzordnen !!! (ERP Sync)"; $Mapping["categories_heading_title"]=""; $Mapping["categories_description"]=""; $Mapping["categories_meta_title"]=""; $Mapping["categories_meta_description"]=""; $Mapping["categories_meta_keywords"]=""; $sql = "SELECT * FROM " . TABLE_CATEGORIES_DESCRIPTION . " WHERE categories_id = " . $Mapping["categories_id"] . ""; $rs = $this->db->Execute($sql); $sql = $this->db->GetInsertSQL($rs,$Mapping); if ($sql){$this->db->Execute($sql);} // Varianten - Kategorie Beschreibung $Mapping=array(); $Mapping["categories_id"]=-1; $Mapping["language_id"]=2; $Mapping["categories_name"]="Varianten Artikel (ERP Sync)"; $Mapping["categories_heading_title"]=""; $Mapping["categories_description"]=""; $Mapping["categories_meta_title"]=""; $Mapping["categories_meta_description"]=""; $Mapping["categories_meta_keywords"]=""; $sql = "SELECT * FROM " . TABLE_CATEGORIES_DESCRIPTION . " WHERE categories_id = " . $Mapping["categories_id"] . ""; $rs = $this->db->Execute($sql); $sql = $this->db->GetInsertSQL($rs,$Mapping); if ($sql){$this->db->Execute($sql);} // Kategorien anlegen foreach ($xml->KATEGORIE as $id => $value){ $Mapping=array(); $Mapping["categories_id"]=$this->changeKategorienID($value->KAT_ID); if (is_numeric($Mapping["categories_id"])){ $Mapping["categories_image"]=""; $Mapping["parent_id"]=$this->changeKategorienID($value->VATER_ID); if ((string)$value->AKTIV == 1){ $Mapping["categories_status"]=1; }else{ $Mapping["categories_status"]=0; } $Mapping["categories_template"]="default"; $Mapping["group_permission_0"]=0; $Mapping["group_permission_1"]=0; $Mapping["group_permission_2"]=0; $Mapping["group_permission_3"]=0; $Mapping["listing_template"]="default"; $Mapping["sort_order"]=0; switch (strtoupper((string)$value->SORT_FELD)){ case"ARTIKELNUMMER": $Mapping["products_sorting"]="p.products_model"; break; case "EAN": $Mapping["products_sorting"]="p.products_ean"; break; case "PREIS": $Mapping["products_sorting"]="p.products_price"; break; case "ANGELEGT AM": $Mapping["products_sorting"]="p.products_date_added"; break; case "LETZE ÄNDERUNG": $Mapping["products_sorting"]="p.products_last_modified"; break; default: $Mapping["products_sorting"]="p.products_price"; break; } switch (strtoupper((string)$value->SORT_RICHTUNG)){ case "ASC": $Mapping["products_sorting2"]="ASC"; break; case "DESC": $Mapping["products_sorting2"]="DESC"; break; default: $Mapping["products_sorting2"]="ASC"; break; } $Mapping["date_added"]=date("d.m.Y",time()); $Mapping["last_modified"]=date("d.m.Y",time()); // Kategorien $sql = "SELECT * FROM " . TABLE_CATEGORIES . " WHERE categories_id = " . $Mapping["categories_id"] . ""; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ $sql = $this->db->GetUpdateSQL($rs,$Mapping); }else{ $sql = $this->db->GetInsertSQL($rs,$Mapping); } if ($sql){$this->db->Execute($sql);} // Kategorien Sprachen if (count($value->SPRACHE) > 0){ foreach ($value->SPRACHE as $id1 => $value1){ $Mapping=array(); $Mapping["categories_id"]=$this->changeKategorienID($value->KAT_ID); $Mapping["language_id"]=$this->getSprachenID($value1->SPRACH_KZ); $Mapping["categories_name"]=$this->ConvertText2DB((string)$value1->TEXT); $Mapping["categories_heading_title"]=$this->ConvertText2DB((string)$value1->KURZTEXT); $Mapping["categories_description"]=$this->ConvertText2DB((string)$value1->LANGTEXT); $Mapping["categories_meta_title"]=$this->ConvertText2DB((string)$value1->SEO->TITLE); $Mapping["categories_meta_description"]=$this->ConvertText2DB((string)$value1->SEO->DESCR); $Mapping["categories_meta_keywords"]=$this->ConvertText2DB((string)$value1->SEO->KEYW); $sql = "SELECT * FROM " . TABLE_CATEGORIES_DESCRIPTION . " WHERE categories_id = " . $Mapping["categories_id"] . " AND language_id = " . $Mapping["language_id"] . ""; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ $sql = $this->db->GetUpdateSQL($rs,$Mapping); }else{ $sql = $this->db->GetInsertSQL($rs,$Mapping); } if ($sql){$this->db->Execute($sql);} } } }else{ $this->setStatus("-- nicht numerische Kategorie ('" . $Mapping["categories_id"] . "') wird ignoriert.","Fehler"); } } } } /** * Erzeugt fuer XTC einen neue ID * * @param string id * @return integer id **/ function changeKategorienID($id){ if (trim($id)){return "1" . $id;}else{return 0;} } /** * Prueft alle Kategorien, ob diese auch Artikel beinhalten * */ function checkKategorien(){ $this->setStatus("Kategorien werden auf hinterlegte Artikel geprueft."); // Alle Kategorie auf leer setzten $sql = "UPDATE " . TABLE_CATEGORIES . " SET categories_status = 0"; $this->db->Execute($sql); $sql = "SELECT * FROM " . TABLE_PRODUCTS_TO_CATEGORIES . ""; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ while (!$rs->EOF){ $sql = "UPDATE " . TABLE_CATEGORIES . " SET categories_status = 1 WHERE categories_id = " . $rs->fields("categories_id") . ""; $this->db->Execute($sql); $TempCategorie=$rs->fields("categories_id"); do{ $sql = "SELECT * FROM " . TABLE_CATEGORIES . " WHERE categories_id = " . $TempCategorie . ""; $rsspeicher = $this->db->Execute($sql); $TempID=$rsspeicher->fields("parent_id"); $TempCategorie=$rsspeicher->fields("parent_id"); if ($TempID > 0){ $sql = "UPDATE " . TABLE_CATEGORIES . " SET categories_status = 1 WHERE categories_id = " . $TempID . ""; $this->db->Execute($sql); } }while ($TempID>1); $rs->MoveNext(); } // "Nicht Zuzuordnen" wieder verstecken $sql = "UPDATE " . TABLE_CATEGORIES . " SET categories_status = 0 WHERE categories_id = 1"; $this->db->Execute($sql); // Varianten Artikel wieder verstecken $sql = "UPDATE " . TABLE_CATEGORIES . " SET categories_status = 0 WHERE categories_id = -1"; $this->db->Execute($sql); }else{ //$this->Log("keine Katagorien zum prüfen vorhanden."); } } /** * Alle Bildangaben im XTC mit den Dateien prüfen * @return unknown_type */ function checkImages(){ $this->setStatus("Bildverknuepfungen werden geprueft."); $sql = "SELECT * FROM " . TABLE_PRODUCTS_IMAGES . ""; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ while (!$rs->EOF){ $Status=true; // Original Bild $filename=DIR_FS_DOCUMENT_ROOT."/images/product_images/original_images/" . $rs->fields("image_name") . ""; if(!file_exists($filename)){ $Status=false; } // INFO Bild $filename=DIR_FS_DOCUMENT_ROOT."/images/product_images/info_images/" . $rs->fields("image_name") . ""; if(!file_exists($filename)){ $Status=false; } // POPUP Bild $filename=DIR_FS_DOCUMENT_ROOT."/images/product_images/popup_images/" . $rs->fields("image_name") . ""; if(!file_exists($filename)){ $Status=false; } // Thunbnail Bild $filename=DIR_FS_DOCUMENT_ROOT."/images/product_images/thumbnail_images/" . $rs->fields("image_name") . ""; if(!file_exists($filename)){ $Status=false; } // Datensatz aus Datenbank loeschen - Bild existiert nicht if (!$Status){ $sql = "DELETE FROM " . TABLE_PRODUCTS_IMAGES . " WHERE image_id = " . $rs->fields("image_id"); $this->db->Execute($sql); } $rs->MoveNext(); } } } /** * prueft alle Bilder auf Duplikate */ function checkImagesDuplikate($products_id=0){ if (!$products_id){$this->setStatus("Bildduplikate werden entfernt.");} $BildVerzeichnisse=array("original_images","info_images","popup_images","thumbnail_images"); $sql = "SELECT * FROM " . TABLE_PRODUCTS_IMAGES . " pi INNER JOIN " . TABLE_PRODUCTS . " p ON p.products_id = pi.products_id "; if ($products_id > 0){$sql .= " WHERE p.products_id = " .$products_id;} $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ $Bilder=array(); $TempProductsId=0; while (!$rs->EOF){ // Erstes Bild if($TempProductsId != $rs->fields("products_id")){ $TempProductsId = $rs->fields("products_id"); $Bilder[$rs->fields("products_id")][0]["image_name"]=$rs->fields("products_image"); $filename=DIR_FS_DOCUMENT_ROOT."/images/product_images/original_images/".$rs->fields("products_image"); if (file_exists($filename)){ $Bilder[$rs->fields("products_id")][0]["md5"]=hash_file('md5', $filename); } } // Weitere Bilder $Bilder[$rs->fields("products_id")][$rs->fields("image_id")]["image_name"]=$rs->fields("image_name"); $filename=DIR_FS_DOCUMENT_ROOT."/images/product_images/original_images/".$rs->fields("image_name"); if (file_exists($filename)){ $Bilder[$rs->fields("products_id")][$rs->fields("image_id")]["md5"]=hash_file('md5', $filename); } $rs->MoveNext(); } } // doppelte Bilder entfernen if (count($Bilder)>0){ foreach ($Bilder as $id => $value){ $i=0; foreach ($value as $id_bild => $value_bild){ if ($i > 0){ if ($value_bild["md5"] == $value[0]["md5"]){ foreach ($BildVerzeichnisse as $key => $path){ $filename=DIR_FS_DOCUMENT_ROOT."/images/product_images/" . $path . "/".$value_bild["image_name"]; if (file_exists($filename)){unlink($filename);} } $sql = "DELETE FROM " . TABLE_PRODUCTS_IMAGES . " WHERE image_id = " . $id_bild; $this->db->Execute($sql); } } $i++; } } } } /** * Loescht die Bilder */ function deleteImportImages(){ if ($this->Config->get("xstar_syncmercator_importbilder_loeschen")!=1){ $this->setStatus("Nicht benoetigte Bilder werden geloescht."); $PathInhaltBilder=$this->fs->readDir($this->PathImport."bilder/"); if (count($PathInhaltBilder)>0){ $this->setStatus("restliche Bilder, deren Zurordnung fehlt, werden geloescht"); foreach ($PathInhaltBilder as $id => $value){ $filename=$this->PathImport."bilder/".$value["name"]; if (file_exists($filename)){unlink($filename);} } } } } /** * Sortierung der Kategorien */ function sortKategorien(){ $this->setStatus("Sortierung fuer Kategorien wird durchgefuehrt."); $sql = "SELECT LEFT(CONCAT(categories_id,'000000000000000'),15) AS categories_id_neu, categories_id FROM " . TABLE_CATEGORIES . " ORDER BY categories_id"; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ $ids=array(); while (!$rs->EOF){ $ids[$rs->fields("categories_id_neu")]=$rs->fields("categories_id"); $rs->MoveNext(); } $Zaehler=0; foreach ($ids as $id => $value){ $sql = "UPDATE " . TABLE_CATEGORIES . " SET sort_order = " . $Zaehler . " WHERE categories_id = " . $value; $this->db->Execute($sql); $Zaehler++; } } } /** * Liesst eine vorgegebene XML Datei * * @param String filename **/ function readXML($filename){ if (file_exists($filename)){ $xml=simplexml_load_file($filename); return $xml; }else{ $this->showMeldung(0,2,array("%filename%"=>$filename)); return false; } } /** * Loescht den Dateinamen pysikalisch und aus dem Hilfsspeicher * @param $filename */ function deleteXML($filename){ if (file_exists($filename)){ if (!$this->Config->get("xstar_syncmercator_importdateien_loeschen")){ unlink($filename); } } } /** * Liefert ein XML String zurueck * * @param $Ebene * @param $Name * @param $Wert * @return $String */ function getXMLNode($Ebene=0,$Name,$Wert){ $XML=""; for($i=0 ; $i <= $Ebene ; $i++){ $XML.="\t"; } $Wert=str_replace("\n"," ",$Wert); if ($this->is_utf8($Wert)){ $Wert=utf8_decode($Wert); } $XML.="<" . $Name . ">" . $Wert . "\n"; return $XML; } /** * Gibt die Meldung aus * * @param String wert **/ function showMeldung($erfolgreich=0,$meldungid=0,$austauschen=array()){ $Ausgabe=""; $Meldungstext=$this->getMeldungsText($meldungid); // Austausch Parameter uebergeben if (count($austauschen)>0){ foreach ($austauschen as $id => $value){ $Meldungstext = str_replace($id,$value,$Meldungstext); } } $Ausgabe=$erfolgreich."~".$meldungid."~".$Meldungstext."~".$this->LogFileLink; if ($this->quiet!=true){print $Ausgabe;} } /** * Ausgabe auf dem Bildschirm * @param $wert */ function setStatus($wert,$art=""){ $wert=htmlentities(utf8_decode($wert)); $wert=str_replace("�","ä",$wert); $wert=str_replace("�","ü",$wert); $wert=str_replace("�","ö",$wert); $wert=str_replace("�","Ä",$wert); $wert=str_replace("�","Ö",$wert); $wert=str_replace("�","Ü",$wert); $wert=str_replace("<","<",$wert); $wert=str_replace(">",">",$wert); $Ausgabe=$wert; if ($this->Debug){print $wert;} // Datenbank Speicherung $Daten=array(); $Daten["sync_id"]=$this->getTODOID(); $Daten["datumuhrzeit"]=str_replace("'","",$this->db->DBTimeStamp(date("Y-m-d H:i:s",time()))); $Daten["beschreibung"]=$Ausgabe; $sql = "SELECT * FROM syncwawi_log"; $rs = $this->db->Execute($sql); $sql = $this->db->GetInsertSQL($rs,$Daten); $this->db->Execute($sql); } /** * Liefert einen Meldungstext zurueck * * @param Integer meldungid * @return String meldung **/ function getMeldungsText($meldungid){ $meldung=""; if ($this->Meldungen[$meldungid]){ return $this->Meldungen[$meldungid]; }else{ return "nicht definiert."; } } /** * Konvertiert Text zum Datenbankstandard * * @param String text * @return String text_konvertiert **/ function ConvertText2DB($text){ return utf8_decode($text); } /** * Prueft eine Email auf Guelitgkeit * * @param String mail * @param Boolean Status **/ function checkEmail($mail){ if(eregi("^[a-z0-9]+([-_\.]?[a-z0-9])+@[a-z0-9]+([-_\.]?[a-z0-9])+\.[a-z]{2,4}$",$mail)){ return true; }else{ return false; } } /** * Versendet eine Bestaetigungsemail */ function sendMail(){ $my = new MyMail(); $my->subject="Syncmodul Mercator / XTC Status"; $body.="

" . $this->Programmname . "
copyright by WEBDESIGN-RÜSTMANN 2009 - " . date("Y",time()) . "

"; $body.="

 

"; $body.="

Ihre Daten wurden erfolgreich synchronisiert.

"; $body.="

Die einzeln Schritte können Sie im unten stehenden Log einsehen:

"; $body.="

 

"; $body.="

--- Log Anfang ---

"; // Log auslesen $sql = "SELECT * FROM syncwawi_log WHERE sync_id = " . $this->getTODOID(); $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ // Standard Log auslesen $TempTime1=strtotime($rs->fields("datumuhrzeit")); while (!$rs->EOF){ $body.="

" . $rs->fields("datumuhrzeit") . ": " . $rs->fields("beschreibung") . "

"; $rs->MoveNext(); } $TempTime2=strtotime($rs->fields("datumuhrzeit")); // Weiteres Log auslesen - was wurde verarbeitet $Dateien=array("Artikel","Hersteller","Kategorien"); $body.="

------------------------------------------------------

"; $body.="

nachfolgende Anzahl von Dateien wurden verarbeitet:

"; $body.=""; foreach ($Dateien as $id => $value){ $sql = "SELECT COUNT(*) AS anzahl FROM syncwawi WHERE wert LIKE '%" . strtolower($value) . "%' AND art = 'FILE' AND erledigt = 1"; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ if ($rs->fields("anzahl")>0){ $body.="

Anzahl der Dateien '" . $value . "': " . $rs->fields("anzahl") . "

"; } } } $body.="

--- Log Ende ---

"; }else{ $body.="

Es gab nichts zu tun :-).

"; } $my->body=$body; $my->send(); } /** * Liefert den Mercator CSS Style */ function getCSS(){ $filename=DIR_FS_DOCUMENT_ROOT_XSTAR."/style/SyncMercator.css"; $Temp=""; return $Temp; } /** * Erzeugt eine Aufgabe in der Datenbank * @param $art * @param $wert * @param $sort * @param $erledigt */ function addTODO($art, $wert, $sort=0, $erledigt=0){ $sql = "INSERT INTO syncwawi ( art, wert, sort, erledigt) VALUES ('" . $art . "', '" . $wert . "', " . $sort . ", " . $erledigt . ")"; $this->db->Execute($sql); } /** * Liefert die aktuelle TODO ID */ function getTODOID(){ if ($this->TODOID > 0){ return $this->TODOID; }else{ $sql = "SELECT * FROM syncwawi WHERE art = 'ID'"; $rs = $this->db->Execute($sql); if (!$rs->EOF && $rs){ return $rs->fields("wert"); }else{ return 0; } } } /** * Erzeugt alle benoetigten Tabellen */ function createTables(){ $Daten=array(); $Daten["SELECT * FROM syncwawi"]="CREATE TABLE syncwawi (id integer NOT NULL AUTO_INCREMENT,art varchar(100),wert varchar(255),sort integer DEFAULT 0,erledigt integer DEFAULT 0,PRIMARY KEY (`id`))"; $Daten["SHOW INDEX FROM syncwawi WHERE Column_name IN ('id','sort','erledigt')"]="ALTER TABLE `syncwawi` ADD INDEX ( `id` , `sort` , `erledigt` );"; $Daten["SELECT * FROM syncwawi_log"]="CREATE TABLE syncwawi_log (log_id integer NOT NULL AUTO_INCREMENT,sync_id integer,datumuhrzeit TIMESTAMP,beschreibung text,PRIMARY KEY (`log_id`))"; $Daten["SHOW INDEX FROM syncwawi_log WHERE Column_name IN ('log_id','sync_id')"]="ALTER TABLE `syncwawi_log` ADD INDEX ( `log_id` , `sync_id` ) ;"; $Daten["SELECT products_price_quantity FROM " . TABLE_PRODUCTS]="ALTER TABLE `products` ADD `products_price_quantity` INT NOT NULL"; $Daten["SELECT in_bearbeitung FROM syncwawi"]="ALTER TABLE `syncwawi` ADD `in_bearbeitung` INT NOT NULL"; foreach ($Daten as $id => $value){ $rs = $this->db->Execute($id); if (!$rs){$this->db->Execute($value);} } } /** * Prueft, ob ein Wert UTF8 ist * @param $str */ function is_utf8($str){ $strlen = strlen($str); for($i=0; $i<$strlen; $i++){ $ord = ord($str[$i]); if($ord < 0x80) continue; // 0bbbbbbb elseif(($ord&0xE0)===0xC0 && $ord>0xC1) $n = 1; // 110bbbbb (exkl C0-C1) elseif(($ord&0xF0)===0xE0) $n = 2; // 1110bbbb elseif(($ord&0xF8)===0xF0 && $ord<0xF5) $n = 3; // 11110bbb (exkl F5-FF) else return false; // ung�ltiges UTF-8-Zeichen for($c=0; $c<$n; $c++) // $n Folgebytes? // 10bbbbbb if(++$i===$strlen || (ord($str[$i])&0xC0)!==0x80) return false; // ung�ltiges UTF-8-Zeichen } return true; // kein ung�ltiges UTF-8-Zeichen gefunden } } ?> Reinigungsmittel - most-Haustechnik


" . $value . "
" . $value1 . "
Impressum | Versand | Kontakt  


Im Angebot
Whirlpoolsystem Capri 130
statt 999,99 nur 736,60 EUR
Zum Angebot
Zu Ihrem Warenkorb
Zur Kasse
Anmelden
Startseite » Katalog » Reinigungsmittel
Suche

Erweiterte Suche »

Reinigungsmittel

Weitere Unterkategorien:
Brennerreiniger
Kaminreiniger
Lecksuchsprays
Rohrreiniger
Schweissschutzsprays

Neue Artikel

Kaminglasscheibenreiniger (Flasche 500 ml)

Kaminglasscheibenreiniger (Flasche 500 ml)

  • extrem leistungsstark
  • Kaminglasscheibenreiniger ist ein Mittel zur Reinigung von Russ, Teer, Kohlestaub, Fettrueckstaenden, usw. an Ofenglaseinsaetzen und Kaminscheiben aber auch fuer Backoefen, Herde, Grillgeraete, Backgitter und Heizplatten (ausser bei Aluminium)
  • Haltbarkeit bei geschlossenem Gebinde mindestens 3 Jahre

6,96 EUR (inkl. 19 % MwSt. zzgl. Versandkosten)

Details

Ofenschwaerze (Dose 220 ml)

Ofenschwaerze (Dose 220 ml)

  • Pflegemittel fuer gusseiserne Teile
  • die Ofenschwaerze gibt Gusseisen oder Eisenmetallen von Herden oder Grills wieder ein neuartiges Aussehen
  • schuetzt gusseiserne und metallene Teile und Einsaetze von Oefen, Herden oder Grills
  • Farbe schwarz
  • Haltbarkeit bei geschlossenem Gebinde mindestens 4 Jahre

8,75 EUR (inkl. 19 % MwSt. zzgl. Versandkosten)

Details

Entrussungspuder (Dose 900 g)

Entrussungspuder (Dose 900 g)

  • fuer Oefen und Kamine
  • der Russentferner in Pulverform ist ein Mittel zur Reinigung von Kaminen und Einsaetzen von Russ und Teer
  • kann bei allen Oefen und Kesseln verwendet werden, ausser bei Oel- oder Gaseinspritzung
  • ist fuer alle Kaminarten, Einsaetze und Rauchabzuege geeignet
  • entfernt Russ bei Oefen und Kaminen, indem er Teerablagerungen im Rauchabzug oder Kamin austrocknet, so dass die Ablagerungen nicht mehr entflammbar sind
  • eine 900 g Dose entspricht ca. 30 Dosiereinheiten
  • Haltbarkeit bei geschlossenem Gebinde mindestens 3 Jahre

10,71 EUR (inkl. 19 % MwSt. zzgl. Versandkosten)

Details

Brennerkammer-Entrusser (Spruehflasche 500 ml)

Brennerkammer-Entrusser (Spruehflasche 500 ml)

  • Reiniger fuer Brennkammern von Oel- und Gasheizungen
  • der Brennkammer-Entrusser ist ein Mittel zur Reinigung und Wartung von Brennkammern von Oel- ,Gas- und Gemischtheizungen
  • er loest Russablagerungen, schwefelhaltige Verkrustungen und vergluehten Staub in der Brennkammer und deren Rauchabzuegen
  • er verbessert die Heizleistung und verzoegert die Bildung neuer Ablagerungen
  • Haltbarkeit bei geschlossenem Gebinde mindestens 3 Jahre

15,32 EUR (inkl. 19 % MwSt. zzgl. Versandkosten)

Details

Brennerreiniger (Spruehflasche 500 ml)

Brennerreiniger (Spruehflasche 500 ml)

  • Reinigungsmittel fuer Oelbrenner
  • der Brennerreiniger ist ein Mittel zur Reinigung von Oelbrennern
  • er loest Fette und Russablagerungen an Brennerkoepfen und Filtern auf
  • er wirkt nicht korrosiv und greift den Lack nicht an
  • Haltbarkeit bei geschlossenem Gebinde mindestens 2 Jahre

13,39 EUR (inkl. 19 % MwSt. zzgl. Versandkosten)

Details

Lecksuchspray (Dose 400 ml)

Lecksuchspray (Dose 400 ml)

  • das Lecksuchspray ist fuer alle Gase und Druckluft geeignet (kein Sauerstoff)
  • zum Auffinden von Leckagen an Rohrleitungen, Gasleitungen, Anschluessen, Ventilen, Haehnen, Schlaeuchen, usw. in Heizkreislaeufen, Klimaanlagen und Kuehlkreislaeufen
  • auch bei entzuendlichen Gasen anwendbar
  • es findet Undichtigkeiten und Lecks schon bei niedrigem Druck
  • es arbeitet auf Basis eines nicht entzuendlichen Treibgases, welches umweltfreundlich ist
  • bei geschlossenem Gebinde mindestens 3 Jahre haltbar

6,60 EUR (inkl. 19 % MwSt. zzgl. Versandkosten)

Details

Thermostop (Flasche 1 Liter)

Thermostop (Flasche 1 Liter)

  • Schutz von Oberflaechen und empfindlichen Teilen gegen beim Loeten und Schweissen entstehende Waerme
  • Thermostop ist ein Gel, das beim Schweissen oder Loeten die Waerme aufnimmt, sich dabei nach und nach zersetzt und den Bereich dahinter schuetzt
  • Thermostop wirkt dabei wie ein Schutzschild
  • es verhindert zum Beispiel ein Loesen von Dichtungen, Teile dehnen sich wesentlich weniger aus oder empfindliche Bauteile werden geschuetzt
  • nicht auf Oberflaechen verwenden, die nicht mit Wasser abgewaschen werden duerfen
  • mindestens 18 Monate haltbar

35,63 EUR (inkl. 19 % MwSt. zzgl. Versandkosten)

Details

Fermitex fluessig - chemischer Rohrreiniger (Flasche 1 Liter)

Fermitex fluessig - chemischer Rohrreiniger (Flasche 1 Liter)

  • beseitigt einfach, schnell und zuverlaessig Verstopfungen, ueble Gerueche und gefaehrliche Bakterien in Abguessen von Ausgussbecken, Waschbecken, Klosettbecken und Pissoirbecken
  • nicht auf Aluminium, Zink oder vergoldeten Armaturen verwenden
  • beugt bei regelmaessiger Anwendung auch Verstopfungen vor und verhindert Geruchsbildung
  • der Rohrreiniger ist aetzend, also geeignete Schutzmittel anwenden

9,21 EUR (inkl. 19 % MwSt. zzgl. Versandkosten)

Details

Fermitex Pulver - chemischer Rohrreiniger (Dose 1 kg)

Fermitex Pulver - chemischer Rohrreiniger (Dose 1 kg)

  • beseitigt einfach, schnell und zuverlaessig Verstopfungen, ueble Gerueche und gefaehrliche Bakterien in Abguessen von Ausgussbecken, Waschbecken, Klosettbecken und Pissoirbecken
  • greift keine Metalle (ausser Aluminium, Zink und vergoldete Armaturen), Glas oder Porzellan an
  • bei Anwendung an Emaille Fermitex vorher separat aufloesen und nicht zu lange an der Emaille stehen lassen, da diese sonst stumpf werden kann
  • der Rohrreiniger ist aetzend, also geeignete Schutzmittel anwenden

8,75 EUR (inkl. 19 % MwSt. zzgl. Versandkosten)

Details

© RS-Filtertechnik.de        Umgesetzt von Liqui.net - Ideen für vernetzte Medien
www.jobdoo.de