order_main.php

Go to the documentation of this file.
00001 <?php
00002 
00009 class Order_Main extends oxAdminDetails
00010 {
00018     public function render()
00019     {
00020         parent::render();
00021 
00022         $soxId = oxConfig::getParameter( "oxid");
00023         // check if we right now saved a new entry
00024         $sSavedID = oxConfig::getParameter( "saved_oxid");
00025         if ( ($soxId == "-1" || !isset( $soxId)) && isset( $sSavedID) ) {
00026             $soxId = $sSavedID;
00027             oxSession::deleteVar( "saved_oxid");
00028             $this->_aViewData["oxid"] =  $soxId;
00029             // for reloading upper frame
00030             $this->_aViewData["updatelist"] =  "1";
00031         }
00032 
00033         if ( $soxId != "-1" && isset( $soxId)) {
00034             // load object
00035             $oOrder = oxNew( "oxorder" );
00036             $oOrder->Load( $soxId);
00037 
00038             // paid ?
00039             if ( $oOrder->oxorder__oxpaid->value != "0000-00-00 00:00:00") {
00040                 $oOrder->blIsPaid = true;
00041                 $oOrder->oxorder__oxpaid->setValue( oxUtilsDate::getInstance()->formatDBDate( $oOrder->oxorder__oxpaid->value));
00042             }
00043 
00044             $this->_aViewData["edit"] =  $oOrder;
00045             $this->_aViewData["paymentType"] =  $oOrder->getPaymentType();
00046 
00047             $this->_aViewData["oShipSet"] =  $oOrder->getShippingSetList();
00048             if ( $oOrder->oxorder__oxdeltype->value ) {
00049 
00050                 // order user
00051                 $oUser = oxNew( 'oxuser' );
00052                 $oUser->load( $oOrder->oxorder__oxuserid->value );
00053 
00054                 // order sum in default currency
00055                 $dPrice = $oOrder->oxorder__oxtotalbrutsum->value / $oOrder->oxorder__oxcurrate->value;
00056 
00057                 $this->_aViewData["oPayments"] =  oxPaymentList::getInstance()->getPaymentList( $oOrder->oxorder__oxdeltype->value, $dPrice, $oUser );
00058             }
00059 
00060             // any voucher used ?
00061             $this->_aViewData["aVouchers"] =  $oOrder->getVoucherNrList();
00062         }
00063 
00064         $this->_aViewData["sNowValue"] = date("Y-m-d H:i:s", oxUtilsDate::getInstance()->getTime());
00065 
00066         return "order_main.tpl";
00067     }
00068 
00074     public function save()
00075     {
00076 
00077         $soxId      = oxConfig::getParameter( "oxid");
00078         $aParams    = oxConfig::getParameter( "editval");
00079         $aDynvalues = oxConfig::getParameter( "dynvalue");
00080 
00081             // shopid
00082             $sShopID = oxSession::getVar( "actshop");
00083             $aParams['oxorder__oxshopid'] = $sShopID;
00084 
00085         $oOrder = oxNew( "oxorder" );
00086         if ( $soxId != "-1")
00087             $oOrder->load( $soxId);
00088         else
00089             $aParams['oxorder__oxid'] = null;
00090 
00091         $oOrder->assign( $aParams);
00092 
00093         if ( isset( $aDynvalues)) {
00094             // #411 Dodger
00095             $oPayment = oxNew( "oxuserpayment" );
00096             $oPayment->load( $oOrder->oxorder__oxpaymentid->value);
00097             $oPayment->oxuserpayments__oxvalue->setValue(oxUtils::getInstance()->assignValuesToText( $aDynvalues));
00098             $oPayment->save();
00099         }
00100 
00101         $oOrder->save();
00102 
00103         // set oxid if inserted
00104         if ( $soxId == "-1")
00105             oxSession::setVar( "saved_oxid", $oOrder->oxorder__oxid->value);
00106 
00107 
00108         return $this->autosave();
00109     }
00110 
00116     public function sendorder()
00117     {
00118         $soxId  = oxConfig::getParameter( "oxid");
00119         $oOrder = oxNew( "oxorder" );
00120         $oOrder->load( $soxId);
00121 
00122         // #632A
00123         $timeout = oxUtilsDate::getInstance()->getTime(); //time();
00124         $now = date("Y-m-d H:i:s", $timeout);
00125         $oOrder->oxorder__oxsenddate->setValue($now);
00126         $oOrder->save();
00127 
00128         // #1071C
00129         $oOrderArticles = $oOrder->getOrderArticles();
00130         foreach ( $oOrderArticles as $oxid=>$oArticle) {
00131             // remove canceled articles from list
00132             if ( $oArticle->oxorderarticles__oxstorno->value == 1 )
00133                 $oOrderArticles->offsetUnset($oxid);
00134         }
00135 
00136         $blMail  = oxConfig::getParameter( "sendmail");
00137         if ( isset( $blMail) && $blMail) {
00138             // send eMail
00139 
00140             $oxEMail = oxNew( "oxemail" );
00141             $oxEMail->SendSendedNowMail( $oOrder );
00142         }
00143 
00144     }
00145 
00151     public function resetorder()
00152     {
00153         $soxId  = oxConfig::getParameter( "oxid");
00154         $oOrder = oxNew( "oxorder" );
00155         $oOrder->load( $soxId);
00156 
00157         $oOrder->oxorder__oxsenddate->setValue("0000-00-00 00:00:00");
00158         $oOrder->save();
00159 
00160     }
00161 
00168     public function changeDelSet()
00169     {
00170         $soxId  = oxConfig::getParameter( "oxid");
00171         $oOrder = oxNew( "oxorder" );
00172         if ($oOrder->load( $soxId)) {
00173             $sDelType = oxConfig::getParameter( "setDelSet");
00174             $oOrder->oxorder__oxdeltype->setValue($sDelType);
00175             $oOrder->oxorder__oxpaymenttype->setValue("oxempty");
00176             $oOrder->save();
00177 
00178             $oOrder->recalculateOrder( array() );
00179         }
00180     }
00181 
00188     public function changePayment()
00189     {
00190         $soxId  = oxConfig::getParameter( "oxid");
00191         $oOrder = oxNew( "oxorder" );
00192         if ($oOrder->Load( $soxId)) {
00193             $sPayment = oxConfig::getParameter( "setPayment");
00194             $oOrder->oxorder__oxpaymenttype->setValue($sPayment);
00195             $oOrder->save();
00196 
00197             $oOrder->recalculateOrder( array() );
00198         }
00199     }
00200 }

Generated on Thu Dec 4 12:04:55 2008 for OXID eShop CE by  doxygen 1.5.5