Go to the documentation of this file.00001 <?php
00002
00008 class Order_Overview extends oxAdminDetails
00009 {
00017 public function render()
00018 {
00019 $myConfig = $this->getConfig();
00020 parent::render();
00021
00022 $oOrder = oxNew( "oxorder" );
00023 $oCur = $myConfig->getActShopCurrencyObject();
00024 $oLang = oxLang::getInstance();
00025
00026 $soxId = $this->getEditObjectId();
00027 if ( $soxId != "-1" && isset( $soxId)) {
00028
00029 $oOrder->load( $soxId);
00030
00031 $this->_aViewData["edit"] = $oOrder;
00032 $this->_aViewData["aProductVats"] = $oOrder->getProductVats();
00033 $this->_aViewData["orderArticles"] = $oOrder->getOrderArticles();
00034 $this->_aViewData["giftCard"] = $oOrder->getGiftCard();
00035 $this->_aViewData["paymentType"] = $this->_getPaymentType( $oOrder );
00036 $this->_aViewData["deliveryType"] = $oOrder->getDelSet();
00037 if ( $oOrder->oxorder__oxtsprotectcosts->value ) {
00038 $this->_aViewData["tsprotectcosts"] = $oLang->formatCurrency( $oOrder->oxorder__oxtsprotectcosts->value, $oCur);
00039 }
00040 }
00041
00042
00043 $dSum = $oOrder->getOrderSum(true);
00044 $this->_aViewData["ordersum"] = $oLang->formatCurrency($dSum, $oCur);
00045 $this->_aViewData["ordercnt"] = $oOrder->getOrderCnt(true);
00046
00047
00048 $dSum = $oOrder->getOrderSum();
00049 $this->_aViewData["ordertotalsum"] = $oLang->formatCurrency( $dSum, $oCur);
00050 $this->_aViewData["ordertotalcnt"] = $oOrder->getOrderCnt();
00051 $this->_aViewData["afolder"] = $myConfig->getConfigParam( 'aOrderfolder' );
00052 $this->_aViewData["sfolder"] = $myConfig->getConfigParam( 'aOrderfolder' );
00053 $this->_aViewData["alangs"] = $oLang->getLanguageNames();
00054
00055 $this->_aViewData["currency"] = $oCur;
00056
00057 return "order_overview.tpl";
00058 }
00059
00069 protected function _getPaymentType( $oOrder )
00070 {
00071 if ( !( $oUserPayment = $oOrder->getPaymentType() ) && $oOrder->oxorder__oxpaymenttype->value ) {
00072 $oPayment = oxNew( "oxpayment" );
00073 if ( $oPayment->load( $oOrder->oxorder__oxpaymenttype->value ) ) {
00074
00075 $oUserPayment = oxNew( "oxuserpayment" );
00076 $oUserPayment->oxpayments__oxdesc = new oxField( $oPayment->oxpayments__oxdesc->value );
00077 }
00078 }
00079
00080 return $oUserPayment;
00081 }
00082
00088 public function exportlex()
00089 {
00090 $sOrderNr = oxConfig::getParameter( "ordernr");
00091 $sToOrderNr = oxConfig::getParameter( "toordernr");
00092 $oImex = oxNew( "oximex" );
00093 if ( ( $sLexware = $oImex->exportLexwareOrders( $sOrderNr, $sToOrderNr ) ) ) {
00094 $oUtils = oxUtils::getInstance();
00095 $oUtils->setHeader( "Pragma: public" );
00096 $oUtils->setHeader( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
00097 $oUtils->setHeader( "Expires: 0" );
00098 $oUtils->setHeader( "Content-type: application/x-download" );
00099 $oUtils->setHeader( "Content-Length: ".strlen( $sLexware ) );
00100 $oUtils->setHeader( "Content-Disposition: attachment; filename=intern.xml" );
00101 $oUtils->showMessageAndExit( $sLexware );
00102 }
00103 }
00109 public function createPDF()
00110 {
00111 $soxId = $this->getEditObjectId();
00112 if ( $soxId != "-1" && isset( $soxId ) ) {
00113
00114 $oOrder = oxNew( "oxorder" );
00115 if ( $oOrder->load( $soxId ) ) {
00116 $oUtils = oxUtils::getInstance();
00117 $sFilename = $oOrder->oxorder__oxordernr->value . "_" . $oOrder->oxorder__oxbilllname->getRawValue() . ".pdf";
00118
00119 ob_start();
00120 $oOrder->genPDF( $sFilename, oxConfig::getParameter( "pdflanguage" ) );
00121 $sPDF = ob_get_contents();
00122 ob_end_clean();
00123
00124 $oUtils->setHeader( "Pragma: public" );
00125 $oUtils->setHeader( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
00126 $oUtils->setHeader( "Expires: 0" );
00127 $oUtils->setHeader( "Content-type: application/pdf" );
00128 $oUtils->setHeader( "Content-Disposition: attachment; filename=".$sFilename );
00129 oxUtils::getInstance()->showMessageAndExit( $sPDF );
00130 }
00131 }
00132 }
00133
00139 public function exportDTAUS()
00140 {
00141 $oOrderList = oxNew( "oxlist" );
00142 $oOrderList->init( "oxorder" );
00143 $sSelect = "select * from oxorder where oxpaymenttype = 'oxiddebitnote'";
00144
00145 if ( ( $iFromOrderNr = oxConfig::getParameter( "ordernr") ) ) {
00146 $sSelect .= " and oxordernr >= $iFromOrderNr";
00147 }
00148
00149 $oOrderList->selectString( $sSelect );
00150 if ( count( $oOrderList ) ) {
00151 $oUserPayment = oxNew( "oxuserpayment" );
00152 $oUtils = oxUtils::getInstance();
00153 $oShop = $this->getConfig()->getActiveShop();
00154
00155 $sCompany = $oShop->oxshops__oxcompany->value;
00156 $sRoutingNr = $this->_cleanup( $oShop->oxshops__oxbankcode->value ) + 1 - 1;
00157 $sAccountNr = $this->_cleanup( $oShop->oxshops__oxbanknumber->value );
00158 $sSubject = oxLang::getInstance()->translateString( "order" );
00159
00160
00161 $oDtaus = oxNew( "oxDtausBuilder", $sCompany, $sRoutingNr, $sAccountNr );
00162 foreach ( $oOrderList as $oOrder ) {
00163 $oUserPayment->load( $oOrder->oxorder__oxpaymentid->value );
00164 $aDynValues = $oUtils->assignValuesFromText( $oUserPayment->oxuserpayments__oxvalue->value );
00165
00166 $sCustName = $aDynValues[3]->value;
00167 $sRoutingNr = $this->_cleanup( $aDynValues[1]->value );
00168 $sAccountNr = $this->_cleanup( $aDynValues[2]->value );
00169
00170 $oDtaus->add( $sCustName, $sRoutingNr, $sAccountNr, $oOrder->getTotalOrderSum(), array( $oShop->oxshops__oxname->getRawValue(), $sSubject . " " . $oOrder->oxorder__oxordernr->value ) );
00171 }
00172
00173 $oUtils->setHeader( "Content-Disposition: attachment; filename=\"dtaus0.txt\"" );
00174 $oUtils->setHeader( "Content-type: text/plain" );
00175 $oUtils->setHeader( "Cache-control: public" );
00176 $oUtils->showMessageAndExit( $oDtaus->create() );
00177 }
00178 }
00179
00187 protected function _cleanup( $sValue )
00188 {
00189 return str_replace( " ", "", $sValue );
00190 }
00191
00197 public function sendorder()
00198 {
00199 $oOrder = oxNew( "oxorder" );
00200 if ( $oOrder->load( $this->getEditObjectId() ) ) {
00201 $oOrder->oxorder__oxsenddate->setValue( date( "Y-m-d H:i:s", oxUtilsDate::getInstance()->getTime() ) );
00202 $oOrder->save();
00203
00204
00205 $oOrderArticles = $oOrder->getOrderArticles();
00206 foreach ( $oOrderArticles as $sOxid => $oArticle ) {
00207
00208 if ( $oArticle->oxorderarticles__oxstorno->value == 1 ) {
00209 $oOrderArticles->offsetUnset( $sOxid );
00210 }
00211 }
00212
00213 if ( ( $blMail = oxConfig::getParameter( "sendmail" ) ) ) {
00214
00215 $oEmail = oxNew( "oxemail" );
00216 $oEmail->sendSendedNowMail( $oOrder );
00217 }
00218 }
00219 }
00220
00226 public function resetorder()
00227 {
00228 $oOrder = oxNew( "oxorder" );
00229 if ( $oOrder->load( $this->getEditObjectId() ) ) {
00230 $oOrder->oxorder__oxsenddate->setValue( "0000-00-00 00:00:00" );
00231 $oOrder->save();
00232 }
00233 }
00234
00240 public function canExport()
00241 {
00242 $blCan = false;
00243
00244 if ( oxUtilsObject::getInstance()->isModuleActive( 'oxorder', 'myorder' ) ) {
00245 $oDb = oxDb::getDb();
00246 $sOrderId = $this->getEditObjectId();
00247 $sTable = getViewName( "oxorderarticles" );
00248 $sQ = "select count(oxid) from {$sTable} where oxorderid = ".$oDb->quote( $sOrderId )." and oxstorno = 0";
00249 $blCan = (bool) $oDb->getOne( $sQ );
00250 }
00251 return $blCan;
00252 }
00253 }