56 if (is_array($sHomeCountry)) {
57 $this->_sHomeCountry =
current($sHomeCountry);
59 $this->_sHomeCountry = $sHomeCountry;
76 protected function _getList($oUser = null, $sCountryId = null)
79 if ($oUser === null) {
86 $sUserId = $oUser ? $oUser->getId() :
'';
88 if ($sUserId !== $this->_sUserId || $sCountryId !== $this->_sCountryId) {
94 $sCountryId = $oUser->getActiveCountry();
101 $this->_sUserId = $sUserId;
102 $this->_sCountryId = $sCountryId;
121 $sTable = getViewName(
'oxdeliveryset');
122 $sQ =
"select $sTable.* from $sTable ";
123 $sQ .=
"where " . $this->
getBaseObject()->getSqlActiveSnippet() .
' ';
133 $sUserId = $oUser->getId();
136 $aGroupIds = $oUser->getUserGroups();
140 if (
count($aGroupIds)) {
141 foreach ($aGroupIds as $oGroup) {
142 $aIds[] = $oGroup->getId();
146 $sUserTable = getViewName(
'oxuser');
147 $sGroupTable = getViewName(
'oxgroups');
148 $sCountryTable = getViewName(
'oxcountry');
152 $sCountrySql = $sCountryId ?
"EXISTS(select oxobject2delivery.oxid from oxobject2delivery where oxobject2delivery.oxdeliveryid=$sTable.OXID and oxobject2delivery.oxtype='oxdelset' and oxobject2delivery.OXOBJECTID=" . $oDb->quote($sCountryId) .
")" :
'0';
153 $sUserSql = $sUserId ?
"EXISTS(select oxobject2delivery.oxid from oxobject2delivery where oxobject2delivery.oxdeliveryid=$sTable.OXID and oxobject2delivery.oxtype='oxdelsetu' and oxobject2delivery.OXOBJECTID=" . $oDb->quote($sUserId) .
")" :
'0';
154 $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';
158 if(EXISTS(select 1 from oxobject2delivery, $sCountryTable where $sCountryTable.oxid=oxobject2delivery.oxobjectid and oxobject2delivery.oxdeliveryid=$sTable.OXID and oxobject2delivery.oxtype='oxdelset' LIMIT 1),
161 if(EXISTS(select 1 from oxobject2delivery, $sUserTable where $sUserTable.oxid=oxobject2delivery.oxobjectid and oxobject2delivery.oxdeliveryid=$sTable.OXID and oxobject2delivery.oxtype='oxdelsetu' LIMIT 1),
164 if(EXISTS(select 1 from oxobject2delivery, $sGroupTable where $sGroupTable.oxid=oxobject2delivery.oxobjectid and oxobject2delivery.oxdeliveryid=$sTable.OXID and oxobject2delivery.oxtype='oxdelsetg' LIMIT 1),
170 $sQ .=
" order by $sTable.oxpos";
186 $this->
_getList($oUser, $sCountryId);
190 if ($sDelSet && isset($aList[$sDelSet])) {
193 $oDelSet = $aList[$sDelSet];
194 unset($aList[$sDelSet]);
196 $aList = array_merge(array($sDelSet => $oDelSet), $aList);
220 $aActPaymentList = array();
226 $this->
_getList($oUser, $oUser->getActiveCountry());
229 if ($this->
count()) {
232 if ($sShipSet && !isset($this->_aArray[$sShipSet])) {
239 $oCur = $this->
getConfig()->getActShopCurrencyObject();
240 $dBasketPrice = $oBasket->getPriceForPayment() / $oCur->rate;
243 foreach ($this as $sShipSetId => $oShipSet) {
245 $aPaymentList = $oPayList->getPaymentList($sShipSetId, $dBasketPrice, $oUser);
246 if (
count($aPaymentList)) {
249 if ($oDelList->hasDeliveries($oBasket, $oUser, $oUser->getActiveCountry(), $sShipSetId)) {
250 $aActSets[$sShipSetId] = $oShipSet;
252 if (!$sShipSet || ($sShipSetId == $sShipSet)) {
253 $sActShipSet = $sShipSet = $sShipSetId;
254 $aActPaymentList = $aPaymentList;
255 $oShipSet->blSelected =
true;
262 return array($aActSets, $sActShipSet, $aActPaymentList);
272 if (!$this->_oUser) {
286 $this->_oUser = $oUser;
295 $sTable = getViewName(
'oxdeliveryset');
296 $sSubSql =
"SELECT * FROM oxobject2delivery WHERE oxobject2delivery.OXDELIVERYID = $sTable.OXID AND oxobject2delivery.OXTYPE = 'rdfadeliveryset'";
297 $this->
selectString(
"SELECT $sTable.* FROM $sTable WHERE NOT EXISTS($sSubSql) AND $sTable.OXACTIVE = 1");
308 $sTable = getViewName(
'oxdeliveryset');
311 $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";
315 $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() .
" ";