From 518a225f7baa8f577877392562f1906aa86723ab Mon Sep 17 00:00:00 2001 From: jcp Date: Tue, 3 Nov 2020 19:48:23 +0100 Subject: [PATCH 01/21] NEW massaction for BankTransfer --- htdocs/fourn/facture/list.php | 101 ++++++++++++++++++++++++++++ htdocs/langs/en_US/withdrawals.lang | 1 + 2 files changed, 102 insertions(+) diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 0ebfd024658..c1c6329cb43 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -270,6 +270,103 @@ if (empty($reshook)) } +if ($massaction == 'transfer_request') +{ + $langs->load("withdrawals"); + + if (!$user->rights->paymentbybanktransfer->create) + { + $error++; + setEventMessages($langs->trans("NotEnoughPermissions"), null, 'errors'); + } + else + { + //Checking error + $error = 0; + + $arrayofselected = is_array($toselect) ? $toselect : array(); + $listofbills = array(); + foreach ($arrayofselected as $toselectid) + { + $objecttmp = new FactureFournisseur($db); + $result = $objecttmp->fetch($toselectid); + if ($result > 0) + { + $totalpaye = $objecttmp->getSommePaiement(); + $totalcreditnotes = $objecttmp->getSumCreditNotesUsed(); + $totaldeposits = $objecttmp->getSumDepositsUsed(); + $objecttmp->resteapayer = price2num($objecttmp->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); + if ($objecttmp->paye || $objecttmp->resteapayer == 0) { + $error++; + setEventMessages($objecttmp->ref.' '.$langs->trans("AlreadyPaid"), $objecttmp->errors, 'errors'); + } elseif ($objecttmp->resteapayer < 0) { + $error++; + setEventMessages($objecttmp->ref.' '.$langs->trans("AmountMustBePositive"), $objecttmp->errors, 'errors'); + } + if (!($objecttmp->statut > FactureFournisseur::STATUS_DRAFT)) { + $error++; + setEventMessages($objecttmp->ref.' '.$langs->trans("Draft"), $objecttmp->errors, 'errors'); + } + + $rsql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande"; + $rsql .= " , pfd.date_traite as date_traite"; + $rsql .= " , pfd.amount"; + $rsql .= " , u.rowid as user_id, u.lastname, u.firstname, u.login"; + $rsql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; + $rsql .= " , ".MAIN_DB_PREFIX."user as u"; + $rsql .= " WHERE fk_facture_fourn = ".$objecttmp->id; + $rsql .= " AND pfd.fk_user_demande = u.rowid"; + $rsql .= " AND pfd.traite = 0"; + $rsql .= " ORDER BY pfd.date_demande DESC"; + + $result_sql = $db->query($rsql); + if ($result_sql) + { + $numprlv = $db->num_rows($result_sql); + } + + if ($numprlv > 0) { + $error++; + setEventMessages($objecttmp->ref.' '.$langs->trans("RequestAlreadyDone"), $objecttmp->errors, 'warnings'); + } + elseif (!empty($objecttmp->mode_reglement_code) && $objecttmp->mode_reglement_code != 'VIR') { + $error++; + setEventMessages($objecttmp->ref.' '.$langs->trans("BadPaymentMethod"), $objecttmp->errors, 'errors'); + } + else { + $listofbills[] = $objecttmp; // $listofbills will only contains invoices with good payment method and no request already done + } + } + } + + //Massive withdraw request for request with no errors + if (!empty($listofbills)) + { + $nbwithdrawrequestok = 0; + foreach ($listofbills as $aBill) + { + $db->begin(); + $result = $aBill->demande_prelevement($user, $aBill->resteapayer, 'bank-transfer', 'supplier_invoice'); + if ($result > 0) + { + $db->commit(); + $nbwithdrawrequestok++; + } + else + { + $db->rollback(); + setEventMessages($aBill->error, $aBill->errors, 'errors'); + } + } + if ($nbwithdrawrequestok > 0) + { + setEventMessages($langs->trans("BankTransferRequestsDone", $nbwithdrawrequestok), null, 'mesgs'); + } + } + } +} + + /* * View */ @@ -505,6 +602,10 @@ if ($resql) //'builddoc'=>$langs->trans("PDFMerge"), //'presend'=>$langs->trans("SendByMail"), ); + if ($conf->paymentbybanktransfer->enabled) { + $langs->load("withdrawals"); + $arrayofmassactions['transfer_request'] = $langs->trans("MakeBankTransferOrder"); + } //if($user->rights->fournisseur->facture->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); if ($user->rights->fournisseur->facture->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); if (in_array($massaction, array('presend', 'predelete', 'createbills'))) $arrayofmassactions = array(); diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index a18ff7a8d31..1b8f2441b33 100644 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -42,6 +42,7 @@ LastWithdrawalReceipt=Latest %s direct debit receipts MakeWithdrawRequest=Make a direct debit payment request MakeBankTransferOrder=Make a credit transfer request WithdrawRequestsDone=%s direct debit payment requests recorded +BankTransferRequestsDone=%s credit transfer requests recorded ThirdPartyBankCode=Third-party bank code NoInvoiceCouldBeWithdrawed=No invoice debited successfully. Check that invoices are on companies with a valid IBAN and that IBAN has a UMR (Unique Mandate Reference) with mode %s. ClassCredited=Classify credited From 61bca50fa62c0b51127e5802e3926f031afb9812 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 5 Nov 2020 16:56:28 +0100 Subject: [PATCH 02/21] NEW: Dictionary for availability - Add column position --- htdocs/admin/dict.php | 14 ++++---- htdocs/core/class/html.form.class.php | 7 ++-- .../install/mysql/data/llx_c_availability.sql | 9 ++--- .../install/mysql/migration/13.0.0-14.0.0.sql | 35 +++++++++++++++++++ .../mysql/tables/llx_c_availability.sql | 5 +-- 5 files changed, 54 insertions(+), 16 deletions(-) create mode 100644 htdocs/install/mysql/migration/13.0.0-14.0.0.sql diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 43ce69f6e02..adacc0d7b8e 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -8,7 +8,7 @@ * Copyright (C) 2011 Remy Younes * Copyright (C) 2012-2015 Marcos García * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2011-2019 Alexandre Spangaro + * Copyright (C) 2011-2020 Alexandre Spangaro * Copyright (C) 2015 Ferran Marcet * Copyright (C) 2016 Raphaël Doursenaud * Copyright (C) 2019-2020 Frédéric France @@ -205,7 +205,7 @@ $tabsql[17] = "SELECT id as rowid, code, label, accountancy_code, active FR $tabsql[18] = "SELECT rowid as rowid, code, libelle, tracking, active FROM ".MAIN_DB_PREFIX."c_shipment_mode"; $tabsql[19] = "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_effectif"; $tabsql[20] = "SELECT rowid as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_input_method"; -$tabsql[21] = "SELECT c.rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_availability AS c"; +$tabsql[21] = "SELECT c.rowid as rowid, c.code, c.label, c.active, c.position FROM ".MAIN_DB_PREFIX."c_availability AS c"; $tabsql[22] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_input_reason"; $tabsql[23] = "SELECT t.rowid as rowid, t.taux, t.revenuestamp_type, c.label as country, c.code as country_code, t.fk_pays as country_id, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_revenuestamp as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid"; $tabsql[24] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_type_resource"; @@ -250,7 +250,7 @@ $tabsqlsort[17] = "code ASC"; $tabsqlsort[18] = "code ASC, libelle ASC"; $tabsqlsort[19] = "id ASC"; $tabsqlsort[20] = "code ASC, libelle ASC"; -$tabsqlsort[21] = "code ASC, label ASC"; +$tabsqlsort[21] = "code ASC, label ASC, position ASC"; $tabsqlsort[22] = "code ASC, label ASC"; $tabsqlsort[23] = "country ASC, taux ASC"; $tabsqlsort[24] = "code ASC, label ASC"; @@ -295,7 +295,7 @@ $tabfield[17] = "code,label,accountancy_code"; $tabfield[18] = "code,libelle,tracking"; $tabfield[19] = "code,libelle"; $tabfield[20] = "code,libelle"; -$tabfield[21] = "code,label"; +$tabfield[21] = "code,label,position"; $tabfield[22] = "code,label"; $tabfield[23] = "country_id,country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note"; $tabfield[24] = "code,label"; @@ -340,7 +340,7 @@ $tabfieldvalue[17] = "code,label,accountancy_code"; $tabfieldvalue[18] = "code,libelle,tracking"; $tabfieldvalue[19] = "code,libelle"; $tabfieldvalue[20] = "code,libelle"; -$tabfieldvalue[21] = "code,label"; +$tabfieldvalue[21] = "code,label,position"; $tabfieldvalue[22] = "code,label"; $tabfieldvalue[23] = "country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note"; $tabfieldvalue[24] = "code,label"; @@ -385,7 +385,7 @@ $tabfieldinsert[17] = "code,label,accountancy_code"; $tabfieldinsert[18] = "code,libelle,tracking"; $tabfieldinsert[19] = "code,libelle"; $tabfieldinsert[20] = "code,libelle"; -$tabfieldinsert[21] = "code,label"; +$tabfieldinsert[21] = "code,label,position"; $tabfieldinsert[22] = "code,label"; $tabfieldinsert[23] = "fk_pays,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note"; $tabfieldinsert[24] = "code,label"; @@ -523,7 +523,7 @@ $tabhelp[17] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[18] = array('code'=>$langs->trans("EnterAnyCode"), 'tracking'=>$langs->trans("UrlTrackingDesc")); $tabhelp[19] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[20] = array('code'=>$langs->trans("EnterAnyCode")); -$tabhelp[21] = array('code'=>$langs->trans("EnterAnyCode")); +$tabhelp[21] = array('code'=>$langs->trans("EnterAnyCode"), 'position'=>$langs->trans("PositionIntoComboList")); $tabhelp[22] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[23] = array('revenuestamp_type'=>'FixedOrPercent'); $tabhelp[24] = array('code'=>$langs->trans("EnterAnyCode")); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 5c457a2a28c..fac12b48d52 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -15,7 +15,7 @@ * Copyright (C) 2012-2016 Marcos García * Copyright (C) 2012 Cedric Salvador * Copyright (C) 2012-2015 Raphaël Doursenaud - * Copyright (C) 2014 Alexandre Spangaro + * Copyright (C) 2014-2020 Alexandre Spangaro * Copyright (C) 2018 Ferran Marcet * Copyright (C) 2018-2019 Frédéric France * Copyright (C) 2018 Nicolas ZABOURI @@ -3218,7 +3218,7 @@ class Form $langs->load('propal'); - $sql = "SELECT rowid, code, label"; + $sql = "SELECT rowid, code, label, position"; $sql .= " FROM ".MAIN_DB_PREFIX.'c_availability'; $sql .= " WHERE active > 0"; @@ -3235,10 +3235,11 @@ class Form $label = ($langs->trans("AvailabilityType".$obj->code) != ("AvailabilityType".$obj->code) ? $langs->trans("AvailabilityType".$obj->code) : ($obj->label != '-' ? $obj->label : '')); $this->cache_availability[$obj->rowid]['code'] = $obj->code; $this->cache_availability[$obj->rowid]['label'] = $label; + $this->cache_availability[$obj->rowid]['position'] = $obj->position; $i++; } - $this->cache_availability = dol_sort_array($this->cache_availability, 'label', 'asc', 0, 0, 1); + $this->cache_availability = dol_sort_array($this->cache_availability, 'position', 'asc', 0, 0, 1); return $num; } else { diff --git a/htdocs/install/mysql/data/llx_c_availability.sql b/htdocs/install/mysql/data/llx_c_availability.sql index 7d834aa2809..2e06d1de8b3 100644 --- a/htdocs/install/mysql/data/llx_c_availability.sql +++ b/htdocs/install/mysql/data/llx_c_availability.sql @@ -1,4 +1,5 @@ -- Copyright (C) 2011 Philippe GRAND +-- Copyright (C) 2020 Alexandre SPANGARO -- -- 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 @@ -25,7 +26,7 @@ -- delete from llx_c_availability; -INSERT INTO llx_c_availability (rowid,code,label,active) VALUES (1, 'AV_NOW', 'Immediate', 1); -INSERT INTO llx_c_availability (rowid,code,label,active) VALUES (2, 'AV_1W', '1 week', 1); -INSERT INTO llx_c_availability (rowid,code,label,active) VALUES (3, 'AV_2W', '2 weeks', 1); -INSERT INTO llx_c_availability (rowid,code,label,active) VALUES (4, 'AV_3W', '3 weeks', 1); +INSERT INTO llx_c_availability (rowid,code,label,active,position) VALUES (1, 'AV_NOW', 'Immediate', 1, 10); +INSERT INTO llx_c_availability (rowid,code,label,active,position) VALUES (2, 'AV_1W', '1 week', 1, 20); +INSERT INTO llx_c_availability (rowid,code,label,active,position) VALUES (3, 'AV_2W', '2 weeks', 1, 30); +INSERT INTO llx_c_availability (rowid,code,label,active,position) VALUES (4, 'AV_3W', '3 weeks', 1, 40); diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql new file mode 100644 index 00000000000..58a3f962e3c --- /dev/null +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -0,0 +1,35 @@ +-- +-- Be carefull to requests order. +-- This file must be loaded by calling /install/index.php page +-- when current version is 14.0.0 or higher. +-- +-- To restrict request to Mysql version x.y minimum use -- VMYSQLx.y +-- To restrict request to Pgsql version x.y minimum use -- VPGSQLx.y +-- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new; +-- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol; +-- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60); +-- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname; +-- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60); +-- To drop a foreign key: ALTER TABLE llx_table DROP FOREIGN KEY fk_name; +-- To create a unique index ALTER TABLE llx_table ADD UNIQUE INDEX uk_table_field (field); +-- To drop an index: -- VMYSQL4.1 DROP INDEX nomindex on llx_table +-- To drop an index: -- VPGSQL8.2 DROP INDEX nomindex +-- To make pk to be auto increment (mysql): -- VMYSQL4.3 ALTER TABLE llx_table CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; +-- To make pk to be auto increment (postgres): +-- -- VPGSQL8.2 CREATE SEQUENCE llx_table_rowid_seq OWNED BY llx_table.rowid; +-- -- VPGSQL8.2 ALTER TABLE llx_table ADD PRIMARY KEY (rowid); +-- -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN rowid SET DEFAULT nextval('llx_table_rowid_seq'); +-- -- VPGSQL8.2 SELECT setval('llx_table_rowid_seq', MAX(rowid)) FROM llx_table; +-- To set a field as NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NULL; +-- To set a field as NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL; +-- To set a field as NOT NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NOT NULL; +-- To set a field as NOT NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET NOT NULL; +-- To set a field as default NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL; +-- Note: fields with type BLOB/TEXT can't have default value. + + +-- Missing in v13 or lower + +-- For v14 + +ALTER TABLE llx_c_availability ADD COLUMN position integer NOT NULL DEFAULT 0; diff --git a/htdocs/install/mysql/tables/llx_c_availability.sql b/htdocs/install/mysql/tables/llx_c_availability.sql index cef03abe548..4cdc8d6203c 100644 --- a/htdocs/install/mysql/tables/llx_c_availability.sql +++ b/htdocs/install/mysql/tables/llx_c_availability.sql @@ -1,5 +1,6 @@ -- ======================================================================== -- Copyright (C) 2011 Philippe GRAND +-- Copyright (C) 2020 Alexandre SPANGARO -- -- 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 @@ -21,6 +22,6 @@ create table llx_c_availability rowid integer AUTO_INCREMENT PRIMARY KEY, code varchar(30) NOT NULL, label varchar(60) NOT NULL, - active tinyint DEFAULT 1 NOT NULL - + active tinyint DEFAULT 1 NOT NULL, + position integer NOT NULL DEFAULT 0 )ENGINE=innodb; From 1bdd617feb8edb25e07ebdf0c520dee4489e821c Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Sat, 7 Nov 2020 15:31:27 +0100 Subject: [PATCH 03/21] NEW: Multiselect ledger account code filter on book keeping list --- htdocs/accountancy/admin/index.php | 20 ++++- htdocs/accountancy/bookkeeping/list.php | 14 +++- .../core/class/html.formaccounting.class.php | 82 ++++++++++++++++++- htdocs/core/modules/modAccounting.class.php | 6 ++ htdocs/langs/en_US/accountancy.lang | 2 +- htdocs/langs/fr_FR/accountancy.lang | 2 +- 6 files changed, 117 insertions(+), 9 deletions(-) diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index 516af988334..92c2df3ba0e 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -48,6 +48,7 @@ $action = GETPOST('action', 'aZ09'); $list = array( 'ACCOUNTING_LENGTH_GACCOUNT', 'ACCOUNTING_LENGTH_AACCOUNT', + 'ACCOUNTING_LIMIT_LIST_VENTILATION' // 'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc // 'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc ); @@ -248,7 +249,7 @@ if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) { print ''; */ -print ''; +/*print ''; print ''.$langs->trans("BANK_DISABLE_DIRECT_INPUT").''; if (!empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) { print ''; @@ -259,7 +260,7 @@ if (!empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) { print img_picto($langs->trans("Disabled"), 'switch_off'); print ''; } -print ''; +print '';*/ print ''; print ''.$langs->trans("ACCOUNTANCY_COMBO_FOR_AUX").''; @@ -313,6 +314,21 @@ print ''; print ''.$langs->trans('BindingOptions').''; print "\n"; + +// TO DO Mutualize code for yes/no constants +print ''; +print ''.$langs->trans("").''; +if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; +} else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; +} +print ''; + // TO DO Mutualize code for yes/no constants print ''; print ''.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO").''; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 6d663edcf4e..7219136c2da 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -85,7 +85,7 @@ $search_mvt_label = GETPOST('search_mvt_label', 'alpha'); $search_direction = GETPOST('search_direction', 'alpha'); $search_debit = GETPOST('search_debit', 'alpha'); $search_credit = GETPOST('search_credit', 'alpha'); -$search_ledger_code = GETPOST('search_ledger_code', 'alpha'); +$search_ledger_code = GETPOST('search_ledger_code', 'array'); $search_lettering_code = GETPOST('search_lettering_code', 'alpha'); $search_not_reconciled = GETPOST('search_reconciled_option', 'alpha'); @@ -192,7 +192,7 @@ if (empty($reshook)) $search_accountancy_aux_code_end = ''; $search_mvt_label = ''; $search_direction = ''; - $search_ledger_code = ''; + $search_ledger_code = array(); $search_date_start = ''; $search_date_end = ''; $search_date_creation_start = ''; @@ -267,7 +267,9 @@ if (empty($reshook)) } if (!empty($search_ledger_code)) { $filter['t.code_journal'] = $search_ledger_code; - $param .= '&search_ledger_code='.urlencode($search_ledger_code); + foreach ($search_ledger_code as $code) { + $param .= '&search_ledger_code[]='.urlencode($code); + } } if (!empty($search_mvt_num)) { $filter['t.piece_num'] = $search_mvt_num; @@ -447,6 +449,8 @@ if (count($filter) > 0) { $sqlwhere[] = natural_search($key, $value, 1, 1); } elseif ($key == 't.reconciled_option') { $sqlwhere[] = 't.lettering_code IS NULL'; + } elseif ($key == 't.code_journal' && !empty($value)) { + $sqlwhere[] = natural_search("t.code_journal", join(',', $value), 3, 1); } else { $sqlwhere[] = natural_search($key, $value, 0, 1); } @@ -756,7 +760,9 @@ if (!empty($arrayfields['t.lettering_code']['checked'])) // Code journal if (!empty($arrayfields['t.code_journal']['checked'])) { - print ''; + print ''; + print $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1); + print ''; } // Fields from hook diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index d6f7b269da1..373501a7adf 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -59,7 +59,7 @@ class FormAccounting extends Form /** * Return list of journals with label by nature * - * @param string $selectid Preselected pcg_type + * @param string $selectid Preselected journal code * @param string $htmlname Name of field in html form * @param int $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 @@ -136,6 +136,86 @@ class FormAccounting extends Form return $out; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return list of journals with label by nature + * + * @param array $selectids Preselected journal code + * @param string $htmlname Name of field in html form + * @param int $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 $disabledajaxcombo Disable ajax combo box. + * @return string String with HTML select + */ + 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(); + if ($usecache && !empty($this->options_cache[$usecache])) + { + $options = $this->options_cache[$usecache]; + $selected = $selectedIds; + } else { + $sql = "SELECT rowid, code, label, nature, entity, active"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_journal"; + $sql .= " WHERE active = 1"; + $sql .= " AND entity = ".$conf->entity; + if ($nature && is_numeric($nature)) $sql .= " AND nature = ".$nature; + $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'); + while ($obj = $this->db->fetch_object($resql)) + { + $label = $langs->trans($obj->label); + + $select_value_in = $obj->rowid; + $select_value_out = $obj->rowid; + + // 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 (!empty($selectedIds) && in_array($select_value_in, $selectedIds)) { + //var_dump("Found ".$selectid." ".$select_value_in); + $selected[] = $select_value_out; + } + $options[$select_value_out] = $label; + } + $this->db->free($resql); + + if ($usecache) + { + $this->options_cache[$usecache] = $options; + } + } + + $out .= Form::multiselectarray($htmlname, $options, $selected, $showempty, 0, $morecss, 0, 0, 0, 'code_journal', '',($disabledajaxcombo ? 0 : 1)); + + return $out; + } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of accounting category. diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 811dd57544e..7eff70422ee 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -154,6 +154,12 @@ class modAccounting extends DolibarrModules "csv", "", 0, 'current', 0 ); + $this->const[14] = array( + "ACCOUNTING_LIMIT_LIST_VENTILATION", + "chaine", + "50", + "", 0, 'current', 0 + ); // Tabs $this->tabs = array(); diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 1d75fa153e8..c35d85e7bcb 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -144,7 +144,7 @@ NotVentilatedinAccount=Not bound to the accounting account XLineSuccessfullyBinded=%s products/services successfully bound to an accounting account XLineFailedToBeBinded=%s products/services were not bound to any accounting account -ACCOUNTING_LIMIT_LIST_VENTILATION=Number of elements to bind shown by page (maximum recommended: 50) +ACCOUNTING_LIMIT_LIST_VENTILATION=Number of elements to on list and bind shown by page (maximum recommended: 50) ACCOUNTING_LIST_SORT_VENTILATION_TODO=Begin the sorting of the page "Binding to do" by the most recent elements ACCOUNTING_LIST_SORT_VENTILATION_DONE=Begin the sorting of the page "Binding done" by the most recent elements diff --git a/htdocs/langs/fr_FR/accountancy.lang b/htdocs/langs/fr_FR/accountancy.lang index 6381caebbec..5309adfae93 100644 --- a/htdocs/langs/fr_FR/accountancy.lang +++ b/htdocs/langs/fr_FR/accountancy.lang @@ -137,7 +137,7 @@ NotVentilatedinAccount=Non lié au compte comptable XLineSuccessfullyBinded=%s produits/service correctement liés à un compte comptable XLineFailedToBeBinded=%s produits/services n'ont pu être liés à un compte comptable -ACCOUNTING_LIMIT_LIST_VENTILATION=Nombre d'éléments à lier représentés par page (maximum recommandé: 50) +ACCOUNTING_LIMIT_LIST_VENTILATION=Nombre de ligne des listes et d'éléments à lier représentés par page (maximum recommandé: 50) ACCOUNTING_LIST_SORT_VENTILATION_TODO=Commencez le tri de la page "Lien à réaliser" par les éléments les plus récents ACCOUNTING_LIST_SORT_VENTILATION_DONE=Commencez le tri de la page "Liens réalisés" par les éléments les plus récents From c9373e318ed68b9944074e16b743a2ca66e0d8d2 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Sat, 7 Nov 2020 15:33:23 +0100 Subject: [PATCH 04/21] fix admin --- htdocs/accountancy/admin/index.php | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index 92c2df3ba0e..6a33d009765 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -249,7 +249,7 @@ if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) { print ''; */ -/*print ''; +print ''; print ''.$langs->trans("BANK_DISABLE_DIRECT_INPUT").''; if (!empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) { print ''; @@ -260,7 +260,7 @@ if (!empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) { print img_picto($langs->trans("Disabled"), 'switch_off'); print ''; } -print '';*/ +print ''; print ''; print ''.$langs->trans("ACCOUNTANCY_COMBO_FOR_AUX").''; @@ -314,21 +314,6 @@ print ''; print ''.$langs->trans('BindingOptions').''; print "\n"; - -// TO DO Mutualize code for yes/no constants -print ''; -print ''.$langs->trans("").''; -if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) { - print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; -} else { - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; -} -print ''; - // TO DO Mutualize code for yes/no constants print ''; print ''.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO").''; From 259462b53a2f372a1094a820d42ece8642d7fc64 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 7 Nov 2020 14:36:28 +0000 Subject: [PATCH 05/21] Fixing style errors. --- htdocs/core/class/html.formaccounting.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index 373501a7adf..14f97d23ebf 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -151,7 +151,7 @@ class FormAccounting extends Form * @param int $disabledajaxcombo Disable ajax combo box. * @return string String with HTML select */ - public function multi_select_journal($selectedIds=array(), $htmlname = 'journal', $nature = 0, $showempty = 0, $select_in = 0, $select_out = 0, $morecss = '', $usecache = '', $disabledajaxcombo = 0) + 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; @@ -211,7 +211,7 @@ class FormAccounting extends Form } } - $out .= Form::multiselectarray($htmlname, $options, $selected, $showempty, 0, $morecss, 0, 0, 0, 'code_journal', '',($disabledajaxcombo ? 0 : 1)); + $out .= Form::multiselectarray($htmlname, $options, $selected, $showempty, 0, $morecss, 0, 0, 0, 'code_journal', '', ($disabledajaxcombo ? 0 : 1)); return $out; } From 58cb63adf74c8648037b5067605f9770de4f34d5 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Sat, 7 Nov 2020 15:48:12 +0100 Subject: [PATCH 06/21] fix stockler --- htdocs/core/class/html.formaccounting.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index 373501a7adf..08268d6bb32 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -140,7 +140,7 @@ class FormAccounting extends Form /** * Return list of journals with label by nature * - * @param array $selectids Preselected journal code + * @param array $selectedIds Preselected journal code array * @param string $htmlname Name of field in html form * @param int $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 From f273273129526bb0ecaccf2a42932a96166fa449 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 22 Dec 2020 06:57:55 +0100 Subject: [PATCH 07/21] FIX: Accountancy - Retire entire opening balance feature --- htdocs/accountancy/bookkeeping/balance.php | 46 +++++++++++++++------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 29e56cd4233..961a012f396 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -77,7 +77,7 @@ $form = new Form($db); if (empty($search_date_start) && !GETPOSTISSET('formfilteraction')) { $sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; - $sql .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'"; + $sql .= " WHERE date_start < '".$db->idate(dol_now())."' AND date_end > '".$db->idate(dol_now())."'"; $sql .= $db->plimit(1); $res = $db->query($sql); if ($res->num_rows > 0) { @@ -237,7 +237,7 @@ if ($action != 'export_csv') print ''; print ''; - print ''; print_liste_field_titre("AccountAccounting", $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder); - print_liste_field_titre("OpeningBalance", $_SERVER['PHP_SELF'], "", $param, "", 'class="right"', $sortfield, $sortorder); + // print_liste_field_titre("OpeningBalance", $_SERVER['PHP_SELF'], "", $param, "", 'class="right"', $sortfield, $sortorder); print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre("Balance", $_SERVER["PHP_SELF"], "", $param, "", 'class="right"', $sortfield, $sortorder); @@ -265,10 +265,13 @@ if ($action != 'export_csv') $total_credit = 0; $sous_total_debit = 0; $sous_total_credit = 0; - $total_opening_balance = 0; - $sous_total_opening_balance = 0; + // $total_opening_balance = 0; + // $sous_total_opening_balance = 0; $displayed_account = ""; + // TODO Debug - In French accounting, this functionality is dangerous, it takes all the entries and adds all the accounts + // without time and class limits (Class 6 and 7 accounts ???) and does not take into account the "a-nouveau" journal. + /* $sql = "SELECT t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as t"; $sql .= " WHERE t.entity = ".$conf->entity; // Never do sharing into accounting features @@ -282,6 +285,7 @@ if ($action != 'export_csv') $arr = $resql->fetch_array(); $opening_balances["'".$arr['numero_compte']."'"] = $arr['opening_balance']; } + */ foreach ($object->lines as $line) { @@ -290,8 +294,8 @@ if ($action != 'export_csv') $total_credit += $line->credit; $description = $object->get_compte_desc($line->numero_compte); // Search description of the account $root_account_description = $object->get_compte_racine($line->numero_compte); - $opening_balance = isset($opening_balances["'".$line->numero_compte."'"]) ? $opening_balances["'".$line->numero_compte."'"] : 0; - $total_opening_balance += $opening_balance; + // $opening_balance = isset($opening_balances["'".$line->numero_compte."'"]) ? $opening_balances["'".$line->numero_compte."'"] : 0; + // $total_opening_balance += $opening_balance; if (empty($description)) { $link = ''.img_edit_add().''; } @@ -302,30 +306,34 @@ if ($action != 'export_csv') { // Display a sub-total per account if ($displayed_account != "") { - print ''; + print ''; + // print ''; + print ''; + print ''; + print ''; print "\n"; print ''; } // Show first line of a break print ''; - print ''; + print ''; print ''; $displayed_account = $root_account_description; $sous_total_debit = 0; $sous_total_credit = 0; - $sous_total_opening_balance = 0; + // $sous_total_opening_balance = 0; } // $object->get_compte_racine($line->numero_compte); print ''; print ''; - print ''; + // print ''; print ''; print ''; - print ''; + print ''; print ''; print "\n"; @@ -333,14 +341,22 @@ if ($action != 'export_csv') // Records the sub-total $sous_total_debit += $line->debit; $sous_total_credit += $line->credit; - $sous_total_opening_balance += $opening_balance; + // $sous_total_opening_balance += $opening_balance; } - print ''; + print ''; + // print ''; + print ''; + print ''; + print ''; print "\n"; print ''; - print ''; + print ''; + // print ''; + print ''; + print ''; + print ''; print "\n"; print ''; From 1017fad75406340c08cae59dbc835d9d62034640 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Tue, 22 Dec 2020 16:07:07 +0100 Subject: [PATCH 08/21] NEW add form confirm hook on company card --- htdocs/societe/card.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 0fc33232c5d..486e68f4d83 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2222,10 +2222,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print dol_get_fiche_head($head, 'card', $langs->trans("ThirdParty"), -1, 'company'); + $formconfirm = ''; + // Confirm delete third party if ($action == 'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) { - print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("DeleteACompany"), $langs->trans("ConfirmDeleteCompany"), "confirm_delete", '', 0, "action-delete"); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("DeleteACompany"), $langs->trans("ConfirmDeleteCompany"), "confirm_delete", '', 0, "action-delete"); } if ($action == 'merge') @@ -2239,9 +2241,18 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) ) ); - print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("MergeThirdparties"), $langs->trans("ConfirmMergeThirdparties"), "confirm_merge", $formquestion, 'no', 1, 250); + $formconfirm .= $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("MergeThirdparties"), $langs->trans("ConfirmMergeThirdparties"), "confirm_merge", $formquestion, 'no', 1, 250); } + // Call Hook formConfirm + $parameters = array('formConfirm' => $formconfirm); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; + + // Print form confirm + print $formconfirm; + dol_htmloutput_mesg(is_numeric($error) ? '' : $error, $errors, 'error'); $linkback = ''.$langs->trans("BackToList").''; From 26791714cee70a00bc05243c49645c0d47ee4cff Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 28 Dec 2020 03:07:33 +0100 Subject: [PATCH 09/21] Fix : Introduce constant ACCOUNTANCY_SHOW_OPENING_BALANCE --- htdocs/accountancy/bookkeeping/balance.php | 76 +++++++++++++--------- 1 file changed, 47 insertions(+), 29 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 961a012f396..b71c633b1e5 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -237,7 +237,8 @@ if ($action != 'export_csv') print '
'; + print ''; print $langs->trans('From'); print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, ''); print ' '; @@ -254,7 +254,7 @@ if ($action != 'export_csv') print '
'.$langs->trans("SubTotal").':'.price($sous_total_opening_balance).''.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num($sous_total_credit - $sous_total_debit)).'
'.$langs->trans("SubTotal").':'.price($sous_total_opening_balance).''.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num($sous_total_credit - $sous_total_debit)).' 
'.$line->numero_compte.($root_account_description ? ' - '.$root_account_description : '').''.$line->numero_compte.($root_account_description ? ' - '.$root_account_description : '').'
'.length_accountg($line->numero_compte).''.$description.''.price($opening_balance).''.price($opening_balance).''.price($line->debit).''.price($line->credit).''.price($opening_balance + $line->debit - $line->credit).''.price(/*$opening_balance +*/ $line->debit - $line->credit).''.$link; print '
'.$langs->trans("SubTotal").':'.price($sous_total_opening_balance).''.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num($sous_total_opening_balance + $sous_total_debit - $sous_total_credit, 'MT')).'
'.$langs->trans("SubTotal").':'.price($sous_total_opening_balance).''.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num(/*$sous_total_opening_balance +*/ $sous_total_debit - $sous_total_credit, 'MT')).' 
'.$langs->trans("AccountBalance").':'.price($total_opening_balance).''.price($total_debit).''.price($total_credit).''.price(price2num($total_opening_balance + $total_debit - $total_credit, 'MT')).'
'.$langs->trans("AccountBalance").':'.price($total_opening_balance).''.price($total_debit).''.price($total_credit).''.price(price2num(/*$total_opening_balance +*/ $total_debit - $total_credit, 'MT')).' 
'; print ''; - print ''; print_liste_field_titre("AccountAccounting", $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder); - // print_liste_field_titre("OpeningBalance", $_SERVER['PHP_SELF'], "", $param, "", 'class="right"', $sortfield, $sortorder); + if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) print_liste_field_titre("OpeningBalance", $_SERVER['PHP_SELF'], "", $param, "", 'class="right"', $sortfield, $sortorder); print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre("Balance", $_SERVER["PHP_SELF"], "", $param, "", 'class="right"', $sortfield, $sortorder); @@ -265,27 +266,29 @@ if ($action != 'export_csv') $total_credit = 0; $sous_total_debit = 0; $sous_total_credit = 0; - // $total_opening_balance = 0; - // $sous_total_opening_balance = 0; + if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) { + $total_opening_balance = 0; + $sous_total_opening_balance = 0; + } $displayed_account = ""; // TODO Debug - In French accounting, this functionality is dangerous, it takes all the entries and adds all the accounts // without time and class limits (Class 6 and 7 accounts ???) and does not take into account the "a-nouveau" journal. - /* - $sql = "SELECT t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance"; - $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as t"; - $sql .= " WHERE t.entity = ".$conf->entity; // Never do sharing into accounting features - $sql .= " AND t.doc_date < '".$db->idate($search_date_start)."'"; - $sql .= " GROUP BY t.numero_compte"; + if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) { + $sql = "SELECT t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance"; + $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as t"; + $sql .= " WHERE t.entity = " . $conf->entity; // Never do sharing into accounting features + $sql .= " AND t.doc_date < '" . $db->idate($search_date_start) . "'"; + $sql .= " GROUP BY t.numero_compte"; - $resql = $db->query($sql); - $nrows = $resql->num_rows; - $opening_balances = array(); - for ($i = 0; $i < $nrows; $i++) { - $arr = $resql->fetch_array(); - $opening_balances["'".$arr['numero_compte']."'"] = $arr['opening_balance']; + $resql = $db->query($sql); + $nrows = $resql->num_rows; + $opening_balances = array(); + for ($i = 0; $i < $nrows; $i++) { + $arr = $resql->fetch_array(); + $opening_balances["'" . $arr['numero_compte'] . "'"] = $arr['opening_balance']; + } } - */ foreach ($object->lines as $line) { @@ -294,8 +297,10 @@ if ($action != 'export_csv') $total_credit += $line->credit; $description = $object->get_compte_desc($line->numero_compte); // Search description of the account $root_account_description = $object->get_compte_racine($line->numero_compte); - // $opening_balance = isset($opening_balances["'".$line->numero_compte."'"]) ? $opening_balances["'".$line->numero_compte."'"] : 0; - // $total_opening_balance += $opening_balance; + if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) { + $opening_balance = isset($opening_balances["'".$line->numero_compte."'"]) ? $opening_balances["'".$line->numero_compte."'"] : 0; + $total_opening_balance += $opening_balance; + } if (empty($description)) { $link = ''.img_edit_add().''; } @@ -307,7 +312,7 @@ if ($action != 'export_csv') // Display a sub-total per account if ($displayed_account != "") { print ''; - // print ''; + if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) print ''; print ''; print ''; print ''; @@ -317,23 +322,28 @@ if ($action != 'export_csv') // Show first line of a break print ''; - print ''; + $colspan = (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE) ? 7 : 6); + print ''; print ''; $displayed_account = $root_account_description; $sous_total_debit = 0; $sous_total_credit = 0; - // $sous_total_opening_balance = 0; + if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) $sous_total_opening_balance = 0; } // $object->get_compte_racine($line->numero_compte); print ''; print ''; - // print ''; + if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) print ''; print ''; print ''; - print ''; + if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) { + print ''; + } else { + print ''; + } print ''; print "\n"; @@ -341,22 +351,30 @@ if ($action != 'export_csv') // Records the sub-total $sous_total_debit += $line->debit; $sous_total_credit += $line->credit; - // $sous_total_opening_balance += $opening_balance; + if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) $sous_total_opening_balance += $opening_balance; } print ''; - // print ''; + if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) print ''; print ''; print ''; - print ''; + if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) { + print ''; + } else { + print ''; + } print "\n"; print ''; print ''; - // print ''; + if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) print ''; print ''; print ''; - print ''; + if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) { + print ''; + } else { + print ''; + } print "\n"; print ''; From 3fe495756be00966aa18de72a0afd963f0df4833 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 29 Dec 2020 21:44:41 +0100 Subject: [PATCH 10/21] add $fields in paymentsalary class --- htdocs/salaries/class/paymentsalary.class.php | 296 +++++++++--------- htdocs/salaries/list.php | 270 ++++++++++------ 2 files changed, 323 insertions(+), 243 deletions(-) diff --git a/htdocs/salaries/class/paymentsalary.class.php b/htdocs/salaries/class/paymentsalary.class.php index 6aee986396b..83371cd6f24 100644 --- a/htdocs/salaries/class/paymentsalary.class.php +++ b/htdocs/salaries/class/paymentsalary.class.php @@ -88,6 +88,10 @@ class PaymentSalary extends CommonObject */ public $fk_user_modif; + /** + * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + */ + public $fields = array(); /** * Constructor @@ -120,8 +124,7 @@ class PaymentSalary extends CommonObject $this->note = trim($this->note); // Check parameters - if (empty($this->fk_user) || $this->fk_user < 0) - { + if (empty($this->fk_user) || $this->fk_user < 0) { $this->error = 'ErrorBadParameter'; return -1; } @@ -151,35 +154,29 @@ class PaymentSalary extends CommonObject dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $this->error = "Error ".$this->db->lasterror(); return -1; } // Update extrafield - if (!$error) - { - if (!$error) - { - $result = $this->insertExtraFields(); - if ($result < 0) - { - $error++; - } + if (!$error) { + $result = $this->insertExtraFields(); + if ($result < 0) { + $error++; } } - if (!$notrigger) - { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('PAYMENT_SALARY_MODIFY', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -227,26 +224,24 @@ class PaymentSalary extends CommonObject dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; - $this->ref = $obj->rowid; - $this->tms = $this->db->jdate($obj->tms); + $this->ref = $obj->rowid; + $this->tms = $this->db->jdate($obj->tms); $this->fk_user = $obj->fk_user; - $this->datep = $this->db->jdate($obj->datep); - $this->datev = $this->db->jdate($obj->datev); + $this->datep = $this->db->jdate($obj->datep); + $this->datev = $this->db->jdate($obj->datev); $this->amount = $obj->amount; $this->fk_project = $obj->fk_project; $this->type_payement = $obj->fk_typepayment; $this->num_payment = $obj->num_payment; - $this->label = $obj->label; - $this->datesp = $this->db->jdate($obj->datesp); - $this->dateep = $this->db->jdate($obj->dateep); - $this->note = $obj->note; + $this->label = $obj->label; + $this->datesp = $this->db->jdate($obj->datesp); + $this->dateep = $this->db->jdate($obj->dateep); + $this->note = $obj->note; $this->fk_bank = $obj->fk_bank; $this->fk_user_author = $obj->fk_user_author; $this->fk_user_modif = $obj->fk_user_modif; @@ -282,18 +277,18 @@ class PaymentSalary extends CommonObject // Call trigger $result = $this->call_trigger('PAYMENT_SALARY_DELETE', $user); - if ($result < 0) return -1; + if ($result < 0) { + return -1; + } // End call triggers // Delete donation - if (!$error) - { + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_salary_extrafields"; $sql .= " WHERE fk_object=".$this->id; $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $this->errors[] = $this->db->lasterror(); $error++; } @@ -304,8 +299,7 @@ class PaymentSalary extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $this->error = "Error ".$this->db->lasterror(); return -1; } @@ -326,7 +320,7 @@ class PaymentSalary extends CommonObject $this->id = 0; $this->tms = ''; - $this->fk_user = ''; + $this->fk_user = 1; $this->datep = ''; $this->datev = ''; $this->amount = ''; @@ -335,8 +329,8 @@ class PaymentSalary extends CommonObject $this->dateep = ''; $this->note = ''; $this->fk_bank = ''; - $this->fk_user_author = ''; - $this->fk_user_modif = ''; + $this->fk_user_author = 1; + $this->fk_user_modif = 1; } /** @@ -356,34 +350,29 @@ class PaymentSalary extends CommonObject $this->amount = price2num(trim($this->amount)); $this->label = trim($this->label); $this->note = trim($this->note); - $this->fk_bank = trim($this->fk_bank); - $this->fk_user_author = trim($this->fk_user_author); - $this->fk_user_modif = trim($this->fk_user_modif); + $this->fk_bank = (int) $this->fk_bank; + $this->fk_user_author = (int) $this->fk_user_author; + $this->fk_user_modif = (int) $this->fk_user_modif; // Check parameters - if (!$this->label) - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); + if (!$this->label) { + $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); return -3; } - if ($this->fk_user < 0 || $this->fk_user == '') - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Employee")); + if ($this->fk_user <= 0 || $this->fk_user == '') { + $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Employee")); return -4; } - if ($this->amount < 0 || $this->amount == '') - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); + if ($this->amount < 0 || $this->amount == '') { + $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); return -5; } - if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); + if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) { + $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); return -6; } - if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); + if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) { + $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); return -7; } @@ -398,7 +387,9 @@ class PaymentSalary extends CommonObject $sql .= ", salary"; $sql .= ", fk_typepayment"; $sql .= ", num_payment"; - if ($this->note) $sql .= ", note"; + if ($this->note) { + $sql .= ", note"; + } $sql .= ", label"; $sql .= ", datesp"; $sql .= ", dateep"; @@ -416,7 +407,9 @@ class PaymentSalary extends CommonObject $sql .= ", ".($this->salary > 0 ? $this->salary : "null"); $sql .= ", ".$this->db->escape($this->type_payment); $sql .= ", '".$this->db->escape($this->num_payment)."'"; - if ($this->note) $sql .= ", '".$this->db->escape($this->note)."'"; + if ($this->note) { + $sql .= ", '".$this->db->escape($this->note)."'"; + } $sql .= ", '".$this->db->escape($this->label)."'"; $sql .= ", '".$this->db->idate($this->datesp)."'"; $sql .= ", '".$this->db->idate($this->dateep)."'"; @@ -428,30 +421,25 @@ class PaymentSalary extends CommonObject dol_syslog(get_class($this)."::create", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_salary"); - if ($this->id > 0) - { - if (!empty($conf->banque->enabled) && !empty($this->amount)) - { + if ($this->id > 0) { + if (!empty($conf->banque->enabled) && !empty($this->amount)) { // Insert into llx_bank require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $acc = new Account($this->db); $result = $acc->fetch($this->accountid); - if ($result <= 0) dol_print_error($this->db); + if ($result <= 0) { + dol_print_error($this->db); + } // Update extrafield if (!$error) { - if (!$error) - { - $result = $this->insertExtraFields(); - if ($result < 0) - { - $error++; - } + $result = $this->insertExtraFields(); + if ($result < 0) { + $error++; } } @@ -473,22 +461,19 @@ class PaymentSalary extends CommonObject // Update fk_bank into llx_paiement. // So we know the payment which has generate the banking ecriture - if ($bank_line_id > 0) - { + if ($bank_line_id > 0) { $this->update_fk_bank($bank_line_id); } else { $this->error = $acc->error; $error++; } - if (!$error) - { + if (!$error) { // Add link 'payment_salary' in bank_url between payment and bank transaction $url = DOL_URL_ROOT.'/salaries/card.php?id='; $result = $acc->add_url_line($bank_line_id, $this->id, $url, "(SalaryPayment)", "payment_salary"); - if ($result <= 0) - { + if ($result <= 0) { $this->error = $acc->error; $error++; } @@ -507,8 +492,7 @@ class PaymentSalary extends CommonObject 'user' ); - if ($result <= 0) - { + if ($result <= 0) { $this->error = $acc->error; $error++; } @@ -516,12 +500,15 @@ class PaymentSalary extends CommonObject // Call trigger $result = $this->call_trigger('PAYMENT_SALARY_CREATE', $user); - if ($result < 0) $error++; + if ($result < 0) { + $error++; + } // End call triggers - } else $error++; + } else { + $error++; + } - if (!$error) - { + if (!$error) { $this->db->commit(); return $this->id; } else { @@ -548,8 +535,7 @@ class PaymentSalary extends CommonObject $sql = 'UPDATE '.MAIN_DB_PREFIX.'payment_salary SET fk_bank = '.$id_bank; $sql .= ' WHERE rowid = '.$this->id; $result = $this->db->query($sql); - if ($result) - { + if ($result) { return 1; } else { dol_print_error($this->db); @@ -574,7 +560,9 @@ class PaymentSalary extends CommonObject global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; - if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) { + $notooltip = 1; // Force disable tooltips + } $result = ''; @@ -583,10 +571,11 @@ class PaymentSalary extends CommonObject if (!empty($this->label)) { $labeltoshow = $this->label; $reg = array(); - if (preg_match('/^\((.*)\)$/i', $this->label, $reg)) - { + if (preg_match('/^\((.*)\)$/i', $this->label, $reg)) { // Label generique car entre parentheses. On l'affiche en le traduisant - if ($reg[1] == 'paiement') $reg[1] = 'Payment'; + if ($reg[1] == 'paiement') { + $reg[1] = 'Payment'; + } $labeltoshow = $langs->trans($reg[1]); } $label .= '
'.$langs->trans('Label').': '.$labeltoshow; @@ -594,19 +583,20 @@ class PaymentSalary extends CommonObject $url = DOL_URL_ROOT.'/salaries/card.php?id='.$this->id; - if ($option != 'nolink') - { + if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + $add_save_lastsearch_values = 1; + } + if ($add_save_lastsearch_values) { + $url .= '&save_lastsearch_values=1'; + } } $linkclose = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowMyObject"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } @@ -614,20 +604,26 @@ class PaymentSalary extends CommonObject $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; /* - $hookmanager->initHooks(array('myobjectdao')); - $parameters=array('id'=>$this->id); - $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) $linkclose = $hookmanager->resPrint; - */ - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + $hookmanager->initHooks(array('myobjectdao')); + $parameters=array('id'=>$this->id); + $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $linkclose = $hookmanager->resPrint; + */ + } else { + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } $linkstart = ''; $linkend = ''; $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) $result .= $this->ref; + if ($withpicto) { + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + } + if ($withpicto != 2) { + $result .= $this->ref; + } $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); @@ -635,8 +631,11 @@ class PaymentSalary extends CommonObject $hookmanager->initHooks(array('salarypayment')); $parameters = array('id'=>$this->id, 'getnomurl'=>$result); $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) $result = $hookmanager->resPrint; - else $result .= $hookmanager->resPrint; + if ($reshook > 0) { + $result = $hookmanager->resPrint; + } else { + $result .= $hookmanager->resPrint; + } return $result; } @@ -656,14 +655,11 @@ class PaymentSalary extends CommonObject dol_syslog(get_class($this).'::info', LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { + if ($result) { + if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; - if ($obj->fk_user_author) - { + if ($obj->fk_user_author) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); $this->user_creation = $cuser; @@ -703,40 +699,40 @@ class PaymentSalary extends CommonObject $langs->load('compta'); /*if ($mode == 0) - { - if ($status == 0) return $langs->trans('ToValidate'); - if ($status == 1) return $langs->trans('Validated'); - } - if ($mode == 1) - { - if ($status == 0) return $langs->trans('ToValidate'); - if ($status == 1) return $langs->trans('Validated'); - } - if ($mode == 2) - { - if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate'); - if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated'); - } - if ($mode == 3) - { - if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1'); - if ($status == 1) return img_picto($langs->trans('Validated'),'statut4'); - } - if ($mode == 4) - { - if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate'); - if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated'); - } - if ($mode == 5) - { - if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1'); - if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4'); - } - if ($mode == 6) - { - if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1'); - if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4'); - }*/ + { + if ($status == 0) return $langs->trans('ToValidate'); + if ($status == 1) return $langs->trans('Validated'); + } + if ($mode == 1) + { + if ($status == 0) return $langs->trans('ToValidate'); + if ($status == 1) return $langs->trans('Validated'); + } + if ($mode == 2) + { + if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate'); + if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated'); + } + if ($mode == 3) + { + if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1'); + if ($status == 1) return img_picto($langs->trans('Validated'),'statut4'); + } + if ($mode == 4) + { + if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate'); + if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated'); + } + if ($mode == 5) + { + if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1'); + if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4'); + } + if ($mode == 6) + { + if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1'); + if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4'); + }*/ return ''; } } diff --git a/htdocs/salaries/list.php b/htdocs/salaries/list.php index b8a0ba69ef7..8d253e6799a 100644 --- a/htdocs/salaries/list.php +++ b/htdocs/salaries/list.php @@ -26,7 +26,9 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; +if (!empty($conf->accounting->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; +} // Load translation files required by the page $langs->loadLangs(array("compta", "salaries", "bills", "hrm")); @@ -46,12 +48,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { + $page = 0; +} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortfield) $sortfield = "s.datep,s.rowid"; -if (!$sortorder) $sortorder = "DESC,DESC"; +if (!$sortfield) { + $sortfield = "s.datep,s.rowid"; +} +if (!$sortorder) { + $sortorder = "DESC,DESC"; +} // Initialize technical objects $object = new PaymentSalary($db); @@ -64,8 +72,12 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); -if (!$sortfield) $sortfield = "s.datep,s.rowid"; -if (!$sortorder) $sortorder = "DESC,DESC"; +if (!$sortfield) { + $sortfield = "s.datep,s.rowid"; +} +if (!$sortorder) { + $sortorder = "DESC,DESC"; +} $search_ref = GETPOST('search_ref', 'int'); $search_user = GETPOST('search_user', 'alpha'); @@ -77,14 +89,14 @@ $search_account = GETPOST('search_account', 'int'); $filtre = GETPOST("filtre", 'restricthtml'); -if (!GETPOST('search_type_id', 'int')) -{ +if (!GETPOST('search_type_id', 'int')) { $newfiltre = str_replace('filtre=', '', $filtre); $filterarray = explode('-', $newfiltre); - foreach ($filterarray as $val) - { + foreach ($filterarray as $val) { $part = explode(':', $val); - if ($part[0] == 's.fk_typepayment') $search_type_id = $part[1]; + if ($part[0] == 's.fk_typepayment') { + $search_type_id = $part[1]; + } } } else { $search_type_id = GETPOST('search_type_id', 'int'); @@ -94,22 +106,27 @@ $childids = $user->getAllChildIds(1); // Security check $socid = GETPOST("socid", "int"); -if ($user->socid) $socid = $user->socid; +if ($user->socid) { + $socid = $user->socid; +} $result = restrictedArea($user, 'salaries', '', '', ''); // Initialize array of search criterias $search_all = GETPOST("search_all", 'alpha'); $search = array(); -foreach ($object->fields as $key => $val) -{ - if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha'); +var_dump($object->fields); +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha') !== '') { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } } // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); -foreach ($object->fields as $key => $val) -{ - if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; +foreach ($object->fields as $key => $val) { + if ($val['searchall']) { + $fieldstosearchall['t.'.$key] = $val['label']; + } } $permissiontoread = $user->rights->salaries->read; @@ -121,21 +138,25 @@ $permissiontodelete = $user->rights->salaries->delete; * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers - { + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers $search_ref = ""; $search_user = ""; $search_label = ""; @@ -146,8 +167,7 @@ if (empty($reshook)) $search_type_id = ""; } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') - || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) - { + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } @@ -158,8 +178,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; // Validate records - if (!$error && $massaction == 'buildsepa' && $permissiontoadd) - { + if (!$error && $massaction == 'buildsepa' && $permissiontoadd) { $objecttmp = new $objectclass($db); // TODO @@ -192,16 +211,32 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.ro $sql .= " ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE u.rowid = s.fk_user"; $sql .= " AND s.entity IN (".getEntity('payment_salaries').")"; -if (empty($user->rights->salaries->readall)) $sql .= " AND s.fk_user IN (".join(',', $childids).")"; +if (empty($user->rights->salaries->readall)) { + $sql .= " AND s.fk_user IN (".join(',', $childids).")"; +} // Search criteria -if ($search_ref) $sql .= " AND s.rowid=".((int) $search_ref); -if ($search_user) $sql .= natural_search(array('u.login', 'u.lastname', 'u.firstname', 'u.email'), $search_user); -if ($search_label) $sql .= natural_search(array('s.label'), $search_label); -if ($search_date_start) $sql .= " AND s.datep >= '".$db->idate($search_date_start)."'"; -if ($search_date_end) $sql .= " AND s.datep <= '".$db->idate($search_date_end)."'"; -if ($search_amount) $sql .= natural_search("s.amount", $search_amount, 1); -if ($search_account > 0) $sql .= " AND b.fk_account=".((int) $search_account); +if ($search_ref) { + $sql .= " AND s.rowid=".((int) $search_ref); +} +if ($search_user) { + $sql .= natural_search(array('u.login', 'u.lastname', 'u.firstname', 'u.email'), $search_user); +} +if ($search_label) { + $sql .= natural_search(array('s.label'), $search_label); +} +if ($search_date_start) { + $sql .= " AND s.datep >= '".$db->idate($search_date_start)."'"; +} +if ($search_date_end) { + $sql .= " AND s.datep <= '".$db->idate($search_date_end)."'"; +} +if ($search_amount) { + $sql .= natural_search("s.amount", $search_amount, 1); +} +if ($search_account > 0) { + $sql .= " AND b.fk_account=".((int) $search_account); +} if ($filtre) { $filtre = str_replace(":", "=", $filtre); $sql .= " AND ".$filtre; @@ -213,26 +248,24 @@ $sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); $nbtotalofrecords = $db->num_rows($resql); - if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 $page = 0; $offset = 0; } } // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. -if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) -{ +if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { $num = $nbtotalofrecords; } else { - if ($limit) $sql .= $db->plimit($limit + 1, $offset); + if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); + } $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($db); exit; } @@ -248,16 +281,36 @@ llxHeader('', $title, $help_url); $arrayofselected = is_array($toselect) ? $toselect : array(); $param = ''; -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); -if ($search_type_id) $param .= '&search_type_id='.urlencode($search_type_id); -if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); -if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); -if ($search_user > 0) $param .= '&search_user='.urlencode($search_user); -if ($search_label) $param .= '&search_label='.urlencode($search_label); -if ($search_account) $param .= '&search_account='.urlencode($search_account); -if ($search_date_start) $param .= '&search_date_startday='.urlencode(GETPOST('search_date_startday', 'int')).'&search_date_startmonth='.urlencode(GETPOST('search_date_startmonth', 'int')).'&search_date_startyear='.urlencode(GETPOST('search_date_startyear', 'int')); -if ($search_date_end) $param .= '&search_date_endday='.urlencode(GETPOST('search_date_endday', 'int')).'&search_date_endmonth='.urlencode(GETPOST('search_date_endmonth', 'int')).'&search_date_endyear='.urlencode(GETPOST('search_date_endyear', 'int')); +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); +} +if ($search_type_id) { + $param .= '&search_type_id='.urlencode($search_type_id); +} +if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); +} +if ($search_ref) { + $param .= '&search_ref='.urlencode($search_ref); +} +if ($search_user > 0) { + $param .= '&search_user='.urlencode($search_user); +} +if ($search_label) { + $param .= '&search_label='.urlencode($search_label); +} +if ($search_account) { + $param .= '&search_account='.urlencode($search_account); +} +if ($search_date_start) { + $param .= '&search_date_startday='.urlencode(GETPOST('search_date_startday', 'int')).'&search_date_startmonth='.urlencode(GETPOST('search_date_startmonth', 'int')).'&search_date_startyear='.urlencode(GETPOST('search_date_startyear', 'int')); +} +if ($search_date_end) { + $param .= '&search_date_endday='.urlencode(GETPOST('search_date_endday', 'int')).'&search_date_endmonth='.urlencode(GETPOST('search_date_endmonth', 'int')).'&search_date_endyear='.urlencode(GETPOST('search_date_endyear', 'int')); +} // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -267,11 +320,15 @@ $arrayofmassactions = array( //'buildsepa'=>$langs->trans("BuildSepa"), // TODO ); //if ($permissiontodelete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); +} $massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '
'; -if ($optioncss != '') print ''; +if ($optioncss != '') { + print ''; +} print ''; print ''; print ''; @@ -280,7 +337,9 @@ print ''; print ''; $url = DOL_URL_ROOT.'/salaries/card.php?action=create'; -if (!empty($socid)) $url .= '&socid='.$socid; +if (!empty($socid)) { + $url .= '&socid='.$socid; +} $newcardbutton = dolGetButtonTitle($langs->trans('NewSalaryPayment'), '', 'fa fa-plus-circle', $url, '', $user->rights->salaries->write); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $totalnboflines, 'object_payment', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -323,8 +382,7 @@ print '
'; // Account -if (!empty($conf->banque->enabled)) -{ +if (!empty($conf->banque->enabled)) { print ''; @@ -356,7 +414,9 @@ print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "s.label", "", $param, 'c print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "s.datep,s.rowid", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("DateValue", $_SERVER["PHP_SELF"], "s.datev,s.rowid", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("PaymentMode", $_SERVER["PHP_SELF"], "type", "", $param, 'class="left"', $sortfield, $sortorder); -if (!empty($conf->banque->enabled)) print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); +if (!empty($conf->banque->enabled)) { + print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); +} print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "s.amount", "", $param, 'class="right"', $sortfield, $sortorder); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; @@ -371,11 +431,11 @@ print ''."\n"; // Detect if we need a fetch on each output line $needToFetchEachLine = 0; -if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) -{ - foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) - { - if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object +if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { + foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { + if (preg_match('/\$object/', $val)) { + $needToFetchEachLine++; // There is at least one compute field that use $object + } } } @@ -384,10 +444,11 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co $i = 0; $total = 0; $totalarray = array(); -while ($i < ($limit ? min($num, $limit) : $num)) -{ +while ($i < ($limit ? min($num, $limit) : $num)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) { + break; // Should not happen + } // Store properties in $object $object->setVarsFromFetchObj($obj); @@ -409,41 +470,50 @@ while ($i < ($limit ? min($num, $limit) : $num)) // Ref print "\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } // Employee print "\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } // Label payment print "\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } // Date payment print '\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } // Date value print '\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } // Type print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } // Account - if (!empty($conf->banque->enabled)) - { + if (!empty($conf->banque->enabled)) { print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Amount print ''; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield'; + } $totalarray['val']['totalttcfield'] += $obj->amount; // Extra fields @@ -472,14 +550,17 @@ while ($i < ($limit ? min($num, $limit) : $num)) print $hookmanager->resPrint; // Action column print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print ''."\n"; @@ -491,10 +572,13 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found -if ($num == 0) -{ +if ($num == 0) { $colspan = 1; - foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } print ''; } From 8d526f8f79003def92face3bbd296d2143d788d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 29 Dec 2020 21:48:53 +0100 Subject: [PATCH 11/21] remove debug --- htdocs/salaries/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/salaries/list.php b/htdocs/salaries/list.php index 8d253e6799a..2b700108d10 100644 --- a/htdocs/salaries/list.php +++ b/htdocs/salaries/list.php @@ -114,7 +114,6 @@ $result = restrictedArea($user, 'salaries', '', '', ''); // Initialize array of search criterias $search_all = GETPOST("search_all", 'alpha'); $search = array(); -var_dump($object->fields); foreach ($object->fields as $key => $val) { if (GETPOST('search_'.$key, 'alpha') !== '') { $search[$key] = GETPOST('search_'.$key, 'alpha'); @@ -139,7 +138,8 @@ $permissiontodelete = $user->rights->salaries->delete; */ if (GETPOST('cancel', 'alpha')) { - $action = 'list'; $massaction = ''; + $action = 'list'; + $massaction = ''; } if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; From 0e2b7d8b3c9fc50d01239cdd01929e5e2ed141d9 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 30 Dec 2020 07:23:26 +0100 Subject: [PATCH 12/21] Remove typo --- htdocs/compta/bank/various_payment/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index ddad89e22fc..0e3c80a6ef8 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -392,7 +392,7 @@ if ($action == 'create') // Subledger account if (!empty($conf->accounting->enabled)) { - print ''; + print ''; print '
'; + $colspan = (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE) ? 6 : 5); + print ''; print $langs->trans('From'); print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, ''); print ' '; @@ -254,7 +255,7 @@ if ($action != 'export_csv') print '
'.$langs->trans("SubTotal").':'.price($sous_total_opening_balance).''.price($sous_total_opening_balance).''.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num($sous_total_credit - $sous_total_debit)).'
'.$line->numero_compte.($root_account_description ? ' - '.$root_account_description : '').''.$line->numero_compte.($root_account_description ? ' - '.$root_account_description : '').'
'.length_accountg($line->numero_compte).''.$description.''.price($opening_balance).''.price($opening_balance).''.price($line->debit).''.price($line->credit).''.price(/*$opening_balance +*/ $line->debit - $line->credit).''.price($opening_balance + $line->debit - $line->credit).''.price($line->debit - $line->credit).''.$link; print '
'.$langs->trans("SubTotal").':'.price($sous_total_opening_balance).''.price($sous_total_opening_balance).''.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num(/*$sous_total_opening_balance +*/ $sous_total_debit - $sous_total_credit, 'MT')).'' . price(price2num($sous_total_opening_balance + $sous_total_debit - $sous_total_credit, 'MT')) . '' . price(price2num($sous_total_debit - $sous_total_credit, 'MT')) . ' 
'.$langs->trans("AccountBalance").':'.price($total_opening_balance).''.price($total_opening_balance).''.price($total_debit).''.price($total_credit).''.price(price2num(/*$total_opening_balance +*/ $total_debit - $total_credit, 'MT')).'' . price(price2num($total_opening_balance + $total_debit - $total_credit, 'MT')) . '' . price(price2num($total_debit - $total_credit, 'MT')) . ' 
'; $form->select_types_paiements($search_type_id, 'search_type_id', '', 0, 1, 1, 16); print ''; $form->select_comptes($search_account, 'search_account', 0, '', 1); print '
".$salstatic->getNomUrl(1)."".$userstatic->getNomUrl(1)."".dol_trunc($obj->label, 40)."'.dol_print_date($db->jdate($obj->datep), 'day')."'.dol_print_date($db->jdate($obj->datev), 'day')."'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.''; - if ($obj->fk_bank > 0) - { + if ($obj->fk_bank > 0) { //$accountstatic->fetch($obj->fk_bank); $accountstatic->id = $obj->bid; $accountstatic->ref = $obj->bref; $accountstatic->number = $obj->bnumber; - if (!empty($conf->accounting->enabled)) - { + if (!empty($conf->accounting->enabled)) { $accountstatic->account_number = $obj->account_number; $accountingjournal = new AccountingJournal($db); @@ -453,15 +523,23 @@ while ($i < ($limit ? min($num, $limit) : $num)) } $accountstatic->label = $obj->blabel; print $accountstatic->getNomUrl(1); - } else print ' '; + } else { + print ' '; + } print ''.price($obj->amount).''; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($object->id, $arrayofselected)) $selected = 1; + if (in_array($object->id, $arrayofselected)) { + $selected = 1; + } print ''; } print '
'.$langs->trans("NoRecordFound").'
'.$langs->trans("SubledgerAccount").'aaaa
'.$langs->trans("SubledgerAccount").''; if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { From a336e4509802386f15c50afa977b5bd521ca475a Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 30 Dec 2020 08:11:20 +0100 Subject: [PATCH 13/21] FIX: #15751 Miscellaneous payment type change to 0 after updating subledger --- htdocs/compta/bank/class/paymentvarious.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index aec104028c0..348c24acd83 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -137,7 +137,7 @@ class PaymentVarious extends CommonObject $sql .= " datev='".$this->db->idate($this->datev)."',"; $sql .= " sens=".(int) $this->sens.","; $sql .= " amount=".price2num($this->amount).","; - $sql .= " fk_typepayment=".(int) $this->fk_typepayment.","; + $sql .= " fk_typepayment=".(int) $this->type_payment.","; $sql .= " num_payment='".$this->db->escape($this->num_payment)."',"; $sql .= " label='".$this->db->escape($this->label)."',"; $sql .= " note='".$this->db->escape($this->note)."',"; From 87a452c6f401eb63e8161fb4740948a9d8f990a4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 30 Dec 2020 12:16:01 +0100 Subject: [PATCH 14/21] Fix warning --- htdocs/user/class/user.class.php | 2 +- htdocs/webservices/server_contact.php | 6 +++--- htdocs/webservices/server_order.php | 4 ++-- htdocs/webservices/server_other.php | 6 +++--- htdocs/webservices/server_user.php | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 98e70cf66b7..7f9c87ab7a7 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1806,7 +1806,7 @@ class User extends CommonObject $adh->pass = $this->pass; - $adh->societe = (empty($adh->societe) && $this->societe_id ? $this->societe_id : $adh->societe); + //$adh->societe = (empty($adh->societe) && $this->societe_id ? $this->societe_id : $adh->societe); $adh->address = $this->address; $adh->town = $this->town; diff --git a/htdocs/webservices/server_contact.php b/htdocs/webservices/server_contact.php index 6fc521a43c7..97b219c7aba 100644 --- a/htdocs/webservices/server_contact.php +++ b/htdocs/webservices/server_contact.php @@ -270,10 +270,10 @@ function getContact($authentication, $id, $ref_ext) if ($result > 0) { // Only internal user who have contact read permission - // Or for external user who have contact read permission, with restrict on societe_id + // Or for external user who have contact read permission, with restrict on socid if ( - $fuser->rights->societe->contact->lire && !$fuser->societe_id - || ($fuser->rights->societe->contact->lire && ($fuser->societe_id == $contact->socid)) + $fuser->rights->societe->contact->lire && !$fuser->socid + || ($fuser->rights->societe->contact->lire && ($fuser->socid == $contact->socid)) ) { $contact_result_fields = array( 'id' => $contact->id, diff --git a/htdocs/webservices/server_order.php b/htdocs/webservices/server_order.php index 361b2a08f4a..5cc964dde4e 100644 --- a/htdocs/webservices/server_order.php +++ b/htdocs/webservices/server_order.php @@ -367,7 +367,7 @@ function getOrder($authentication, $id = '', $ref = '', $ref_ext = '') $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); - if ($fuser->societe_id) $socid = $fuser->societe_id; + if ($fuser->socid) $socid = $fuser->socid; // Check parameters if (!$error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext))) @@ -516,7 +516,7 @@ function getOrdersForThirdParty($authentication, $idthirdparty) $error = 0; $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); - if ($fuser->societe_id) $socid = $fuser->societe_id; + if ($fuser->socid) $socid = $fuser->socid; // Check parameters if (!$error && empty($idthirdparty)) diff --git a/htdocs/webservices/server_other.php b/htdocs/webservices/server_other.php index 61f53f7e275..3494f928cde 100644 --- a/htdocs/webservices/server_other.php +++ b/htdocs/webservices/server_other.php @@ -208,7 +208,7 @@ function getDocument($authentication, $modulepart, $file, $refname = '') $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); - if ($fuser->societe_id) $socid = $fuser->societe_id; + if ($fuser->socid) $socid = $fuser->socid; // Check parameters if (!$error && (!$file || !$modulepart)) @@ -234,7 +234,7 @@ function getDocument($authentication, $modulepart, $file, $refname = '') $original_file = $check_access['original_file']; // Basic protection (against external users only) - if ($fuser->societe_id > 0) + if ($fuser->socid > 0) { if ($sqlprotectagainstexternals) { @@ -246,7 +246,7 @@ function getDocument($authentication, $modulepart, $file, $refname = '') while ($i < $num) { $obj = $db->fetch_object($resql); - if ($fuser->societe_id != $obj->fk_soc) + if ($fuser->socid != $obj->fk_soc) { $accessallowed = 0; break; diff --git a/htdocs/webservices/server_user.php b/htdocs/webservices/server_user.php index 8619a952ea1..6c4e472d1c7 100644 --- a/htdocs/webservices/server_user.php +++ b/htdocs/webservices/server_user.php @@ -485,7 +485,7 @@ function createUserFromThirdparty($authentication, $thirdpartywithuser) $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); - if ($fuser->societe_id) $socid = $fuser->societe_id; + if ($fuser->socid) $socid = $fuser->socid; if (!$error && !$thirdpartywithuser) { @@ -502,7 +502,7 @@ function createUserFromThirdparty($authentication, $thirdpartywithuser) $thirdparty = new Societe($db); // If a contact / company already exists with the email, return the corresponding socid - $sql = "SELECT s.rowid as societe_id FROM ".MAIN_DB_PREFIX."societe as s"; + $sql = "SELECT s.rowid as socid FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON sp.fk_soc = s.rowid"; $sql .= " WHERE s.entity=".$conf->entity; $sql .= " AND s.email='".$db->escape($thirdpartywithuser['email'])."'"; @@ -690,7 +690,7 @@ function setUserPassword($authentication, $shortuser) $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); - if ($fuser->societe_id) $socid = $fuser->societe_id; + if ($fuser->socid) $socid = $fuser->socid; if (!$error && !$shortuser) { From 7e9fcfe6649b681aa1e98c100c9c776c211db54c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 30 Dec 2020 12:31:33 +0100 Subject: [PATCH 15/21] Fix warning --- htdocs/webservices/server_order.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/webservices/server_order.php b/htdocs/webservices/server_order.php index 5cc964dde4e..7f2f2ebd43f 100644 --- a/htdocs/webservices/server_order.php +++ b/htdocs/webservices/server_order.php @@ -387,10 +387,10 @@ function getOrder($authentication, $id = '', $ref = '', $ref_ext = '') if ($result > 0) { // Security for external user - if ($socid && ($socid != $order->socid)) + if ($socid && (empty($order->socid) || $socid != $order->socid)) { $error++; - $errorcode = 'PERMISSION_DENIED'; $errorlabel = $order->socid.'User does not have permission for this request'; + $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request'; } if (!$error) From e34fb394a0078ac8e19a14d6059b796166c3d8fc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 30 Dec 2020 12:38:45 +0100 Subject: [PATCH 16/21] Fix warning --- htdocs/webservices/server_productorservice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/webservices/server_productorservice.php b/htdocs/webservices/server_productorservice.php index d35dc705b6f..f04ade49f05 100644 --- a/htdocs/webservices/server_productorservice.php +++ b/htdocs/webservices/server_productorservice.php @@ -154,7 +154,7 @@ if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafie } } -if (is_array($extrafield_array)) $productorservice_fields = array_merge($productorservice_fields, $extrafield_array); +if (!empty($extrafield_array) && is_array($extrafield_array)) $productorservice_fields = array_merge($productorservice_fields, $extrafield_array); // Define other specific objects $server->wsdl->addComplexType( From a77d0d90ffca061f2106f78e105af6750cf4d645 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 30 Dec 2020 11:46:33 +0000 Subject: [PATCH 17/21] Fixing style errors. --- htdocs/webservices/server_productorservice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/webservices/server_productorservice.php b/htdocs/webservices/server_productorservice.php index c8475089212..3b2110b9602 100644 --- a/htdocs/webservices/server_productorservice.php +++ b/htdocs/webservices/server_productorservice.php @@ -158,7 +158,7 @@ if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafie } if (!empty($extrafield_array) && is_array($extrafield_array)) { - $productorservice_fields = array_merge($productorservice_fields, $extrafield_array); + $productorservice_fields = array_merge($productorservice_fields, $extrafield_array); } // Define other specific objects From 6a63fea184d0d0c2dfe8378acb4d6dc61968cadb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 30 Dec 2020 13:00:10 +0100 Subject: [PATCH 18/21] FIX #15817 --- htdocs/salaries/class/paymentsalary.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/salaries/class/paymentsalary.class.php b/htdocs/salaries/class/paymentsalary.class.php index 6aee986396b..807d3537775 100644 --- a/htdocs/salaries/class/paymentsalary.class.php +++ b/htdocs/salaries/class/paymentsalary.class.php @@ -88,6 +88,11 @@ class PaymentSalary extends CommonObject */ public $fk_user_modif; + /** + * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + */ + public $fields = array(); + /** * Constructor From e5da047134964ecb8c2d1d2b5f9f27abe1887663 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 30 Dec 2020 13:16:38 +0100 Subject: [PATCH 19/21] Update index.php --- htdocs/accountancy/admin/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index 6a33d009765..7eae1eb6536 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -48,7 +48,7 @@ $action = GETPOST('action', 'aZ09'); $list = array( 'ACCOUNTING_LENGTH_GACCOUNT', 'ACCOUNTING_LENGTH_AACCOUNT', - 'ACCOUNTING_LIMIT_LIST_VENTILATION' +// 'ACCOUNTING_LIMIT_LIST_VENTILATION' // there is already a global parameter to define the nb of records in lists, we must use it in priority. Having one parameter for nb of record for each page is deprecated. // 'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc // 'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc ); From 7165bd43d999cb170b6f484b9ffa03385081d62b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 30 Dec 2020 13:17:57 +0100 Subject: [PATCH 20/21] Update modAccounting.class.php --- htdocs/core/modules/modAccounting.class.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 7eff70422ee..811dd57544e 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -154,12 +154,6 @@ class modAccounting extends DolibarrModules "csv", "", 0, 'current', 0 ); - $this->const[14] = array( - "ACCOUNTING_LIMIT_LIST_VENTILATION", - "chaine", - "50", - "", 0, 'current', 0 - ); // Tabs $this->tabs = array(); From b6e33771be7bc98dc44ce462f2f85d4f2da9b55c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 30 Dec 2020 13:19:15 +0100 Subject: [PATCH 21/21] Update accountancy.lang --- htdocs/langs/en_US/accountancy.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index c35d85e7bcb..7d1e9bf4fbc 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -144,7 +144,7 @@ NotVentilatedinAccount=Not bound to the accounting account XLineSuccessfullyBinded=%s products/services successfully bound to an accounting account XLineFailedToBeBinded=%s products/services were not bound to any accounting account -ACCOUNTING_LIMIT_LIST_VENTILATION=Number of elements to on list and bind shown by page (maximum recommended: 50) +ACCOUNTING_LIMIT_LIST_VENTILATION=Maximum number of lines on list and bind page (recommended: 50) ACCOUNTING_LIST_SORT_VENTILATION_TODO=Begin the sorting of the page "Binding to do" by the most recent elements ACCOUNTING_LIST_SORT_VENTILATION_DONE=Begin the sorting of the page "Binding done" by the most recent elements