00001 <?php
00002
00010 class Delivery_Main extends oxAdminDetails
00011 {
00018 public function render()
00019 {
00020 $myConfig = $this->getConfig();
00021
00022 parent::render();
00023
00024 $iLang = oxLang::getInstance()->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 = oxLang::getInstance()->translateString( "amount", $iLang );
00034 $aDelTypes['a'] = $oType;
00035 $oType = new oxStdClass();
00036 $oType->typ = "s";
00037 $oType->Desc = oxLang::getInstance()->translateString( "size", $iLang );
00038 $aDelTypes['s'] = $oType;
00039 $oType = new oxStdClass();
00040 $oType->typ = "w";
00041 $oType->Desc = oxLang::getInstance()->translateString( "weight", $iLang );
00042 $aDelTypes['w'] = $oType;
00043 $oType = new oxStdClass();
00044 $oType->typ = "p";
00045 $oType->Desc = oxLang::getInstance()->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 ( oxLang::getInstance()->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 return $this->autosave();
00148 }
00149
00155 public function saveinnlang()
00156 {
00157 $soxId = oxConfig::getParameter( "oxid");
00158 $aParams = oxConfig::getParameter( "editval");
00159
00160
00161 $sShopID = oxSession::getVar( "actshop");
00162 $aParams['oxdelivery__oxshopid'] = $sShopID;
00163 $oAttr = oxNew( "oxdelivery" );
00164
00165 if ( $soxId != "-1")
00166 $oAttr->loadInLang( $this->_iEditLang, $soxId );
00167 else
00168 $aParams['oxdelivery__oxid'] = null;
00169
00170 if ( !isset( $aParams['oxdelivery__oxactive']))
00171 $aParams['oxdelivery__oxactive'] = 0;
00172 if ( !isset( $aParams['oxdelivery__oxfixed']))
00173 $aParams['oxdelivery__oxfixed'] = 0;
00174
00175
00176
00177 $oAttr->setLanguage(0);
00178 $oAttr->assign( $aParams);
00179 $oAttr->setLanguage($this->_iEditLang);
00180 $oAttr = oxUtilsFile::getInstance()->processFiles( $oAttr );
00181 $oAttr->save();
00182 $this->_aViewData["updatelist"] = "1";
00183
00184
00185 if ( $soxId == "-1")
00186 oxSession::setVar( "saved_oxid", $oAttr->oxdelivery__oxid->value);
00187
00188 return $this->autosave();
00189 }
00190
00196 public function addtoset()
00197 {
00198 $soxId = oxConfig::getParameter( "oxid");
00199 $aChosenSets = oxConfig::getParameter( "allsets");
00200
00201
00202 if ( isset( $soxId) && $soxId != "-1" && isset( $aChosenSets) && $aChosenSets) {
00203 foreach ( $aChosenSets as $sChosenSet) {
00204
00205 $sID = oxDb::getDb()->GetOne("select oxid from oxdel2delset where oxdelid = '$soxId' and oxdelsetid = '$sChosenSet'");
00206 if ( !isset( $sID) || !$sID) {
00207 $oDel2delset = oxNew( 'oxbase' );
00208 $oDel2delset->init( 'oxdel2delset' );
00209 $oDel2delset->oxdel2delset__oxdelid = new oxField($soxId);
00210 $oDel2delset->oxdel2delset__oxdelsetid = new oxField($sChosenSet);
00211 $oDel2delset->save();
00212 }
00213 }
00214 }
00215 }
00216
00222 public function removefromset()
00223 {
00224 $soxId = oxConfig::getParameter( "oxid" );
00225 $aChosenSets = oxConfig::getParameter( "allasssets" );
00226
00227
00228 if ( isset( $soxId) && $soxId != "-1" && isset( $aChosenSets) && $aChosenSets) {
00229 foreach ( $aChosenSets as $sChosenSet) {
00230 oxDb::getDb()->Execute( "delete from oxdel2delset where oxdelid = '$soxId' and oxdelsetid = '$sChosenSet'");
00231 }
00232 }
00233 }
00234 }