| '.$langs->trans("TicketMessageMailIntroLabelAdmin").' ('.$langs->trans("Responses").')';
print ' | ';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor('TICKET_MESSAGE_MAIL_INTRO', $mail_intro, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70);
diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php
index 2fb97ff949c..bc5b9d46be1 100644
--- a/htdocs/compta/bank/class/api_bankaccounts.class.php
+++ b/htdocs/compta/bank/class/api_bankaccounts.class.php
@@ -57,12 +57,13 @@ class BankAccounts extends DolibarrApi
* @param string $sortorder Sort order
* @param int $limit Limit for list
* @param int $page Page number
+ * @param int $category Use this param to filter list by category
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.import_key:<:'20160101')"
* @return array List of account objects
*
* @throws RestException
*/
- public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '')
+ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $category = 0, $sqlfilters = '')
{
$list = array();
@@ -71,7 +72,14 @@ class BankAccounts extends DolibarrApi
}
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."bank_account as t";
+ if ($category > 0) {
+ $sql .= ", ".MAIN_DB_PREFIX."categorie_account as c";
+ }
$sql .= ' WHERE t.entity IN ('.getEntity('bank_account').')';
+ // Select accounts of given category
+ if ($category > 0) {
+ $sql .= " AND c.fk_categorie = ".$db->escape($category)." AND c.fk_account = t.rowid ";
+ }
// Add sql filters
if ($sqlfilters)
{
diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php
index 077c577ff26..66ed09413ef 100644
--- a/htdocs/core/actions_addupdatedelete.inc.php
+++ b/htdocs/core/actions_addupdatedelete.inc.php
@@ -75,6 +75,8 @@ if ($action == 'add' && !empty($permissiontoadd))
$value = 60 * 60 * GETPOST($key.'hour', 'int') + 60 * GETPOST($key.'min', 'int');
} elseif (preg_match('/^(integer|price|real|double)/', $object->fields[$key]['type'])) {
$value = price2num(GETPOST($key, 'none')); // To fix decimal separator according to lang setup
+ } elseif ($object->fields[$key]['type'] == 'boolean') {
+ $value = (GETPOST($key) == 'on' ? 1 : 0);
} else {
$value = GETPOST($key, 'alphanohtml');
}
@@ -156,6 +158,8 @@ if ($action == 'update' && !empty($permissiontoadd))
}
} elseif (preg_match('/^(integer|price|real|double)/', $object->fields[$key]['type'])) {
$value = price2num(GETPOST($key, 'none')); // To fix decimal separator according to lang setup
+ } elseif ($object->fields[$key]['type'] == 'boolean') {
+ $value = (GETPOST($key) == 'on' ? 1 : 0);
} else {
$value = GETPOST($key, 'alpha');
}
diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php
index 1be4d4eec89..e868934e55a 100644
--- a/htdocs/core/class/commondocgenerator.class.php
+++ b/htdocs/core/class/commondocgenerator.class.php
@@ -6,6 +6,7 @@
* Copyright (C) 2015 Marcos García
* Copyright (C) 2016 Charlie Benke
* Copyright (C) 2018 Frédéric France
+ * Copyright (C) 2020 Josep Lluís Amador
*
* 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
@@ -386,6 +387,12 @@ abstract class CommonDocGenerator
$sumcreditnote = $object->getSumCreditNotesUsed();
$already_payed_all = $sumpayed + $sumdeposit + $sumcreditnote;
$remain_to_pay = $sumpayed - $sumdeposit - $sumcreditnote;
+
+ if ($object->fk_account > 0) {
+ require_once DOL_DOCUMENT_ROOT .'/compta/bank/class/account.class.php';
+ $bank_account = new Account($this->db);
+ $bank_account->fetch($object->fk_account);
+ }
}
$date = ($object->element == 'contrat' ? $object->date_contrat : $object->date);
@@ -414,6 +421,9 @@ abstract class CommonDocGenerator
$array_key.'_payment_term_code'=>$object->cond_reglement_code,
$array_key.'_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code) != 'PaymentCondition'.$object->cond_reglement_code ? $outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code) : ($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement)),
+ $array_key.'_bank_iban'=>$bank_account->iban,
+ $array_key.'_bank_bic'=>$bank_account->bic,
+
$array_key.'_total_ht_locale'=>price($object->total_ht, 0, $outputlangs),
$array_key.'_total_vat_locale'=>(!empty($object->total_vat) ?price($object->total_vat, 0, $outputlangs) : price($object->total_tva, 0, $outputlangs)),
$array_key.'_total_localtax1_locale'=>price($object->total_localtax1, 0, $outputlangs),
diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php
index 8b4d1dee6ef..b6c7017e408 100644
--- a/htdocs/core/class/html.formprojet.class.php
+++ b/htdocs/core/class/html.formprojet.class.php
@@ -30,9 +30,9 @@
class FormProjets
{
/**
- * @var DoliDB Database handler.
- */
- public $db;
+ * @var DoliDB Database handler.
+ */
+ public $db;
/**
* @var string Error code (or message)
@@ -50,7 +50,7 @@ class FormProjets
$this->db = $db;
}
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Output a combo list with projects qualified for a third party / user
*
@@ -71,9 +71,9 @@ class FormProjets
* @param int $htmlid Html id to use instead of htmlname
* @return string Return html content
*/
- public function select_projects($socid = -1, $selected = '', $htmlname = 'projectid', $maxlength = 16, $option_only = 0, $show_empty = 1, $discard_closed = 0, $forcefocus = 0, $disabled = 0, $mode = 0, $filterkey = '', $nooutput = 0, $forceaddid = 0, $morecss = '', $htmlid = '')
- {
- // phpcs:enable
+ public function select_projects($socid = -1, $selected = '', $htmlname = 'projectid', $maxlength = 16, $option_only = 0, $show_empty = 1, $discard_closed = 0, $forcefocus = 0, $disabled = 0, $mode = 0, $filterkey = '', $nooutput = 0, $forceaddid = 0, $morecss = '', $htmlid = '')
+ {
+ // phpcs:enable
global $langs, $conf, $form;
$out = '';
@@ -90,13 +90,13 @@ class FormProjets
$selected_input_value = $project->ref;
}
$urloption = 'socid='.$socid.'&htmlname='.$htmlname.'&discardclosed='.$discard_closed;
- $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projects.php', $urloption, $conf->global->PROJECT_USE_SEARCH_TO_SELECT, 0, array(
- // 'update' => array(
- // 'projectid' => 'id'
- // )
- ));
+ $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projects.php', $urloption, $conf->global->PROJECT_USE_SEARCH_TO_SELECT, 0, array(
+ // 'update' => array(
+ // 'projectid' => 'id'
+ // )
+ ));
- $out .= '';
+ $out .= '';
}
else
{
@@ -113,13 +113,13 @@ class FormProjets
if (empty($nooutput))
{
- print $out;
- return '';
+ print $out;
+ return '';
}
else return $out;
}
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Returns an array with projects qualified for a third party
*
@@ -130,8 +130,8 @@ class FormProjets
* @param int $option_only Return only html options lines without the select tag
* @param int $show_empty Add an empty line
* @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable)
- * @param int $forcefocus Force focus on field (works with javascript only)
- * @param int $disabled Disabled
+ * @param int $forcefocus Force focus on field (works with javascript only)
+ * @param int $disabled Disabled
* @param int $mode 0 for HTML mode and 1 for array return (to be used by json_encode for example)
* @param string $filterkey Key to filter
* @param int $nooutput No print output. Return it only.
@@ -140,9 +140,9 @@ class FormProjets
* @param string $morecss More CSS
* @return int Nb of project if OK, <0 if KO
*/
- public function select_projects_list($socid = -1, $selected = '', $htmlname = 'projectid', $maxlength = 24, $option_only = 0, $show_empty = 1, $discard_closed = 0, $forcefocus = 0, $disabled = 0, $mode = 0, $filterkey = '', $nooutput = 0, $forceaddid = 0, $htmlid = '', $morecss = 'maxwidth500')
- {
- // phpcs:enable
+ public function select_projects_list($socid = -1, $selected = '', $htmlname = 'projectid', $maxlength = 24, $option_only = 0, $show_empty = 1, $discard_closed = 0, $forcefocus = 0, $disabled = 0, $mode = 0, $filterkey = '', $nooutput = 0, $forceaddid = 0, $htmlid = '', $morecss = 'maxwidth500')
+ {
+ // phpcs:enable
global $user, $conf, $langs;
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
@@ -170,11 +170,11 @@ class FormProjets
if ($socid == 0) $sql .= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
if ($socid > 0)
{
- if (empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) $sql .= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)";
- elseif ($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all') // PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY is 'all' or a list of ids separated by coma.
- {
- $sql .= " AND (p.fk_soc IN (".$socid.", ".$conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY.") OR p.fk_soc IS NULL)";
- }
+ if (empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) $sql .= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)";
+ elseif ($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all') // PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY is 'all' or a list of ids separated by coma.
+ {
+ $sql .= " AND (p.fk_soc IN (".$socid.", ".$conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY.") OR p.fk_soc IS NULL)";
+ }
}
if (!empty($filterkey)) $sql .= natural_search(array('p.title', 'p.ref'), $filterkey);
$sql .= " ORDER BY p.ref ASC";
@@ -186,9 +186,9 @@ class FormProjets
if (!empty($conf->use_javascript_ajax))
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
- $comboenhancement = ajax_combobox($htmlid, array(), 0, $forcefocus);
- $out .= $comboenhancement;
- $morecss .= ' minwidth100';
+ $comboenhancement = ajax_combobox($htmlid, array(), 0, $forcefocus);
+ $out .= $comboenhancement;
+ $morecss .= ' minwidth100';
}
if (empty($option_only)) {
@@ -223,8 +223,8 @@ class FormProjets
$labeltoshow .= ', '.dol_trunc($obj->title, $maxlength);
if ($obj->name)
{
- $labeltoshow .= ' - '.$obj->name;
- if ($obj->name_alias) $labeltoshow .= ' ('.$obj->name_alias.')';
+ $labeltoshow .= ' - '.$obj->name;
+ if ($obj->name_alias) $labeltoshow .= ' ('.$obj->name_alias.')';
}
$disabled = 0;
@@ -287,8 +287,8 @@ class FormProjets
if (empty($option_only)) $out .= '';
if (empty($nooutput))
{
- print $out;
- return '';
+ print $out;
+ return '';
}
else return $out;
} else {
@@ -312,15 +312,15 @@ class FormProjets
* @param int $option_only Return only html options lines without the select tag
* @param string $show_empty Add an empty line ('1' or string to show for empty line)
* @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable)
- * @param int $forcefocus Force focus on field (works with javascript only)
- * @param int $disabled Disabled
+ * @param int $forcefocus Force focus on field (works with javascript only)
+ * @param int $disabled Disabled
* @param string $morecss More css added to the select component
* @param string $projectsListId ''=Automatic filter on project allowed. List of id=Filter on project ids.
* @param string $showproject 'all' = Show project info, ''=Hide project info
* @param User $usertofilter User object to use for filtering
- * @return int Nbr of project if OK, <0 if KO
+ * @return int Nbr of tasks if OK, <0 if KO
*/
- public function selectTasks($socid = -1, $selected = '', $htmlname = 'taskid', $maxlength = 24, $option_only = 0, $show_empty = '1', $discard_closed = 0, $forcefocus = 0, $disabled = 0, $morecss = 'maxwidth500', $projectsListId = '', $showproject = 'all', $usertofilter = null)
+ public function selectTasks($socid = -1, $selected = '', $htmlname = 'taskid', $maxlength = 24, $option_only = 0, $show_empty = '1', $discard_closed = 0, $forcefocus = 0, $disabled = 0, $morecss = 'maxwidth500', $projectsListId = '', $showproject = 'all', $usertofilter = null)
{
global $user, $conf, $langs;
@@ -365,9 +365,9 @@ class FormProjets
if (!empty($conf->use_javascript_ajax))
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
- $comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus);
- $out .= $comboenhancement;
- $morecss = 'minwidth200imp maxwidth500';
+ $comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus);
+ $out .= $comboenhancement;
+ $morecss = 'minwidth200imp maxwidth500';
}
if (empty($option_only)) {
@@ -481,7 +481,7 @@ class FormProjets
}
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Build a HTML select list of element of same thirdparty to suggest to link them to project
*
@@ -494,7 +494,7 @@ class FormProjets
*/
public function select_element($table_element, $socid = 0, $morecss = '', $limitonstatus = -2, $projectkey = "fk_projet")
{
- // phpcs:enable
+ // phpcs:enable
global $conf, $langs;
if ($table_element == 'projet_task') return ''; // Special cas of element we never link to a project (already always done)
@@ -518,7 +518,7 @@ class FormProjets
break;
case "commande_fourn":
case "commande_fournisseur":
- $sql = "SELECT t.rowid, t.ref, t.ref_supplier";
+ $sql = "SELECT t.rowid, t.ref, t.ref_supplier";
break;
case "facture_rec":
$sql = "SELECT t.rowid, t.titre as ref";
@@ -535,10 +535,10 @@ class FormProjets
break;*/
return '';
case "commande":
- case "contrat":
+ case "contrat":
case "fichinter":
- $sql = "SELECT t.rowid, t.ref";
- break;
+ $sql = "SELECT t.rowid, t.ref";
+ break;
case 'stock_mouvement':
$sql = 'SELECT t.rowid, t.label as ref';
$projectkey = 'fk_origin';
@@ -560,8 +560,8 @@ class FormProjets
$sql .= " WHERE ".$projectkey." is null";
if (!empty($socid) && $linkedtothirdparty)
{
- if (is_numeric($socid)) $sql .= " AND t.fk_soc=".$socid;
- else $sql .= " AND t.fk_soc IN (".$socid.")";
+ if (is_numeric($socid)) $sql .= " AND t.fk_soc=".$socid;
+ else $sql .= " AND t.fk_soc IN (".$socid.")";
}
if (!in_array($table_element, array('expensereport_det', 'stock_mouvement'))) $sql .= ' AND t.entity IN ('.getEntity('project').')';
if ($linkedtothirdparty) $sql .= " AND s.rowid = t.fk_soc";
@@ -640,15 +640,15 @@ class FormProjets
{
$sellist = ' |