* Copyright (C) 2008-2012 Regis Houssin * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2017 Rui Strecht * * 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 3 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 . */ /** * \file htdocs/core/class/html.formcompany.class.php * \ingroup core * \brief File of class to build HTML component for third parties management */ /** * Class to build HTML component for third parties management * Only common components are here. */ require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; class FormCompany extends Form { // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of labels (translated) of third parties type * * @param int $mode 0=Return id+label, 1=Return code+label * @param string $filter Add a SQL filter to select * @return array Array of types */ public function typent_array($mode = 0, $filter = '') { // phpcs:enable global $langs, $mysoc; $effs = array(); $sql = "SELECT id, code, libelle"; $sql .= " FROM ".MAIN_DB_PREFIX."c_typent"; $sql .= " WHERE active = 1 AND (fk_country IS NULL OR fk_country = ".(empty($mysoc->country_id) ? '0' : $mysoc->country_id).")"; if ($filter) $sql .= " ".$filter; $sql .= " ORDER by position, id"; dol_syslog(get_class($this).'::typent_array', LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); $i = 0; while ($i < $num) { $objp = $this->db->fetch_object($resql); if (!$mode) $key = $objp->id; else $key = $objp->code; if ($langs->trans($objp->code) != $objp->code) $effs[$key] = $langs->trans($objp->code); else $effs[$key] = $objp->libelle; if ($effs[$key] == '-') $effs[$key] = ''; $i++; } $this->db->free($resql); } return $effs; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoie la liste des types d'effectifs possibles (pas de traduction car nombre) * * @param int $mode 0=renvoi id+libelle, 1=renvoi code+libelle * @param string $filter Add a SQL filter to select * @return array Array of types d'effectifs */ public function effectif_array($mode = 0, $filter = '') { // phpcs:enable $effs = array(); $sql = "SELECT id, code, libelle"; $sql .= " FROM ".MAIN_DB_PREFIX."c_effectif"; $sql .= " WHERE active = 1"; if ($filter) $sql .= " ".$filter; $sql .= " ORDER BY id ASC"; dol_syslog(get_class($this).'::effectif_array', LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); $i = 0; while ($i < $num) { $objp = $this->db->fetch_object($resql); if (!$mode) $key = $objp->id; else $key = $objp->code; $effs[$key] = $objp->libelle != '-' ? $objp->libelle : ''; $i++; } $this->db->free($resql); } return $effs; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Affiche formulaire de selection des modes de reglement * * @param int $page Page * @param int $selected Id or code preselected * @param string $htmlname Nom du formulaire select * @param int $empty Add empty value in list * @return void */ public function form_prospect_level($page, $selected = '', $htmlname = 'prospect_level_id', $empty = 0) { // phpcs:enable global $user, $langs; print '
'; print ''; print ''; dol_syslog(get_class($this).'::form_prospect_level', LOG_DEBUG); $sql = "SELECT code, label"; $sql .= " FROM ".MAIN_DB_PREFIX."c_prospectlevel"; $sql .= " WHERE active > 0"; $sql .= " ORDER BY sortorder"; $resql = $this->db->query($sql); if ($resql) { $options = array(); if ($empty) { $options[''] = ''; } while ($obj = $this->db->fetch_object($resql)) { $level = $langs->trans($obj->code); if ($level == $obj->code) { $level = $langs->trans($obj->label); } $options[$obj->code] = $level; } print Form::selectarray($htmlname, $options, $selected); } else dol_print_error($this->db); if (!empty($htmlname) && $user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print ''; print '
'; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns the drop-down list of departments/provinces/cantons for all countries or for a given country. * In the case of an all-country list, the display breaks on the country. * The key of the list is the code (there can be several entries for a given code but in this case, the country field differs). * Thus the links with the departments are done on a department independently of its name. * * @param string $selected Code state preselected * @param int $country_codeid 0=list for all countries, otherwise country code or country rowid to show * @param string $htmlname Id of department * @return void */ public function select_departement($selected = '', $country_codeid = 0, $htmlname = 'state_id') { // phpcs:enable print $this->select_state($selected, $country_codeid, $htmlname); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns the drop-down list of departments/provinces/cantons for all countries or for a given country. * In the case of an all-country list, the display breaks on the country. * The key of the list is the code (there can be several entries for a given code but in this case, the country field differs). * Thus the links with the departments are done on a department independently of its name. * * @param int $selected Code state preselected (mus be state id) * @param integer $country_codeid Country code or id: 0=list for all countries, otherwise country code or country rowid to show * @param string $htmlname Id of department. If '', we want only the string with