OXID eShop CE  4.8.12
 All Classes Files Functions Variables Pages
article_overview.php
Go to the documentation of this file.
1 <?php
2 
10 {
17  public function render()
18  {
19  $myConfig = $this->getConfig();
20 
22 
23  $this->_aViewData['edit'] = $oArticle = oxNew( 'oxarticle' );
24 
25  $soxId = $this->getEditObjectId();
26  if ( $soxId != "-1" && isset( $soxId ) ) {
27 
28  // load object
29  $oArticle->loadInLang( oxConfig::getParameter( "editlanguage" ), $soxId );
30 
31 
32  $oDB = oxDb::getDb();
33 
34  // variant handling
35  if ( $oArticle->oxarticles__oxparentid->value) {
36  $oParentArticle = oxNew( "oxarticle");
37  $oParentArticle->load( $oArticle->oxarticles__oxparentid->value);
38  $this->_aViewData["parentarticle"] = $oParentArticle;
39  $this->_aViewData["oxparentid"] = $oArticle->oxarticles__oxparentid->value;
40  }
41 
42  // ordered amount
43  $sSelect = "select sum(oxamount) from oxorderarticles ";
44  $sSelect .= "where oxartid=".$oDB->quote( $soxId );
45  $this->_aViewData["totalordercnt"] = $iTotalOrderCnt = (float) $oDB->getOne( $sSelect);
46 
47  // sold amount
48  $sSelect = "select sum(oxorderarticles.oxamount) from oxorderarticles, oxorder ";
49  $sSelect .= "where (oxorder.oxpaid>0 or oxorder.oxsenddate > 0) and oxorderarticles.oxstorno != '1' and oxorderarticles.oxartid=".$oDB->quote( $soxId );
50  $sSelect .= "and oxorder.oxid =oxorderarticles.oxorderid";
51  $this->_aViewData["soldcnt"] = $iSoldCnt = (float) $oDB->getOne( $sSelect);;
52 
53  // canceled amount
54  $sSelect = "select sum(oxamount) from oxorderarticles where oxstorno = '1' and oxartid=".$oDB->quote( $soxId );
55  $this->_aViewData["canceledcnt"] = $iCanceledCnt = (float) $oDB->getOne( $sSelect);
56 
57  // not yet processed
58  $this->_aViewData["leftordercnt"] = $iTotalOrderCnt - $iSoldCnt - $iCanceledCnt;
59 
60  // position in top ten
61  $sSelect = "select oxartid,sum(oxamount) as cnt from oxorderarticles group by oxartid order by cnt desc";
62 
63  $rs = $oDB->execute( $sSelect );
64  $iTopPos = 0;
65  $iPos = 0;
66  if ( $rs != false && $rs->recordCount() > 0) {
67  while (!$rs->EOF) {
68  $iPos++;
69  if( $rs->fields[0] == $soxId)
70  $iTopPos = $iPos;
71  $rs->moveNext();
72  }
73  }
74 
75  $this->_aViewData["postopten"] = $iTopPos;
76  $this->_aViewData["toptentotal"] = $iPos;
77  }
78 
79  $this->_aViewData["afolder"] = $myConfig->getConfigParam( 'aProductfolder' );
80  $this->_aViewData["aSubclass"] = $myConfig->getConfigParam( 'aArticleClasses' );
81 
82  return "article_overview.tpl";
83  }
84 
85 }