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
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 $sArtNum = oxConfig::getParameter( "sArtNum");
00042 $dAmount = oxConfig::getParameter( "am");
00043 $sOrderId = oxConfig::getParameter( "oxid");
00044
00045 if (!$sArtNum)
00046 return;
00047
00048
00049 $sSql = "select oxid from oxarticles where oxarticles.oxartnum = '$sArtNum'";
00050 $sArtId = oxDb::getDb()->getOne( $sSql);
00051
00052 if (!$sArtId)
00053 return;
00054
00055 $oOrderArticle = oxNew( 'oxOrderArticle' );
00056 $oOrderArticle->oxorderarticles__oxartid = new oxField($sArtId);
00057 $oOrderArticle->oxorderarticles__oxartnum = new oxField($sArtNum);
00058 $oOrderArticle->oxorderarticles__oxamount = new oxField($dAmount);
00059 $aOrderArticles[] = $oOrderArticle;
00060
00061 $oOrder = oxNew( "oxOrder" );
00062 $oOrder->load( $sOrderId );
00063 $oOrder->recalculateOrder( $aOrderArticles );
00064 }
00065
00071 public function deleteThisArticle()
00072 {
00073 $sOrderArtId = oxConfig::getParameter( "sArtID");
00074 $sOrderId = oxConfig::getParameter( "oxid");
00075
00076
00077 $sSql = "select oxartid from oxorderarticles where oxid = '$sOrderArtId'";
00078 $sArtId = oxDb::getDb()->getOne( $sSql);
00079
00080 if (!$sArtId)
00081 return;
00082
00083 $oOrderArticle = oxNew( 'oxOrderArticle' );
00084 $oOrderArticle->oxorderarticles__oxartid = new oxField($sArtId);
00085 $oOrderArticle->oxorderarticles__oxartnum = new oxField($sOrderArtId);
00086 $oOrderArticle->oxorderarticles__oxamount = new oxField(0);
00087 $aOrderArticles[] = $oOrderArticle;
00088
00089 $oOrder = oxNew( "oxOrder" );
00090 $oOrder->load( $sOrderId );
00091
00092 $oOrder->recalculateOrder( $aOrderArticles );
00093
00094 }
00095
00100 public function storno()
00101 {
00102 $myConfig = $this->getConfig();
00103
00104 $sOrderArtId = oxConfig::getParameter( "sArtID" );
00105 $oArticle = oxNew( "oxorderarticle" );
00106 $oArticle->load( $sOrderArtId );
00107
00108 if ( $oArticle->oxorderarticles__oxstorno->value == 1) {
00109 $oArticle->oxorderarticles__oxstorno->setValue(0);
00110 $sStockSign = -1;
00111 } else {
00112 $oArticle->oxorderarticles__oxstorno->setValue(1);
00113 $sStockSign = 1;
00114 }
00115
00116
00117 if ( $myConfig->getConfigParam( 'blUseStock' ) )
00118 $oArticle->updateArticleStock($oArticle->oxorderarticles__oxamount->value * $sStockSign, $myConfig->getConfigParam('blAllowNegativeStock'));
00119
00120 $sOxStorNo = $oArticle->oxorderarticles__oxstorno->value;
00121 $sSql = "update oxorderarticles set oxstorno = '$sOxStorNo' where oxid = '$sOrderArtId'";
00122 oxDb::getDb()->execute( $sSql );
00123
00124
00125 $sSql = "select oxartid from oxorderarticles where oxid = '$sOrderArtId'";
00126 $sArtId = oxDb::getDb()->getOne( $sSql);
00127
00128 if (!$sArtId)
00129 return;
00130
00131 $soxId = oxConfig::getParameter( "oxid");
00132 $oOrder = oxNew( "oxorder" );
00133 $oOrder->load( $soxId);
00134
00135 $oOrder->recalculateOrder( array() );
00136 }
00137 }