Go to the documentation of this file.00001 <?php
00002
00008 class Order_Address extends oxAdminDetails
00009 {
00017 public function render()
00018 {
00019 parent::render();
00020
00021 $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
00022 if ( $soxId != "-1" && isset( $soxId)) {
00023
00024 $oOrder = oxNew( "oxorder" );
00025 $oOrder->load( $soxId);
00026
00027 $this->_aViewData["edit"] = $oOrder;
00028 }
00029
00030 $oCountryList = oxNew( "oxCountryList" );
00031 $oCountryList->loadActiveCountries( oxRegistry::getLang()->getObjectTplLanguage() );
00032
00033 $this->_aViewData["countrylist"] = $oCountryList;
00034
00035 return "order_address.tpl";
00036 }
00037
00048 protected function _processAddress( $aData, $sTypeToProcess, $aIgnore )
00049 {
00050
00051 $blEmpty = true;
00052
00053
00054 $aFields = array();
00055
00056 foreach ( $aData as $sName => $sValue ) {
00057
00058
00059 if ( strpos( $sName, $sTypeToProcess ) !== false ) {
00060
00061
00062 $aFields[] = $sName;
00063
00064
00065 if ( !in_array( $sName, $aIgnore ) && $sValue ) {
00066
00067
00068 $blEmpty = false;
00069 break;
00070 }
00071 }
00072 }
00073
00074
00075 if ( $blEmpty ) {
00076 foreach ( $aFields as $sName ) {
00077 $aData[$sName] = "";
00078 }
00079 }
00080
00081 return $aData;
00082 }
00083
00089 public function save()
00090 {
00091 parent::save();
00092
00093 $soxId = $this->getEditObjectId();
00094 $aParams = (array) oxConfig::getParameter( "editval");
00095
00096
00097 $sShopID = oxSession::getVar( "actshop" );
00098 $aParams['oxorder__oxshopid'] = $sShopID;
00099
00100 $oOrder = oxNew( "oxorder" );
00101 if ( $soxId != "-1") {
00102 $oOrder->load( $soxId );
00103 } else {
00104 $aParams['oxorder__oxid'] = null;
00105 }
00106
00107 $aParams = $this->_processAddress( $aParams, "oxorder__oxdel", array( "oxorder__oxdelsal" ) );
00108 $oOrder->assign( $aParams );
00109 $oOrder->save();
00110
00111
00112 $this->setEditObjectId( $oOrder->getId() );
00113 }
00114 }