dolibarr  7.0.0-beta
html.formsocialcontrib.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2012 Laurent Destailleur <eldy@users.sourceforge.net>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
29 {
30  var $db;
31  var $error;
32 
33 
39  public function __construct($db)
40  {
41  $this->db = $db;
42  }
43 
56  function select_type_socialcontrib($selected='',$htmlname='actioncode', $useempty=0, $maxlen=40, $help=1, $morecss='minwidth300')
57  {
58  global $conf,$db,$langs,$user,$mysoc;
59 
60  if (empty($mysoc->country_id) && empty($mysoc->country_code))
61  {
62  dol_print_error('','Call to select_type_socialcontrib with mysoc country not yet defined');
63  exit;
64  }
65 
66  if (! empty($mysoc->country_id))
67  {
68  $sql = "SELECT c.id, c.libelle as type";
69  $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
70  $sql.= " WHERE c.active = 1";
71  $sql.= " AND c.fk_pays = ".$mysoc->country_id;
72  $sql.= " ORDER BY c.libelle ASC";
73  }
74  else
75  {
76  $sql = "SELECT c.id, c.libelle as type";
77  $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c, ".MAIN_DB_PREFIX."c_country as co";
78  $sql.= " WHERE c.active = 1 AND c.fk_pays = co.rowid";
79  $sql.= " AND co.code = '".$mysoc->country_code."'";
80  $sql.= " ORDER BY c.libelle ASC";
81  }
82 
83  dol_syslog("Form::select_type_socialcontrib", LOG_DEBUG);
84  $resql=$db->query($sql);
85  if ($resql)
86  {
87  $num = $db->num_rows($resql);
88  if ($num)
89  {
90  print '<select class="'.($morecss?$morecss:'').'" id="'.$htmlname.'" name="'.$htmlname.'">';
91  $i = 0;
92 
93  if ($useempty) print '<option value="0">&nbsp;</option>';
94  while ($i < $num)
95  {
96  $obj = $db->fetch_object($resql);
97  print '<option value="'.$obj->id.'"';
98  if ($obj->id == $selected) print ' selected';
99  print '>'.dol_trunc($obj->type,$maxlen);
100  $i++;
101  }
102  print '</select>';
103  if ($user->admin && $help) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
104  if (! empty($conf->use_javascript_ajax)) print ajax_combobox($htmlname);
105  }
106  else
107  {
108  print $langs->trans("ErrorNoSocialContributionForSellerCountry",$mysoc->country_code);
109  }
110  }
111  else
112  {
113  dol_print_error($db,$db->lasterror());
114  }
115  }
116 
117 }
118 
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve')
Convert a html select field into an ajax combobox.
Definition: ajax.lib.php:392
if(GETPOST('cancel','alpha')) if(!GETPOST('confirmmassaction','alpha')&&$massaction!= 'presend'&&$massaction!= 'confirm_presend')
Draft customers invoices.
Definition: list.php:147
select_type_socialcontrib($selected='', $htmlname='actioncode', $useempty=0, $maxlen=40, $help=1, $morecss='minwidth300')
Return list of social contributions.
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1')
Show information for admin users or standard users.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
Class to manage generation of HTML components for social contributions management.
print
Draft customers invoices.
Definition: index.php:91
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->societe->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1013