* * 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 metallzuschlag/metallzuschlagindex.php * \ingroup metallzuschlag * \brief Metallzuschlag Dashboard - Aktuelle Notierungen und Verlauf */ // Dolibarr Umgebung laden $res = 0; if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; } $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; } if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; } if (!$res && file_exists("../main.inc.php")) { $res = @include "../main.inc.php"; } if (!$res && file_exists("../../main.inc.php")) { $res = @include "../../main.inc.php"; } if (!$res && file_exists("../../../main.inc.php")) { $res = @include "../../../main.inc.php"; } if (!$res) { die("Include of main fails"); } require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once './class/metallzuschlagapi.class.php'; require_once './lib/metallzuschlag.lib.php'; /** * @var Conf $conf * @var DoliDB $db * @var HookManager $hookmanager * @var Translate $langs * @var User $user */ $langs->loadLangs(array("metallzuschlag@metallzuschlag")); $action = GETPOST('action', 'aZ09'); // Zugriffskontrolle if (!$user->hasRight('metallzuschlag', 'read')) { accessforbidden(); } $api = new MetallzuschlagApi($db); /* * Actions */ // Manueller Abruf if ($action == 'fetch' && $user->hasRight('metallzuschlag', 'config')) { if (!verifCond(GETPOST('token', 'alpha') == newToken())) { accessforbidden('Bad CSRF token'); } $result = $api->fetchMetalNotes(); if ($result >= 0) { setEventMessages($langs->trans("MetallzuschlagFetchSuccess"), null, 'mesgs'); if (!empty($api->output)) { setEventMessages($api->output, null, 'mesgs'); } } else { setEventMessages($langs->trans("MetallzuschlagFetchError"), null, 'errors'); if (!empty($api->error)) { setEventMessages($api->error, null, 'errors'); } } header("Location: ".$_SERVER["PHP_SELF"]); exit; } /* * View */ llxHeader("", $langs->trans("MetallzuschlagDashboard"), '', '', 0, 0, '', '', '', 'mod-metallzuschlag page-index'); print load_fiche_titre($langs->trans("MetallzuschlagDashboard"), '', 'fa-coins'); // Aktuelle Werte abrufen $latestCU = $api->getLatest('CU'); $latestAL = $api->getLatest('AL'); // Info-Panels: Aktuelle Notierungen print '
| '.$langs->trans("MetallzuschlagDate").' | '; print ''.$langs->trans("MetallzuschlagMetal").' | '; print ''.$langs->trans("MetallzuschlagValue").' | '; print ''.$langs->trans("MetallzuschlagMonthAvg").' | '; print ''.$langs->trans("MetallzuschlagSourceCol").' | '; print '
| '.dol_print_date($db->jdate($row->date_notiz), 'day').' | '; print ''.metallzuschlagGetMetalLabel($row->metal).' | '; print ''.price($row->value, 0, '', 1, -1, 2).' €/100kg | '; print ''.(!empty($row->value_month_avg) ? price($row->value_month_avg, 0, '', 1, -1, 2).' €/100kg' : '-').' | '; print ''.dol_escape_htmltag($row->source).' | '; print '