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
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
00029 $this->_aViewData["updatelist"] = "1";
00030 }
00031
00032 if ( $soxId != "-1" && isset( $soxId ) ) {
00033
00034 $oOrder = oxNew( "oxorder" );
00035 $oOrder->load( $soxId);
00036
00037
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
00050 $oUser = oxNew( 'oxuser' );
00051 $oUser->load( $oOrder->oxorder__oxuserid->value );
00052
00053
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
00060 $this->_aViewData["aVouchers"] = $oOrder->getVoucherNrList();
00061 }
00062
00063 $this->_aViewData["sNowValue"] = date("Y-m-d H:i:s", oxUtilsDate::getInstance()->getTime());
00064 return "order_main.tpl";
00065 }
00066
00072 public function save()
00073 {
00074
00075 $soxId = oxConfig::getParameter( "oxid");
00076 $aParams = oxConfig::getParameter( "editval");
00077 $aDynvalues = oxConfig::getParameter( "dynvalue");
00078
00079
00080 $sShopID = oxSession::getVar( "actshop");
00081 $aParams['oxorder__oxshopid'] = $sShopID;
00082
00083 $oOrder = oxNew( "oxorder" );
00084 if ( $soxId != "-1") {
00085 $oOrder->load( $soxId);
00086 } else {
00087 $aParams['oxorder__oxid'] = null;
00088 }
00089
00090 $oOrder->assign( $aParams);
00091
00092 if ( isset( $aDynvalues)) {
00093
00094 $oPayment = oxNew( "oxuserpayment" );
00095 $oPayment->load( $oOrder->oxorder__oxpaymentid->value);
00096 $oPayment->oxuserpayments__oxvalue->setValue(oxUtils::getInstance()->assignValuesToText( $aDynvalues));
00097 $oPayment->save();
00098 }
00099
00100
00101 $oOrder->reloadDelivery( false );
00102
00103
00104 $oOrder->reloadDiscount( false );
00105
00106 $oOrder->recalculateOrder();
00107
00108
00109 if ( $soxId == "-1")
00110 oxSession::setVar( "saved_oxid", $oOrder->oxorder__oxid->value);
00111
00112
00113 $this->_aViewData["updatelist"] = "1";
00114 }
00115
00121 public function sendorder()
00122 {
00123 $soxId = oxConfig::getParameter( "oxid");
00124 $oOrder = oxNew( "oxorder" );
00125 $oOrder->load( $soxId);
00126
00127
00128 $timeout = oxUtilsDate::getInstance()->getTime();
00129 $now = date("Y-m-d H:i:s", $timeout);
00130 $oOrder->oxorder__oxsenddate->setValue($now);
00131 $oOrder->save();
00132
00133
00134 $oOrderArticles = $oOrder->getOrderArticles();
00135 foreach ( $oOrderArticles as $oxid=>$oArticle) {
00136
00137 if ( $oArticle->oxorderarticles__oxstorno->value == 1 )
00138 $oOrderArticles->offsetUnset($oxid);
00139 }
00140
00141 $blMail = oxConfig::getParameter( "sendmail");
00142 if ( isset( $blMail) && $blMail) {
00143
00144
00145 $oxEMail = oxNew( "oxemail" );
00146 $oxEMail->SendSendedNowMail( $oOrder );
00147 }
00148
00149 }
00150
00156 public function resetorder()
00157 {
00158 $soxId = oxConfig::getParameter( "oxid");
00159 $oOrder = oxNew( "oxorder" );
00160 $oOrder->load( $soxId);
00161
00162 $oOrder->oxorder__oxsenddate->setValue("0000-00-00 00:00:00");
00163 $oOrder->save();
00164
00165 }
00166
00173 public function changeDelSet()
00174 {
00175 $oOrder = oxNew( "oxorder" );
00176 if ( ( $sDelSetId = oxConfig::getParameter( "setDelSet" ) ) &&
00177 $oOrder->load( oxConfig::getParameter( "oxid" ) ) ) {
00178 $oOrder->oxorder__oxpaymenttype->setValue( "oxempty" );
00179 $oOrder->setDelivery( $sDelSetId );
00180 $oOrder->recalculateOrder();
00181 }
00182 }
00183
00190 public function changePayment()
00191 {
00192 $oOrder = oxNew( "oxorder" );
00193 if ( ( $sPayId = oxConfig::getParameter( "setPayment") ) &&
00194 $oOrder->load( oxConfig::getParameter( "oxid" ) ) ) {
00195 $oOrder->oxorder__oxpaymenttype->setValue( $sPayId );
00196 $oOrder->recalculateOrder();
00197 }
00198 }
00199 }