article_overview.php

Go to the documentation of this file.
00001 <?php
00002 
00009 class Article_Overview extends oxAdminDetails
00010 {
00017     public function render()
00018     {
00019         $myConfig = $this->getConfig();
00020 
00021         parent::render();
00022 
00023         $this->_aViewData['edit'] = $oArticle = oxNew( 'oxarticle' );
00024 
00025         $soxId = $this->getEditObjectId();
00026         if ( $soxId != "-1" && isset( $soxId ) ) {
00027 
00028             // load object
00029             $oArticle->loadInLang( oxConfig::getParameter( "editlanguage" ), $soxId );
00030 
00031 
00032             $oDB = oxDb::getDb();
00033 
00034                 // variant handling
00035                 if ( $oArticle->oxarticles__oxparentid->value) {
00036                     $oParentArticle = oxNew( "oxarticle");
00037                     $oParentArticle->load( $oArticle->oxarticles__oxparentid->value);
00038                     $this->_aViewData["parentarticle"] =  $oParentArticle;
00039                     $this->_aViewData["oxparentid"] =  $oArticle->oxarticles__oxparentid->value;
00040                 }
00041 
00042                 // ordered amount
00043                 $sSelect =  "select sum(oxamount) from oxorderarticles ";
00044                 $sSelect .= "where oxartid=".$oDB->quote( $soxId );
00045                 $this->_aViewData["totalordercnt"] = $iTotalOrderCnt = (float) $oDB->getOne( $sSelect);
00046 
00047                 // sold amount
00048                 $sSelect  = "select sum(oxorderarticles.oxamount) from  oxorderarticles, oxorder ";
00049                 $sSelect .= "where (oxorder.oxpaid>0 or oxorder.oxsenddate > 0) and oxorderarticles.oxstorno != '1' and oxorderarticles.oxartid=".$oDB->quote( $soxId );
00050                 $sSelect .= "and oxorder.oxid =oxorderarticles.oxorderid";
00051                 $this->_aViewData["soldcnt"] = $iSoldCnt = (float) $oDB->getOne( $sSelect);;
00052 
00053                 // canceled amount
00054                 $sSelect =  "select sum(oxamount) from oxorderarticles where oxstorno = '1' and oxartid=".$oDB->quote( $soxId );
00055                 $this->_aViewData["canceledcnt"] = $iCanceledCnt = (float) $oDB->getOne( $sSelect);
00056 
00057                 // not yet processed
00058                 $this->_aViewData["leftordercnt"] = $iTotalOrderCnt - $iSoldCnt - $iCanceledCnt;
00059 
00060                 // position in top ten
00061                 $sSelect =  "select oxartid,sum(oxamount) as cnt from oxorderarticles group by oxartid order by cnt desc";
00062 
00063             $rs = $oDB->execute( $sSelect );
00064             $iTopPos = 0;
00065             $iPos    = 0;
00066             if ( $rs != false && $rs->recordCount() > 0) {
00067                 while (!$rs->EOF) {
00068                     $iPos++;
00069                     if( $rs->fields[0] == $soxId)
00070                         $iTopPos = $iPos;
00071                     $rs->moveNext();
00072                 }
00073             }
00074 
00075             $this->_aViewData["postopten"]   = $iTopPos;
00076             $this->_aViewData["toptentotal"] = $iPos;
00077         }
00078 
00079         $this->_aViewData["afolder"]   = $myConfig->getConfigParam( 'aProductfolder' );
00080         $this->_aViewData["aSubclass"] = $myConfig->getConfigParam( 'aArticleClasses' );
00081 
00082         return "article_overview.tpl";
00083     }
00084 
00085 }