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 ( 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
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
00098 $sOxId = $this->getEditObjectId();
00099 $aParams = oxConfig::getParameter( "editval");
00100
00101
00102 $sShopID = oxSession::getVar( "actshop");
00103 $aParams['oxdiscount__oxshopid'] = $sShopID;
00104 $oAttr = oxNew( "oxdiscount" );
00105 if ( $sOxId != "-1")
00106 $oAttr->load( $sOxId );
00107 else
00108 $aParams['oxdiscount__oxid'] = null;
00109
00110
00111 if ( !isset( $aParams['oxdiscount__oxactive']))
00112 $aParams['oxdiscount__oxactive'] = 0;
00113
00114
00115
00116 $oAttr->setLanguage(0);
00117 $oAttr->assign( $aParams );
00118 $oAttr->setLanguage($this->_iEditLang);
00119 $oAttr = oxUtilsFile::getInstance()->processFiles( $oAttr );
00120 $oAttr->save();
00121
00122
00123 $this->setEditObjectId( $oAttr->getId() );
00124 }
00125
00131 public function saveinnlang()
00132 {
00133
00134 $sOxId = $this->getEditObjectId();
00135 $aParams = oxConfig::getParameter( "editval");
00136
00137
00138 $sShopID = oxSession::getVar( "actshop");
00139 $aParams['oxdiscount__oxshopid'] = $sShopID;
00140 $oAttr = oxNew( "oxdiscount" );
00141 if ( $sOxId != "-1")
00142 $oAttr->load( $sOxId);
00143 else
00144 $aParams['oxdiscount__oxid'] = null;
00145
00146 if ( !isset( $aParams['oxdiscount__oxactive']))
00147 $aParams['oxdiscount__oxactive'] = 0;
00148
00149
00150
00151 $oAttr->setLanguage(0);
00152 $oAttr->assign( $aParams);
00153 $oAttr->setLanguage($this->_iEditLang);
00154 $oAttr = oxUtilsFile::getInstance()->processFiles( $oAttr );
00155 $oAttr->save();
00156
00157
00158 $this->setEditObjectId( $oAttr->getId() );
00159 }
00160 }