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["orderArticles"] = $oOrder->getOrderArticles();
00034             $this->_aViewData["giftCard"]      = $oOrder->getGiftCard();
00035             $this->_aViewData["paymentType"]   = $oOrder->getPaymentType();
00036             $this->_aViewData["deliveryType"]  = $oOrder->getDelSet();
00037         }
00038 
00039         // orders today
00040         $oLang = oxLang::getInstance();
00041         $oCur  = $myConfig->getActShopCurrencyObject();
00042         $dSum  = $oOrder->getOrderSum(true);
00043         $this->_aViewData["ordersum"] = $oLang->formatCurrency($dSum, $oCur);
00044         $this->_aViewData["ordercnt"] = $oOrder->getOrderCnt(true);
00045 
00046         // ALL orders
00047         $dSum = $oOrder->getOrderSum();
00048         $this->_aViewData["ordertotalsum"] = $oLang->formatCurrency( $dSum, $oCur);
00049         $this->_aViewData["ordertotalcnt"] = $oOrder->getOrderCnt();
00050         $this->_aViewData["afolder"] = $myConfig->getConfigParam( 'aOrderfolder' );
00051         $this->_aViewData["sfolder"] = $myConfig->getConfigParam( 'aOrderfolder' );
00052             $this->_aViewData["alangs"] = $oLang->getLanguageNames();
00053 
00054 
00055         $this->_aViewData["currency"] = $oCur;
00056 
00057         return "order_overview.tpl";
00058     }
00059 
00065     public function exportlex()
00066     {
00067         $sOrderNr   = oxConfig::getParameter( "ordernr");
00068         $sToOrderNr = oxConfig::getParameter( "toordernr");
00069 
00070         $oImex = oxNew( "oximex" );
00071         $sLexware = $oImex->exportLexwareOrders( $sOrderNr, $sToOrderNr);
00072         if ( isset( $sLexware) && $sLexware) {
00073             header("Pragma: public");
00074             header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
00075             header("Expires: 0");
00076             header("Content-type: application/x-download");
00077             header('Content-Length: '.getStr()->strlen($sLexware));
00078             header("Content-Disposition: attachment; filename=intern.xml");
00079             echo( $sLexware);
00080             exit();
00081         }
00082     }
00088     public function createPDF()
00089     {
00090         $soxId = oxConfig::getParameter( "oxid");
00091         if ( $soxId != "-1" && isset( $soxId)) {
00092             // load object
00093             $oOrder = oxNew( "oxorder" );
00094             $oOrder->load( $soxId);
00095             $sFilename = $oOrder->oxorder__oxordernr->value."_".$oOrder->oxorder__oxbilllname->value.".pdf";
00096 
00097             ob_start();
00098             $oOrder->genPDF( $sFilename, oxConfig::getParameter( "pdflanguage"));
00099             $sPDF = ob_get_contents();
00100             ob_end_clean();
00101 
00102             header("Pragma: public");
00103             header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
00104             header("Expires: 0");
00105             header("Content-type: application/pdf");
00106             header("Content-Disposition: attachment; filename=".$sFilename);
00107             echo( $sPDF);
00108             exit();
00109         }
00110 
00111     }
00112 
00118     public function exportDTAUS()
00119     {
00120         $iFromOrderNr = oxConfig::getParameter( "ordernr");
00121 
00122         $oOrderList = oxNew( "oxlist" );
00123         $oOrderList->init( "oxorder");
00124         $sSelect =  "select * from oxorder where oxpaymenttype = 'oxiddebitnote'";
00125 
00126         if ( isset( $iFromOrderNr) && $iFromOrderNr)
00127             $sSelect .= " and oxordernr >= $iFromOrderNr";
00128 
00129         $oOrderList->selectString( $sSelect);
00130 
00131         if ( !count( $oOrderList))
00132             return;
00133 
00134         $oPayment = oxNew( "oxuserpayment" );
00135         $oShop = $this->getConfig()->getActiveShop();
00136         $dtaus = new DTAUS("L", $oShop->oxshops__oxcompany->value, str_replace( " ", "", $oShop->oxshops__oxbankcode->value), str_replace( " ", "", $oShop->oxshops__oxbanknumber->value));
00137 
00138         $myUtils = oxUtils::getInstance();
00139         $myLang  = oxLang::getInstance();
00140         foreach ( $oOrderList as $oOrder) {
00141             $oPayment->load( $oOrder->oxorder__oxpaymentid->value);
00142             $aDynValues = $myUtils->assignValuesFromText( $oPayment->oxuserpayments__oxvalue->value );
00143             // #630
00144             //$dtaus->addTransaktion( $aDynValues[3]->value, str_replace( array(" ", "-"), "", $aDynValues[1]->value), str_replace( array(" ", "-"), "", $aDynValues[2]->value), str_replace( ",", ".",$oOrder->ftotalorder), $oShop->oxshops__oxname->getRawValue(), oxLang::getInstance()->translateString("order")." ".$oOrder->oxorder__oxordernr->value,"");
00145             $dtaus->addTransaktion( $aDynValues[3]->value, str_replace( " ", "", $aDynValues[1]->value), str_replace( " ", "", $aDynValues[2]->value), str_replace( ",", ".", $oOrder->ftotalorder), $oShop->oxshops__oxname->getRawValue(), $myLang->translateString("order")." ".$oOrder->oxorder__oxordernr->value, "");
00146 
00147         }
00148 
00149         header("Content-Disposition: attachment; filename=\"dtaus0.txt\"");
00150         header("Content-type: text/plain");
00151         header("Cache-control: public");
00152 
00153         echo(  $dtaus->create());
00154         exit();
00155     }
00156 
00162     public function sendorder()
00163     {
00164         $soxId  = oxConfig::getParameter( "oxid");
00165         $oOrder = oxNew( "oxorder" );
00166         $oOrder->load( $soxId);
00167 
00168         // #632A
00169         $timeout = oxUtilsDate::getInstance()->getTime(); //time();
00170         $now = date("Y-m-d H:i:s", $timeout);
00171         $oOrder->oxorder__oxsenddate->setValue($now);
00172         $oOrder->save();
00173 
00174         // #1071C
00175         $oOrderArticles = $oOrder->getOrderArticles();
00176         foreach ( $oOrderArticles as $oxid=>$oArticle) {
00177             // remove canceled articles from list
00178             if ( $oArticle->oxorderarticles__oxstorno->value == 1 )
00179                 $oOrderArticles->offsetUnset($oxid);
00180         }
00181 
00182         $blMail  = oxConfig::getParameter( "sendmail");
00183         if ( isset( $blMail) && $blMail) {
00184             // send eMail
00185             $oxEMail = oxNew( "oxemail" );
00186             $oxEMail->sendSendedNowMail( $oOrder );
00187         }
00188     }
00189 
00195     public function resetorder()
00196     {
00197         $soxId  = oxConfig::getParameter( "oxid");
00198         $oOrder = oxNew( "oxorder" );
00199         $oOrder->load( $soxId);
00200 
00201         $oOrder->oxorder__oxsenddate->setValue("0000-00-00 00:00:00");
00202         $oOrder->save();
00203     }
00204 
00210     public function canExport()
00211     {
00212         //V #529: check if PDF invoice modul is active
00213         if ( oxUtilsObject::getInstance()->isModuleActive( 'oxorder', 'myorder' ) ) {
00214             $oDb = oxDb::getDb();
00215             $sOrderId = oxConfig::getParameter( "oxid" );
00216             $sTable = getViewName( "oxorderarticles" );
00217             $sQ = "select count(oxid) from {$sTable} where oxorderid = ".$oDb->quote( $sOrderId )." and oxstorno = 0";
00218             return (bool) $oDb->getOne( $sQ );
00219         }
00220         return false;
00221     }
00222 }

Generated on Wed May 13 13:25:50 2009 for OXID eShop CE by  doxygen 1.5.5