From d6301233da9abb5260595fcd49090dcc51165d71 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur 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"]."
\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 ''.$langs->trans("DateActionPlanned").''; 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 ''; @@ -317,21 +322,17 @@ if ($_GET["action"] == 'create') print ''.$langs->trans("DateActionDone").''; 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 ''; // Duration print ''.$langs->trans("Duration").''; - print_duree_select("duree"); + $html->select_duree("duree"); print ''; add_row_for_webcal_link(); @@ -464,15 +465,11 @@ if ($_GET["action"] == 'create') print ''.$langs->trans("DateActionPlanned").''; 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 ''; @@ -480,15 +477,11 @@ if ($_GET["action"] == 'create') print ''.$langs->trans("DateActionDone").''; 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 ''; @@ -599,16 +592,12 @@ if ($_GET["id"]) // Date planification print ''.$langs->trans("DateActionPlanned").''; - $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 ''; // Date done print ''.$langs->trans("DateActionDone").''; - $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 ''; 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 'H\n"; - - if ($m) + print ""; + print "H\n"; + } + + /* + * Affiche min en select + */ + if ($m) + { + print ''; - - for ($min = 0; $min < 60 ; $min++) + if (strlen($min) < 2) { - if (strlen($min) < 2) - { - $min = "0" . $min; - } - if ($min == $smin) - { - print ""; + $min = "0" . $min; + } + if ($min == $smin) + { + print ""; + } + else + { + print ""; } - print "M\n"; } - + print ""; + print "M\n"; } } + /** + \brief Fonction servant a afficher une durée dans une liste déroulante + \param prefix prefix + */ + function select_duree($prefix) + { + print '"; + print "H  "; + print '"; + 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 ' H "; - print '\n"; -} - -/** - \brief Fonction servant a afficher une durée dans une liste déroulante - \param prefix prefix -*/ -function print_duree_select($prefix) -{ - print ' H "; - print '\n"; -} - - /** \brief Fonction qui retourne un montant monétaire formaté \remarks Fonction utilisée dans les pdf et les pages html