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 $oAttr = oxNew( "oxdelivery" );
00119
00120 if ( $soxId != "-1")
00121 $oAttr->loadInLang( $this->_iEditLang, $soxId );
00122 else
00123 $aParams['oxdelivery__oxid'] = null;
00124
00125 if ( !isset( $aParams['oxdelivery__oxactive']))
00126 $aParams['oxdelivery__oxactive'] = 0;
00127 if ( !isset( $aParams['oxdelivery__oxfixed']))
00128 $aParams['oxdelivery__oxfixed'] = 0;
00129 if ( !isset( $aParams['oxdelivery__oxfinalize']))
00130 $aParams['oxdelivery__oxfinalize'] = 0;
00131 if ( !isset( $aParams['oxdelivery__oxsort']))
00132 $aParams['oxdelivery__oxsort'] = 9999;
00133
00134
00135
00136 $oAttr->setLanguage(0);
00137 $oAttr->assign( $aParams);
00138 $oAttr->setLanguage($this->_iEditLang);
00139 $oAttr = oxUtilsFile::getInstance()->processFiles( $oAttr );
00140 $oAttr->save();
00141 $this->_aViewData["updatelist"] = "1";
00142
00143
00144 if ( $soxId == "-1")
00145 oxSession::setVar( "saved_oxid", $oAttr->oxdelivery__oxid->value);
00146 }
00147
00153 public function saveinnlang()
00154 {
00155 $soxId = oxConfig::getParameter( "oxid");
00156 $aParams = oxConfig::getParameter( "editval");
00157
00158
00159 $sShopID = oxSession::getVar( "actshop");
00160 $aParams['oxdelivery__oxshopid'] = $sShopID;
00161 $oAttr = oxNew( "oxdelivery" );
00162
00163 if ( $soxId != "-1")
00164 $oAttr->loadInLang( $this->_iEditLang, $soxId );
00165 else
00166 $aParams['oxdelivery__oxid'] = null;
00167
00168 if ( !isset( $aParams['oxdelivery__oxactive']))
00169 $aParams['oxdelivery__oxactive'] = 0;
00170 if ( !isset( $aParams['oxdelivery__oxfixed']))
00171 $aParams['oxdelivery__oxfixed'] = 0;
00172
00173
00174
00175 $oAttr->setLanguage(0);
00176 $oAttr->assign( $aParams);
00177 $oAttr->setLanguage($this->_iEditLang);
00178 $oAttr = oxUtilsFile::getInstance()->processFiles( $oAttr );
00179 $oAttr->save();
00180 $this->_aViewData["updatelist"] = "1";
00181
00182
00183 if ( $soxId == "-1")
00184 oxSession::setVar( "saved_oxid", $oAttr->oxdelivery__oxid->value);
00185 }
00186
00192 public function addtoset()
00193 {
00194 $soxId = oxConfig::getParameter( "oxid");
00195 $aChosenSets = oxConfig::getParameter( "allsets");
00196
00197
00198 if ( isset( $soxId) && $soxId != "-1" && isset( $aChosenSets) && $aChosenSets) {
00199 $oDb = oxDb::getDb();
00200 foreach ( $aChosenSets as $sChosenSet) {
00201
00202 $sID = $oDb->GetOne("select oxid from oxdel2delset where oxdelid = '$soxId' and oxdelsetid = '$sChosenSet'");
00203 if ( !isset( $sID) || !$sID) {
00204 $oDel2delset = oxNew( 'oxbase' );
00205 $oDel2delset->init( 'oxdel2delset' );
00206 $oDel2delset->oxdel2delset__oxdelid = new oxField($soxId);
00207 $oDel2delset->oxdel2delset__oxdelsetid = new oxField($sChosenSet);
00208 $oDel2delset->save();
00209 }
00210 }
00211 }
00212 }
00213
00219 public function removefromset()
00220 {
00221 $soxId = oxConfig::getParameter( "oxid" );
00222 $aChosenSets = oxConfig::getParameter( "allasssets" );
00223
00224
00225 if ( isset( $soxId) && $soxId != "-1" && isset( $aChosenSets) && $aChosenSets) {
00226 $oDb = oxDb::getDb();
00227 foreach ( $aChosenSets as $sChosenSet) {
00228 $oDb->Execute( "delete from oxdel2delset where oxdelid = '$soxId' and oxdelsetid = '$sChosenSet'");
00229 }
00230 }
00231 }
00232 }