* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. */ /** * \file htdocs/custom/buchaltungswidget/class/actions_buchaltungswidget.class.php * \ingroup buchaltungswidget * \brief Hook actions for displaying payment statistics on thirdparty card */ require_once DOL_DOCUMENT_ROOT.'/core/class/commonhookactions.class.php'; /** * Class ActionsBuchaltungsWidget */ class ActionsBuchaltungsWidget extends CommonHookActions { /** * @var DoliDB Database handler */ public $db; /** * @var string Error message */ public $error = ''; /** * @var array Errors array */ public $errors = array(); /** * @var string HTML output to be printed */ public $resprints; /** * Constructor * * @param DoliDB $db Database handler */ public function __construct($db) { $this->db = $db; } /** * Hook to add payment statistics on thirdparty card view * * @param array $parameters Hook parameters * @param object $object The object being processed (Societe) * @param string $action Current action * @return int 0 = continue, > 0 = replace */ public function tabContentViewThirdparty($parameters, &$object, &$action) { global $conf, $langs, $user; // Check if feature is enabled in settings (default: enabled) if (!getDolGlobalInt('BUCHALTUNGSWIDGET_SHOW_PAYMENT_STATS', 1)) { return 0; } // Check if user has rights if (!$user->hasRight('facture', 'lire')) { return 0; } // Only show for customers (client = 1, 2 or 3) if (empty($object->client)) { return 0; } $langs->load("buchaltungswidget@buchaltungswidget"); // Get payment statistics $stats = $this->getPaymentStatistics($object->id); if ($stats['invoice_count'] == 0) { // No invoices yet return 0; } // Determine color based on payment behavior $colorClass = $this->getPaymentColorClass($stats); $icon = $this->getPaymentIcon($stats); // Build HTML output $html = ''; $html .= '