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