49 public function __construct( $sObjectsInListName =
'oxdeliveryset')
64 if ( is_array( $sHomeCountry ) ) {
65 $this->_sHomeCountry =
current( $sHomeCountry );
67 $this->_sHomeCountry = $sHomeCountry;
97 protected function _getList( $oUser = null, $sCountryId = null )
100 if ( $oUser === null ) {
107 $sUserId = $oUser ? $oUser->getId() :
'';
109 if ( $sUserId !== $this->_sUserId || $sCountryId !== $this->_sCountryId) {
112 if ( !$sCountryId ) {
115 $sCountryId = $oUser->getActiveCountry();
122 $this->_sUserId = $sUserId;
123 $this->_sCountryId = $sCountryId;
142 $sTable = getViewName(
'oxdeliveryset' );
143 $sQ =
"select $sTable.* from $sTable ";
144 $sQ .=
"where ".$this->getBaseObject()->getSqlActiveSnippet().
' ';
154 $sUserId = $oUser->getId();
157 $aGroupIds = $oUser->getUserGroups();
161 if (
count( $aGroupIds ) ) {
162 foreach ( $aGroupIds as $oGroup ) {
163 $aIds[] = $oGroup->getId();
167 $sUserTable = getViewName(
'oxuser' );
168 $sGroupTable = getViewName(
'oxgroups' );
169 $sCountryTable = getViewName(
'oxcountry' );
173 $sCountrySql = $sCountryId?
"EXISTS(select oxobject2delivery.oxid from oxobject2delivery where oxobject2delivery.oxdeliveryid=$sTable.OXID and oxobject2delivery.oxtype='oxdelset' and oxobject2delivery.OXOBJECTID=".$oDb->quote($sCountryId).
")":
'0';
174 $sUserSql = $sUserId ?
"EXISTS(select oxobject2delivery.oxid from oxobject2delivery where oxobject2delivery.oxdeliveryid=$sTable.OXID and oxobject2delivery.oxtype='oxdelsetu' and oxobject2delivery.OXOBJECTID=".$oDb->quote($sUserId).
")":
'0';
175 $sGroupSql =
count( $aIds ) ?
"EXISTS(select oxobject2delivery.oxid from oxobject2delivery where oxobject2delivery.oxdeliveryid=$sTable.OXID and oxobject2delivery.oxtype='oxdelsetg' and oxobject2delivery.OXOBJECTID in (".implode(
', ',
oxDb::getInstance()->quoteArray($aIds) ).
") )":
'0';
179 if(EXISTS(select 1 from oxobject2delivery, $sCountryTable where $sCountryTable.oxid=oxobject2delivery.oxobjectid and oxobject2delivery.oxdeliveryid=$sTable.OXID and oxobject2delivery.oxtype='oxdelset' LIMIT 1),
182 if(EXISTS(select 1 from oxobject2delivery, $sUserTable where $sUserTable.oxid=oxobject2delivery.oxobjectid and oxobject2delivery.oxdeliveryid=$sTable.OXID and oxobject2delivery.oxtype='oxdelsetu' LIMIT 1),
185 if(EXISTS(select 1 from oxobject2delivery, $sGroupTable where $sGroupTable.oxid=oxobject2delivery.oxobjectid and oxobject2delivery.oxdeliveryid=$sTable.OXID and oxobject2delivery.oxtype='oxdelsetg' LIMIT 1),
191 $sQ .=
" order by $sTable.oxpos";
207 $this->
_getList( $oUser, $sCountryId );
211 if ( $sDelSet && isset( $aList[$sDelSet] ) ) {
214 $oDelSet = $aList[$sDelSet];
215 unset( $aList[$sDelSet] );
217 $aList = array_merge( array( $sDelSet => $oDelSet ), $aList );
240 $aActPaymentList = array();
246 $this->
_getList( $oUser, $oUser->getActiveCountry() );
249 if ( $this->
count() ) {
252 if ( $sShipSet && !isset( $this->_aArray[$sShipSet] ) ) {
259 $oCur = $this->
getConfig()->getActShopCurrencyObject();
260 $dBasketPrice = $oBasket->getPriceForPayment() / $oCur->rate;
263 foreach ( $this as $sShipSetId => $oShipSet ) {
265 $aPaymentList = $oPayList->getPaymentList( $sShipSetId, $dBasketPrice, $oUser );
266 if (
count( $aPaymentList ) ) {
269 if ( $oDelList->hasDeliveries( $oBasket, $oUser, $oUser->getActiveCountry(), $sShipSetId ) ) {
270 $aActSets[$sShipSetId] = $oShipSet;
272 if ( !$sShipSet || ( $sShipSetId == $sShipSet ) ) {
273 $sActShipSet = $sShipSet = $sShipSetId;
274 $aActPaymentList = $aPaymentList;
275 $oShipSet->blSelected =
true;
282 return array( $aActSets, $sActShipSet, $aActPaymentList );
292 if ( !$this->_oUser ) {
308 $this->_oUser = $oUser;
319 $sTable = getViewName(
'oxdeliveryset' );
320 $sSubSql =
"SELECT * FROM oxobject2delivery WHERE oxobject2delivery.OXDELIVERYID = $sTable.OXID AND oxobject2delivery.OXTYPE = 'rdfadeliveryset'";
321 $this->
selectString(
"SELECT $sTable.* FROM $sTable WHERE NOT EXISTS($sSubSql) AND $sTable.OXACTIVE = 1" );
334 $sTable = getViewName(
'oxdeliveryset' );
337 $sSubSql =
"( select $sTable.* from $sTable left join oxdel2delset on oxdel2delset.oxdelsetid=$sTable.oxid where ".$this->getBaseObject()->getSqlActiveSnippet().
" and oxdel2delset.oxdelid = ".$oDb->quote($sDelId).
" ) as $sTable";
341 $sQ =
"select $sTable.*, oxobject2delivery.oxobjectid from $sSubSql left join (select oxobject2delivery.* from oxobject2delivery where oxobject2delivery.oxtype = 'rdfadeliveryset' ) as oxobject2delivery on oxobject2delivery.oxdeliveryid=$sTable.oxid where ".$this->getBaseObject()->getSqlActiveSnippet().
" ";