order_overview.php

Go to the documentation of this file.
00001 <?php
00002 
00003     // DTAUS
00004     require_once "dtaus/class.DTAUS.php";
00005 
00011 class Order_Overview extends oxAdminDetails
00012 {
00020     public function render()
00021     {
00022         $myConfig = $this->getConfig();
00023         parent::render();
00024 
00025         $oOrder = oxNew( "oxorder" );
00026 
00027         $soxId = oxConfig::getParameter( "oxid");
00028         if ( $soxId != "-1" && isset( $soxId)) {
00029             // load object
00030             $oOrder->load( $soxId);
00031 
00032             $this->_aViewData["edit"]          = $oOrder;
00033             $this->_aViewData["aProductVats"]  = $oOrder->getProductVats();
00034             $this->_aViewData["orderArticles"] = $oOrder->getOrderArticles();
00035             $this->_aViewData["giftCard"]      = $oOrder->getGiftCard();
00036             $this->_aViewData["paymentType"]   = $this->_getPaymentType( $oOrder );
00037             $this->_aViewData["deliveryType"]  = $oOrder->getDelSet();
00038         }
00039 
00040         // orders today
00041         $oLang = oxLang::getInstance();
00042         $oCur  = $myConfig->getActShopCurrencyObject();
00043         $dSum  = $oOrder->getOrderSum(true);
00044         $this->_aViewData["ordersum"] = $oLang->formatCurrency($dSum, $oCur);
00045         $this->_aViewData["ordercnt"] = $oOrder->getOrderCnt(true);
00046 
00047         // ALL orders
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 
00056         $this->_aViewData["currency"] = $oCur;
00057 
00058         return "order_overview.tpl";
00059     }
00060 
00070     protected function _getPaymentType( $oOrder )
00071     {
00072         if ( !( $oUserPayment = $oOrder->getPaymentType() ) && $oOrder->oxorder__oxpaymenttype->value ) {
00073             $oPayment = oxNew( "oxpayment" );
00074             if ( $oPayment->load( $oOrder->oxorder__oxpaymenttype->value ) ) {
00075                 // in case due to security reasons payment info was not kept in db
00076                 $oUserPayment = oxNew( "oxuserpayment" );
00077                 $oUserPayment->oxpayments__oxdesc = new oxField( $oPayment->oxpayments__oxdesc->value );
00078             }
00079         }
00080 
00081         return $oUserPayment;
00082     }
00083 
00089     public function exportlex()
00090     {
00091         $sOrderNr   = oxConfig::getParameter( "ordernr");
00092         $sToOrderNr = oxConfig::getParameter( "toordernr");
00093         $oImex = oxNew( "oximex" );
00094         if ( ( $sLexware = $oImex->exportLexwareOrders( $sOrderNr, $sToOrderNr ) ) ) {
00095             $oUtils = oxUtils::getInstance();
00096             $oUtils->setHeader( "Pragma: public" );
00097             $oUtils->setHeader( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
00098             $oUtils->setHeader( "Expires: 0" );
00099             $oUtils->setHeader( "Content-type: application/x-download" );
00100             $oUtils->setHeader( "Content-Length: ".strlen( $sLexware ) );
00101             $oUtils->setHeader( "Content-Disposition: attachment; filename=intern.xml" );
00102             $oUtils->showMessageAndExit( $sLexware );
00103         }
00104     }
00110     public function createPDF()
00111     {
00112         $soxId = oxConfig::getParameter( "oxid" );
00113         if ( $soxId != "-1" && isset( $soxId ) ) {
00114             // load object
00115             $oOrder = oxNew( "oxorder" );
00116             if ( $oOrder->load( $soxId ) ) {
00117                 $oUtils = oxUtils::getInstance();
00118                 $sFilename = $oOrder->oxorder__oxordernr->value . "_" . $oOrder->oxorder__oxbilllname->getRawValue() . ".pdf";
00119 
00120                 ob_start();
00121                 $oOrder->genPDF( $sFilename, oxConfig::getParameter( "pdflanguage" ) );
00122                 $sPDF = ob_get_contents();
00123                 ob_end_clean();
00124 
00125                 $oUtils->setHeader( "Pragma: public" );
00126                 $oUtils->setHeader( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
00127                 $oUtils->setHeader( "Expires: 0" );
00128                 $oUtils->setHeader( "Content-type: application/pdf" );
00129                 $oUtils->setHeader( "Content-Disposition: attachment; filename=".$sFilename );
00130                 oxUtils::getInstance()->showMessageAndExit( $sPDF );
00131             }
00132         }
00133     }
00134 
00140     public function exportDTAUS()
00141     {
00142         $oOrderList = oxNew( "oxlist" );
00143         $oOrderList->init( "oxorder" );
00144         $sSelect =  "select * from oxorder where oxpaymenttype = 'oxiddebitnote'";
00145 
00146         if ( ( $iFromOrderNr = oxConfig::getParameter( "ordernr") ) ) {
00147             $sSelect .= " and oxordernr >= $iFromOrderNr";
00148         }
00149 
00150         $oOrderList->selectString( $sSelect );
00151         if ( count( $oOrderList ) ) {
00152             $oPayment = oxNew( "oxuserpayment" );
00153             $oShop = $this->getConfig()->getActiveShop();
00154             $oDtaus = new DTAUS( "L", $oShop->oxshops__oxcompany->value, str_replace( " ", "", $oShop->oxshops__oxbankcode->value), str_replace( " ", "", $oShop->oxshops__oxbanknumber->value ) );
00155 
00156             $oUtils = oxUtils::getInstance();
00157             $oLang  = oxLang::getInstance();
00158             foreach ( $oOrderList as $oOrder ) {
00159                 $oPayment->load( $oOrder->oxorder__oxpaymentid->value );
00160                 $aDynValues = $oUtils->assignValuesFromText( $oPayment->oxuserpayments__oxvalue->value );
00161                 $oDtaus->addTransaktion( $aDynValues[3]->value, str_replace( " ", "", $aDynValues[1]->value ), str_replace( " ", "", $aDynValues[2]->value ), str_replace( ",", ".", $oOrder->ftotalorder), $oShop->oxshops__oxname->getRawValue(), $oLang->translateString( "order" )." ".$oOrder->oxorder__oxordernr->value, "" );
00162             }
00163 
00164             $oUtils->setHeader( "Content-Disposition: attachment; filename=\"dtaus0.txt\"" );
00165             $oUtils->setHeader( "Content-type: text/plain" );
00166             $oUtils->setHeader( "Cache-control: public" );
00167             $oUtils->showMessageAndExit( $oDtaus->create() );
00168         }
00169     }
00170 
00176     public function sendorder()
00177     {
00178         $oOrder = oxNew( "oxorder" );
00179         if ( $oOrder->load( oxConfig::getParameter( "oxid" ) ) ) {
00180             $oOrder->oxorder__oxsenddate->setValue( date( "Y-m-d H:i:s", oxUtilsDate::getInstance()->getTime() ) );
00181             $oOrder->save();
00182 
00183             // #1071C
00184             $oOrderArticles = $oOrder->getOrderArticles();
00185             foreach ( $oOrderArticles as $sOxid => $oArticle ) {
00186                 // remove canceled articles from list
00187                 if ( $oArticle->oxorderarticles__oxstorno->value == 1 ) {
00188                     $oOrderArticles->offsetUnset( $sOxid );
00189                 }
00190             }
00191 
00192             if ( ( $blMail = oxConfig::getParameter( "sendmail" ) ) ) {
00193                 // send eMail
00194                 $oEmail = oxNew( "oxemail" );
00195                 $oEmail->sendSendedNowMail( $oOrder );
00196             }
00197         }
00198     }
00199 
00205     public function resetorder()
00206     {
00207         $oOrder = oxNew( "oxorder" );
00208         if ( $oOrder->load( oxConfig::getParameter( "oxid" ) ) ) {
00209             $oOrder->oxorder__oxsenddate->setValue( "0000-00-00 00:00:00" );
00210             $oOrder->save();
00211         }
00212     }
00213 
00219     public function canExport()
00220     {
00221         $blCan = false;
00222         //V #529: check if PDF invoice module is active
00223         if ( oxUtilsObject::getInstance()->isModuleActive( 'oxorder', 'myorder' ) ) {
00224             $oDb = oxDb::getDb();
00225             $sOrderId = oxConfig::getParameter( "oxid" );
00226             $sTable = getViewName( "oxorderarticles" );
00227             $sQ = "select count(oxid) from {$sTable} where oxorderid = ".$oDb->quote( $sOrderId )." and oxstorno = 0";
00228             $blCan = (bool) $oDb->getOne( $sQ );
00229         }
00230         return $blCan;
00231     }
00232 }

Generated by  doxygen 1.6.2