Webgui: user definable menu implemented
This commit is contained in:
+83
-10
@@ -235,6 +235,7 @@ class User {
|
||||
public $vessel; // name of current vessel
|
||||
public $datefmt;
|
||||
public $rows_pp;
|
||||
public $menu;
|
||||
|
||||
private function __construct() {
|
||||
global $g_rows_pp;
|
||||
@@ -245,6 +246,7 @@ class User {
|
||||
$this->vessel = 'Yacht';
|
||||
$this->datefmt = 'Y-m-d';
|
||||
$this->rows_pp = $g_rows_pp;
|
||||
$this->menu = [1, 2, 3, 4, 5, 6];
|
||||
}
|
||||
|
||||
public static function getInstance() {
|
||||
@@ -350,6 +352,18 @@ class User {
|
||||
if ($user_rows_pp) {
|
||||
$this->rows_pp = $user_rows_pp;
|
||||
}
|
||||
// user defined menu
|
||||
$sql = "SELECT valstr FROM settings WHERE userid=? AND sno=3";
|
||||
$sth = $pdo->prepare($sql);
|
||||
$sth->execute([$this->id]);
|
||||
$res = $sth->fetchColumn();
|
||||
if ($res === false) {
|
||||
$sql = "INSERT INTO settings (userid, sno, valstr) VALUES (?, 3, ?)";
|
||||
$sth = $pdo->prepare($sql);
|
||||
$sth->execute([$this->id, implode(',', $this->menu)]);
|
||||
} else {
|
||||
$this->menu = array_map('intval', explode(',', $res));
|
||||
}
|
||||
}
|
||||
|
||||
function get_last_error() {
|
||||
@@ -1455,13 +1469,72 @@ function normalize_phone_e164($phone) {
|
||||
|
||||
// ========== MENU FUNCTIONS ==================================================
|
||||
|
||||
$g_menu = Array (
|
||||
'equipment.php' => [_('Equipment')],
|
||||
'inventory.php' => [_('Inventory')],
|
||||
'provisions.php' => [_('Provisions')],
|
||||
'maintenance.php' => [_('Maintenance')],
|
||||
'projects.php' => [_('Projects')],
|
||||
'documents.php' => [_('Documents')],
|
||||
'manual.php' => ['<i class="bi-book"></i>'],
|
||||
'logout.php' => ['<i class="bi-door-open"></i>']
|
||||
);
|
||||
$g_modules = Array(
|
||||
1 => ['file' => 'equipment.php',
|
||||
'title' => _('Equipment'),
|
||||
'type' => 'primary',
|
||||
'group' => 'main'],
|
||||
2 => ['file' => 'inventory.php',
|
||||
'title' => _('Inventory'),
|
||||
'type' => 'primary',
|
||||
'group' => 'main'],
|
||||
3 => ['file' => 'provisions.php',
|
||||
'title' => _('Provisions'),
|
||||
'type' => 'primary',
|
||||
'group' => 'main'],
|
||||
4 => ['file' => 'maintenance.php',
|
||||
'title' => _('Maintenance'),
|
||||
'type' => 'primary',
|
||||
'group' => 'main'],
|
||||
5 => ['file' => 'projects.php',
|
||||
'title' => _('Projects'),
|
||||
'type' => 'primary',
|
||||
'group' => 'main'],
|
||||
6 => ['file' => 'documents.php',
|
||||
'title' => _('Documents'),
|
||||
'type' => 'primary',
|
||||
'group' => 'main'],
|
||||
7 => ['file' => 'company.php',
|
||||
'title' => _('Companies'),
|
||||
'type' => 'primary',
|
||||
'group' => 'base'],
|
||||
8 => ['file' => 'task.php',
|
||||
'title' => _('Task'),
|
||||
'type' => 'primary',
|
||||
'group' => 'extra'],
|
||||
9 => ['file' => 'measurement.php',
|
||||
'title' => _('Measurement'),
|
||||
'type' => 'primary',
|
||||
'group' => 'extra'],
|
||||
10 => ['file' => 'storage.php',
|
||||
'title' => _('Storage'),
|
||||
'type' => 'primary',
|
||||
'group' => 'base'],
|
||||
11 => ['file' => 'box.php',
|
||||
'title' => _('Boxes'),
|
||||
'type' => 'primary',
|
||||
'group' => 'extra'],
|
||||
12 => ['file' => 'cable.php',
|
||||
'title' => _('Cables'),
|
||||
'type' => 'primary',
|
||||
'group' => 'extra'],
|
||||
13 => ['file' => 'fuse.php',
|
||||
'title' => _('Fuses'),
|
||||
'type' => 'primary',
|
||||
'group' => 'extra'],
|
||||
14 => ['file' => 'checklist.php',
|
||||
'title' => _('Checklists'),
|
||||
'type' => 'primary',
|
||||
'group' => 'extra'],
|
||||
15 => ['file' => 'tag.php',
|
||||
'title' => _('Tags'),
|
||||
'type' => 'secondary',
|
||||
'group' => 'base'],
|
||||
16 => ['file' => 'settings.php',
|
||||
'title' => _('Settings'),
|
||||
'type' => 'secondary',
|
||||
'group' => 'extra'],
|
||||
17 => ['file' => 'dropdown.php',
|
||||
'title' => _('Selection lists'),
|
||||
'type' => 'secondary',
|
||||
'group' => 'base']);
|
||||
|
||||
Reference in New Issue
Block a user