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 ( oxLang::getInstance()->getLanguageNames(), $oOtherLang );
00038 
00039             if ( count( $aLang ) ) {
00040                 $this->_aViewData["posslang"] = $aLang;
00041             }
00042 
00043             foreach ( $oOtherLang as $id => $language) {
00044                 $oLang= new oxStdClass();
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             $aColumns = array();
00053             if ( $iAoc == "1" ) {
00054                 include_once 'inc/'.strtolower(__CLASS__).'.inc.php';
00055                 $this->_aViewData['oxajax'] = $aColumns;
00056                 return "popups/discount_main.tpl";
00057             } elseif ( $iAoc == "2" ) {
00058                 // generating category tree for artikel choose select list
00059                 $this->_getCategoryTree( "artcattree", null );
00060 
00061                 include_once 'inc/discount_item.inc.php';
00062                 $this->_aViewData['oxajax'] = $aColumns;
00063                 return "popups/discount_item.tpl";
00064             }
00065         }
00066         return "discount_main.tpl";
00067     }
00068 
00074     public function getItemDiscountProductTitle()
00075     {
00076         $sTitle = false;
00077         $sOxId = $this->getEditObjectId();
00078         if ( $sOxId != "-1" && isset( $sOxId)) {
00079             $sViewName = getViewName( "oxarticles", $this->_iEditLang );
00080             $oDb = oxDb::getDb();
00081             $sQ = "select concat( $sViewName.oxartnum, ' ', $sViewName.oxtitle ) from oxdiscount
00082                    left join $sViewName on $sViewName.oxid=oxdiscount.oxitmartid
00083                    where oxdiscount.oxitmartid != '' and oxdiscount.oxid=" . $oDb->quote( $sOxId );
00084             $sTitle = $oDb->getOne( $sQ );
00085         }
00086 
00087         return $sTitle ? $sTitle : " -- ";
00088     }
00089 
00095     public function save()
00096     {
00097         parent::save();
00098 
00099         $sOxId = $this->getEditObjectId();
00100         $aParams = oxConfig::getParameter( "editval");
00101 
00102             // shopid
00103             $sShopID = oxSession::getVar( "actshop");
00104             $aParams['oxdiscount__oxshopid'] = $sShopID;
00105         $oAttr = oxNew( "oxdiscount" );
00106         if ( $sOxId != "-1")
00107             $oAttr->load( $sOxId );
00108         else
00109             $aParams['oxdiscount__oxid'] = null;
00110 
00111         // checkbox handling
00112         if ( !isset( $aParams['oxdiscount__oxactive']))
00113             $aParams['oxdiscount__oxactive'] = 0;
00114 
00115 
00116         //$aParams = $oAttr->ConvertNameArray2Idx( $aParams);
00117         $oAttr->setLanguage(0);
00118         $oAttr->assign( $aParams );
00119         $oAttr->setLanguage($this->_iEditLang);
00120         $oAttr = oxUtilsFile::getInstance()->processFiles( $oAttr );
00121         $oAttr->save();
00122 
00123         // set oxid if inserted
00124         $this->setEditObjectId( $oAttr->getId() );
00125     }
00126 
00132     public function saveinnlang()
00133     {
00134         parent::save();
00135 
00136         $sOxId = $this->getEditObjectId();
00137         $aParams = oxConfig::getParameter( "editval");
00138 
00139             // shopid
00140             $sShopID = oxSession::getVar( "actshop");
00141             $aParams['oxdiscount__oxshopid'] = $sShopID;
00142         $oAttr = oxNew( "oxdiscount" );
00143         if ( $sOxId != "-1")
00144             $oAttr->load( $sOxId);
00145         else
00146             $aParams['oxdiscount__oxid'] = null;
00147         // checkbox handling
00148         if ( !isset( $aParams['oxdiscount__oxactive']))
00149             $aParams['oxdiscount__oxactive'] = 0;
00150 
00151 
00152         //$aParams = $oAttr->ConvertNameArray2Idx( $aParams);
00153         $oAttr->setLanguage(0);
00154         $oAttr->assign( $aParams);
00155         $oAttr->setLanguage($this->_iEditLang);
00156         $oAttr = oxUtilsFile::getInstance()->processFiles( $oAttr );
00157         $oAttr->save();
00158 
00159         // set oxid if inserted
00160         $this->setEditObjectId( $oAttr->getId() );
00161     }
00162 }