forked from studio42/Virtuemart-2-Joomla-3-Bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
orderstatus.php
124 lines (106 loc) · 3.55 KB
/
orderstatus.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
/**
*
* Data module for the order status
*
* @package VirtueMart
* @subpackage OrderStatus
* @author Oscar van Eijk
* @link http://www.virtuemart.net
* @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* @version $Id: orderstatus.php 6350 2012-08-14 17:18:08Z Milbo $
*/
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die();
JLoader::register('VmModel', JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'vmmodel.php');
/**
* Model class for the order status
*
* @package VirtueMart
* @subpackage OrderStatus
* @author Oscar van Eijk
*/
class VirtueMartModelOrderstatus extends VmModel {
private $renderStatusList = null;
/**
* constructs a VmModel
* setMainTable defines the maintable of the model
* @author Max Milbers
*/
function __construct($cidName=null, $config=array()) {
parent::__construct('virtuemart_orderstate_id', $config);
VmConfig::loadJLang('com_virtuemart_orders',TRUE);
$this->setMainTable('orderstates');
}
function getVMCoreStatusCode(){
return array( 'P','S');
}
/**
* Retrieve a list of order statuses from the database.
*
* @return object List of order status objects
*/
function getOrderStatusList()
{
if (JRequest::getWord('view') !== 'orderstatus') $ordering = ' order by `ordering` ';
else $ordering = $this->_getOrdering();
$this->_noLimit=true;
$this->_data = $this->exeSortSearchListQuery(0,'*',' FROM `#__virtuemart_orderstates`','','',$ordering);
// vmdebug('order data',$this->_data);
return $this->_data ;
}
/**
* Return the order status names
*
* @author Kohl Patrick
* @access public
*
* @param char $_code Order status code
* @return string The name of the order status
*/
public function getOrderStatusNames ()
{
$q = 'SELECT `order_status_name`,`order_status_code` FROM `#__virtuemart_orderstates` order by `ordering` ';
$this->_db->setQuery($q);
return $this->_db->loadAssocList('order_status_code');
}
function renderOSList($value,$name = 'order_status',$multiple=FALSE,$attrs='',$langkey=''){
$idA = $id = $name;
$attrs .= ' class="inputbox" ';
if ($multiple) {
$attrs .= ' multiple="multiple" ';
if(empty($langkey)) $langkey = 'COM_VIRTUEMART_DRDOWN_SELECT_SOME_OPTIONS';
$attrs .= ' data-placeholder="'.JText::_($langkey).'"';
$idA .= '[]';
} else {
if(empty($langkey)) $langkey = 'COM_VIRTUEMART_LIST_EMPTY_OPTION';
}
if(is_array($value)){
$hashValue = implode($value);
} else {
$hashValue = $value;
}
$hash = md5($hashValue.$name.$attrs);
if (!isset($this->_renderStatusList[$hash])) {
$orderStates = $this->getOrderStatusNames();
$emptyOption = JHTML::_ ('select.option', -1, JText::_ ($langkey), 'order_status_code', 'order_status_name');
array_unshift ($orderStates, $emptyOption);
if ($multiple) {
$attrs .=' size="'.count($orderStates).'" ';
}
$this->_renderStatusList[$hash] = JHTML::_('select.genericlist', $orderStates, $idA, $attrs, 'order_status_code', 'order_status_name', $value,$id,true);
}
return $this->_renderStatusList[$hash] ;
}
function renderOrderStatusList($value, $name = 'order_status[]' )
{
$id = substr($name,0,-2);
return $this->renderOSList($value,$id,TRUE);
}
}
//No Closing tag