OXID eShop CE  4.10.7
 All Classes Namespaces Files Functions Variables Pages
delivery_main.php
Go to the documentation of this file.
1 <?php
2 
10 {
11 
18  public function render()
19  {
20  $myConfig = $this->getConfig();
21 
23 
24  $oLang = oxRegistry::getLang();
25  $iLang = $oLang->getTplLanguage();
26 
27  // remove itm from list
28  unset($this->_aViewData["sumtype"][2]);
29 
30  // Deliverytypes
31  $aDelTypes = array();
32  $oType = new stdClass();
33  $oType->sType = "a"; // amount
34  $oType->sDesc = $oLang->translateString("amount", $iLang);
35  $aDelTypes['a'] = $oType;
36  $oType = new stdClass();
37  $oType->sType = "s"; // Size
38  $oType->sDesc = $oLang->translateString("size", $iLang);
39  $aDelTypes['s'] = $oType;
40  $oType = new stdClass();
41  $oType->sType = "w"; // Weight
42  $oType->sDesc = $oLang->translateString("weight", $iLang);
43  $aDelTypes['w'] = $oType;
44  $oType = new stdClass();
45  $oType->sType = "p"; // Price
46  $oType->sDesc = $oLang->translateString("price", $iLang);
47  $aDelTypes['p'] = $oType;
48 
49  $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
50  if ($soxId != "-1" && isset($soxId)) {
51  // load object
52  $oDelivery = oxNew("oxdelivery");
53  $oDelivery->loadInLang($this->_iEditLang, $soxId);
54 
55  $oOtherLang = $oDelivery->getAvailableInLangs();
56  if (!isset($oOtherLang[$this->_iEditLang])) {
57  // echo "language entry doesn't exist! using: ".key($oOtherLang);
58  $oDelivery->loadInLang(key($oOtherLang), $soxId);
59  }
60 
61  $this->_aViewData["edit"] = $oDelivery;
62 
63 
64  // remove already created languages
65  $aLang = array_diff($oLang->getLanguageNames(), $oOtherLang);
66  if (count($aLang)) {
67  $this->_aViewData["posslang"] = $aLang;
68  }
69 
70  foreach ($oOtherLang as $id => $language) {
71  $oLang = new stdClass();
72  $oLang->sLangDesc = $language;
73  $oLang->selected = ($id == $this->_iEditLang);
74  $this->_aViewData["otherlang"][$id] = clone $oLang;
75  }
76 
77  // set selected delivery type
78  if (!$oDelivery->oxdelivery__oxdeltype->value) {
79  $oDelivery->oxdelivery__oxdeltype = new oxField("a"); // default
80  }
81  $aDelTypes[$oDelivery->oxdelivery__oxdeltype->value]->selected = true;
82  }
83 
84  $this->_aViewData["deltypes"] = $aDelTypes;
85 
86  if (oxRegistry::getConfig()->getRequestParameter("aoc")) {
87  $oDeliveryMainAjax = oxNew('delivery_main_ajax');
88  $this->_aViewData['oxajax'] = $oDeliveryMainAjax->getColumns();
89 
90  return "popups/delivery_main.tpl";
91  }
92 
93  return "delivery_main.tpl";
94  }
95 
101  public function save()
102  {
103  parent::save();
104 
105  $soxId = $this->getEditObjectId();
106  $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
107 
108  // shopid
109  $sShopID = oxRegistry::getSession()->getVariable("actshop");
110  $aParams['oxdelivery__oxshopid'] = $sShopID;
111 
112  $oDelivery = oxNew("oxdelivery");
113 
114  if ($soxId != "-1") {
115  $oDelivery->loadInLang($this->_iEditLang, $soxId);
116  } else {
117  $aParams['oxdelivery__oxid'] = null;
118  }
119 
120  // checkbox handling
121  if (!isset($aParams['oxdelivery__oxactive'])) {
122  $aParams['oxdelivery__oxactive'] = 0;
123  }
124 
125  if (!isset($aParams['oxdelivery__oxfixed'])) {
126  $aParams['oxdelivery__oxfixed'] = 0;
127  }
128 
129  if (!isset($aParams['oxdelivery__oxfinalize'])) {
130  $aParams['oxdelivery__oxfinalize'] = 0;
131  }
132 
133  if (!isset($aParams['oxdelivery__oxsort'])) {
134  $aParams['oxdelivery__oxsort'] = 9999;
135  }
136 
137 
138  $oDelivery->setLanguage(0);
139  $oDelivery->assign($aParams);
140  $oDelivery->setLanguage($this->_iEditLang);
141  $oDelivery = oxRegistry::get("oxUtilsFile")->processFiles($oDelivery);
142  $oDelivery->save();
143 
144  // set oxid if inserted
145  $this->setEditObjectId($oDelivery->getId());
146  }
147 
153  public function saveinnlang()
154  {
155  $soxId = $this->getEditObjectId();
156  $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
157 
158  // shopid
159  $sShopID = oxRegistry::getSession()->getVariable("actshop");
160  $aParams['oxdelivery__oxshopid'] = $sShopID;
161 
162  $oDelivery = oxNew("oxdelivery");
163 
164  if ($soxId != "-1") {
165  $oDelivery->loadInLang($this->_iEditLang, $soxId);
166  } else {
167  $aParams['oxdelivery__oxid'] = null;
168  }
169 
170  // checkbox handling
171  if (!isset($aParams['oxdelivery__oxactive'])) {
172  $aParams['oxdelivery__oxactive'] = 0;
173  }
174  if (!isset($aParams['oxdelivery__oxfixed'])) {
175  $aParams['oxdelivery__oxfixed'] = 0;
176  }
177 
178 
179  $oDelivery->setLanguage(0);
180  $oDelivery->assign($aParams);
181  $oDelivery->setLanguage($this->_iEditLang);
182  $oDelivery = oxRegistry::get("oxUtilsFile")->processFiles($oDelivery);
183  $oDelivery->save();
184 
185  // set oxid if inserted
186  $this->setEditObjectId($oDelivery->getId());
187  }
188 }