Qual: Doxygen

Perf: Reduc size of form.class.php
This commit is contained in:
Laurent Destailleur 2012-02-20 10:09:28 +01:00
parent 8466ea055c
commit b93c03a9c9
12 changed files with 264 additions and 201 deletions

View File

@ -17,10 +17,10 @@
*/
/**
* \file dev/skeletons/skeleton_class.class.php
* \ingroup mymodule othermodule1 othermodule2
* \brief This file is an example for a CRUD class file (Create/Read/Update/Delete)
* Put here some comments
* \file dev/skeletons/skeleton_class.class.php
* \ingroup mymodule othermodule1 othermodule2
* \brief This file is an example for a CRUD class file (Create/Read/Update/Delete)
* Put here some comments
*/
// Put here all includes required by your class file

View File

@ -24,6 +24,7 @@
require('../../main.inc.php');
require_once(DOL_DOCUMENT_ROOT."/compta/sociales/class/chargesociales.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formsocialcontrib.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/tax.lib.php");
$langs->load("compta");
@ -169,10 +170,12 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->tax->charges->cr
* View
*/
$form = new Form($db);
$formsocialcontrib = new FormSocialContrib($db);
$help_url='EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:Módulo Impuestos y cargas sociales (IVA, impuestos)';
llxHeader("",$langs->trans("SocialContribution"),$help_url);
$form = new Form($db);
// Mode creation
if ($action == 'create')
@ -216,7 +219,7 @@ if ($action == 'create')
// Type
print '<td align="left">';
$form->select_type_socialcontrib(isset($_POST["actioncode"])?$_POST["actioncode"]:'','actioncode',1);
$formsocialcontrib->select_type_socialcontrib(isset($_POST["actioncode"])?$_POST["actioncode"]:'','actioncode',1);
print '</td>';
// Date end period

View File

