218 $this->
init(
'oxorder' );
234 if ( $sName ==
'oDelSet' ) {
238 if ( $sName ==
'oxorder__oxbillcountry' ) {
242 if ( $sName ==
'oxorder__oxdelcountry' ) {
262 $this->oxorder__oxorderdate =
new oxField( $oUtilsDate->formatDBDate( $this->oxorder__oxorderdate->value));
263 $this->oxorder__oxsenddate =
new oxField( $oUtilsDate->formatDBDate( $this->oxorder__oxsenddate->value));
276 if ( $sCountryId && $sCountryId !=
'-1' ) {
277 $oCountry =
oxNew(
'oxcountry' );
279 $sTitle = $oCountry->oxcountry__oxtitle->value;
294 $sSelect =
"SELECT `oxorderarticles`.* FROM `oxorderarticles`
295 WHERE `oxorderarticles`.`oxorderid` = '".$this->getId() .
"'" .
296 ( $blExcludeCanceled ?
" AND `oxorderarticles`.`oxstorno` != 1 ":
" " ) .
"
297 ORDER BY `oxorderarticles`.`oxartid`, `oxorderarticles`.`oxselvariant`, `oxorderarticles`.`oxpersparam` ";
300 $oArticles =
oxNew(
'oxlist' );
301 $oArticles->init(
'oxorderarticle' );
302 $oArticles->selectString( $sSelect );
317 if ( $blExcludeCanceled ) {
321 } elseif ( $this->_oArticles === null ) {
337 $this->_oArticles = $oOrderArticleList;
347 if ( $this->_oDelPrice != null ) {
351 $this->_oDelPrice =
oxNew(
'oxprice' );
352 $this->_oDelPrice->setBruttoPriceMode();
353 $this->_oDelPrice->setPrice( $this->oxorder__oxdelcost->value, $this->oxorder__oxdelvat->value );
364 if ( $this->_oWrappingPrice != null ) {
368 $this->_oWrappingPrice =
oxNew(
'oxprice' );
369 $this->_oWrappingPrice->setBruttoPriceMode();
370 $this->_oWrappingPrice->setPrice( $this->oxorder__oxwrapcost->value, $this->oxorder__oxwrapvat->value );
381 if ( $this->_oGidtCardPrice != null ) {
382 return $this->_oGidtCardPrice;
385 $this->_oGidtCardPrice =
oxNew(
'oxprice' );
386 $this->_oGidtCardPrice->setBruttoPriceMode();
387 $this->_oGidtCardPrice->setPrice( $this->oxorder__oxgiftcardcost->value, $this->oxorder__oxgiftcardvat->value );
388 return $this->_oGidtCardPrice;
399 if ( $this->_oPaymentPrice != null ) {
403 $this->_oPaymentPrice =
oxNew(
'oxprice' );
404 $this->_oPaymentPrice->setBruttoPriceMode();
405 $this->_oPaymentPrice->setPrice( $this->oxorder__oxpaycost->value, $this->oxorder__oxpayvat->value );
416 if ( $this->_oTsProtectionPrice != null ) {
420 $this->_oTsProtectionPrice =
oxNew(
'oxprice' );
421 $this->_oTsProtectionPrice->setBruttoPriceMode();
422 $this->_oTsProtectionPrice->setPrice( $this->oxorder__oxtsprotectcosts->value, $this->getConfig()->getConfigParam(
'dDefaultVAT' ) );
436 $dTotalNetSum += $this->oxorder__oxtotalnetsum->value;
441 return $dTotalNetSum;
475 if ( !$blRecalculatingOrder ) {
477 $this->
setId( $sGetChallenge );
480 if ( $iOrderState = $this->
validateOrder( $oBasket, $oUser ) ) {
496 if ( !$blRecalculatingOrder ) {
508 if ( !$blRecalculatingOrder ) {
510 if ( $blRet !==
true ) {
515 if ( !$this->oxorder__oxordernr->value ) {
524 if ( $blRet !==
true ) {
534 if ( !$blRecalculatingOrder ) {
552 if ( !$blRecalculatingOrder ) {
558 if ( !$blRecalculatingOrder ) {
574 return (
bool) $this->oxorder__oxisnettomode->value;
588 $sQ =
'update oxorder set oxtransstatus='.$oDb->quote( $sStatus ).
' where oxid='.$oDb->quote( $this->
getId() );
589 $oDb->execute( $sQ );
604 if ( strpos( $sVat,
'.' ) < strpos( $sVat,
',' ) ) {
605 $sVat = str_replace( array(
'.',
',' ), array(
'',
'.' ), $sVat );
607 $sVat = str_replace(
',',
'', $sVat );
609 return (
float) $sVat;
619 $this->oxorder__oxartvat1 =
new oxField( null );
620 $this->oxorder__oxartvatprice1 =
new oxField( null );
621 $this->oxorder__oxartvat2 =
new oxField( null );
622 $this->oxorder__oxartvatprice2 =
new oxField( null );
640 if (
$myConfig->getConfigParam(
'blStoreIPs' ) && $this->oxorder__oxip->value === null ) {
662 if ( ( $oPaymentCost = $oBasket->
getCosts(
'oxpayment' ) ) ) {
668 if ( ( $oDeliveryCost = $oBasket->
getCosts(
'oxdelivery' ) ) ) {
676 if ( !isset( $this->oxorder__oxremark ) || $this->oxorder__oxremark->value === null ) {
681 $oCur =
$myConfig->getActShopCurrencyObject();
682 $this->oxorder__oxcurrency =
new oxField($oCur->name);
687 $this->oxorder__oxvoucherdiscount =
new oxField($oVoucherDiscount->getBruttoPrice(),
oxField::T_RAW);
691 if ( $this->_blReloadDiscount ) {
694 if ( count($aDiscounts) > 0 ) {
695 foreach ($aDiscounts as $oDiscount) {
696 $dDiscount += $oDiscount->dDiscount;
727 if ( $this->_iOrderLang === null ) {
728 if ( isset( $this->oxorder__oxlang->value ) ) {
729 $this->_iOrderLang =
oxRegistry::getLang()->validateLanguage( $this->oxorder__oxlang->value );
747 $this->oxorder__oxuserid =
new oxField($oUser->getId());
750 $this->oxorder__oxbillcompany = clone $oUser->oxuser__oxcompany;
751 $this->oxorder__oxbillemail = clone $oUser->oxuser__oxusername;
752 $this->oxorder__oxbillfname = clone $oUser->oxuser__oxfname;
753 $this->oxorder__oxbilllname = clone $oUser->oxuser__oxlname;
754 $this->oxorder__oxbillstreet = clone $oUser->oxuser__oxstreet;
755 $this->oxorder__oxbillstreetnr = clone $oUser->oxuser__oxstreetnr;
756 $this->oxorder__oxbilladdinfo = clone $oUser->oxuser__oxaddinfo;
757 $this->oxorder__oxbillustid = clone $oUser->oxuser__oxustid;
758 $this->oxorder__oxbillcity = clone $oUser->oxuser__oxcity;
759 $this->oxorder__oxbillcountryid = clone $oUser->oxuser__oxcountryid;
760 $this->oxorder__oxbillstateid = clone $oUser->oxuser__oxstateid;
761 $this->oxorder__oxbillzip = clone $oUser->oxuser__oxzip;
762 $this->oxorder__oxbillfon = clone $oUser->oxuser__oxfon;
763 $this->oxorder__oxbillfax = clone $oUser->oxuser__oxfax;
764 $this->oxorder__oxbillsal = clone $oUser->oxuser__oxsal;
770 $this->oxorder__oxdelcompany = clone $oDelAdress->oxaddress__oxcompany;
771 $this->oxorder__oxdelfname = clone $oDelAdress->oxaddress__oxfname;
772 $this->oxorder__oxdellname = clone $oDelAdress->oxaddress__oxlname;
773 $this->oxorder__oxdelstreet = clone $oDelAdress->oxaddress__oxstreet;
774 $this->oxorder__oxdelstreetnr = clone $oDelAdress->oxaddress__oxstreetnr;
775 $this->oxorder__oxdeladdinfo = clone $oDelAdress->oxaddress__oxaddinfo;
776 $this->oxorder__oxdelcity = clone $oDelAdress->oxaddress__oxcity;
777 $this->oxorder__oxdelcountryid = clone $oDelAdress->oxaddress__oxcountryid;
778 $this->oxorder__oxdelstateid = clone $oDelAdress->oxaddress__oxstateid;
779 $this->oxorder__oxdelzip = clone $oDelAdress->oxaddress__oxzip;
780 $this->oxorder__oxdelfon = clone $oDelAdress->oxaddress__oxfon;
781 $this->oxorder__oxdelfax = clone $oDelAdress->oxaddress__oxfax;
782 $this->oxorder__oxdelsal = clone $oDelAdress->oxaddress__oxsal;
798 if ( ( $oWrappingCost = $oBasket->
getCosts(
'oxwrapping' ) ) ) {
804 if ( ( $oGiftCardCost = $oBasket->
getCosts(
'oxgiftcard' ) ) ) {
827 $this->_oArticles =
oxNew(
'oxlist' );
831 foreach ( $aArticleList as $oContent ) {
835 $oProduct = $oContent->getArticle(
true, null,
true);
838 if ( $oProduct->isOrderArticle() ) {
839 $oOrderArticle = $oProduct;
843 if ( $iCurrLang != $oProduct->getLanguage() ) {
844 $oProduct->loadInLang( $iCurrLang, $oProduct->getProductId() );
849 if ( count( $aChosenSelList = $oContent->getChosenSelList() ) ) {
850 foreach ( $aChosenSelList as $oItem ) {
854 $sSelList .=
"{$oItem->name} : {$oItem->value}";
858 $oOrderArticle =
oxNew(
'oxorderarticle' );
859 $oOrderArticle->setIsNewOrderItem(
true );
860 $oOrderArticle->copyThis( $oProduct );
861 $oOrderArticle->setId();
863 $oOrderArticle->oxorderarticles__oxartnum = clone $oProduct->oxarticles__oxartnum;
864 $oOrderArticle->oxorderarticles__oxselvariant =
new oxField( trim( $sSelList.
' '.$oProduct->oxarticles__oxvarselect->getRawValue() ),
oxField::T_RAW );
865 $oOrderArticle->oxorderarticles__oxshortdesc =
new oxField( $oProduct->oxarticles__oxshortdesc->getRawValue(),
oxField::T_RAW );
867 $oOrderArticle->oxorderarticles__oxtitle =
new oxField( trim( $oProduct->oxarticles__oxtitle->getRawValue() ),
oxField::T_RAW );
870 if ( !is_array( $aPersParams = $oProduct->getPersParams() ) ) {
871 $aPersParams = $oContent->getPersParams();
873 if ( is_array( $aPersParams ) && count( $aPersParams )) {
874 $oOrderArticle->oxorderarticles__oxpersparam =
new oxField( serialize( $aPersParams ),
oxField::T_RAW );
879 $oOrderArticle->oxorderarticles__oxorderid =
new oxField( $this->
getId() );
880 $oOrderArticle->oxorderarticles__oxartid =
new oxField( $oContent->getProductId() );
881 $oOrderArticle->oxorderarticles__oxamount =
new oxField( $oContent->getAmount() );
884 $oPrice = $oContent->getPrice();
885 $oOrderArticle->oxorderarticles__oxnetprice =
new oxField( $oPrice->getNettoPrice(),
oxField::T_RAW );
887 $oOrderArticle->oxorderarticles__oxbrutprice =
new oxField( $oPrice->getBruttoPrice(),
oxField::T_RAW );
890 $oUnitPtice = $oContent->getUnitPrice();
891 $oOrderArticle->oxorderarticles__oxnprice =
new oxField( $oUnitPtice->getNettoPrice(),
oxField::T_RAW );
892 $oOrderArticle->oxorderarticles__oxbprice =
new oxField( $oUnitPtice->getBruttoPrice(),
oxField::T_RAW );
895 $oOrderArticle->oxorderarticles__oxwrapid =
new oxField( $oContent->getWrappingId(),
oxField::T_RAW );
898 $oOrderArticle->oxorderarticles__oxordershopid =
new oxField( $oContent->getShopId(),
oxField::T_RAW );
901 $oOrderArticle->oxorderarticles__oxisbundle =
new oxField( $oContent->isBundle() );
906 $oOrderArticle->oProduct = $oProduct;
908 $oOrderArticle->setArticle( $oProduct );
911 $this->_oArticles->offsetSet( $oOrderArticle->getId(), $oOrderArticle );
929 $oPayTransaction->setPaymentParams( $oUserpayment );
931 if ( !$oPayTransaction->executePayment( $oBasket->
getPrice()->getBruttoPrice(), $this ) ) {
935 if ( method_exists( $oPayTransaction,
'getLastError' ) ) {
936 if ( ( $sLastError = $oPayTransaction->getLastError() ) ) {
942 if ( method_exists( $oPayTransaction,
'getLastErrorNo' ) ) {
943 if ( ( $iLastErrorNo = $oPayTransaction->getLastErrorNo() ) ) {
944 return $iLastErrorNo;
961 return oxNew(
'oxPaymentGateway' );
978 $oPayment =
oxNew(
'oxpayment' );
980 if (!$oPayment->load( $sPaymentid )) {
985 if ( !$aDynvalue && ( $oUserpayment = $this->
getPaymentType() ) ) {
986 if ( is_array( $aStoredDynvalue = $oUserpayment->getDynValues() ) ) {
987 foreach ( $aStoredDynvalue as $oVal ) {
988 $aDynvalue[$oVal->name] = $oVal->value;
993 $oPayment->setDynValues(
oxRegistry::getUtils()->assignValuesFromText( $oPayment->oxpayments__oxvaldesc->value ) );
998 if ( is_array( $aPaymentDynValues = $oPayment->getDynValues() ) ) {
999 foreach ( $aPaymentDynValues as $key => $oVal ) {
1000 if ( isset( $aDynvalue[$oVal->name] ) ) {
1001 $oVal->value = $aDynvalue[$oVal->name];
1005 $aPaymentDynValues[$key] = $oVal;
1006 $aDynVal[$oVal->name] = $oVal->value;
1013 $oUserpayment =
oxNew(
'oxuserpayment' );
1014 $oUserpayment->oxuserpayments__oxuserid = clone $this->oxorder__oxuserid;
1017 $oUserpayment->oxpayments__oxdesc = clone $oPayment->oxpayments__oxdesc;
1018 $oUserpayment->oxpayments__oxlongdesc = clone $oPayment->oxpayments__oxlongdesc;
1019 $oUserpayment->setDynValues( $aPaymentDynValues );
1020 $oUserpayment->save();
1024 $this->oxorder__oxpaymenttype = clone $oUserpayment->oxuserpayments__oxpaymentsid;
1027 return $oUserpayment;
1053 foreach ( $aArticleList as $oContent) {
1054 if ( ( $sWishId = $oContent->getWishId() ) ) {
1057 if ( $sWishId == $oUser->getId() ) {
1058 $oUserBasket = $oUser->getBasket(
'wishlist' );
1060 $aWhere = array(
'oxuserbaskets.oxuserid' => $sWishId,
'oxuserbaskets.oxtitle' =>
'wishlist' );
1061 $oUserBasket =
oxNew(
'oxuserbasket' );
1062 $oUserBasket->assignRecord( $oUserBasket->buildSelectString( $aWhere ) );
1066 if ( $oUserBasket ) {
1067 if ( !($sProdId = $oContent->getWishArticleId() )) {
1068 $sProdId = $oContent->getProductId();
1070 $oUserBasketItem = $oUserBasket->getItem( $sProdId, $oContent->getSelList() );
1071 $dNewAmount = $oUserBasketItem->oxuserbasketitems__oxamount->value - $oContent->getAmount();
1072 if ( $dNewAmount < 0) {
1075 $oUserBasket->addItemToBasket( $sProdId, $dNewAmount, $oContent->getSelList(), true );
1093 if ( $oUserBasket = $oUser->getBasket(
'noticelist' ) ) {
1095 foreach ( $aArticleList as $oContent) {
1096 $sProdId = $oContent->getProductId();
1099 $oUserBasketItem = $oUserBasket->getItem( $sProdId, $oContent->getSelList(), $oContent->getPersParams() );
1100 $dNewAmount = $oUserBasketItem->oxuserbasketitems__oxamount->value - $oContent->getAmount();
1101 if ( $dNewAmount < 0) {
1104 $oUserBasket->addItemToBasket( $sProdId, $dNewAmount, $oContent->getSelList(),
true, $oContent->getPersParams() );
1117 $sDate = date(
'Y-m-d H:i:s',
oxRegistry::get(
"oxUtilsDate")->getTime() );
1118 $sQ =
'update oxorder set oxorderdate=' . $oDb->quote( $sDate ) .
' where oxid=' . $oDb->quote( $this->
getId() );
1120 $oDb->execute( $sQ );
1134 $this->_aVoucherList = $oBasket->getVouchers();
1136 if ( is_array( $this->_aVoucherList ) ) {
1137 foreach ( $this->_aVoucherList as $sVoucherId => $oSimpleVoucher) {
1138 $oVoucher =
oxNew(
'oxvoucher' );
1139 $oVoucher->load( $sVoucherId );
1140 $oVoucher->markAsUsed( $this->oxorder__oxid->value, $oUser->oxuser__oxid->value, $oSimpleVoucher->dVoucherdiscount );
1142 $this->_aVoucherList[$sVoucherId] = $oVoucher;
1154 if ( ( $blSave = parent::save() ) ) {
1158 if ( $oOrderArticles && count( $oOrderArticles ) > 0 ) {
1159 foreach ( $oOrderArticles as $oOrderArticle ) {
1160 $oOrderArticle->save();
1180 if ( $soxAddressId ) {
1181 $oDelAdress =
oxNew(
'oxaddress' );
1182 $oDelAdress->load( $soxAddressId );
1185 if ( $oDelAdress->oxaddress__oxcountryid->value && $oDelAdress->oxaddress__oxcountryid->value != -1 ) {
1186 $oCountry =
oxNew(
'oxcountry' );
1187 $oCountry->load( $oDelAdress->oxaddress__oxcountryid->value );
1188 $oDelAdress->oxaddress__oxcountry = clone $oCountry->oxcountry__oxtitle;
1206 foreach ( $oBasket->getContents() as $key => $oContent ) {
1208 $oProd = $oContent->getArticle(
true );
1210 $oBasket->removeItem( $key );
1213 $oBasket->removeItem( $key );
1218 $dArtStockAmount = $oBasket->getArtStockInBasket( $oProd->getId(), $key );
1219 $iOnStock = $oProd->checkForStock( $oContent->getAmount(), $dArtStockAmount );
1220 if ( $iOnStock !==
true ) {
1221 $oEx =
oxNew(
'oxOutOfStockException' );
1222 $oEx->
setMessage(
'ERROR_MESSAGE_OUTOFSTOCK_OUTOFSTOCK' );
1223 $oEx->
setArticleNr( $oProd->oxarticles__oxartnum->value );
1226 if (!is_numeric($iOnStock)) {
1229 $oEx->setRemainingAmount( $iOnStock );
1246 if ( !$this->oxorder__oxorderdate->value ) {
1247 $this->oxorder__oxorderdate =
new oxField(date(
'Y-m-d H:i:s', $oUtilsDate->getTime() ),
oxField::T_RAW);
1249 $this->oxorder__oxorderdate =
new oxField( $oUtilsDate->formatDBDate( $this->oxorder__oxorderdate->value,
true ));
1253 $this->oxorder__oxsenddate =
new oxField( $oUtilsDate->formatDBDate( $this->oxorder__oxsenddate->value,
true ));
1268 return $sCounterIdent;
1282 $sQ =
"update oxorder set oxordernr = ? where oxid = ?";
1283 $blUpdate = ( bool ) $oDb->execute( $sQ, array($iCnt, $this->
getId() ) );
1286 $this->oxorder__oxordernr =
new oxField( $iCnt );
1299 $this->_aSkipSaveFields = array(
'oxtimestamp',
'oxorderdate' );
1300 $this->oxorder__oxsenddate =
new oxField(
oxRegistry::get(
"oxUtilsDate")->formatDBDate( $this->oxorder__oxsenddate->value,
true ));
1312 public function delete( $sOxId = null )
1315 if ( !$this->
load( $sOxId ) ) {
1319 } elseif ( !$sOxId ) {
1320 $sOxId = $this->
getId();
1331 foreach ( $oOrderArticles as $oOrderArticle ) {
1332 $oOrderArticle->delete();
1337 $oPaymentType->delete();
1366 $oBasket->calculateBasket(
true );
1372 if ( $iRet !== 1 ) {
1382 if ( defined(
'OXID_PHP_UNIT' ) ) {
1398 $this->_oOrderBasket =
oxNew(
"oxbasket" );
1401 $this->_oOrderBasket->setCalculationModeNetto( $this->
isNettoMode() );
1404 $this->_oOrderBasket->setStockCheckMode( $blStockCheck );
1407 $this->_oOrderBasket->setBasketUser( $this->
getOrderUser() );
1410 $this->_oOrderBasket->setOrderId( $this->
getId() );
1413 $aCurrencies = $this->
getConfig()->getCurrencyArray();
1414 foreach ( $aCurrencies as $oCur ) {
1415 if ($oCur->name == $this->oxorder__oxcurrency->value) {
1416 $oBasketCur = $oCur;
1422 $this->_oOrderBasket->setBasketCurrency( $oBasketCur );
1425 $this->_oOrderBasket->setCardId( $this->oxorder__oxcardid->value );
1426 $this->_oOrderBasket->setCardMessage( $this->oxorder__oxcardtext->value );
1428 if ( $this->_blReloadDiscount ) {
1431 $this->_oOrderBasket->setSkipVouchersChecking(
true );
1434 $sQ =
'select oxid from oxvouchers where oxorderid = '.$oDb->quote( $this->
getId() );
1435 $aVouchers = $oDb->getAll( $sQ );
1436 foreach ( $aVouchers as $aVoucher ) {
1437 $this->_oOrderBasket->addVoucher( $aVoucher[
'oxid'] );
1440 $this->_oOrderBasket->setDiscountCalcMode(
false );
1441 $this->_oOrderBasket->setVoucherDiscount( $this->oxorder__oxvoucherdiscount->value );
1442 $this->_oOrderBasket->setTotalDiscount( $this->oxorder__oxdiscount->value );
1446 if ( !$this->_blReloadDelivery ) {
1450 $this->_oOrderBasket->setShipping( $this->oxorder__oxdeltype->value );
1451 $this->_oOrderBasket->setDeliveryPrice( null );
1455 $this->_oOrderBasket->setPayment( $this->oxorder__oxpaymenttype->value );
1471 $this->oxorder__oxdeltype =
new oxField( $sDeliveryId );
1481 if ($this->_oUser === null ) {
1482 $this->_oUser =
oxNew(
"oxuser" );
1483 $this->_oUser->load( $this->oxorder__oxuserid->value );
1486 if ( $this->_isLoaded ) {
1488 $this->_oUser->oxuser__oxcompany = clone $this->oxorder__oxbillcompany;
1489 $this->_oUser->oxuser__oxusername = clone $this->oxorder__oxbillemail;
1490 $this->_oUser->oxuser__oxfname = clone $this->oxorder__oxbillfname;
1491 $this->_oUser->oxuser__oxlname = clone $this->oxorder__oxbilllname;
1492 $this->_oUser->oxuser__oxstreet = clone $this->oxorder__oxbillstreet;
1493 $this->_oUser->oxuser__oxstreetnr = clone $this->oxorder__oxbillstreetnr;
1494 $this->_oUser->oxuser__oxaddinfo = clone $this->oxorder__oxbilladdinfo;
1495 $this->_oUser->oxuser__oxustid = clone $this->oxorder__oxbillustid;
1498 $this->_oUser->oxuser__oxcity = clone $this->oxorder__oxbillcity;
1499 $this->_oUser->oxuser__oxcountryid = clone $this->oxorder__oxbillcountryid;
1500 $this->_oUser->oxuser__oxstateid = clone $this->oxorder__oxbillstateid;
1501 $this->_oUser->oxuser__oxzip = clone $this->oxorder__oxbillzip;
1502 $this->_oUser->oxuser__oxfon = clone $this->oxorder__oxbillfon;
1503 $this->_oUser->oxuser__oxfax = clone $this->oxorder__oxbillfax;
1504 $this->_oUser->oxuser__oxsal = clone $this->oxorder__oxbillsal;
1552 public function genPdf( $sFilename, $iSelLang = 0 )
1563 $sQ =
'select max(oxorder.oxinvoicenr) from oxorder where oxorder.oxshopid = "'.$this->getConfig()->getShopId().
'" ';
1564 return ( (
int )
oxDb::getDb()->getOne( $sQ,
false ) + 1 );
1574 $sQ =
'select max(cast(oxorder.oxbillnr as unsigned)) from oxorder where oxorder.oxshopid = "'.$this->getConfig()->getShopId().
'" ';
1575 return ( (
int )
oxDb::getDb()->getOne( $sQ,
false ) + 1 );
1586 if ( !( $sShipId = $this->oxorder__oxdelcountryid->value ) ) {
1587 $sShipId = $this->oxorder__oxbillcountryid->value;
1594 foreach ( $oOrderArticles as $sItemId => $oItem ) {
1595 if ( $oItem->isBundle() ) {
1596 $oOrderArticles->offsetUnset( $sItemId );
1604 $oBasket->calculateBasket(
true );
1607 $oDeliveryList =
oxNew(
"oxDeliveryList",
"core" );
1608 $oDeliveryList->setCollectFittingDeliveriesSets(
true );
1610 return $oDeliveryList->getDeliveryList( $oBasket, $this->
getOrderUser(), $sShipId );
1621 $aVouchers = array();
1622 $sSelect =
"select oxvouchernr from oxvouchers where oxorderid = ".$oDb->quote( $this->oxorder__oxid->value );
1623 $rs = $oDb->select( $sSelect );
1624 if ($rs !=
false && $rs->recordCount() > 0) {
1626 $aVouchers[] = $rs->fields[
'oxvouchernr'];
1642 $sSelect =
'select sum(oxtotalordersum / oxcurrate) from oxorder where ';
1643 $sSelect .=
'oxshopid = "'.$this->getConfig()->getShopId().
'" and oxorder.oxstorno != "1" ';
1646 $sSelect .=
'and oxorderdate like "'.date(
'Y-m-d').
'%" ';
1649 return (
double )
oxDb::getDb()->getOne( $sSelect,
false,
false );
1661 $sSelect =
'select count(*) from oxorder where ';
1662 $sSelect .=
'oxshopid = "'.$this->getConfig()->getShopId().
'" and oxorder.oxstorno != "1" ';
1665 $sSelect .=
'and oxorderdate like "'.date(
'Y-m-d').
'%" ';
1668 return (
int )
oxDb::getDb()->getOne( $sSelect,
false,
false );
1686 if ( $oDb->getOne(
'select oxid from oxorder where oxid = '.$oDb->quote( $sOxId ),
false, false ) ) {
1707 $this->_oUser = $oUser;
1708 $this->_oBasket = $oBasket;
1709 $this->_oPayment = $oPayment;
1711 $oxEmail =
oxNew(
'oxemail' );
1714 if ( $oxEmail->sendOrderEMailToUser( $this ) ) {
1720 $oxEmail->sendOrderEMailToOwner( $this );
1762 if ( $this->_oDelSet == null ) {
1764 $this->_oDelSet =
oxNew(
'oxdeliveryset' );
1765 $this->_oDelSet->load( $this->oxorder__oxdeltype->value );
1778 if ( $this->oxorder__oxpaymentid->value && $this->_oPaymentType === null ) {
1779 $this->_oPaymentType =
false;
1780 $oPaymentType =
oxNew(
'oxuserpayment' );
1781 if ( $oPaymentType->load( $this->oxorder__oxpaymentid->value ) ) {
1782 $this->_oPaymentType = $oPaymentType;
1796 if ( $this->oxorder__oxcardid->value && $this->_oGiftCard == null ) {
1797 $this->_oGiftCard =
oxNew(
'oxwrapping' );
1798 $this->_oGiftCard->load( $this->oxorder__oxcardid->value );
1813 $this->_blSeparateNumbering = $blSeparateNumbering;
1826 $sQ =
'select oxorder.oxpaymenttype from oxorder where oxorder.oxshopid="'.$this->getConfig()->getShopId().
'" and oxorder.oxuserid='.$oDb->quote( $sUserId ).
' order by oxorder.oxorderdate desc ';
1827 $sLastPaymentId = $oDb->getOne( $sQ,
false,
false );
1828 return $sLastPaymentId;
1842 if ( count( $aOrderArticles ) > 0 ) {
1845 foreach ( $aOrderArticles as $oOrderArticle ) {
1846 $oBasket->addOrderArticleToBasket( $oOrderArticle );
1862 if ( count($aArticles ) > 0 ) {
1865 foreach ( $aArticles as $oArticle ) {
1866 $aSel = isset( $oArticle->oxorderarticles__oxselvariant ) ? $oArticle->oxorderarticles__oxselvariant->value : null;
1867 $aPersParam = isset( $oArticle->oxorderarticles__oxpersparam ) ? $oArticle->getPersParams() : null;
1868 $oBasket->addToBasket( $oArticle->oxorderarticles__oxartid->value,
1869 $oArticle->oxorderarticles__oxamount->value,
1870 $aSel, $aPersParam );
1882 $oCur = $this->
getConfig()->getActShopCurrencyObject();
1883 return number_format( (
double)$this->oxorder__oxtotalordersum->value, $oCur->decimal,
'.',
'');
1896 if ($this->oxorder__oxartvat1->value) {
1897 $aVats[$this->oxorder__oxartvat1->value] = $this->oxorder__oxartvatprice1->value;
1899 if ($this->oxorder__oxartvat2->value) {
1900 $aVats[$this->oxorder__oxartvat2->value] = $this->oxorder__oxartvatprice2->value;
1903 if ( $blFormatCurrency ) {
1905 $oCur = $this->
getConfig()->getActShopCurrencyObject();
1906 foreach ( $aVats as $sKey => $dVat ) {
1907 $aVats[$sKey] = $oLang->formatCurrency( $dVat, $oCur );
1920 if ( !$this->oxorder__oxbillcountry->value ) {
1921 $this->oxorder__oxbillcountry =
new oxField($this->
_getCountryTitle( $this->oxorder__oxbillcountryid->value ));
1923 return $this->oxorder__oxbillcountry;
1933 if ( !$this->oxorder__oxdelcountry->value ) {
1936 return $this->oxorder__oxdelcountry;
1947 $this->_blReloadDelivery = $blReload;
1959 $this->_blReloadDiscount = $blReload;
1969 $this->oxorder__oxstorno =
new oxField( 1 );
1970 if ( $this->
save() ) {
1977 $oOrderArticle->cancelOrderArticle();
1990 if ( $this->_oOrderCurrency === null ) {
1993 $aCurrencies = $this->
getConfig()->getCurrencyArray();
1994 $this->_oOrderCurrency = current( $aCurrencies );
1996 foreach ( $aCurrencies as $oCurr ) {
1997 if ( $oCurr->name == $this->oxorder__oxcurrency->value ) {
1998 $this->_oOrderCurrency = $oCurr;
2020 if ( !$iValidState ) {
2025 if ( !$iValidState ) {
2030 if ( !$iValidState ) {
2035 if ( !$iValidState ) {
2039 return $iValidState;
2051 return $oBasket->isBelowMinOrderPrice() ? self::ORDER_STATE_BELOWMINPRICE : null;
2066 $sDelAddress = $oUser->getEncodedDeliveryAddress();
2070 $sDelAddress .= $oDelAdress->getEncodedDeliveryAddress();
2073 if ( $sDelAddressMD5 != $sDelAddress ) {
2094 if ( $oBasket->getPaymentId() ==
'oxempty') {
2099 $oDelSet =
oxNew(
"oxdeliveryset" );
2100 $sTable = $oDelSet->getViewName();
2102 $sQ =
"select 1 from {$sTable} where {$sTable}.oxid=".
2103 $oDb->quote( $oBasket->getShippingId() ).
" and ".$oDelSet->getSqlActiveSnippet();
2105 if ( !$oDb->getOne( $sQ,
false,
false ) ) {
2123 $oPayment =
oxNew(
"oxpayment" );
2124 $sTable = $oPayment->getViewName();
2126 $sQ =
"select 1 from {$sTable} where {$sTable}.oxid=".
2127 $oDb->quote( $oBasket->getPaymentId() ).
" and ".$oPayment->getSqlActiveSnippet();
2129 if ( !$oDb->getOne( $sQ,
false,
false ) ) {
2144 if ( ( $oTsProtectionCost = $oBasket->
getCosts(
'oxtsprotection' ) ) ) {
2145 $this->oxorder__oxtsprotectcosts =
new oxField($oTsProtectionCost->getBruttoPrice(),
oxField::T_RAW);
2161 $aValues[
'tsProductId'] = $this->oxorder__oxtsprotectid->value;
2162 $aValues[
'amount'] = $oBasket->
getPrice()->getBruttoPrice();
2163 $oCur = $this->
getConfig()->getActShopCurrencyObject();
2164 $aValues[
'currency'] = $oCur->name;
2165 $aValues[
'buyerEmail'] = $this->oxorder__oxbillemail->value;
2166 $aValues[
'shopCustomerID'] = $this->oxorder__oxuserid->value;
2167 $aValues[
'shopOrderID'] = $this->oxorder__oxordernr->value;
2168 $aValues[
'orderDate'] = $this->oxorder__oxorderdate->value;
2172 $oTsProtection =
oxNew(
'oxtsprotection');
2173 $oTsProtection->requestForTsProtection( $aValues, $sPaymentId );
2185 return oxRegistry::getLang()->formatCurrency( $this->oxorder__oxtotalnetsum->value, $this->getOrderCurrency() );
2195 return oxRegistry::getLang()->formatCurrency( $this->oxorder__oxtotalbrutsum->value, $this->getOrderCurrency() );
2205 return oxRegistry::getLang()->formatCurrency( $this->oxorder__oxdelcost->value, $this->getOrderCurrency() );
2215 return oxRegistry::getLang()->formatCurrency( $this->oxorder__oxpaycost->value, $this->getOrderCurrency() );
2225 return oxRegistry::getLang()->formatCurrency( $this->oxorder__oxwrapcost->value, $this->getOrderCurrency() );
2235 return oxRegistry::getLang()->formatCurrency( $this->oxorder__oxgiftcardcost->value, $this->getOrderCurrency() );
2245 return oxRegistry::getLang()->formatCurrency( $this->oxorder__oxvoucherdiscount->value, $this->getOrderCurrency() );
2255 return oxRegistry::getLang()->formatCurrency( $this->oxorder__oxdiscount->value, $this->getOrderCurrency() );
2265 return oxRegistry::getLang()->formatCurrency( $this->oxorder__oxtotalordersum->value, $this->getOrderCurrency() );
2275 if ( $this->_sShipTrackUrl === null && $this->oxorder__oxtrackcode->value ) {
2276 $this->_sShipTrackUrl =
"http://www.dpd.de/cgi-bin/delistrack?typ=1&lang=de&pknr=".$this->oxorder__oxtrackcode->value;
2279 return $this->_sShipTrackUrl;