delivery_main.php

Go to the documentation of this file.
00001 <?php
00002 
00009 class Delivery_Main extends oxAdminDetails
00010 {
00011 
00018     public function render()
00019     {
00020         $myConfig = $this->getConfig();
00021 
00022         parent::render();
00023 
00024         $oLang = oxRegistry::getLang();
00025         $iLang = $oLang->getTplLanguage();
00026 
00027         // remove itm from list
00028         unset($this->_aViewData["sumtype"][2]);
00029 
00030         // Deliverytypes
00031         $aDelTypes = array();
00032         $oType = new stdClass();
00033         $oType->sType = "a"; // amount
00034         $oType->sDesc = $oLang->translateString("amount", $iLang);
00035         $aDelTypes['a'] = $oType;
00036         $oType = new stdClass();
00037         $oType->sType = "s"; // Size
00038         $oType->sDesc = $oLang->translateString("size", $iLang);
00039         $aDelTypes['s'] = $oType;
00040         $oType = new stdClass();
00041         $oType->sType = "w"; // Weight
00042         $oType->sDesc = $oLang->translateString("weight", $iLang);
00043         $aDelTypes['w'] = $oType;
00044         $oType = new stdClass();
00045         $oType->sType = "p"; // Price
00046         $oType->sDesc = $oLang->translateString("price", $iLang);
00047         $aDelTypes['p'] = $oType;
00048 
00049         $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
00050         if ($soxId != "-1" && isset($soxId)) {
00051             // load object
00052             $oDelivery = oxNew("oxdelivery");
00053             $oDelivery->loadInLang($this->_iEditLang, $soxId);
00054 
00055             $oOtherLang = $oDelivery->getAvailableInLangs();
00056             if (!isset($oOtherLang[$this->_iEditLang])) {
00057                 // echo "language entry doesn't exist! using: ".key($oOtherLang);
00058                 $oDelivery->loadInLang(key($oOtherLang), $soxId);
00059             }
00060 
00061             $this->_aViewData["edit"] = $oDelivery;
00062 
00063 
00064             // remove already created languages
00065             $aLang = array_diff($oLang->getLanguageNames(), $oOtherLang);
00066             if (count($aLang)) {
00067                 $this->_aViewData["posslang"] = $aLang;
00068             }
00069 
00070             foreach ($oOtherLang as $id => $language) {
00071                 $oLang = new stdClass();
00072                 $oLang->sLangDesc = $language;
00073                 $oLang->selected = ($id == $this->_iEditLang);
00074                 $this->_aViewData["otherlang"][$id] = clone $oLang;
00075             }
00076 
00077             // set selected delivery type
00078             if (!$oDelivery->oxdelivery__oxdeltype->value) {
00079                 $oDelivery->oxdelivery__oxdeltype = new oxField("a"); // default
00080             }
00081             $aDelTypes[$oDelivery->oxdelivery__oxdeltype->value]->selected = true;
00082         }
00083 
00084         $this->_aViewData["deltypes"] = $aDelTypes;
00085 
00086         if (oxRegistry::getConfig()->getRequestParameter("aoc")) {
00087             $oDeliveryMainAjax = oxNew('delivery_main_ajax');
00088             $this->_aViewData['oxajax'] = $oDeliveryMainAjax->getColumns();
00089 
00090             return "popups/delivery_main.tpl";
00091         }
00092 
00093         return "delivery_main.tpl";
00094     }
00095 
00101     public function save()
00102     {
00103         parent::save();
00104 
00105         $soxId = $this->getEditObjectId();
00106         $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
00107 
00108         // shopid
00109         $sShopID = oxRegistry::getSession()->getVariable("actshop");
00110         $aParams['oxdelivery__oxshopid'] = $sShopID;
00111 
00112         $oDelivery = oxNew("oxdelivery");
00113 
00114         if ($soxId != "-1") {
00115             $oDelivery->loadInLang($this->_iEditLang, $soxId);
00116         } else {
00117             $aParams['oxdelivery__oxid'] = null;
00118         }
00119 
00120         // checkbox handling
00121         if (!isset($aParams['oxdelivery__oxactive'])) {
00122             $aParams['oxdelivery__oxactive'] = 0;
00123         }
00124 
00125         if (!isset($aParams['oxdelivery__oxfixed'])) {
00126             $aParams['oxdelivery__oxfixed'] = 0;
00127         }
00128 
00129         if (!isset($aParams['oxdelivery__oxfinalize'])) {
00130             $aParams['oxdelivery__oxfinalize'] = 0;
00131         }
00132 
00133         if (!isset($aParams['oxdelivery__oxsort'])) {
00134             $aParams['oxdelivery__oxsort'] = 9999;
00135         }
00136 
00137 
00138         $oDelivery->setLanguage(0);
00139         $oDelivery->assign($aParams);
00140         $oDelivery->setLanguage($this->_iEditLang);
00141         $oDelivery = oxRegistry::get("oxUtilsFile")->processFiles($oDelivery);
00142         $oDelivery->save();
00143 
00144         // set oxid if inserted
00145         $this->setEditObjectId($oDelivery->getId());
00146     }
00147 
00153     public function saveinnlang()
00154     {
00155         $soxId = $this->getEditObjectId();
00156         $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
00157 
00158         // shopid
00159         $sShopID = oxRegistry::getSession()->getVariable("actshop");
00160         $aParams['oxdelivery__oxshopid'] = $sShopID;
00161 
00162         $oDelivery = oxNew("oxdelivery");
00163 
00164         if ($soxId != "-1") {
00165             $oDelivery->loadInLang($this->_iEditLang, $soxId);
00166         } else {
00167             $aParams['oxdelivery__oxid'] = null;
00168         }
00169 
00170         // checkbox handling
00171         if (!isset($aParams['oxdelivery__oxactive'])) {
00172             $aParams['oxdelivery__oxactive'] = 0;
00173         }
00174         if (!isset($aParams['oxdelivery__oxfixed'])) {
00175             $aParams['oxdelivery__oxfixed'] = 0;
00176         }
00177 
00178 
00179         $oDelivery->setLanguage(0);
00180         $oDelivery->assign($aParams);
00181         $oDelivery->setLanguage($this->_iEditLang);
00182         $oDelivery = oxRegistry::get("oxUtilsFile")->processFiles($oDelivery);
00183         $oDelivery->save();
00184 
00185         // set oxid if inserted
00186         $this->setEditObjectId($oDelivery->getId());
00187     }
00188 }