delivery_main.php

Go to the documentation of this file.
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         // remove itm from list
00025         unset( $this->_aViewData["sumtype"][2]);
00026 
00027         // Deliverytypes
00028         $aDelTypes = array();
00029         $oType = new oxStdClass();
00030         $oType->typ     = "a";      // amount
00031         $oType->Desc    = oxLang::getInstance()->translateString("amount");
00032         $aDelTypes['a'] = $oType;
00033         $oType = new oxStdClass();
00034         $oType->typ     = "s";      // Size
00035         $oType->Desc    = oxLang::getInstance()->translateString("size");
00036         $aDelTypes['s'] = $oType;
00037         $oType = new oxStdClass();
00038         $oType->typ     = "w";      // Weight
00039         $oType->Desc    = oxLang::getInstance()->translateString("weight");
00040         $aDelTypes['w'] = $oType;
00041         $oType = new oxStdClass();
00042         $oType->typ     = "p";      // Price
00043         $oType->Desc    = oxLang::getInstance()->translateString("price");
00044         $aDelTypes['p'] = $oType;
00045 
00046         $soxId = oxConfig::getParameter( "oxid");
00047         // check if we right now saved a new entry
00048         $sSavedID = oxConfig::getParameter( "saved_oxid");
00049         if ( ($soxId == "-1" || !isset( $soxId)) && isset( $sSavedID) ) {
00050             $soxId = $sSavedID;
00051             oxSession::deleteVar( "saved_oxid");
00052             $this->_aViewData["oxid"] =  $soxId;
00053             // for reloading upper frame
00054             $this->_aViewData["updatelist"] =  "1";
00055         }
00056 
00057         if ( $soxId != "-1" && isset( $soxId)) {
00058             // load object
00059             $oDelivery = oxNew( "oxdelivery" );
00060             $oDelivery->loadInLang( $this->_iEditLang, $soxId );
00061 
00062             $oOtherLang = $oDelivery->getAvailableInLangs();
00063             if (!isset($oOtherLang[$this->_iEditLang])) {
00064                 // echo "language entry doesn't exist! using: ".key($oOtherLang);
00065                 $oDelivery->loadInLang( key($oOtherLang), $soxId );
00066             }
00067 
00068             $this->_aViewData["edit"] =  $oDelivery;
00069 
00070 
00071             // remove already created languages
00072             $aLang = array_diff ( oxLang::getInstance()->getLanguageNames(), $oOtherLang);
00073             if ( count( $aLang))
00074                 $this->_aViewData["posslang"] = $aLang;
00075 
00076             foreach ( $oOtherLang as $id => $language) {
00077                 $oLang= new oxStdClass();
00078                 $oLang->sLangDesc = $language;
00079                 $oLang->selected = ($id == $this->_iEditLang);
00080                 $this->_aViewData["otherlang"][$id] = clone $oLang;
00081             }
00082 
00083             // set selected delivery type
00084             if ( !$oDelivery->oxdelivery__oxdeltype->value)
00085                 $oDelivery->oxdelivery__oxdeltype->setValue("a"); // default
00086             $aDelTypes[$oDelivery->oxdelivery__oxdeltype->value]->selected = true;
00087         }
00088 
00089         $this->_aViewData["deltypes"] = $aDelTypes;
00090 
00091         if ( oxConfig::getParameter("aoc") ) {
00092 
00093             $aColumns = array();
00094             include_once 'inc/'.strtolower(__CLASS__).'.inc.php';
00095             $this->_aViewData['oxajax'] = $aColumns;
00096 
00097             return "popups/delivery_main.tpl";
00098         }
00099         return "delivery_main.tpl";
00100     }
00101 
00107     public function save()
00108     {
00109 
00110         $soxId   = oxConfig::getParameter( "oxid");
00111         $aParams = oxConfig::getParameter( "editval");
00112 
00113             // shopid
00114             $sShopID = oxSession::getVar( "actshop");
00115             $aParams['oxdelivery__oxshopid'] = $sShopID;
00116         $oAttr = oxNew( "oxdelivery" );
00117 
00118         if ( $soxId != "-1")
00119             $oAttr->loadInLang( $this->_iEditLang, $soxId );
00120         else
00121             $aParams['oxdelivery__oxid'] = null;
00122         // checkbox handling
00123         if ( !isset( $aParams['oxdelivery__oxactive']))
00124             $aParams['oxdelivery__oxactive'] = 0;
00125         if ( !isset( $aParams['oxdelivery__oxfixed']))
00126             $aParams['oxdelivery__oxfixed'] = 0;
00127         if ( !isset( $aParams['oxdelivery__oxfinalize']))
00128             $aParams['oxdelivery__oxfinalize'] = 0;
00129         if ( !isset( $aParams['oxdelivery__oxsort']))
00130             $aParams['oxdelivery__oxsort'] = 9999;
00131 
00132 
00133         //$aParams = $oAttr->ConvertNameArray2Idx( $aParams);
00134         $oAttr->setLanguage(0);
00135         $oAttr->assign( $aParams);
00136         $oAttr->setLanguage($this->_iEditLang);
00137         $oAttr = oxUtilsFile::getInstance()->processFiles( $oAttr );
00138         $oAttr->save();
00139         $this->_aViewData["updatelist"] = "1";
00140 
00141         // set oxid if inserted
00142         if ( $soxId == "-1")
00143             oxSession::setVar( "saved_oxid", $oAttr->oxdelivery__oxid->value);
00144 
00145         return $this->autosave();
00146     }
00147 
00153     public function saveinnlang()
00154     {
00155         $soxId     = oxConfig::getParameter( "oxid");
00156         $aParams   = oxConfig::getParameter( "editval");
00157 
00158             // shopid
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         // checkbox handling
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         //$aParams = $oAttr->ConvertNameArray2Idx( $aParams);
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         // set oxid if inserted
00183         if ( $soxId == "-1")
00184             oxSession::setVar( "saved_oxid", $oAttr->oxdelivery__oxid->value);
00185 
00186         return $this->autosave();
00187     }
00188 
00194     public function addtoset()
00195     {
00196         $soxId = oxConfig::getParameter( "oxid");
00197         $aChosenSets = oxConfig::getParameter( "allsets");
00198 
00199 
00200         if ( isset( $soxId) && $soxId != "-1" && isset( $aChosenSets) && $aChosenSets) {
00201             foreach ( $aChosenSets as $sChosenSet) {
00202                 // check if we have this entry already in
00203                 $sID = oxDb::getDb()->GetOne("select oxid from oxdel2delset where oxdelid = '$soxId' and oxdelsetid = '$sChosenSet'");
00204                 if ( !isset( $sID) || !$sID) {
00205                         $oDel2delset = oxNew( 'oxbase' );
00206                         $oDel2delset->init( 'oxdel2delset' );
00207                         $oDel2delset->oxdel2delset__oxdelid    = new oxField($soxId);
00208                         $oDel2delset->oxdel2delset__oxdelsetid = new oxField($sChosenSet);
00209                         $oDel2delset->save();
00210                 }
00211             }
00212         }
00213     }
00214 
00220     public function removefromset()
00221     {
00222         $soxId = oxConfig::getParameter( "oxid" );
00223         $aChosenSets = oxConfig::getParameter( "allasssets" );
00224 
00225 
00226         if ( isset( $soxId) && $soxId != "-1" && isset( $aChosenSets) && $aChosenSets) {
00227             foreach ( $aChosenSets as $sChosenSet) {
00228                 oxDb::getDb()->Execute( "delete from oxdel2delset where oxdelid = '$soxId' and oxdelsetid = '$sChosenSet'");
00229             }
00230         }
00231     }
00232 }

Generated on Thu Dec 4 12:04:55 2008 for OXID eShop CE by  doxygen 1.5.5