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->typ = "a";
00033 $oType->Desc = $oLang->translateString( "amount", $iLang );
00034 $aDelTypes['a'] = $oType;
00035 $oType = new oxStdClass();
00036 $oType->typ = "s";
00037 $oType->Desc = $oLang->translateString( "size", $iLang );
00038 $aDelTypes['s'] = $oType;
00039 $oType = new oxStdClass();
00040 $oType->typ = "w";
00041 $oType->Desc = $oLang->translateString( "weight", $iLang );
00042 $aDelTypes['w'] = $oType;
00043 $oType = new oxStdClass();
00044 $oType->typ = "p";
00045 $oType->Desc = $oLang->translateString( "price", $iLang );
00046 $aDelTypes['p'] = $oType;
00047
00048 $soxId = oxConfig::getParameter( "oxid");
00049
00050 $sSavedID = oxConfig::getParameter( "saved_oxid");
00051 if ( ($soxId == "-1" || !isset( $soxId)) && isset( $sSavedID) ) {
00052 $soxId = $sSavedID;
00053 oxSession::deleteVar( "saved_oxid");
00054 $this->_aViewData["oxid"] = $soxId;
00055
00056 $this->_aViewData["updatelist"] = "1";
00057 }
00058
00059 if ( $soxId != "-1" && isset( $soxId)) {
00060
00061 $oDelivery = oxNew( "oxdelivery" );
00062 $oDelivery->loadInLang( $this->_iEditLang, $soxId );
00063
00064 $oOtherLang = $oDelivery->getAvailableInLangs();
00065 if (!isset($oOtherLang[$this->_iEditLang])) {
00066
00067 $oDelivery->loadInLang( key($oOtherLang), $soxId );
00068 }
00069
00070 $this->_aViewData["edit"] = $oDelivery;
00071
00072
00073
00074 $aLang = array_diff ( $oLang->getLanguageNames(), $oOtherLang);
00075 if ( count( $aLang))
00076 $this->_aViewData["posslang"] = $aLang;
00077
00078 foreach ( $oOtherLang as $id => $language) {
00079 $oLang= new oxStdClass();
00080 $oLang->sLangDesc = $language;
00081 $oLang->selected = ($id == $this->_iEditLang);
00082 $this->_aViewData["otherlang"][$id] = clone $oLang;
00083 }
00084
00085
00086 if ( !$oDelivery->oxdelivery__oxdeltype->value)
00087 $oDelivery->oxdelivery__oxdeltype->setValue("a");
00088 $aDelTypes[$oDelivery->oxdelivery__oxdeltype->value]->selected = true;
00089 }
00090
00091 $this->_aViewData["deltypes"] = $aDelTypes;
00092
00093 if ( oxConfig::getParameter("aoc") ) {
00094
00095 $aColumns = array();
00096 include_once 'inc/'.strtolower(__CLASS__).'.inc.php';
00097 $this->_aViewData['oxajax'] = $aColumns;
00098
00099 return "popups/delivery_main.tpl";
00100 }
00101 return "delivery_main.tpl";
00102 }
00103
00109 public function save()
00110 {
00111
00112 $soxId = oxConfig::getParameter( "oxid");
00113 $aParams = oxConfig::getParameter( "editval");
00114
00115
00116 $sShopID = oxSession::getVar( "actshop");
00117 $aParams['oxdelivery__oxshopid'] = $sShopID;
00118
00119 $oDelivery = oxNew( "oxdelivery" );
00120
00121 if ( $soxId != "-1") {
00122 $oDelivery->loadInLang( $this->_iEditLang, $soxId );
00123 } else {
00124 $aParams['oxdelivery__oxid'] = null;
00125 }
00126
00127
00128 if ( !isset( $aParams['oxdelivery__oxactive']))
00129 $aParams['oxdelivery__oxactive'] = 0;
00130 if ( !isset( $aParams['oxdelivery__oxfixed']))
00131 $aParams['oxdelivery__oxfixed'] = 0;
00132 if ( !isset( $aParams['oxdelivery__oxfinalize']))
00133 $aParams['oxdelivery__oxfinalize'] = 0;
00134 if ( !isset( $aParams['oxdelivery__oxsort']))
00135 $aParams['oxdelivery__oxsort'] = 9999;
00136
00137
00138 $oDelivery->setLanguage(0);
00139 $oDelivery->assign( $aParams );
00140 $oDelivery->setLanguage($this->_iEditLang);
00141 $oDelivery = oxUtilsFile::getInstance()->processFiles( $oDelivery );
00142 $oDelivery->save();
00143 $this->_aViewData["updatelist"] = "1";
00144
00145
00146 if ( $soxId == "-1") {
00147 oxSession::setVar( "saved_oxid", $oDelivery->oxdelivery__oxid->value);
00148 }
00149 }
00150
00156 public function saveinnlang()
00157 {
00158 $soxId = oxConfig::getParameter( "oxid");
00159 $aParams = oxConfig::getParameter( "editval");
00160
00161
00162 $sShopID = oxSession::getVar( "actshop");
00163 $aParams['oxdelivery__oxshopid'] = $sShopID;
00164
00165 $oDelivery = oxNew( "oxdelivery" );
00166
00167 if ( $soxId != "-1") {
00168 $oDelivery->loadInLang( $this->_iEditLang, $soxId );
00169 } else {
00170 $aParams['oxdelivery__oxid'] = null;
00171 }
00172
00173
00174 if ( !isset( $aParams['oxdelivery__oxactive'])) {
00175 $aParams['oxdelivery__oxactive'] = 0;
00176 }
00177 if ( !isset( $aParams['oxdelivery__oxfixed'])) {
00178 $aParams['oxdelivery__oxfixed'] = 0;
00179 }
00180
00181
00182 $oDelivery->setLanguage(0);
00183 $oDelivery->assign( $aParams);
00184 $oDelivery->setLanguage($this->_iEditLang);
00185 $oDelivery = oxUtilsFile::getInstance()->processFiles( $oDelivery );
00186 $oDelivery->save();
00187 $this->_aViewData["updatelist"] = "1";
00188
00189
00190 if ( $soxId == "-1") {
00191 oxSession::setVar( "saved_oxid", $oDelivery->oxdelivery__oxid->value);
00192 }
00193 }
00194 }