dolibarr  9.0.0
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 {
33  public $db;
34 
38  public $error='';
39 
40 
46  public function __construct($db)
47  {
48  $this->db = $db;
49  }
50 
51  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
64  function select_type_socialcontrib($selected='',$htmlname='actioncode', $useempty=0, $maxlen=40, $help=1, $morecss='minwidth300')
65  {
66  // phpcs:enable
67  global $conf,$db,$langs,$user,$mysoc;
68 
69  if (empty($mysoc->country_id) && empty($mysoc->country_code))
70  {
71  dol_print_error('','Call to select_type_socialcontrib with mysoc country not yet defined');
72  exit;
73  }
74 
75  if (! empty($mysoc->country_id))
76  {
77  $sql = "SELECT c.id, c.libelle as type";
78  $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
79  $sql.= " WHERE c.active = 1";
80  $sql.= " AND c.fk_pays = ".$mysoc->country_id;
81  $sql.= " ORDER BY c.libelle ASC";
82  }
83  else
84  {
85  $sql = "SELECT c.id, c.libelle as type";
86  $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c, ".MAIN_DB_PREFIX."c_country as co";
87  $sql.= " WHERE c.active = 1 AND c.fk_pays = co.rowid";
88  $sql.= " AND co.code = '".$mysoc->country_code."'";
89  $sql.= " ORDER BY c.libelle ASC";
90  }
91 
92  dol_syslog("Form::select_type_socialcontrib", LOG_DEBUG);
93  $resql=$db->query($sql);
94  if ($resql)
95  {
96  $num = $db->num_rows($resql);
97  if ($num)
98  {
99  print '<select class="'.($morecss?$morecss:'').'" id="'.$htmlname.'" name="'.$htmlname.'">';
100  $i = 0;
101 
102  if ($useempty) print '<option value="0">&nbsp;</option>';
103  while ($i < $num)
104  {
105  $obj = $db->fetch_object($resql);
106  print '<option value="'.$obj->id.'"';
107  if ($obj->id == $selected) print ' selected';
108  print '>'.dol_trunc($obj->type,$maxlen);
109  $i++;
110  }
111  print '</select>';
112  if ($user->admin && $help) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
113  if (! empty($conf->use_javascript_ajax)) print ajax_combobox($htmlname);
114  }
115  else
116  {
117  print $langs->trans("ErrorNoSocialContributionForSellerCountry",$mysoc->country_code);
118  }
119  }
120  else
121  {
122  dol_print_error($db,$db->lasterror());
123  }
124  }
125 }
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve')
Convert a html select field into an ajax combobox.
Definition: ajax.lib.php:374
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:1053
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...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='')
Show information for admin users or standard users.
Class to manage generation of HTML components for social contributions management.
if(GETPOST('cancel', 'alpha')) if(! GETPOST( 'confirmmassaction', 'alpha') &&$massaction !='presend' &&$massaction !='confirm_presend')
Draft customers invoices.
Definition: list.php:156