diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index 782d7444429..af09519cfef 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -183,7 +183,7 @@ if ($action == 'add_action') if (! empty($conf->phenix->enabled) && GETPOST('add_phenix') == 'on') $actioncomm->use_phenix=1; // Check parameters - if ($actioncomm->type_code == 'AC_RDV' && ($datep == '' || $datef == '')) + if ($actioncomm->type_code == 'AC_RDV' && ($datep == '' || ($datef == '' && empty($fulldayevent)))) { $error++; $action = 'create'; @@ -559,7 +559,7 @@ if ($action == 'create') } else { print $form->select_company('','socid','',1,1); } - + } print ''; diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 3974a93641a..9c20caed835 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -32,14 +32,14 @@ class Holiday extends CommonObject { public $element='holiday'; public $table_element='holiday'; - + var $db; var $error; var $errors=array(); var $rowid; var $ref; - + var $fk_user; var $date_create=''; var $description; @@ -72,16 +72,24 @@ class Holiday extends CommonObject function __construct($db) { $this->db = $db; - - // Mets à jour les congés payés en début de mois - $this->updateSoldeCP(); - - // Vérifie le nombre d'utilisateur et mets à jour si besoin - $this->verifNbUsers($this->countActiveUsers(),$this->getConfCP('nbUser')); - return 1; } + /** + * updateSold + * + * @return int Return 1 + */ + function updateSold() + { + // Mets à jour les congés payés en début de mois + $this->updateSoldeCP(); + + // Vérifie le nombre d'utilisateur et mets à jour si besoin + $this->verifNbUsers($this->countActiveUsers(),$this->getConfCP('nbUser')); + return 1; + } + /** * Créer un congés payés dans la base de données * @@ -358,10 +366,10 @@ class Holiday extends CommonObject $sql.= " uu.name as user_lastname,"; $sql.= " uu.firstname as user_firstname,"; - + $sql.= " ua.name as validator_lastname,"; $sql.= " ua.firstname as validator_firstname"; - + $sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp, ".MAIN_DB_PREFIX."user as uu, ".MAIN_DB_PREFIX."user as ua"; $sql.= " WHERE cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid "; // Hack pour la recherche sur le tableau @@ -415,10 +423,10 @@ class Holiday extends CommonObject $tab_result[$i]['user_firstname'] = $obj->user_firstname; $tab_result[$i]['user_lastname'] = $obj->user_lastname; - + $tab_result[$i]['validator_firstname'] = $obj->validator_firstname; $tab_result[$i]['validator_lastname'] = $obj->validator_lastname; - + $i++; } // Retourne 1 et ajoute le tableau à la variable @@ -601,13 +609,13 @@ class Holiday extends CommonObject { $this->fetchByUser($fk_user,'',''); - foreach($this->holiday as $infos_CP) + foreach($this->holiday as $infos_CP) { if ($infos_CP['statut'] == 4) continue; // ignore not validated holidays if ($infos_CP['statut'] == 5) continue; // ignore not validated holidays - + // TODO Also use halfday for the check - if ($dateDebut >= $infos_CP['date_debut'] && $dateDebut <= $infos_CP['date_fin'] || $dateFin <= $infos_CP['date_fin'] && $dateFin >= $infos_CP['date_debut']) + if ($dateDebut >= $infos_CP['date_debut'] && $dateDebut <= $infos_CP['date_fin'] || $dateFin <= $infos_CP['date_fin'] && $dateFin >= $infos_CP['date_debut']) { return false; } @@ -627,23 +635,24 @@ class Holiday extends CommonObject function getNomUrl($withpicto=0) { global $langs; - + $result=''; - + $lien = ''; $lienfin=''; - + $picto='holiday'; - + $label=$langs->trans("Show").': '.$this->ref; - + if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin); if ($withpicto && $withpicto != 2) $result.=' '; if ($withpicto != 2) $result.=$lien.$this->ref.$lienfin; return $result; + } - + /** * Returns the label status * @@ -654,7 +663,7 @@ class Holiday extends CommonObject { return $this->LibStatut($this->statut, $mode, $this->date_debut); } - + /** * Returns the label of a statut * @@ -678,7 +687,7 @@ class Holiday extends CommonObject if ($mode == 2) { $pictoapproved='statut6'; - if (! empty($startdate) && $startdate > dol_now()) $pictoapproved='statut4'; + if (! empty($startdate) && $startdate > dol_now()) $pictoapproved='statut4'; if ($statut == 1) return img_picto($langs->trans('DraftCP'),'statut0').' '.$langs->trans('DraftCP'); // Draft if ($statut == 2) return img_picto($langs->trans('ToValidateCP'),'statut1').' '.$langs->trans('ToValidateCP'); // Waiting approval if ($statut == 3) return img_picto($langs->trans('ValidateCP'),$pictoapproved).' '.$langs->trans('ValidateCP'); @@ -688,18 +697,18 @@ class Holiday extends CommonObject if ($mode == 5) { $pictoapproved='statut6'; - if (! empty($startdate) && $startdate > dol_now()) $pictoapproved='statut4'; + if (! empty($startdate) && $startdate > dol_now()) $pictoapproved='statut4'; if ($statut == 1) return $langs->trans('DraftCP').' '.img_picto($langs->trans('DraftCP'),'statut0'); // Draft if ($statut == 2) return $langs->trans('ToValidateCP').' '.img_picto($langs->trans('ToValidateCP'),'statut1'); // Waiting approval if ($statut == 3) return $langs->trans('ValidateCP').' '.img_picto($langs->trans('ValidateCP'),$pictoapproved); if ($statut == 4) return $langs->trans('CancelCP').' '.img_picto($langs->trans('CancelCP'),'statut5'); if ($statut == 5) return $langs->trans('RefuseCP').' '.img_picto($langs->trans('RefuseCP'),'statut5'); } - + return $statut; } - + /** * Affiche un select HTML des statuts de congés payés * @@ -857,19 +866,21 @@ class Holiday extends CommonObject { // Si mise à jour pour tout le monde en début de mois $now=dol_now(); - + // Mois actuel $month = date('m',$now); $lastUpdate = $this->getConfCP('lastUpdate'); - $monthLastUpdate = date('m', $lastUpdate); + $monthLastUpdate = $lastUpdate[4].$lastUpdate[5]; + //print 'month: '.$month.' '.$lastUpdate.' '.$monthLastUpdate; // Si la date du mois n'est pas la même que celle sauvegardée, on met à jour le timestamp if ($month != $monthLastUpdate) { $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET"; - $sql.= " value = '".$this->db->idate($now)."'"; + $sql.= " value = '".dol_print_date($now,'%Y%m%d%H%M%S')."'"; $sql.= " WHERE name = 'lastUpdate'"; + dol_syslog(get_class($this).'::updateSoldeCP sql='.$sql); $result = $this->db->query($sql); // On ajoute x jours à chaque utilisateurs diff --git a/htdocs/holiday/common.inc.php b/htdocs/holiday/common.inc.php index 8953352973b..133177df614 100644 --- a/htdocs/holiday/common.inc.php +++ b/htdocs/holiday/common.inc.php @@ -50,7 +50,7 @@ $sql.= " WHERE name = 'userGroup'"; $result = $db->query($sql); $obj = $db->fetch_object($result); -if ($obj->value == null) +if ($obj->value == null || $obj->value < 0) { llxHeader('',$langs->trans('CPTitreMenu')); diff --git a/htdocs/holiday/index.php b/htdocs/holiday/index.php index c9f77a3f63e..19944b16ae8 100644 --- a/htdocs/holiday/index.php +++ b/htdocs/holiday/index.php @@ -73,6 +73,9 @@ $search_statut = GETPOST('select_statut'); $holiday = new Holiday($db); $holidaystatic=new Holiday($db); +// Update sold +$holiday->updateSold(); + $max_year = 5; $min_year = 10; $filter=''; diff --git a/htdocs/langs/es_ES/dict.lang b/htdocs/langs/es_ES/dict.lang index bf0b59e3ef1..c0cd7042334 100644 --- a/htdocs/langs/es_ES/dict.lang +++ b/htdocs/langs/es_ES/dict.lang @@ -85,7 +85,7 @@ CountryDM=Dominica CountryDO=República Dominicana CountryEC=Ecuador CountryEG=Egipto -CountrySV=Salvador +CountrySV=El Salvador CountryGQ=Guinea Ecuatorial CountryER=Eritrea CountryEE=Estonia diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index 92ebb740523..cf0e0170c94 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -324,9 +324,7 @@ if ($action == 'update' && ! $_POST["cancel"]) $object->firstname = GETPOST("prenom"); $object->login = GETPOST("login"); $object->pass = GETPOST("password"); - if($user->admin == 1) { // A user can only be set admin by an admin - $object->admin = GETPOST("admin"); - } + $object->admin = empty($user->admin)?0:GETPOST("admin"); // A user can only be set admin by an admin $object->office_phone=GETPOST("office_phone"); $object->office_fax = GETPOST("office_fax"); $object->user_mobile= GETPOST("user_mobile");