OXID eShop CE  4.8.12
 All Classes Files Functions Variables Pages
order_main.php
Go to the documentation of this file.
1 <?php
2 
9 {
17  public function render()
18  {
20 
21  $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
22  if ( $soxId != "-1" && isset( $soxId ) ) {
23  // load object
24  $oOrder = oxNew( "oxorder" );
25  $oOrder->load( $soxId);
26 
27 
28  // paid ?
29  if ( $oOrder->oxorder__oxpaid->value != "0000-00-00 00:00:00") {
30  $oOrder->blIsPaid = true;
31  $oOrder->oxorder__oxpaid = new oxField( oxRegistry::get("oxUtilsDate")->formatDBDate( $oOrder->oxorder__oxpaid->value ) );
32  }
33 
34 
35  $this->_aViewData["edit"] = $oOrder;
36  $this->_aViewData["paymentType"] = $oOrder->getPaymentType();
37  $this->_aViewData["oShipSet"] = $oOrder->getShippingSetList();
38 
39 
40  if ( $oOrder->oxorder__oxdeltype->value ) {
41 
42  // order user
43  $oUser = oxNew( 'oxuser' );
44  $oUser->load( $oOrder->oxorder__oxuserid->value );
45 
46  // order sum in default currency
47  $dPrice = $oOrder->oxorder__oxtotalbrutsum->value / $oOrder->oxorder__oxcurrate->value;
48 
49  $this->_aViewData["oPayments"] = oxRegistry::get("oxPaymentList")->getPaymentList( $oOrder->oxorder__oxdeltype->value, $dPrice, $oUser );
50  }
51 
52  // any voucher used ?
53  $this->_aViewData["aVouchers"] = $oOrder->getVoucherNrList();
54  }
55 
56  $this->_aViewData["sNowValue"] = date("Y-m-d H:i:s", oxRegistry::get("oxUtilsDate")->getTime());
57  return "order_main.tpl";
58  }
59 
65  public function save()
66  {
67  parent::save();
68 
69  $soxId = $this->getEditObjectId();
70  $aParams = oxConfig::getParameter( "editval" );
71 
72  // shopid
73  $sShopID = oxSession::getVar( "actshop" );
74  $aParams['oxorder__oxshopid'] = $sShopID;
75 
76  $oOrder = oxNew( "oxorder" );
77  if ( $soxId != "-1") {
78  $oOrder->load( $soxId);
79  } else {
80  $aParams['oxorder__oxid'] = null;
81  }
82 
83  //change payment
84  $sPayId = oxConfig::getParameter( "setPayment");
85  if ($sPayId != $oOrder->oxorder__oxpaymenttype->value) {
86  $aParams['oxorder__oxpaymenttype'] = $sPayId;
87  }
88 
89  $oOrder->assign( $aParams);
90 
91  $aDynvalues = oxConfig::getParameter( "dynvalue" );
92  if ( isset( $aDynvalues ) ) {
93  $oPayment = oxNew( "oxuserpayment" );
94  $oPayment->load( $oOrder->oxorder__oxpaymentid->value);
95  $oPayment->oxuserpayments__oxvalue->setValue(oxRegistry::getUtils()->assignValuesToText( $aDynvalues));
96  $oPayment->save();
97  }
98  //change delivery set
99  $sDelSetId = oxConfig::getParameter( "setDelSet");
100  if ($sDelSetId != $oOrder->oxorder__oxdeltype->value) {
101  $oOrder->oxorder__oxpaymenttype->setValue( "oxempty" );
102  $oOrder->setDelivery( $sDelSetId );
103  } else {
104  // keeps old delivery cost
105  $oOrder->reloadDelivery( false );
106  }
107 
108  // keeps old discount
109  $oOrder->reloadDiscount( false );
110 
111  $oOrder->recalculateOrder();
112 
113 
114 
115  // set oxid if inserted
116  $this->setEditObjectId( $oOrder->getId() );
117  }
118 
124  public function sendorder()
125  {
126  $soxId = $this->getEditObjectId();
127  $oOrder = oxNew( "oxorder" );
128  if ( $oOrder->load( $soxId ) ) {
129 
130  // #632A
131  $oOrder->oxorder__oxsenddate = new oxField( date( "Y-m-d H:i:s", oxRegistry::get("oxUtilsDate")->getTime() ) );
132  $oOrder->save();
133 
134  // #1071C
135  $oOrderArticles = $oOrder->getOrderArticles( true );
136  if ( oxConfig::getParameter( "sendmail" ) ) {
137  // send eMail
138  $oEmail = oxNew( "oxemail" );
139  $oEmail->sendSendedNowMail( $oOrder );
140  }
141 
142  }
143  }
144 
150  public function senddownloadlinks()
151  {
152  $soxId = $this->getEditObjectId();
153  $oOrder = oxNew( "oxorder" );
154  if ( $oOrder->load( $soxId ) ) {
155  $oEmail = oxNew( "oxemail" );
156  $oEmail->sendDownloadLinksMail( $oOrder );
157  }
158  }
159 
165  public function resetorder()
166  {
167  $oOrder = oxNew( "oxorder" );
168  if ( $oOrder->load( $this->getEditObjectId() ) ) {
169 
170  $oOrder->oxorder__oxsenddate = new oxField("0000-00-00 00:00:00");
171  $oOrder->save();
172 
173  }
174  }
175 }