order_article.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class Order_Article extends oxAdminDetails
00009 {
00017     public function render()
00018     {
00019         parent::render();
00020 
00021         $soxId = oxConfig::getParameter( "oxid" );
00022         if ( $soxId != "-1" && isset( $soxId ) ) {
00023             // load object
00024             $oOrder = oxNew( "oxorder" );
00025             $oOrder->load( $soxId );
00026 
00027             $this->_aViewData["edit"] =  $oOrder;
00028         }
00029 
00030         return "order_article.tpl";
00031     }
00032 
00038     public function addThisArticle()
00039     {
00040         if ( ( $sArtNum = oxConfig::getParameter( 'sArtNum' ) ) ) {
00041             $dAmount  = oxConfig::getParameter( 'am' );
00042             $sOrderId = oxConfig::getParameter( 'oxid' );
00043 
00044             //get article id
00045             $sQ = "select oxid from oxarticles where oxarticles.oxartnum = '$sArtNum'";
00046             if ( ( $sArtId = oxDb::getDb()->getOne( $sQ ) ) ) {
00047                 $oOrderArticle = oxNew( 'oxorderArticle' );
00048                 $oOrderArticle->oxorderarticles__oxartid  = new oxField( $sArtId );
00049                 $oOrderArticle->oxorderarticles__oxartnum = new oxField( $sArtNum );
00050                 $oOrderArticle->oxorderarticles__oxamount = new oxField( $dAmount );
00051                 $aOrderArticles[] = $oOrderArticle;
00052 
00053                 $oOrder = oxNew( 'oxorder' );
00054                 if ( $oOrder->load( $sOrderId ) ) {
00055                     $oOrder->recalculateOrder( $aOrderArticles );
00056                 }
00057             }
00058         }
00059     }
00060 
00066     public function deleteThisArticle()
00067     {
00068         // get article id
00069         $sOrderArtId = oxConfig::getParameter( 'sArtID' );
00070         $sQ = "select oxartid from oxorderarticles where oxid = '$sOrderArtId'";
00071         if ( ( $sArtId = oxDb::getDb()->getOne( $sQ ) ) ) {
00072 
00073             $oOrderArticle = oxNew( 'oxorderarticle' );
00074             $oOrderArticle->oxorderarticles__oxartid  = new oxField( $sArtId );
00075             $oOrderArticle->oxorderarticles__oxartnum = new oxField( $sOrderArtId );
00076             $oOrderArticle->oxorderarticles__oxamount = new oxField( 0 );
00077             $aOrderArticles[] = $oOrderArticle;
00078 
00079             $oOrder = oxNew( 'oxorder' );
00080             $sOrderId = oxConfig::getParameter( 'oxid' );
00081             if ( $oOrder->load( $sOrderId ) ) {
00082                 $oOrder->recalculateOrder( $aOrderArticles );
00083             }
00084         }
00085     }
00086 
00092     public function storno()
00093     {
00094         $myConfig = $this->getConfig();
00095 
00096         $sOrderArtId = oxConfig::getParameter( 'sArtID' );
00097         $oArticle = oxNew( 'oxorderarticle' );
00098         $oArticle->load( $sOrderArtId );
00099 
00100         if ( $oArticle->oxorderarticles__oxstorno->value == 1 ) {
00101             $oArticle->oxorderarticles__oxstorno->setValue( 0 );
00102             $sStockSign = -1;
00103         } else {
00104             $oArticle->oxorderarticles__oxstorno->setValue( 1 );
00105             $sStockSign = 1;
00106         }
00107 
00108         // stock information
00109         if ( $myConfig->getConfigParam( 'blUseStock' ) ) {
00110             $oArticle->updateArticleStock($oArticle->oxorderarticles__oxamount->value * $sStockSign, $myConfig->getConfigParam('blAllowNegativeStock'));
00111         }
00112 
00113         $sQ = "update oxorderarticles set oxstorno = '{$oArticle->oxorderarticles__oxstorno->value}' where oxid = '$sOrderArtId'";
00114         oxDb::getDb()->execute( $sQ );
00115 
00116         //get article id
00117         $sQ = "select oxartid from oxorderarticles where oxid = '$sOrderArtId'";
00118         if ( ( $sArtId = oxDb::getDb()->getOne( $sQ ) ) ) {
00119             $oOrder = oxNew( 'oxorder' );
00120             if ( $oOrder->load( oxConfig::getParameter( 'oxid' ) ) ) {
00121                 $oOrder->recalculateOrder( array() );
00122             }
00123         }
00124     }
00125 }

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