74 if (is_array($sHomeCountry)) {
75 $this->_sHomeCountry =
current($sHomeCountry);
77 $this->_sHomeCountry = $sHomeCountry;
95 protected function _getList($oUser = null, $sCountryId = null, $sDelSet = null)
98 if ($oUser === null) {
105 $sUserId = $oUser ? $oUser->getId() :
'';
110 $sCountryId = $oUser->getActiveCountry();
116 if (($sUserId . $sCountryId . $sDelSet) !== $this->_sUserId) {
119 $this->_sUserId = $sUserId . $sCountryId . $sDelSet;
140 $sTable = getViewName(
'oxdelivery');
141 $sQ =
"select $sTable.* from ( select $sTable.* from $sTable left join oxdel2delset on oxdel2delset.oxdelid=$sTable.oxid ";
142 $sQ .=
"where " . $this->
getBaseObject()->getSqlActiveSnippet() .
" and oxdel2delset.oxdelsetid = " . $oDb->quote($sDelSet) .
" ";
152 $sUserId = $oUser->getId();
155 $aGroupIds = $oUser->getUserGroups();
159 if (
count($aGroupIds)) {
160 foreach ($aGroupIds as $oGroup) {
161 $aIds[] = $oGroup->getId();
165 $sUserTable = getViewName(
'oxuser');
166 $sGroupTable = getViewName(
'oxgroups');
167 $sCountryTable = getViewName(
'oxcountry');
169 $sCountrySql = $sCountryId ?
"EXISTS(select oxobject2delivery.oxid from oxobject2delivery where oxobject2delivery.oxdeliveryid=$sTable.OXID and oxobject2delivery.oxtype='oxcountry' and oxobject2delivery.OXOBJECTID=" . $oDb->quote($sCountryId) .
")" :
'0';
170 $sUserSql = $sUserId ?
"EXISTS(select oxobject2delivery.oxid from oxobject2delivery where oxobject2delivery.oxdeliveryid=$sTable.OXID and oxobject2delivery.oxtype='oxuser' and oxobject2delivery.OXOBJECTID=" . $oDb->quote($sUserId) .
")" :
'0';
171 $sGroupSql =
count($aIds) ?
"EXISTS(select oxobject2delivery.oxid from oxobject2delivery where oxobject2delivery.oxdeliveryid=$sTable.OXID and oxobject2delivery.oxtype='oxgroups' and oxobject2delivery.OXOBJECTID in (" . implode(
', ',
oxDb::getInstance()->quoteArray($aIds)) .
") )" :
'0';
173 $sQ .=
") as $sTable where (
175 if(EXISTS(select 1 from oxobject2delivery, $sCountryTable where $sCountryTable.oxid=oxobject2delivery.oxobjectid and oxobject2delivery.oxdeliveryid=$sTable.OXID and oxobject2delivery.oxtype='oxcountry' LIMIT 1),
178 if(EXISTS(select 1 from oxobject2delivery, $sUserTable where $sUserTable.oxid=oxobject2delivery.oxobjectid and oxobject2delivery.oxdeliveryid=$sTable.OXID and oxobject2delivery.oxtype='oxuser' LIMIT 1),
181 if(EXISTS(select 1 from oxobject2delivery, $sGroupTable where $sGroupTable.oxid=oxobject2delivery.oxobjectid and oxobject2delivery.oxdeliveryid=$sTable.OXID and oxobject2delivery.oxtype='oxgroups' LIMIT 1),
186 $sQ .=
" order by $sTable.oxsort ";
222 public function getDeliveryList($oBasket, $oUser = null, $sDelCountry = null, $sDelSet = null)
225 $aSkipDeliveries = array();
226 $aDelSetList =
oxRegistry::get(
"oxDeliverySetList")->getDeliverySetList($oUser, $sDelCountry, $sDelSet);
229 foreach ($aDelSetList as $sDeliverySetId => $oDeliverySet) {
232 $aDeliveries = $this->
_getList($oUser, $sDelCountry, $sDeliverySetId);
235 foreach ($aDeliveries as $sDeliveryId => $oDelivery) {
238 if (in_array($sDeliveryId, $aSkipDeliveries)) {
242 $aSkipDeliveries[] = $sDeliveryId;
244 if ($oDelivery->isForBasket($oBasket)) {
247 $this->_aDeliveries[$sDeliveryId] = $aDeliveries[$sDeliveryId];
251 array_pop($aSkipDeliveries);
254 if ($oDelivery->oxdelivery__oxfinalize->value) {
262 if ($this->_blCollectFittingDeliveriesSets) {
264 $aFittingDelSets[$sDeliverySetId] = $oDeliverySet;
275 if ($this->_blCollectFittingDeliveriesSets &&
count($aFittingDelSets)) {
278 $this->_blCollectFittingDeliveriesSets =
false;
284 return $aFittingDelSets;
301 public function hasDeliveries($oBasket, $oUser, $sDelCountry, $sDeliverySetId)
306 $this->
_getList($oUser, $sDelCountry, $sDeliverySetId);
307 foreach ($this as $oDelivery) {
308 if ($oDelivery->isForBasket($oBasket)) {
326 if (!$this->_oUser) {
340 $this->_oUser = $oUser;
351 $this->_blCollectFittingDeliveriesSets = $blCollectFittingDeliveriesSets;
362 $dPrice = $oDb->quote($oProduct->getPrice()->getBruttoPrice());
363 $dSize = $oDb->quote($oProduct->getSize());
364 $dWeight = $oDb->quote($oProduct->getWeight());
366 $sTable = getViewName(
'oxdelivery');
368 $sQ =
"select $sTable.* from $sTable";
369 $sQ .=
" where " . $this->
getBaseObject()->getSqlActiveSnippet();
370 $sQ .=
" and ($sTable.oxdeltype != 'a' || ( $sTable.oxparam <= 1 && $sTable.oxparamend >= 1))";
372 $sQ .=
" and ($sTable.oxdeltype != 'p' || ( $sTable.oxparam <= $dPrice && $sTable.oxparamend >= $dPrice))";
375 $sQ .=
" and ($sTable.oxdeltype != 's' || ( $sTable.oxparam <= $dSize && $sTable.oxparamend >= $dSize))";
378 $sQ .=
" and ($sTable.oxdeltype != 'w' || ( $sTable.oxparam <= $dWeight && $sTable.oxparamend >= $dWeight))";