Skip to content

Commit

Permalink
#3 [Mod] add: create table + insert dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
evarisk-francois committed Aug 8, 2024
1 parent 01b5567 commit c8c96b5
Show file tree
Hide file tree
Showing 7 changed files with 182 additions and 5 deletions.
48 changes: 47 additions & 1 deletion admin/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,57 @@

// Subheader
$linkback = '<a href="' . ($backtopage ?: DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1') . '">' . $langs->trans('BackToModuleList') . '</a>';
print load_fiche_titre($title, $linkback, 'digikanban_color@digikanban');
print load_fiche_titre($title, $linkback, 'title_setup');

// Configuration header
$head = digikanban_admin_prepare_head();
print dol_get_fiche_head($head, 'settings', $title, -1, 'digikanban_color@digikanban');

print load_fiche_titre($langs->trans('GeneralConfig'), '', '');

print '<table class="noborder centpercent"><tr class="liste_titre">';
print '<td>' . $langs->trans('Name') . '</td>';
print '<td>' . $langs->trans('Description') . '</td>';
print '<td class="center">' . $langs->trans('Status') . '</td></tr>';

print '<tr class="oddeven"><td>';
print $langs->trans('DefaultAllProjects');
print '</td><td>';
print $langs->trans('DefaultAllProjectsDescription');
print '</td>';

print '<td class="center">';
print ajax_constantonoff('DIGIKANBAN_DEFAULT_SELECT_ALL_PROJECTS');
print '</td>';
print '</tr>';

print '<tr class="oddeven"><td>';
print $langs->trans('HideDoneTasks');
print '</td><td>';
print $langs->trans('HideDoneTasksDescription');
print '</td>';

print '<td class="center">';
print ajax_constantonoff('DIGIKANBAN_DEFAULT_HIDE_DONE_TASKS');
print '</td>';
print '</tr>';

print '<table>';

print load_fiche_titre($langs->trans('FilterConfig'), '', '');

print '<table class="noborder centpercent"><tr class="liste_titre">';
print '<td>' . $langs->trans('Name') . '</td>';
print '<td>' . $langs->trans('Description') . '</td>';
print '<td class="center">' . $langs->trans('Valeur') . '</td></tr>';

print '<tr class="oddeven"><td>';
print $langs->trans('FilterDateRange');
print '</td><td>';
print $langs->trans('FilterDateRangeDescription');
print '</td>';

print '<table>';

$db->close();
llxFooter();
61 changes: 57 additions & 4 deletions core/modules/modDigiKanban.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ public function __construct($db)
// );
$i = 0;
$this->const = [
// CONST CONFIG
$i++ => ['DIGIKANBAN_DEFAULT_SELECT_ALL_PROJECTS', 'integer', 1, '', 0, 'current'],
$i++ => ['DIGIKANBAN_DEFAULT_HIDE_DONE_TASKS', 'integer', 1, '', 0, 'current'],

// CONST MODULE
$i++ => ['DIGIKANBAN_VERSION','chaine', $this->version, '', 0, 'current'],
$i++ => ['DIGIKANBAN_DB_VERSION', 'chaine', $this->version, '', 0, 'current'],
Expand All @@ -179,7 +183,36 @@ public function __construct($db)
$this->tabs = [];

// Dictionaries.
$this->dictionaries = [];
$this->dictionaries = [
'langs' => 'digikanban@digikanban',
'tabname' => [
MAIN_DB_PREFIX . 'c_tasks_columns',
],
'tablib' => [
'TasksColumns',
],
'tabsql' => [
'SELECT t.rowid as rowid, t.ref, t.label, lowerpercent, upperpercent, t.position, t.active FROM ' . MAIN_DB_PREFIX . 'c_tasks_columns as t',
],
'tabsqlsort' => [
'position ASC',
],
'tabfield' => [
'ref,label,lowerpercent,upperpercent,position',
],
'tabfieldvalue' => [
'ref,label,lowerpercent,upperpercent,position',
],
'tabfieldinsert' => [
'ref,label,lowerpercent,upperpercent,position',
],
'tabrowid' => [
'rowid',
],
'tabcond' => [
$conf->digikanban->enabled,
]
];

// Boxes/Widgets
// Add here list of php file(s) stored in digikanban/core/boxes that contains a class to show a widget
Expand Down Expand Up @@ -277,22 +310,42 @@ public function init($options = ''): int
{
global $conf;

// Permissions
$this->remove($options);
if ($this->error > 0) {
setEventMessages('', $this->errors, 'errors');
return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
}

$sql = [];
$result = $this->_load_tables('/digikanban/sql/');

// Load sql sub folders
$sqlFolder = scandir(__DIR__ . '/../../sql');
foreach ($sqlFolder as $subFolder) {
if ( ! preg_match('/\./', $subFolder)) {
$this->_load_tables('/digikanban/sql/' . $subFolder . '/');
}
}

if ($result < 0) {
return -1;
} // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')

dolibarr_set_const($this->db, 'DIGIKANBAN_VERSION', $this->version, 'chaine', 0, '', $conf->entity);
dolibarr_set_const($this->db, 'DIGIKANBAN_DB_VERSION', $this->version, 'chaine', 0, '', $conf->entity);

// Permissions
$this->remove($options);

$result = $this->_init($sql, $options);

// Create extrafields during init
// require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
// $extraFields = new ExtraFields($this->db);
//
// //$extraFields->update('label', $langs->transnoentities('Label'), 'varchar', '', 'contrat', 0, 0, 1040, '', '', '', 1);
// //$extraFields->addExtraField('label', $langs->transnoentities('Label'), 'varchar', 1040, '', 'contrat', 0, 0, '', '', '', '', 1);

return $this->_init($sql, $options);
return $result;
}

/**
Expand Down
14 changes: 14 additions & 0 deletions langs/fr_FR/digikanban.lang
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,24 @@ DigiKanbanDescriptionLong = Création d'urls raccourcies pour YOURLS et Dolibarr
#

# Data - Donnée
ColumnsManagement = Gestion des colonnes
ColumnList = Liste des colonnes

# Dictionaries - Dictionnaires
TasksColumns = Colonnes des tâches
NotStarted = Non démarrée
InProgress = En cours
Completed = Completée

#
# Other - Autre
#

# Data - Donnée
DefaultAllProjects = Sélectionner tous les projets
DefaultAllProjectsDescription = Sélectionner par défaut tous les projets
HideDoneTasks = Cacher les tâches réalisées
HideDoneTasksDescription = Cacher par défaut toutes les tâches déjà réalisées
FilterConfig = Configuration des filtres
FilterDateRange = Plage de dates par défaut
FilterDateRangeDescription = Plage de dates par défaut pour le filtrage des tâches
22 changes: 22 additions & 0 deletions sql/data.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-- Copyright (C) 2024 EVARISK <[email protected]>
--
-- 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.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see https://www.gnu.org/licenses/.

-- 1.0.0

INSERT INTO `llx_c_tasks_columns` (`rowid`, `entity`, `ref`, `label`, `description`, `active`, `lowerpercent`, `upperpercent`, `position`) VALUES(1, 0, 'Backlog', 'Backlog', 'BacklogDescription', 1, '0', '20', 1);
INSERT INTO `llx_c_tasks_columns` (`rowid`, `entity`, `ref`, `label`, `description`, `active`, `lowerpercent`, `upperpercent`, `position`) VALUES(2, 0, 'ToDo', 'ToDo', 'ToDoDescription', 1, '21', '40', 10);
INSERT INTO `llx_c_tasks_columns` (`rowid`, `entity`, `ref`, `label`, `description`, `active`, `lowerpercent`, `upperpercent`, `position`) VALUES(3, 0, 'InProgress', 'InProgress', 'InProgressDescription', 1, '41', '60', 20);
INSERT INTO `llx_c_tasks_columns` (`rowid`, `entity`, `ref`, `label`, `description`, `active`, `lowerpercent`, `upperpercent`, `position`) VALUES(4, 0, 'InReview', 'InReview', 'InReviewDescription', 1, '61', '80', 30);
INSERT INTO `llx_c_tasks_columns` (`rowid`, `entity`, `ref`, `label`, `description`, `active`, `lowerpercent`, `upperpercent`, `position`) VALUES(5, 0, 'Done', 'Done', 'DoneDescription', 1, '81', '100', 40);
2 changes: 2 additions & 0 deletions sql/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
//Silence is golden
26 changes: 26 additions & 0 deletions sql/llx_c_tasks_columns.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
-- Copyright (C) 2024 EVARISK <[email protected]>
--
-- 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.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see https://www.gnu.org/licenses/.

CREATE TABLE llx_c_tasks_columns(
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
entity integer default 1,
ref varchar(128),
label varchar(255),
description text,
active tinyint(4) DEFAULT 1,
lowerpercent double(5,2) DEFAULT NULL,
upperpercent double(5,2) DEFAULT NULL,
position integer DEFAULT 0
) ENGINE=innodb;
14 changes: 14 additions & 0 deletions sql/update.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-- Copyright (C) 2024 EVARISK <[email protected]>
--
-- 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.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see https://www.gnu.org/licenses/.

0 comments on commit c8c96b5

Please sign in to comment.