52 $this->_aViewData[
"edit"] = $oOrder;
53 $this->_aViewData[
"aProductVats"] = $oOrder->getProductVats(
true);
56 return "order_article.tpl";
67 if ( $this->_oEditObject === null && isset( $soxId ) && $soxId !=
"-1" ) {
68 $this->_oEditObject =
oxNew(
"oxorder" );
69 $this->_oEditObject->load( $soxId );
91 if ( $this->_oSearchProduct === null ) {
92 $this->_oSearchProduct =
false;
96 if ( $oProduct->oxarticles__oxartnum->value == $sSearchArtNum ) {
97 $this->_oSearchProduct = $oProduct;
114 $this->_oMainSearchProduct =
false;
119 $sTable = getViewName(
"oxarticles" );
120 $sQ =
"select oxid, oxparentid from $sTable where oxartnum = ".$oDb->quote( $sArtNum ).
" limit 1";
122 $rs = $oDb->execute( $sQ );
123 if ($rs !=
false && $rs->recordCount() > 0) {
124 $sArtId = $rs->fields[
'OXPARENTID'] ? $rs->fields[
'OXPARENTID'] : $rs->fields[
'OXID'];
126 $oProduct =
oxNew(
"oxarticle" );
127 if ( $oProduct->load( $sArtId ) ) {
128 $this->_oMainSearchProduct = $oProduct;
143 if ( $this->_oSearchProductList === null ) {
144 $this->_oSearchProductList =
oxNew(
"oxlist" );
149 $this->_oSearchProductList->offsetSet( $oMainSearchProduct->getId(), $oMainSearchProduct );
152 foreach ( $oMainSearchProduct->getVariants() as $oVariant ) {
153 $this->_oSearchProductList->offsetSet( $oVariant->getId(), $oVariant );
170 $oProduct =
oxNew(
"oxarticle" );
172 if ( $sOxid && $dAmount && $oProduct->load( $sOxid ) ) {
175 $oOrder =
oxNew(
'oxorder' );
176 if ( $sOrderId && $oOrder->load( $sOrderId ) ) {
177 $oOrderArticle =
oxNew(
'oxorderArticle' );
178 $oOrderArticle->oxorderarticles__oxartid =
new oxField( $oProduct->getId() );
179 $oOrderArticle->oxorderarticles__oxartnum =
new oxField( $oProduct->oxarticles__oxartnum->value );
180 $oOrderArticle->oxorderarticles__oxamount =
new oxField( $dAmount );
182 $oOrder->recalculateOrder( array( $oOrderArticle ) );
198 $oOrderArticle =
oxNew(
'oxorderarticle' );
199 $oOrder =
oxNew(
'oxorder' );
202 if ( $oOrderArticle->load( $sOrderArtId ) && $oOrder->load( $sOrderId ) ) {
206 $oOrderArticle->delete();
209 $oOrder->recalculateOrder();
223 $oArticle =
oxNew(
'oxorderarticle' );
224 $oArticle->load( $sOrderArtId );
226 if ( $oArticle->oxorderarticles__oxstorno->value == 1 ) {
227 $oArticle->oxorderarticles__oxstorno->setValue( 0 );
230 $oArticle->oxorderarticles__oxstorno->setValue( 1 );
235 if (
$myConfig->getConfigParam(
'blUseStock' ) ) {
236 $oArticle->updateArticleStock( $oArticle->oxorderarticles__oxamount->value * $sStockSign,
$myConfig->getConfigParam(
'blAllowNegativeStock') );
240 $sQ =
"update oxorderarticles set oxstorno = ".$oDb->quote( $oArticle->oxorderarticles__oxstorno->value ).
" where oxid = ".$oDb->quote( $sOrderArtId );
241 $oDb->execute( $sQ );
244 $sQ =
"select oxartid from oxorderarticles where oxid = ".$oDb->quote( $sOrderArtId );
245 if ( ( $sArtId =
oxDb::getDb()->getOne( $sQ,
false,
false ) ) ) {
246 $oOrder =
oxNew(
'oxorder' );
247 if ( $oOrder->load( $this->getEditObjectId() ) ) {
248 $oOrder->recalculateOrder();
262 $oOrder =
oxNew(
'oxorder' );
263 if ( is_array( $aOrderArticles ) && $oOrder->load( $this->getEditObjectId() ) ) {
266 $oOrderArticles = $oOrder->getOrderArticles(
true );
268 $blUseStock =
$myConfig->getConfigParam(
'blUseStock' );
269 foreach ( $oOrderArticles as $oOrderArticle ) {
270 $sItemId = $oOrderArticle->getId();
271 if ( isset( $aOrderArticles[$sItemId] ) ) {
275 $oOrderArticle->setNewAmount( $aOrderArticles[$sItemId][
'oxamount'] );
277 $oOrderArticle->assign( $aOrderArticles[$sItemId] );
278 $oOrderArticle->save();
284 $oOrder->recalculateOrder();