@ -24,7 +24,8 @@
*/
require('../../main.inc.php');
require(DOL_DOCUMENT_ROOT."/compta/sociales/class/chargesociales.class.php");
require_once(DOL_DOCUMENT_ROOT."/compta/sociales/class/chargesociales.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formsocialcontrib.class.php");
// Security check
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
@ -66,10 +67,11 @@ else
* View
*/
llxHeader();
$form = new Form($db);
$formsocialcontrib = new FormSocialContrib($db);
$chargesociale_static=new ChargeSociales($db);
llxHeader();
$sql = "SELECT cs.rowid as id, cs.fk_type as type, ";
$sql.= " cs.amount, cs.date_ech, cs.libelle, cs.paye, cs.periode,";
@ -99,8 +101,6 @@ $sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit($limit+1,$offset);
$chargesociale_static=new ChargeSociales($db);
$resql=$db->query($sql);
if ($resql)
{
@ -155,7 +155,7 @@ if ($resql)
print '<td class="liste_titre"><input type="text" class="flat" size="8" name="search_label" value="'.GETPOST("search_label").'"></td>';
// Type
print '<td class="liste_titre" align="left">';
$form->select_type_socialcontrib($typeid,'typeid',1,16,0);
$formsocialcontrib->select_type_socialcontrib($typeid,'typeid',1,16,0);
print '</td>';
// Period end date
print '<td class="liste_titre">&nbsp;</td>';

View File

@ -48,13 +48,15 @@ class CSMSFile
/**
* CSMSFile
* @param to Recipients SMS
* @param from Sender SMS
* @param msg Message
* @param deliveryreceipt Ask a delivery receipt
* @param deferred Deferred or not
* @param priority Priority
* @param class Class
*
* @param string $to Recipients SMS
* @param string $from Sender SMS
* @param string $msg Message
* @param int $deliveryreceipt Ask a delivery receipt
* @param int $deferred Deferred or not
* @param int $priority Priority
* @param int $class Class
* @return int
*/
function CSMSFile($to,$from,$msg,$deliveryreceipt=0,$deferred=0,$priority=3,$class=1)
{
@ -191,6 +193,8 @@ class CSMSFile
/**
* Write content of a SMTP request into a dump file (mode = all)
* Used for debugging.
*
* @return void
*/
function dump_sms()
{
@ -212,6 +216,9 @@ class CSMSFile
/**
* Write content of a SMTP request into a dump file (mode = all)
* Used for debugging.
*
* @param int $result Result of sms sending
* @return void
*/
function dump_sms_result($result)
{

View File

@ -109,7 +109,7 @@ class DolCookie
* @param string $value Cookie value
* @param string $expire Expiration
* @param string $path Path of cookie
* @param string $domaine Domain name
* @param string $domain Domain name
* @param int $secure 0 or 1
* @return void
*/

View File

@ -23,11 +23,13 @@
/**
* \class DolException
* \brief Class to manage exceptions
* Class to manage exceptions
*/
class DolException extends Exception
{
/**
* Constructor
*/
function DolException()
{
}

View File

@ -89,8 +89,8 @@ class DolGeoIP
/**
* Return in lower case the country code from an ip
*
* @param $ip IP to scan
* @return string Country code (two letters)
* @param string $ip IP to scan
* @return string Country code (two letters)
*/
function getCountryCodeFromIP($ip)
{
@ -113,8 +113,8 @@ class DolGeoIP
/**
* Return in lower case the country code from a host name
*
* @param $name FQN of host (example: myserver.xyz.com)
* @return string Country code (two letters)
* @param string $name FQN of host (example: myserver.xyz.com)
* @return string Country code (two letters)
*/
function getCountryCodeFromName($name)
{

View File

@ -30,9 +30,8 @@
/**
\class Events
\brief Events class
\remarks Initialy built by build_class_from_table on 2008-02-28 17:25
* Events class
* Initialy built by build_class_from_table on 2008-02-28 17:25
*/
class Events // extends CommonObject
{
@ -40,6 +39,7 @@ class Events // extends CommonObject
public $table_element='events'; //!< Name of table without prefix where object is stored
var $id;
var $db;
var $tms;
var $type;
@ -88,17 +88,18 @@ class Events // extends CommonObject
/**
* Constructor
*
* @param DoliDB $DB Database handler
* @param DoliDB $db Database handler
*/
function Events($DB)
function Events($db)
{
$this->db = $DB;
$this->db = $db;
return 1;
}
/**
* Create in database
*
* @param User $user User that create
* @return int <0 if KO, >0 if OK
*/
@ -131,7 +132,7 @@ class Events // extends CommonObject
$sql.= " '".$this->db->escape($this->description)."'";
$sql.= ")";
dol_syslog("Events::create sql=".$sql, LOG_DEBUG);
dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
@ -141,17 +142,18 @@ class Events // extends CommonObject
else
{
$this->error="Error ".$this->db->lasterror();
dol_syslog("Events::create ".$this->error, LOG_ERR);
dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
return -1;
}
}
/**
* \brief Update database
* \param user User that modify
* \param notrigger 0=no, 1=yes (no update trigger)
* \return int <0 if KO, >0 if OK
* Update database
*
* @param User $user User that modify
* @param int $notrigger 0=no, 1=yes (no update trigger)
* @return int <0 if KO, >0 if OK
*/
function update($user=0, $notrigger=0)
{
@ -172,12 +174,12 @@ class Events // extends CommonObject
$sql.= " description='".$this->db->escape($this->description)."'";
$sql.= " WHERE rowid=".$this->id;
dol_syslog("Events::update sql=".$sql, LOG_DEBUG);
dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql)
{
$this->error="Error ".$this->db->lasterror();
dol_syslog("Events::update ".$this->error, LOG_ERR);
dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR);
return -1;
}
return 1;
@ -185,10 +187,11 @@ class Events // extends CommonObject
/**
* \brief Load object in memory from database
* \param id id object
* \param user User that load
* \return int <0 if KO, >0 if OK
* Load object in memory from database
*
* @param int $id Id object
* @param User $user User that load
* @return int <0 if KO, >0 if OK
*/
function fetch($id, $user=0)
{
@ -206,7 +209,7 @@ class Events // extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX."events as t";
$sql.= " WHERE t.rowid = ".$id;
dol_syslog("Events::fetch sql=".$sql, LOG_DEBUG);
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
@ -230,16 +233,17 @@ class Events // extends CommonObject
else
{
$this->error="Error ".$this->db->lasterror();
dol_syslog("Events::fetch ".$this->error, LOG_ERR);
dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
return -1;
}
}
/**
* \brief Delete object in database
* \param user User that delete
* \return int <0 if KO, >0 if OK
* Delete object in database
*
* @param User $user User that delete
* @return int <0 if KO, >0 if OK
*/
function delete($user)
{
@ -248,12 +252,12 @@ class Events // extends CommonObject
$sql = "DELETE FROM ".MAIN_DB_PREFIX."events";
$sql.= " WHERE rowid=".$this->id;
dol_syslog("Events::delete sql=".$sql);
dol_syslog(get_class($this)."::delete sql=".$sql);
$resql = $this->db->query($sql);
if (! $resql)
{
$this->error="Error ".$this->db->lasterror();
dol_syslog("Events::delete ".$this->error, LOG_ERR);
dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
return -1;
}

View File

@ -60,13 +60,13 @@ class ExtraFields
/**
* Add a new extra field parameter
*
* @param attrname code of attribute
* @param label label of attribute
* @param type Type of attribute ('int', 'text', 'varchar', 'date', 'datehour')
* @param pos Position of attribute
* @param size Size/length of attribute
* @param elementtype Element type ('member', 'product', 'company', ...)
* @return int <=0 if KO, >0 if OK
* @param string $attrname Code of attribute
* @param string $label label of attribute
* @param int $type Type of attribute ('int', 'text', 'varchar', 'date', 'datehour')
* @param int $pos Position of attribute
* @param int $size Size/length of attribute
* @param string $elementtype Element type ('member', 'product', 'company', ...)
* @return int <=0 if KO, >0 if OK
*/
function addExtraField($attrname,$label,$type='',$pos=0,$size=0, $elementtype='member')
{
@ -89,11 +89,11 @@ class ExtraFields
/**
* Add a new optionnal attribute
*
* @param attrname code of attribute
* @param type Type of attribute ('int', 'text', 'varchar', 'date', 'datehour')
* @param length Size/length of attribute
* @param elementtype Element type ('member', 'product', 'company', ...)
* @return int <=0 if KO, >0 if OK
* @param string $attrname code of attribute
* @param int $type Type of attribute ('int', 'text', 'varchar', 'date', 'datehour')
* @param int $length Size/length of attribute
* @param string $elementtype Element type ('member', 'product', 'company', ...)
* @return int <=0 if KO, >0 if OK
*/
function create($attrname,$type='varchar',$length=255,$elementtype='member')
{
@ -131,13 +131,13 @@ class ExtraFields
/**
* Add description of a new optionnal attribute
*
* @param attrname code of attribute
* @param label label of attribute
* @param type Type of attribute ('int', 'text', 'varchar', 'date', 'datehour')
* @param pos Position of attribute
* @param size Size/length of attribute
* @param elementtype Element type ('member', 'product', 'company', ...)
* @return int <=0 if KO, >0 if OK
* @param string $attrname code of attribute
* @param string $label label of attribute
* @param int $type Type of attribute ('int', 'text', 'varchar', 'date', 'datehour')
* @param int $pos Position of attribute
* @param int $size Size/length of attribute
* @param string $elementtype Element type ('member', 'product', 'company', ...)
* @return int <=0 if KO, >0 if OK
*/
function create_label($attrname,$label='',$type='',$pos=0,$size=0, $elementtype='member')
{
@ -175,9 +175,9 @@ class ExtraFields
/**
* Delete an optionnal attribute
*
* @param attrname Code of attribute to delete
* @param elementtype Element type ('member', 'product', 'company', ...)
* @return int < 0 if KO, 0 if nothing is done, 1 if OK
* @param string $attrname Code of attribute to delete
* @param string $elementtype Element type ('member', 'product', 'company', ...)
* @return int < 0 if KO, 0 if nothing is done, 1 if OK
*/
function delete($attrname,$elementtype='member')
{
@ -215,9 +215,9 @@ class ExtraFields
/**
* Delete description of an optionnal attribute
*
* @param attrname Code of attribute to delete
* @param elementtype Element type ('member', 'product', 'company', ...)
* @return int < 0 if KO, 0 if nothing is done, 1 if OK
* @param string $attrname Code of attribute to delete
* @param string $elementtype Element type ('member', 'product', 'company', ...)
* @return int < 0 if KO, 0 if nothing is done, 1 if OK
*/
function delete_label($attrname,$elementtype='member')
{
@ -231,7 +231,8 @@ class ExtraFields
$sql.= " AND elementtype = '".$elementtype."'";
dol_syslog(get_class($this)."::delete_label sql=".$sql);
if ( $this->db->query( $sql) )
$resql=$this->db->query($sql);
if ($resql)
{
return 1;
}
@ -251,11 +252,11 @@ class ExtraFields
/**
* Modify type of a personalized attribute
*
* @param attrname name of attribute
* @param type type of attribute
* @param length length of attribute
* @param elementtype Element type ('member', 'product', 'company', ...)
* @return int >0 if OK, <=0 if KO
* @param string $attrname Name of attribute
* @param string $type Type of attribute
* @param int $length Length of attribute
* @param string $elementtype Element type ('member', 'product', 'company', ...)
* @return int >0 if OK, <=0 if KO
*/
function update($attrname,$type='varchar',$length=255,$elementtype='member')
{
@ -297,8 +298,9 @@ class ExtraFields
* @param string $attrname Name of attribute
* @param string $label Label of attribute
* @param string $type Type of attribute
* @param int $length Length of attribute
* @param int $size Length of attribute
* @param string $elementtype Element type ('member', 'product', 'company', ...)
* @return int <0 if KO, >0 if OK
*/
function update_label($attrname,$label,$type,$size,$elementtype='member')
{
@ -409,10 +411,12 @@ class ExtraFields
/**
* Return HTML string to put an input field into a page
* @param key Key of attribute
* @param value Value to show
* @param moreparam To add more parametes on html input tag
* Return HTML string to put an input field into a page
*
* @param string $key Key of attribute
* @param string $value Value to show
* @param string $moreparam To add more parametes on html input tag
* @return void
*/
function showInputField($key,$value,$moreparam='')
{
@ -460,11 +464,12 @@ class ExtraFields
}
/**
* Return HTML string to put an output field into a page
* Return HTML string to put an output field into a page
*
* @param string $key Key of attribute
* @param string $value Value to show
* @return string Formated value
* @param string $key Key of attribute
* @param string $value Value to show
* @param string $moreparam More param
* @return string Formated value
*/
function showOutputField($key,$value,$moreparam='')
{

View File

@ -20,6 +20,10 @@
* \file htdocs/core/class/google.class.php
* \brief A set of functions for using Google APIs
*/
/**
* Class to manage Google API
*/
class GoogleAPI
{
var $db;
@ -32,27 +36,27 @@ class GoogleAPI
*
* @param DoliDB $db Database handler
* @param string $key Google key
* @return GoogleAPI
* @return GoogleAPI
*/
function GoogleAPI($DB,$key)
function GoogleAPI($db,$key)
{
$this->db=$DB;
$this->db=$db;
$this->key=$key;
}
/**
* \brief Return geo coordinates of an address
* \param address Address
* Example: 68 Grande rue Charles de Gaulle,+94130,+Nogent sur Marne,+France
* Example: 188, rue de Fontenay,+94300,+Vincennes,+France
* \return string Coordinates
* Return geo coordinates of an address
*
* @param string $address Address
* Example: 68 Grande rue Charles de Gaulle,+94130,+Nogent sur Marne,+France
* Example: 188, rue de Fontenay,+94300,+Vincennes,+France
* @return string Coordinates
*/
function getGeoCoordinatesOfAddress($address)
{
global $conf;
$i=0;
// Desired address

View File

@ -35,9 +35,8 @@
/**
* \class Form
* \brief Class to manage generation of HTML components
* \remarks Only common components must be here.
* Class to manage generation of HTML components
* Only common components must be here.
*/
class Form
{
@ -393,9 +392,10 @@ class Form
/**
* Return combo list of activated countries, into language of user
*
* @param selected Id or Code or Label of preselected country
* @param htmlname Name of html select object
* @param htmloption Options html on select object
* @param string $selected Id or Code or Label of preselected country
* @param string $htmlname Name of html select object
* @param string $htmloption Options html on select object
* @return void
*/
function select_pays($selected='',$htmlname='pays_id',$htmloption='')
{
@ -405,10 +405,10 @@ class Form
/**
* Return combo list of activated countries, into language of user
*
* @param selected Id or Code or Label of preselected country
* @param htmlname Name of html select object
* @param htmloption Options html on select object
* @return string HTML string with select
* @param string $selected Id or Code or Label of preselected country
* @param string $htmlname Name of html select object
* @param string $htmloption Options html on select object
* @return string HTML string with select
*/
function select_country($selected='',$htmlname='pays_id',$htmloption='')
{
@ -479,8 +479,9 @@ class Form
/**
* Retourne la liste des types de comptes financiers
*
* @param selected Type pre-selectionne
* @param htmlname Nom champ formulaire
* @param string $selected Type pre-selectionne
* @param string $htmlname Nom champ formulaire
* @return void
*/
function select_type_comptes_financiers($selected=1,$htmlname='type')
{
@ -510,86 +511,16 @@ class Form
print '</select>';
}
/**
* Return list of social contributions.
* Use mysoc->country_id or mysoc->country_code so they must be defined.
* Return list of types of lines (product or service)
* Example: 0=product, 1=service, 9=other (for external module)
*
* @param selected Preselected type
* @param htmlname Name of field in form
* @param useempty Set to 1 if we want an empty value
* @param maxlen Max length of text in combo box
* @param help Add or not the admin help picto
*/
function select_type_socialcontrib($selected='',$htmlname='actioncode', $useempty=0, $maxlen=40, $help=1)
{
global $db,$langs,$user,$mysoc;
if (empty($mysoc->country_id) && empty($mysoc->country_code))
{
dol_print_error('','Call to select_type_socialcontrib with mysoc country not yet defined');
exit;
}
if (! empty($mysoc->country_id))
{
$sql = "SELECT c.id, c.libelle as type";
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
$sql.= " WHERE c.active = 1";
$sql.= " AND c.fk_pays = ".$mysoc->country_id;
$sql.= " ORDER BY c.libelle ASC";
}
else
{
$sql = "SELECT c.id, c.libelle as type";
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c, ".MAIN_DB_PREFIX."c_pays as p";
$sql.= " WHERE c.active = 1 AND c.fk_pays = p.rowid";
$sql.= " AND p.code = '".$mysoc->country_code."'";
$sql.= " ORDER BY c.libelle ASC";
}
dol_syslog("Form::select_type_socialcontrib sql=".$sql, LOG_DEBUG);
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
if ($num)
{
print '<select class="flat" name="'.$htmlname.'">';
$i = 0;
if ($useempty) print '<option value="0">&nbsp;</option>';
while ($i < $num)
{
$obj = $db->fetch_object($resql);
print '<option value="'.$obj->id.'"';
if ($obj->id == $selected) print ' selected="selected"';
print '>'.dol_trunc($obj->type,$maxlen);
$i++;
}
print '</select>';
if ($user->admin && $help) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
}
else
{
print $langs->trans("ErrorNoSocialContributionForSellerCountry",$mysoc->country_code);
}
}
else
{
dol_print_error($db,$db->lasterror());
}
}
/**
* Return list of types of lines (product or service)
* Example: 0=product, 1=service, 9=other (for external module)
*
* @param selected Preselected type
* @param htmlname Name of field in html form
* @param showempty Add an empty field
* @param hidetext Do not show label before combo box
* @param forceall Force to show products and services in combo list, whatever are activated modules
* @param string $selected Preselected type
* @param string $htmlname Name of field in html form
* @param int $showempty Add an empty field
* @param int $hidetext Do not show label before combo box
* @param string $forceall Force to show products and services in combo list, whatever are activated modules
* @return void
*/
function select_type_of_lines($selected='',$htmlname='type',$showempty=0,$hidetext=0,$forceall=0)
{
@ -676,10 +607,10 @@ class Form
/**
* Return list of types of notes
*
* @param string $selected Preselected type
* @param string $htmlname Name of field in form
* @param int $showempty Add an empty field
* @return void
* @param string $selected Preselected type
* @param string $htmlname Name of field in form
* @param int $showempty Add an empty field
* @return void
*/
function select_type_fees($selected='',$htmlname='type',$showempty=0)
{
@ -711,14 +642,15 @@ class Form
}
/**
* Output html form to select a third party
* Output html form to select a third party
*
* @param selected Preselected type
* @param htmlname Name of field in form
* @param filter Optionnal filters criteras
* @param showempty Add an empty field
* @param showtype Show third party type in combolist (customer, prospect or supplier)
* @param forcecombo Force to use combo box
* @param string $selected Preselected type
* @param string $htmlname Name of field in form
* @param string $filter Optionnal filters criteras
* @param int $showempty Add an empty field
* @param int $showtype Show third party type in combolist (customer, prospect or supplier)
* @param int $forcecombo Force to use combo box
* @return void
*/
function select_societes($selected='',$htmlname='socid',$filter='',$showempty=0, $showtype=0, $forcecombo=0)
{

View File

@ -0,0 +1,106 @@
<?php
/* Copyright (C) 2012 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/core/class/html.form.class.php
* \ingroup core
* \brief File of class with all html predefined components
*/
/**
* Class to manage generation of HTML components for social contributions management
*/
class FormSocialContrib
{
var $db;
var $error;
/**
* Return list of social contributions.
* Use mysoc->country_id or mysoc->country_code so they must be defined.
*
* @param string $selected Preselected type
* @param string $htmlname Name of field in form
* @param int $useempty Set to 1 if we want an empty value
* @param int $maxlen Max length of text in combo box
* @param int $help Add or not the admin help picto
* @return void
*/
function select_type_socialcontrib($selected='',$htmlname='actioncode', $useempty=0, $maxlen=40, $help=1)
{
global $db,$langs,$user,$mysoc;
if (empty($mysoc->country_id) && empty($mysoc->country_code))
{
dol_print_error('','Call to select_type_socialcontrib with mysoc country not yet defined');
exit;
}
if (! empty($mysoc->country_id))
{
$sql = "SELECT c.id, c.libelle as type";
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
$sql.= " WHERE c.active = 1";
$sql.= " AND c.fk_pays = ".$mysoc->country_id;
$sql.= " ORDER BY c.libelle ASC";
}
else
{
$sql = "SELECT c.id, c.libelle as type";
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c, ".MAIN_DB_PREFIX."c_pays as p";
$sql.= " WHERE c.active = 1 AND c.fk_pays = p.rowid";
$sql.= " AND p.code = '".$mysoc->country_code."'";
$sql.= " ORDER BY c.libelle ASC";
}
dol_syslog("Form::select_type_socialcontrib sql=".$sql, LOG_DEBUG);
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
if ($num)
{
print '<select class="flat" name="'.$htmlname.'">';
$i = 0;
if ($useempty) print '<option value="0">&nbsp;</option>';
while ($i < $num)
{
$obj = $db->fetch_object($resql);
print '<option value="'.$obj->id.'"';
if ($obj->id == $selected) print ' selected="selected"';
print '>'.dol_trunc($obj->type,$maxlen);
$i++;
}
print '</select>';
if ($user->admin && $help) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
}
else
{
print $langs->trans("ErrorNoSocialContributionForSellerCountry",$mysoc->country_code);
}
}
else
{
dol_print_error($db,$db->lasterror());
}
}
}
?>