From 6bd01ce7d2c8b506c7ffb8f6d79ff041ee7a9421 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 29 Mar 2010 14:51:33 +0000 Subject: [PATCH] Works on milestone module --- .../includes/modules/modMilestone.class.php | 133 ++++++++++++++++++ .../install/mysql/migration/2.7.0-2.8.0.sql | 22 --- .../install/mysql/migration/2.8.0-2.9.0.sql | 31 ++++ .../tables/llx_element_milestone.key.sql | 29 ++++ .../mysql/tables/llx_element_milestone.sql | 28 ++++ ...ilestone.key.sql => llx_milestone.key.sql} | 6 +- ...projet_milestone.sql => llx_milestone.sql} | 5 +- 7 files changed, 225 insertions(+), 29 deletions(-) create mode 100644 htdocs/includes/modules/modMilestone.class.php create mode 100644 htdocs/install/mysql/tables/llx_element_milestone.key.sql create mode 100644 htdocs/install/mysql/tables/llx_element_milestone.sql rename htdocs/install/mysql/tables/{llx_projet_milestone.key.sql => llx_milestone.key.sql} (67%) rename htdocs/install/mysql/tables/{llx_projet_milestone.sql => llx_milestone.sql} (91%) diff --git a/htdocs/includes/modules/modMilestone.class.php b/htdocs/includes/modules/modMilestone.class.php new file mode 100644 index 00000000000..c1e31033a90 --- /dev/null +++ b/htdocs/includes/modules/modMilestone.class.php @@ -0,0 +1,133 @@ + + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * \defgroup milestone Milestone module + * \brief Module to manage milestones + * \version $Id$ + */ + +/** + * \file htdocs/includes/modules/modMilestone.class.php + * \ingroup milestone + * \brief Fichier de description et activation du module Milestone + */ +include_once(DOL_DOCUMENT_ROOT ."/includes/modules/DolibarrModules.class.php"); + + +/** + * \class modMilestone + * \brief Classe de description et activation du module Milestone + */ +class modMilestone extends DolibarrModules +{ + /** + * \brief Constructeur. definit les noms, constantes et boites + * \param DB handler d'acces base + */ + function modMilestone ($DB) + { + $this->db = $DB; + $this->numero = 1790; + + $this->family = "technic"; + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i','',get_class($this)); + $this->description = "Gestion des jalons (projets, contrats, propales, ...)"; + + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'development'; + + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + $this->special = 2; + $this->picto = 'category'; + + // Data directories to create when module is enabled + $this->dirs = array(); + + // Dependencies + $this->depends = array(); + + // Config pages + $this->config_page_url = array(); + $this->langfiles = array("milestone"); + + // Constantes + $this->const = array(); + + // Boxes + $this->boxes = array(); + + // Permissions + $this->rights = array(); + $this->rights_class = 'milestone'; + + $r=0; + + $this->rights[$r][0] = 1791; // id de la permission + $this->rights[$r][1] = 'Lire les jalons'; // libelle de la permission + $this->rights[$r][2] = 'r'; // type de la permission (deprecated) + $this->rights[$r][3] = 1; // La permission est-elle une permission par defaut + $this->rights[$r][4] = 'lire'; + $r++; + + $this->rights[$r][0] = 1792; // id de la permission + $this->rights[$r][1] = 'Creer/modifier les jalons'; // libelle de la permission + $this->rights[$r][2] = 'w'; // type de la permission (deprecated) + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut + $this->rights[$r][4] = 'creer'; + $r++; + + $this->rights[$r][0] = 1793; // id de la permission + $this->rights[$r][1] = 'Supprimer les jalons'; // libelle de la permission + $this->rights[$r][2] = 'd'; // type de la permission (deprecated) + $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut + $this->rights[$r][4] = 'supprimer'; + $r++; + + } + + + /** + * \brief Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories. + * \return int 1 if OK, 0 if KO + */ + function init() + { + $sql = array(); + + return $this->_init($sql); + } + + /** + * \brief Function called when module is disabled. + * Remove from database constants, boxes and permissions from Dolibarr database. + * Data directories are not deleted. + * \return int 1 if OK, 0 if KO + */ + function remove() + { + $sql = array(); + + return $this->_remove($sql); + } + +} +?> diff --git a/htdocs/install/mysql/migration/2.7.0-2.8.0.sql b/htdocs/install/mysql/migration/2.7.0-2.8.0.sql index 95aa1c32b4a..198b92a1afc 100755 --- a/htdocs/install/mysql/migration/2.7.0-2.8.0.sql +++ b/htdocs/install/mysql/migration/2.7.0-2.8.0.sql @@ -169,28 +169,6 @@ ALTER TABLE llx_projet ADD COLUMN note_public text AFTER note_private; ALTER TABLE llx_projet MODIFY fk_statut smallint DEFAULT 0 NOT NULL; ALTER TABLE llx_projet MODIFY fk_user_creat integer NOT NULL; --- Add project milestone -create table llx_projet_milestone -( - rowid integer AUTO_INCREMENT PRIMARY KEY, - fk_projet integer NOT NULL, - label varchar(255) NOT NULL, - description text, - datec datetime, - tms timestamp, - dateo datetime, - datee datetime, - priority integer DEFAULT 0, - fk_user_creat integer, - rang integer DEFAULT 0 -)type=innodb; - -ALTER TABLE llx_projet_milestone ADD INDEX idx_projet_milestone_fk_projet (fk_projet); -ALTER TABLE llx_projet_milestone ADD INDEX idx_projet_milestone_fk_user_creat (fk_user_creat); - -ALTER TABLE llx_projet_milestone ADD CONSTRAINT fk_projet_milestone_fk_projet FOREIGN KEY (fk_projet) REFERENCES llx_projet (rowid); -ALTER TABLE llx_projet_milestone ADD CONSTRAINT fk_projet_milestone_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user (rowid); - -- Uniformize code: change tva_taux to tva_tx ALTER TABLE llx_facturedet CHANGE tva_taux tva_tx real; ALTER TABLE llx_facture_fourn_det CHANGE tva_taux tva_tx double(6,3); diff --git a/htdocs/install/mysql/migration/2.8.0-2.9.0.sql b/htdocs/install/mysql/migration/2.8.0-2.9.0.sql index e9ebc00228c..a5f9a0c556e 100755 --- a/htdocs/install/mysql/migration/2.8.0-2.9.0.sql +++ b/htdocs/install/mysql/migration/2.8.0-2.9.0.sql @@ -163,3 +163,34 @@ INSERT INTO `llx_c_field_list` (`rowid`, `element`, `entity`, `name`, `alias`, ` UPDATE llx_adherent SET pays = null where pays <= 0 and pays != '0'; ALTER table llx_adherent MODIFY pays integer; + +-- add milestone module +DROP TABLE llx_projet_milestone; +create table llx_milestone +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + label varchar(255) NOT NULL, + description text, + datec datetime, + tms timestamp, + dateo datetime, + datee datetime, + priority integer DEFAULT 0, + fk_user_creat integer, + rang integer DEFAULT 0 +)type=innodb; + +ALTER TABLE llx_milestone ADD INDEX idx_milestone_fk_user_creat (fk_user_creat); +ALTER TABLE llx_milestone ADD CONSTRAINT fk_milestone_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user (rowid); + +create table llx_element_milestone +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_element integer NOT NULL, + elementtype varchar(16) NOT NULL, + fk_milestone integer NOT NULL +) type=innodb; + +ALTER TABLE llx_element_milestone ADD UNIQUE INDEX idx_element_milestone_idx1 (fk_element, elementtype, fk_milestone); +ALTER TABLE llx_element_milestone ADD INDEX idx_element_milestone_fk_milestone (fk_milestone); +ALTER TABLE llx_element_milestone ADD CONSTRAINT fk_element_milestone_fk_milestone FOREIGN KEY (fk_milestone) REFERENCES llx_milestone(rowid); \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_element_milestone.key.sql b/htdocs/install/mysql/tables/llx_element_milestone.key.sql new file mode 100644 index 00000000000..712a2cfc155 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_element_milestone.key.sql @@ -0,0 +1,29 @@ +-- ============================================================================ +-- Copyright (C) 2010 Regis Houssin +-- +-- 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 2 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, write to the Free Software +-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +-- +-- $Id$ +-- ============================================================================ + + +ALTER TABLE llx_element_milestone ADD UNIQUE INDEX idx_element_milestone_idx1 (fk_element, elementtype, fk_milestone); + +ALTER TABLE llx_element_milestone ADD INDEX idx_element_milestone_fk_milestone (fk_milestone); + +ALTER TABLE llx_element_milestone ADD CONSTRAINT fk_element_milestone_fk_milestone FOREIGN KEY (fk_milestone) REFERENCES llx_milestone(rowid); + +-- Pas de contrainte sur fk_element car pointe sur differentes tables + \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_element_milestone.sql b/htdocs/install/mysql/tables/llx_element_milestone.sql new file mode 100644 index 00000000000..94551360b89 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_element_milestone.sql @@ -0,0 +1,28 @@ +-- ============================================================================ +-- Copyright (C) 2010 Regis Houssin +-- +-- 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 2 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, write to the Free Software +-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +-- +-- $Id$ +-- ============================================================================ + +create table llx_element_milestone +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_element integer NOT NULL, + elementtype varchar(16) NOT NULL, + fk_milestone integer NOT NULL +) type=innodb; + diff --git a/htdocs/install/mysql/tables/llx_projet_milestone.key.sql b/htdocs/install/mysql/tables/llx_milestone.key.sql similarity index 67% rename from htdocs/install/mysql/tables/llx_projet_milestone.key.sql rename to htdocs/install/mysql/tables/llx_milestone.key.sql index 61ccc154a81..e7cfe547263 100644 --- a/htdocs/install/mysql/tables/llx_projet_milestone.key.sql +++ b/htdocs/install/mysql/tables/llx_milestone.key.sql @@ -20,8 +20,6 @@ -- ============================================================================ -ALTER TABLE llx_projet_milestone ADD INDEX idx_projet_milestone_fk_projet (fk_projet); -ALTER TABLE llx_projet_milestone ADD INDEX idx_projet_milestone_fk_user_creat (fk_user_creat); +ALTER TABLE llx_milestone ADD INDEX idx_milestone_fk_user_creat (fk_user_creat); -ALTER TABLE llx_projet_milestone ADD CONSTRAINT fk_projet_milestone_fk_projet FOREIGN KEY (fk_projet) REFERENCES llx_projet (rowid); -ALTER TABLE llx_projet_milestone ADD CONSTRAINT fk_projet_milestone_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user (rowid); +ALTER TABLE llx_milestone ADD CONSTRAINT fk_milestone_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user (rowid); diff --git a/htdocs/install/mysql/tables/llx_projet_milestone.sql b/htdocs/install/mysql/tables/llx_milestone.sql similarity index 91% rename from htdocs/install/mysql/tables/llx_projet_milestone.sql rename to htdocs/install/mysql/tables/llx_milestone.sql index 6c0652e04c9..209c24b2e13 100644 --- a/htdocs/install/mysql/tables/llx_projet_milestone.sql +++ b/htdocs/install/mysql/tables/llx_milestone.sql @@ -18,10 +18,9 @@ -- $Id$ -- =========================================================================== -create table llx_projet_milestone +create table llx_milestone ( rowid integer AUTO_INCREMENT PRIMARY KEY, - fk_projet integer NOT NULL, label varchar(255) NOT NULL, description text, datec datetime, -- date creation @@ -29,6 +28,6 @@ create table llx_projet_milestone dateo datetime, -- date start milestone datee datetime, -- date end milestone priority integer DEFAULT 0, -- priority - fk_user_creat integer, -- user who created the task + fk_user_creat integer, -- user who created the milestone rang integer DEFAULT 0 )type=innodb;