diff --git a/.github/workflows/exakat.yml b/.github/workflows/exakat.yml index d1bdffc71a6..0b33ede5f4f 100644 --- a/.github/workflows/exakat.yml +++ b/.github/workflows/exakat.yml @@ -16,7 +16,7 @@ jobs: exakat: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 1 - name: Exakat diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml index 560891f1ef1..1bb1184586f 100644 --- a/.github/workflows/phpcs.yml +++ b/.github/workflows/phpcs.yml @@ -11,7 +11,7 @@ jobs: phpcs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 50 # important! diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index 3b6f12566fe..d24c29651b1 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -45,6 +45,8 @@ if (!$user->hasRight('accounting', 'chartofaccount')) { $action = GETPOST('action', 'aZ09'); +$nbletter = GETPOST('ACCOUNTING_LETTERING_NBLETTERS', 'int'); + // Parameters ACCOUNTING_* and others $list = array( 'ACCOUNTING_LENGTH_GACCOUNT', @@ -56,7 +58,8 @@ $list = array( $list_binding = array( 'ACCOUNTING_DATE_START_BINDING', - 'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER' + 'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER', + 'ACCOUNTING_LETTERING_NBLETTERS' ); $error = 0; @@ -474,6 +477,24 @@ if (!empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) { print ''; if (!empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) { + // Number of letters for lettering (3 by default (AAA), min 2 (AA)) + print ''; + print ''; + print $form->textwithpicto($langs->trans("ACCOUNTING_LETTERING_NBLETTERS"), $langs->trans("ACCOUNTING_LETTERING_NBLETTERS_DESC")) . ''; + print ''; + + if (empty($letter)) { + if (getDolGlobalInt('ACCOUNTING_LETTERING_NBLETTERS')) { + $nbletter = getDolGlobalInt('ACCOUNTING_LETTERING_NBLETTERS'); + } else { + $nbletter = 3; + } + } + + print '' . "\n"; + print ''; + + // Auto Lettering when transfer in accountancy is realized print ''; print ''; print $form->textwithpicto($langs->trans("ACCOUNTING_ENABLE_AUTOLETTERING"), $langs->trans("ACCOUNTING_ENABLE_AUTOLETTERING_DESC")) . ''; diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php index 67eee9022b5..5cda6cad5b4 100644 --- a/htdocs/accountancy/class/lettering.class.php +++ b/htdocs/accountancy/class/lettering.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2013 Olivier Geffroy - * Copyright (C) 2013-2019 Alexandre Spangaro + * Copyright (C) 2013-2023 Alexandre Spangaro * Copyright (C) 2018 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -97,8 +97,8 @@ class Lettering extends BookKeeping $object->fetch($socid); - if ($object->code_compta == '411CUSTCODE') { - $object->code_compta = ''; + if ($object->code_compta_client == '411CUSTCODE') { + $object->code_compta_client = ''; } if ($object->code_compta_fournisseur == '401SUPPCODE') { @@ -106,7 +106,7 @@ class Lettering extends BookKeeping } /** - * Prise en charge des lettering complexe avec prelevment , virement + * Support for complex lettering with debit, credit transfer */ $sql = "SELECT DISTINCT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.subledger_account, "; $sql .= " bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant "; @@ -114,10 +114,10 @@ class Lettering extends BookKeeping $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON(bk.fk_doc = bu.fk_bank AND bu.type IN ('payment', 'payment_supplier') ) "; $sql .= " WHERE ( "; - if ($object->code_compta != "") { - $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta)."' "; + if ($object->code_compta_client != "") { + $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta_client)."' "; } - if ($object->code_compta != "" && $object->code_compta_fournisseur != "") { + if ($object->code_compta_client != "" && $object->code_compta_fournisseur != "") { $sql .= " OR "; } if ($object->code_compta_fournisseur != "") { @@ -149,10 +149,10 @@ class Lettering extends BookKeeping $sql .= " AND facf.entity = ".$conf->entity; $sql .= " AND code_journal IN (SELECT code FROM ".MAIN_DB_PREFIX."accounting_journal WHERE nature=4 AND entity=".$conf->entity.") "; $sql .= " AND ( "; - if ($object->code_compta != "") { - $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta)."' "; + if ($object->code_compta_client != "") { + $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta_client)."' "; } - if ($object->code_compta != "" && $object->code_compta_fournisseur != "") { + if ($object->code_compta_client != "" && $object->code_compta_fournisseur != "") { $sql .= " OR "; } if ($object->code_compta_fournisseur != "") { @@ -178,10 +178,10 @@ class Lettering extends BookKeeping $sql .= " WHERE bk.code_journal IN (SELECT code FROM ".MAIN_DB_PREFIX."accounting_journal WHERE nature=3 AND entity=".$conf->entity.") "; $sql .= " AND facf.entity = ".$conf->entity; $sql .= " AND ( "; - if ($object->code_compta != "") { - $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta)."' "; + if ($object->code_compta_client != "") { + $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta_client)."' "; } - if ($object->code_compta != "" && $object->code_compta_fournisseur != "") { + if ($object->code_compta_client != "" && $object->code_compta_fournisseur != "") { $sql .= " OR "; } if ($object->code_compta_fournisseur != "") { @@ -210,10 +210,10 @@ class Lettering extends BookKeeping $sql .= " AND bk.code_journal IN (SELECT code FROM ".MAIN_DB_PREFIX."accounting_journal WHERE nature=4 AND entity=".$conf->entity.") "; $sql .= " AND fac.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy $sql .= " AND ( "; - if ($object->code_compta != "") { - $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta)."' "; + if ($object->code_compta_client != "") { + $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta_client)."' "; } - if ($object->code_compta != "" && $object->code_compta_fournisseur != "") { + if ($object->code_compta_client != "" && $object->code_compta_fournisseur != "") { $sql .= " OR "; } if ($object->code_compta_fournisseur != "") { @@ -238,10 +238,10 @@ class Lettering extends BookKeeping $sql .= " WHERE code_journal IN (SELECT code FROM ".MAIN_DB_PREFIX."accounting_journal WHERE nature=2 AND entity=".$conf->entity.") "; $sql .= " AND fac.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy $sql .= " AND ( "; - if ($object->code_compta != "") { - $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta)."' "; + if ($object->code_compta_client != "") { + $sql .= " bk.subledger_account = '".$this->db->escape($object->code_compta_client)."' "; } - if ($object->code_compta != "" && $object->code_compta_fournisseur != "") { + if ($object->code_compta_client != "" && $object->code_compta_fournisseur != "") { $sql .= " OR "; } if ($object->code_compta_fournisseur != "") { @@ -288,7 +288,9 @@ class Lettering extends BookKeeping public function updateLettering($ids = array(), $notrigger = false) { $error = 0; - $lettre = 'AAA'; + + // Generate a string with n char A where n is ACCOUNTING_LETTERING_NBLETTERS (So 'AA', 'AAA', ...) + $lettre = str_pad("", getDolGlobalInt('ACCOUNTING_LETTERING_NBLETTERS', 3), "A"); $sql = "SELECT DISTINCT ab2.lettering_code"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS ab"; @@ -327,7 +329,6 @@ class Lettering extends BookKeeping } // Update request - $now = dol_now(); $affected_rows = 0; diff --git a/htdocs/core/ajax/ziptown.php b/htdocs/core/ajax/ziptown.php index 92db98c250d..af47b7fc77d 100644 --- a/htdocs/core/ajax/ziptown.php +++ b/htdocs/core/ajax/ziptown.php @@ -143,6 +143,9 @@ if (GETPOST('zipcode') || GETPOST('town')) { } echo json_encode($return_arr); +} elseif (GETPOSTISSET('country_codeid')) { + $formcompany = new FormCompany($db); + print $formcompany->select_state(GETPOST('selected', 'int', 1), GETPOST('country_codeid', 'int', 1), GETPOST('htmlname', 'alpha', 1), GETPOST('morecss', 'alpha', 1)); } $db->close(); diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 9ab8fa473dc..1d445094ea9 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -368,6 +368,32 @@ class FormCompany extends Form return $out; } + // 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 $parent_field_id Parent select name to monitor + * @param integer $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