order_main.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class Order_Main extends oxAdminDetails
00009 {
00017     public function render()
00018     {
00019         parent::render();
00020 
00021         $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
00022         if ( $soxId != "-1" && isset( $soxId ) ) {
00023             // load object
00024             $oOrder = oxNew( "oxorder" );
00025             $oOrder->load( $soxId);
00026 
00027             // paid ?
00028             if ( $oOrder->oxorder__oxpaid->value != "0000-00-00 00:00:00") {
00029                 $oOrder->blIsPaid = true;
00030                 $oOrder->oxorder__oxpaid = new oxField( oxUtilsDate::getInstance()->formatDBDate( $oOrder->oxorder__oxpaid->value ) );
00031             }
00032 
00033             $this->_aViewData["edit"] =  $oOrder;
00034             $this->_aViewData["paymentType"] =  $oOrder->getPaymentType();
00035 
00036             $this->_aViewData["oShipSet"] =  $oOrder->getShippingSetList();
00037             if ( $oOrder->oxorder__oxdeltype->value ) {
00038 
00039                 // order user
00040                 $oUser = oxNew( 'oxuser' );
00041                 $oUser->load( $oOrder->oxorder__oxuserid->value );
00042 
00043                 // order sum in default currency
00044                 $dPrice = $oOrder->oxorder__oxtotalbrutsum->value / $oOrder->oxorder__oxcurrate->value;
00045 
00046                 $this->_aViewData["oPayments"] = oxPaymentList::getInstance()->getPaymentList( $oOrder->oxorder__oxdeltype->value, $dPrice, $oUser );
00047             }
00048 
00049             // any voucher used ?
00050             $this->_aViewData["aVouchers"] =  $oOrder->getVoucherNrList();
00051         }
00052 
00053         $this->_aViewData["sNowValue"] = date("Y-m-d H:i:s", oxUtilsDate::getInstance()->getTime());
00054         return "order_main.tpl";
00055     }
00056 
00062     public function save()
00063     {
00064 
00065         $soxId = $this->getEditObjectId();
00066         $aParams    = oxConfig::getParameter( "editval" );
00067 
00068             // shopid
00069             $sShopID = oxSession::getVar( "actshop" );
00070             $aParams['oxorder__oxshopid'] = $sShopID;
00071 
00072         $oOrder = oxNew( "oxorder" );
00073         if ( $soxId != "-1") {
00074             $oOrder->load( $soxId);
00075         } else {
00076             $aParams['oxorder__oxid'] = null;
00077         }
00078 
00079         $oOrder->assign( $aParams);
00080 
00081         $aDynvalues = oxConfig::getParameter( "dynvalue" );
00082         if ( isset( $aDynvalues ) ) {
00083             // #411 Dodger
00084             $oPayment = oxNew( "oxuserpayment" );
00085             $oPayment->load( $oOrder->oxorder__oxpaymentid->value);
00086             $oPayment->oxuserpayments__oxvalue->setValue(oxUtils::getInstance()->assignValuesToText( $aDynvalues));
00087             $oPayment->save();
00088         }
00089 
00090         // keeps old delivery cost
00091         $oOrder->reloadDelivery( false );
00092 
00093         // keeps old discount
00094         $oOrder->reloadDiscount( false );
00095 
00096         $oOrder->recalculateOrder();
00097 
00098         // set oxid if inserted
00099         $this->setEditObjectId( $oOrder->getId() );
00100     }
00101 
00107     public function sendorder()
00108     {
00109         $soxId = $this->getEditObjectId();
00110         $oOrder = oxNew( "oxorder" );
00111         if ( $oOrder->load( $soxId ) ) {
00112 
00113             // #632A
00114             $oOrder->oxorder__oxsenddate->setValue( date( "Y-m-d H:i:s", oxUtilsDate::getInstance()->getTime() ) );
00115             $oOrder->save();
00116 
00117             // #1071C
00118             $oOrderArticles = $oOrder->getOrderArticles();
00119             foreach ( $oOrderArticles as $sOxId => $oArticle ) {
00120                 // remove canceled articles from list
00121                 if ( $oArticle->oxorderarticles__oxstorno->value == 1 ) {
00122                     $oOrderArticles->offsetUnset( $sOxId );
00123                 }
00124             }
00125 
00126             if ( oxConfig::getParameter( "sendmail" ) ) {
00127                 // send eMail
00128                 $oEmail = oxNew( "oxemail" );
00129                 $oEmail->sendSendedNowMail( $oOrder );
00130             }
00131 
00132         }
00133     }
00134 
00140     public function resetorder()
00141     {
00142         $oOrder = oxNew( "oxorder" );
00143         if ( $oOrder->load( $this->getEditObjectId() ) ) {
00144 
00145             $oOrder->oxorder__oxsenddate->setValue("0000-00-00 00:00:00");
00146             $oOrder->save();
00147 
00148         }
00149     }
00150 
00157     public function changeDelSet()
00158     {
00159         $oOrder = oxNew( "oxorder" );
00160         if ( ( $sDelSetId = oxConfig::getParameter( "setDelSet" ) ) &&
00161              $oOrder->load( $this->getEditObjectId() ) ) {
00162             $oOrder->oxorder__oxpaymenttype->setValue( "oxempty" );
00163             // keeps old discount
00164             $oOrder->reloadDiscount( false );
00165             $oOrder->setDelivery( $sDelSetId );
00166             $oOrder->recalculateOrder();
00167         }
00168     }
00169 
00176     public function changePayment()
00177     {
00178         $oOrder = oxNew( "oxorder" );
00179         if ( ( $sPayId = oxConfig::getParameter( "setPayment") ) &&
00180              $oOrder->load( $this->getEditObjectId() ) ) {
00181             $oOrder->oxorder__oxpaymenttype->setValue( $sPayId );
00182             // keeps old discount
00183             $oOrder->reloadDiscount( false );
00184             $oOrder->recalculateOrder();
00185         }
00186     }
00187 }