Merge remote-tracking branch 'origin/3.5' into 3.6

Conflicts:
	htdocs/holiday/fiche.php
This commit is contained in:
Laurent Destailleur 2014-08-06 09:12:29 +02:00
commit c781bb4d08
3 changed files with 43 additions and 26 deletions

View File

@ -111,6 +111,7 @@ removed. You must now use the 6 parameters way. See file modMyModule.class.php f
***** 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)

View File

@ -79,7 +79,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
*/
@ -991,25 +991,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);
}
}
/**
@ -1056,7 +1062,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)
@ -1271,50 +1277,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);
@ -1341,11 +1353,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;
}
}

View File

@ -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']))