oximex.php

Go to the documentation of this file.
00001 <?php
00002 
00005 class oxImex extends oxBase
00006 {
00018     public function export( $iStart, $iLines, $sFilepath)
00019     {
00020         if ( !$this->getViewName()) {
00021             return false;
00022         } elseif ( $this->getViewName() == "lexware") {
00023             return $this->exportLexwareArticles( $iStart, $iLines, $sFilepath);
00024         }
00025 
00026         $myConfig = $this->getConfig();
00027         $oDB      = oxDb::getDb();
00028 
00029         $sWhere = "";
00030 
00031         $sSearch = $this->_sCoreTbl . "__oxshopid";
00032         if ( isset( $this->$sSearch)) {
00033             $sWhere = " where oxshopid = '".$myConfig->getShopId()."' ";
00034         }
00035 
00036         $sSelect = "select count(oxid) from ".$this->getViewName().$sWhere;
00037         $iSize = $oDB->getOne( $sSelect);
00038         if ( $iStart < $iSize) {
00039             // if first, delete the file
00040             $fp = fopen( $sFilepath, "a");
00041 
00042             $sSelect = "select * from ".$this->getViewName().$sWhere;
00043             $rs = $oDB->selectLimit( $sSelect, $iLines, $iStart);
00044             // #573 defining decimal separator
00045             $blDecReplace = false;
00046             $sDecimalSeparator = $myConfig->getConfigParam( 'sDecimalSeparator' );
00047             if ( $sDecimalSeparator != ".") {
00048                 $blDecReplace = true;
00049             }
00050 
00051             while (!$rs->EOF) {
00052                 $sLine = "\"".$this->_sCoreTbl."\"";
00053 
00054                 foreach ( $rs->fields as $iNum => $field) {
00055                     $sLine .= $myConfig->getConfigParam( 'sCSVSign' );
00056 
00057                     if ( !is_numeric( $field)) {
00058                         $sLine .= "\"".$this->interFormSimple($field)."\"";
00059                     } else {
00060                         if ( $blDecReplace) {
00061                             $field = str_replace( ".", $sDecimalSeparator, $field );
00062                         }
00063                         $sLine .= $field;
00064                     }
00065                 }
00066                 $sLine .= "\r\n";
00067 
00068                 fputs( $fp, $sLine);
00069 
00070                 $rs->moveNext();
00071             }
00072 
00073             fclose( $fp);
00074 
00075             return true;
00076         }
00077 
00078         return false;
00079     }
00080 
00092     public function exportUsers( $iStart, $iLines, $sFilepath)
00093     {
00094         $myConfig  = $this->getConfig();
00095 
00096         $aGroups = oxSession::getVar("_agroups");
00097 
00098         if ( !$this->getViewName() || !$aGroups) {
00099             return false;
00100         }
00101 
00102         $oDB = oxDb::getDb();
00103 
00104         $sWhere = "";
00105         $sInGroup = "";
00106         $blSep = false;
00107         foreach ($aGroups as $sGroupId => $iAct) {
00108             if ($blSep) {
00109                 $sInGroup .= ", ";
00110             }
00111             $sInGroup .= "'".$sGroupId."'";
00112             $blSep = true;
00113         }
00114 
00115         $sSelect  = "select count(".$this->getViewName().".oxid) from ".$this->getViewName()." ";
00116         $sSelect .= "left join oxobject2group on ".$this->getViewName().".oxid=oxobject2group.oxobjectid ";
00117         $sSelect .= "where oxobject2group.oxgroupsid in ($sInGroup) ";
00118         $sSearch = $this->getViewName() . "__oxshopid";
00119         if ( isset( $this->$sSearch)) {
00120             $sSelect .= $sWhere = "and ".$this->getViewName().".oxshopid = '".$myConfig->getShopId()."' ";
00121         }
00122 
00123         $iSize = $oDB->getOne( $sSelect);
00124         if ( $iStart < $iSize) {   // #387A creating object to fetch field information
00125             $oObj = oxNew( "oxbase" );
00126             $oObj->init($this->getViewName());
00127 
00128             // if first, delete the file
00129             $fp = fopen( $sFilepath, "a");
00130 
00131             $sSelect  = "select * from ".$this->getViewName()." ";
00132             $sSelect .= "left join oxobject2group on ".$this->getViewName().".oxid=oxobject2group.oxobjectid ";
00133             $sSelect .= "where oxobject2group.oxgroupsid in ($sInGroup) ".$sWhere;
00134             $rs = $oDB->selectLimit( $sSelect, $iLines, $iStart);
00135 
00136             // #573 defining decimal separator
00137             $blDecReplace = false;
00138             $sDecimalSeparator = $myConfig->getConfigParam( 'sDecimalSeparator' );
00139             if ( $sDecimalSeparator != "." ) {
00140                 $blDecReplace = true;
00141             }
00142 
00143             while (!$rs->EOF) {
00144                 $sLine = "\"".$this->getViewName()."\"";
00145 
00146                 foreach ( $rs->fields as $iNum => $field) {
00147                     $sLine .= $myConfig->getConfigParam( 'sCSVSign' );
00148 
00149                     if ( !is_numeric( $field)) {   // #387A
00150                         $oFieldObj = null;
00151                         $aIdx2FldName = $oObj->getIdx2FldName();
00152                         if ( isset($aIdx2FldName[$iNum])) {
00153                             $sFieldName = $aIdx2FldName[$iNum];
00154                             //#1096S full copy instead of reference.
00155                             $oFieldObj = clone $oObj->$sFieldName;
00156                         }
00157 
00158                         $sLine .= "\"".$this->interForm($field, $oFieldObj)."\"";
00159                     } else {
00160                         if ( $blDecReplace) {
00161                             $field = str_replace( ".", $sDecimalSeparator, $field );
00162                         }
00163                         $sLine .= $field;
00164                     }
00165                 }
00166                 $sLine .= "\r\n";
00167 
00168                 fputs( $fp, $sLine);
00169 
00170                 $rs->moveNext();
00171             }
00172 
00173             fclose( $fp);
00174             return true;
00175         }
00176 
00177         return false;
00178     }
00179 
00189     public function exportLexwareArticles( $iStart, $iLines, $sFilepath)
00190     {
00191         $myConfig = $this->getConfig();
00192         $oDB      = oxDb::getDb();
00193 
00194         $sArticleTable = getViewName('oxarticles');
00195 
00196         $sSelect = "select count(oxid) from $sArticleTable ";
00197         $iSize = $oDB->getOne( $sSelect);
00198 
00199         if ( $iStart < $iSize) {
00200             $fp = fopen( $sFilepath, "ab");
00201             if ( !$iStart) {   // first time, write header
00202                 fwrite( $fp, "\"Artikelnummer\";\"Bezeichnung\";\"Einheit\";\"Gewicht\";\"Matchcode\";\"Preis pro Anzahl\";\"Warengruppe\";\"Warengr.-Kurzbez.\";\"Warengr.-Steuersatz\";\"Warengr.-Konto Inland\";\"Warengr.-Konto Ausland\";\"Warengr.-Konto EG\";\"Preis 1\";\"Preis 2\";\"Preis 3\";\"Preis I/1\";\"Preis I/2\";\"Preis I/3\";\"Preis II/1\";\"Preis II/2\";\"Preis II/3\";\"Preis III/1\";\"Preis III/2\";\"Preis III/3\";\"B/N\";\"Lagerartikel\";\"EK 1\";\"Währung EK1\";\"EK 2\";\"Währung EK2\";\"Staffelmenge 1\";\"Staffelmenge 2\";\"Staffelmenge 3\";\"Lieferantennummer 1\";\"Lieferantennummer 2\";\"Bestellmenge Lf.1\";\"Bestellmenge Lf.2\";\"Bestellnr. Lf.1\";\"Bestellnr. Lf.2\";\"Lieferzeit Lf.1\";\"Lieferzeit Lf.2\";\"Lagerbestand\";\"Mindestbestand\";\"Lagerort\";\"Bestellte Menge\";\"Stückliste\";\"Internet\";\"Text\"\r\n");
00203             }
00204             $oldMode = $oDB->setFetchMode( ADODB_FETCH_ASSOC);
00205             $sSelect = "select * from $sArticleTable ";
00206             $rs = $oDB->selectLimit( $sSelect, $iLines, $iStart);
00207             $oDB->setFetchMode( $oldMode);
00208 
00209             while (!$rs->EOF) {
00210                 $oArticle = oxNew( "oxarticle" );
00211                 $blAdmin = $this->isAdmin();
00212                 // TODO: this workaround should be overworked
00213                 $this->setAdminMode( false );
00214                 $oArticle->load( $rs->fields['OXID']);
00215                 $this->setAdminMode( $blAdmin );
00216 
00217                 $sSelect = "select oxtitle from oxarticles where oxid = '".$oArticle->oxarticles__oxparentid->value."'";
00218                 $oTitle = $oDB->getOne( $sSelect);
00219                 if ($oTitle != false && strlen ($oTitle)) {
00220                     $nTitle = $this->interForm($oTitle);
00221                 } else {
00222                     $nTitle = $this->interForm($oArticle->oxarticles__oxtitle->value);
00223                 }
00224 
00225 
00226                 $sToFile = $oArticle->oxarticles__oxartnum->value            // Artikelnummer
00227                 //.";".$this->interForm($oArticle->oxarticles__oxshortdesc->value." ".$oArticle->oxarticles__oxvarselect->value) // Bezeichnung
00228                 .";".$nTitle." ".$this->interForm($oArticle->oxarticles__oxvarselect->value) // Bezeichnung
00229                 .";"."Stueck"                        // Einheit
00230                 .";".$oArticle->oxarticles__oxweight->value                  // Gewicht
00231                 .";".$oArticle->oxarticles__oxartnum->value                  // Matchcode
00232                 .";"."1,000"                         // Preis pro Anzahl
00233                 .";"                                  // Warengruppe
00234                 .";"                                  // Warengr.-Kurzbez.
00235                 .";"                                 // Warengr.-Steuersatz
00236                 .";"                                  // Warengr.-Konto Inland
00237                 .";"                                  // Warengr.-Konto Ausland
00238                 .";"                                  // Warengr.-Konto EG
00239                 .";".number_format($oArticle->oxarticles__oxprice->value, 2, '.', '')  // Preis 1
00240                 .";"                                  // Preis 2
00241                 .";"                                 // Preis 3
00242                 .";"                                 // Preis I/1
00243                 .";"                                 // Preis I/2
00244                 .";"                                  // Preis I/3
00245                 .";"                                  // Preis II/1
00246                 .";"                                  // Preis II/2
00247                 .";"                                  // Preis II/3
00248                 .";"                                  // Preis III/1
00249                 .";"                                  // Preis III/2
00250                 .";"                                  // Preis III/3
00251                 .";"                           // B/N
00252                 .";"                           // Lagerartikel
00253                 //.";".number_format($oArticle->oxarticles__oxtprice->value, 2, '.', '')// EK 1
00254                 // #343 fix
00255                 .";".number_format($oArticle->oxarticles__oxbprice->value, 2, '.', '')// EK 1
00256                 .";"                           // Währung EK1
00257                 .";"                           // EK 2
00258                 .";"                           // Währung EK2
00259                 .";"                           // Staffelmenge 1
00260                 .";"                           // Staffelmenge 2
00261                 .";"                           // Staffelmenge 3
00262                 .";"                           // Lieferantennummer 1
00263                 .";"                           // Lieferantennummer 2
00264                 .";"                           // Bestellmenge Lf.1
00265                 .";"                           // Bestellmenge Lf.2
00266                 .";"                           // Bestellnr. Lf.1
00267                 .";"                           // Bestellnr. Lf.2
00268                 .";"                           // Lieferzeit Lf.1
00269                 .";"                           // Lieferzeit Lf.2
00270                 .";".$oArticle->oxarticles__oxstock->value           // Lagerbestand
00271                 .";"                           // Mindestbestand
00272                 .";"                           // Lagerort
00273                 .";"                           // Bestellte Menge
00274                 .";"                           // Stückliste
00275                 .";1"                              // Internet
00276                 .";".$this->interForm( $oArticle->oxarticles__oxshortdesc->value.$oArticle->oxarticles__oxlongdesc->value)// Text
00277                 .";";
00278                 $sToFile .= "\r\n";
00279 
00280                 fwrite( $fp, $sToFile);
00281                 $rs->moveNext();
00282             }
00283 
00284             fclose( $fp );
00285             return true;
00286         }
00287 
00288         return false;
00289 
00290     }
00291 
00299     function interFormSimple( $nValue )
00300     {
00301         $nValue = str_replace( "\r", "", $nValue );
00302         $nValue = str_replace( "\n", " ", $nValue );
00303         $nValue = str_replace( '"', '""', $nValue );
00304         return $nValue;
00305     }
00306 
00316     function interForm( $nValue, $oObj = null)
00317     {   // thnx to Volker Dörk for this function and his help here
00318 
00319         // #387A skipping conversion for fields where info must be passed in original format
00320         $aFieldTypesToSkip = array("text", "oxshortdesc", "oxlongdesc");
00321         $blSkipStrpTags = false;
00322         if ( $oObj != null) {
00323             // using object field "fldtype", to skip processing because usually
00324             // this type of field is used for HTML text
00325             //
00326             // you may change field to "fldname" and add to $aFieldTypesToSkip
00327             // "oxlongdesc" value to skip only longdesc field
00328             //
00329             if ( in_array($oObj->fldtype, $aFieldTypesToSkip)) {
00330                 $blSkipStripTags = true;
00331             } elseif ( in_array($oObj->fldname, $aFieldTypesToSkip)) {
00332                 $blSkipStripTags = true;
00333             }
00334         }
00335 
00336         //removing simple & (and not  &uuml; chars)
00337         //(not full just a simple check for existing customers for cases like Johnson&Johnson)
00338 
00339         $oStr = getStr();
00340         if ( $oStr->strpos( $nValue, "&" ) !== false && $oStr->strpos($nValue, ";" ) == false ) {
00341             $nValue = str_replace("&", "&amp;", $nValue);
00342         }
00343 
00344         $nValue = str_replace( "&nbsp;", " ", $nValue);
00345         $nValue = str_replace( "&auml;", "ä", $nValue);
00346         $nValue = str_replace( "&ouml;", "ö", $nValue);
00347         $nValue = str_replace( "&uuml;", "ü", $nValue);
00348         $nValue = str_replace( "&Auml;", "Ä", $nValue);
00349         $nValue = str_replace( "&Ouml;", "Ö", $nValue);
00350         $nValue = str_replace( "&Uuml;", "Ü", $nValue);
00351         $nValue = str_replace( "&szlig;", "ß", $nValue);
00352 
00353         // usually & symbol goes (or should go) like that:
00354         // "& text...", so we predict that this is a rule
00355         // and replace it with special HTML code
00356         $nValue = str_replace( "& ", "&amp; ", $nValue);
00357 
00358         $nValue = str_replace( "\"", "'", $nValue);
00359         $nValue = str_replace( "(", "'", $nValue);
00360         $nValue = str_replace( ")", "'", $nValue);
00361         $nValue = str_replace( "\r\n", "", $nValue);
00362         $nValue = str_replace( "\n", "", $nValue);
00363 
00364         if ( !$blSkipStripTags) {
00365             $nValue = strip_tags( $nValue );
00366         }
00367 
00368         return $nValue;
00369     }
00370 
00378     function internPrice( $nPrice)
00379     {  // thnx to Volker Dörk for this function and his help here
00380         $nPrice = $this->interForm($nPrice);
00381         $nPrice = number_format($nPrice, 2, '.', '');
00382         return $nPrice;
00383     }
00384 
00396     function import( $iStart, $iLines, $sFilepath)
00397     {
00398         $myConfig  = $this->getConfig();
00399         $blContinue = true;
00400 
00401         $fp     = fopen( $sFilepath, "r");
00402         $iEnd   = $iStart+$iLines;
00403         $aData  = null;
00404 
00405         //array of tables whitch were updated
00406         $aProcTables = oxSession::getVar("_aProcTables");
00407         if ( !$aProcTables) {
00408             $aProcTables = array();
00409         }
00410 
00411         // #573 defining decimal separator
00412         $blDecReplace = false;
00413         $sDecimalSeparator = $myConfig->getConfigParam( 'sDecimalSeparator' );
00414         if ( $sDecimalSeparator != "." ) {
00415             $blDecReplace = true;
00416         }
00417 
00418         for ( $i = 0; $i<=$iEnd; $i++) {
00419             $aData = $this->_oxFGetCsv( $fp, 40960, $myConfig->getConfigParam( 'sCSVSign' ) );
00420 
00421             if ( $aData && $i >= $iStart) {   // import
00422 
00423                 // read table description if needed
00424                 $sTable = $aData[0];
00425                 $aProcTables[] = $sTable;
00426                 $this->init( $sTable);
00427                 // remove table from line
00428                 $aData = array_splice( $aData, 1, count($aData)-1);
00429                 foreach ($aData as $key => $value) {
00430                     if ( $value == "''" || $value == "" || !$value) {
00431                         $value = null;
00432                     }
00433 
00434                     // #573 - fixing import
00435                     $sKey = $this->_aIdx2FldName[$key];
00436                     if ( $blDecReplace && $this->$sKey->fldtype == "double") {
00437                         $value = str_replace( $sDecimalSeparator, ".", $value );
00438                     }
00439 
00440                     $aData[$key] = trim($value);
00441                 }
00442                 $this->assign($aData);
00443                 $this->save();
00444             }
00445 
00446             if ( feof( $fp)) {
00447                 $blContinue = false;
00448                 if ( $sTable == "oxcategories" || in_array( "oxcategories", $aProcTables)) {
00449                     $oDB = oxDb::getDb();
00450                     $oDB->execute( "update oxcategories set oxhidden = '0' where oxhidden='' ");
00451                 }
00452                 $aProcTables = array();
00453                 break;
00454             }
00455         }
00456         oxSession::setVar( "_aProcTables", $aProcTables);
00457         fclose( $fp);
00458 
00459         return $blContinue;
00460     }
00461 
00470     function exportLexwareOrders( $iFromOrderNr = null, $iToOrderNr = null)
00471     {
00472         // thnx to Volker Dörk for this function and his help here
00473         $myConfig = $this->getConfig();
00474 
00475         $sRet = "";
00476 
00477         $sNewLine = "\r\n";
00478 
00479         $oOrderlist = oxNew( "oxlist" );
00480         $oOrderlist->init( "oxorder" );
00481 
00482         $sSelect = "select * from oxorder where 1 ";
00483 
00484         if ( !empty( $iFromOrderNr)) {
00485             $sSelect .= "and oxordernr >= $iFromOrderNr ";
00486         }
00487         if ( !empty( $iToOrderNr)) {
00488             $sSelect .= "and oxordernr <= $iToOrderNr ";
00489         }
00490 
00491         $oOrderlist->selectString( $sSelect);
00492 
00493         if ( !$oOrderlist->count() ) {
00494             return null;
00495         }
00496 
00497         $sExport  = "<?xml version=\"1.0\" encoding=\"ISO-8859-15\"?>$sNewLine";
00498         $sExport .= "<Bestellliste>$sNewLine";
00499         $sRet .= $sExport;
00500 
00501         //foreach (array_keys( $oOrderlist) as $key) {
00502         foreach ($oOrderlist->arrayKeys() as $key) {
00503             $oOrder = $oOrderlist[$key];
00504 
00505             $oUser = oxNew( "oxuser" );
00506             $oUser->load( $oOrder->oxorder__oxuserid->value);
00507 
00508             $sExport  = "<Bestellung zurückgestellt=\"Nein\" bearbeitet=\"Nein\" übertragen=\"Nein\">$sNewLine";
00509             $sExport .= "<Bestellnummer>".$oOrder->oxorder__oxordernr->value."</Bestellnummer>$sNewLine";
00510             $sExport .= "<Standardwaehrung>978</Standardwaehrung>$sNewLine";
00511             $sExport .= "<Bestelldatum>$sNewLine";
00512             $sDBDate = oxUtilsDate::getInstance()->formatDBDate($oOrder->oxorder__oxorderdate->value);
00513             $sExport .= "<Datum>".substr($sDBDate, 0, 10)."</Datum>$sNewLine";
00514             $sExport .= "<Zeit>".substr($sDBDate, 11, 8)."</Zeit>$sNewLine";
00515             $sExport .= "</Bestelldatum>$sNewLine";
00516             $sExport .= "<Kunde>$sNewLine";
00517 
00518             $sExport .= "<Kundennummer>"./*$this->interForm($oUser->oxuser__oxcustnr->value).*/"</Kundennummer>$sNewLine";
00519             $sExport .= "<Firmenname>".$this->interForm($oOrder->oxorder__oxbillcompany->value)."</Firmenname>$sNewLine";
00520             $sExport .= "<Vorname>".$this->interForm($oOrder->oxorder__oxbillfname->value)."</Vorname>$sNewLine";
00521             $sExport .= "<Name>".$this->interForm($oOrder->oxorder__oxbilllname->value)."</Name>$sNewLine";
00522             $sExport .= "<Strasse>".$this->interForm($oOrder->oxorder__oxbillstreet->value)." ".$this->interForm($oOrder->oxorder__oxbillstreetnr->value)."</Strasse>$sNewLine";
00523             $sExport .= "<PLZ>".$this->interForm($oOrder->oxorder__oxbillzip->value)."</PLZ>$sNewLine";
00524             $sExport .= "<Ort>".$this->interForm($oOrder->oxorder__oxbillcity->value)."</Ort>$sNewLine";
00525             $sExport .= "<Bundesland>".""."</Bundesland>$sNewLine";
00526             $sExport .= "<Land>".$this->interForm($oOrder->oxorder__oxbillcountry->value)."</Land>$sNewLine";
00527             $sExport .= "<Email>".$this->interForm($oUser->oxuser__oxusername->value)."</Email>$sNewLine";
00528             $sExport .= "<Telefon>".$this->interForm($oOrder->oxorder__oxbillfon->value)."</Telefon>$sNewLine";
00529             $sExport .= "<Telefon2>".$this->interForm($oUser->oxuser__oxprivfon->value)."</Telefon2>$sNewLine";
00530             $sExport .= "<Fax>".$this->interForm($oOrder->oxorder__oxbillfax->value)."</Fax>$sNewLine";
00531 
00532             // lieferadresse
00533             if ( $oOrder->oxorder__oxdellname->value) {
00534                 $sDelComp   = $oOrder->oxorder__oxdelcompany->value;
00535                 $sDelfName  = $oOrder->oxorder__oxdelfname->value;
00536                 $sDellName  = $oOrder->oxorder__oxdellname->value;
00537                 $sDelStreet = $oOrder->oxorder__oxdelstreet->value;
00538                 $sDelZip    = $oOrder->oxorder__oxdelzip->value;
00539                 $sDelCity   = $oOrder->oxorder__oxdelcity->value;
00540                 $sDelCountry= $oOrder->oxorder__oxdelcountry->value;
00541             } else {
00542                 $sDelComp   = "";
00543                 $sDelfName  = "";
00544                 $sDellName  = "";
00545                 $sDelStreet = "";
00546                 $sDelZip    = "";
00547                 $sDelCity   = "";
00548                 $sDelCountry= "";
00549             }
00550 
00551             $sExport .= "<Lieferadresse>$sNewLine";
00552             $sExport .= "<Firmenname>".$this->interForm($sDelComp)."</Firmenname>$sNewLine";
00553             $sExport .= "<Vorname>".$this->interForm($sDelfName)."</Vorname>$sNewLine";
00554             $sExport .= "<Name>".$this->interForm($sDellName)."</Name>$sNewLine";
00555             $sExport .= "<Strasse>".$this->interForm($sDelStreet)."</Strasse>$sNewLine";
00556             $sExport .= "<PLZ>".$this->interForm($sDelZip)."</PLZ>$sNewLine";
00557             $sExport .= "<Ort>".$this->interForm($sDelCity)."</Ort>$sNewLine";
00558             $sExport .= "<Bundesland>".""."</Bundesland>$sNewLine";
00559             $sExport .= "<Land>".$this->interForm($sDelCountry)."</Land>$sNewLine";
00560             $sExport .= "</Lieferadresse>$sNewLine";
00561             $sExport .= "<Matchcode>".$this->interForm($oOrder->oxorder__oxbilllname->value).", ".$this->interForm($oOrder->oxorder__oxbillfname->value)."</Matchcode>$sNewLine";
00562 
00563             // ermitteln ob steuerbar oder nicht
00564             $sCountry = strtolower( $oUser->oxuser__oxcountryid->value);
00565             $aHomeCountry = $myConfig->getConfigParam( 'aHomeCountry' );
00566             if ( is_array( $aHomeCountry ) && in_array( $sCountry, $aHomeCountry ) ) {
00567                 $sSteuerbar = "ja";
00568             } else {
00569                 $sSteuerbar = "nein";
00570             }
00571 
00572             $sExport .= "<fSteuerbar>".$this->interForm($sSteuerbar)."</fSteuerbar>$sNewLine";
00573             $sExport .= "</Kunde>$sNewLine";
00574             $sExport .= "<Artikelliste>$sNewLine";
00575             $sRet .= $sExport;
00576 
00577             $dSumNetPrice = 0;
00578             $dSumBrutPrice = 0;
00579 
00580             /*
00581             if( $oOrder->oxorder__oxdelcost->value)
00582             {   // add virtual article for delivery costs
00583                 $oDelCost = oxNew( "oxorderarticle" );
00584                 $oDelCost->oxorderarticles__oxvat->setValue(0);
00585                 $oDelCost->oxorderarticles__oxnetprice->setValue($oOrder->oxorder__oxdelcost->value);
00586                 $oDelCost->oxorderarticles__oxamount->setValue(1);
00587                 $oDelCost->oxorderarticles__oxtitle->setValue("Versandkosten");
00588                 $oDelCost->oxorderarticles__oxbrutprice->setValue($oOrder->oxorder__oxdelcost->value);
00589                 $oOrder->oArticles['oxdelcostid'] = $oDelCost;
00590             }*/
00591 
00592             $oOrderArticles = $oOrder->getOrderArticles();
00593             foreach ($oOrderArticles->arrayKeys() as $key) {
00594                 $oOrderArt = $oOrderArticles->offsetGet($key);
00595 
00596                 $dVATSet = array_search( $oOrderArt->oxorderarticles__oxvat->value, $myConfig->getConfigParam( 'aLexwareVAT' ) );
00597                 $sExport  = "   <Artikel>$sNewLine";
00598                 //$sExport .= "   <Artikelzusatzinfo><Nettostaffelpreis>".$this->InternPrice( $oOrderArt->oxorderarticles__oxnetprice->value)."</Nettostaffelpreis></Artikelzusatzinfo>$sNewLine";
00599                 $sExport .= "   <Artikelzusatzinfo><Nettostaffelpreis></Nettostaffelpreis></Artikelzusatzinfo>$sNewLine";
00600                 $sExport .= "   <SteuersatzID>".$dVATSet."</SteuersatzID>$sNewLine";
00601                 $sExport .= "   <Steuersatz>".$this->internPrice($oOrderArt->oxorderarticles__oxvat->value/100)."</Steuersatz>$sNewLine";
00602                 $sExport .= "   <Artikelnummer>".$oOrderArt->oxorderarticles__oxartnum->value."</Artikelnummer>$sNewLine";
00603                 $sExport .= "   <Anzahl>".$oOrderArt->oxorderarticles__oxamount->value."</Anzahl>$sNewLine";
00604                 $sExport .= "   <Produktname>".$this->interForm( $oOrderArt->oxorderarticles__oxtitle->value);
00605                 if ( $oOrderArt->oxorderarticles__oxselvariant->value) {
00606                     $sExport .= "/".$oOrderArt->oxorderarticles__oxselvariant->value;
00607                 }
00608                 $sExport .= "   </Produktname>$sNewLine";
00609                 $sExport .= "   <Rabatt>0.00</Rabatt>$sNewLine";
00610                 $sExport .= "   <Preis>".$this->internPrice($oOrderArt->oxorderarticles__oxbrutprice->value/$oOrderArt->oxorderarticles__oxamount->value)."</Preis>$sNewLine";
00611                 $sExport .= "   </Artikel>$sNewLine";
00612                 $sRet .= $sExport;
00613 
00614                 $dSumNetPrice   += $oOrderArt->oxorderarticles__oxnetprice->value;
00615                 $dSumBrutPrice  += $oOrderArt->oxorderarticles__oxbrutprice->value;
00616             }
00617 
00618             $dDiscount = $oOrder->oxorder__oxvoucherdiscount->value + $oOrder->oxorder__oxdiscount->value;
00619             $sExport  = "<GesamtRabatt>".$this->internPrice( $dDiscount)."</GesamtRabatt>$sNewLine";
00620             $sExport .= "<GesamtNetto>".$this->internPrice($dSumNetPrice)."</GesamtNetto>$sNewLine";
00621             $sExport .= "<Lieferkosten>".$this->internPrice($oOrder->oxorder__oxdelcost->value)."</Lieferkosten>$sNewLine";
00622             $sExport .= "<Zahlungsartkosten>0.00</Zahlungsartkosten>$sNewLine";
00623             $sExport .= "<GesamtBrutto>".$this->internPrice($dSumBrutPrice)."</GesamtBrutto>$sNewLine";
00624 
00625             $oUserpayment = oxNew( "oxuserpayment" );
00626             $oUserpayment->load( $oOrder->oxorder__oxpaymentid->value);
00627             $sPayment = $oUserpayment->oxuserpayments__oxvalue->value;
00628             $sPayment = str_replace( "__", "", $sPayment);
00629             $sPayment = str_replace( "@@", ",", $sPayment);
00630 
00631             $oPayment = oxNew( "oxpayment" );
00632             $oPayment->load( $oOrder->oxorder__oxpaymenttype->value);
00633 
00634 
00635             $sExport .= "<Bemerkung>".strip_tags( $oOrder->oxorder__oxremark->value)."</Bemerkung>$sNewLine";
00636             $sRet .= $sExport;
00637 
00638             $sExport  = "</Artikelliste>$sNewLine";
00639 
00640             $sExport .= "<Zahlung>$sNewLine";
00641             $oPayment = oxNew( "oxpayment" );
00642             $oPayment->load( $oOrder->oxorder__oxpaymenttype->value);
00643 
00644             //print_r($oPayment);
00645 
00646             $sExport .= "<Art>".$oPayment->oxpayments__oxdesc->value."</Art>$sNewLine";
00647             $sExport .= "</Zahlung>$sNewLine";
00648 
00649             $sExport .= "</Bestellung>$sNewLine";
00650             $sRet .= $sExport;
00651 
00652 
00653             $oOrder->oxorder__oxexport->setValue(1);
00654             $oOrder->save();
00655 
00656         }
00657         $sExport = "</Bestellliste>$sNewLine";
00658         $sRet .= $sExport;
00659 
00660         return $sRet;
00661     }
00662 
00674     protected function _oxFGetCsv( $fp, $iMaxLen, $sSep )
00675     {
00676         $aRet = null;
00677 
00678         $iField = 0;
00679         $iQuote = 0;
00680 
00681         for ( $i=0; $i<$iMaxLen; $i++) {
00682             $c = fread( $fp, 1);
00683 
00684             if ( ($c === false || !isset( $c)) || (($c == "\n") && !$iQuote)) {
00685                 break;  // end
00686             } elseif ( $c == $sSep && !$iQuote) {
00687                 $iField++;
00688                 $aRet[$iField] = "";
00689                 continue;
00690             } elseif ( $c == "\"") {
00691                 if ( $iQuote) {
00692                     $iQuote--;
00693                 } else {
00694                     $iQuote++;
00695                 }
00696             }
00697             if ( !isset( $aRet[$iField])) {
00698                 $aRet[$iField] = "";
00699             }
00700             $aRet[$iField] .= $c;
00701         }
00702 
00703         if ( count( $aRet) > 1) {
00704             $oStr = getStr();
00705             // remove " or '
00706             foreach ( $aRet as $key => $sField) {
00707                 $sField = trim($sField);
00708                 if ( $sField) {
00709                     if ( $sField[0] == "\"" || $sField[0] == "'") {
00710                         $sField = $oStr->substr( $sField, 1);
00711                     }
00712 
00713                     $iLen = $oStr->strlen( $sField) - 1;
00714                     if ( $sField[$iLen] == "\"" || $sField[$iLen] == "'") {
00715                         $sField = $oStr->substr( $sField, 0, $iLen);
00716                     }
00717 
00718                     $aRet[$key] = $sField;
00719                 }
00720             }
00721             // process "" qoutes
00722             return str_replace('""', '"', $aRet);
00723         } else {
00724             return null;
00725         }
00726     }
00727 }

Generated on Wed Apr 22 12:26:31 2009 for OXID eShop CE by  doxygen 1.5.5