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 = oxConfig::getParameter( "oxid");
00022         // check if we right now saved a new entry
00023         $sSavedID = oxConfig::getParameter( "saved_oxid");
00024         if ( ($soxId == "-1" || !isset( $soxId)) && isset( $sSavedID) ) {
00025             $soxId = $sSavedID;
00026             oxSession::deleteVar( "saved_oxid");
00027             $this->_aViewData["oxid"] =  $soxId;
00028             // for reloading upper frame
00029             $this->_aViewData["updatelist"] =  "1";
00030         }
00031 
00032         if ( $soxId != "-1" && isset( $soxId)) {
00033             // load object
00034             $oOrder = oxNew( "oxorder" );
00035             $oOrder->Load( $soxId);
00036 
00037             // paid ?
00038             if ( $oOrder->oxorder__oxpaid->value != "0000-00-00 00:00:00") {
00039                 $oOrder->blIsPaid = true;
00040                 $oOrder->oxorder__oxpaid->setValue( oxUtilsDate::getInstance()->formatDBDate( $oOrder->oxorder__oxpaid->value));
00041             }
00042 
00043             $this->_aViewData["edit"] =  $oOrder;
00044             $this->_aViewData["paymentType"] =  $oOrder->getPaymentType();
00045 
00046             $this->_aViewData["oShipSet"] =  $oOrder->getShippingSetList();
00047             if ( $oOrder->oxorder__oxdeltype->value ) {
00048 
00049                 // order user
00050                 $oUser = oxNew( 'oxuser' );
00051                 $oUser->load( $oOrder->oxorder__oxuserid->value );
00052 
00053                 // order sum in default currency
00054                 $dPrice = $oOrder->oxorder__oxtotalbrutsum->value / $oOrder->oxorder__oxcurrate->value;
00055 
00056                 $this->_aViewData["oPayments"] =  oxPaymentList::getInstance()->getPaymentList( $oOrder->oxorder__oxdeltype->value, $dPrice, $oUser );
00057             }
00058 
00059             // any voucher used ?
00060             $this->_aViewData["aVouchers"] =  $oOrder->getVoucherNrList();
00061         }
00062 
00063         $this->_aViewData["sNowValue"] = date("Y-m-d H:i:s", oxUtilsDate::getInstance()->getTime());
00064 
00065         return "order_main.tpl";
00066     }
00067 
00073     public function save()
00074     {
00075 
00076         $soxId      = oxConfig::getParameter( "oxid");
00077         $aParams    = oxConfig::getParameter( "editval");
00078         $aDynvalues = oxConfig::getParameter( "dynvalue");
00079 
00080         $blChangeDelivery = false;
00081         $blChangeDiscount = false;
00082 
00083             // shopid
00084             $sShopID = oxSession::getVar( "actshop");
00085             $aParams['oxorder__oxshopid'] = $sShopID;
00086 
00087         $oOrder = oxNew( "oxorder" );
00088         if ( $soxId != "-1") {
00089             $oOrder->load( $soxId);
00090             if ( $oOrder->oxorder__oxdelcost->value != $aParams['oxorder__oxdelcost'] ) {
00091                 $blChangeDelivery = true;
00092             }
00093             if ( $oOrder->oxorder__oxdiscount->value != $aParams['oxorder__oxdiscount'] ) {
00094                 $blChangeDiscount = true;
00095             }
00096         } else {
00097             $aParams['oxorder__oxid'] = null;
00098         }
00099 
00100         $oOrder->assign( $aParams);
00101 
00102         if ( isset( $aDynvalues)) {
00103             // #411 Dodger
00104             $oPayment = oxNew( "oxuserpayment" );
00105             $oPayment->load( $oOrder->oxorder__oxpaymentid->value);
00106             $oPayment->oxuserpayments__oxvalue->setValue(oxUtils::getInstance()->assignValuesToText( $aDynvalues));
00107             $oPayment->save();
00108         }
00109 
00110         $oOrder->save();
00111 
00112         if ( $blChangeDelivery || $blChangeDiscount ) {
00113             $oOrder->recalculateOrder( array(), $blChangeDelivery, $blChangeDiscount );
00114         }
00115 
00116         // set oxid if inserted
00117         if ( $soxId == "-1")
00118             oxSession::setVar( "saved_oxid", $oOrder->oxorder__oxid->value);
00119 
00120         // reloading upper frame
00121         $this->_aViewData["updatelist"] =  "1";
00122     }
00123 
00129     public function sendorder()
00130     {
00131         $soxId  = oxConfig::getParameter( "oxid");
00132         $oOrder = oxNew( "oxorder" );
00133         $oOrder->load( $soxId);
00134 
00135         // #632A
00136         $timeout = oxUtilsDate::getInstance()->getTime(); //time();
00137         $now = date("Y-m-d H:i:s", $timeout);
00138         $oOrder->oxorder__oxsenddate->setValue($now);
00139         $oOrder->save();
00140 
00141         // #1071C
00142         $oOrderArticles = $oOrder->getOrderArticles();
00143         foreach ( $oOrderArticles as $oxid=>$oArticle) {
00144             // remove canceled articles from list
00145             if ( $oArticle->oxorderarticles__oxstorno->value == 1 )
00146                 $oOrderArticles->offsetUnset($oxid);
00147         }
00148 
00149         $blMail  = oxConfig::getParameter( "sendmail");
00150         if ( isset( $blMail) && $blMail) {
00151             // send eMail
00152 
00153             $oxEMail = oxNew( "oxemail" );
00154             $oxEMail->SendSendedNowMail( $oOrder );
00155         }
00156 
00157     }
00158 
00164     public function resetorder()
00165     {
00166         $soxId  = oxConfig::getParameter( "oxid");
00167         $oOrder = oxNew( "oxorder" );
00168         $oOrder->load( $soxId);
00169 
00170         $oOrder->oxorder__oxsenddate->setValue("0000-00-00 00:00:00");
00171         $oOrder->save();
00172 
00173     }
00174 
00181     public function changeDelSet()
00182     {
00183         $soxId  = oxConfig::getParameter( "oxid");
00184         $oOrder = oxNew( "oxorder" );
00185         if ($oOrder->load( $soxId)) {
00186             $sDelType = oxConfig::getParameter( "setDelSet");
00187             $oOrder->oxorder__oxdeltype->setValue($sDelType);
00188             $oOrder->oxorder__oxpaymenttype->setValue("oxempty");
00189             $oOrder->save();
00190 
00191             $oOrder->recalculateOrder( array() );
00192         }
00193     }
00194 
00201     public function changePayment()
00202     {
00203         $soxId  = oxConfig::getParameter( "oxid");
00204         $oOrder = oxNew( "oxorder" );
00205         if ($oOrder->load( $soxId)) {
00206             $sPayment = oxConfig::getParameter( "setPayment");
00207             $oOrder->oxorder__oxpaymenttype->setValue($sPayment);
00208             $oOrder->save();
00209 
00210             $oOrder->recalculateOrder( array() );
00211         }
00212     }
00213 }

Generated on Wed May 13 13:25:50 2009 for OXID eShop CE by  doxygen 1.5.5