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 $_sDefSortField = "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         } elseif ( !$sFolder && is_array( $aFolders ) ) {
00081             $aFolderNames = array_keys( $aFolders );
00082             $sQ .= " and ( oxorder.oxfolder = ".$oDb->quote( $aFolderNames[0] )." )";
00083         }
00084 
00085         return $sQ;
00086     }
00087 
00095     protected function _buildSelectString( $oListObject = null )
00096     {
00097         $sSql = parent::_buildSelectString( $oListObject );
00098         $oDb = oxDb::getDb();
00099 
00100         $sSearch      = oxConfig::getParameter( 'addsearch' );
00101         $sSearch      = trim( $sSearch );
00102         $sSearchField = oxConfig::getParameter( 'addsearchfld' );
00103 
00104         if ( $sSearch ) {
00105             switch ( $sSearchField ) {
00106             case 'oxorderarticles':
00107                 $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 ";
00108                 break;
00109             case 'oxpayments':
00110                 $sQ = "oxorder left join oxpayments on oxpayments.oxid=oxorder.oxpaymenttype where oxpayments.oxdesc like ".$oDb->quote( "%{$sSearch}%" ) ." and ";
00111                 break;
00112             default:
00113                 $sQ = "oxorder where oxorder.oxpaid like ".$oDb->quote( "%{$sSearch}%" )." and ";
00114                 break;
00115             }
00116             $sSql = str_replace( 'oxorder where', $sQ, $sSql);
00117         }
00118 
00119         return $sSql;
00120     }
00121 
00127     public function storno()
00128     {
00129         $oOrder = oxNew( "oxorder" );
00130         if ( $oOrder->load( $this->getEditObjectId() ) ) {
00131             $oOrder->cancelOrder();
00132         }
00133 
00134 
00135         //we call init() here to load list items after sorno()
00136         $this->init();
00137     }
00138 
00144     public function getListSorting()
00145     {
00146         $aSorting = parent::getListSorting();
00147         if ( isset( $aSorting["oxorder"]["oxbilllname"] )) {
00148             $this->_blDesc = false;
00149         }
00150         return $aSorting;
00151     }
00152 }