Go to the documentation of this file.00001 <?php
00002
00009 class Delivery_Main extends oxAdminDetails
00010 {
00017 public function render()
00018 {
00019 $myConfig = $this->getConfig();
00020
00021 parent::render();
00022
00023 $oLang = oxLang::getInstance();
00024 $iLang = $oLang->getTplLanguage();
00025
00026
00027 unset( $this->_aViewData["sumtype"][2]);
00028
00029
00030 $aDelTypes = array();
00031 $oType = new oxStdClass();
00032 $oType->sType = "a";
00033 $oType->sDesc = $oLang->translateString( "amount", $iLang );
00034 $aDelTypes['a'] = $oType;
00035 $oType = new oxStdClass();
00036 $oType->sType = "s";
00037 $oType->sDesc = $oLang->translateString( "size", $iLang );
00038 $aDelTypes['s'] = $oType;
00039 $oType = new oxStdClass();
00040 $oType->sType = "w";
00041 $oType->sDesc = $oLang->translateString( "weight", $iLang );
00042 $aDelTypes['w'] = $oType;
00043 $oType = new oxStdClass();
00044 $oType->sType = "p";
00045 $oType->sDesc = $oLang->translateString( "price", $iLang );
00046 $aDelTypes['p'] = $oType;
00047
00048 $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
00049 if ( $soxId != "-1" && isset( $soxId)) {
00050
00051 $oDelivery = oxNew( "oxdelivery" );
00052 $oDelivery->loadInLang( $this->_iEditLang, $soxId );
00053
00054 $oOtherLang = $oDelivery->getAvailableInLangs();
00055 if (!isset($oOtherLang[$this->_iEditLang])) {
00056
00057 $oDelivery->loadInLang( key($oOtherLang), $soxId );
00058 }
00059
00060 $this->_aViewData["edit"] = $oDelivery;
00061
00062
00063
00064 $aLang = array_diff ( $oLang->getLanguageNames(), $oOtherLang);
00065 if ( count( $aLang))
00066 $this->_aViewData["posslang"] = $aLang;
00067
00068 foreach ( $oOtherLang as $id => $language) {
00069 $oLang= new oxStdClass();
00070 $oLang->sLangDesc = $language;
00071 $oLang->selected = ($id == $this->_iEditLang);
00072 $this->_aViewData["otherlang"][$id] = clone $oLang;
00073 }
00074
00075
00076 if ( !$oDelivery->oxdelivery__oxdeltype->value)
00077 $oDelivery->oxdelivery__oxdeltype->setValue("a");
00078 $aDelTypes[$oDelivery->oxdelivery__oxdeltype->value]->selected = true;
00079 }
00080
00081 $this->_aViewData["deltypes"] = $aDelTypes;
00082
00083 if ( oxConfig::getParameter("aoc") ) {
00084 $oDeliveryMainAjax = oxNew( 'delivery_main_ajax' );
00085 $this->_aViewData['oxajax'] = $oDeliveryMainAjax->getColumns();
00086
00087 return "popups/delivery_main.tpl";
00088 }
00089 return "delivery_main.tpl";
00090 }
00091
00097 public function save()
00098 {
00099 parent::save();
00100
00101 $soxId = $this->getEditObjectId();
00102 $aParams = oxConfig::getParameter( "editval");
00103
00104
00105 $sShopID = oxSession::getVar( "actshop");
00106 $aParams['oxdelivery__oxshopid'] = $sShopID;
00107
00108 $oDelivery = oxNew( "oxdelivery" );
00109
00110 if ( $soxId != "-1") {
00111 $oDelivery->loadInLang( $this->_iEditLang, $soxId );
00112 } else {
00113 $aParams['oxdelivery__oxid'] = null;
00114 }
00115
00116
00117 if ( !isset( $aParams['oxdelivery__oxactive']))
00118 $aParams['oxdelivery__oxactive'] = 0;
00119 if ( !isset( $aParams['oxdelivery__oxfixed']))
00120 $aParams['oxdelivery__oxfixed'] = 0;
00121 if ( !isset( $aParams['oxdelivery__oxfinalize']))
00122 $aParams['oxdelivery__oxfinalize'] = 0;
00123 if ( !isset( $aParams['oxdelivery__oxsort']))
00124 $aParams['oxdelivery__oxsort'] = 9999;
00125
00126
00127 $oDelivery->setLanguage(0);
00128 $oDelivery->assign( $aParams );
00129 $oDelivery->setLanguage($this->_iEditLang);
00130 $oDelivery = oxUtilsFile::getInstance()->processFiles( $oDelivery );
00131 $oDelivery->save();
00132
00133
00134 $this->setEditObjectId( $oDelivery->getId() );
00135 }
00136
00142 public function saveinnlang()
00143 {
00144 $soxId = $this->getEditObjectId();
00145 $aParams = oxConfig::getParameter( "editval");
00146
00147
00148 $sShopID = oxSession::getVar( "actshop");
00149 $aParams['oxdelivery__oxshopid'] = $sShopID;
00150
00151 $oDelivery = oxNew( "oxdelivery" );
00152
00153 if ( $soxId != "-1") {
00154 $oDelivery->loadInLang( $this->_iEditLang, $soxId );
00155 } else {
00156 $aParams['oxdelivery__oxid'] = null;
00157 }
00158
00159
00160 if ( !isset( $aParams['oxdelivery__oxactive'])) {
00161 $aParams['oxdelivery__oxactive'] = 0;
00162 }
00163 if ( !isset( $aParams['oxdelivery__oxfixed'])) {
00164 $aParams['oxdelivery__oxfixed'] = 0;
00165 }
00166
00167
00168 $oDelivery->setLanguage(0);
00169 $oDelivery->assign( $aParams);
00170 $oDelivery->setLanguage($this->_iEditLang);
00171 $oDelivery = oxUtilsFile::getInstance()->processFiles( $oDelivery );
00172 $oDelivery->save();
00173
00174
00175 $this->setEditObjectId( $oDelivery->getId() );
00176 }
00177 }