src/ShopDhlPackstationBundle/pkgShop/objects/db/TShopOrderStep/TPkgShopDhlPackstation_ShopStepUserDataV2.class.php
public function ChangeShippingAddressIsPackstationState()
    {
        $this->SetPreventProcessStepMethodFromExecuting(true);

        $bIsDhlPackstation = false;
        $aShipping = $this->GetShippingAddressData();
        if (is_array($aShipping) && array_key_exists('is_dhl_packstation', $aShipping)) {
            $bIsDhlPackstation = ('1' == $aShipping['is_dhl_packstation']) ? (true) : (false);
        }

        $sShippingAdrId = '';
        if (is_array($aShipping) && array_key_exists('id', $aShipping)) {
            $sShippingAdrId = $aShipping['id'];
        }

        $oUser = TdbDataExtranetUser::GetInstance();
        if (!empty($sShippingAdrId)) {
            $oAdr = TdbDataExtranetUserAddress::GetNewInstance();
            if ($oAdr->LoadFromFields(array('data_extranet_user_id' => $oUser->id, 'id' => $sShippingAdrId))) {
                $oAdr->SetIsDhlPackstation($bIsDhlPackstation);
                $this->SetShippingAddressData($oAdr->sqlData);
                $oUser->GetShippingAddress(true);
            }
        } else {
            $oAdr = TdbDataExtranetUserAddress::GetNewInstance();
            $oAdr->LoadFromRowProtected($aShipping);
            $oAdr->SetIsDhlPackstation($bIsDhlPackstation);
            $this->SetShippingAddressData($oAdr->sqlData);
            $oUser->GetShippingAddress(true, true);
        }

        if ($bIsDhlPackstation) {
            $bChangedBillingAddress = false;
            if ('0' != $this->GetShipToBillingAddress()) {
                $this->SetShipToBillingAddress('0');
                $bChangedBillingAddress = true;
            }
            // if the shipping address is also the billing address, then we need to change the billing address
            $sBillingAdrId = '';
            $aBilling = $this->GetBillingAddressData();
            if (is_array($aBilling) && array_key_exists('id', $aBilling)) {
                $sBillingAdrId = $aBilling['id'];
            }
            if (!empty($sBillingAdrId) && !empty($aShipping) && 0 == strcmp($sBillingAdrId, $sShippingAdrId)) {
                $bChangedBillingAddress = true;
                $aNewBilling = array('selectedAddressId' => $this->GetAnotherAddressFromUser($sBillingAdrId, TdbDataExtranetUserAddress::FORM_DATA_NAME_BILLING));
                $this->SetBillingAddressData($aNewBilling);
            }

            if ($bChangedBillingAddress) {
                $oMsgManager = TCMSMessageManager::GetInstance();
                $oMsgManager->AddMessage(TdbDataExtranetUserAddress::FORM_DATA_NAME_BILLING, 'PkgShopDhlPackstation-ERROR-BILLING-MAY-NOT-BE-PACKSTATION');
            }
        }
    }
public function ChangeShippingAddressIsPackstationState()
    {
        $this->SetPreventProcessStepMethodFromExecuting(true);

        $bIsDhlPackstation = false;
        $aShipping = $this->GetShippingAddressData();
        if (is_array($aShipping) && array_key_exists('is_dhl_packstation', $aShipping)) {
            $bIsDhlPackstation = ('1' == $aShipping['is_dhl_packstation']) ? (true) : (false);
        }

        $sShippingAdrId = '';
        if (is_array($aShipping) && array_key_exists('id', $aShipping)) {
            $sShippingAdrId = $aShipping['id'];
        }

        $oUser = TdbDataExtranetUser::GetInstance();
        if (!empty($sShippingAdrId)) {
            $oAdr = TdbDataExtranetUserAddress::GetNewInstance();
            if ($oAdr->LoadFromFields(array('data_extranet_user_id' => $oUser->id, 'id' => $sShippingAdrId))) {
                $oAdr->SetIsDhlPackstation($bIsDhlPackstation);
                $this->SetShippingAddressData($oAdr->sqlData);
                $oUser->GetShippingAddress(true);
            }
        } else {
            $oAdr = TdbDataExtranetUserAddress::GetNewInstance();
            $oAdr->LoadFromRowProtected($aShipping);
            $oAdr->SetIsDhlPackstation($bIsDhlPackstation);
            $this->SetShippingAddressData($oAdr->sqlData);
            $oUser->GetShippingAddress(true, true);
        }

        if ($bIsDhlPackstation) {
            $bChangedBillingAddress = false;
            if ('0' != $this->GetShipToBillingAddress()) {
                $this->SetShipToBillingAddress('0');
                $bChangedBillingAddress = true;
            }
            // if the shipping address is also the billing address, then we need to change the billing address
            $sBillingAdrId = '';
            $aBilling = $this->GetBillingAddressData();
            if (is_array($aBilling) && array_key_exists('id', $aBilling)) {
                $sBillingAdrId = $aBilling['id'];
            }
            if (!empty($sBillingAdrId) && !empty($aShipping) && 0 == strcmp($sBillingAdrId, $sShippingAdrId)) {
                $bChangedBillingAddress = true;
                $aNewBilling = array('selectedAddressId' => $this->GetAnotherAddressFromUser($sBillingAdrId, TdbDataExtranetUserAddress::FORM_DATA_NAME_BILLING));
                $this->SetBillingAddressData($aNewBilling);
            }

            if ($bChangedBillingAddress) {
                $oMsgManager = TCMSMessageManager::GetInstance();
                $oMsgManager->AddMessage(TdbDataExtranetUserAddress::FORM_DATA_NAME_BILLING, 'PkgShopDhlPackstation-ERROR-BILLING-MAY-NOT-BE-PACKSTATION');
            }
        }
    }
