dolibarr  13.0.2
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 <https://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.ScopeNotCamelCaps
65  public function select_type_socialcontrib($selected = '', $htmlname = 'actioncode', $useempty = 0, $maxlen = 40, $help = 1, $morecss = 'minwidth300', $noerrorifempty = 0)
66  {
67  // phpcs:enable
68  global $conf, $db, $langs, $user, $mysoc;
69 
70  if (empty($mysoc->country_id) && empty($mysoc->country_code))
71  {
72  print $langs->trans("ErrorSetupOfCountryMustBeDone");
73  return;
74  }
75 
76  if (!empty($mysoc->country_id))
77  {
78  $sql = "SELECT c.id, c.libelle as type";
79  $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
80  $sql .= " WHERE c.active = 1";
81  $sql .= " AND c.fk_pays = ".$mysoc->country_id;
82  $sql .= " ORDER BY c.libelle ASC";
83  } else {
84  $sql = "SELECT c.id, c.libelle as type";
85  $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c, ".MAIN_DB_PREFIX."c_country as co";
86  $sql .= " WHERE c.active = 1 AND c.fk_pays = co.rowid";
87  $sql .= " AND co.code = '".$this->db->escape($mysoc->country_code)."'";
88  $sql .= " ORDER BY c.libelle ASC";
89  }
90 
91  dol_syslog("Form::select_type_socialcontrib", LOG_DEBUG);
92  $resql = $this->db->query($sql);
93  if ($resql)
94  {
95  $num = $this->db->num_rows($resql);
96  if ($num)
97  {
98  print '<select class="'.($morecss ? $morecss : '').'" id="'.$htmlname.'" name="'.$htmlname.'">';
99  $i = 0;
100 
101  if ($useempty) print '<option value="0">&nbsp;</option>';
102  while ($i < $num)
103  {
104  $obj = $this->db->fetch_object($resql);
105  print '<option value="'.$obj->id.'"';
106  if ($obj->id == $selected) print ' selected';
107  print '>'.dol_trunc($obj->type, $maxlen);
108  $i++;
109  }
110  print '</select>';
111  if ($user->admin && $help) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
112  if (!empty($conf->use_javascript_ajax)) print ajax_combobox($htmlname);
113  } else {
114  if (empty($noerrorifempty)) print $langs->trans("ErrorNoSocialContributionForSellerCountry", $mysoc->country_code);
115  }
116  } else {
117  dol_print_error($this->db);
118  }
119  }
120 }
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete= 'resolve')
Convert a html select field into an ajax combobox.
Definition: ajax.lib.php:391
$conf db
API class for accounts.
Definition: inc.php:54
select_type_socialcontrib($selected= '', $htmlname= 'actioncode', $useempty=0, $maxlen=40, $help=1, $morecss= 'minwidth300', $noerrorifempty=0)
Return list of social contributions.
Class to manage generation of HTML components for social contributions management.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
print
Draft customers invoices.
Definition: index.php:89
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->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)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= '', $textfordropdown= '')
Show information for admin users or standard users.