From d6301233da9abb5260595fcd49090dcc51165d71 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@users.sourceforge.net> Date: Sun, 10 Sep 2006 13:46:25 +0000 Subject: [PATCH] Qual: Suppression fonction print_heure_select qui faisait double emploi avec select_date --- htdocs/comm/action/fiche.php | 67 ++++++++++++--------------- htdocs/html.form.class.php | 88 ++++++++++++++++++++++++------------ htdocs/lib/functions.inc.php | 47 ------------------- 3 files changed, 86 insertions(+), 116 deletions(-) diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index 418d632abfb..ff5c8b039d1 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -93,14 +93,14 @@ if ($_POST["action"] == 'add_action') } } } - $actioncomm->date_p = @mktime($_POST["heurephour"], - $_POST["heurepmin"], + $actioncomm->date_p = @mktime($_POST["aphour"], + $_POST["apmin"], 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]); - $actioncomm->date_a = @mktime($_POST["heuredhour"], - $_POST["heuredmin"], + $actioncomm->date_a = @mktime($_POST["adhour"], + $_POST["admin"], 0, $_POST["admonth"], $_POST["adday"], @@ -183,20 +183,29 @@ if ($_POST["action"] == 'update') { if (! $_POST["cancel"]) { + if ($_POST["aphour"] == -1) $_POST["aphour"]='0'; + if ($_POST["apmin"] == -1) $_POST["apmin"]='0'; + if ($_POST["adhour"] == -1) $_POST["adhour"]='0'; + if ($_POST["admin"] == -1) $_POST["admin"]='0'; + $action = new Actioncomm($db); $action->fetch($_POST["id"]); - $action->date_p = @mktime($_POST["heurephour"], - $_POST["heurepmin"], + + + $action->date_p = @mktime($_POST["aphour"], + $_POST["apmin"], 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]); - $action->date_a = @mktime($_POST["heuredhour"], - $_POST["heuredmin"], + $action->date_a = @mktime($_POST["adhour"], + $_POST["admin"], 0, $_POST["admonth"], $_POST["adday"], $_POST["adyear"]); + //print $_POST["apmonth"].",".$_POST["apday"].",".$_POST["apyear"].",".$_POST["aphour"].",".$_POST["apmin"]."<br>\n"; + //print $action->datep; $action->label = $_POST["label"]; $action->percent = $_POST["percent"]; $action->contact->id = $_POST["contactid"]; @@ -301,15 +310,11 @@ if ($_GET["action"] == 'create') print '<tr><td>'.$langs->trans("DateActionPlanned").'</td><td>'; if ($_GET["afaire"] == 1 || $_GET["afaire"] == 2) { - $html->select_date(-1,'ap','','','',"action"); - print ' '; - print_heure_select("heurep",8,20); + $html->select_date(-1,'ap',1,1,1,"action"); } else { - $html->select_date(-1,'ap','','','',"action"); - print ' '; - print_heure_select("heurep",8,20); + $html->select_date(-1,'ap',1,1,1,"action"); } print '</td></tr>'; @@ -317,21 +322,17 @@ if ($_GET["action"] == 'create') print '<tr><td>'.$langs->trans("DateActionDone").'</td><td>'; if ($_GET["afaire"] == 1 || $_GET["afaire"] == 2) { - $html->select_date(-1,'ad','','','',"action"); - print ' '; - print_heure_select("heured",8,20); + $html->select_date(-1,'ad',1,1,1,"action"); } else { - $html->select_date(-1,'ad','','','',"action"); - print ' '; - print_heure_select("heured",8,20); + $html->select_date(-1,'ad',1,1,1,"action"); } print '</td></tr>'; // Duration print '<tr><td>'.$langs->trans("Duration").'</td><td>'; - print_duree_select("duree"); + $html->select_duree("duree"); print '</td></tr>'; add_row_for_webcal_link(); @@ -464,15 +465,11 @@ if ($_GET["action"] == 'create') print '<tr><td>'.$langs->trans("DateActionPlanned").'</td><td>'; if ($_GET["afaire"] == 1 || $_GET["afaire"] == 2) { - $html->select_date(-1,'ap','','','',"action"); - print ' '; - print_heure_select("heurep",8,20); + $html->select_date(-1,'ap',1,1,1,"action"); } else { - $html->select_date(-1,'ap','','','',"action"); - print ' '; - print_heure_select("heurep",8,20); + $html->select_date(-1,'ap',1,1,1,"action"); } print '</td></tr>'; @@ -480,15 +477,11 @@ if ($_GET["action"] == 'create') print '<tr><td>'.$langs->trans("DateActionDone").'</td><td>'; if ($_GET["afaire"] == 1 || $_GET["afaire"] == 2) { - $html->select_date(-1,'ad','','','',"action"); - print ' '; - print_heure_select("heured",8,20); + $html->select_date(-1,'ad',1,1,1,"action"); } else { - $html->select_date(-1,'ad','','','',"action"); - print ' '; - print_heure_select("heured",8,20); + $html->select_date(-1,'ad',1,1,1,"action"); } print '</td></tr>'; @@ -599,16 +592,12 @@ if ($_GET["id"]) // Date planification print '<tr><td>'.$langs->trans("DateActionPlanned").'</td><td colspan="3">'; - $html->select_date(($act->datep?$act->datep:-1),'ap','','','',"action"); - print ' '; - print_heure_select("heurep",8,20); + $html->select_date(($act->datep?$act->datep:-1),'ap',1,1,1,"action"); print '</td></tr>'; // Date done print '<tr><td>'.$langs->trans("DateActionDone").'</td><td colspan="3">'; - $html->select_date(($act->date?$act->date:-1),'ad','','','',"action"); - print ' '; - print_heure_select("heured",8,20); + $html->select_date(($act->date?$act->date:-1),'ad',1,1,1,"action"); print '</td></tr>'; diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 5be365366ef..877245f9716 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -1989,11 +1989,11 @@ class Form * Les champs sont pr�s�lectionn�es avec: * - La date set_time (timestamps ou date au format YYYY-MM-DD ou YYYY-MM-DD HH:MM) * - La date du jour si set_time vaut '' - * - Aucune date (champs vides) si set_time vaut -1 (dans ce cas empty doit valoir 0) + * - Aucune date (champs vides) si set_time vaut -1 (dans ce cas empty doit valoir 1) * \param set_time Date de pr�-s�lection * \param prefix Prefix pour nom champ - * \param h Heure - * \param m Minutes + * \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. Utilis� pour les dates en popup style andre. */ @@ -2040,7 +2040,7 @@ class Form /* * Affiche date en popup */ - if ($conf->use_javascript && $conf->use_popup_calendar && $h==0 && $m==0) + if ($conf->use_javascript && $conf->use_popup_calendar) { //print "e".$set_time." t ".$conf->format_date_short; if ($set_time > 0) @@ -2169,8 +2169,8 @@ class Form if ($h) { print '<select class="flat" name="'.$prefix.'hour">'; - - for ($hour = 0; $hour < 24 ; $hour++) + if ($empty) print '<option value="-1"> </option>'; + for ($hour = 0; $hour < 24; $hour++) { if (strlen($hour) < 2) { @@ -2178,43 +2178,71 @@ class Form } if ($hour == $shour) { - print "<option value=\"$hour\" selected=\"true\">$hour"; + print "<option value=\"$hour\" selected=\"true\">$hour</option>"; } else { - print "<option value=\"$hour\">$hour"; + print "<option value=\"$hour\">$hour</option>"; } - print "</option>"; } - print "</select>H\n"; - - if ($m) + print "</select>"; + print "H\n"; + } + + /* + * Affiche min en select + */ + if ($m) + { + print '<select class="flat" name="'.$prefix.'min">'; + if ($empty) print '<option value="-1"> </option>'; + for ($min = 0; $min < 60 ; $min++) { - print '<select class="flat" name="'.$prefix.'min">'; - - for ($min = 0; $min < 60 ; $min++) + if (strlen($min) < 2) { - if (strlen($min) < 2) - { - $min = "0" . $min; - } - if ($min == $smin) - { - print "<option value=\"$min\" selected=\"true\">$min"; - } - else - { - print "<option value=\"$min\">$min"; - } - print "</option>"; + $min = "0" . $min; + } + if ($min == $smin) + { + print "<option value=\"$min\" selected=\"true\">$min</option>"; + } + else + { + print "<option value=\"$min\">$min</option>"; } - print "</select>M\n"; } - + print "</select>"; + print "M\n"; } } + /** + \brief Fonction servant a afficher une dur�e dans une liste d�roulante + \param prefix prefix + */ + function select_duree($prefix) + { + print '<select class="flat" name="'.$prefix.'hour">'; + print "<option value=\"0\">0</option>"; + for ($hour = 1 ; $hour < 24 ; $hour++) + { + print "<option value=\"$hour\""; + if ($hour == 1) print " selected=\"true\""; + print ">$hour</option>"; + } + print "</select>"; + print "H "; + print '<select class="flat" name="'.$prefix.'min">'; + for ($min = 0 ; $min < 55 ; $min=$min+5) + { + print "<option value=\"$min\">$min</option>"; + } + print "</select>"; + print "M "; + } + + /** \brief Affiche un select � partir d'un tableau \param htmlname Nom de la zone select diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php index 74bb635ffeb..38f28d078c4 100644 --- a/htdocs/lib/functions.inc.php +++ b/htdocs/lib/functions.inc.php @@ -1686,53 +1686,6 @@ function print_fleche_navigation($page,$file,$options='',$nextpage) } -/** - \brief Fonction servant a afficher les heures/minutes dans un liste d�roulante - \param prefix - \param begin (1 par defaut) - \param end (23 par defaut) -*/ -function print_heure_select($prefix,$begin=1,$end=23) -{ - print '<select class="flat" name="'.$prefix.'hour">'; - for ($hour = $begin ; $hour <= $end ; $hour++) { - print "<option value=\"$hour\">$hour"; - } - print "</select> H "; - print '<select class="flat" name="'.$prefix.'min">'; - for ($min = 0 ; $min < 60 ; $min=$min+5) { - if ($min < 10) { - $min = "0" . $min; - } - print "<option value=\"$min\">$min"; - } - print "</select>\n"; -} - -/** - \brief Fonction servant a afficher une dur�e dans une liste d�roulante - \param prefix prefix -*/ -function print_duree_select($prefix) -{ - print '<select class="flat" name="'.$prefix.'hour">'; - print "<option value=\"0\">0</option>"; - print "<option value=\"1\" selected=\"true\">1</option>"; - - for ($hour = 2 ; $hour < 13 ; $hour++) - { - print "<option value=\"$hour\">$hour</option>"; - } - print "</select> H "; - print '<select class="flat" name="'.$prefix.'min">'; - for ($min = 0 ; $min < 55 ; $min=$min+5) - { - print "<option value=\"$min\">$min</option>"; - } - print "</select>\n"; -} - - /** \brief Fonction qui retourne un montant mon�taire format� \remarks Fonction utilis�e dans les pdf et les pages html -- GitLab