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