Fix: move 3 functions to formother class

This commit is contained in:
Regis Houssin 2011-05-20 15:59:18 +00:00
parent ab5c9edd37
commit c593df2d68
9 changed files with 136 additions and 113 deletions

View File

@ -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='<font class="error">'.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')</font>';
@ -488,7 +490,7 @@ if ((isset($_GET["action"]) && $_GET["action"] == 'edit')
$var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("FiscalMonthStart").'</td><td>';
print $form->select_month($conf->global->SOCIETE_FISCAL_MONTH_START,'fiscalmonthstart',1) . '</td></tr>';
print $formother->select_month($conf->global->SOCIETE_FISCAL_MONTH_START,'fiscalmonthstart',1) . '</td></tr>';
print "</table>";

View File

@ -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&eacute;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 '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("WeekStartOnDay").'</td><td>';
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 '</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';

View File

@ -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 '&nbsp;'.$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 '</td>';
print '<td class="liste_titre" colspan="1">&nbsp;</td>';
print '<td class="liste_titre" align="right">';

View File

@ -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 '&nbsp;'.$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 '</td>';
print '<td class="liste_titre" align="left">&nbsp;</td>';
print '<td class="liste_titre" align="left">';

View File

@ -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 '</td>';
print '<td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="10" name="search_montant_ht" value="'.$_GET['search_montant_ht'].'">';

View File

@ -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 = '<select class="flat" name="'.$htmlname.'">';
if ($useempty)
{
$select_week .= '<option value="-1">&nbsp;</option>';
}
foreach ($week as $key => $val)
{
if ($selected == $key)
{
$select_week .= '<option value="'.$key.'" selected="selected">';
}
else
{
$select_week .= '<option value="'.$key.'">';
}
$select_week .= $val;
}
$select_week .= '</select>';
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 = '<select class="flat" name="'.$htmlname.'">';
if ($useempty)
{
$select_month .= '<option value="0">&nbsp;</option>';
}
foreach ($month as $key => $val)
{
if ($selected == $key)
{
$select_month .= '<option value="'.$key.'" selected="selected">';
}
else
{
$select_month .= '<option value="'.$key.'">';
}
$select_month .= $val;
}
$select_month .= '</select>';
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 '<select class="flat" name="' . $htmlname . '">';
if($useempty)
{
if ($selected == '') $selected_html = ' selected="selected"';
print '<option value=""' . $selected_html . '>&nbsp;</option>';
}
for ($y = $max_year; $y >= $min_year; $y--)
{
$selected_html='';
if ($selected > 0 && $y == $selected) $selected_html = ' selected="selected"';
print '<option value="'.$y.'"'.$selected_html.' >'.$y.'</option>';
}
print "</select>\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.

View File

@ -4,7 +4,7 @@
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2006 Marc Barilley/Ocebo <marc@ocebo.com>
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerker@telenet.be>
@ -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 = '<select class="flat" name="'.$htmlname.'">';
if ($useempty)
{
$select_week .= '<option value="-1">&nbsp;</option>';
}
foreach ($week as $key => $val)
{
if ($selected == $key)
{
$select_week .= '<option value="'.$key.'" selected="selected">';
}
else
{
$select_week .= '<option value="'.$key.'">';
}
$select_week .= $val;
}
$select_week .= '</select>';
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 = '<select class="flat" name="'.$htmlname.'">';
if ($useempty)
{
$select_month .= '<option value="0">&nbsp;</option>';
}
foreach ($month as $key => $val)
{
if ($selected == $key)
{
$select_month .= '<option value="'.$key.'" selected="selected">';
}
else
{
$select_month .= '<option value="'.$key.'">';
}
$select_month .= $val;
}
$select_month .= '</select>';
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 '<select class="flat" id="' . $htmlname . '" name="' . $htmlname . '"'.$option.' >';
if($useempty)
{
if ($selected == '') $selected_html = ' selected="selected"';
print '<option value=""' . $selected_html . '>&nbsp;</option>';
}
if (! $invert)
{
for ($y = $max_year; $y >= $min_year; $y--)
{
$selected_html='';
if ($selected > 0 && $y == $selected) $selected_html = ' selected="selected"';
print '<option value="'.$y.'"'.$selected_html.' >'.$y.'</option>';
}
}
else
{
for ($y = $min_year; $y <= $max_year; $y++)
{
$selected_html='';
if ($selected > 0 && $y == $selected) $selected_html = ' selected="selected"';
print '<option value="'.$y.'"'.$selected_html.' >'.$y.'</option>';
}
}
print "</select>\n";
}
}

View File

@ -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 '&nbsp;'.$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 '</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre" align="left">';

View File

@ -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 '&nbsp;'.$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 '</td>';
// Label of movement
print '<td class="liste_titre" align="left">';