order_list.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class Order_List extends oxAdminList
00009 {
00015     protected $_sListClass = 'oxorder';
00016 
00022     protected $_blDesc = true;
00023 
00029     protected $_sDefSort = "oxorder.oxorderdate";
00030 
00037     public function render()
00038     {
00039         parent::render();
00040 
00041         $aFolders = $this->getConfig()->getConfigParam( 'aOrderfolder' );
00042         $sFolder  = oxConfig::getParameter( "folder" );
00043         // first display new orders
00044         if ( !$sFolder && is_array( $aFolders )) {
00045             $aNames = array_keys( $aFolders );
00046             $sFolder = $aNames[0];
00047         }
00048 
00049         $aSearch    = array( 'oxorderarticles' => 'ARTID', 'oxpayments' => 'PAYMENT');
00050         $sSearch    = oxConfig::getParameter( "addsearch" );
00051         $sSearchfld = oxConfig::getParameter( "addsearchfld" );
00052 
00053         $this->_aViewData["folder"]       = $sFolder ? $sFolder : -1;
00054         $this->_aViewData["addsearchfld"] = $sSearchfld ? $sSearchfld : -1;
00055         $this->_aViewData["asearch"]      = $aSearch;
00056         $this->_aViewData["addsearch"]    = $sSearch;
00057         $this->_aViewData["afolder"]      = $aFolders;
00058 
00059         return "order_list.tpl";
00060     }
00061 
00070     protected function _prepareWhereQuery( $aWhere, $sqlFull )
00071     {
00072         $oDb = oxDb::getDb();
00073         $sQ = parent::_prepareWhereQuery( $aWhere, $sqlFull );
00074         $myConfig = $this->getConfig();
00075         $aFolders = $myConfig->getConfigParam( 'aOrderfolder' );
00076         $sFolder = oxConfig::getParameter( 'folder' );
00077         //searchong for empty oxfolder fields
00078         if ( $sFolder && $sFolder != '-1' ) {
00079             $sQ .= " and ( oxorder.oxfolder = ".$oDb->quote( $sFolder )." ";
00080             //deprecated check for old orders
00081             $sQ .= "or oxorder.oxfolder = ".$oDb->quote( oxLang::getInstance()->translateString( $sFolder ) )." )";
00082         } elseif ( !$sFolder && is_array( $aFolders ) ) {
00083             $aFolderNames = array_keys( $aFolders );
00084             $sQ .= " and ( oxorder.oxfolder = ".$oDb->quote( $aFolderNames[0] )." ";
00085             //deprecated check for old orders
00086             $sQ .= "or oxorder.oxfolder = ".$oDb->quote( oxLang::getInstance()->translateString($aFolderNames[0] ) )." )";
00087         }
00088 
00089         return $sQ;
00090     }
00091 
00099     protected function _buildSelectString( $oListObject = null )
00100     {
00101         $sSql = parent::_buildSelectString( $oListObject );
00102         $oDb = oxDb::getDb();
00103 
00104         $sSearch      = oxConfig::getParameter( 'addsearch' );
00105         $sSearch      = trim( $sSearch );
00106         $sSearchField = oxConfig::getParameter( 'addsearchfld' );
00107 
00108         if ( $sSearch ) {
00109             switch ( $sSearchField ) {
00110             case 'oxorderarticles':
00111                 $sQ = "oxorder left join oxorderarticles on oxorderarticles.oxorderid=oxorder.oxid where ( oxorderarticles.oxartnum like ".$oDb->quote( "%{$sSearch}%" ) ." or oxorderarticles.oxtitle like ".$oDb->quote( "%{$sSearch}%" )." ) and ";
00112                 break;
00113             case 'oxpayments':
00114                 $sQ = "oxorder left join oxpayments on oxpayments.oxid=oxorder.oxpaymenttype where oxpayments.oxdesc like ".$oDb->quote( "%{$sSearch}%" ) ." and ";
00115                 break;
00116             default:
00117                 $sQ = "oxorder where oxorder.oxpaid like ".$oDb->quote( "%{$sSearch}%" )." and ";
00118                 break;
00119             }
00120             $sSql = str_replace( 'oxorder where', $sQ, $sSql);
00121         }
00122 
00123         return $sSql;
00124     }
00125 
00131     public function storno()
00132     {
00133         $myConfig = $this->getConfig();
00134         $soxId    = oxConfig::getParameter( "oxid");
00135 
00136         $oOrder = oxNew( "oxorder" );
00137         if ( $oOrder->load( $soxId ) ) {
00138             $oOrder->cancelOrder();
00139         }
00140 
00141 
00142         //we call init() here to load list items after sorno()
00143         $this->init();
00144     }
00145 
00153     protected function _prepareOrderByQuery( $sSql = null )
00154     {
00155         $sSortParam = oxConfig::getParameter( 'sort' );
00156         //setting sort order as ASC for oxbilllname column
00157         if ( $sSortParam && $sSortParam == 'oxorder.oxbilllname' ) {
00158            $this->_blDesc = false;
00159         }
00160 
00161         return parent::_prepareOrderByQuery( $sSql );
00162     }
00163 }