79         $this->
init( 
'oxorderarticles' );
 
   91         $aObjectVars = get_object_vars( $oProduct );
 
   93         foreach ( $aObjectVars as $sName => $sValue ) {
 
   94             if ( isset( $oProduct->$sName->value ) ) {
 
   95                 $sFieldName = preg_replace(
'/oxarticles__/', 
'oxorderarticles__', $sName);
 
   96                 if ( $sFieldName != 
"oxorderarticles__oxtimestamp" ) {
 
   97                     $this->$sFieldName = $oProduct->$sName;
 
  100                 if ( !$this->
getConfig()->getConfigParam( 
'blSkipFormatConversion' ) ) {
 
  101                     if ( $sFieldName == 
"oxorderarticles__oxinsert" ) {
 
  102                         oxRegistry::get(
"oxUtilsDate")->convertDBDate( $this->$sFieldName, 
true );
 
  137         $oArticle = 
oxNew( 
'oxarticle' );
 
  138         $oArticle->load( $this->oxorderarticles__oxartid->value );
 
  139         $oArticle->beforeUpdate();
 
  141         if ( $this->
getConfig()->getConfigParam( 
'blUseStock' ) ) {
 
  143             $iStockCount = $this->
_getArtStock( $dAddAmount, $blAllowNegativeStock );
 
  146             $oArticle->oxarticles__oxstock = 
new oxField($iStockCount);
 
  147             $oDb->execute( 
'update oxarticles set oxarticles.oxstock = '.$oDb->quote( $iStockCount ).
' where oxarticles.oxid = '.$oDb->quote( $this->oxorderarticles__oxartid->value ) );
 
  148             $oArticle->onChange( ACTION_UPDATE_STOCK );
 
  152         $oArticle->updateSoldAmount( $dAddAmount * ( -1 ) );
 
  163     protected function _getArtStock( $dAddAmount = 0, $blAllowNegativeStock = 
false )
 
  168         $sQ = 
'select oxstock from oxarticles where oxid = '.$oDb->quote( $this->oxorderarticles__oxartid->value );
 
  169         $iStockCount  = ( float ) $oDb->getOne( $sQ, 
false, 
false );
 
  171         $iStockCount += $dAddAmount;
 
  174         if ( !$blAllowNegativeStock && $iStockCount < 0 ) {
 
  189         if ( $this->_aPersParam != null ) {
 
  193         if ( $this->oxorderarticles__oxpersparam->value ) {
 
  194             $this->_aPersParam = unserialize( $this->oxorderarticles__oxpersparam->value );
 
  209         $this->_aPersParam = $aParams;
 
  226         $sFieldName = strtolower($sFieldName);
 
  227         switch ( $sFieldName ) {
 
  229             case 'oxorderarticles__oxpersparam':
 
  231             case 'oxorderarticles__oxerpstatus':
 
  233             case 'oxorderarticles__oxtitle':
 
  250         return $this->
load( $sOxid );
 
  260         return $this->oxorderarticles__oxartid->value;
 
  271         if ( isset( $this->oxorderarticles__oxartparentid ) && $this->oxorderarticles__oxartparentid->value !== 
false ) {
 
  272             return $this->oxorderarticles__oxartparentid->value;
 
  276         $oArticle = 
oxNew( 
"oxarticle" );
 
  277         $sQ = 
"select oxparentid from " . $oArticle->getViewName() . 
" where oxid=" . $oDb->quote( $this->
getProductId() );
 
  278         $this->oxarticles__oxparentid = 
new oxField( $oDb->getOne( $sQ ) );
 
  279         return $this->oxarticles__oxparentid->value;
 
  290         $this->oxarticles__oxstock  = $this->oxorderarticles__oxamount;
 
  291         $this->oxarticles__oxtitle  = $this->oxorderarticles__oxtitle;
 
  292         $this->oxarticles__oxwidth  = $this->oxorderarticles__oxwidth;
 
  293         $this->oxarticles__oxlength = $this->oxorderarticles__oxlength;
 
  294         $this->oxarticles__oxheight = $this->oxorderarticles__oxheight;
 
  295         $this->oxarticles__oxweight = $this->oxorderarticles__oxweight;
 
  296         $this->oxarticles__oxsubclass  = $this->oxorderarticles__oxsubclass;
 
  297         $this->oxarticles__oxartnum    = $this->oxorderarticles__oxartnum;
 
  298         $this->oxarticles__oxshortdesc = $this->oxorderarticles__oxshortdesc;
 
  300         $this->oxarticles__oxvat    = $this->oxorderarticles__oxvat;
 
  301         $this->oxarticles__oxprice  = $this->oxorderarticles__oxprice;
 
  302         $this->oxarticles__oxbprice = $this->oxorderarticles__oxbprice;
 
  304         $this->oxarticles__oxthumb = $this->oxorderarticles__oxthumb;
 
  305         $this->oxarticles__oxpic1  = $this->oxorderarticles__oxpic1;
 
  306         $this->oxarticles__oxpic2  = $this->oxorderarticles__oxpic2;
 
  307         $this->oxarticles__oxpic3  = $this->oxorderarticles__oxpic3;
 
  308         $this->oxarticles__oxpic4  = $this->oxorderarticles__oxpic4;
 
  309         $this->oxarticles__oxpic5  = $this->oxorderarticles__oxpic5;
 
  311         $this->oxarticles__oxfile     = $this->oxorderarticles__oxfile;
 
  312         $this->oxarticles__oxdelivery = $this->oxorderarticles__oxdelivery;
 
  313         $this->oxarticles__oxissearch = $this->oxorderarticles__oxissearch;
 
  314         $this->oxarticles__oxfolder   = $this->oxorderarticles__oxfolder;
 
  315         $this->oxarticles__oxtemplate = $this->oxorderarticles__oxtemplate;
 
  316         $this->oxarticles__oxexturl   = $this->oxorderarticles__oxexturl;
 
  317         $this->oxarticles__oxurlimg   = $this->oxorderarticles__oxurlimg;
 
  318         $this->oxarticles__oxurldesc  = $this->oxorderarticles__oxurldesc;
 
  319         $this->oxarticles__oxshopid   = $this->oxorderarticles__oxordershopid;
 
  320         $this->oxarticles__oxquestionemail = $this->oxorderarticles__oxquestionemail;
 
  321         $this->oxarticles__oxsearchkeys    = $this->oxorderarticles__oxsearchkeys;
 
  347         if ( $this->_oOrderArticle === null ) {
 
  348             $this->_oOrderArticle = 
false;
 
  350             $sArticleId = $sArticleId ? $sArticleId : $this->
getProductId();
 
  351             $oArticle = 
oxNew( 
"oxArticle" );
 
  352             $oArticle->setLoadParentData(
true);
 
  353             if ( $oArticle->load( $sArticleId ) ) {
 
  354                 $this->_oOrderArticle = $oArticle;
 
  369         $aSelLists = array();
 
  371             $aSelLists = $oArticle->getSelectLists();
 
  386         if ( $this->_aOrderArticleSelList === null ) {
 
  388             $sOrderArtSelList = $sOrderArtSelList ? $sOrderArtSelList : $this->oxorderarticles__oxselvariant->value;
 
  394                 $aList = explode( 
", ", $sOrderArtSelList );
 
  397                 $aArticleSelList = $oArticle->getSelectLists();
 
  400                 foreach ( $aList as $sList ) {
 
  403                         $aVal = explode( 
":", $sList );
 
  404                         if ( isset($aVal[0]) && isset($aVal[1])) {
 
  405                             $sOrderArtListTitle = $oStr->strtolower( trim($aVal[0]) );
 
  406                             $sOrderArtSelValue  = $oStr->strtolower( trim($aVal[1]) );
 
  410                             if ( count($aArticleSelList) > 0 ) {
 
  411                                 foreach ( $aArticleSelList as $aSelect ) {
 
  414                                     if ( $oStr->strtolower($aSelect[
'name']) == $sOrderArtListTitle ) {
 
  417                                         foreach ( $aSelect as $oSel ) {
 
  418                                             if ( $oStr->strtolower($oSel->name) == $sOrderArtSelValue ) {
 
  420                                                 $aRet[$iSelListNum] = $iSelValueNum;
 
  435             $this->_aOrderArticleSelList = $aRet;
 
  454             return $oArticle->getBasketPrice( $dAmount, $aSelList, $oBasket );
 
  482             $aCatIds = $oOrderArticle->getCategoryIds( $blActCats, $blSkipCache );
 
  517         $oBasePrice = 
oxNew( 
'oxPrice' );
 
  519         $oBasePrice->setBruttoPriceMode();
 
  520         $oBasePrice->setVat( $this->oxorderarticles__oxvat->value );
 
  521         $oBasePrice->setPrice( $this->oxorderarticles__oxbprice->value );
 
  535         $this->_blIsNewOrderItem = $blIsNew;
 
  559         if ( $iNewAmount >= 0 ) {
 
  561             $oArticle = 
oxNew( 
"oxarticle" );
 
  562             if ( $oArticle->load( $this->oxorderarticles__oxartid->value ) ) {
 
  565                 $iStockChange = $iNewAmount - $this->oxorderarticles__oxamount->value;
 
  566                 if ( $iStockChange > 0 && ( $iOnStock = $oArticle->checkForStock( $iStockChange ) ) !== 
false ) {
 
  567                     if ( $iOnStock !== 
true ) {
 
  568                         $iStockChange = $iOnStock;
 
  569                         $iNewAmount   = $this->oxorderarticles__oxamount->value + $iStockChange;
 
  601         if ( $this->oxorderarticles__oxstorno->value == 0 ) {
 
  603             $this->oxorderarticles__oxstorno = 
new oxField( 1 );
 
  604             if ( $this->
save() ) {
 
  618     public function delete( $sOXID = null)
 
  620         if ( $blDelete = parent::delete( $sOXID ) ) {
 
  622             if ( $this->oxorderarticles__oxstorno->value != 1 ) {
 
  641             if ( 
$myConfig->getConfigParam( 
'blUseStock' ) &&
 
  642                  $myConfig->getConfigParam( 
'blPsBasketReservationEnabled' ) ) {
 
  644                             ->getBasketReservations()
 
  645                             ->commitArticleReservation(
 
  646                                    $this->oxorderarticles__oxartid->value,
 
  647                                    $this->oxorderarticles__oxamount->value
 
  670         if ($this->oxorderarticles__oxwrapid->value) {
 
  671             $oWrapping = 
oxNew(
'oxwrapping');
 
  672             if ($oWrapping->load($this->oxorderarticles__oxwrapid->value)) {
 
  686         return ( 
bool ) $this->oxorderarticles__oxisbundle->value;
 
  698         $oCurrency = $this->
getConfig()->getCurrencyObject( $oOrder->oxorder__oxcurrency->value );
 
  699         return $oLang->formatCurrency( $this->oxorderarticles__oxbrutprice->value, $oCurrency );
 
  711         $oCurrency = $this->
getConfig()->getCurrencyObject( $oOrder->oxorder__oxcurrency->value );
 
  712         return $oLang->formatCurrency(  $this->oxorderarticles__oxbprice->value, $oCurrency );
 
  724         $oCurrency = $this->
getConfig()->getCurrencyObject( $oOrder->oxorder__oxcurrency->value );
 
  725         return $oLang->formatCurrency(  $this->oxorderarticles__oxnprice->value, $oCurrency );
 
  735         if ( $this->oxorderarticles__oxorderid->value ) {
 
  737             if ( isset( $this->_aOrderCache[ $this->oxorderarticles__oxorderid->value ] )) {
 
  739                 return $this->_aOrderCache[ $this->oxorderarticles__oxorderid->value ];
 
  742             $oOrder = 
oxNew( 
'oxOrder' );
 
  743             if ( $oOrder->load( $this->oxorderarticles__oxorderid->value )) {
 
  744                 return $this->_aOrderCache[$this->oxorderarticles__oxorderid->value] = $oOrder;
 
  760         $iInsertTime = time();
 
  761         $now = date(
'Y-m-d H:i:s', $iInsertTime);
 
  762         $this->oxorderarticles__oxtimestamp = 
new oxField( $now );
 
  777         $this->_oArticle = $oArticle;
 
  787         if ( $this->_oArticle === null ) {
 
  788             $oArticle = 
oxNew( 
'oxArticle' );
 
  789             $oArticle->load($this->oxorderarticles__oxartid->value);
 
  790             $this->_oArticle = $oArticle;
 
  807         if ( $oArticle->oxarticles__oxisdownloadable->value ) {
 
  810             $sOrderId          = $this->oxorderarticles__oxorderid->value;
 
  811             $sOrderArticleId = $this->
getId();
 
  812             $sShopId          = $oConfig->getShopId();
 
  814             $oUser             = $oConfig->getUser();
 
  816             $oFiles = $oArticle->getArticleFiles( 
true );
 
  819                 foreach ($oFiles as $oFile) {
 
  820                     $oOrderFile = 
oxNew( 
'oxOrderFile' );
 
  821                     $oOrderFile->setOrderId( $sOrderId );
 
  822                     $oOrderFile->setOrderArticleId( $sOrderArticleId );
 
  823                     $oOrderFile->setShopId( $sShopId );
 
  824                     $iMaxDownloadCount = (!empty($oUser) && !$oUser->hasAccount()) ? $oFile->getMaxUnregisteredDownloadsCount() :  $oFile->getMaxDownloadsCount();
 
  825                     $oOrderFile->setFile(
 
  826                         $oFile->oxfiles__oxfilename->value,
 
  828                         $iMaxDownloadCount * $this->oxorderarticles__oxamount->value,
 
  829                         $oFile->getLinkExpirationTime(),
 
  830                         $oFile->getDownloadExpirationTime()
 
  848         $oCurrency = $this->
getConfig()->getCurrencyObject( $oOrder->oxorder__oxcurrency->value );
 
  849         return $oLang->formatCurrency( $this->oxorderarticles__oxnetprice->value, $oCurrency );