discount_main.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class Discount_Main extends oxAdminDetails
00009 {
00016     public function render()
00017     {
00018         $myConfig = $this->getConfig();
00019         parent::render();
00020 
00021         $sOxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
00022         if ( $sOxId != "-1" && isset( $sOxId)) {
00023             // load object
00024             $oDiscount = oxNew( "oxdiscount" );
00025             $oDiscount->loadInLang( $this->_iEditLang, $sOxId );
00026 
00027             $oOtherLang = $oDiscount->getAvailableInLangs();
00028             if (!isset($oOtherLang[$this->_iEditLang])) {
00029                 // echo "language entry doesn't exist! using: ".key($oOtherLang);
00030                 $oDiscount->loadInLang( key( $oOtherLang ), $sOxId );
00031             }
00032 
00033             $this->_aViewData["edit"] =  $oDiscount;
00034 
00035 
00036             // remove already created languages
00037             $aLang = array_diff ( oxRegistry::getLang()->getLanguageNames(), $oOtherLang );
00038 
00039             if ( count( $aLang ) ) {
00040                 $this->_aViewData["posslang"] = $aLang;
00041             }
00042 
00043             foreach ( $oOtherLang as $id => $language) {
00044                 $oLang= new stdClass();
00045                 $oLang->sLangDesc = $language;
00046                 $oLang->selected = ($id == $this->_iEditLang);
00047                 $this->_aViewData["otherlang"][$id] = clone $oLang;
00048             }
00049         }
00050 
00051         if ( ( $iAoc = oxConfig::getParameter("aoc") ) ) {
00052             if ( $iAoc == "1" ) {
00053                 $oDiscountMainAjax = oxNew( 'discount_main_ajax' );
00054                 $this->_aViewData['oxajax'] = $oDiscountMainAjax->getColumns();
00055 
00056                 return "popups/discount_main.tpl";
00057             } elseif ( $iAoc == "2" ) {
00058                 // generating category tree for artikel choose select list
00059                 $this->_createCategoryTree( "artcattree" );
00060 
00061                 $oDiscountItemAjax = oxNew( 'discount_item_ajax' );
00062                 $this->_aViewData['oxajax'] = $oDiscountItemAjax->getColumns();
00063 
00064                 return "popups/discount_item.tpl";
00065             }
00066         }
00067         return "discount_main.tpl";
00068     }
00069 
00075     public function getItemDiscountProductTitle()
00076     {
00077         $sTitle = false;
00078         $sOxId = $this->getEditObjectId();
00079         if ( $sOxId != "-1" && isset( $sOxId)) {
00080             $sViewName = getViewName( "oxarticles", $this->_iEditLang );
00081             $oDb = oxDb::getDb();
00082             $sQ = "select concat( $sViewName.oxartnum, ' ', $sViewName.oxtitle ) from oxdiscount
00083                    left join $sViewName on $sViewName.oxid=oxdiscount.oxitmartid
00084                    where oxdiscount.oxitmartid != '' and oxdiscount.oxid=" . $oDb->quote( $sOxId );
00085             $sTitle = $oDb->getOne( $sQ, false, false );
00086         }
00087 
00088         return $sTitle ? $sTitle : " -- ";
00089     }
00090 
00096     public function save()
00097     {
00098         parent::save();
00099 
00100         $sOxId = $this->getEditObjectId();
00101         $aParams = oxConfig::getParameter( "editval");
00102 
00103             // shopid
00104             $sShopID = oxSession::getVar( "actshop");
00105             $aParams['oxdiscount__oxshopid'] = $sShopID;
00106         $oAttr = oxNew( "oxdiscount" );
00107         if ( $sOxId != "-1")
00108             $oAttr->load( $sOxId );
00109         else
00110             $aParams['oxdiscount__oxid'] = null;
00111 
00112         // checkbox handling
00113         if ( !isset( $aParams['oxdiscount__oxactive']))
00114             $aParams['oxdiscount__oxactive'] = 0;
00115 
00116 
00117         //$aParams = $oAttr->ConvertNameArray2Idx( $aParams);
00118         $oAttr->setLanguage(0);
00119         $oAttr->assign( $aParams );
00120         $oAttr->setLanguage($this->_iEditLang);
00121         $oAttr = oxRegistry::get("oxUtilsFile")->processFiles( $oAttr );
00122         $oAttr->save();
00123 
00124         // set oxid if inserted
00125         $this->setEditObjectId( $oAttr->getId() );
00126     }
00127 
00133     public function saveinnlang()
00134     {
00135         parent::save();
00136 
00137         $sOxId = $this->getEditObjectId();
00138         $aParams = oxConfig::getParameter( "editval");
00139 
00140             // shopid
00141             $sShopID = oxSession::getVar( "actshop");
00142             $aParams['oxdiscount__oxshopid'] = $sShopID;
00143         $oAttr = oxNew( "oxdiscount" );
00144         if ( $sOxId != "-1")
00145             $oAttr->load( $sOxId);
00146         else
00147             $aParams['oxdiscount__oxid'] = null;
00148         // checkbox handling
00149         if ( !isset( $aParams['oxdiscount__oxactive']))
00150             $aParams['oxdiscount__oxactive'] = 0;
00151 
00152 
00153         //$aParams = $oAttr->ConvertNameArray2Idx( $aParams);
00154         $oAttr->setLanguage(0);
00155         $oAttr->assign( $aParams);
00156         $oAttr->setLanguage($this->_iEditLang);
00157         $oAttr = oxRegistry::get("oxUtilsFile")->processFiles( $oAttr );
00158         $oAttr->save();
00159 
00160         // set oxid if inserted
00161         $this->setEditObjectId( $oAttr->getId() );
00162     }
00163 }