OXID eShop CE  4.10.2
 All Classes Namespaces Files Functions Variables Pages
order_overview.php
Go to the documentation of this file.
1 <?php
2 
9 {
10 
18  public function render()
19  {
20  $myConfig = $this->getConfig();
22 
23  $oOrder = oxNew("oxOrder");
24  $oCur = $myConfig->getActShopCurrencyObject();
25  $oLang = oxRegistry::getLang();
26 
27  $soxId = $this->getEditObjectId();
28  if ($soxId != "-1" && isset($soxId)) {
29  // load object
30  $oOrder->load($soxId);
31 
32  $this->_aViewData["edit"] = $oOrder;
33  $this->_aViewData["aProductVats"] = $oOrder->getProductVats();
34  $this->_aViewData["orderArticles"] = $oOrder->getOrderArticles();
35  $this->_aViewData["giftCard"] = $oOrder->getGiftCard();
36  $this->_aViewData["paymentType"] = $this->_getPaymentType($oOrder);
37  $this->_aViewData["deliveryType"] = $oOrder->getDelSet();
38  $sTsProtectsField = 'oxorder__oxtsprotectcosts';
39  if ($oOrder->$sTsProtectsField->value) {
40  $this->_aViewData["tsprotectcosts"] = $oLang->formatCurrency($oOrder->$sTsProtectsField->value, $oCur);
41  }
42  }
43 
44  // orders today
45  $dSum = $oOrder->getOrderSum(true);
46  $this->_aViewData["ordersum"] = $oLang->formatCurrency($dSum, $oCur);
47  $this->_aViewData["ordercnt"] = $oOrder->getOrderCnt(true);
48 
49  // ALL orders
50  $dSum = $oOrder->getOrderSum();
51  $this->_aViewData["ordertotalsum"] = $oLang->formatCurrency($dSum, $oCur);
52  $this->_aViewData["ordertotalcnt"] = $oOrder->getOrderCnt();
53  $this->_aViewData["afolder"] = $myConfig->getConfigParam('aOrderfolder');
54  $this->_aViewData["alangs"] = $oLang->getLanguageNames();
55 
56  $this->_aViewData["currency"] = $oCur;
57 
58  return "order_overview.tpl";
59  }
60 
70  protected function _getPaymentType($oOrder)
71  {
72  if (!($oUserPayment = $oOrder->getPaymentType()) && $oOrder->oxorder__oxpaymenttype->value) {
73  $oPayment = oxNew("oxPayment");
74  if ($oPayment->load($oOrder->oxorder__oxpaymenttype->value)) {
75  // in case due to security reasons payment info was not kept in db
76  $oUserPayment = oxNew("oxUserPayment");
77  $oUserPayment->oxpayments__oxdesc = new oxField($oPayment->oxpayments__oxdesc->value);
78  }
79  }
80 
81  return $oUserPayment;
82  }
83 
89  public function exportlex()
90  {
91  $sOrderNr = oxRegistry::getConfig()->getRequestParameter("ordernr");
92  $sToOrderNr = oxRegistry::getConfig()->getRequestParameter("toordernr");
93  $oImex = oxNew("oximex");
94  if (($sLexware = $oImex->exportLexwareOrders($sOrderNr, $sToOrderNr))) {
95  $oUtils = oxRegistry::getUtils();
96  $oUtils->setHeader("Pragma: public");
97  $oUtils->setHeader("Cache-Control: must-revalidate, post-check=0, pre-check=0");
98  $oUtils->setHeader("Expires: 0");
99  $oUtils->setHeader("Content-type: application/x-download");
100  $oUtils->setHeader("Content-Length: " . strlen($sLexware));
101  $oUtils->setHeader("Content-Disposition: attachment; filename=intern.xml");
102  $oUtils->showMessageAndExit($sLexware);
103  }
104  }
105 
113  public function makeValidFileName($sFilename)
114  {
115  $sFilename = preg_replace('/[\s]+/', '_', $sFilename);
116  $sFilename = preg_replace('/[^a-zA-Z0-9_\.-]/', '', $sFilename);
117 
118  return str_replace(' ', '_', $sFilename);
119  }
120 
126  public function createPDF()
127  {
128  $soxId = $this->getEditObjectId();
129  if ($soxId != "-1" && isset($soxId)) {
130  // load object
131  $oOrder = oxNew("oxorder");
132  if ($oOrder->load($soxId)) {
133  $oUtils = oxRegistry::getUtils();
134  $sTrimmedBillName = trim($oOrder->oxorder__oxbilllname->getRawValue());
135  $sFilename = $oOrder->oxorder__oxordernr->value . "_" . $sTrimmedBillName . ".pdf";
136  $sFilename = $this->makeValidFileName($sFilename);
137  ob_start();
138  $oOrder->genPDF($sFilename, oxRegistry::getConfig()->getRequestParameter("pdflanguage"));
139  $sPDF = ob_get_contents();
140  ob_end_clean();
141  $oUtils->setHeader("Pragma: public");
142  $oUtils->setHeader("Cache-Control: must-revalidate, post-check=0, pre-check=0");
143  $oUtils->setHeader("Expires: 0");
144  $oUtils->setHeader("Content-type: application/pdf");
145  $oUtils->setHeader("Content-Disposition: attachment; filename=" . $sFilename);
146  oxRegistry::getUtils()->showMessageAndExit($sPDF);
147  }
148  }
149  }
150 
151 
155  public function sendorder()
156  {
157  $oOrder = oxNew("oxorder");
158  if ($oOrder->load($this->getEditObjectId())) {
159  $oOrder->oxorder__oxsenddate = new oxField(date("Y-m-d H:i:s", oxRegistry::get("oxUtilsDate")->getTime()));
160  $oOrder->save();
161 
162  // #1071C
163  $oOrderArticles = $oOrder->getOrderArticles();
164  foreach ($oOrderArticles as $sOxid => $oArticle) {
165  // remove canceled articles from list
166  if ($oArticle->oxorderarticles__oxstorno->value == 1) {
167  $oOrderArticles->offsetUnset($sOxid);
168  }
169  }
170 
171  if (($blMail = oxRegistry::getConfig()->getRequestParameter("sendmail"))) {
172  // send eMail
173  $oEmail = oxNew("oxemail");
174  $oEmail->sendSendedNowMail($oOrder);
175  }
176  }
177  }
178 
182  public function resetorder()
183  {
184  $oOrder = oxNew("oxorder");
185  if ($oOrder->load($this->getEditObjectId())) {
186  $oOrder->oxorder__oxsenddate = new oxField("0000-00-00 00:00:00");
187  $oOrder->save();
188  }
189  }
190 
198  public function canExport()
199  {
200  $blCan = false;
201  //V #529: check if PDF invoice module is active
202  $oModule = oxNew('oxmodule');
203  $oModule->load('invoicepdf');
204  if ($oModule->isActive()) {
205  $oDb = oxDb::getDb();
206  $sOrderId = $this->getEditObjectId();
207  $sTable = getViewName("oxorderarticles");
208  $sQ = "select count(oxid) from {$sTable} where oxorderid = " . $oDb->quote($sOrderId) . " and oxstorno = 0";
209  $blCan = (bool) $oDb->getOne($sQ, false, false);
210  }
211 
212  return $blCan;
213  }
214 
220  public function canResetShippingDate()
221  {
222  $oOrder = oxNew("oxorder");
223  $blCan = false;
224  if ($oOrder->load($this->getEditObjectId())) {
225  $blCan = $oOrder->oxorder__oxstorno->value == "0" &&
226  !($oOrder->oxorder__oxsenddate->value == "0000-00-00 00:00:00" || $oOrder->oxorder__oxsenddate->value == "-");
227  }
228 
229  return $blCan;
230  }
231 }