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

@ -24,6 +24,7 @@
require('../../main.inc.php'); require('../../main.inc.php');
require_once(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");
require_once(DOL_DOCUMENT_ROOT."/core/lib/tax.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/tax.lib.php");
$langs->load("compta"); $langs->load("compta");
@ -169,10 +170,12 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->tax->charges->cr
* View * 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)'; $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); llxHeader("",$langs->trans("SocialContribution"),$help_url);
$form = new Form($db);
// Mode creation // Mode creation
if ($action == 'create') if ($action == 'create')
@ -216,7 +219,7 @@ if ($action == 'create')
// Type // Type
print '<td align="left">'; 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>'; print '</td>';
// Date end period // Date end period

View File

@ -24,7 +24,8 @@
*/ */
require('../../main.inc.php'); 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 // Security check
$socid = isset($_GET["socid"])?$_GET["socid"]:''; $socid = isset($_GET["socid"])?$_GET["socid"]:'';
@ -66,10 +67,11 @@ else
* View * View
*/ */
llxHeader();
$form = new Form($db); $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 = "SELECT cs.rowid as id, cs.fk_type as type, ";
$sql.= " cs.amount, cs.date_ech, cs.libelle, cs.paye, cs.periode,"; $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); $sql.= $db->plimit($limit+1,$offset);
$chargesociale_static=new ChargeSociales($db);
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) 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>'; print '<td class="liste_titre"><input type="text" class="flat" size="8" name="search_label" value="'.GETPOST("search_label").'"></td>';
// Type // Type
print '<td class="liste_titre" align="left">'; 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>'; print '</td>';
// Period end date // Period end date
print '<td class="liste_titre">&nbsp;</td>'; print '<td class="liste_titre">&nbsp;</td>';

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -35,9 +35,8 @@
/** /**
* \class Form * Class to manage generation of HTML components
* \brief Class to manage generation of HTML components * Only common components must be here.
* \remarks Only common components must be here.
*/ */
class Form class Form
{ {
@ -393,9 +392,10 @@ class Form
/** /**
* Return combo list of activated countries, into language of user * Return combo list of activated countries, into language of user
* *
* @param selected Id or Code or Label of preselected country * @param string $selected Id or Code or Label of preselected country
* @param htmlname Name of html select object * @param string $htmlname Name of html select object
* @param htmloption Options html on select object * @param string $htmloption Options html on select object
* @return void
*/ */
function select_pays($selected='',$htmlname='pays_id',$htmloption='') function select_pays($selected='',$htmlname='pays_id',$htmloption='')
{ {
@ -405,9 +405,9 @@ class Form
/** /**
* Return combo list of activated countries, into language of user * Return combo list of activated countries, into language of user
* *
* @param selected Id or Code or Label of preselected country * @param string $selected Id or Code or Label of preselected country
* @param htmlname Name of html select object * @param string $htmlname Name of html select object
* @param htmloption Options html on select object * @param string $htmloption Options html on select object
* @return string HTML string with select * @return string HTML string with select
*/ */
function select_country($selected='',$htmlname='pays_id',$htmloption='') function select_country($selected='',$htmlname='pays_id',$htmloption='')
@ -479,8 +479,9 @@ class Form
/** /**
* Retourne la liste des types de comptes financiers * Retourne la liste des types de comptes financiers
* *
* @param selected Type pre-selectionne * @param string $selected Type pre-selectionne
* @param htmlname Nom champ formulaire * @param string $htmlname Nom champ formulaire
* @return void
*/ */
function select_type_comptes_financiers($selected=1,$htmlname='type') function select_type_comptes_financiers($selected=1,$htmlname='type')
{ {
@ -510,86 +511,16 @@ class Form
print '</select>'; print '</select>';
} }
/**
* Return list of social contributions.
* Use mysoc->country_id or mysoc->country_code so they must be defined.
*
* @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) * Return list of types of lines (product or service)
* Example: 0=product, 1=service, 9=other (for external module) * Example: 0=product, 1=service, 9=other (for external module)
* *
* @param selected Preselected type * @param string $selected Preselected type
* @param htmlname Name of field in html form * @param string $htmlname Name of field in html form
* @param showempty Add an empty field * @param int $showempty Add an empty field
* @param hidetext Do not show label before combo box * @param int $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 $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) function select_type_of_lines($selected='',$htmlname='type',$showempty=0,$hidetext=0,$forceall=0)
{ {
@ -713,12 +644,13 @@ class Form
/** /**
* Output html form to select a third party * Output html form to select a third party
* *
* @param selected Preselected type * @param string $selected Preselected type
* @param htmlname Name of field in form * @param string $htmlname Name of field in form
* @param filter Optionnal filters criteras * @param string $filter Optionnal filters criteras
* @param showempty Add an empty field * @param int $showempty Add an empty field
* @param showtype Show third party type in combolist (customer, prospect or supplier) * @param int $showtype Show third party type in combolist (customer, prospect or supplier)
* @param forcecombo Force to use combo box * @param int $forcecombo Force to use combo box
* @return void
*/ */
function select_societes($selected='',$htmlname='socid',$filter='',$showempty=0, $showtype=0, $forcecombo=0) 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());
}
}
}
?>