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