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
00024 $oDiscount = oxNew( "oxdiscount" );
00025 $oDiscount->loadInLang( $this->_iEditLang, $sOxId );
00026
00027 $oOtherLang = $oDiscount->getAvailableInLangs();
00028 if (!isset($oOtherLang[$this->_iEditLang])) {
00029
00030 $oDiscount->loadInLang( key( $oOtherLang ), $sOxId );
00031 }
00032
00033 $this->_aViewData["edit"] = $oDiscount;
00034
00035
00036
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
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
00104 $sShopID = oxSession::getVar( "actshop");
00105 $aParams['oxdiscount__oxshopid'] = $sShopID;
00106
00107 $oAttr = oxNew( "oxdiscount" );
00108 if ( $sOxId != "-1") {
00109 $oAttr->load( $sOxId );
00110 } else {
00111 $aParams['oxdiscount__oxid'] = null;
00112 }
00113
00114
00115 if ( !isset( $aParams['oxdiscount__oxactive'])) {
00116 $aParams['oxdiscount__oxactive'] = 0;
00117 }
00118
00119
00120
00121 $oAttr->setLanguage(0);
00122 $oAttr->assign( $aParams );
00123 $oAttr->setLanguage($this->_iEditLang);
00124 $oAttr = oxRegistry::get("oxUtilsFile")->processFiles( $oAttr );
00125 $oAttr->save();
00126
00127
00128 $this->setEditObjectId( $oAttr->getId() );
00129 }
00130
00136 public function saveinnlang()
00137 {
00138 parent::save();
00139
00140 $sOxId = $this->getEditObjectId();
00141 $aParams = oxConfig::getParameter( "editval");
00142
00143
00144 $sShopID = oxSession::getVar( "actshop");
00145 $aParams['oxdiscount__oxshopid'] = $sShopID;
00146 $oAttr = oxNew( "oxdiscount" );
00147 if ( $sOxId != "-1")
00148 $oAttr->load( $sOxId);
00149 else
00150 $aParams['oxdiscount__oxid'] = null;
00151
00152 if ( !isset( $aParams['oxdiscount__oxactive']))
00153 $aParams['oxdiscount__oxactive'] = 0;
00154
00155
00156
00157 $oAttr->setLanguage(0);
00158 $oAttr->assign( $aParams);
00159 $oAttr->setLanguage($this->_iEditLang);
00160 $oAttr = oxRegistry::get("oxUtilsFile")->processFiles( $oAttr );
00161 $oAttr->save();
00162
00163
00164 $this->setEditObjectId( $oAttr->getId() );
00165 }
00166 }