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 = oxRegistry::getLang();
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 stdClass();
00032         $oType->sType     = "a";      // amount
00033         $oType->sDesc    = $oLang->translateString( "amount", $iLang );
00034         $aDelTypes['a'] = $oType;
00035         $oType = new stdClass();
00036         $oType->sType     = "s";      // Size
00037         $oType->sDesc    = $oLang->translateString( "size", $iLang );
00038         $aDelTypes['s'] = $oType;
00039         $oType = new stdClass();
00040         $oType->sType     = "w";      // Weight
00041         $oType->sDesc    = $oLang->translateString( "weight", $iLang );
00042         $aDelTypes['w'] = $oType;
00043         $oType = new stdClass();
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 stdClass();
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 = new oxField("a"); // default
00078             }
00079             $aDelTypes[$oDelivery->oxdelivery__oxdeltype->value]->selected = true;
00080         }
00081 
00082         $this->_aViewData["deltypes"] = $aDelTypes;
00083 
00084         if ( oxConfig::getParameter("aoc") ) {
00085             $oDeliveryMainAjax = oxNew( 'delivery_main_ajax' );
00086             $this->_aViewData['oxajax'] = $oDeliveryMainAjax->getColumns();
00087 
00088             return "popups/delivery_main.tpl";
00089         }
00090         return "delivery_main.tpl";
00091     }
00092 
00098     public function save()
00099     {
00100         parent::save();
00101 
00102         $soxId = $this->getEditObjectId();
00103         $aParams = oxConfig::getParameter( "editval");
00104 
00105             // shopid
00106             $sShopID = oxSession::getVar( "actshop");
00107             $aParams['oxdelivery__oxshopid'] = $sShopID;
00108 
00109         $oDelivery = oxNew( "oxdelivery" );
00110 
00111         if ( $soxId != "-1") {
00112             $oDelivery->loadInLang( $this->_iEditLang, $soxId );
00113         } else {
00114             $aParams['oxdelivery__oxid'] = null;
00115         }
00116 
00117         // checkbox handling
00118         if ( !isset( $aParams['oxdelivery__oxactive']))
00119             $aParams['oxdelivery__oxactive'] = 0;
00120         if ( !isset( $aParams['oxdelivery__oxfixed']))
00121             $aParams['oxdelivery__oxfixed'] = 0;
00122         if ( !isset( $aParams['oxdelivery__oxfinalize']))
00123             $aParams['oxdelivery__oxfinalize'] = 0;
00124         if ( !isset( $aParams['oxdelivery__oxsort']))
00125             $aParams['oxdelivery__oxsort'] = 9999;
00126 
00127 
00128         $oDelivery->setLanguage(0);
00129         $oDelivery->assign( $aParams );
00130         $oDelivery->setLanguage($this->_iEditLang);
00131         $oDelivery = oxRegistry::get("oxUtilsFile")->processFiles( $oDelivery );
00132         $oDelivery->save();
00133 
00134         // set oxid if inserted
00135         $this->setEditObjectId( $oDelivery->getId() );
00136     }
00137 
00143     public function saveinnlang()
00144     {
00145         $soxId = $this->getEditObjectId();
00146         $aParams = oxConfig::getParameter( "editval");
00147 
00148             // shopid
00149             $sShopID = oxSession::getVar( "actshop");
00150             $aParams['oxdelivery__oxshopid'] = $sShopID;
00151 
00152         $oDelivery = oxNew( "oxdelivery" );
00153 
00154         if ( $soxId != "-1") {
00155             $oDelivery->loadInLang( $this->_iEditLang, $soxId );
00156         } else {
00157             $aParams['oxdelivery__oxid'] = null;
00158         }
00159 
00160         // checkbox handling
00161         if ( !isset( $aParams['oxdelivery__oxactive'])) {
00162             $aParams['oxdelivery__oxactive'] = 0;
00163         }
00164         if ( !isset( $aParams['oxdelivery__oxfixed'])) {
00165             $aParams['oxdelivery__oxfixed'] = 0;
00166         }
00167 
00168 
00169         $oDelivery->setLanguage(0);
00170         $oDelivery->assign( $aParams);
00171         $oDelivery->setLanguage($this->_iEditLang);
00172         $oDelivery = oxRegistry::get("oxUtilsFile")->processFiles( $oDelivery );
00173         $oDelivery->save();
00174 
00175         // set oxid if inserted
00176         $this->setEditObjectId( $oDelivery->getId() );
00177     }
00178 }