order_article.php

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

Generated on Thu Feb 19 15:02:21 2009 for OXID eShop CE by  doxygen 1.5.5