list_order.php

Go to the documentation of this file.
00001 <?php
00002 
00006 class List_Order extends Order_List
00007 {
00008 
00014     protected $_blDesc = false;
00015 
00021     public function getListSorting()
00022     {
00023         $aSort = oxRegistry::getConfig()->getRequestParameter('sort');
00024         if ($this->_aCurrSorting === null && isset($aSort[0]['oxorderdate'])) {
00025             $this->_aCurrSorting[]["max(oxorder.oxorderdate)"] = "desc";
00026 
00027             return $this->_aCurrSorting;
00028         } else {
00029             return parent::getListSorting();
00030         }
00031     }
00032 
00038     protected function _getViewListSize()
00039     {
00040         return $this->_getUserDefListSize();
00041     }
00042 
00049     public function render()
00050     {
00051         oxAdminList::render();
00052 
00053         $this->_aViewData["menustructure"] = $this->getNavigation()->getDomXml()->documentElement->childNodes;
00054 
00055         return "list_order.tpl";
00056     }
00057 
00058 
00067     public function _prepareWhereQuery($aWhere, $sqlFull)
00068     {
00069         $sQ = oxAdminList::_prepareWhereQuery($aWhere, $sqlFull);
00070         $sQ .= " group by oxorderarticles.oxartnum";
00071 
00072         return $sQ;
00073     }
00074 
00080     protected function _calcListItemsCount($sSql)
00081     {
00082         $oStr = getStr();
00083 
00084         // count SQL
00085         $sSql = $oStr->preg_replace('/select .* from/', 'select count(*) from ', $sSql);
00086 
00087         // removing order by
00088         $sSql = $oStr->preg_replace('/order by .*$/', '', $sSql);
00089 
00090         // con of list items which fits current search conditions
00091         $this->_iListSize = oxDb::getDb()->getOne("select count(*) from ( $sSql ) as test", false, false);
00092 
00093         // set it into session that other frames know about size of DB
00094         oxRegistry::getSession()->setVariable('iArtCnt', $this->_iListSize);
00095     }
00096 
00104     protected function _buildSelectString($oObject = null)
00105     {
00106         return 'select oxorderarticles.oxid, oxorder.oxid as oxorderid, max(oxorder.oxorderdate) as oxorderdate, oxorderarticles.oxartnum, sum( oxorderarticles.oxamount ) as oxorderamount, oxorderarticles.oxtitle, round( sum(oxorderarticles.oxbrutprice*oxorder.oxcurrate),2) as oxprice from oxorderarticles left join oxorder on oxorder.oxid=oxorderarticles.oxorderid where 1 ';
00107     }
00108 
00116     protected function _prepareOrderByQuery($sSql = null)
00117     {
00118         // calculating sum
00119         $sSumQ = getStr()->preg_replace(array("/select .*? from/", "/group by oxorderarticles.oxartnum/"), array("select round( sum(oxorderarticles.oxbrutprice*oxorder.oxcurrate),2) from", ""), $sSql);
00120         $this->_aViewData["sumresult"] = oxDb::getDb()->getOne($sSumQ, false, false);
00121 
00122         return parent::_prepareOrderByQuery($sSql);
00123     }
00124 }