OXID eShop CE  4.8.10
 All Classes Files Functions Variables Pages
order_list.php
Go to the documentation of this file.
1 <?php
2 
8 class Order_List extends oxAdminList
9 {
15  protected $_sListClass = 'oxorder';
16 
22  protected $_blDesc = true;
23 
29  protected $_sDefSortField = "oxorderdate";
30 
37  public function render()
38  {
40 
41  $aFolders = $this->getConfig()->getConfigParam( 'aOrderfolder' );
42  $sFolder = oxConfig::getParameter( "folder" );
43  // first display new orders
44  if ( !$sFolder && is_array( $aFolders )) {
45  $aNames = array_keys( $aFolders );
46  $sFolder = $aNames[0];
47  }
48 
49  $aSearch = array( 'oxorderarticles' => 'ARTID', 'oxpayments' => 'PAYMENT');
50  $sSearch = oxConfig::getParameter( "addsearch" );
51  $sSearchfld = oxConfig::getParameter( "addsearchfld" );
52 
53  $this->_aViewData["folder"] = $sFolder ? $sFolder : -1;
54  $this->_aViewData["addsearchfld"] = $sSearchfld ? $sSearchfld : -1;
55  $this->_aViewData["asearch"] = $aSearch;
56  $this->_aViewData["addsearch"] = $sSearch;
57  $this->_aViewData["afolder"] = $aFolders;
58 
59  return "order_list.tpl";
60  }
61 
70  protected function _prepareWhereQuery( $aWhere, $sqlFull )
71  {
72  $oDb = oxDb::getDb();
73  $sQ = parent::_prepareWhereQuery( $aWhere, $sqlFull );
74  $myConfig = $this->getConfig();
75  $aFolders = $myConfig->getConfigParam( 'aOrderfolder' );
76  $sFolder = oxConfig::getParameter( 'folder' );
77  //searchong for empty oxfolder fields
78  if ( $sFolder && $sFolder != '-1' ) {
79  $sQ .= " and ( oxorder.oxfolder = ".$oDb->quote( $sFolder )." )";
80  } elseif ( !$sFolder && is_array( $aFolders ) ) {
81  $aFolderNames = array_keys( $aFolders );
82  $sQ .= " and ( oxorder.oxfolder = ".$oDb->quote( $aFolderNames[0] )." )";
83  }
84 
85  return $sQ;
86  }
87 
95  protected function _buildSelectString( $oListObject = null )
96  {
97  $sSql = parent::_buildSelectString( $oListObject );
98  $oDb = oxDb::getDb();
99 
100  $sSearch = oxConfig::getParameter( 'addsearch' );
101  $sSearch = trim( $sSearch );
102  $sSearchField = oxConfig::getParameter( 'addsearchfld' );
103 
104  if ( $sSearch ) {
105  switch ( $sSearchField ) {
106  case 'oxorderarticles':
107  $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 ";
108  break;
109  case 'oxpayments':
110  $sQ = "oxorder left join oxpayments on oxpayments.oxid=oxorder.oxpaymenttype where oxpayments.oxdesc like ".$oDb->quote( "%{$sSearch}%" ) ." and ";
111  break;
112  default:
113  $sQ = "oxorder where oxorder.oxpaid like ".$oDb->quote( "%{$sSearch}%" )." and ";
114  break;
115  }
116  $sSql = str_replace( 'oxorder where', $sQ, $sSql);
117  }
118 
119  return $sSql;
120  }
121 
127  public function storno()
128  {
129  $oOrder = oxNew( "oxorder" );
130  if ( $oOrder->load( $this->getEditObjectId() ) ) {
131  $oOrder->cancelOrder();
132  }
133 
134 
135  //we call init() here to load list items after sorno()
136  $this->init();
137  }
138 
144  public function getListSorting()
145  {
146  $aSorting = parent::getListSorting();
147  if ( isset( $aSorting["oxorder"]["oxbilllname"] )) {
148  $this->_blDesc = false;
149  }
150  return $aSorting;
151  }
152 }