| Server IP : 85.158.181.41 / Your IP : 216.73.217.12 Web Server : Apache System : Linux cloud9-vm129 6.1.178+1-ph #ph SMP PREEMPT_DYNAMIC Wed Jul 29 09:00:54 UTC 2026 x86_64 User : moncbefd ( 1024) PHP Version : 7.3.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/moncbefd/www.moneta.at/GXMainComponents/Extensions/Orders/ |
Upload File : |
<?php
/* --------------------------------------------------------------
OrderStatusStyles.inc.php 2018-07-24
Gambio GmbH
http://www.gambio.de
Copyright (c) 2017 Gambio GmbH
Released under the GNU General Public License (Version 2)
[http://www.gnu.org/licenses/gpl-2.0.html]
--------------------------------------------------------------
*/
/**
* Class OrderStatusStyles
*
* This class works in cooperation with the "admin/html/content/layouts/main/partial/order_status_styles.html" to
* provide the dynamic styling of the order status labels.
*
* @category System
* @package Extensions
* @subpackage Orders
*/
class OrderStatusStyles
{
/**
* @var CI_DB_query_builder
*/
protected $db;
/**
* OrderStatusStyles constructor.
*
* @param CI_DB_query_builder $db
*/
public function __construct(CI_DB_query_builder $db)
{
$this->db = $db;
}
/**
* Get the order status styles for the "order_status_styles.html" partial.
*
* Include the order_status_styles.html in your template and pass in a variable with the "order_status_styles"
* name. The template will output a <style> tag with the colors for each status.
*
* @return array
*
* @throws UnexpectedValueException
* @throws InvalidArgumentException
*/
public function getStyles()
{
$rows = $this->db->select('orders_status_id, color')
->from('orders_status')
->group_by('orders_status_id, color')
->get()
->result_array();
$orderStatusStyles = [];
foreach ($rows as $row) {
$color = $row['color'];
if ($row['color'] === '') {
$color = '#FFFFFF'; // Use fallback color to prevent errors if color is not set properly
}
$orderStatusStyles[] = [
'id' => $row['orders_status_id'],
'color' => ColorHelper::getLuminance(new StringType($color)) > 143 ? '#333' : '#FFF',
'background_color' => '#' . $row['color']
];
}
return $orderStatusStyles;
}
}