From 9c89bc4095bca33fbe985ca6dae6ebbcb56ba5d4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Jul 2016 10:57:27 +0200 Subject: [PATCH] Remove deprecated tables and code --- htdocs/holiday/class/holiday.class.php | 320 ------------------ htdocs/holiday/define_holiday.php | 3 +- .../install/mysql/migration/4.0.0-5.0.0.sql | 2 + .../mysql/tables/llx_holiday_events.key.sql | 19 -- .../mysql/tables/llx_holiday_events.sql | 26 -- 5 files changed, 4 insertions(+), 366 deletions(-) delete mode 100644 htdocs/install/mysql/tables/llx_holiday_events.key.sql delete mode 100644 htdocs/install/mysql/tables/llx_holiday_events.sql diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index a31bd28da49..b76c90cbf48 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1364,330 +1364,10 @@ class Holiday extends CommonObject { if (empty($userCP)) $userCP=0; dol_syslog(get_class($this).'::verifNbUsers userDolibarr='.$userDolibarrWithoutCP.' userCP='.$userCP); -/* - // On vérifie les users Dolibarr sans CP - if ($userDolibarrWithoutCP > 0) - { - $this->db->begin(); - - //$this->updateConfCP('nbUser',$userDolibarrWithoutCP); - - $listUsersCP = $this->fetchUsers(true,false); - - // On séléctionne les utilisateurs qui ne sont pas déjà dans le module - $sql = "SELECT u.rowid, u.lastname, u.firstname"; - $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; - if ($listUsersCP != '') $sql.= " WHERE u.rowid NOT IN(".$listUsersCP.")"; - - $resql = $this->db->query($sql); - if ($resql) - { - $i = 0; - $num = $this->db->num_rows($resql); - - while($i < $num) - { - $obj = $this->db->fetch_object($resql); - $uid = $obj->rowid; - - // On ajoute l'utilisateur - //print "Add user rowid = ".$uid." into database holiday"; - - $result = $this->createCPusers(true,$uid); - - $i++; - } - - $this->db->commit(); - } else { - // Erreur SQL - $this->error="Error ".$this->db->lasterror(); - dol_syslog(get_class($this)."::verifNbUsers ".$this->error, LOG_ERR); - $this->db->rollback(); - return -1; - } - - } - else - { - $this->db->begin(); - - // Si il y a moins d'utilisateur Dolibarr que dans le module CP - - $this->updateConfCP('nbUser',$userDolibarrWithoutCP); - - $listUsersDolibarr = $this->fetchUsers(true,true); - - // On séléctionne les utilisateurs qui ne sont pas déjà dans le module - $sql = "SELECT u.fk_user"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as u"; - $sql.= " WHERE u.fk_user NOT IN (".$listUsersDolibarr.")"; - - $resql = $this->db->query($sql); - - // Si pas d'erreur SQL - if ($resql) { - - $i = 0; - $num = $this->db->num_rows($resql); - - while($i < $num) { - - $obj = $this->db->fetch_object($resql); - - // On supprime l'utilisateur - $this->deleteCPuser($obj->fk_user); - - $i++; - } - - $this->db->commit(); - } else { - // Erreur SQL - $this->error="Error ".$this->db->lasterror(); - dol_syslog(get_class($this)."::verifNbUsers ".$this->error, LOG_ERR); - $this->db->rollback(); - return -1; - } - } -*/ return 1; } - /** - * Liste les évènements de congés payés enregistré - * - * @return int -1 si erreur, 1 si OK et 2 si pas de résultat - */ - function fetchEventsCP() - { - global $langs; - - $sql = "SELECT"; - $sql.= " cpe.rowid,"; - $sql.= " cpe.name,"; - $sql.= " cpe.value"; - - $sql.= " FROM ".MAIN_DB_PREFIX."holiday_events as cpe"; - - dol_syslog(get_class($this)."::fetchEventsCP", LOG_DEBUG); - $resql=$this->db->query($sql); - - // Si pas d'erreur SQL - if ($resql) { - - $i = 0; - $tab_result = $this->events; - $num = $this->db->num_rows($resql); - - // Si pas d'enregistrement - if(!$num) { - return 2; - } - - // On liste les résultats et on les ajoutent dans le tableau - while($i < $num) { - - $obj = $this->db->fetch_object($resql); - - $tab_result[$i]['rowid'] = $obj->rowid; - $tab_result[$i]['name'] = $obj->name; - $tab_result[$i]['value'] = $obj->value; - - $i++; - } - // Retourne 1 et ajoute le tableau à la variable - $this->events = $tab_result; - return 1; - } - else - { - // Erreur SQL - $this->error="Error ".$this->db->lasterror(); - return -1; - } - } - - /** - * Créer un évènement de congés payés - * - * @param User $user User - * @param int $notrigger No trigger - * @return int -1 si erreur, id si OK - */ - function createEventCP($user, $notrigger=0) - { - global $conf, $langs; - $error=0; - - // Insert request - $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_events ("; - - $sql.= "name,"; - $sql.= "value"; - - $sql.= ") VALUES ("; - - $sql.= " '".$this->db->escape($this->optName)."',"; - $sql.= " '".$this->optValue."'"; - $sql.= ")"; - - $this->db->begin(); - - dol_syslog(get_class($this)."::createEventCP", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) { - $error++; $this->errors[]="Error ".$this->db->lasterror(); - } - - if (! $error) - { - $this->optRowid = $this->db->last_insert_id(MAIN_DB_PREFIX."holiday_events"); - - } - - // Commit or rollback - if ($error) - { - foreach($this->errors as $errmsg) - { - dol_syslog(get_class($this)."::createEventCP ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); - } - $this->db->rollback(); - return -1*$error; - } - else - { - $this->db->commit(); - return $this->optRowid; - } - } - - /** - * Met à jour les évènements de congés payés - * - * @param int $rowid Row id - * @param string $name Name - * @param value $value Value - * @return int -1 si erreur, id si OK - */ - function updateEventCP($rowid, $name, $value) { - - $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_events SET"; - $sql.= " name = '".$this->db->escape($name)."', value = '".$value."'"; - $sql.= " WHERE rowid = '".$rowid."'"; - - $result = $this->db->query($sql); - - if($result) { - return true; - } - - return false; - } - - /** - * Select event - * - * @return string|false Select Html to select type of holiday - */ - function selectEventCP() - { - - $sql = "SELECT rowid, name, value"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday_events"; - - $result = $this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); - $i = 0; - - $out = ''; - - return $out; - } - else - { - return false; - } - } - - /** - * deleteEvent - * - * @param int $rowid Row id - * @return boolean Success or not - */ - function deleteEventCP($rowid) { - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."holiday_events"; - $sql.= " WHERE rowid = '".$rowid."'"; - - $result = $this->db->query($sql); - - if($result) { - return true; - } else { - return false; - } - } - - /** - * getValueEventCp - * - * @param int $rowid Row id - * @return string|false - */ - function getValueEventCp($rowid) { - - $sql = "SELECT value"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday_events"; - $sql.= " WHERE rowid = '".$rowid."'"; - - $result = $this->db->query($sql); - - if($result) { - $obj = $this->db->fetch_array($result); - return number_format($obj['value'],2); - } else { - return false; - } - } - - /** - * getNameEventCp - * - * @param int $rowid Row id - * @return unknown|boolean - */ - function getNameEventCp($rowid) { - - $sql = "SELECT name"; - $sql.= " FROM ".MAIN_DB_PREFIX."holiday_events"; - $sql.= " WHERE rowid = '".$rowid."'"; - - $result = $this->db->query($sql); - - if($result) { - $obj = $this->db->fetch_array($result); - return $obj['name']; - } else { - return false; - } - } - /** * addLogCP * diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index 7a94e686173..35e952a6df7 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -186,6 +186,7 @@ if (is_numeric($listUsers) && $listUsers < 0) $var=true; $i = 0; +/* $cp_events = $holiday->fetchEventsCP(); if ($cp_events == 1) { @@ -202,7 +203,7 @@ if ($cp_events == 1) print '
'; } - +*/ $typeleaves=$holiday->getTypes(1,1); diff --git a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql index dcecfc3d398..81872e8d10d 100644 --- a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql +++ b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql @@ -36,6 +36,8 @@ ALTER TABLE llx_ecm_files ADD COLUMN gen_or_uploaded varchar(12) after cover; DROP TABLE llx_document_generator; DROP TABLE llx_ecm_documents; +DROP TABLE llx_holiday_events; +DROP TABLE llx_holiday_types; ALTER TABLE llx_notify ADD COLUMN type_target varchar(16) NULL; diff --git a/htdocs/install/mysql/tables/llx_holiday_events.key.sql b/htdocs/install/mysql/tables/llx_holiday_events.key.sql deleted file mode 100644 index 250e1fa9114..00000000000 --- a/htdocs/install/mysql/tables/llx_holiday_events.key.sql +++ /dev/null @@ -1,19 +0,0 @@ --- =================================================================== --- Copyright (C) 2012 Laurent Destailleur --- --- 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 . --- --- =================================================================== - -ALTER TABLE llx_holiday_events ADD UNIQUE INDEX uk_holiday_name (name, entity); diff --git a/htdocs/install/mysql/tables/llx_holiday_events.sql b/htdocs/install/mysql/tables/llx_holiday_events.sql deleted file mode 100644 index 904671af0e1..00000000000 --- a/htdocs/install/mysql/tables/llx_holiday_events.sql +++ /dev/null @@ -1,26 +0,0 @@ --- =================================================================== --- Copyright (C) 2012 Laurent Destailleur --- --- 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 . --- --- =================================================================== - -CREATE TABLE llx_holiday_events -( - rowid integer NOT NULL PRIMARY KEY AUTO_INCREMENT, - entity integer DEFAULT 1 NOT NULL, -- multi company id - name VARCHAR( 255 ) NOT NULL, - value TEXT NOT NULL -) -ENGINE=innodb; \ No newline at end of file