60 public function __construct( $sObjectsInListName =
'oxdelivery')
89 if ( is_array( $sHomeCountry ) ) {
90 $this->_sHomeCountry =
current( $sHomeCountry );
92 $this->_sHomeCountry = $sHomeCountry;
110 protected function _getList( $oUser = null, $sCountryId = null, $sDelSet = null )
113 if ( $oUser === null ) {
120 $sUserId = $oUser ? $oUser->getId() :
'';
123 if ( !$sCountryId ) {
125 $sCountryId = $oUser->getActiveCountry();
131 if ( ( $sUserId.$sCountryId.$sDelSet ) !== $this->_sUserId ) {
134 $this->_sUserId = $sUserId.$sCountryId.$sDelSet;
155 $sTable = getViewName(
'oxdelivery' );
156 $sQ =
"select $sTable.* from ( select $sTable.* from $sTable left join oxdel2delset on oxdel2delset.oxdelid=$sTable.oxid ";
157 $sQ .=
"where ".$this->getBaseObject()->getSqlActiveSnippet().
" and oxdel2delset.oxdelsetid = ".$oDb->quote($sDelSet).
" ";
167 $sUserId = $oUser->getId();
170 $aGroupIds = $oUser->getUserGroups();
174 if (
count( $aGroupIds ) ) {
175 foreach ( $aGroupIds as $oGroup ) {
176 $aIds[] = $oGroup->getId();
180 $sUserTable = getViewName(
'oxuser' );
181 $sGroupTable = getViewName(
'oxgroups' );
182 $sCountryTable = getViewName(
'oxcountry' );
184 $sCountrySql = $sCountryId ?
"EXISTS(select oxobject2delivery.oxid from oxobject2delivery where oxobject2delivery.oxdeliveryid=$sTable.OXID and oxobject2delivery.oxtype='oxcountry' and oxobject2delivery.OXOBJECTID=".$oDb->quote($sCountryId).
")" :
'0';
185 $sUserSql = $sUserId ?
"EXISTS(select oxobject2delivery.oxid from oxobject2delivery where oxobject2delivery.oxdeliveryid=$sTable.OXID and oxobject2delivery.oxtype='oxuser' and oxobject2delivery.OXOBJECTID=".$oDb->quote($sUserId).
")" :
'0';
186 $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';
188 $sQ .=
") as $sTable where (
190 if(EXISTS(select 1 from oxobject2delivery, $sCountryTable where $sCountryTable.oxid=oxobject2delivery.oxobjectid and oxobject2delivery.oxdeliveryid=$sTable.OXID and oxobject2delivery.oxtype='oxcountry' LIMIT 1),
193 if(EXISTS(select 1 from oxobject2delivery, $sUserTable where $sUserTable.oxid=oxobject2delivery.oxobjectid and oxobject2delivery.oxdeliveryid=$sTable.OXID and oxobject2delivery.oxtype='oxuser' LIMIT 1),
196 if(EXISTS(select 1 from oxobject2delivery, $sGroupTable where $sGroupTable.oxid=oxobject2delivery.oxobjectid and oxobject2delivery.oxdeliveryid=$sTable.OXID and oxobject2delivery.oxtype='oxgroups' LIMIT 1),
201 $sQ .=
" order by $sTable.oxsort ";
237 public function getDeliveryList( $oBasket, $oUser = null, $sDelCountry = null, $sDelSet = null )
240 $aSkipDeliveries = array();
241 $aDelSetList =
oxRegistry::get(
"oxDeliverySetList")->getDeliverySetList( $oUser, $sDelCountry, $sDelSet );
244 foreach ( $aDelSetList as $sDeliverySetId => $oDeliverySet ) {
247 $aDeliveries = $this->
_getList( $oUser, $sDelCountry, $sDeliverySetId );
250 foreach ( $aDeliveries as $sDeliveryId => $oDelivery ) {
253 if ( in_array( $sDeliveryId, $aSkipDeliveries ) ) {
257 $aSkipDeliveries[] = $sDeliveryId;
259 if ( $oDelivery->isForBasket( $oBasket ) ) {
262 $this->_aDeliveries[$sDeliveryId] = $aDeliveries[$sDeliveryId];
266 array_pop( $aSkipDeliveries );
269 if ( $oDelivery->oxdelivery__oxfinalize->value ) {
277 if ( $this->_blCollectFittingDeliveriesSets ) {
279 $aFittingDelSets[$sDeliverySetId] = $oDeliverySet;
289 if ( $this->_blCollectFittingDeliveriesSets &&
count($aFittingDelSets) ) {
292 $this->_blCollectFittingDeliveriesSets =
false;
298 return $aFittingDelSets;
315 public function hasDeliveries( $oBasket, $oUser, $sDelCountry, $sDeliverySetId )
320 $this->
_getList( $oUser, $sDelCountry, $sDeliverySetId );
321 foreach ( $this as $oDelivery ) {
322 if ( $oDelivery->isForBasket( $oBasket ) ) {
339 if ( !$this->_oUser ) {
355 $this->_oUser = $oUser;
368 $this->_blCollectFittingDeliveriesSets = $blCollectFittingDeliveriesSets;
381 $dPrice = $oDb->quote($oProduct->getPrice()->getBruttoPrice());
382 $dSize = $oDb->quote($oProduct->oxarticles__oxlength->value * $oProduct->oxarticles__oxwidth->value * $oProduct->oxarticles__oxheight->value);
383 $dWeight = $oProduct->oxarticles__oxweight->value;
384 $sTable = getViewName(
'oxdelivery' );
385 $sQ =
"select $sTable.* from $sTable";
386 $sQ .=
" where ".$this->getBaseObject()->getSqlActiveSnippet();
387 $sQ .=
" and ($sTable.oxdeltype != 'a' || ( $sTable.oxparam <= 1 && $sTable.oxparamend >= 1))";
389 $sQ .=
" and ($sTable.oxdeltype != 'p' || ( $sTable.oxparam <= $dPrice && $sTable.oxparamend >= $dPrice))";
392 $sQ .=
" and ($sTable.oxdeltype != 's' || ( $sTable.oxparam <= $dSize && $sTable.oxparamend >= $dSize))";
395 $sQ .=
" and ($sTable.oxdeltype != 'w' || ( $sTable.oxparam <= $dWeight && $sTable.oxparamend >= $dWeight))";