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