From cb5c49906803fa805a21d06e612dd9a0941aee39 Mon Sep 17 00:00:00 2001 From: Abdy Franco Date: Mon, 1 Jun 2026 17:08:01 -0600 Subject: [PATCH] Added icons --- client_cards_plugin.php | 59 ++++++++++++++++++++++++++++++++++++++--- config.json | 2 +- 2 files changed, 56 insertions(+), 5 deletions(-) diff --git a/client_cards_plugin.php b/client_cards_plugin.php index efd506c..73362be 100644 --- a/client_cards_plugin.php +++ b/client_cards_plugin.php @@ -20,6 +20,55 @@ public function __construct() $this->loadConfig(dirname(__FILE__) . DS . 'config.json'); } + /** + * Performs migration of data from $current_version (the current installed version) + * to the given file set version + * + * @param string $current_version The current installed version of this plugin + * @param int $plugin_id The ID of the plugin being upgraded + */ + public function upgrade($current_version, $plugin_id) + { + if (!isset($this->Record)) { + Loader::loadComponents($this, ['Record']); + } + + // Upgrade to 1.3.0 + if (version_compare($current_version, '1.3.0', '<')) { + $this->updateCardColors(); + } + } + + /** + * Updates the default card background colors to match the Meridian palette + * (services -> primary blue, invoices -> warning amber). Only cards still using the + * previous default colors are updated, preserving any admin customizations. + */ + private function updateCardColors() + { + // Map the previous default backgrounds to the new Meridian palette + $colors = ['#ffc107' => '#2563eb', '#28a746' => '#d97706']; + + // Gather this plugin's instances across all companies + $plugins = $this->Record->select(['id']) + ->from('plugins') + ->where('dir', '=', 'client_cards') + ->fetchAll(); + $plugin_ids = array_map(function ($plugin) { + return $plugin->id; + }, $plugins); + + if (empty($plugin_ids)) { + return; + } + + foreach ($colors as $from => $to) { + $this->Record->where('plugin_id', 'in', $plugin_ids) + ->where('background', '=', $from) + ->update('plugin_cards', ['background' => $to]); + } + } + /** * Retrieves the total number of active and suspended services * @@ -79,9 +128,10 @@ public function getCards() 'callback' => ['this', 'getServicesCount'], 'callback_type' => 'value', 'label' => 'ClientCardsPlugin.card_client.services', - 'text_color' => '#fffaeb', - 'background' => '#ffc107', + 'text_color' => '#ffffff', + 'background' => '#2563eb', 'background_type' => 'color', + 'icon' => 'bi bi-hdd-stack', 'link' => 'services/index/active/', 'enabled' => 1 ], @@ -90,9 +140,10 @@ public function getCards() 'callback' => ['this', 'getInvoicesCount'], 'callback_type' => 'value', 'label' => 'ClientCardsPlugin.card_client.invoices', - 'text_color' => '#e4f5e7', - 'background' => '#28a746', + 'text_color' => '#ffffff', + 'background' => '#d97706', 'background_type' => 'color', + 'icon' => 'bi bi-receipt', 'link' => 'invoices/index/open/', 'enabled' => 1 ] diff --git a/config.json b/config.json index 3cde5e3..4970f33 100644 --- a/config.json +++ b/config.json @@ -1,5 +1,5 @@ { - "version": "1.2.0", + "version": "1.3.0", "name": "ClientCardsPlugin.name", "description": "ClientCardsPlugin.description", "authors": [