public function ChangeShippingAddressIsPackstationState ( ) { $ this -> SetPreventProcessStepMethodFromExecuting ( true ) ; $ bIsDhlPackstation = false ; $ aShipping = $ this -> GetShippingAddressData ( ) ; if ( is_array ( $ aShipping ) && array_key_exists ( 'is_dhl_packstation' , $ aShipping ) ) { $ bIsDhlPackstation = ( '1' == $ aShipping [ 'is_dhl_packstation' ] ) ? ( true ) : ( false ) ; } $ sShippingAdrId = '' ; if ( is_array ( $ aShipping ) && array_key_exists ( 'id' , $ aShipping ) ) { $ sShippingAdrId = $ aShipping [ 'id' ] ; } $ oUser = TdbDataExtranetUser :: GetInstance ( ) ; if ( ! empty ( $ sShippingAdrId ) ) { $ oAdr = TdbDataExtranetUserAddress :: GetNewInstance ( ) ; if ( $ oAdr -> LoadFromFields ( array ( 'data_extranet_user_id' => $ oUser -> id , 'id' => $ sShippingAdrId ) ) ) { $ oAdr -> SetIsDhlPackstation ( $ bIsDhlPackstation ) ; $ this -> SetShippingAddressData ( $ oAdr -> sqlData ) ; $ oUser -> GetShippingAddress ( true ) ; } } else { $ oAdr = TdbDataExtranetUserAddress :: GetNewInstance ( ) ; $ oAdr -> LoadFromRowProtected ( $ aShipping ) ; $ oAdr -> SetIsDhlPackstation ( $ bIsDhlPackstation ) ; $ this -> SetShippingAddressData ( $ oAdr -> sqlData ) ; $ oUser -> GetShippingAddress ( true , true ) ; } if ( $ bIsDhlPackstation ) { $ bChangedBillingAddress = false ; if ( '0' != $ this -> GetShipToBillingAddress ( ) ) { $ this -> SetShipToBillingAddress ( '0' ) ; $ bChangedBillingAddress = true ; } // if the shipping address is also the billing address, then we need to change the billing address $ sBillingAdrId = '' ; $ aBilling = $ this -> GetBillingAddressData ( ) ; if ( is_array ( $ aBilling ) && array_key_exists ( 'id' , $ aBilling ) ) { $ sBillingAdrId = $ aBilling [ 'id' ] ; } if ( ! empty ( $ sBillingAdrId ) && ! empty ( $ aShipping ) && 0 == strcmp ( $ sBillingAdrId , $ sShippingAdrId ) ) { $ bChangedBillingAddress = true ; $ aNewBilling = array ( 'selectedAddressId' => $ this -> GetAnotherAddressFromUser ( $ sBillingAdrId , TdbDataExtranetUserAddress :: FORM_DATA_NAME_BILLING ) ) ; $ this -> SetBillingAddressData ( $ aNewBilling ) ; } if ( $ bChangedBillingAddress ) { $ oMsgManager = TCMSMessageManager :: GetInstance ( ) ; $ oMsgManager -> AddMessage ( TdbDataExtranetUserAddress :: FORM_DATA_NAME_BILLING , 'PkgShopDhlPackstation-ERROR-BILLING-MAY-NOT-BE-PACKSTATION' ) ; } } }
switch the current shipping address from being a packstation address to a normal address and back.
switch the current shipping address from being a packstation address to a normal address and back .