delivery_main.php

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         // remove itm from list
00027         unset( $this->_aViewData["sumtype"][2]);
00028 
00029         // Deliverytypes
00030         $aDelTypes = array();
00031         $oType = new oxStdClass();
00032         $oType->sType     = "a";      // amount
00033         $oType->sDesc    = $oLang->translateString( "amount", $iLang );
00034         $aDelTypes['a'] = $oType;
00035         $oType = new oxStdClass();
00036         $oType->sType     = "s";      // Size
00037         $oType->sDesc    = $oLang->translateString( "size", $iLang );
00038         $aDelTypes['s'] = $oType;
00039         $oType = new oxStdClass();
00040         $oType->sType     = "w";      // Weight
00041         $oType->sDesc    = $oLang->translateString( "weight", $iLang );
00042         $aDelTypes['w'] = $oType;
00043         $oType = new oxStdClass();
00044         $oType->sType     = "p";      // Price
00045         $oType->sDesc    = $oLang->translateString( "price", $iLang );
00046         $aDelTypes['p'] = $oType;
00047 
00048         $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
00049         if ( $soxId != "-1" && isset( $soxId)) {
00050             // load object
00051             $oDelivery = oxNew( "oxdelivery" );
00052             $oDelivery->loadInLang( $this->_iEditLang, $soxId );
00053 
00054             $oOtherLang = $oDelivery->getAvailableInLangs();
00055             if (!isset($oOtherLang[$this->_iEditLang])) {
00056                 // echo "language entry doesn't exist! using: ".key($oOtherLang);
00057                 $oDelivery->loadInLang( key($oOtherLang), $soxId );
00058             }
00059 
00060             $this->_aViewData["edit"] =  $oDelivery;
00061 
00062 
00063             // remove already created languages
00064             $aLang = array_diff ( $oLang->getLanguageNames(), $oOtherLang);
00065             if ( count( $aLang))
00066                 $this->_aViewData["posslang"] = $aLang;
00067 
00068             foreach ( $oOtherLang as $id => $language) {
00069                 $oLang= new oxStdClass();
00070                 $oLang->sLangDesc = $language;
00071                 $oLang->selected = ($id == $this->_iEditLang);
00072                 $this->_aViewData["otherlang"][$id] = clone $oLang;
00073             }
00074 
00075             // set selected delivery type
00076             if ( !$oDelivery->oxdelivery__oxdeltype->value)
00077                 $oDelivery->oxdelivery__oxdeltype->setValue("a"); // default
00078             $aDelTypes[$oDelivery->oxdelivery__oxdeltype->value]->selected = true;
00079         }
00080 
00081         $this->_aViewData["deltypes"] = $aDelTypes;
00082 
00083         if ( oxConfig::getParameter("aoc") ) {
00084 
00085             $aColumns = array();
00086             include_once 'inc/'.strtolower(__CLASS__).'.inc.php';
00087             $this->_aViewData['oxajax'] = $aColumns;
00088 
00089             return "popups/delivery_main.tpl";
00090         }
00091         return "delivery_main.tpl";
00092     }
00093 
00099     public function save()
00100     {
00101         parent::save();
00102 
00103         $soxId = $this->getEditObjectId();
00104         $aParams = oxConfig::getParameter( "editval");
00105 
00106             // shopid
00107             $sShopID = oxSession::getVar( "actshop");
00108             $aParams['oxdelivery__oxshopid'] = $sShopID;
00109 
00110         $oDelivery = oxNew( "oxdelivery" );
00111 
00112         if ( $soxId != "-1") {
00113             $oDelivery->loadInLang( $this->_iEditLang, $soxId );
00114         } else {
00115             $aParams['oxdelivery__oxid'] = null;
00116         }
00117 
00118         // checkbox handling
00119         if ( !isset( $aParams['oxdelivery__oxactive']))
00120             $aParams['oxdelivery__oxactive'] = 0;
00121         if ( !isset( $aParams['oxdelivery__oxfixed']))
00122             $aParams['oxdelivery__oxfixed'] = 0;
00123         if ( !isset( $aParams['oxdelivery__oxfinalize']))
00124             $aParams['oxdelivery__oxfinalize'] = 0;
00125         if ( !isset( $aParams['oxdelivery__oxsort']))
00126             $aParams['oxdelivery__oxsort'] = 9999;
00127 
00128 
00129         $oDelivery->setLanguage(0);
00130         $oDelivery->assign( $aParams );
00131         $oDelivery->setLanguage($this->_iEditLang);
00132         $oDelivery = oxUtilsFile::getInstance()->processFiles( $oDelivery );
00133         $oDelivery->save();
00134 
00135         // set oxid if inserted
00136         $this->setEditObjectId( $oDelivery->getId() );
00137     }
00138 
00144     public function saveinnlang()
00145     {
00146         $soxId = $this->getEditObjectId();
00147         $aParams = oxConfig::getParameter( "editval");
00148 
00149             // shopid
00150             $sShopID = oxSession::getVar( "actshop");
00151             $aParams['oxdelivery__oxshopid'] = $sShopID;
00152 
00153         $oDelivery = oxNew( "oxdelivery" );
00154 
00155         if ( $soxId != "-1") {
00156             $oDelivery->loadInLang( $this->_iEditLang, $soxId );
00157         } else {
00158             $aParams['oxdelivery__oxid'] = null;
00159         }
00160 
00161         // checkbox handling
00162         if ( !isset( $aParams['oxdelivery__oxactive'])) {
00163             $aParams['oxdelivery__oxactive'] = 0;
00164         }
00165         if ( !isset( $aParams['oxdelivery__oxfixed'])) {
00166             $aParams['oxdelivery__oxfixed'] = 0;
00167         }
00168 
00169 
00170         $oDelivery->setLanguage(0);
00171         $oDelivery->assign( $aParams);
00172         $oDelivery->setLanguage($this->_iEditLang);
00173         $oDelivery = oxUtilsFile::getInstance()->processFiles( $oDelivery );
00174         $oDelivery->save();
00175 
00176         // set oxid if inserted
00177         $this->setEditObjectId( $oDelivery->getId() );
00178     }
00179 }