OXID eShop CE  4.10.7
 All Classes Namespaces Files Functions Variables Pages
discount_main.php
Go to the documentation of this file.
1 <?php
2 
9 {
10 
17  public function render()
18  {
19  $myConfig = $this->getConfig();
21 
22  $sOxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
23  if ($sOxId != "-1" && isset($sOxId)) {
24  // load object
25  $oDiscount = oxNew("oxdiscount");
26  $oDiscount->loadInLang($this->_iEditLang, $sOxId);
27 
28  $oOtherLang = $oDiscount->getAvailableInLangs();
29  if (!isset($oOtherLang[$this->_iEditLang])) {
30  // echo "language entry doesn't exist! using: ".key($oOtherLang);
31  $oDiscount->loadInLang(key($oOtherLang), $sOxId);
32  }
33 
34  $this->_aViewData["edit"] = $oDiscount;
35 
36 
37  // remove already created languages
38  $aLang = array_diff(oxRegistry::getLang()->getLanguageNames(), $oOtherLang);
39 
40  if (count($aLang)) {
41  $this->_aViewData["posslang"] = $aLang;
42  }
43 
44  foreach ($oOtherLang as $id => $language) {
45  $oLang = new stdClass();
46  $oLang->sLangDesc = $language;
47  $oLang->selected = ($id == $this->_iEditLang);
48  $this->_aViewData["otherlang"][$id] = clone $oLang;
49  }
50  }
51 
52  if (($iAoc = oxRegistry::getConfig()->getRequestParameter("aoc"))) {
53  if ($iAoc == "1") {
54  $oDiscountMainAjax = oxNew('discount_main_ajax');
55  $this->_aViewData['oxajax'] = $oDiscountMainAjax->getColumns();
56 
57  return "popups/discount_main.tpl";
58  } elseif ($iAoc == "2") {
59  // generating category tree for artikel choose select list
60  $this->_createCategoryTree("artcattree");
61 
62  $oDiscountItemAjax = oxNew('discount_item_ajax');
63  $this->_aViewData['oxajax'] = $oDiscountItemAjax->getColumns();
64 
65  return "popups/discount_item.tpl";
66  }
67  }
68 
69  return "discount_main.tpl";
70  }
71 
77  public function getItemDiscountProductTitle()
78  {
79  $sTitle = false;
80  $sOxId = $this->getEditObjectId();
81  if ($sOxId != "-1" && isset($sOxId)) {
82  $sViewName = getViewName("oxarticles", $this->_iEditLang);
83  $oDb = oxDb::getDb();
84  $sQ = "select concat( $sViewName.oxartnum, ' ', $sViewName.oxtitle ) from oxdiscount
85  left join $sViewName on $sViewName.oxid=oxdiscount.oxitmartid
86  where oxdiscount.oxitmartid != '' and oxdiscount.oxid=" . $oDb->quote($sOxId);
87  $sTitle = $oDb->getOne($sQ, false, false);
88  }
89 
90  return $sTitle ? $sTitle : " -- ";
91  }
92 
98  public function save()
99  {
100  parent::save();
101 
102  $sOxId = $this->getEditObjectId();
103  $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
104 
105  $sShopID = oxRegistry::getSession()->getVariable("actshop");
106  $aParams['oxdiscount__oxshopid'] = $sShopID;
107 
108  $oDiscount = oxNew("oxDiscount");
109  if ($sOxId != "-1") {
110  $oDiscount->load($sOxId);
111  } else {
112  $aParams['oxdiscount__oxid'] = null;
113  }
114 
115  // checkbox handling
116  if (!isset($aParams['oxdiscount__oxactive'])) {
117  $aParams['oxdiscount__oxactive'] = 0;
118  }
119 
120 
121  //$aParams = $oAttr->ConvertNameArray2Idx( $aParams);
122  $oDiscount->setLanguage(0);
123  $oDiscount->assign($aParams);
124  $oDiscount->setLanguage($this->_iEditLang);
125  $oDiscount = oxRegistry::get("oxUtilsFile")->processFiles($oDiscount);
126  $oDiscount->save();
127 
128  // set oxid if inserted
129  $this->setEditObjectId($oDiscount->getId());
130  }
131 
137  public function saveinnlang()
138  {
139  parent::save();
140 
141  $sOxId = $this->getEditObjectId();
142  $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
143 
144  // shopid
145  $sShopID = oxRegistry::getSession()->getVariable("actshop");
146  $aParams['oxdiscount__oxshopid'] = $sShopID;
147  $oAttr = oxNew("oxdiscount");
148  if ($sOxId != "-1") {
149  $oAttr->load($sOxId);
150  } else {
151  $aParams['oxdiscount__oxid'] = null;
152  }
153  // checkbox handling
154  if (!isset($aParams['oxdiscount__oxactive'])) {
155  $aParams['oxdiscount__oxactive'] = 0;
156  }
157 
158 
159  //$aParams = $oAttr->ConvertNameArray2Idx( $aParams);
160  $oAttr->setLanguage(0);
161  $oAttr->assign($aParams);
162  $oAttr->setLanguage($this->_iEditLang);
163  $oAttr = oxRegistry::get("oxUtilsFile")->processFiles($oAttr);
164  $oAttr->save();
165 
166  // set oxid if inserted
167  $this->setEditObjectId($oAttr->getId());
168  }
169 }