00001 <?php
00002
00003
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
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
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
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["alangs"] = $oLang->getLanguageNames();
00052
00053
00054 $this->_aViewData["currency"] = $oCur;
00055
00056 return "order_overview.tpl";
00057 }
00058
00064 public function exportlex()
00065 {
00066 $sOrderNr = oxConfig::getParameter( "ordernr");
00067 $sToOrderNr = oxConfig::getParameter( "toordernr");
00068
00069 $oImex = oxNew( "oximex" );
00070 $sLexware = $oImex->exportLexwareOrders( $sOrderNr, $sToOrderNr);
00071 if ( isset( $sLexware) && $sLexware) {
00072 header("Pragma: public");
00073 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
00074 header("Expires: 0");
00075 header("Content-type: application/x-download");
00076 header('Content-Length: '.getStr()->strlen($sLexware));
00077 header("Content-Disposition: attachment; filename=intern.xml");
00078 echo( $sLexware);
00079 exit();
00080 }
00081 }
00087 public function createPDF()
00088 {
00089 $soxId = oxConfig::getParameter( "oxid");
00090 if ( $soxId != "-1" && isset( $soxId)) {
00091
00092 $oOrder = oxNew( "oxorder" );
00093 $oOrder->load( $soxId);
00094 $sFilename = $oOrder->oxorder__oxordernr->value."_".$oOrder->oxorder__oxbilllname->value.".pdf";
00095
00096 ob_start();
00097 $oOrder->genPDF( $sFilename, oxConfig::getParameter( "pdflanguage"));
00098 $sPDF = ob_get_contents();
00099 ob_end_clean();
00100
00101 header("Pragma: public");
00102 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
00103 header("Expires: 0");
00104 header("Content-type: application/pdf");
00105 header("Content-Disposition: attachment; filename=".$sFilename);
00106 echo( $sPDF);
00107 exit();
00108 }
00109
00110 }
00111
00117 public function exportDTAUS()
00118 {
00119 $iFromOrderNr = oxConfig::getParameter( "ordernr");
00120
00121 $oOrderList = oxNew( "oxlist" );
00122 $oOrderList->init( "oxorder");
00123 $sSelect = "select * from oxorder where oxpaymenttype = 'oxiddebitnote'";
00124
00125 if ( isset( $iFromOrderNr) && $iFromOrderNr)
00126 $sSelect .= " and oxordernr >= $iFromOrderNr";
00127
00128 $oOrderList->selectString( $sSelect);
00129
00130 if ( !count( $oOrderList))
00131 return;
00132
00133 $oPayment = oxNew( "oxuserpayment" );
00134 $oShop = $this->getConfig()->getActiveShop();
00135 $dtaus = new DTAUS("L", $oShop->oxshops__oxcompany->value, str_replace( " ", "", $oShop->oxshops__oxbankcode->value), str_replace( " ", "", $oShop->oxshops__oxbanknumber->value));
00136
00137 $myUtils = oxUtils::getInstance();
00138 $myLang = oxLang::getInstance();
00139 foreach ( $oOrderList as $oOrder) {
00140 $oPayment->load( $oOrder->oxorder__oxpaymentid->value);
00141 $aDynValues = $myUtils->assignValuesFromText( $oPayment->oxuserpayments__oxvalue->value );
00142
00143
00144 $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, "");
00145
00146 }
00147
00148 header("Content-Disposition: attachment; filename=\"dtaus0.txt\"");
00149 header("Content-type: text/plain");
00150 header("Cache-control: public");
00151
00152 echo( $dtaus->create());
00153 exit();
00154 }
00155
00161 public function sendorder()
00162 {
00163 $soxId = oxConfig::getParameter( "oxid");
00164 $oOrder = oxNew( "oxorder" );
00165 $oOrder->load( $soxId);
00166
00167
00168 $timeout = oxUtilsDate::getInstance()->getTime();
00169 $now = date("Y-m-d H:i:s", $timeout);
00170 $oOrder->oxorder__oxsenddate->setValue($now);
00171 $oOrder->save();
00172
00173
00174 $oOrderArticles = $oOrder->getOrderArticles();
00175 foreach ( $oOrderArticles as $oxid=>$oArticle) {
00176
00177 if ( $oArticle->oxorderarticles__oxstorno->value == 1 )
00178 $oOrderArticles->offsetUnset($oxid);
00179 }
00180
00181 $blMail = oxConfig::getParameter( "sendmail");
00182 if ( isset( $blMail) && $blMail) {
00183
00184 $oxEMail = oxNew( "oxemail" );
00185 $oxEMail->sendSendedNowMail( $oOrder );
00186 }
00187 }
00188
00194 public function resetorder()
00195 {
00196 $soxId = oxConfig::getParameter( "oxid");
00197 $oOrder = oxNew( "oxorder" );
00198 $oOrder->load( $soxId);
00199
00200 $oOrder->oxorder__oxsenddate->setValue("0000-00-00 00:00:00");
00201 $oOrder->save();
00202 }
00203
00209 public function canExport()
00210 {
00211
00212 if ( oxUtilsObject::getInstance()->isModuleActive( 'oxorder', 'myorder' ) ) {
00213 $oDb = oxDb::getDb();
00214 $sOrderId = oxConfig::getParameter( "oxid" );
00215 $sTable = getViewName( "oxorderarticles" );
00216 $sQ = "select count(oxid) from {$sTable} where oxorderid = ".$oDb->quote( $sOrderId )." and oxstorno = 0";
00217 return (bool) $oDb->getOne( $sQ );
00218 }
00219 return false;
00220 }
00221 }