OXID eShop CE  4.8.10
 All Classes Files Functions Variables Pages
order_overview.php
Go to the documentation of this file.
1 <?php
2 
9 {
17  public function render()
18  {
19  $myConfig = $this->getConfig();
21 
22  $oOrder = oxNew( "oxOrder" );
23  $oCur = $myConfig->getActShopCurrencyObject();
24  $oLang = oxRegistry::getLang();
25 
26  $soxId = $this->getEditObjectId();
27  if ( $soxId != "-1" && isset( $soxId)) {
28  // load object
29  $oOrder->load( $soxId);
30 
31  $this->_aViewData["edit"] = $oOrder;
32  $this->_aViewData["aProductVats"] = $oOrder->getProductVats();
33  $this->_aViewData["orderArticles"] = $oOrder->getOrderArticles();
34  $this->_aViewData["giftCard"] = $oOrder->getGiftCard();
35  $this->_aViewData["paymentType"] = $this->_getPaymentType( $oOrder );
36  $this->_aViewData["deliveryType"] = $oOrder->getDelSet();
37  if ( $oOrder->oxorder__oxtsprotectcosts->value ) {
38  $this->_aViewData["tsprotectcosts"] = $oLang->formatCurrency( $oOrder->oxorder__oxtsprotectcosts->value, $oCur);
39  }
40  }
41 
42  // orders today
43  $dSum = $oOrder->getOrderSum(true);
44  $this->_aViewData["ordersum"] = $oLang->formatCurrency($dSum, $oCur);
45  $this->_aViewData["ordercnt"] = $oOrder->getOrderCnt(true);
46 
47  // ALL orders
48  $dSum = $oOrder->getOrderSum();
49  $this->_aViewData["ordertotalsum"] = $oLang->formatCurrency( $dSum, $oCur);
50  $this->_aViewData["ordertotalcnt"] = $oOrder->getOrderCnt();
51  $this->_aViewData["afolder"] = $myConfig->getConfigParam( 'aOrderfolder' );
52  $this->_aViewData["alangs"] = $oLang->getLanguageNames();
53 
54  $this->_aViewData["currency"] = $oCur;
55 
56  return "order_overview.tpl";
57  }
58 
68  protected function _getPaymentType( $oOrder )
69  {
70  if ( !( $oUserPayment = $oOrder->getPaymentType() ) && $oOrder->oxorder__oxpaymenttype->value ) {
71  $oPayment = oxNew( "oxPayment" );
72  if ( $oPayment->load( $oOrder->oxorder__oxpaymenttype->value ) ) {
73  // in case due to security reasons payment info was not kept in db
74  $oUserPayment = oxNew( "oxUserPayment" );
75  $oUserPayment->oxpayments__oxdesc = new oxField( $oPayment->oxpayments__oxdesc->value );
76  }
77  }
78 
79  return $oUserPayment;
80  }
81 
87  public function exportlex()
88  {
89  $sOrderNr = oxConfig::getParameter( "ordernr");
90  $sToOrderNr = oxConfig::getParameter( "toordernr");
91  $oImex = oxNew( "oximex" );
92  if ( ( $sLexware = $oImex->exportLexwareOrders( $sOrderNr, $sToOrderNr ) ) ) {
93  $oUtils = oxRegistry::getUtils();
94  $oUtils->setHeader( "Pragma: public" );
95  $oUtils->setHeader( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
96  $oUtils->setHeader( "Expires: 0" );
97  $oUtils->setHeader( "Content-type: application/x-download" );
98  $oUtils->setHeader( "Content-Length: ".strlen( $sLexware ) );
99  $oUtils->setHeader( "Content-Disposition: attachment; filename=intern.xml" );
100  $oUtils->showMessageAndExit( $sLexware );
101  }
102  }
108  public function createPDF()
109  {
110  $soxId = $this->getEditObjectId();
111  if ( $soxId != "-1" && isset( $soxId ) ) {
112  // load object
113  $oOrder = oxNew( "oxorder" );
114  if ( $oOrder->load( $soxId ) ) {
115  $oUtils = oxRegistry::getUtils();
116  $sTrimmedBillName = trim($oOrder->oxorder__oxbilllname->getRawValue());
117  $sFilename = $oOrder->oxorder__oxordernr->value . "_" . $sTrimmedBillName . ".pdf";
118  $sFilename = str_replace(" ", "_", $sFilename);
119  ob_start();
120  $oOrder->genPDF( $sFilename, oxConfig::getParameter( "pdflanguage" ) );
121  $sPDF = ob_get_contents();
122  ob_end_clean();
123  $oUtils->setHeader( "Pragma: public" );
124  $oUtils->setHeader( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
125  $oUtils->setHeader( "Expires: 0" );
126  $oUtils->setHeader( "Content-type: application/pdf" );
127  $oUtils->setHeader( "Content-Disposition: attachment; filename=".$sFilename );
128  oxRegistry::getUtils()->showMessageAndExit( $sPDF );
129  }
130  }
131  }
132 
138  public function exportDTAUS()
139  {
140  $oOrderList = oxNew( "oxList" );
141  $oOrderList->init( "oxOrder" );
142  $sSelect = "select * from oxorder where oxpaymenttype = 'oxiddebitnote'";
143 
144  if ( ( $iFromOrderNr = oxConfig::getParameter( "ordernr") ) ) {
145  $sSelect .= " and oxordernr >= $iFromOrderNr";
146  }
147 
148  $oOrderList->selectString( $sSelect );
149  if ( count( $oOrderList ) ) {
150  $oUserPayment = oxNew( "oxUserPayment" );
151  $oUtils = oxRegistry::getUtils();
152  $oShop = $this->getConfig()->getActiveShop();
153 
154  $sCompany = $oShop->oxshops__oxcompany->value;
155  $sRoutingNr = $this->_cleanup( $oShop->oxshops__oxbankcode->value ) + 1 - 1;
156  $sAccountNr = $this->_cleanup( $oShop->oxshops__oxbanknumber->value );
157  $sSubject = oxRegistry::getLang()->translateString( "order" );
158 
159  // can't be called with oxnew, as it only supports single constructor parameter
160  $oDtaus = oxNew( "oxDtausBuilder", $sCompany, $sRoutingNr, $sAccountNr );
161  foreach ( $oOrderList as $oOrder ) {
162  $oUserPayment->load( $oOrder->oxorder__oxpaymentid->value );
163  $aDynValues = $oUtils->assignValuesFromText( $oUserPayment->oxuserpayments__oxvalue->value );
164 
165  $sCustName = $aDynValues[3]->value;
166  $sRoutingNr = $this->_cleanup( $aDynValues[1]->value );
167  $sAccountNr = $this->_cleanup( $aDynValues[2]->value );
168 
169  $oDtaus->add( $sCustName, $sRoutingNr, $sAccountNr, $oOrder->getTotalOrderSum(), array( $oShop->oxshops__oxname->getRawValue(), $sSubject . " " . $oOrder->oxorder__oxordernr->value ) );
170  }
171 
172  $oUtils->setHeader( "Content-Disposition: attachment; filename=\"dtaus0.txt\"" );
173  $oUtils->setHeader( "Content-type: text/plain" );
174  $oUtils->setHeader( "Cache-control: public" );
175  $oUtils->showMessageAndExit( $oDtaus->create() );
176  }
177  }
178 
186  protected function _cleanup( $sValue )
187  {
188  return str_replace( " ", "", $sValue );
189  }
190 
196  public function sendorder()
197  {
198  $oOrder = oxNew( "oxorder" );
199  if ( $oOrder->load( $this->getEditObjectId() ) ) {
200  $oOrder->oxorder__oxsenddate = new oxField( date( "Y-m-d H:i:s", oxRegistry::get("oxUtilsDate")->getTime() ) );
201  $oOrder->save();
202 
203  // #1071C
204  $oOrderArticles = $oOrder->getOrderArticles();
205  foreach ( $oOrderArticles as $sOxid => $oArticle ) {
206  // remove canceled articles from list
207  if ( $oArticle->oxorderarticles__oxstorno->value == 1 ) {
208  $oOrderArticles->offsetUnset( $sOxid );
209  }
210  }
211 
212  if ( ( $blMail = oxConfig::getParameter( "sendmail" ) ) ) {
213  // send eMail
214  $oEmail = oxNew( "oxemail" );
215  $oEmail->sendSendedNowMail( $oOrder );
216  }
217  }
218  }
219 
225  public function resetorder()
226  {
227  $oOrder = oxNew( "oxorder" );
228  if ( $oOrder->load( $this->getEditObjectId() ) ) {
229  $oOrder->oxorder__oxsenddate = new oxField( "0000-00-00 00:00:00" );
230  $oOrder->save();
231  }
232  }
233 
239  public function canExport()
240  {
241  $blCan = false;
242  //V #529: check if PDF invoice module is active
243  $oModule = oxNew('oxmodule');
244  $oModule->load('invoicepdf');
245  if ( $oModule->isActive() ) {
246  $oDb = oxDb::getDb();
247  $sOrderId = $this->getEditObjectId();
248  $sTable = getViewName( "oxorderarticles" );
249  $sQ = "select count(oxid) from {$sTable} where oxorderid = ".$oDb->quote( $sOrderId )." and oxstorno = 0";
250  $blCan = (bool) $oDb->getOne( $sQ, false, false );
251  }
252  return $blCan;
253  }
254 
260  public function canResetShippingDate()
261  {
262  $oOrder = oxNew( "oxorder" );
263  $blCan = false;
264  if ( $oOrder->load( $this->getEditObjectId() ) ) {
265  $blCan = $oOrder->oxorder__oxstorno->value == "0" &&
266  !( $oOrder->oxorder__oxsenddate->value == "0000-00-00 00:00:00" || $oOrder->oxorder__oxsenddate->value == "-" );
267  }
268  return $blCan;
269  }
270 }