dolibarr/htdocs/core/class/html.formaccounting.class.php

762 lines
29 KiB
PHP
Raw Permalink Normal View History

2016-03-28 11:51:19 +00:00
<?php
/* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2016-2026 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
2016-03-28 11:51:19 +00:00
*
* 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
2019-09-23 19:55:30 +00:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2016-03-28 11:51:19 +00:00
*/
/**
* \file htdocs/core/class/html.formaccounting.class.php
2019-06-18 20:38:52 +00:00
* \ingroup Accountancy (Double entries)
2016-03-28 11:51:19 +00:00
* \brief File of class with all html predefined components
*/
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
2016-03-28 11:51:19 +00:00
/**
* Class to manage generation of HTML components for accounting management
*/
class FormAccounting extends Form
2016-03-28 11:51:19 +00:00
{
/**
* @var array<string, array<string, string>|array<string, array<string, mixed>>>
*/
private $options_cache = array();
2016-03-28 11:51:19 +00:00
/**
* @var DoliDB Database handler.
*/
public $db;
2018-09-02 21:01:14 +00:00
2018-08-22 08:37:16 +00:00
/**
* @var string Error code (or message)
*/
public $error = '';
2016-03-28 11:51:19 +00:00
2023-07-10 20:14:07 +00:00
/**
* @var int Nb of accounts found
*/
public $nbaccounts;
2023-09-24 23:00:25 +00:00
/**
* @var int Nb of accounts category found
*/
public $nbaccounts_category;
2023-07-10 20:14:07 +00:00
/**
2019-10-27 10:18:36 +00:00
* Constructor
*
* @param DoliDB $db Database handler
*/
2016-03-28 11:51:19 +00:00
public function __construct($db)
{
$this->db = $db;
2016-03-28 11:51:19 +00:00
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of journals with label by nature
*
* @param string $selectid Preselected journal code
* @param string $htmlname Name of field in html form
* @param int<0,9> $nature Limit the list to a particular type of journals (1:various operations / 2:sale / 3:purchase / 4:bank / 9: has-new)
* @param int<0,1> $showempty Add an empty field
* @param int<0,1> $select_in 0=selectid value is the journal rowid (default) or 1=selectid is journal code
* @param int<0,1> $select_out Set value returned by select. 0=rowid (default), 1=code
* @param string $morecss More css non HTML object
* @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache.
* @param int<0,1> $disabledajaxcombo Disable ajax combo box.
* @return string|int String with HTML select, or -1 if error
*/
2019-02-27 22:55:18 +00:00
public function select_journal($selectid, $htmlname = 'journal', $nature = 0, $showempty = 0, $select_in = 0, $select_out = 0, $morecss = 'maxwidth300 maxwidthonsmartphone', $usecache = '', $disabledajaxcombo = 0)
{
// phpcs:enable
global $conf, $langs;
2017-05-06 06:06:01 +00:00
$out = '';
$options = array();
2021-02-23 21:03:23 +00:00
if ($usecache && !empty($this->options_cache[$usecache])) {
$options = $this->options_cache[$usecache];
$selected = $selectid;
2020-05-21 13:05:19 +00:00
} else {
2017-05-06 06:06:01 +00:00
$sql = "SELECT rowid, code, label, nature, entity, active";
2022-01-27 09:19:35 +00:00
$sql .= " FROM ".$this->db->prefix()."accounting_journal";
$sql .= " WHERE active = 1";
$sql .= " AND entity = ".((int) $conf->entity);
2021-02-23 21:03:23 +00:00
if ($nature && is_numeric($nature)) {
2021-05-03 10:32:31 +00:00
$sql .= " AND nature = ".((int) $nature);
2021-02-23 21:03:23 +00:00
}
$sql .= " ORDER BY code";
2017-05-06 06:06:01 +00:00
dol_syslog(get_class($this)."::select_journal", LOG_DEBUG);
2017-05-06 06:06:01 +00:00
$resql = $this->db->query($sql);
if (!$resql) {
$this->error = "Error ".$this->db->lasterror();
dol_syslog(get_class($this)."::select_journal ".$this->error, LOG_ERR);
return -1;
}
$selected = 0;
$langs->load('accountancy');
2021-02-23 21:03:23 +00:00
while ($obj = $this->db->fetch_object($resql)) {
$label = $obj->code.' - '.$langs->trans($obj->label);
2017-05-08 04:20:17 +00:00
$select_value_in = $obj->rowid;
2017-05-06 06:06:01 +00:00
$select_value_out = $obj->rowid;
2017-05-08 04:20:17 +00:00
// Try to guess if we have found default value
if ($select_in == 1) {
$select_value_in = $obj->code;
}
if ($select_out == 1) {
$select_value_out = $obj->code;
}
// Remember guy's we store in database llx_accounting_bookkeeping the code of accounting_journal and not the rowid
if ($selectid != '' && $selectid == $select_value_in) {
//var_dump("Found ".$selectid." ".$select_value_in);
$selected = $select_value_out;
}
2017-05-08 04:20:17 +00:00
2017-05-06 06:06:01 +00:00
$options[$select_value_out] = $label;
}
$this->db->free($resql);
2021-02-23 21:03:23 +00:00
if ($usecache) {
2017-05-06 06:06:01 +00:00
$this->options_cache[$usecache] = $options;
}
}
$out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, ($disabledajaxcombo ? 0 : 1));
return $out;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of journals with label by nature
*
* @param string[] $selectedIds Preselected journal code array
* @param string $htmlname Name of field in html form
* @param int<0,9> $nature Limit the list to a particular type of journals (1:various operations / 2:sale / 3:purchase / 4:bank / 9: has-new)
* @param int $showempty Add an empty field
* @param int $select_in 0=selectid value is the journal rowid (default) or 1=selectid is journal code
* @param int $select_out Set value returned by select. 0=rowid (default), 1=code
* @param string $morecss More css non HTML object
* @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache.
* @param int<0,1> $disabledajaxcombo Disable ajax combo box.
* @return string|int<-1,-1> String with HTML select, or -1 if error
*/
2020-11-07 14:36:28 +00:00
public function multi_select_journal($selectedIds = array(), $htmlname = 'journal', $nature = 0, $showempty = 0, $select_in = 0, $select_out = 0, $morecss = '', $usecache = '', $disabledajaxcombo = 0)
{
// phpcs:enable
global $conf, $langs;
$out = '';
$options = array();
2021-02-23 21:03:23 +00:00
if ($usecache && !empty($this->options_cache[$usecache])) {
$options = $this->options_cache[$usecache];
$selected = $selectedIds;
} else {
$sql = "SELECT rowid, code, label, nature, entity, active";
2022-01-27 09:19:35 +00:00
$sql .= " FROM ".$this->db->prefix()."accounting_journal";
$sql .= " WHERE active = 1";
$sql .= " AND entity = ".((int) $conf->entity);
2021-02-23 21:03:23 +00:00
if ($nature && is_numeric($nature)) {
2021-05-03 10:32:31 +00:00
$sql .= " AND nature = ".((int) $nature);
2021-02-23 21:03:23 +00:00
}
$sql .= " ORDER BY code";
dol_syslog(get_class($this)."::multi_select_journal", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$this->error = "Error ".$this->db->lasterror();
dol_syslog(get_class($this)."::multi_select_journal ".$this->error, LOG_ERR);
return -1;
}
$selected = array();
$langs->load('accountancy');
2021-02-23 21:03:23 +00:00
while ($obj = $this->db->fetch_object($resql)) {
// Build the full text directly here
$translatedLabel = $langs->trans($obj->label);
if (empty($translatedLabel) || $translatedLabel === $obj->label) {
$translatedLabel = $obj->label; // fallback to the raw label
}
$label = $obj->code . ' - ' . $translatedLabel;
$select_value_in = ($select_in == 1 ? $obj->code : $obj->rowid);
$select_value_out = ($select_out == 1 ? $obj->code : $obj->rowid);
// Remember guy's we store in database llx_accounting_bookkeeping the code of accounting_journal and not the rowid
if (!empty($selectedIds) && in_array($select_value_in, $selectedIds)) {
$selected[] = $select_value_out;
}
$options[$select_value_out] = $label;
}
$this->db->free($resql);
2021-02-23 21:03:23 +00:00
if ($usecache) {
$this->options_cache[$usecache] = $options;
}
}
$out .= Form::multiselectarray($htmlname, $options, $selected, 0, 0, $morecss, 0, 0, '', 'code_journal', '', ($disabledajaxcombo ? 0 : 1));
return $out;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of accounting category.
* Use mysoc->country_id or mysoc->country_code so they must be defined.
*
* @param int $selected Preselected type
* @param string $htmlname Name of field in form
* @param int<0,1> $useempty Set to 1 if we want an empty value
* @param int $maxlen Max length of text in combo box
* @param int<0,1> $help Add or not the admin help picto
* @param int<0,1> $allcountries All countries
* @return void|string HTML component with the select
*/
2024-01-15 02:15:27 +00:00
public function select_accounting_category($selected = 0, $htmlname = 'account_category', $useempty = 0, $maxlen = 0, $help = 1, $allcountries = 0)
{
// phpcs:enable
2023-09-24 23:00:25 +00:00
global $langs, $mysoc;
2021-02-23 21:03:23 +00:00
if (empty($mysoc->country_id) && empty($mysoc->country_code) && empty($allcountries)) {
2024-01-20 08:22:38 +00:00
dol_print_error(null, 'Call to select_accounting_account with mysoc country not yet defined');
exit;
}
$out = '';
2021-02-23 21:03:23 +00:00
if (!empty($mysoc->country_id)) {
$sql = "SELECT c.rowid, c.label as type, c.range_account";
2022-01-27 09:19:35 +00:00
$sql .= " FROM ".$this->db->prefix()."c_accounting_category as c";
$sql .= " WHERE c.active = 1";
$sql .= " AND c.category_type = 0";
2021-02-23 21:03:23 +00:00
if (empty($allcountries)) {
2021-06-09 13:36:47 +00:00
$sql .= " AND c.fk_country = ".((int) $mysoc->country_id);
2021-02-23 21:03:23 +00:00
}
$sql .= " ORDER BY c.label ASC";
} else {
$sql = "SELECT c.rowid, c.label as type, c.range_account";
2022-01-27 09:19:35 +00:00
$sql .= " FROM ".$this->db->prefix()."c_accounting_category as c, ".$this->db->prefix()."c_country as co";
$sql .= " WHERE c.active = 1";
$sql .= " AND c.category_type = 0";
$sql .= " AND c.fk_country = co.rowid";
2021-02-23 21:03:23 +00:00
if (empty($allcountries)) {
$sql .= " AND co.code = '".$this->db->escape($mysoc->country_code)."'";
}
$sql .= " ORDER BY c.label ASC";
}
2023-09-24 23:00:25 +00:00
$this->nbaccounts_category = 0;
dol_syslog(get_class($this).'::'.__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql);
2021-02-23 21:03:23 +00:00
if ($resql) {
$num = $this->db->num_rows($resql);
2021-02-23 21:03:23 +00:00
if ($num) {
2023-09-24 23:00:25 +00:00
$this->nbaccounts_category = $num;
$out .= '<select class="flat minwidth200" id="'.$htmlname.'" name="'.$htmlname.'">';
$i = 0;
2021-02-23 21:03:23 +00:00
if ($useempty) {
$out .= '<option value="0">&nbsp;</option>';
}
while ($i < $num) {
$obj = $this->db->fetch_object($resql);
2022-12-22 02:06:53 +00:00
$titletoshowhtml = ($maxlen ? dol_trunc($obj->type, $maxlen) : $obj->type).($obj->range_account ? ' <span class="opacitymedium">('.$obj->range_account.')</span>' : '');
$titletoshow = ($maxlen ? dol_trunc($obj->type, $maxlen) : $obj->type).($obj->range_account ? ' ('.$obj->range_account.')' : '');
$out .= '<option value="'.$obj->rowid.'"';
2021-02-23 21:03:23 +00:00
if ($obj->rowid == $selected) {
$out .= ' selected';
}
2023-12-16 15:26:38 +00:00
//$out .= ' data-html="'.dol_escape_htmltag(dol_string_onlythesehtmltags($titletoshowhtml, 1, 0, 0, 0, array('span'))).'"';
$out .= ' data-html="'.dolPrintHTMLForAttribute($titletoshowhtml).'"';
2021-04-05 13:21:17 +00:00
$out .= '>';
$out .= dol_escape_htmltag($titletoshow);
$out .= '</option>';
$i++;
}
$out .= '</select>';
//if ($user->admin && $help) $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
$out .= ajax_combobox($htmlname, array());
} else {
$out .= '<span class="opacitymedium">'.$langs->trans("ErrorNoAccountingCategoryForThisCountry", $mysoc->country_code, $langs->transnoentitiesnoconv("Accounting"), $langs->transnoentitiesnoconv("Setup"), $langs->transnoentitiesnoconv("AccountingCategories")).'</span>';
}
} else {
dol_print_error($this->db);
}
return $out;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return select filter with date of transaction
*
* @param string $htmlname Name of select field
* @param string $selectedkey Value
* @return string|int<-1,-1> HTML edit field, or -1 if error
*/
public function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey = '')
{
// phpcs:enable
$options = array();
$sql = "SELECT DISTINCT import_key FROM ".$this->db->prefix()."accounting_bookkeeping";
$sql .= " WHERE entity IN (".getEntity('accountancy').")";
$sql .= ' ORDER BY import_key DESC';
dol_syslog(get_class($this)."::select_bookkeeping_importkey", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$this->error = "Error ".$this->db->lasterror();
dol_syslog(get_class($this)."::select_bookkeeping_importkey ".$this->error, LOG_ERR);
return -1;
}
while ($obj = $this->db->fetch_object($resql)) {
$options[$obj->import_key] = $obj->import_key;
}
return Form::selectarray($htmlname, $options, $selectedkey);
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of accounts with label by chart of accounts
*
2026-01-19 13:28:33 +00:00
* @param int|string $selectid Preselected id of accounting accounts (depends on $select_in)
* @param string $htmlname Name of HTML field id. If name start with '.', it is name of HTML css class, so several component with same name in different forms can be used.
* @param int|string $showempty 1=Add an empty field, 2=Add an empty field+'None' field
* @param array<array<string,mixed>> $event Event options
2026-01-19 13:28:33 +00:00
* @param int|string $select_in 0=selectid value is a aa.rowid (default) or 1=selectid is aa.account_number
* @param int|string $select_out Set value returned by select. 0=rowid (default), 1=account_number
* @param string $morecss More css non HTML object
* @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache.
* @param '1'|'0'|'' $active Filter on status active or not: '0', '1' or '' for no filter
* @param int $centralized 0=No filter on centralized account, 1=filter only on centralized accounts, 2=show all accounts with centralized account in top of the list like favorite
* @return string|int<-1,-1> String with HTML select, or -1 if error
*/
public function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $morecss = 'minwidth100 maxwidth300 maxwidthonsmartphone', $usecache = '', $active = '1', $centralized = 0)
{
global $conf, $langs;
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
$out = '';
$selected = '';
$options = [];
2026-01-19 13:28:33 +00:00
$selectid = (string) $selectid;
2021-02-23 21:03:23 +00:00
if ($showempty == 2) {
$options['0'] = '--- '.$langs->trans("None").' ---';
}
2021-02-23 21:03:23 +00:00
if ($usecache && !empty($this->options_cache[$usecache])) {
$options += $this->options_cache[$usecache];
2026-01-19 13:28:33 +00:00
$selected = (string) $selectid;
2020-05-21 13:05:19 +00:00
} else {
$trunclength = getDolGlobalInt('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', 50);
// Construct SQL request
$sql = "SELECT DISTINCT aa.account_number, aa.label, aa.labelshort, aa.rowid, aa.fk_pcg_version, aa.centralized";
2022-01-27 09:19:35 +00:00
$sql .= " FROM ".$this->db->prefix()."accounting_account as aa";
$sql .= " INNER JOIN ".$this->db->prefix()."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
2023-07-10 20:20:26 +00:00
$sql .= " AND asy.rowid = ".((int) getDolGlobalInt('CHARTOFACCOUNTS'));
if ($active === '1') {
$sql .= " AND aa.active = 1";
} elseif ($active === '0') {
$sql .= " AND aa.active = 0";
}
if ($centralized == 1) {
$sql .= " AND aa.centralized = 1";
}
$sql .= " AND aa.entity=".((int) $conf->entity);
// Sorting: centralized accounts first, then others
if ($centralized == 2) {
$sql .= " ORDER BY aa.centralized DESC, aa.account_number";
} else {
$sql .= " ORDER BY aa.account_number";
}
dol_syslog(get_class($this)."::select_account", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$this->error = "Error ".$this->db->lasterror();
dol_syslog(get_class($this)."::select_account ".$this->error, LOG_ERR);
return -1;
}
$num_rows = $this->db->num_rows($resql);
2023-08-27 15:11:28 +00:00
if ($num_rows == 0 && getDolGlobalInt('CHARTOFACCOUNTS') <= 0) {
$langs->load("errors");
$showempty = $langs->trans("ErrorYouMustFirstSetupYourChartOfAccount");
2026-02-23 18:49:45 +00:00
} elseif ($num_rows == 0) {
$langs->load("errors");
$showempty = $langs->trans("ErrorYouMustFirstSetupYourChartOfAccount");
} else {
$selected = $selectid;
$lastCentralized = null;
while ($obj = $this->db->fetch_object($resql)) {
// Insert a separator if you change category (centralized = 1 → 0)
if ($centralized == 2 && $lastCentralized !== null && $lastCentralized != $obj->centralized) {
$options['0'] = '-------------'; // Visual separator
}
$lastCentralized = $obj->centralized;
$labeltoshow = !empty($obj->labelshort) ? $obj->labelshort : $obj->label;
$label = length_accountg($obj->account_number).' - '.$labeltoshow;
$label = dol_trunc($label, $trunclength);
$select_value_in = $obj->rowid;
$select_value_out = $obj->rowid;
if ($select_in == 1) {
$select_value_in = $obj->account_number;
}
if ($select_out == 1) {
$select_value_out = $obj->account_number;
}
2026-01-19 13:28:33 +00:00
if ($selectid != '' && $selectid == (string) $select_value_in) {
$selected = (string) $select_value_out;
}
$options[$select_value_out] = array(
'label' => $label,
'data-centralized' => $obj->centralized ? 1 : 0
);
}
}
$this->db->free($resql);
2021-02-23 21:03:23 +00:00
if ($usecache) {
$this->options_cache[$usecache] = $options;
unset($this->options_cache[$usecache]['0']);
}
}
2023-12-04 11:04:36 +00:00
$out .= Form::selectarray($htmlname, $options, $selected, ($showempty ? (is_numeric($showempty) ? 1 : $showempty) : 0), 0, 0, '', 0, 0, 0, '', $morecss, 1);
2023-07-10 20:14:07 +00:00
$this->nbaccounts = count($options) - ($showempty == 2 ? 1 : 0);
return $out;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of auxiliary accounts. Cumulate list from customers, suppliers and users.
* Behavior depends on constant ACCOUNTANCY_AUXACCOUNT_USE_SEARCH_TO_SELECT:
* 0 = free text input, no autocomplete, no list
* 1 = native HTML select with full list loaded, with select2 (original behavior)
* 2 = ajax search triggered after 1 character typed
* 3 = ajax search triggered after 2 characters typed
* 4 = ajax search triggered after 3 characters typed (recommended for large datasets)
*
* @param string $selectid Preselected account number
* @param string $htmlname Name of field in html form
* @param int|string $showempty Add an empty field
* @param string $morecss More css
* @param string $usecache Key to use for cache (mode 1 only)
* @param string $labelhtmlname HTML name of label input for autofill of subledger label
* @param string $selected_input_value Displayed text of preselected entry (ajax modes 2/3/4 only)
* @return string|int<-1,-1> HTML string or -1 on error
*/
public function select_auxaccount($selectid, $htmlname = 'account_num_aux', $showempty = 0, $morecss = 'minwidth100 maxwidth300 maxwidthonsmartphone', $usecache = '', $labelhtmlname = '', $selected_input_value = '')
{
// phpcs:enable
global $conf, $langs;
$out = '';
$auxaccount_mode = getDolGlobalInt('ACCOUNTANCY_AUXACCOUNT_USE_SEARCH_TO_SELECT', 0);
$placeholder = (!empty($showempty) && !is_numeric($showempty)) ? $showempty : $langs->trans("SubledgerAccount");
// MODE 0: free text input - no list, no autocomplete
if ($auxaccount_mode == 0) {
$out .= '<input type="text" class="'.$morecss.'" name="'.$htmlname.'" id="'.$htmlname.'" value="'.dol_escape_htmltag($selectid).'" placeholder="'.dol_escape_htmltag($placeholder).'" />';
return $out;
}
// MODES 2/3/4: ajax - on-demand loading via endpoint
// minLength: mode 2 -> 1 char, mode 3 -> 2 chars, etc
if (!empty($conf->use_javascript_ajax) && $auxaccount_mode >= 2) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
$minLength = $auxaccount_mode - 1;
$urloption = 'htmlname='.urlencode($htmlname).'&outjson=1';
// Resolve displayed text from selectid if no label was provided (e.g. on page reload)
if ($selectid && empty($selected_input_value)) {
// Search in thirdparties first
$sql = "SELECT nom AS name FROM ".$this->db->prefix()."societe";
$sql .= " WHERE entity IN (".getEntity('societe').")";
$sql .= " AND (code_compta = '".$this->db->escape($selectid)."'";
$sql .= " OR code_compta_fournisseur = '".$this->db->escape($selectid)."')";
$sql .= $this->db->plimit(1, 0);
$resql = $this->db->query($sql);
if ($resql && ($obj = $this->db->fetch_object($resql))) {
$selected_input_value = $selectid.' ('.$obj->name.')';
$this->db->free($resql);
} else {
// Fallback: search in users
$sql2 = "SELECT lastname, firstname FROM ".$this->db->prefix()."user";
$sql2 .= " WHERE entity IN (".getEntity('user').")";
$sql2 .= " AND accountancy_code = '".$this->db->escape($selectid)."'";
$sql2 .= $this->db->plimit(1, 0);
$resql2 = $this->db->query($sql2);
if ($resql2 && ($obj2 = $this->db->fetch_object($resql2))) {
$selected_input_value = $selectid.' ('.dolGetFirstLastname($obj2->firstname, $obj2->lastname).')';
$this->db->free($resql2);
} else {
$selected_input_value = $selectid;
}
}
}
// Visible text input — targeted by ajax_autocompleter() JavaScript via "input#search_$htmlname"
$out .= '<input type="text" class="'.$morecss.'" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.dol_escape_htmltag($selected_input_value).'" placeholder="'.dol_escape_htmltag($placeholder).'" />';
// Autofill subledger label — listen on "change" of the hidden field
// auxaccount.php returns 'label_name' = just the name without the account code
$ajaxoptions = array();
if (!empty($labelhtmlname)) {
$ajaxoptions['update'] = array($labelhtmlname => 'label_name');
}
// Hidden input + jQuery UI autocomplete JS
$out .= ajax_autocompleter($selectid, $htmlname, DOL_URL_ROOT.'/core/ajax/auxaccount.php', $urloption, $minLength, 0, $ajaxoptions);
return $out;
}
// MODE 1 (or ajax disabled): native HTML select with full list + select2 - original behavior
$aux_account = array();
2021-05-03 10:32:31 +00:00
if ($usecache && !empty($this->options_cache[$usecache])) {
Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests (#30544) * Remove PhanPluginDuplicateExpressionAssignmentOperation from baseline * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * fixup! Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2024-08-07 00:53:45 +00:00
$aux_account += $this->options_cache[$usecache]; // We use + instead of array_merge because we don't want to reindex key from 0
2021-05-03 10:32:31 +00:00
} else {
dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG);
2021-05-03 10:32:31 +00:00
// Auxiliary thirdparties account
$sql = "SELECT code_compta as code_compta_client, code_compta_fournisseur, nom as name";
2022-01-27 09:19:35 +00:00
$sql .= " FROM ".$this->db->prefix()."societe";
2021-05-03 10:32:31 +00:00
$sql .= " WHERE entity IN (".getEntity('societe').")";
2021-12-09 09:31:02 +00:00
$sql .= " AND (client IN (1,3) OR fournisseur = 1)";
2021-05-03 10:32:31 +00:00
$resql = $this->db->query($sql);
if ($resql) {
while ($obj = $this->db->fetch_object($resql)) {
if (!empty($obj->code_compta_client)) {
$aux_account[$obj->code_compta_client] = $obj->code_compta_client.' <span class="opacitymedium">('.$obj->name.')</span>';
2021-05-03 10:32:31 +00:00
}
if (!empty($obj->code_compta_fournisseur)) {
$aux_account[$obj->code_compta_fournisseur] = $obj->code_compta_fournisseur.' <span class="opacitymedium">('.$obj->name.')</span>';
}
}
2021-05-03 10:32:31 +00:00
} else {
$this->error = "Error ".$this->db->lasterror();
dol_syslog(get_class($this)."::select_auxaccount ".$this->error, LOG_ERR);
return -1;
}
2021-05-03 10:32:31 +00:00
$this->db->free($resql);
2021-05-03 10:32:31 +00:00
// Auxiliary user account
$sql = "SELECT DISTINCT accountancy_code, lastname, firstname";
2022-01-27 09:19:35 +00:00
$sql .= " FROM ".$this->db->prefix()."user";
2021-05-03 10:32:31 +00:00
$sql .= " WHERE entity IN (".getEntity('user').")";
$sql .= " ORDER BY accountancy_code";
$resql = $this->db->query($sql);
if ($resql) {
while ($obj = $this->db->fetch_object($resql)) {
if (!empty($obj->accountancy_code)) {
$aux_account[$obj->accountancy_code] = $obj->accountancy_code.' <span class="opacitymedium">('.dolGetFirstLastname($obj->firstname, $obj->lastname).')</span>';
}
}
2021-05-03 10:32:31 +00:00
} else {
$this->error = "Error ".$this->db->lasterror();
dol_syslog(get_class($this)."::select_auxaccount ".$this->error, LOG_ERR);
return -1;
}
$this->db->free($resql);
ksort($aux_account);
2021-05-03 10:32:31 +00:00
if ($usecache) {
$this->options_cache[$usecache] = $aux_account;
}
}
// Build native select — select2 is automatically activated by Form::selectarray() with $useajax=1
$out .= Form::selectarray($htmlname, $aux_account, $selectid, $placeholder, 0, 0, '', 0, 0, 0, '', $morecss, 1);
// Autofill subledger label on select2 selection event (mode 1 only)
2022-02-28 20:55:30 +00:00
if (!empty($conf->use_javascript_ajax) && !empty($labelhtmlname)) {
2023-02-18 14:10:05 +00:00
$out .= '<script nonce="'.getNonce().'">
jQuery(document).ready(() => {
$("#'.dol_escape_js($htmlname).'").on("select2:select", function(e) {
var match = /\(([^)]+)\)/.exec(e.params.data.text);
if (match) { $("input[name=\"'.dol_escape_js($labelhtmlname).'\"]").val(match[1]); }
});
});
</script>';
}
2022-02-25 15:10:10 +00:00
return $out;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return HTML combo list of years existing into book keepping
*
2020-05-27 21:20:26 +00:00
* @param string $selected Preselected value
* @param string $htmlname Name of HTML select object
* @param int $useempty Display empty value in list
* @param string $output_format (html/option (for option html only)/array (to return options arrays
* @return string|array<string,string>|int<-1,-1> HTML select component || array of select options || - 1 if error
*/
2019-02-27 22:55:18 +00:00
public function selectyear_accountancy_bookkepping($selected = '', $htmlname = 'yearid', $useempty = 0, $output_format = 'html')
{
// phpcs:enable
global $conf;
$out_array = array();
$sql = "SELECT DISTINCT date_format(doc_date, '%Y') as dtyear";
2022-01-27 09:19:35 +00:00
$sql .= " FROM ".$this->db->prefix()."accounting_bookkeeping";
$sql .= " WHERE entity IN (".getEntity('accountancy').")";
$sql .= " ORDER BY date_format(doc_date, '%Y')";
dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$this->error = "Error ".$this->db->lasterror();
dol_syslog(__METHOD__.$this->error, LOG_ERR);
return -1;
}
while ($obj = $this->db->fetch_object($resql)) {
$out_array[$obj->dtyear] = $obj->dtyear;
}
$this->db->free($resql);
if ($output_format == 'html') {
return Form::selectarray($htmlname, $out_array, $selected, $useempty, 0, 0, 'placeholder="aa"');
} else {
return $out_array;
}
}
Fix #28071 - New branch to fix bad merge (#28083) * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Qual: Introduce getDataToShowPhoto to prepare generic code * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Fix missing trans * Fix langs * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Remove useless files in web templates * Clean code * Fix duplicate translation key * Fix duplicate translation key * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Fix duplicate key * Fix $object * Debug v19 * WIP SMSing * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * WIP EMAILINGS_SUPPORT_ALSO_SMS * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * WIP SMSing * Debug the "validate" feature * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Clean code * Move rights->x->y into hasRight('x', 'y') * Move rights->x->y into hasRight('x', 'y') * Move rights->x->y into hasRight('x', 'y') * Move rights->x->y into hasRight('x', 'y') * Move rights->x->y into hasRight('x', 'y') * Move rights->x->y into hasRight('x', 'y') * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Enhance rector to fix empty($user->rights->modulex->perm1) * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Fix template to use v19 dev rules * Fix use v19 dev rules * Fix phpunit * Debug v19 * Clean code * Use rector to convert user->rights into user->hasRight * Clean code * Use rector to convert user->rights into user->hasRight * Use rector to convert user->rights into user->hasRight * Clean code * Fix phpcs * add editorconfig for sql files (#27999) Co-authored-by: Laurent Destailleur <eldy@destailleur.fr> * add model_pdf field in llx_ticket-ticket.sql (#27996) * add model_pdf field in llx_ticket-ticket.sql * Update 19.0.0-20.0.0.sql * Update 19.0.0-20.0.0.sql * Improve wording in README (#27994) * fix phpstan (#27989) * fix phpstan * Update UserRightsToFunction.php --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr> * Qual: Fix spelling/working in datapolicy translations (#28006) # Qual: Fix spelling/wording in datapolicy translations Fixed some spelling and wording in datapolicy translations. * qual: phpstan for htdocs/ticket/class/ticketstats.class.php (#27986) htdocs/ticket/class/ticketstats.class.php 98 Parameter #1 $year (string) of method TicketStats::getNbByMonth() should be compatible with parameter $year (int) of method Stats::getNbByMonth() * Merge branch '19.0' of git@github.com:Dolibarr/dolibarr.git into develop * Fix user with readonly perm on email template must be able to read. * Fix doc * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Better message * Add missing fields in merge of thirdparty * Debug v19 selection of ticket printer per terminal * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Use constant * NEW: Adding a recipient on emails sent, change status to sent partialy. * fix travis (#28052) * fix travis * Update partnership.class.php * fix php doc (#28047) * fix undefined array key (#28048) * Add region and departament for Cuba (#28046) * Update llx_10_c_regions.sql Add Cuba Regions (id_country=77) * Update llx_20_c_departements.sql Add Provinces Cuba (id country=77) * Find the typo (#28050) * Find the typo * clean code * add last_main_doc field to product (#28045) * add las_main_doc field to product * add field fetch * NEW Add Categorie filter for ActionComm (#28041) * New Add Categorie filter for ActionComm New Add Categorie filter for ActionComm * Fix space errors Fix space errors * Fix space errors 2 Fix space errors 2 * Update cunits.class.php (#28056) FIX: error SQL when creating a Cunit * Update codespell-lines-ignore.txt to avoid PR merge conflict --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr> Co-authored-by: Frédéric FRANCE <frederic34@users.noreply.github.com> Co-authored-by: thibdrev <thibault.drevet@gmail.com> Co-authored-by: sonikf <93765174+sonikf@users.noreply.github.com> Co-authored-by: Ikarus <44511582+LeKarSol@users.noreply.github.com> Co-authored-by: Anthony Damhet <73399671+EchoLoGeek@users.noreply.github.com> Co-authored-by: Quentin-Seekness <72733832+Quentin-Seekness@users.noreply.github.com>
2024-02-09 14:58:49 +00:00
/**
* Output html select to select accounting account
*
* @param string $page Page
* @param string $selected Id preselected
* @param string $htmlname Name of HTML select object
* @param int $option option (0: aggregate by general account or 1: aggregate by subaccount)
* @param int $useempty Show empty value in list
* @param string $filter Optional filter criteria
Fix #28071 - New branch to fix bad merge (#28083) * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Qual: Introduce getDataToShowPhoto to prepare generic code * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Fix missing trans * Fix langs * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Remove useless files in web templates * Clean code * Fix duplicate translation key * Fix duplicate translation key * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Fix duplicate key * Fix $object * Debug v19 * WIP SMSing * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * WIP EMAILINGS_SUPPORT_ALSO_SMS * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * WIP SMSing * Debug the "validate" feature * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Clean code * Move rights->x->y into hasRight('x', 'y') * Move rights->x->y into hasRight('x', 'y') * Move rights->x->y into hasRight('x', 'y') * Move rights->x->y into hasRight('x', 'y') * Move rights->x->y into hasRight('x', 'y') * Move rights->x->y into hasRight('x', 'y') * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Enhance rector to fix empty($user->rights->modulex->perm1) * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Fix template to use v19 dev rules * Fix use v19 dev rules * Fix phpunit * Debug v19 * Clean code * Use rector to convert user->rights into user->hasRight * Clean code * Use rector to convert user->rights into user->hasRight * Use rector to convert user->rights into user->hasRight * Clean code * Fix phpcs * add editorconfig for sql files (#27999) Co-authored-by: Laurent Destailleur <eldy@destailleur.fr> * add model_pdf field in llx_ticket-ticket.sql (#27996) * add model_pdf field in llx_ticket-ticket.sql * Update 19.0.0-20.0.0.sql * Update 19.0.0-20.0.0.sql * Improve wording in README (#27994) * fix phpstan (#27989) * fix phpstan * Update UserRightsToFunction.php --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr> * Qual: Fix spelling/working in datapolicy translations (#28006) # Qual: Fix spelling/wording in datapolicy translations Fixed some spelling and wording in datapolicy translations. * qual: phpstan for htdocs/ticket/class/ticketstats.class.php (#27986) htdocs/ticket/class/ticketstats.class.php 98 Parameter #1 $year (string) of method TicketStats::getNbByMonth() should be compatible with parameter $year (int) of method Stats::getNbByMonth() * Merge branch '19.0' of git@github.com:Dolibarr/dolibarr.git into develop * Fix user with readonly perm on email template must be able to read. * Fix doc * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Better message * Add missing fields in merge of thirdparty * Debug v19 selection of ticket printer per terminal * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Use constant * NEW: Adding a recipient on emails sent, change status to sent partialy. * fix travis (#28052) * fix travis * Update partnership.class.php * fix php doc (#28047) * fix undefined array key (#28048) * Add region and departament for Cuba (#28046) * Update llx_10_c_regions.sql Add Cuba Regions (id_country=77) * Update llx_20_c_departements.sql Add Provinces Cuba (id country=77) * Find the typo (#28050) * Find the typo * clean code * add last_main_doc field to product (#28045) * add las_main_doc field to product * add field fetch * NEW Add Categorie filter for ActionComm (#28041) * New Add Categorie filter for ActionComm New Add Categorie filter for ActionComm * Fix space errors Fix space errors * Fix space errors 2 Fix space errors 2 * Update cunits.class.php (#28056) FIX: error SQL when creating a Cunit * Update codespell-lines-ignore.txt to avoid PR merge conflict --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr> Co-authored-by: Frédéric FRANCE <frederic34@users.noreply.github.com> Co-authored-by: thibdrev <thibault.drevet@gmail.com> Co-authored-by: sonikf <93765174+sonikf@users.noreply.github.com> Co-authored-by: Ikarus <44511582+LeKarSol@users.noreply.github.com> Co-authored-by: Anthony Damhet <73399671+EchoLoGeek@users.noreply.github.com> Co-authored-by: Quentin-Seekness <72733832+Quentin-Seekness@users.noreply.github.com>
2024-02-09 14:58:49 +00:00
* @param int $nooutput No print output. Return it only.
* @return void|string
*/
public function formAccountingAccount($page, $selected = '', $htmlname = 'none', $option = 0, $useempty = 1, $filter = '', $nooutput = 0)
{
global $langs;
$out = '';
if ($htmlname != "none") {
$out .= '<form method="post" action="' . $page . '">';
$out .= '<input type="hidden" name="action" value="set'.$htmlname.'">';
$out .= '<input type="hidden" name="token" value="' . newToken() . '">';
if ($option == 0) {
$out .= $this->select_account($selected, $htmlname, $useempty, array(), 1, 1, 'minwidth100 maxwidth300 maxwidthonsmartphone', 'accounts', $filter);
Fix #28071 - New branch to fix bad merge (#28083) * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Qual: Introduce getDataToShowPhoto to prepare generic code * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Fix missing trans * Fix langs * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Remove useless files in web templates * Clean code * Fix duplicate translation key * Fix duplicate translation key * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Fix duplicate key * Fix $object * Debug v19 * WIP SMSing * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * WIP EMAILINGS_SUPPORT_ALSO_SMS * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * WIP SMSing * Debug the "validate" feature * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Clean code * Move rights->x->y into hasRight('x', 'y') * Move rights->x->y into hasRight('x', 'y') * Move rights->x->y into hasRight('x', 'y') * Move rights->x->y into hasRight('x', 'y') * Move rights->x->y into hasRight('x', 'y') * Move rights->x->y into hasRight('x', 'y') * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Enhance rector to fix empty($user->rights->modulex->perm1) * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Fix template to use v19 dev rules * Fix use v19 dev rules * Fix phpunit * Debug v19 * Clean code * Use rector to convert user->rights into user->hasRight * Clean code * Use rector to convert user->rights into user->hasRight * Use rector to convert user->rights into user->hasRight * Clean code * Fix phpcs * add editorconfig for sql files (#27999) Co-authored-by: Laurent Destailleur <eldy@destailleur.fr> * add model_pdf field in llx_ticket-ticket.sql (#27996) * add model_pdf field in llx_ticket-ticket.sql * Update 19.0.0-20.0.0.sql * Update 19.0.0-20.0.0.sql * Improve wording in README (#27994) * fix phpstan (#27989) * fix phpstan * Update UserRightsToFunction.php --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr> * Qual: Fix spelling/working in datapolicy translations (#28006) # Qual: Fix spelling/wording in datapolicy translations Fixed some spelling and wording in datapolicy translations. * qual: phpstan for htdocs/ticket/class/ticketstats.class.php (#27986) htdocs/ticket/class/ticketstats.class.php 98 Parameter #1 $year (string) of method TicketStats::getNbByMonth() should be compatible with parameter $year (int) of method Stats::getNbByMonth() * Merge branch '19.0' of git@github.com:Dolibarr/dolibarr.git into develop * Fix user with readonly perm on email template must be able to read. * Fix doc * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Better message * Add missing fields in merge of thirdparty * Debug v19 selection of ticket printer per terminal * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Use constant * NEW: Adding a recipient on emails sent, change status to sent partialy. * fix travis (#28052) * fix travis * Update partnership.class.php * fix php doc (#28047) * fix undefined array key (#28048) * Add region and departament for Cuba (#28046) * Update llx_10_c_regions.sql Add Cuba Regions (id_country=77) * Update llx_20_c_departements.sql Add Provinces Cuba (id country=77) * Find the typo (#28050) * Find the typo * clean code * add last_main_doc field to product (#28045) * add las_main_doc field to product * add field fetch * NEW Add Categorie filter for ActionComm (#28041) * New Add Categorie filter for ActionComm New Add Categorie filter for ActionComm * Fix space errors Fix space errors * Fix space errors 2 Fix space errors 2 * Update cunits.class.php (#28056) FIX: error SQL when creating a Cunit * Update codespell-lines-ignore.txt to avoid PR merge conflict --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr> Co-authored-by: Frédéric FRANCE <frederic34@users.noreply.github.com> Co-authored-by: thibdrev <thibault.drevet@gmail.com> Co-authored-by: sonikf <93765174+sonikf@users.noreply.github.com> Co-authored-by: Ikarus <44511582+LeKarSol@users.noreply.github.com> Co-authored-by: Anthony Damhet <73399671+EchoLoGeek@users.noreply.github.com> Co-authored-by: Quentin-Seekness <72733832+Quentin-Seekness@users.noreply.github.com>
2024-02-09 14:58:49 +00:00
} else {
$out .= $this->select_auxaccount($selected, $htmlname, $useempty, 'minwidth100 maxwidth300 maxwidthonsmartphone', 'subaccounts');
}
$out .= '<input type="submit" class="button smallpaddingimp valignmiddle" name="modify" value="' . $langs->trans("Modify") . '">';
//$out .= '<input type="submit" class="button smallpaddingimp valignmiddle button-cancel" name="cancel" value="' . $langs->trans("Cancel") . '">';
$out .= '</form>';
} else {
$out .= "&nbsp;";
}
if ($nooutput) {
return $out;
} else {
print $out;
}
}
/**
* Print line into the journal table
*
* @param Translate $langs Language translation object
* @param string $date Date of line
* @param string $ref Reference of line
* @param string $accountAccounting Accounting account
* @param string $labelOperation Operation label
* @param string $paymentMode Payment mode
* @param double $amount Amount
* @return void
*/
public static function printJournalLine($langs, $date, $ref, $accountAccounting, $labelOperation, $paymentMode, $amount)
{
$out = '<tr class="oddeven">';
$out .= '<td>'.$date.'</td>';
$out .= '<td>'.$ref.'</td>';
// Ledger account
$out .= '<td>';
$accounttoshow = length_accountg($accountAccounting);
if (empty($accounttoshow) || $accounttoshow == 'NotDefined') {
2025-04-13 19:32:28 +00:00
// Could be ProductAccountNotDefined, VATAccountNotDefined, ...
$out .= '<span class="error">'.$langs->trans('AccountNotDefined').'</span>';
} else {
$out .= $accounttoshow;
}
$out .= '</td>';
$out .= '<td>'.$labelOperation.'</td>';
2025-04-13 19:32:28 +00:00
$out .= '<td class="center">'.$paymentMode.'</td>';
$out .= '<td class="nowraponall right amount">'.($amount >= 0 ? price($amount) : '').'</td>';
$out .= '<td class="nowraponall right amount">'.($amount < 0 ? price(-$amount) : '').'</td>';
$out .= '</tr>';
print $out;
}
2016-03-28 11:51:19 +00:00
}