From 8f73c7a82a41d4ac8afa7a448336d7929833ec4b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Aug 2014 01:49:22 +0200 Subject: [PATCH 1/3] Fix: Remove debug --- htdocs/holiday/class/holiday.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 05fef5dd47a..f8a837e879f 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1618,7 +1618,7 @@ class Holiday extends CommonObject $sql.= ")"; $this->db->begin(); -print $sql;exit; + dol_syslog(get_class($this)."::addLogCP sql=".$sql, LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) { From 85748711b55cb4e1ba1ad54a2382737bd80d2ffb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Aug 2014 09:08:28 +0200 Subject: [PATCH 2/3] Fix: Table holiday_user was not initialized anymore. Conflicts: htdocs/holiday/class/holiday.class.php htdocs/holiday/fiche.php --- htdocs/holiday/class/holiday.class.php | 61 ++++++++++++++++---------- htdocs/holiday/define_holiday.php | 7 ++- htdocs/holiday/fiche.php | 32 +++++++------- 3 files changed, 58 insertions(+), 42 deletions(-) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index f8a837e879f..0d661018481 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -77,7 +77,7 @@ class Holiday extends CommonObject /** - * updateSold + * updateSold. Update sold and check table of users for holidays is complete. If not complete. * * @return int Return 1 */ @@ -983,25 +983,31 @@ class Holiday extends CommonObject */ function createCPusers($single=false,$userid='') { - // Si c'est l'ensemble des utilisateurs à ajoutés - if(!$single) + // Si c'est l'ensemble des utilisateurs à ajouter + if (! $single) { dol_syslog(get_class($this).'::createCPusers'); - foreach($this->fetchUsers(false,true) as $users) { + $arrayofusers = $this->fetchUsers(false,true); + + foreach($arrayofusers as $users) + { $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_users"; $sql.= " (fk_user, nb_holiday)"; $sql.= " VALUES ('".$users['rowid']."','0')"; - $this->db->query($sql); + $resql=$this->db->query($sql); + if (! $resql) dol_print_error($this->db); } - } else { + } + else + { $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_users"; $sql.= " (fk_user, nb_holiday)"; $sql.= " VALUES ('".$userid."','0')"; - $this->db->query($sql); + $resql=$this->db->query($sql); + if (! $resql) dol_print_error($this->db); } - } /** @@ -1048,7 +1054,7 @@ class Holiday extends CommonObject * uniquement pour vérifier si il existe de nouveau utilisateur * * @param boolean $liste si vrai retourne une liste, si faux retourne un array - * @param boolean $type si vrai retourne pour Dolibarr si faux retourne pour CP + * @param boolean $type si vrai retourne pour Dolibarr, si faux retourne pour CP * @return string retourne un tableau de tout les utilisateurs actifs */ function fetchUsers($liste=true,$type=true) @@ -1263,50 +1269,56 @@ class Holiday extends CommonObject function verifNbUsers($userDolibarrWithoutCP,$userCP) { if (empty($userCP)) $userCP=0; - dol_syslog(get_class($this).'::verifNbUsers userDolibarr='.$userDolibarr.' userCP='.$userCP); + dol_syslog(get_class($this).'::verifNbUsers userDolibarr='.$userDolibarrWithoutCP.' userCP='.$userCP); // On vérifie les users Dolibarr sans CP if ($userDolibarrWithoutCP > 0) { - $this->updateConfCP('nbUser',$userDolibarr); + $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"; - $sql.= " WHERE u.rowid NOT IN(".$listUsersCP.")"; - - $result = $this->db->query($sql); - - // Si pas d'erreur SQL - if($result) { + 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) { - + while($i < $num) + { $obj = $this->db->fetch_object($resql); + $uid = $obj->rowid; // On ajoute l'utilisateur - $this->createCPusers(true,$obj->rowid); + //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 { - // Si il y a moins d'utilisateur Dolibarr que dans le module CP + $this->db->begin(); - $this->updateConfCP('nbUser',$userDolibarr); + // Si il y a moins d'utilisateur Dolibarr que dans le module CP + + $this->updateConfCP('nbUser',$userDolibarrWithoutCP); $listUsersDolibarr = $this->fetchUsers(true,true); @@ -1333,11 +1345,12 @@ class Holiday extends CommonObject $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; } } diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index 1bf8a2716cc..4e1540c99e5 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -43,14 +43,17 @@ $action=GETPOST('action'); */ $form = new Form($db); +$userstatic=new User($db); +$holiday = new Holiday($db); + llxHeader(array(),$langs->trans('CPTitreMenu')); print_fiche_titre($langs->trans('MenuConfCP')); -$holiday = new Holiday($db); +$holiday->updateSold(); // Create users into table holiday if they don't exists. TODO Remove if we use field into table user. + $listUsers = $holiday->fetchUsers(false,false); -$userstatic=new User($db); // Si il y a une action de mise à jour if ($action == 'update' && isset($_POST['update_cp'])) diff --git a/htdocs/holiday/fiche.php b/htdocs/holiday/fiche.php index 0ff0194d5cf..2f6c52eaf86 100644 --- a/htdocs/holiday/fiche.php +++ b/htdocs/holiday/fiche.php @@ -237,9 +237,9 @@ if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes') if($user->rights->holiday->delete) { $error=0; - + $db->begin(); - + $cp = new Holiday($db); $cp->fetch($id); @@ -251,12 +251,12 @@ if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes') { $result=$cp->delete($id); } - else + else { $error = $langs->trans('ErrorCantDeleteCP'); } } - + if (! $error) { $db->commit(); @@ -265,7 +265,7 @@ if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes') } else { - $db->rollback(); + $db->rollback(); } } } @@ -384,7 +384,7 @@ if($action == 'confirm_valid') $verif = $cp->update($user->id); // Si pas d'erreur SQL on redirige vers la fiche de la demande - if ($verif > 0) + if ($verif > 0) { // Calculcate number of days consummed $nbopenedday=num_open_day($cp->date_debut,$cp->date_fin,0,1); @@ -470,7 +470,7 @@ if ($action == 'confirm_refuse') $verif = $cp->update($user->id); // Si pas d'erreur SQL on redirige vers la fiche de la demande - if ($verif > 0) + if ($verif > 0) { // To $destinataire = new User($db); @@ -541,7 +541,7 @@ if ($action == 'confirm_cancel' && GETPOST('confirm') == 'yes') if (($cp->statut == 2 || $cp->statut == 3) && ($user->id == $cp->fk_validator || $user->id == $cp->fk_user)) { $db->begin(); - + $oldstatus = $cp->statut; $cp->date_cancel = dol_now(); $cp->fk_user_cancel = $user->id; @@ -568,16 +568,16 @@ if ($action == 'confirm_cancel' && GETPOST('confirm') == 'yes') $error = $langs->trans('ErrorCantDeleteCP'); } } - + if (! $error) { - $db->commit(); + $db->commit(); } else { $db->rollback(); } - + // Si pas d'erreur SQL on redirige vers la fiche de la demande if (! $error && $result > 0) { @@ -874,7 +874,7 @@ else if($user->id == $cp->fk_user || $user->rights->holiday->lire_tous) { - if ($action == 'delete') + if ($action == 'delete') { if($user->rights->holiday->delete) { @@ -943,8 +943,8 @@ else print $langs->trans($listhalfday[$starthalfday]); print ''; print ''; - } - else + } + else { print ''; print ''.$langs->trans('DateDebCP').' ('.$langs->trans("FirstDayOfHoliday").')'; @@ -965,8 +965,8 @@ else print $langs->trans($listhalfday[$endhalfday]); print ''; print ''; - } - else + } + else { print ''; print ''.$langs->trans('DateFinCP').' ('.$langs->trans("LastDayOfHoliday").')'; From 2d524f2edc0f88c30354c54e5968bff6dbe80f5e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Aug 2014 09:09:22 +0200 Subject: [PATCH 3/3] Fix: Holiday module was broken. Initializaion of amount of holidays failed. --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 58bfffebd2e..44239e48fc0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ English Dolibarr ChangeLog -------------------------------------------------------------- ***** ChangeLog for 3.5.5 compared to 3.5.4 ***** +Fix: Holiday module was broken. Initializaion of amount of holidays failed. Fix: [ bug #1523 ] suite bug #1334 : filtre et ordre de tri conjoints ne s'appliquent pas. Fix: Fusion PDF button on unpaid invoice is no more displayed Fix: Unpaid invoice launch fusion PDF action even if it is only search (with enter keyboard input instead of lens click)