00001 <?php
00002
00007 class List_Order extends oxAdminList
00008 {
00015 public function render()
00016 {
00017 $this->_oList = oxNew( "oxlist", "core" );
00018 $this->_oList->setSqlLimit( 0, 5000 );
00019 $this->_oList->init( "oxbase", "oxorder" );
00020
00021 $aWhere = $this->buildWhere();
00022
00023 $sSql = $this->_buildSelectString( $this->_oList->getBaseObject() );
00024 $sSql = $this->_prepareWhereQuery( $aWhere, $sSql );
00025
00026
00027 $sSumQ = preg_replace("/select .*? from/", "select round( sum(oxorderarticles.oxbrutprice*oxorder.oxcurrate),2) from", $sSql );
00028 $this->_aViewData["sumresult"] = oxDb::getDb()->getOne( $sSumQ );
00029
00030 $sSql = $this->_prepareOrderByQuery( $sSql );
00031 $sSql = $this->_changeselect( $sSql );
00032 $this->_oList->selectString( $sSql );
00033
00034 parent::render();
00035
00036 $aWhere = oxConfig::getParameter( "where");
00037 if ( is_array( $aWhere ) ) {
00038 foreach ( $aWhere as $sField => $sValue ) {
00039 $this->_aViewData["where"]->{str_replace( '.', '__', $sField )} = $sValue;
00040 }
00041 }
00042
00043 $this->_aViewData["menustructure"] = $this->getNavigation()->getDomXml()->documentElement->childNodes;
00044
00045 return "list_order.tpl";
00046 }
00047
00051 protected function _buildSelectString( $oObject = null )
00052 {
00053 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 ';
00054 }
00055
00063 protected function _prepareOrderByQuery( $sSql = null )
00064 {
00065 $sSql = " $sSql group by oxorderarticles.oxartnum";
00066 if ( $sSort = oxConfig::getParameter( "sort" ) ) {
00067 $sSortDesc = ($sSort == 'oxorder.oxorderdate') ? 'DESC' : '';
00068 $sSql .= " order by $sSort " . $sSortDesc;
00069 }
00070
00071 return $sSql;
00072 }
00073 }