From c593df2d68f86d45dd4a251504e399880aa248a2 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 20 May 2011 15:59:18 +0000 Subject: [PATCH] Fix: move 3 functions to formother class --- htdocs/admin/company.php | 8 +- htdocs/admin/ihm.php | 4 +- htdocs/comm/propal.php | 4 +- htdocs/compta/facture.php | 4 +- htdocs/compta/propal.php | 4 +- htdocs/core/class/html.form.class.php | 103 ------------------- htdocs/core/class/html.formother.class.php | 114 ++++++++++++++++++++- htdocs/fourn/facture/index.php | 4 +- htdocs/product/stock/mouvement.php | 4 +- 9 files changed, 136 insertions(+), 113 deletions(-) diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 2b089fe33a4..8966da61e6d 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -30,6 +30,7 @@ require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/images.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formcompany.class.php"); $langs->load("admin"); @@ -224,8 +225,9 @@ if ($_GET["action"] == 'removelogo') $wikihelp='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones'; llxHeader('',$langs->trans("Setup"),$wikihelp); -$form = new Form($db); -$formcompany = new FormCompany($db); +$form=new Form($db); +$formother=new FormOther($db); +$formcompany=new FormCompany($db); $countrynotdefined=''.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; @@ -488,7 +490,7 @@ if ((isset($_GET["action"]) && $_GET["action"] == 'edit') $var=!$var; print ''.$langs->trans("FiscalMonthStart").''; - print $form->select_month($conf->global->SOCIETE_FISCAL_MONTH_START,'fiscalmonthstart',1) . ''; + print $formother->select_month($conf->global->SOCIETE_FISCAL_MONTH_START,'fiscalmonthstart',1) . ''; print ""; diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 797bcb1f04f..12821b8d0c8 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -28,6 +28,7 @@ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/usergroups.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formadmin.class.php"); $langs->load("admin"); @@ -101,6 +102,7 @@ $wikihelp='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configurac llxHeader('',$langs->trans("Setup"),$wikihelp); $html=new Form($db); +$formother=new FormOther($db); $formadmin=new FormAdmin($db); print_fiche_titre($langs->trans("GUISetup"),'','setup'); @@ -232,7 +234,7 @@ if (isset($_GET["action"]) && $_GET["action"] == 'edit') // Edit // First day for weeks $var=!$var; print ''.$langs->trans("WeekStartOnDay").''; - print $html->select_dayofweek((isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:'1'),'MAIN_START_WEEK',0); + print $formother->select_dayofweek((isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:'1'),'MAIN_START_WEEK',0); print ''; print ' '; print ''; diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index e92b5d90d7c..b2d68660cf7 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -34,6 +34,7 @@ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'); require_once(DOL_DOCUMENT_ROOT."/includes/modules/propale/modules_propale.php"); require_once(DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'); +require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); require_once(DOL_DOCUMENT_ROOT."/lib/propal.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); @@ -991,6 +992,7 @@ if ($action == 'down' && $user->rights->propale->creer) llxHeader('',$langs->trans('Proposal'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'); $html = new Form($db); +$htmlother = new FormOther($db); $formfile = new FormFile($db); $companystatic=new Societe($db); @@ -1833,7 +1835,7 @@ else print ' '.$langs->trans('Year').': '; $syear = $year; //if($syear == '') $syear = date("Y"); - $html->select_year($syear,'year',1, 20, 5); + $htmlother->select_year($syear,'year',1, 20, 5); print ''; print ' '; print ''; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index d90f9ce502b..bebd7402995 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -31,6 +31,7 @@ require('../main.inc.php'); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); +require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php"); require_once(DOL_DOCUMENT_ROOT.'/includes/modules/facture/modules_facture.php'); require_once(DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'); require_once(DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'); @@ -1385,6 +1386,7 @@ if (GETPOST('action') == 'builddoc') // En get ou en post llxHeader('',$langs->trans('Bill'),'EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes'); $html = new Form($db); +$htmlother = new FormOther($db); $formfile = new FormFile($db); $now=dol_now(); @@ -3040,7 +3042,7 @@ else //print ' '.$langs->trans('Year').': '; $syear = $year; //if ($syear == '') $syear = date("Y"); - $html->select_year($syear,'year',1, 20, 5); + $htmlother->select_year($syear,'year',1, 20, 5); print ''; print ' '; print ''; diff --git a/htdocs/compta/propal.php b/htdocs/compta/propal.php index 9b534dc4a04..bbe0895a61a 100644 --- a/htdocs/compta/propal.php +++ b/htdocs/compta/propal.php @@ -30,6 +30,7 @@ require('../main.inc.php'); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); +require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php"); require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php"); require_once(DOL_DOCUMENT_ROOT."/lib/propal.lib.php"); if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'); @@ -107,6 +108,7 @@ $now=gmmktime(); llxHeader(); $html = new Form($db); +$htmlother = new FormOther($db); $formfile = new FormFile($db); $societestatic=new Societe($db); $propalstatic=new Propal($db); @@ -615,7 +617,7 @@ else $syear = $year; if($syear == '') $syear = date("Y"); - $html->select_year($syear,'year',1, 20, 5); + $htmlother->select_year($syear,'year',1, 20, 5); print ''; print ''; print ''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 6a13f097a7a..3841183a7d1 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3264,109 +3264,6 @@ class Form } } - /** - * Return HTML combo list of week - * @param selected Preselected value - * @param htmlname Nom de la zone select - * @param useempty Affiche valeur vide dans liste - * TODO Move into html.formother - */ - function select_dayofweek($selected='',$htmlname='weekid',$useempty=0) - { - global $langs; - - $week = array( 0=>$langs->trans("Day0"), - 1=>$langs->trans("Day1"), - 2=>$langs->trans("Day2"), - 3=>$langs->trans("Day3"), - 4=>$langs->trans("Day4"), - 5=>$langs->trans("Day5"), - 6=>$langs->trans("Day6")); - - $select_week = ''; - return $select_week; - } - - /** - * Return HTML combo list of month - * @param selected Preselected value - * @param htmlname Nom de la zone select - * @param useempty Affiche valeur vide dans liste - * TODO Move into html.formother - */ - function select_month($selected='',$htmlname='monthid',$useempty=0) - { - $month = monthArrayOrSelected(-1); // Get array - - $select_month = ''; - return $select_month; - } - - /** - * Return HTML combo list of years - * @param selected Preselected value (''=current year, -1=none, year otherwise) - * @param htmlname Name of HTML select object - * @param useempty Affiche valeur vide dans liste - * @param $min_year Offset of minimum year into list (by default current year -10) - * @param $max_year Offset of maximum year into list (by default current year + 5) - * TODO Move into html.formother - */ - function select_year($selected='',$htmlname='yearid',$useempty=0, $min_year=10, $max_year=5) - { - $currentyear = date("Y"); - $max_year = $currentyear+$max_year; - $min_year = $currentyear-$min_year; - if(empty($selected)) $selected = $currentyear; - - print '\n"; - } - /** * Return a HTML area with the reference of object and a navigation bar for a business object * To add a particular filter on select, you must set $object->next_prev_filter to SQL criteria. diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 12ed562a12e..71da7f1106d 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2006 Marc Barilley/Ocebo * Copyright (C) 2007 Franky Van Liedekerke @@ -470,6 +470,118 @@ class FormOther ImagePng($image,$file); //renvoie une image sous format png ImageDestroy($image); } + + /** + * Return HTML combo list of week + * @param selected Preselected value + * @param htmlname Nom de la zone select + * @param useempty Affiche valeur vide dans liste + */ + function select_dayofweek($selected='',$htmlname='weekid',$useempty=0) + { + global $langs; + + $week = array( 0=>$langs->trans("Day0"), + 1=>$langs->trans("Day1"), + 2=>$langs->trans("Day2"), + 3=>$langs->trans("Day3"), + 4=>$langs->trans("Day4"), + 5=>$langs->trans("Day5"), + 6=>$langs->trans("Day6")); + + $select_week = ''; + return $select_week; + } + + /** + * Return HTML combo list of month + * @param selected Preselected value + * @param htmlname Nom de la zone select + * @param useempty Affiche valeur vide dans liste + */ + function select_month($selected='',$htmlname='monthid',$useempty=0) + { + $month = monthArrayOrSelected(-1); // Get array + + $select_month = ''; + return $select_month; + } + + /** + * Return HTML combo list of years + * @param selected Preselected value (''=current year, -1=none, year otherwise) + * @param htmlname Name of HTML select object + * @param useempty Affiche valeur vide dans liste + * @param $min_year Offset of minimum year into list (by default current year -10) + * @param $max_year Offset of maximum year into list (by default current year + 5) + */ + function select_year($selected='',$htmlname='yearid',$useempty=0, $min_year=10, $max_year=5, $offset=0, $invert=0, $option='') + { + $currentyear = date("Y")+$offset; + $max_year = $currentyear+$max_year; + $min_year = $currentyear-$min_year; + if(empty($selected)) $selected = $currentyear; + + print '\n"; + } } diff --git a/htdocs/fourn/facture/index.php b/htdocs/fourn/facture/index.php index 632e7a26302..61f8131f847 100644 --- a/htdocs/fourn/facture/index.php +++ b/htdocs/fourn/facture/index.php @@ -28,6 +28,7 @@ require("../../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.facture.class.php"); require_once(DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.class.php"); +require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php"); require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php"); if (!$user->rights->fournisseur->facture->lire) @@ -93,6 +94,7 @@ if ($_POST["mode"] == 'search') $now=gmmktime(); $html=new Form($db); +$htmlother=new FormOther($db); llxHeader('',$langs->trans("SuppliersInvoices"),'EN:Suppliers_Invoices|FR:FactureFournisseur|ES:Facturas_de_proveedores'); @@ -206,7 +208,7 @@ if ($resql) //print ' '.$langs->trans('Year').': '; $syear = $year; //if ($syear == '') $syear = date("Y"); - $html->select_year($syear?$syear:-1,'year',1, 20, 5); + $htmlother->select_year($syear?$syear:-1,'year',1, 20, 5); print ''; print ' '; print ''; diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index 278a944a4df..03aa2476520 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -28,6 +28,7 @@ require("../../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/product/stock/class/entrepot.class.php"); require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); +require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php"); require_once(DOL_DOCUMENT_ROOT."/lib/stock.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php"); @@ -73,6 +74,7 @@ $productstatic=new Product($db); $warehousestatic=new Entrepot($db); $userstatic=new User($db); $form=new Form($db); +$formother=new FormOther($db); $sql = "SELECT p.rowid, p.label as produit, p.fk_product_type as type,"; $sql.= " s.label as stock, s.rowid as entrepot_id,"; @@ -264,7 +266,7 @@ if ($resql) print ' '.$langs->trans('Year').': '; $max_year = date("Y"); $syear = $year; - $form->select_year($syear,'year',1, 20, 5); + $formother->select_year($syear,'year',1, 20, 5); print ''; // Label of movement print '';