oxorder.php

Go to the documentation of this file.
00001 <?php
00002 
00006 require_once oxConfig::getInstance()->getConfigParam( 'sCoreDir' ) . 'fpdf/oxpdf.php';
00007 
00013 class oxOrder extends oxBase
00014 {
00015 
00021     protected $_aSkipSaveFields = array( 'oxorderdate' );
00022 
00028     protected $_oArticles = null;
00029 
00035     protected $_oDelSet   = null;
00036 
00042     protected $_oGiftCard = null;
00043 
00049     protected $_oPaymentType = null;
00050 
00056     protected $_oPayment = null;
00057 
00063     protected $_aVoucherList = null;
00064 
00070     protected $_oDelPrice = null;
00071 
00077     protected $_oUser = null;
00078 
00084     protected $_oBasket = null;
00085 
00091     protected $_oWrappingPrice = null;
00092 
00098     protected $_oPaymentPrice = null;
00099 
00105     protected $_sClassName = 'oxorder';
00106 
00112     protected $_blSeparateNumbering = null;
00113 
00119     protected $_iOrderLang = null;
00120 
00124     public function __construct()
00125     {
00126         parent::__construct();
00127         $this->init( 'oxorder' );
00128 
00129         // set usage of seperate orders numbering for different shops
00130         $this->setSeparateNumbering( $this->getConfig()->getConfigParam( 'blSeparateNumbering') );
00131 
00132     }
00133 
00141     public function __get( $sName )
00142     {
00143         if ( $sName == 'oDelSet' ) {
00144             return $this->getDelSet();
00145         }
00146     }
00147 
00155     public function assign( $dbRecord )
00156     {
00157 
00158         parent::assign( $dbRecord );
00159 
00160         // convert date's to international format
00161         $this->oxorder__oxorderdate = new oxField(oxUtilsDate::getInstance()->formatDBDate( $this->oxorder__oxorderdate->value ), oxField::T_RAW);
00162         $this->oxorder__oxsenddate  = new oxField(oxUtilsDate::getInstance()->formatDBDate( $this->oxorder__oxsenddate->value ), oxField::T_RAW);
00163 
00164 
00165         //get billing country name from billing country id
00166         if ( !$this->oxorder__oxbillcountry->value ) {
00167             $this->oxorder__oxbillcountry = new oxField($this->_getCountryTitle( $this->oxorder__oxbillcountryid->value ));
00168         }
00169 
00170         //get delivery country name from delivery country id
00171         if ( !$this->oxorder__oxdelcountry->value ) {
00172              $this->oxorder__oxdelcountry = new oxField($this->_getCountryTitle( $this->oxorder__oxdelcountryid->value ));
00173         }
00174 
00175         //settting deprecated template variables
00176         $this->_setDeprecatedValues();
00177     }
00178 
00186     protected function _getCountryTitle( $sCountryId )
00187     {
00188         $sTitle = null;
00189         if ( $sCountryId && $sCountryId != '-1' ) {
00190             $oCountry = oxNew( 'oxcountry' );
00191             $oCountry->load( $sCountryId );
00192             $sTitle = $oCountry->oxcountry__oxtitle->value;
00193         }
00194 
00195         return $sTitle;
00196     }
00197 
00203     public function getOrderArticles()
00204     {
00205         if ( $this->_oArticles == null ) {
00206 
00207             // order articles
00208             $this->_oArticles = oxNew( 'oxlist' );
00209             $this->_oArticles->init( 'oxorderarticle' );
00210 
00211             $sSelect = 'select oxorderarticles.* from oxorderarticles
00212                         where oxorderarticles.oxorderid="'.$this->getId().'"
00213                         order by oxorderarticles.oxartid';
00214             $this->_oArticles->selectString( $sSelect );
00215         }
00216 
00217         return $this->_oArticles;
00218     }
00219 
00225     public function getOrderDeliveryPrice()
00226     {
00227         if ( $this->_oDelPrice != null ) {
00228             return $this->_oDelPrice;
00229         }
00230 
00231         $this->_oDelPrice = oxNew( 'oxprice' );
00232         $this->_oDelPrice->setBruttoPriceMode();
00233         $this->_oDelPrice->setPrice( $this->oxorder__oxdelcost->value, $this->oxorder__oxdelvat->value );
00234         return $this->_oDelPrice;
00235     }
00236 
00242     public function getOrderWrappingPrice()
00243     {
00244         if ( $this->_oWrappingPrice != null ) {
00245             return $this->_oWrappingPrice;
00246         }
00247 
00248         $this->_oWrappingPrice = oxNew( 'oxprice' );
00249         $this->_oWrappingPrice->setBruttoPriceMode();
00250         $this->_oWrappingPrice->setPrice( $this->oxorder__oxwrapcost->value, $this->oxorder__oxwrapvat->value );
00251         return $this->_oWrappingPrice;
00252     }
00253 
00259     public function getOrderPaymentPrice()
00260     {
00261         if ( $this->_oPaymentPrice != null ) {
00262             return $this->_oPaymentPrice;
00263         }
00264 
00265         $this->_oPaymentPrice = oxNew( 'oxprice' );
00266         $this->_oPaymentPrice->setBruttoPriceMode();
00267         $this->_oPaymentPrice->setPrice( $this->oxorder__oxpaycost->value, $this->oxorder__oxpayvat->value );
00268         return $this->_oPaymentPrice;
00269     }
00270 
00277     public function getOrderNetSum()
00278     {
00279         $dTotalNetSum = 0;
00280 
00281         $dTotalNetSum += $this->oxorder__oxtotalnetsum->value;
00282         $dTotalNetSum += $this->getOrderDeliveryPrice()->getNettoPrice();
00283         $dTotalNetSum += $this->getOrderWrappingPrice()->getNettoPrice();
00284         $dTotalNetSum += $this->getOrderPaymentPrice()->getNettoPrice();
00285 
00286         return $dTotalNetSum;
00287     }
00288 
00309     public function finalizeOrder( oxBasket $oBasket, $oUser, $blRecalculatingOrder = false )
00310     {
00311         // check if this order is already stored
00312         $sGetChallenge = oxSession::getVar( 'sess_challenge' );
00313         if ( $this->_checkOrderExist( $sGetChallenge ) ) {
00314             oxUtils::getInstance()->logger( 'BLOCKER' );
00315             // we might use this later, this means that somebody klicked like mad on order button
00316             return 3;
00317         }
00318 
00319         // if not recalculating order, use sess_challenge id, else leave old order id
00320         if ( !$blRecalculatingOrder ) {
00321             // use this ID
00322             $this->setId( $sGetChallenge );
00323         }
00324 
00325         // copies user info
00326         $this->_setUser( $oUser );
00327 
00328         // copies basket info
00329         $this->_loadFromBasket( $oBasket );
00330 
00331         // payment information
00332         $oUserPayment = $this->_setPayment( $oBasket->getPaymentId() );
00333 
00334         //saving all order data to DB
00335         $this->save();
00336 
00337         // executing payment (on failure deletes order and returns error code)
00338         // in case when recalcualting order, payment execution is skipped
00339         if ( !$blRecalculatingOrder ) {
00340             $blRet = $this->_executePayment( $oBasket, $oUserPayment );
00341             if ( $blRet !== true ) {
00342                 return $blRet;
00343             }
00344         }
00345 
00346         // deleting remark info only when order is finished
00347         oxSession::deleteVar( 'ordrem' );
00348 
00349         // updating order trans status (success status)
00350         $this->_setOrderStatus( 'OK' );
00351 
00352         // store orderid
00353         $oBasket->setOrderId( $this->getId() );
00354 
00355         // updating bought items stock
00356         $this->_updateStock();
00357 
00358         // updating wish lists
00359         $this->_updateWishlist( $oBasket->getContents(), $oUser );
00360 
00361         // updating users notice list
00362         $this->_updateNoticeList( $oBasket->getContents(), $oUser );
00363 
00364         // marking vouchers as used and sets them to $this->_aVoucherList (will be used in order email)
00365         // skipping this action in case of order recalculation
00366         if ( !$blRecalculatingOrder ) {
00367             $this->_markVouchers( $oBasket, $oUser );
00368         }
00369 
00370         // send order by email to shop owner and current user
00371         // skipping this action in case of order recalculation
00372         if ( !$blRecalculatingOrder ) {
00373             $iRet = $this->_sendOrderByEmail( $oUser, $oBasket, $oUserPayment );
00374         } else {
00375             $iRet = 1;
00376         }
00377 
00378         return $iRet;
00379     }
00380 
00388     protected function _setOrderStatus( $sStatus )
00389     {
00390         $sQ = 'update oxorder set oxtransstatus="'.$sStatus.'" where oxid="'.$this->getId().'" ';
00391         oxDb::getDb()->execute( $sQ );
00392     }
00393 
00404     protected function _loadFromBasket( oxBasket $oBasket )
00405     {
00406         $myConfig = $this->getConfig();
00407 
00408         // store IP Adress - default must be FALSE as it is illegal to store
00409         if ( $myConfig->getConfigParam( 'blStoreIPs' ) ) {
00410             $this->oxorder__oxip = new oxField(oxUtilsServer::getInstance()->getRemoteAddress(), oxField::T_RAW);
00411         }
00412 
00413         // copying main price info
00414         $this->oxorder__oxtotalnetsum   = new oxField(oxUtils::getInstance()->fRound($oBasket->getProductsPrice()->getNettoSum()), oxField::T_RAW);
00415         $this->oxorder__oxtotalbrutsum  = new oxField($oBasket->getProductsPrice()->getBruttoSum(), oxField::T_RAW);
00416         $this->oxorder__oxtotalordersum = new oxField($oBasket->getPrice()->getBruttoPrice(), oxField::T_RAW);
00417 
00418         // payment costs if available
00419         if ( ( $oPaymentCost = $oBasket->getCosts( 'oxpayment' ) ) ) {
00420             $this->oxorder__oxpaycost = new oxField($oPaymentCost->getBruttoPrice(), oxField::T_RAW);
00421             $this->oxorder__oxpayvat  = new oxField($oPaymentCost->getVAT(), oxField::T_RAW);
00422         }
00423 
00424         // delivery info
00425         if ( ( $oDeliveryCost = $oBasket->getCosts( 'oxdelivery' ) ) ) {
00426             $this->oxorder__oxdelcost = new oxField($oDeliveryCost->getBruttoPrice(), oxField::T_RAW);
00427             //V #M382: Save VAT, not VAT value for delivery costs
00428             $this->oxorder__oxdelvat  = new oxField($oDeliveryCost->getVAT(), oxField::T_RAW); //V #M382
00429             $this->oxorder__oxdeltype = new oxField($oBasket->getShippingId(), oxField::T_RAW);
00430         }
00431 
00432         // user remark
00433         $this->oxorder__oxremark = new oxField(oxSession::getVar( 'ordrem' ), oxField::T_RAW);
00434 
00435         // currency
00436         $oCur = $myConfig->getActShopCurrencyObject();
00437         $this->oxorder__oxcurrency = new oxField($oCur->name);
00438         $this->oxorder__oxcurrate  = new oxField($oCur->rate, oxField::T_RAW);
00439 
00440         // store voucherdiscount
00441         if ( ( $oVoucherDiscount = $oBasket->getVoucherDiscount() ) ) {
00442             $this->oxorder__oxvoucherdiscount = new oxField($oVoucherDiscount->getBruttoPrice(), oxField::T_RAW);
00443         }
00444 
00445         // general discount
00446         if ( ( $oTotalDiscount = $oBasket->getTotalDiscount() ) ) {
00447             $this->oxorder__oxdiscount = new oxField($oTotalDiscount->getBruttoPrice(), oxField::T_RAW);
00448         }
00449 
00450         //order language
00451         $this->oxorder__oxlang = new oxField( $this->getOrderLanguage() );
00452 
00453 
00454         // initial status - 'ERROR'
00455         $this->oxorder__oxtransstatus = new oxField('ERROR', oxField::T_RAW);
00456 
00457         // copies basket product info ...
00458         $this->_setOrderArticles( $oBasket->getContents() );
00459 
00460         // copies wrapping info
00461         $this->_setWrapping( $oBasket );
00462     }
00463 
00470     public function getOrderLanguage()
00471     {
00472         if ( $this->_iOrderLang === null ) {
00473             if ( isset( $this->oxorder__oxlang->value ) ) {
00474                 $this->_iOrderLang = oxLang::getInstance()->validateLanguage( $this->oxorder__oxlang->value );
00475             } else {
00476                 $this->_iOrderLang = oxLang::getInstance()->getBaseLanguage();
00477             }
00478         }
00479         return $this->_iOrderLang;
00480     }
00481 
00489     protected function _setUser( $oUser )
00490     {
00491 
00492         $this->oxorder__oxuserid        = new oxField($oUser->getId());
00493 
00494         // bill address
00495         $this->oxorder__oxbillcompany     = clone $oUser->oxuser__oxcompany;
00496         $this->oxorder__oxbillemail       = clone $oUser->oxuser__oxusername;
00497         $this->oxorder__oxbillfname       = clone $oUser->oxuser__oxfname;
00498         $this->oxorder__oxbilllname       = clone $oUser->oxuser__oxlname;
00499         $this->oxorder__oxbillstreet      = clone $oUser->oxuser__oxstreet;
00500         $this->oxorder__oxbillstreetnr    = clone $oUser->oxuser__oxstreetnr;
00501         $this->oxorder__oxbilladdinfo     = clone $oUser->oxuser__oxaddinfo;
00502         $this->oxorder__oxbillustid       = clone $oUser->oxuser__oxustid;
00503         $this->oxorder__oxbillcity        = clone $oUser->oxuser__oxcity;
00504         $this->oxorder__oxbillcountryid   = clone $oUser->oxuser__oxcountryid;
00505         $this->oxorder__oxbillzip         = clone $oUser->oxuser__oxzip;
00506         $this->oxorder__oxbillfon         = clone $oUser->oxuser__oxfon;
00507         $this->oxorder__oxbillfax         = clone $oUser->oxuser__oxfax;
00508         $this->oxorder__oxbillsal         = clone $oUser->oxuser__oxsal;
00509 
00510 
00511         // delivery address
00512         if ( ( $oDelAdress = $this->getDelAddressInfo() ) ) {
00513             // set delivery address
00514             $this->oxorder__oxdelcompany   = clone $oDelAdress->oxaddress__oxcompany;
00515             $this->oxorder__oxdelfname     = clone $oDelAdress->oxaddress__oxfname;
00516             $this->oxorder__oxdellname     = clone $oDelAdress->oxaddress__oxlname;
00517             $this->oxorder__oxdelstreet    = clone $oDelAdress->oxaddress__oxstreet;
00518             $this->oxorder__oxdelstreetnr  = clone $oDelAdress->oxaddress__oxstreetnr;
00519             $this->oxorder__oxdeladdinfo   = clone $oDelAdress->oxaddress__oxaddinfo;
00520             $this->oxorder__oxdelcity      = clone $oDelAdress->oxaddress__oxcity;
00521             $this->oxorder__oxdelcountryid = clone $oDelAdress->oxaddress__oxcountryid;
00522             $this->oxorder__oxdelzip       = clone $oDelAdress->oxaddress__oxzip;
00523             $this->oxorder__oxdelfon       = clone $oDelAdress->oxaddress__oxfon;
00524             $this->oxorder__oxdelfax       = clone $oDelAdress->oxaddress__oxfax;
00525             $this->oxorder__oxdelsal       = clone $oDelAdress->oxaddress__oxsal;
00526         }
00527     }
00528 
00536     protected function _setWrapping( oxBasket $oBasket )
00537     {
00538         $myConfig = $this->getConfig();
00539 
00540         // wrapping price
00541         if ( ( $oWrappingCost = $oBasket->getCosts( 'oxwrapping' ) ) ) {
00542             $this->oxorder__oxwrapcost = new oxField($oWrappingCost->getBruttoPrice(), oxField::T_RAW);
00543 
00544             // wrapping VAT
00545             if ( $myConfig->getConfigParam( 'blCalcVatForWrapping' ) ) {
00546                 $this->oxorder__oxwrapvat = new oxField($oWrappingCost->getVAT(), oxField::T_RAW);
00547             }
00548         }
00549 
00550         // greetings card
00551         $this->oxorder__oxcardid = new oxField($oBasket->getCardId(), oxField::T_RAW);
00552 
00553         // card text will be stored in database
00554         $this->oxorder__oxcardtext = new oxField($oBasket->getCardMessage(), oxField::T_RAW);
00555     }
00556 
00565     protected function _setOrderArticles( $aArticleList )
00566     {
00567         // reset articles list
00568         $this->_oArticles = null;
00569         $iCurrLang = $this->getOrderLanguage();
00570 
00571         // add all the products we have on basket to the order
00572         foreach ( $aArticleList as $oContent ) {
00573 
00574             //$oContent->oProduct = $oContent->getArticle();
00575             $oProduct = $oContent->getArticle();
00576 
00577             // if order language doe not match product language - article must be reloaded in order language
00578             if ( $iCurrLang != $oProduct->getLanguage() ) {
00579                 $oProduct->loadInLang( $iCurrLang, $oProduct->getId() );
00580             }
00581 
00582             $aSelList = array();
00583             // set chosen selectlist
00584             $sSelList = '';
00585             if ( count($oContent->getChosenSelList()) ) {
00586                 foreach ( $oContent->getChosenSelList() as $oItem ) {
00587                     $aSelList[] = $oItem->name.' : '.$oItem->value;
00588                 }
00589                 $sSelList = implode( ', ', $aSelList );
00590             }
00591 
00592             $oOrderArticle = oxNew( 'oxorderarticle' );
00593 
00594             // copying additional data
00595             $oOrderArticle->copyThis( $oProduct );
00596 
00597             // ids, titles, numbers ...
00598             //$oOrderArticle->oxorderarticles__oxid->setValue($oOrderArticle->setId());
00599             $oOrderArticle->setId();
00600             $oOrderArticle->oxorderarticles__oxorderid = new oxField($this->getId());
00601             $oOrderArticle->oxorderarticles__oxartid   = new oxField($oContent->getProductId());
00602             $oOrderArticle->oxorderarticles__oxamount  = new oxField($oContent->getAmount());
00603 
00604             //$oOrderArticle->oxorderarticles__oxartnum->setValue($oContent->oProduct->oxarticles__oxartnum->value);
00605             $oOrderArticle->oxorderarticles__oxartnum  = clone $oProduct->oxarticles__oxartnum;
00606 
00607             //$oOrderArticle->oxorderarticles__oxselvariant->setValue(trim( $sSelList.' '.$oContent->oProduct->oxarticles__oxvarselect->value ));
00608             $oOrderArticle->oxorderarticles__oxselvariant = new oxField(trim( $sSelList.' '.$oProduct->oxarticles__oxvarselect->value ), oxField::T_RAW);
00609 
00610             //$oOrderArticle->oxorderarticles__oxtitle->setValue(trim( $oContent->oProduct->oxarticles__oxtitle->value.' '.$oOrderArticle->oxorderarticles__oxselvariant->value ));
00611             $oOrderArticle->oxorderarticles__oxtitle      = new oxField(trim( $oProduct->oxarticles__oxtitle->value.' '.$oOrderArticle->oxorderarticles__oxselvariant->value ), oxField::T_RAW);
00612 
00613             //$oOrderArticle->oxorderarticles__oxshortdesc->setValue($oContent->oProduct->oxarticles__oxshortdesc->value);
00614             $oOrderArticle->oxorderarticles__oxshortdesc  = new oxField( $oProduct->oxarticles__oxshortdesc->value, oxField::T_RAW);
00615 
00616             // prices
00617             $oOrderArticle->oxorderarticles__oxnetprice  = new oxField($oContent->getPrice()->getNettoPrice(), oxField::T_RAW);
00618             $oOrderArticle->oxorderarticles__oxvatprice  = new oxField($oContent->getPrice()->getVATValue(), oxField::T_RAW);
00619             $oOrderArticle->oxorderarticles__oxbrutprice = new oxField($oContent->getPrice()->getBruttoPrice(), oxField::T_RAW);
00620             $oOrderArticle->oxorderarticles__oxnprice    = new oxField($oContent->getUnitPrice()->getNettoPrice(), oxField::T_RAW);
00621             $oOrderArticle->oxorderarticles__oxbprice    = new oxField($oContent->getUnitPrice()->getBruttoPrice(), oxField::T_RAW);
00622             $oOrderArticle->oxorderarticles__oxvat       = new oxField($oContent->getPrice()->getVAT(), oxField::T_RAW);
00623 
00624             // wrap id
00625             $oOrderArticle->oxorderarticles__oxwrapid      = new oxField($oContent->getWrappingId(), oxField::T_RAW);
00626 
00627             // items shop id
00628             $oOrderArticle->oxorderarticles__oxordershopid = new oxField($oContent->getShopId(), oxField::T_RAW);
00629 
00630             // copying persistent parameters ...
00631             if ( count( $oProduct->getPersParams() ) ) {
00632                 $oOrderArticle->oxorderarticles__oxpersparam = new oxField(serialize( $oProduct->getPersParams() ), oxField::T_RAW);
00633             } elseif ( count( $oContent->getPersParams() ) ) {
00634                 $oOrderArticle->oxorderarticles__oxpersparam = new oxField(serialize( $oContent->getPersParams()), oxField::T_RAW);
00635             }
00636 
00637             // add information for eMail
00638             //P
00639             //TODO: check if this assign is needed at all
00640             $oOrderArticle->oProduct = $oProduct;
00641 
00642             // simulatin order article list
00643             $this->_oArticles[$oOrderArticle->getId()] = $oOrderArticle;
00644         }
00645     }
00646 
00658     protected function _executePayment( oxBasket $oBasket, $oUserpayment )
00659     {
00660         $oPayTransaction = $this->_getGateway();
00661         $oPayTransaction->setPaymentParams( $oUserpayment );
00662 
00663         if ( !$oPayTransaction->executePayment( $oBasket->getPrice()->getBruttoPrice(), $this ) ) {
00664             $this->delete();
00665 
00666             // checking for error messages
00667             if ( method_exists( $oPayTransaction, 'getLastError' ) ) {
00668                 if ( ( $sLastError = $oPayTransaction->getLastError() ) ) {
00669                     return $sLastError;
00670                 }
00671             }
00672 
00673             // checking for error codes
00674             if ( method_exists( $oPayTransaction, 'getLastErrorNo' ) ) {
00675                 if ( ( $iLastErrorNo = $oPayTransaction->getLastErrorNo() ) ) {
00676                     return $iLastErrorNo;
00677                 }
00678             }
00679 
00680             return 2; // means no authentication
00681         }
00682         return true; // everything fine
00683     }
00684 
00691     protected function _getGateway()
00692     {
00693         return oxNew( 'oxPaymentGateway' );
00694     }
00695 
00703     protected function _setPayment( $sPaymentid )
00704     {
00705         // copying payment info fields
00706         $aDynvalue = oxSession::getVar( 'dynvalue' );
00707         $aDynvalue = $aDynvalue ? $aDynvalue : oxConfig::getParameter( 'dynvalue' );
00708 
00709         // loading payment object
00710         $oPayment = oxNew( 'oxpayment' );
00711 
00712         if (!$oPayment->load( $sPaymentid )) {
00713             return null;
00714         }
00715 
00716         $oPayment->setDynValues( oxUtils::getInstance()->assignValuesFromText( $oPayment->oxpayments__oxvaldesc->value ) );
00717 
00718         // collecting dynamic values
00719         $aDynVal = array();
00720 
00721         $aPaymentDynValues = $oPayment->getDynValues();
00722         foreach ( $aPaymentDynValues  as $key => $oVal ) {
00723             if ( isset( $aDynvalue[$oVal->name] ) ) {
00724                 $oVal->value = $aDynvalue[$oVal->name];
00725             }
00726 
00727             //$oPayment->setDynValue($key, $oVal);
00728             $aPaymentDynValues[$key] = $oVal;
00729             $aDynVal[$oVal->name] = $oVal->value;
00730         }
00731 
00732         // Store this payment information, we might allow users later to
00733         // reactivate already give payment informations
00734 
00735         $oUserpayment = oxNew( 'oxuserpayment' );
00736         $oUserpayment->oxuserpayments__oxuserid     = clone $this->oxorder__oxuserid;
00737         $oUserpayment->oxuserpayments__oxpaymentsid = new oxField($sPaymentid, oxField::T_RAW);
00738         $oUserpayment->oxuserpayments__oxvalue      = new oxField(oxUtils::getInstance()->assignValuesToText( $aDynVal ), oxField::T_RAW);
00739         $oUserpayment->oxpayments__oxdesc           = clone $oPayment->oxpayments__oxdesc;
00740         $oUserpayment->setDynValues( $aPaymentDynValues );
00741         $oUserpayment->save();
00742 
00743         // storing payment information to order
00744         $this->oxorder__oxpaymentid   = new oxField($oUserpayment->getId(), oxField::T_RAW);
00745         $this->oxorder__oxpaymenttype = clone $oUserpayment->oxuserpayments__oxpaymentsid;
00746 
00747         // returning user payment object which will be used later in code ...
00748         return $oUserpayment;
00749     }
00750 
00760     protected function _updateWishlist( $aArticleList, $oUser )
00761     {
00762 
00763         foreach ( $aArticleList as $oContent) {
00764             if ( ( $sWishId = $oContent->getWishId() ) ) {
00765 
00766                 // checking which wishlist user uses ..
00767                 if ( $sWishId == $oUser->getId() ) {
00768                     $oUserBasket = $oUser->getBasket( 'wishlist' );
00769                 } else {
00770                     $aWhere = array( 'oxuserbaskets.oxuserid' => $sWishId, 'oxuserbaskets.oxtitle' => 'wishlist' );
00771                     $oUserBasket = oxNew( 'oxuserbasket' );
00772                     $oUserBasket->assignRecord( $oUserBasket->buildSelectString( $aWhere ) );
00773                 }
00774 
00775                 // updating users wish list
00776                 if ( $oUserBasket ) {
00777                     if ( !($sProdId = $oContent->getWishArticleId() )) {
00778                         $sProdId = $oContent->getProductId();
00779                     }
00780                     $oUserBasketItem = $oUserBasket->getItem( $sProdId, $oContent->getSelList() );
00781                     $dNewAmount = $oUserBasketItem->oxuserbasketitems__oxamount->value - $oContent->getAmount();
00782                     if ( $dNewAmount < 0) {
00783                         $dNewAmount = 0;
00784                     }
00785                     $oUserBasket->addItemToBasket( $sProdId, $dNewAmount, $oContent->getSelList(), true );
00786                 }
00787             }
00788         }
00789     }
00790 
00800     protected function _updateNoticeList( $aArticleList, $oUser )
00801     {
00802         // loading users notice list ..
00803         if ( $oUserBasket = $oUser->getBasket( 'noticelist' ) ) {
00804             // only if wishlist is enabled
00805             foreach ( $aArticleList as $oContent) {
00806                 $sProdId = $oContent->getProductId();
00807 
00808                 // updating users notice list
00809                 $oUserBasketItem = $oUserBasket->getItem( $sProdId, $oContent->getSelList() );
00810                 $dNewAmount = $oUserBasketItem->oxuserbasketitems__oxamount->value - $oContent->getAmount();
00811                 if ( $dNewAmount < 0) {
00812                     $dNewAmount = 0;
00813                 }
00814                 $oUserBasket->addItemToBasket( $sProdId, $dNewAmount, $oContent->getSelList(), true );
00815             }
00816         }
00817     }
00818 
00824     protected function _updateStock()
00825     {
00826         $myConfig = $this->getConfig();
00827         $blUseStock = $myConfig->getConfigParam( 'blUseStock' );
00828 
00829         // ordered articles
00830         $oOrderArticles = $this->getOrderArticles();
00831         if ( $oOrderArticles && count( $oOrderArticles ) > 0 && $blUseStock ) {
00832             foreach ( $oOrderArticles as $oOrderArticle ) {
00833                 $oOrderArticle->updateArticleStock( $oOrderArticle->oxorderarticles__oxamount->value * (-1), $myConfig->getConfigParam( 'blAllowNegativeStock' ) );
00834             }
00835         }
00836     }
00837 
00849     protected function _markVouchers( $oBasket, $oUser )
00850     {
00851         $this->_aVoucherList = $oBasket->getVouchers();
00852 
00853         if ( is_array( $this->_aVoucherList ) ) {
00854             foreach ( array_keys( $this->_aVoucherList ) as $sVoucherId ) {
00855                 $oVoucher = oxNew( 'oxvoucher' );
00856                 $oVoucher->load( $sVoucherId );
00857                 $oVoucher->markAsUsed( $this->oxorder__oxid->value, $oUser->oxuser__oxid->value );
00858 
00859                 // -- set deprecated values for email templates
00860                 $oVoucher->oxmodvouchers__oxvouchernr = $oVoucher->oxvouchers__oxvouchernr;
00861                 $oVSerie = $oVoucher->getSerie();
00862                 $oVoucher->oxmodvouchers__oxdiscount     = clone $oVSerie->oxvoucherseries__oxdiscount;
00863                 $oVoucher->oxmodvouchers__oxdiscounttype = clone $oVSerie->oxvoucherseries__oxdiscounttype;
00864                 // -- set deprecated values for email templates
00865 
00866                 $this->_aVoucherList[$sVoucherId] = $oVoucher;
00867             }
00868         }
00869     }
00870 
00876     public function save()
00877     {
00878         if ( ( $blSave = parent::save() ) ) {
00879 
00880             // saving order articles
00881             $oOrderArticles = $this->getOrderArticles();
00882             if ( $oOrderArticles && count( $oOrderArticles ) > 0 ) {
00883                 foreach ( $oOrderArticles as $oOrderArticle ) {
00884                     $oOrderArticle->save();
00885                 }
00886             }
00887         }
00888 
00889         return $blSave;
00890     }
00891 
00898     public function getDelAddressInfo()
00899     {
00900         $oDelAdress = null;
00901         if ( ( $soxAddressId = oxConfig::getParameter( 'deladrid' ) ) ) {
00902             $oDelAdress = oxNew( 'oxbase' );
00903             $oDelAdress->init( 'oxaddress' );
00904             $oDelAdress->load( $soxAddressId );
00905 
00906             //get delivery country name from delivery country id
00907             if ( $oDelAdress->oxaddress__oxcountryid->value && $oDelAdress->oxaddress__oxcountryid->value != -1 ) {
00908                  $oCountry = oxNew( 'oxcountry' );
00909                  $oCountry->load( $oDelAdress->oxaddress__oxcountryid->value );
00910                  $oDelAdress->oxaddress__oxcountry = clone $oCountry->oxcountry__oxtitle;
00911             }
00912         }
00913         return $oDelAdress;
00914     }
00915 
00926     public function validateStock( $oBasket )
00927     {
00928         foreach ( $oBasket->getContents() as $oContent ) {
00929             $oProd = $oContent->getArticle();
00930 
00931             // check if its still available
00932             $iOnStock = $oProd->checkForStock( $oContent->getAmount() );
00933             if ( $iOnStock !== true ) {
00934                 $oEx = oxNew( 'oxOutOfStockException' );
00935                 $oEx->setMessage( 'EXCEPTION_OUTOFSTOCK_OUTOFSTOCK' );
00936                 $oEx->setArticleNr( $oProd->oxarticles__oxartnum->value );
00937                 $oEx->setRemainingAmount( $oProd->oxarticles__oxstock->value );
00938                 throw $oEx;
00939             }
00940         }
00941     }
00942 
00948     protected function _insert()
00949     {
00950         $myConfig = $this->getConfig();
00951 
00952         $this->oxorder__oxorderdate = new oxField(date( 'Y-m-d H:i:s', oxUtilsDate::getInstance()->getTime() ), oxField::T_RAW);
00953         $this->oxorder__oxshopid    = new oxField($myConfig->getShopId(), oxField::T_RAW);
00954         $this->oxorder__oxfolder    = new oxField(key( $myConfig->getShopConfVar(  'aOrderfolder', $myConfig->getShopId() ) ), oxField::T_RAW);
00955 
00956         if ( ( $blInsert = parent::_insert() ) ) {
00957             // setting order number
00958             if ( !$this->oxorder__oxordernr->value ) {
00959                 $aWhere = '';
00960                 // separate order numbers for shops ...
00961                 if ( $this->_blSeparateNumbering ) {
00962                     $aWhere = array( 'oxshopid = "'.$myConfig->getShopId().'"' );
00963                 }
00964                 $this->_setRecordNumber( 'oxordernr', $aWhere );
00965             }
00966         }
00967         return $blInsert;
00968     }
00969 
00975     protected function _update()
00976     {
00977         $this->oxorder__oxsenddate = new oxField(oxUtilsDate::getInstance()->formatDBDate( $this->oxorder__oxsenddate->value, true ), oxField::T_RAW);
00978         return parent::_update();
00979     }
00980 
00989     public function delete( $sOxId = null )
00990     {
00991         if ( $sOxId ) {
00992             if ( !$this->load( $sOxId ) ) {
00993                 // such order does not exist
00994                 return false;
00995             }
00996         } elseif ( !$sOxId ) {
00997             $sOxId = $this->getId();
00998         }
00999 
01000         // no order id is passed
01001         if ( !$sOxId ) {
01002             return false;
01003         }
01004 
01005 
01006         // update article stock information and delete order articles
01007         $myConfig   = $this->getConfig();
01008         $blUseStock = $myConfig->getConfigParam( 'blUseStock' );
01009 
01010         $oOrderArticles = $this->getOrderArticles();
01011         foreach ( $oOrderArticles as $oOrderArticle ) {
01012             // updating amounts only on non canceled items
01013             if ( $blUseStock ) {
01014                 if ( !$oOrderArticle->oxorderarticles__oxstorno->value ) {
01015                     $oOrderArticle->updateArticleStock( $oOrderArticle->oxorderarticles__oxamount->value, $myConfig->getConfigParam('blAllowNegativeStock') );
01016                 }
01017             }
01018             $oOrderArticle->delete();
01019         }
01020 
01021         // #440 - deleting user payment info
01022         if ( $this->oxorder__oxpaymentid->value ) {
01023             $oDB = oxDb::getDb();
01024             $oDB->execute( 'delete from oxuserpayments where oxuserpayments.oxid = "'.$this->oxorder__oxpaymentid->value.'"' );
01025         }
01026 
01027         return parent::delete( $sOxId );
01028     }
01029 
01039     public function recalculateOrder( $aNewOrderArticles = array() )
01040     {
01041         oxDb::startTransaction();
01042 
01043         try {
01044             // deleting old order with order articles
01045             //load order articles and delete order and order articles
01046             $this->_oArticles = $this->getOrderArticles();
01047             $this->delete();
01048 
01049             $oUser = oxNew( "oxuser" );
01050             $oUser->load( $this->oxorder__oxuserid->value );
01051 
01052             //creating virtual basket and initalizing additional parameters (user, stock, currency)
01053             $oBasket = oxNew( "oxBasket" );
01054 
01055             $aCanceledArticles = array();
01056 
01057             // collect order articles ids's (oxarticles) and canceled order articles
01058             foreach ( $this->_oArticles as $sOrderArticleId => $oOrderArticle ) {
01059                 //articles id's
01060                 $aArticlesIds[$sOrderArticleId] = $oOrderArticle->oxorderarticles__oxartid->value;
01061 
01062                 // collect canceled order articles, they will not be included in recalculation articles list
01063                 // and will be saved back to order after recalculating and finalizieOrder()
01064                 if ( $oOrderArticle->oxorderarticles__oxstorno->value == '1') {
01065                     $aCanceledArticles[$sOrderArticleId] = $oOrderArticle;
01066 
01067                     // unset canceled article from recalcualtion list
01068                     unset( $this->_oArticles[$sOrderArticleId] );
01069                 }
01070             }
01071 
01072             // add or remove newly added order articles to/from old articles list
01073             foreach ($aNewOrderArticles as $oNewOrderArticle) {
01074 
01075                 $sNewOrderArtId = null;
01076                 $blIsOldOrderArticle = false;
01077 
01078                 //check, if added article already is in old order articles list
01079                 if ( is_array( $aArticlesIds ) ) {
01080                     if ( ( $sNewOrderArtId = array_search( $oNewOrderArticle->oxorderarticles__oxartid->value, $aArticlesIds ) ) ) {
01081                         $blIsOldOrderArticle = true;
01082                     }
01083                 }
01084 
01085                 //check, if we are going to delete it
01086                 if ( $oNewOrderArticle->oxorderarticles__oxamount->value == 0 ) {
01087                     // if it is in canceled articles list, remove it from canceled articles list,
01088                     // because they will be restored after recalcualtion
01089                     if ( array_key_exists( $sNewOrderArtId, $aCanceledArticles) ) {
01090                         // add it back to recalculation list from canceled articles list
01091                         // to delete it in finalizeOrder()
01092                         $this->_oArticles[$sNewOrderArtId] = $aCanceledArticles[$sNewOrderArtId];
01093 
01094                         // and remove it from canceled articles, because they will be restored after recalculation
01095                         unset($aCanceledArticles[$sNewOrderArtId]);
01096                     }
01097                 }
01098 
01099                 if ( $blIsOldOrderArticle ) {
01100                     //just update existing order article amount
01101                     $this->_oArticles[$sNewOrderArtId]->oxorderarticles__oxamount = clone $oNewOrderArticle->oxorderarticles__oxamount;
01102                 } else {
01103                     //add new article to order articles
01104                     $this->_oArticles[] = $oNewOrderArticle;
01105                 }
01106             }
01107 
01108             // add this order articles to virtual basket and recalculates basket
01109             $oBasket = $this->_addOrderArticlesToBasket( $oUser, $this->_oArticles );
01110 
01111             //finalizing order (skipping payment execution, vouchers marking and mail sending)
01112             $iRet = $this->finalizeOrder( $oBasket, $oUser, true );
01113 
01114             //adding back canceled articles
01115             if ( count($aCanceledArticles) > 0 ) {
01116                 foreach($aCanceledArticles as $oCanceledOrderArticle ) {
01117                     $oCanceledOrderArticle->save();
01118                 }
01119             }
01120 
01121             //if finalizing order failed, rollback transaction
01122             if ( $iRet !== 1 ) {
01123                 oxDb::rollbackTransaction();
01124             } else {
01125                 oxDb::commitTransaction();
01126             }
01127 
01128         } catch( Exception $oE ) {
01129                 // if exception, rollBack everything
01130                 oxDb::rollbackTransaction();
01131         }
01132     }
01133 
01141     public function pdfFooter( $oPdf )
01142     {
01143     }
01144 
01152     public function pdfHeaderplus( $oPdf )
01153     {
01154     }
01155 
01163     public function pdfHeader( $oPdf )
01164     {
01165     }
01166 
01175     public function genPdf( $sFilename, $iSelLang = 0 )
01176     {
01177     }
01178 
01184     public function getInvoiceNum()
01185     {
01186         $sQ = 'select max(oxorder.oxinvoicenr) from oxorder where oxorder.oxshopid = "'.$this->getConfig()->getShopId().'" ';
01187         return ( ( int ) oxDb::getDb()->getOne( $sQ ) + 1 );
01188     }
01189 
01190 
01196     public function getShippingSetList()
01197     {
01198         $myConfig = $this->getConfig();
01199 
01200         // in which country we deliver
01201         $sShipID = $this->oxorder__oxdelcountryid->value;
01202 
01203         if (!$sShipID) {
01204             $sShipID = $this->oxorder__oxbillcountryid->value;
01205         }
01206 
01207         $oUser = oxNew( "oxuser" );
01208         $oUser->load( $this->oxorder__oxuserid->value );
01209 
01210         // add this order articles to basket and recalculate basket
01211         $oBasket = $this->_addOrderArticlesToBasket( $oUser, $this->getOrderArticles() );
01212 
01213         $aOrderDelSetList = array();
01214 
01215         // load fitting deliveries list
01216         $oDleliveryList = oxNew( "oxDeliveryList", "core");
01217         $oDleliveryList->setCollectFittingDeliveriesSets( true );
01218         $aOrderDelSetList = $oDleliveryList->getDeliveryList( $oBasket, $oUser, $sShipID, null );
01219 
01220         return $aOrderDelSetList;
01221     }
01222 
01228     public function getVoucherNrList()
01229     {
01230         $oDB = oxDb::getDb( true );
01231         $aVouchers = array();
01232         $sSelect =  "select oxvouchernr from oxvouchers where oxorderid = '".$this->oxorder__oxid->value."'";
01233         $rs = $oDB->execute( $sSelect);
01234         if ($rs != false && $rs->recordCount() > 0) {
01235             while (!$rs->EOF) {
01236                 $aVouchers[] = $rs->fields['oxvouchernr'];
01237                 $rs->moveNext();
01238             }
01239         }
01240         return $aVouchers;
01241     }
01242 
01250     public function getOrderSum( $blToday = false )
01251     {
01252         $sSelect  = 'select sum(oxtotalordersum) from oxorder where ';
01253         $sSelect .= 'oxshopid = "'.$this->getConfig()->getShopId().'" and oxorder.oxstorno != "1" ';
01254 
01255         if ( $blToday )
01256             $sSelect .= 'and oxorderdate like "'.date( 'Y-m-d').'%" ';
01257 
01258         return ( double ) oxDb::getDb()->getOne( $sSelect );
01259     }
01260 
01268     public function getOrderCnt( $blToday = false )
01269     {
01270         $sSelect  = 'select count(*) from oxorder where ';
01271         $sSelect .= 'oxshopid = "'.$this->getConfig()->getShopId().'"  and oxorder.oxstorno != "1" ';
01272 
01273         if ( $blToday ) {
01274             $sSelect .= 'and oxorderdate like "'.date( 'Y-m-d').'%" ';
01275         }
01276 
01277         return ( int ) oxDb::getDb()->getOne( $sSelect );
01278     }
01279 
01280 
01288     protected function _checkOrderExist( $sOxId = null )
01289     {
01290         if ( !$sOxId) {
01291             return false;
01292         }
01293 
01294         if ( oxDb::getDb()->getOne( 'select oxid from oxorder where oxid = "'.$sOxId.'"' ) ) {
01295             return true;
01296         }
01297 
01298         return false;
01299     }
01300 
01310     protected function _sendOrderByEmail( $oUser = null, $oBasket = null, $oPayment = null )
01311     {
01312         $iRet = 0;
01313 
01314         // add user, basket and payment to order
01315         $this->_oUser    = $oUser;
01316         $this->_oBasket  = $oBasket;
01317         $this->_oPayment = $oPayment;
01318 
01319         $oxEmail = oxNew( 'oxemail' );
01320 
01321         // send order email to user
01322         if ( $oxEmail->sendOrderEMailToUser( $this ) ) {
01323             // mail to user was successfully sent
01324             $iRet = 1;
01325         }
01326 
01327         // send order email to shop owner
01328         $oxEmail->sendOrderEMailToOwner( $this );
01329 
01330         return $iRet;
01331     }
01332 
01338     public function getUser()
01339     {
01340         return $this->_oUser;
01341     }
01342 
01348     public function getBasket()
01349     {
01350         return $this->_oBasket;
01351     }
01352 
01358     public function getPayment()
01359     {
01360         return $this->_oPayment;
01361     }
01362 
01368     public function getVoucherList()
01369     {
01370         return $this->_aVoucherList;
01371     }
01372 
01378     public function getDelSet()
01379     {
01380         if ( $this->_oDelSet == null ) {
01381             // load deliveryset info
01382             $this->_oDelSet = oxNew( 'oxdeliveryset' );
01383             $this->_oDelSet->load( $this->oxorder__oxdeltype->value );
01384         }
01385 
01386         return $this->_oDelSet;
01387     }
01388 
01394     public function getPaymentType()
01395     {
01396         if ( $this->oxorder__oxpaymentid->value && $this->_oPaymentType == null ) {
01397             $this->_oPaymentType = oxNew( 'oxuserpayment' );
01398             $this->_oPaymentType->load( $this->oxorder__oxpaymentid->value );
01399         }
01400 
01401         return $this->_oPaymentType;
01402     }
01403 
01409     public function getGiftCard()
01410     {
01411         if ( $this->oxorder__oxcardid->value && $this->_oGiftCard == null ) {
01412             $this->_oGiftCard = oxNew( 'oxwrapping' );
01413             $this->_oGiftCard->load( $this->oxorder__oxcardid->value );
01414         }
01415 
01416         return $this->_oGiftCard;
01417     }
01418 
01426     public function setSeparateNumbering( $blSeparateNumbering = null )
01427     {
01428         $this->_blSeparateNumbering = $blSeparateNumbering;
01429     }
01430 
01438     public function getLastUserPaymentType( $sUserId)
01439     {
01440         $sQ = 'select oxorder.oxpaymenttype from oxorder where oxorder.oxshopid="'.$this->getConfig()->getShopId().'" and oxorder.oxuserid="'.$sUserId.'" order by oxorder.oxorderdate desc ';
01441         $sLastPaymentId = oxDb::getDb()->getOne( $sQ );
01442         return $sLastPaymentId;
01443     }
01444 
01455     protected function _makeSelListArray( $sArtId = null, $sOrderArtSelList = null )
01456     {
01457         $aList = array();
01458         $aRet  = array();
01459 
01460         if ( $sArtId ) {
01461             $aList = explode( ",", $sOrderArtSelList );
01462 
01463             //$oArticle = oxNew( "oxArticle", "core" );
01464             $oArticle = oxNew( "oxArticle" );
01465             $oArticle->load( $sArtId );
01466             $aArticleSelList = $oArticle->getSelectLists();
01467 
01468             //formating temporary list array from string
01469             foreach ( $aList as $sList ) {
01470                 if ( $sList ) {
01471 
01472                     $aVal = explode( ":", $sList );
01473 
01474                     if ( isset($aVal[0]) && isset($aVal[1])) {
01475                         $sOrderArtListTitle = strtolower( trim($aVal[0]) );
01476                         $sOrderArtSelValue  = strtolower( trim($aVal[1]) );
01477 
01478                         //checking article list for matches with article list stored in oxorderitem
01479                         $iSelListNum = 0;
01480                         if ( count($aArticleSelList) > 0 ) {
01481                             foreach ( $aArticleSelList as $aSelect ) {
01482                                 //chek if selects titles are equal
01483 
01484                                 if ( strtolower($aSelect['name']) == $sOrderArtListTitle ) {
01485                                     //try to find matching select items value
01486                                     $iSelValueNum = 0;
01487                                     foreach ( $aSelect as $oSel ) {
01488                                         if ( strtolower($oSel->name) == $sOrderArtSelValue ) {
01489                                             // found, adding tu return array
01490                                             $aRet[$iSelListNum] = $iSelValueNum;
01491                                         }
01492                                         //next article list item
01493                                         $iSelValueNum++;
01494                                     }
01495                                 }
01496                                 //next article list
01497                                 $iSelListNum++;
01498                             }
01499                         }
01500                     }
01501                 }
01502             }
01503         }
01504 
01505         return $aRet;
01506     }
01507 
01516     protected function _addOrderArticlesToBasket( $oUser = null, $aOrderArticles = null )
01517     {
01518         $myConfig = $this->getConfig();
01519 
01520         $oBasket = oxNew( "oxbasket" );
01521 
01522         // setting virtual basket user
01523         $oBasket->setBasketUser( $oUser );
01524 
01525         // setting basket currency order uses
01526         $aCurrencies = $myConfig->getCurrencyArray();
01527         foreach ($aCurrencies as $oCur) {
01528             if ($oCur->name == $this->oxorder__oxcurrency->value) {
01529                 $oBasketCur = $oCur;
01530                 break;
01531             }
01532         }
01533 
01534         $oBasket->setBasketCurrency( $oBasketCur );
01535 
01536         // if no order articles, return empty basket
01537         if (count($aOrderArticles) < 1) {
01538             return $oBasket;
01539         }
01540 
01541         //adding order articles to basket
01542         foreach ( $aOrderArticles as $oOrderArticle ) {
01543             $sArtId      = $oOrderArticle->oxorderarticles__oxartid->value;
01544             $dAmount     = $oOrderArticle->oxorderarticles__oxamount->value;
01545             $sSelVariant = $oOrderArticle->oxorderarticles__oxselvariant->value;
01546 
01547             if ( $oOrderArticle->oxorderarticles__oxpersparam->value ) {
01548                 $aPersParam = unserialize($oOrderArticle->oxorderarticles__oxpersparam->value);
01549             } else {
01550                 $aPersParam = null;
01551             }
01552 
01553             $aSel = $this->_makeSelListArray( $sArtId, $sSelVariant );
01554 
01555             $oBasketItem = $oBasket->addToBasket( $sArtId, $dAmount, $aSel, $aPersParam );
01556             if ( $oBasketItem ) {
01557                 $oBasketItem->setWrapping( $oOrderArticle->oxorderarticles__oxwrapid->value );
01558             }
01559         }
01560 
01561         // set basket card id and message
01562         $oBasket->setCardId( $this->oxorder__oxcardid->value );
01563         $oBasket->setCardMessage( $this->oxorder__oxcardtext->value );
01564 
01565         // set skip vouchers availability checking
01566         $oBasket->setSkipVouchersChecking( true );
01567 
01568         // add previously used vouchers
01569         $sQ = 'select oxid from oxvouchers where oxorderid = "'.$this->getId().'"';
01570         $aVouchers = oxDb::getDb( true )->getAll( $sQ );
01571         foreach ( $aVouchers AS $aVoucher ) {
01572             $oBasket->addVoucher($aVoucher['oxid']);
01573         }
01574 
01575         //set shipping
01576         $oBasket->setShipping( $this->oxorder__oxdeltype->value );
01577 
01578         //set basket payment
01579         $oBasket->setPayment( $this->oxorder__oxpaymenttype->value );
01580 
01581         // recalculating basket
01582         $oBasket->calculateBasket( true );
01583 
01584         return $oBasket;
01585     }
01586 
01594     protected function _setDeprecatedValues()
01595     {
01596         if ( $this->oxorder__oxstorno->value != 1 ) {
01597             $oCur = $this->getConfig()->getActShopCurrencyObject();
01598 
01599             $this->totalnetsum   = $this->oxorder__oxtotalnetsum->value;
01600             $this->totalbrutsum  = $this->oxorder__oxtotalbrutsum->value;
01601             $this->totalorder    = $this->oxorder__oxtotalordersum->value;
01602             $this->ftotalnetsum  = oxLang::getInstance()->formatCurrency( $this->oxorder__oxtotalnetsum->value, $oCur );
01603             $this->ftotalbrutsum = oxLang::getInstance()->formatCurrency( $this->oxorder__oxtotalbrutsum->value, $oCur );
01604             $this->fdelcost      = oxLang::getInstance()->formatCurrency( $this->oxorder__oxdelcost->value, $oCur );
01605             $this->fpaycost      = oxLang::getInstance()->formatCurrency( $this->oxorder__oxpaycost->value, $oCur );
01606             $this->fwrapcost     = oxLang::getInstance()->formatCurrency( $this->oxorder__oxwrapcost->value, $oCur );
01607             $this->ftotalorder   = $this->getTotalOrderSum();
01608             $this->totalvouchers = 0;
01609 
01610             if ( $this->oxorder__oxvoucherdiscount->value ) {
01611                 $this->totalvouchers  = oxLang::getInstance()->formatCurrency( $this->oxorder__oxvoucherdiscount->value, $oCur );
01612             }
01613 
01614             if ( $this->oxorder__oxdiscount->value ) {
01615                 $this->discount  = $this->oxorder__oxdiscount->value;
01616                 $this->fdiscount = oxLang::getInstance()->formatCurrency( $this->oxorder__oxdiscount->value, $oCur );
01617             }
01618         }
01619     }
01620 
01626     public function getTotalOrderSum()
01627     {
01628         $oCur = $this->getConfig()->getActShopCurrencyObject();
01629         return oxLang::getInstance()->formatCurrency( $this->oxorder__oxtotalordersum->value, $oCur );
01630     }
01631 
01632 }

Generated on Thu Dec 4 12:04:56 2008 for OXID eShop CE by  doxygen 1.5.5