diff --git a/ChangeLog b/ChangeLog index afad633907f..4b319358986 100644 --- a/ChangeLog +++ b/ChangeLog @@ -42,6 +42,7 @@ For users: - New: Option MAIN_INVERT_SENDER_RECIPIENT is available in einstein pdf template. - New: Easier way to define url for clicktodial module. - New: Add a fckeditor test area in fckeditor module setup. +- New: Add property "Event on full day" on agenda - Perf: Avoid reading database to determine country code after each page call. - Fix: Better Postgresql compatibility. diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 72815db21db..0cd604675ba 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -59,6 +59,7 @@ class ActionComm extends CommonObject //var $dateend; // Date action realise fin (datea2) // deprecated //var $durationa = -1; // deprecated var $priority; + var $fulldayevent = 0; // 1=Event on full day var $punctual = 1; var $usertodo; // Object user that must do action @@ -100,10 +101,10 @@ class ActionComm extends CommonObject } /** - * \brief Add an action into database - * \param user auteur de la creation de l'action - * \param notrigger 1 ne declenche pas les triggers, 0 sinon - * \return int id de l'action creee, < 0 if KO + * Add an action into database + * @param user auteur de la creation de l'action + * @param notrigger 1 ne declenche pas les triggers, 0 sinon + * @return int id de l'action creee, < 0 if KO */ function add($user,$notrigger=0) { @@ -115,9 +116,10 @@ class ActionComm extends CommonObject $this->label=dol_trunc(trim($this->label),128); $this->location=dol_trunc(trim($this->location),128); $this->note=dol_htmlcleanlastbr(trim($this->note)); - if (! $this->percentage) $this->percentage = 0; - if (! $this->priority) $this->priority = 0; - if (! $this->punctual) $this->punctual = 0; + if (empty($this->percentage)) $this->percentage = 0; + if (empty($this->priority)) $this->priority = 0; + if (empty($this->fulldayevent)) $this->fuldayevent = 0; + if (empty($this->punctual)) $this->punctual = 0; if ($this->percentage > 100) $this->percentage = 100; if ($this->percentage == 100 && ! $this->dateend) $this->dateend = $this->date; if ($this->datep && $this->datef) $this->durationp=($this->datef - $this->datep); @@ -168,7 +170,7 @@ class ActionComm extends CommonObject $sql.= "fk_user_author,"; $sql.= "fk_user_action,"; $sql.= "fk_user_done,"; - $sql.= "label,percent,priority,location,punctual,"; + $sql.= "label,percent,priority,fulldayevent,location,punctual,"; $sql.= "fk_facture,"; $sql.= "propalrowid,"; $sql.= "fk_commande,"; @@ -190,7 +192,7 @@ class ActionComm extends CommonObject $sql.= ($user->id > 0 ? "'".$user->id."'":"null").","; $sql.= ($this->usertodo->id > 0?"'".$this->usertodo->id."'":"null").","; $sql.= ($this->userdone->id > 0?"'".$this->userdone->id."'":"null").","; - $sql.= "'".addslashes($this->label)."','".$this->percentage."','".$this->priority."','".addslashes($this->location)."','".$this->punctual."',"; + $sql.= "'".addslashes($this->label)."','".$this->percentage."','".$this->priority."','".$this->fulldayevent."','".addslashes($this->location)."','".$this->punctual."',"; $sql.= ($this->facid?$this->facid:"null").","; $sql.= ($this->propalrowid?$this->propalrowid:"null").","; $sql.= ($this->orderrowid?$this->orderrowid:"null").","; @@ -227,8 +229,8 @@ class ActionComm extends CommonObject } /** - * \brief Charge l'objet action depuis la base - * \param id id de l'action a recuperer + * Charge l'objet action depuis la base + * @param id id de l'action a recuperer */ function fetch($id) { @@ -246,7 +248,7 @@ class ActionComm extends CommonObject $sql.= " a.fk_user_author, a.fk_user_mod,"; $sql.= " a.fk_user_action, a.fk_user_done,"; $sql.= " a.fk_contact, a.percent as percentage, a.fk_facture, a.fk_commande, a.propalrowid,"; - $sql.= " a.priority, a.location,"; + $sql.= " a.priority, a.fulldayevent, a.location,"; $sql.= " c.id as type_id, c.code as type_code, c.libelle,"; $sql.= " s.nom as socname,"; $sql.= " u.firstname, u.name"; @@ -288,6 +290,7 @@ class ActionComm extends CommonObject $this->usertodo->id = $obj->fk_user_action; $this->userdone->id = $obj->fk_user_done; $this->priority = $obj->priority; + $this->fulldayevent = $obj->fulldayevent; $this->location = $obj->location; $this->socid = $obj->fk_soc; // To have fetch_thirdparty method working @@ -328,8 +331,8 @@ class ActionComm extends CommonObject } /** - * \brief Supprime l'action de la base - * \return int <0 si ko, >0 si ok + * Supprime l'action de la base + * @return int <0 si ko, >0 si ok */ function delete() { @@ -349,17 +352,18 @@ class ActionComm extends CommonObject } /** - * \brief Met a jour l'action en base. - * Si percentage = 100, on met a jour date 100% - * \return int <0 si ko, >0 si ok + * Met a jour l'action en base. + * Si percentage = 100, on met a jour date 100% + * @return int <0 si ko, >0 si ok */ function update($user) { // Clean parameters $this->label=trim($this->label); $this->note=trim($this->note); - if (! $this->percentage) $this->percentage = 0; - if (! $this->priority) $this->priority = 0; + if (empty($this->percentage)) $this->percentage = 0; + if (empty($this->priority)) $this->priority = 0; + if (empty($this->fulldayevent)) $this->fulldayevent = 0; if ($this->percentage > 100) $this->percentage = 100; if ($this->percentage == 100 && ! $this->dateend) $this->dateend = $this->date; if ($this->datep && $this->datef) $this->durationp=($this->datef - $this->datep); @@ -388,6 +392,7 @@ class ActionComm extends CommonObject $sql.= ", fk_project =". ($this->fk_project > 0 ? "'".$this->fk_project."'":"null"); $sql.= ", fk_contact =". ($this->contact->id > 0 ? "'".$this->contact->id."'":"null"); $sql.= ", priority = '".$this->priority."'"; + $sql.= ", fulldayevent = '".$this->fulldayevent."'"; $sql.= ", location = ".($this->location ? "'".addslashes($this->location)."'":"null"); $sql.= ", fk_user_mod = '".$user->id."'"; $sql.= ", fk_user_action=".($this->usertodo->id > 0 ? "'".$this->usertodo->id."'":"null"); diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index 9d958d5d7dd..2f511310064 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -75,22 +75,26 @@ if ($_POST["action"] == 'add_action') if (! empty($_POST["backtopage"])) $backtopage=$_POST["backtopage"]; if (! $backtopage) { - if ($socid) $backtopage = DOL_URL_ROOT.'/comm/fiche.php?socid='.$socid; + if ($socid > 0) $backtopage = DOL_URL_ROOT.'/comm/fiche.php?socid='.$socid; else $backtopage=DOL_URL_ROOT.'/comm/action/index.php'; } header("Location: ".$backtopage); exit; } - // Clean parameters - $datep=dol_mktime($_POST["aphour"], - $_POST["apmin"], + $fulldayevent=$_POST["fullday"]; + + // Clean parameters + $datep=dol_mktime( + $fulldayevent?'00':$_POST["aphour"], + $fulldayevent?'00':$_POST["apmin"], 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]); - $datep2=dol_mktime($_POST["p2hour"], - $_POST["p2min"], + $datep2=dol_mktime( + $fulldayevent?'23':$_POST["p2hour"], + $fulldayevent?'59':$_POST["p2min"], 0, $_POST["p2month"], $_POST["p2day"], @@ -120,6 +124,7 @@ if ($_POST["action"] == 'add_action') $actioncomm->type_id = $cactioncomm->id; $actioncomm->type_code = $cactioncomm->code; $actioncomm->priority = isset($_POST["priority"])?$_POST["priority"]:0; + $actioncomm->fulldayevent = $_POST["fullday"]?1:0; $actioncomm->location = isset($_POST["location"])?$_POST["location"]:''; $actioncomm->label = trim($_POST["label"]); if (! $_POST["label"]) @@ -286,7 +291,9 @@ if (GETPOST("action") == 'update') { if (! $_POST["cancel"]) { - // Clean parameters + $fulldayevent=$_POST["fullday"]; + + // Clean parameters if ($_POST["aphour"] == -1) $_POST["aphour"]='0'; if ($_POST["apmin"] == -1) $_POST["apmin"]='0'; if ($_POST["p2hour"] == -1) $_POST["p2hour"]='0'; @@ -297,15 +304,17 @@ if (GETPOST("action") == 'update') $actioncomm = new Actioncomm($db); $actioncomm->fetch($id); - $datep=dol_mktime($_POST["aphour"], - $_POST["apmin"], + $datep=dol_mktime( + $fulldayevent?'00':$_POST["aphour"], + $fulldayevent?'00':$_POST["apmin"], 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]); - $datep2=dol_mktime($_POST["p2hour"], - $_POST["p2min"], + $datep2=dol_mktime( + $fulldayevent?'23':$_POST["p2hour"], + $fulldayevent?'59':$_POST["p2min"], 0, $_POST["p2month"], $_POST["p2day"], @@ -334,6 +343,7 @@ if (GETPOST("action") == 'update') //$actioncomm->dateend = $datea2; $actioncomm->percentage = $_POST["percentage"]; $actioncomm->priority = $_POST["priority"]; + $actioncomm->fulldayevent= $_POST["fullday"]?1:0; $actioncomm->location = isset($_POST["location"])?$_POST["location"]:''; $actioncomm->societe->id = $_POST["socid"]; $actioncomm->contact->id = $_POST["contactid"]; @@ -418,19 +428,40 @@ if (GETPOST('action') == 'create') if ($conf->use_javascript_ajax) { - /* print "\n".''."\n"; - */ } - print '
'; + print ''; print ''; print ''; if (GETPOST("backtopage")) print ''; @@ -463,17 +494,20 @@ if (GETPOST('action') == 'create') // Location print ''.$langs->trans("Location").''; + // Full day + print ''.$langs->trans("EventOnFullDay").''; + // Date start print ''.$langs->trans("DateActionStart").''; - if (GETPOST("afaire") == 1) $html->select_date($actioncomm->datep,'ap',1,1,0,"action",1,1); - else if (GETPOST("afaire") == 2) $html->select_date($actioncomm->datep,'ap',1,1,1,"action",1,1); - else $html->select_date($actioncomm->datep,'ap',1,1,1,"action",1,1); + if (GETPOST("afaire") == 1) $html->select_date($actioncomm->datep,'ap',1,1,0,"action",1,1,0,0,'fulldayend'); + else if (GETPOST("afaire") == 2) $html->select_date($actioncomm->datep,'ap',1,1,1,"action",1,1,0,0,'fulldayend'); + else $html->select_date($actioncomm->datep,'ap',1,1,1,"action",1,1,0,0,'fulldaystart'); print ''; // Date end print ''.$langs->trans("DateActionEnd").''; - if (GETPOST("afaire") == 1) $html->select_date($actioncomm->datef,'p2',1,1,1,"action",1,1); - else if (GETPOST("afaire") == 2) $html->select_date($actioncomm->datef,'p2',1,1,1,"action",1,1); - else $html->select_date($actioncomm->datef,'p2',1,1,1,"action",1,1); + if (GETPOST("afaire") == 1) $html->select_date($actioncomm->datef,'p2',1,1,1,"action",1,1,0,0,'fulldayend'); + else if (GETPOST("afaire") == 2) $html->select_date($actioncomm->datef,'p2',1,1,1,"action",1,1,0,0,'fulldayend'); + else $html->select_date($actioncomm->datef,'p2',1,1,1,"action",1,1,0,0,'fulldayend'); print ''; // Avancement @@ -578,9 +612,7 @@ if (GETPOST('action') == 'create') print "
"; } -/* - * Affichage action en mode edition ou visu - */ +// View or edit if ($id) { if ($error) @@ -638,8 +670,43 @@ if ($id) if (GETPOST("action") == 'edit') { - // Fiche action en mode edition - print '
'; + if ($conf->use_javascript_ajax) + { + print "\n".''."\n"; + } + + // Fiche action en mode edition + print ''; print ''; print ''; print ''; @@ -659,17 +726,20 @@ if ($id) // Location print ''.$langs->trans("Location").''; + // Full day event + print ''.$langs->trans("EventOnFullDay").'fulldayevent?' checked="true"':'').'>'; + // Date start print ''.$langs->trans("DateActionStart").''; - if (GETPOST("afaire") == 1) $html->select_date($act->datep,'ap',1,1,0,"action",1,1); - else if (GETPOST("afaire") == 2) $html->select_date($act->datep,'ap',1,1,1,"action",1,1); - else $html->select_date($act->datep,'ap',1,1,1,"action",1,1); + if (GETPOST("afaire") == 1) $html->select_date($act->datep,'ap',1,1,0,"action",1,1,0,0,'fulldaystart'); + else if (GETPOST("afaire") == 2) $html->select_date($act->datep,'ap',1,1,1,"action",1,1,0,0,'fulldaystart'); + else $html->select_date($act->datep,'ap',1,1,1,"action",1,1,0,0,'fulldaystart'); print ''; // Date end print ''.$langs->trans("DateActionEnd").''; - if (GETPOST("afaire") == 1) $html->select_date($act->datef,'p2',1,1,1,"action",1,1); - else if (GETPOST("afaire") == 2) $html->select_date($act->datef,'p2',1,1,1,"action",1,1); - else $html->select_date($act->datef,'p2',1,1,1,"action",1,1); + if (GETPOST("afaire") == 1) $html->select_date($act->datef,'p2',1,1,1,"action",1,1,0,0,'fulldayend'); + else if (GETPOST("afaire") == 2) $html->select_date($act->datef,'p2',1,1,1,"action",1,1,0,0,'fulldayend'); + else $html->select_date($act->datef,'p2',1,1,1,"action",1,1,0,0,'fulldayend'); print ''; // Status @@ -772,6 +842,9 @@ if ($id) // Location print ''.$langs->trans("Location").''.$act->location.''; + // Full day event + print ''.$langs->trans("EventOnFullDay").''.yn($act->fulldayevent).''; + // Date debut print ''.$langs->trans("DateActionStart").''; print dol_print_date($act->datep,'dayhour'); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 0be811de8d8..fe03f2a40d8 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -485,7 +485,7 @@ class Form print ''; if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); } - + /** * Output html form to select a third party * @param selected Preselected type @@ -512,7 +512,7 @@ class Form function select_company($selected='',$htmlname='socid',$filter='',$showempty=0, $showtype=0, $forcecombo=0) { global $conf,$user,$langs; - + $out=''; // On recherche les societes @@ -594,7 +594,7 @@ class Form { dol_print_error($this->db); } - + return $out; } @@ -2521,25 +2521,25 @@ class Form /** - * Affiche zone de selection de date - * Liste deroulante pour les jours, mois, annee et eventuellement heurs et minutes - * Les champs sont pre-selectionnes avec: - * - La date set_time (Local PHP server timestamps ou date au format YYYY-MM-DD ou YYYY-MM-DD HH:MM) - * - La date local du server PHP si set_time vaut '' - * - Aucune date (champs vides) si set_time vaut -1 (dans ce cas empty doit valoir 1) + * Show a HTML widget to input a date or combo list for daye, month, years and optionnaly hours and minutes + * Fields are preselected with : + * - set_time date (Local PHP server timestamps ou date au format YYYY-MM-DD ou YYYY-MM-DD HH:MM) + * - local date of PHP server if set_time is '' + * - Empty (fields empty) if set_time is -1 (in this case, parameter empty must also have value 1) * @param set_time Pre-selected date (must be a local PHP server timestamp) - * @param prefix Prefix pour nom champ - * @param h 1=Affiche aussi les heures - * @param m 1=Affiche aussi les minutes - * @param empty 0=Champ obligatoire, 1=Permet une saisie vide - * @param form_name Nom du formulaire de provenance. Utilise pour les dates en popup. - * @param d 1=Affiche aussi les jours, mois, annees + * @param prefix Prefix for fields name + * @param h 1=Show also hours + * @param m 1=Show also minutes + * @param empty 0=Fields required, 1=Empty input is allowed + * @param form_name Form name. Used by popup dates. + * @param d 1=Show days, month, years * @param addnowbutton Add a button "Now" * @param nooutput Do not output html string but return it * @param disabled Disable input fields + * @param fullday When a checkbox with this html name is on, hour and day are set with 00:00 or 23:59 * @return nothing or string if nooutput is 1 */ - function select_date($set_time='', $prefix='re', $h=0, $m=0, $empty=0, $form_name="", $d=1, $addnowbutton=0, $nooutput=0, $disabled=0) + function select_date($set_time='', $prefix='re', $h=0, $m=0, $empty=0, $form_name="", $d=1, $addnowbutton=0, $nooutput=0, $disabled=0, $fullday='') { global $conf,$langs; @@ -2651,7 +2651,7 @@ class Form } /* - * Affiche date en select + * Show date with combo selects */ if (! $conf->use_javascript_ajax || ! $conf->use_popup_calendar) { @@ -2726,7 +2726,7 @@ class Form /* * Affiche heure en select */ - $retstring.=''; + $retstring.=''; if ($empty) $retstring.=''; for ($hour = 0; $hour < 24; $hour++) { @@ -2752,7 +2752,7 @@ class Form /* * Affiche min en select */ - $retstring.=''; + $retstring.=''; if ($empty) $retstring.=''; for ($min = 0; $min < 60 ; $min++) { @@ -2773,8 +2773,7 @@ class Form $retstring.="M\n"; } - // Added by Matelli http://matelli.fr/showcases/patchs-dolibarr/update-date-input-in-action-form.html) - // "Now" button + // Add a "Now" button if ($conf->use_javascript_ajax && $addnowbutton) { // Script which will be inserted in the OnClick of the "Now" button @@ -2795,17 +2794,21 @@ class Form // Generate the hour part if ($h) { + if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; $reset_scripts .= 'this.form.elements[\''.$prefix.'hour\'].value=formatDate(new Date(), \'HH\'); '; + if ($fullday) $reset_scripts .= ' } '; } // Generate the minute part if ($m) { + if ($fullday) $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; $reset_scripts .= 'this.form.elements[\''.$prefix.'min\'].value=formatDate(new Date(), \'mm\'); '; + if ($fullday) $reset_scripts .= ' } '; } // If reset_scripts is not empty, print the button with the reset_scripts in OnClick if ($reset_scripts) { - $retstring.=' '; @@ -3224,7 +3227,7 @@ class Form return $ret; } - + /** * Return select list of groups * @param selected Id group preselected @@ -3277,9 +3280,9 @@ class Form $out.= ' selected="selected"'; } $out.= '>'; - + $out.= $obj->nom; - + $out.= ''; $i++; } @@ -3293,7 +3296,7 @@ class Form return $out; } - + } ?> diff --git a/htdocs/install/mysql/migration/2.9.0-3.0.0.sql b/htdocs/install/mysql/migration/2.9.0-3.0.0.sql index c87eacebe07..7a901b4447a 100644 --- a/htdocs/install/mysql/migration/2.9.0-3.0.0.sql +++ b/htdocs/install/mysql/migration/2.9.0-3.0.0.sql @@ -104,3 +104,5 @@ UPDATE llx_societe SET canvas = 'default' WHERE canvas = 'default@thirdparty'; UPDATE llx_societe SET canvas = 'individual' WHERE canvas = 'individual@thirdparty'; insert into llx_const (name, value, type, note, visible) values ('MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS','7','chaine','Tolérance de retard avant alerte (en jours) sur commandes fournisseurs non traitées',0); + +ALTER TABLE llx_actioncomm ADD COLUMN fulldayevent smallint NOT NULL default 0 after priority; diff --git a/htdocs/install/mysql/tables/llx_actioncomm.sql b/htdocs/install/mysql/tables/llx_actioncomm.sql index 9b3257b80f4..8078f017484 100644 --- a/htdocs/install/mysql/tables/llx_actioncomm.sql +++ b/htdocs/install/mysql/tables/llx_actioncomm.sql @@ -45,6 +45,7 @@ create table llx_actioncomm fk_user_action integer, -- id de la personne qui doit effectuer l'action fk_user_done integer, -- id de la personne qui a effectue l'action priority smallint, + fulldayevent smallint NOT NULL default 0, punctual smallint NOT NULL default 1, percent smallint NOT NULL default 0, location varchar(128), diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index e8b0f587cfb..9e1de95f473 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -11,6 +11,7 @@ DoneBy= Done by Events= Events ListOfActions=List of events Location=Location +EventOnFullDay=Event on full day SearchAnAction= Search an action/task MenuToDoActions= All incomplete actions MenuDoneActions= All terminated actions diff --git a/htdocs/langs/fr_FR/agenda.lang b/htdocs/langs/fr_FR/agenda.lang index 7a057da91f6..59919c56b0b 100644 --- a/htdocs/langs/fr_FR/agenda.lang +++ b/htdocs/langs/fr_FR/agenda.lang @@ -10,6 +10,7 @@ AffectedTo=Affecté à DoneBy=Réalisé par Events=Evénements ListOfActions=Liste des événements +EventOnFullDay=Evênement sur la journée Location=Lieu SearchAnAction=Rechercher une action/tâche MenuToDoActions=Les actions incomplètes