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
00024 $oOrder = oxNew( "oxorder" );
00025 $oOrder->load( $soxId);
00026
00027
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
00040 $oUser = oxNew( 'oxuser' );
00041 $oUser->load( $oOrder->oxorder__oxuserid->value );
00042
00043
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
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 parent::save();
00065
00066 $soxId = $this->getEditObjectId();
00067 $aParams = oxConfig::getParameter( "editval" );
00068
00069
00070 $sShopID = oxSession::getVar( "actshop" );
00071 $aParams['oxorder__oxshopid'] = $sShopID;
00072
00073 $oOrder = oxNew( "oxorder" );
00074 if ( $soxId != "-1") {
00075 $oOrder->load( $soxId);
00076 } else {
00077 $aParams['oxorder__oxid'] = null;
00078 }
00079
00080 $oOrder->assign( $aParams);
00081
00082 $aDynvalues = oxConfig::getParameter( "dynvalue" );
00083 if ( isset( $aDynvalues ) ) {
00084
00085 $oPayment = oxNew( "oxuserpayment" );
00086 $oPayment->load( $oOrder->oxorder__oxpaymentid->value);
00087 $oPayment->oxuserpayments__oxvalue->setValue(oxUtils::getInstance()->assignValuesToText( $aDynvalues));
00088 $oPayment->save();
00089 }
00090
00091
00092 $oOrder->reloadDelivery( false );
00093
00094
00095 $oOrder->reloadDiscount( false );
00096
00097 $oOrder->recalculateOrder();
00098
00099
00100 $this->setEditObjectId( $oOrder->getId() );
00101 }
00102
00108 public function sendorder()
00109 {
00110 $soxId = $this->getEditObjectId();
00111 $oOrder = oxNew( "oxorder" );
00112 if ( $oOrder->load( $soxId ) ) {
00113
00114
00115 $oOrder->oxorder__oxsenddate->setValue( date( "Y-m-d H:i:s", oxUtilsDate::getInstance()->getTime() ) );
00116 $oOrder->save();
00117
00118
00119 $oOrderArticles = $oOrder->getOrderArticles();
00120 foreach ( $oOrderArticles as $sOxId => $oArticle ) {
00121
00122 if ( $oArticle->oxorderarticles__oxstorno->value == 1 ) {
00123 $oOrderArticles->offsetUnset( $sOxId );
00124 }
00125 }
00126
00127 if ( oxConfig::getParameter( "sendmail" ) ) {
00128
00129 $oEmail = oxNew( "oxemail" );
00130 $oEmail->sendSendedNowMail( $oOrder );
00131 }
00132
00133 }
00134 }
00135
00141 public function resetorder()
00142 {
00143 $oOrder = oxNew( "oxorder" );
00144 if ( $oOrder->load( $this->getEditObjectId() ) ) {
00145
00146 $oOrder->oxorder__oxsenddate->setValue("0000-00-00 00:00:00");
00147 $oOrder->save();
00148
00149 }
00150 }
00151
00158 public function changeDelSet()
00159 {
00160 $oOrder = oxNew( "oxorder" );
00161 if ( ( $sDelSetId = oxConfig::getParameter( "setDelSet" ) ) &&
00162 $oOrder->load( $this->getEditObjectId() ) ) {
00163 $oOrder->oxorder__oxpaymenttype->setValue( "oxempty" );
00164
00165 $oOrder->reloadDiscount( false );
00166 $oOrder->setDelivery( $sDelSetId );
00167 $oOrder->recalculateOrder();
00168 }
00169 }
00170
00177 public function changePayment()
00178 {
00179 $oOrder = oxNew( "oxorder" );
00180 if ( ( $sPayId = oxConfig::getParameter( "setPayment") ) &&
00181 $oOrder->load( $this->getEditObjectId() ) ) {
00182 $oOrder->oxorder__oxpaymenttype->setValue( $sPayId );
00183
00184 $oOrder->reloadDiscount( false );
00185 $oOrder->recalculateOrder();
00186 }
00187 }
00188 }