00001 <?php
00002
00010 class DeliverySet_Main extends oxAdminDetails
00011 {
00018 public function render()
00019 {
00020 $myConfig = $this->getConfig();
00021 parent::render();
00022
00023 $soxId = oxConfig::getParameter( "oxid");
00024
00025 $sSavedID = oxConfig::getParameter( "saved_oxid");
00026 if ( ($soxId == "-1" || !isset( $soxId)) && isset( $sSavedID) ) {
00027 $soxId = $sSavedID;
00028 oxSession::deleteVar( "saved_oxid");
00029 $this->_aViewData["oxid"] = $soxId;
00030
00031 $this->_aViewData["updatelist"] = "1";
00032 }
00033
00034 if ( $soxId != "-1" && isset( $soxId)) {
00035
00036 $odeliveryset = oxNew( "oxdeliveryset" );
00037 $odeliveryset->loadInLang( $this->_iEditLang, $soxId );
00038
00039 $oOtherLang = $odeliveryset->getAvailableInLangs();
00040
00041 if (!isset($oOtherLang[$this->_iEditLang])) {
00042
00043 $odeliveryset->loadInLang( key($oOtherLang), $soxId );
00044 }
00045
00046 $this->_aViewData["edit"] = $odeliveryset;
00047
00048
00049
00050 $aLang = array_diff ( oxLang::getInstance()->getLanguageNames(), $oOtherLang );
00051 if ( count( $aLang))
00052 $this->_aViewData["posslang"] = $aLang;
00053
00054 foreach ( $oOtherLang as $id => $language) {
00055 $oLang= new oxStdClass();
00056 $oLang->sLangDesc = $language;
00057 $oLang->selected = ($id == $this->_iEditLang);
00058 $this->_aViewData["otherlang"][$id] = clone $oLang;
00059 }
00060 }
00061
00062 if ( oxConfig::getParameter("aoc") ) {
00063
00064 $aColumns = array();
00065 include_once 'inc/'.strtolower(__CLASS__).'.inc.php';
00066 $this->_aViewData['oxajax'] = $aColumns;
00067
00068 return "popups/deliveryset_main.tpl";
00069 }
00070
00071 return "deliveryset_main.tpl";
00072 }
00073
00079 public function save()
00080 {
00081
00082 $soxId = oxConfig::getParameter( "oxid");
00083 $aParams = oxConfig::getParameter( "editval");
00084
00085
00086 $sShopID = oxSession::getVar( "actshop");
00087 $aParams['oxdeliveryset__oxshopid'] = $sShopID;
00088 $oDelSet = oxNew( "oxdeliveryset" );
00089
00090 if ( $soxId != "-1")
00091 $oDelSet->loadInLang( $this->_iEditLang, $soxId );
00092 else
00093 $aParams['oxdeliveryset__oxid'] = null;
00094
00095 if ( !isset( $aParams['oxdeliveryset__oxactive']))
00096 $aParams['oxdeliveryset__oxactive'] = 0;
00097
00098
00099
00100 $oDelSet->setLanguage(0);
00101 $oDelSet->assign( $aParams);
00102 $oDelSet->setLanguage($this->_iEditLang);
00103 $oDelSet = oxUtilsFile::getInstance()->processFiles( $oDelSet );
00104 $oDelSet->save();
00105 $this->_aViewData["updatelist"] = "1";
00106
00107
00108 if ( $soxId == "-1")
00109 oxSession::setVar( "saved_oxid", $oDelSet->oxdeliveryset__oxid->value);
00110
00111 return $this->autosave();
00112 }
00113
00119 public function saveinnlang()
00120 {
00121 $soxId = oxConfig::getParameter( "oxid");
00122 $aParams = oxConfig::getParameter( "editval");
00123
00124 if( !isset( $aParams['oxdeliveryset__oxactive']))
00125 $aParams['oxdeliveryset__oxactive'] = 0;
00126
00127
00128 $sShopID = oxSession::getVar( "actshop");
00129 $aParams['oxdeliveryset__oxshopid'] = $sShopID;
00130 $oDelSet = oxNew( "oxdeliveryset" );
00131
00132 if ( $soxId != "-1")
00133 $oDelSet->loadInLang( $this->_iEditLang, $soxId );
00134 else
00135 $aParams['oxdeliveryset__oxid'] = null;
00136
00137
00138 $oDelSet->setLanguage(0);
00139 $oDelSet->assign( $aParams);
00140
00141
00142
00143 $sNewLanguage = oxConfig::getParameter( "new_lang");
00144 $oDelSet->setLanguage( $sNewLanguage);
00145 $oDelSet->save();
00146 $this->_aViewData["updatelist"] = "1";
00147
00148
00149 oxSession::setVar( "new_lang", $sNewLanguage);
00150
00151
00152 if ( $soxId == "-1")
00153 oxSession::setVar( "saved_oxid", $oDelSet->oxdeliveryset__oxid->value);
00154
00155 return $this->autosave();
00156 }
00157 }