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

Generated on Tue Sep 29 16:45:12 2009 for OXID eShop CE by  doxygen 1.5.5