From 518a225f7baa8f577877392562f1906aa86723ab Mon Sep 17 00:00:00 2001 From: jcp Date: Tue, 3 Nov 2020 19:48:23 +0100 Subject: [PATCH 001/214] 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 002/214] 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 003/214] 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 004/214] 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 005/214] 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 006/214] 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 50d530733e7450ff3481baead7cbfb51a9e9fd26 Mon Sep 17 00:00:00 2001 From: jcp Date: Mon, 9 Nov 2020 13:17:24 +0100 Subject: [PATCH 007/214] NEW: ICS fields moved into bank account table --- htdocs/admin/paymentbybanktransfer.php | 6 ++- htdocs/admin/prelevement.php | 9 ++++- htdocs/compta/bank/card.php | 22 ++++++++++- htdocs/compta/bank/class/account.class.php | 20 +++++++++- htdocs/compta/paymentbybanktransfer/index.php | 2 +- .../class/bonprelevement.class.php | 7 ++-- htdocs/compta/prelevement/create.php | 39 +++++++++++++++---- htdocs/core/lib/prelevement.lib.php | 18 ++++++--- .../bank/doc/pdf_sepamandate.modules.php | 2 +- htdocs/langs/en_US/withdrawals.lang | 6 ++- 10 files changed, 107 insertions(+), 24 deletions(-) diff --git a/htdocs/admin/paymentbybanktransfer.php b/htdocs/admin/paymentbybanktransfer.php index 6a419d39e53..5449e927a4f 100644 --- a/htdocs/admin/paymentbybanktransfer.php +++ b/htdocs/admin/paymentbybanktransfer.php @@ -71,10 +71,10 @@ if ($action == "set") if (! $res > 0) $error++; */ } else $error++; - +/* Moved to account $res = dolibarr_set_const($db, "PAYMENTBYBANKTRANSFER_ICS", GETPOST("PAYMENTBYBANKTRANSFER_ICS"), 'chaine', 0, '', $conf->entity); if (!$res > 0) $error++; - +*/ if (GETPOST("PAYMENTBYBANKTRANSFER_USER") > 0) { $res = dolibarr_set_const($db, "PAYMENTBYBANKTRANSFER_USER", GETPOST("PAYMENTBYBANKTRANSFER_USER"), 'chaine', 0, '', $conf->entity); @@ -156,11 +156,13 @@ print ''; $form->select_comptes($conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT, 'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT', 0, "courant=1", 1); print ''; +/* Moved to bank account data // ICS print ''.$langs->trans("ICS").''; print ''; print ''; print ''; +*/ //User print ''.$langs->trans("ResponsibleUser").''; diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php index c16b5c30c47..601cefc1dd2 100644 --- a/htdocs/admin/prelevement.php +++ b/htdocs/admin/prelevement.php @@ -70,11 +70,14 @@ if ($action == "set") $res = dolibarr_set_const($db, "PRELEVEMENT_RAISON_SOCIALE", $account->proprio,'chaine',0,'',$conf->entity); if (! $res > 0) $error++; */ + } else $error++; +/* Moved to account + $res = dolibarr_set_const($db, "PRELEVEMENT_ICS", GETPOST("PRELEVEMENT_ICS"), 'chaine', 0, '', $conf->entity); if (!$res > 0) $error++; - +*/ if (GETPOST("PRELEVEMENT_USER") > 0) { $res = dolibarr_set_const($db, "PRELEVEMENT_USER", GETPOST("PRELEVEMENT_USER"), 'chaine', 0, '', $conf->entity); @@ -149,13 +152,16 @@ print ''.$langs->trans("Parameter").''; print ''.$langs->trans("Value").''; print ""; + // Bank account (from Banks module) print ''.$langs->trans("BankToReceiveWithdraw").''; print ''; $form->select_comptes($conf->global->PRELEVEMENT_ID_BANKACCOUNT, 'PRELEVEMENT_ID_BANKACCOUNT', 0, "courant=1", 1); print ''; +/* Moved to bank account data // ICS + print ''; $htmltext = $langs->trans("AskThisIDToYourBank"); print $form->textwithpicto($langs->trans("ICS"), $htmltext); @@ -164,6 +170,7 @@ print ''; print ''; print ''; print ''; +*/ //User print ''.$langs->trans("ResponsibleUser").''; diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 8b086516351..83940f4ac43 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -94,6 +94,9 @@ if ($action == 'add') $object->proprio = trim(GETPOST("proprio", 'alphanohtml')); $object->owner_address = trim(GETPOST("owner_address", 'nohtml')); + + $object->ics = trim($_POST["ics"]); + $object->ics_transfer = trim($_POST["ics_transfer"]); $account_number = GETPOST('account_number', 'alphanohtml'); if (empty($account_number) || $account_number == '-1') @@ -195,6 +198,9 @@ if ($action == 'update') $object->proprio = trim(GETPOST("proprio", 'alphanohtml')); $object->owner_address = trim(GETPOST("owner_address", 'nohtml')); + + $object->ics = trim($_POST["ics"]); + $object->ics_transfer = trim($_POST["ics_transfer"]); $account_number = GETPOST('account_number', 'alpha'); if (empty($account_number) || $account_number == '-1') @@ -730,6 +736,14 @@ if ($action == 'create') } } print ''; + + print ''.$langs->trans("ICS").''; + print ''.$object->ics.''; + print ''; + + print ''.$langs->trans("ICSTransfer").''; + print ''.$object->ics_transfer.''; + print ''; print ''.$langs->trans("BankAccountDomiciliation").''; print nl2br($object->domiciliation); @@ -1010,7 +1024,13 @@ if ($action == 'create') print ''.$langs->trans($bickey).''; print ''; - + + print ''.$langs->trans("ICS").''; + print ''; + + print ''.$langs->trans("ICSTransfer").''; + print ''; + print ''.$langs->trans("BankAccountDomiciliation").''; print '', null, 'warnings'); setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings'); $action = ''; - } elseif ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) - { + } elseif ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) { setEventMessages($langs->trans("NotEnoughPermissions"), null, 'warnings'); $action = ''; } else { $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); - if ($object->statut == 0) - { + if ($object->statut == 0) { dol_print_error('', 'ErrorMailIsNotValidated'); exit; } @@ -137,7 +135,9 @@ if (empty($reshook)) $errorsto = $object->email_errorsto; // Is the message in html $msgishtml = -1; // Unknown by default - if (preg_match('/[\s\t]*/i', $message)) $msgishtml = 1; + if (preg_match('/[\s\t]*/i', $message)) { + $msgishtml = 1; + } // Warning, we must not use begin-commit transaction here // because we want to save update for each mail sent. @@ -153,12 +153,10 @@ if (empty($reshook)) dol_syslog("card.php: select targets", LOG_DEBUG); $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); // Number of possible recipients - if ($num) - { + if ($num) { dol_syslog("comm/mailing/card.php: nb of targets = ".$num, LOG_DEBUG); $now = dol_now(); @@ -166,16 +164,14 @@ if (empty($reshook)) // Positioning date of start sending $sql = "UPDATE ".MAIN_DB_PREFIX."mailing SET date_envoi='".$db->idate($now)."' WHERE rowid=".$object->id; $resql2 = $db->query($sql); - if (!$resql2) - { + if (!$resql2) { dol_print_error($db); } // Loop on each email and send it $i = 0; - while ($i < $num && $i < $conf->global->MAILING_LIMIT_SENDBYWEB) - { + while ($i < $num && $i < $conf->global->MAILING_LIMIT_SENDBYWEB) { // Here code is common with same loop ino mailing-send.php $res = 1; $now = dol_now(); @@ -215,14 +211,18 @@ if (empty($reshook)) $substitutionarray['__UNSUBSCRIBE__'] = ''.$langs->trans("MailUnsubcribe").''; $onlinepaymentenabled = 0; - if (!empty($conf->paypal->enabled)) $onlinepaymentenabled++; - if (!empty($conf->paybox->enabled)) $onlinepaymentenabled++; - if (!empty($conf->stripe->enabled)) $onlinepaymentenabled++; - if ($onlinepaymentenabled && !empty($conf->global->PAYMENT_SECURITY_TOKEN)) - { + if (!empty($conf->paypal->enabled)) { + $onlinepaymentenabled++; + } + if (!empty($conf->paybox->enabled)) { + $onlinepaymentenabled++; + } + if (!empty($conf->stripe->enabled)) { + $onlinepaymentenabled++; + } + if ($onlinepaymentenabled && !empty($conf->global->PAYMENT_SECURITY_TOKEN)) { $substitutionarray['__SECUREKEYPAYMENT__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); - if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) - { + if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { $substitutionarray['__SECUREKEYPAYMENT_MEMBER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); $substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); $substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); @@ -235,21 +235,32 @@ if (empty($reshook)) } } /* For backward compatibility, deprecated */ - if (!empty($conf->paypal->enabled) && !empty($conf->global->PAYPAL_SECURITY_TOKEN)) - { + if (!empty($conf->paypal->enabled) && !empty($conf->global->PAYPAL_SECURITY_TOKEN)) { $substitutionarray['__SECUREKEYPAYPAL__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_MEMBER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); - else $substitutionarray['__SECUREKEYPAYPAL_MEMBER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'membersubscription'.$obj->source_id, 2); + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) { + $substitutionarray['__SECUREKEYPAYPAL_MEMBER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + } else { + $substitutionarray['__SECUREKEYPAYPAL_MEMBER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'membersubscription'.$obj->source_id, 2); + } - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_ORDER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); - else $substitutionarray['__SECUREKEYPAYPAL_ORDER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'order'.$obj->source_id, 2); + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) { + $substitutionarray['__SECUREKEYPAYPAL_ORDER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + } else { + $substitutionarray['__SECUREKEYPAYPAL_ORDER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'order'.$obj->source_id, 2); + } - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_INVOICE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); - else $substitutionarray['__SECUREKEYPAYPAL_INVOICE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'invoice'.$obj->source_id, 2); + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) { + $substitutionarray['__SECUREKEYPAYPAL_INVOICE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + } else { + $substitutionarray['__SECUREKEYPAYPAL_INVOICE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'invoice'.$obj->source_id, 2); + } - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); - else $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'contractline'.$obj->source_id, 2); + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) { + $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); + } else { + $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'contractline'.$obj->source_id, 2); + } } //$substitutionisok=true; @@ -263,10 +274,8 @@ if (empty($reshook)) $arr_css = array(); $listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0); - if (count($listofpaths)) - { - foreach ($listofpaths as $key => $val) - { + if (count($listofpaths)) { + foreach ($listofpaths as $key => $val) { $arr_file[] = $listofpaths[$key]['fullname']; $arr_mime[] = dol_mimetype($listofpaths[$key]['name']); $arr_name[] = $listofpaths[$key]['name']; @@ -277,8 +286,7 @@ if (empty($reshook)) $trackid = 'emailing-'.$obj->fk_mailing.'-'.$obj->rowid; $mail = new CMailFile($newsubject, $sendto, $from, $newmessage, $arr_file, $arr_mime, $arr_name, '', '', 0, $msgishtml, $errorsto, $arr_css, $trackid, '', 'emailing'); - if ($mail->error) - { + if ($mail->error) { $res = 0; } /*if (! $substitutionisok) @@ -288,13 +296,11 @@ if (empty($reshook)) }*/ // Send mail - if ($res) - { + if ($res) { $res = $mail->sendfile(); } - if ($res) - { + if ($res) { // Mail successful $nbok++; @@ -303,19 +309,16 @@ if (empty($reshook)) $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; $sql .= " SET statut=1, date_envoi='".$db->idate($now)."' WHERE rowid=".$obj->rowid; $resql2 = $db->query($sql); - if (!$resql2) - { + if (!$resql2) { dol_print_error($db); } else { //if cheack read is use then update prospect contact status - if (strpos($message, '__CHECK_READ__') !== false) - { + if (strpos($message, '__CHECK_READ__') !== false) { //Update status communication of thirdparty prospect $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT source_id FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE rowid=".$obj->rowid.")"; dol_syslog("card.php: set prospect thirdparty status", LOG_DEBUG); $resql2 = $db->query($sql); - if (!$resql2) - { + if (!$resql2) { dol_print_error($db); } @@ -324,15 +327,13 @@ if (empty($reshook)) dol_syslog("card.php: set prospect contact status", LOG_DEBUG); $resql2 = $db->query($sql); - if (!$resql2) - { + if (!$resql2) { dol_print_error($db); } } } - if (!empty($conf->global->MAILING_DELAY)) - { + if (!empty($conf->global->MAILING_DELAY)) { dol_syslog("Wait a delay of MAILING_DELAY=".$conf->global->MAILING_DELAY); sleep($conf->global->MAILING_DELAY); } @@ -347,8 +348,7 @@ if (empty($reshook)) $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; $sql .= " SET statut=-1, error_text='".$db->escape($mail->error)."', date_envoi='".$db->idate($now)."' WHERE rowid=".$obj->rowid; $resql2 = $db->query($sql); - if (!$resql2) - { + if (!$resql2) { dol_print_error($db); } } @@ -360,14 +360,15 @@ if (empty($reshook)) } // Loop finished, set global statut of mail - if ($nbko > 0) - { + if ($nbko > 0) { $statut = 2; // Status 'sent partially' (because at least one error) - if ($nbok > 0) setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs'); - else setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs'); + if ($nbok > 0) { + setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs'); + } else { + setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs'); + } } else { - if ($nbok >= $num) - { + if ($nbok >= $num) { $statut = 3; // Send to everybody setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs'); } else { @@ -379,8 +380,7 @@ if (empty($reshook)) $sql = "UPDATE ".MAIN_DB_PREFIX."mailing SET statut=".$statut." WHERE rowid=".$object->id; dol_syslog("comm/mailing/card.php: update global status", LOG_DEBUG); $resql2 = $db->query($sql); - if (!$resql2) - { + if (!$resql2) { dol_print_error($db); } } else { @@ -393,24 +393,23 @@ if (empty($reshook)) } // Action send test emailing - if ($action == 'send' && empty($_POST["cancel"])) - { + if ($action == 'send' && empty($_POST["cancel"])) { $error = 0; $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); $object->sendto = $_POST["sendto"]; - if (!$object->sendto) - { + if (!$object->sendto) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MailTo")), null, 'errors'); $error++; } - if (!$error) - { + if (!$error) { // Is the message in html $msgishtml = -1; // Unknow by default - if (preg_match('/[\s\t]*/i', $object->body)) $msgishtml = 1; + if (preg_match('/[\s\t]*/i', $object->body)) { + $msgishtml = 1; + } // other are set at begin of page $object->substitutionarrayfortest['__EMAIL__'] = $object->sendto; @@ -427,15 +426,17 @@ if (empty($reshook)) $arr_css = array(); // Add CSS - if (!empty($object->bgcolor)) $arr_css['bgcolor'] = (preg_match('/^#/', $object->bgcolor) ? '' : '#').$object->bgcolor; - if (!empty($object->bgimage)) $arr_css['bgimage'] = $object->bgimage; + if (!empty($object->bgcolor)) { + $arr_css['bgcolor'] = (preg_match('/^#/', $object->bgcolor) ? '' : '#').$object->bgcolor; + } + if (!empty($object->bgimage)) { + $arr_css['bgimage'] = $object->bgimage; + } // Attached files $listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0); - if (count($listofpaths)) - { - foreach ($listofpaths as $key => $val) - { + if (count($listofpaths)) { + foreach ($listofpaths as $key => $val) { $arr_file[] = $listofpaths[$key]['fullname']; $arr_mime[] = dol_mimetype($listofpaths[$key]['name']); $arr_name[] = $listofpaths[$key]['name']; @@ -446,8 +447,7 @@ if (empty($reshook)) $mailfile = new CMailFile($tmpsujet, $object->sendto, $object->email_from, $tmpbody, $arr_file, $arr_mime, $arr_name, '', '', 0, $msgishtml, $object->email_errorsto, $arr_css, $trackid, '', 'emailing'); $result = $mailfile->sendfile(); - if ($result) - { + if ($result) { setEventMessages($langs->trans("MailSuccessfulySent", $mailfile->getValidAddress($object->email_from, 2), $mailfile->getValidAddress($object->sendto, 2)), null, 'mesgs'); $action = ''; } else { @@ -458,18 +458,17 @@ if (empty($reshook)) } // Action add emailing - if ($action == 'add') - { + if ($action == 'add') { $mesgs = array(); - $object->email_from = GETPOST("from", "none"); // Must allow 'name ' - $object->email_replyto = GETPOST("replyto", "none"); // Must allow 'name ' - $object->email_errorsto = GETPOST("errorsto", "none"); // Must allow 'name ' - $object->title = GETPOST("title"); - $object->sujet = GETPOST("sujet"); - $object->body = GETPOST("bodyemail", 'restricthtml'); - $object->bgcolor = GETPOST("bgcolor"); - $object->bgimage = GETPOST("bgimage"); + $object->email_from = (string) GETPOST("from", "none"); // Must allow 'name ' + $object->email_replyto = (string) GETPOST("replyto", "none"); // Must allow 'name ' + $object->email_errorsto = (string) GETPOST("errorsto", "none"); // Must allow 'name ' + $object->title = (string) GETPOST("title"); + $object->sujet = (string) GETPOST("sujet"); + $object->body = (string) GETPOST("bodyemail", 'restricthtml'); + $object->bgcolor = (string) GETPOST("bgcolor"); + $object->bgimage = (string) GETPOST("bgimage"); if (!$object->title) { $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTitle")); @@ -481,10 +480,8 @@ if (empty($reshook)) $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailMessage")); } - if (!count($mesgs)) - { - if ($object->create($user) >= 0) - { + if (!count($mesgs)) { + if ($object->create($user) >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } @@ -496,24 +493,25 @@ if (empty($reshook)) } // Action update description of emailing - if ($action == 'settitle' || $action == 'setemail_from' || $action == 'setreplyto' || $action == 'setemail_errorsto') - { + if ($action == 'settitle' || $action == 'setemail_from' || $action == 'setreplyto' || $action == 'setemail_errorsto') { $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); - if ($action == 'settitle') $object->title = trim(GETPOST('title', 'alpha')); - elseif ($action == 'setemail_from') $object->email_from = trim(GETPOST('email_from', 'none')); // Must allow 'name ' - elseif ($action == 'setemail_replyto') $object->email_replyto = trim(GETPOST('email_replyto', 'none')); // Must allow 'name ' - elseif ($action == 'setemail_errorsto') $object->email_errorsto = trim(GETPOST('email_errorsto', 'none')); // Must allow 'name ' - elseif ($action == 'settitle' && empty($object->title)) { + if ($action == 'settitle') { + $object->title = trim(GETPOST('title', 'alpha')); + } elseif ($action == 'setemail_from') { + $object->email_from = trim(GETPOST('email_from', 'none')); // Must allow 'name ' + } elseif ($action == 'setemail_replyto') { + $object->email_replyto = trim(GETPOST('email_replyto', 'none')); // Must allow 'name ' + } elseif ($action == 'setemail_errorsto') { + $object->email_errorsto = trim(GETPOST('email_errorsto', 'none')); // Must allow 'name ' + } elseif ($action == 'settitle' && empty($object->title)) { $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTitle")); } elseif ($action == 'setfrom' && empty($object->email_from)) { $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailFrom")); } - if (!$mesg) - { - if ($object->update($user) >= 0) - { + if (!$mesg) { + if ($object->update($user) >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } @@ -527,8 +525,7 @@ if (empty($reshook)) /* * Add file in email form */ - if (!empty($_POST['addfile'])) - { + if (!empty($_POST['addfile'])) { $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -540,8 +537,7 @@ if (empty($reshook)) } // Action of file remove - if (!empty($_POST["removedfile"])) - { + if (!empty($_POST["removedfile"])) { $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -552,20 +548,18 @@ if (empty($reshook)) } // Action of emailing update - if ($action == 'update' && empty($_POST["removedfile"]) && empty($_POST["cancel"])) - { + if ($action == 'update' && empty($_POST["removedfile"]) && empty($_POST["cancel"])) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $isupload = 0; - if (!$isupload) - { + if (!$isupload) { $mesgs = array(); - $object->sujet = GETPOST("sujet"); - $object->body = GETPOST("bodyemail", 'restricthtml'); - $object->bgcolor = GETPOST("bgcolor"); - $object->bgimage = GETPOST("bgimage"); + $object->sujet = (string) GETPOST("sujet"); + $object->body = (string) GETPOST("bodyemail", 'restricthtml'); + $object->bgcolor = (string) GETPOST("bgcolor"); + $object->bgimage = (string) GETPOST("bgimage"); if (!$object->sujet) { $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTopic")); @@ -574,10 +568,8 @@ if (empty($reshook)) $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailMessage")); } - if (!count($mesgs)) - { - if ($object->update($user) >= 0) - { + if (!count($mesgs)) { + if ($object->update($user) >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } @@ -592,10 +584,8 @@ if (empty($reshook)) } // Action of validation confirmation - if ($action == 'confirm_valid' && $confirm == 'yes') - { - if ($object->id > 0) - { + if ($action == 'confirm_valid' && $confirm == 'yes') { + if ($object->id > 0) { $object->valid($user); setEventMessages($langs->trans("MailingSuccessfullyValidated"), null, 'mesgs'); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); @@ -606,13 +596,10 @@ if (empty($reshook)) } // Action of validation confirmation - if ($action == 'confirm_settodraft' && $confirm == 'yes') - { - if ($object->id > 0) - { + if ($action == 'confirm_settodraft' && $confirm == 'yes') { + if ($object->id > 0) { $result = $object->setStatut(0); - if ($result > 0) - { + if ($result > 0) { //setEventMessages($langs->trans("MailingSuccessfullyValidated"), null, 'mesgs'); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; @@ -625,20 +612,16 @@ if (empty($reshook)) } // Resend - if ($action == 'confirm_reset' && $confirm == 'yes') - { - if ($object->id > 0) - { + if ($action == 'confirm_reset' && $confirm == 'yes') { + if ($object->id > 0) { $db->begin(); $result = $object->valid($user); - if ($result > 0) - { + if ($result > 0) { $result = $object->reset_targets_status($user); } - if ($result > 0) - { + if ($result > 0) { $db->commit(); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; @@ -652,18 +635,15 @@ if (empty($reshook)) } // Action of delete confirmation - if ($action == 'confirm_delete' && $confirm == 'yes') - { - if ($object->delete($object->id)) - { + if ($action == 'confirm_delete' && $confirm == 'yes') { + if ($object->delete($object->id)) { $url = (!empty($urlfrom) ? $urlfrom : 'list.php'); header("Location: ".$url); exit; } } - if (!empty($_POST["cancel"])) - { + if (!empty($_POST["cancel"])) { $action = ''; } } @@ -677,24 +657,30 @@ $form = new Form($db); $htmlother = new FormOther($db); $help_url = 'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing'; -llxHeader('', $langs->trans("Mailing"), $help_url, '', 0, 0, +llxHeader( + '', + $langs->trans("Mailing"), + $help_url, + '', + 0, + 0, array( - '/includes/ace/src/ace.js', - '/includes/ace/src/ext-statusbar.js', - '/includes/ace/src/ext-language_tools.js', - //'/includes/ace/src/ext-chromevox.js' - ), array()); + '/includes/ace/src/ace.js', + '/includes/ace/src/ext-statusbar.js', + '/includes/ace/src/ext-language_tools.js', + //'/includes/ace/src/ext-chromevox.js' + ), + array() +); -if ($action == 'create') -{ +if ($action == 'create') { // EMailing in creation mode print '
'."\n"; print ''; print ''; $htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").':
'; - foreach ($object->substitutionarray as $key => $val) - { + foreach ($object->substitutionarray as $key => $val) { $htmltext .= $key.' = '.$langs->trans($val).'
'; } $htmltext .= '
'; @@ -718,8 +704,7 @@ if ($action == 'create') $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook)) - { + if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit'); } @@ -747,79 +732,80 @@ if ($action == 'create') print '
'; } else { - if ($object->id > 0) - { + if ($object->id > 0) { $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); $head = emailing_prepare_head($object); - // Confirmation back to draft - if ($action == 'settodraft') - { + if ($action == 'settodraft') { + // Confirmation back to draft print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("SetToDraft"), $langs->trans("ConfirmUnvalidateEmailing"), "confirm_settodraft", '', '', 1); - } - // Confirmation of mailing validation - if ($action == 'valid') - { + } elseif ($action == 'valid') { + // Confirmation of mailing validation print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ValidMailing"), $langs->trans("ConfirmValidMailing"), "confirm_valid", '', '', 1); - } // Confirm reset - elseif ($action == 'reset') - { + } elseif ($action == 'reset') { + // Confirm reset print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ResetMailing"), $langs->trans("ConfirmResetMailing", $object->ref), "confirm_reset", '', '', 2); - } // Confirm delete - elseif ($action == 'delete') - { + } elseif ($action == 'delete') { + // Confirm delete print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id.(!empty($urlfrom) ? '&urlfrom='.urlencode($urlfrom) : ''), $langs->trans("DeleteAMailing"), $langs->trans("ConfirmDeleteMailing"), "confirm_delete", '', '', 1); } - - if ($action != 'edit' && $action != 'edithtml') - { + if ($action != 'edit' && $action != 'edithtml') { print dol_get_fiche_head($head, 'card', $langs->trans("Mailing"), -1, 'email'); /* * View mode mailing */ - if ($action == 'sendall') - { + if ($action == 'sendall') { // Define message to recommand from command line $sendingmode = $conf->global->EMAILING_MAIL_SENDMODE; - if (empty($sendingmode)) $sendingmode = $conf->global->MAIN_MAIL_SENDMODE; - if (empty($sendingmode)) $sendingmode = 'mail'; // If not defined, we use php mail function + if (empty($sendingmode)) { + $sendingmode = $conf->global->MAIN_MAIL_SENDMODE; + } + if (empty($sendingmode)) { + $sendingmode = 'mail'; // If not defined, we use php mail function + } // MAILING_NO_USING_PHPMAIL may be defined or not. // MAILING_LIMIT_SENDBYWEB is always defined to something != 0 (-1=forbidden). // MAILING_LIMIT_SENDBYCLI may be defined ot not (-1=forbidden, 0 or undefined=no limit). - if (!empty($conf->global->MAILING_NO_USING_PHPMAIL) && $sendingmode == 'mail') - { + if (!empty($conf->global->MAILING_NO_USING_PHPMAIL) && $sendingmode == 'mail') { // EMailing feature may be a spam problem, so when you host several users/instance, having this option may force each user to use their own SMTP agent. // You ensure that every user is using its own SMTP server when using the mass emailing module. $linktoadminemailbefore = ''; $linktoadminemailend = ''; setEventMessages($langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]), null, 'warnings'); setEventMessages($langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']), null, 'warnings'); - if (!empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS)) setEventMessages($langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS), null, 'warnings'); + if (!empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS)) { + setEventMessages($langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS), null, 'warnings'); + } $_GET["action"] = ''; - } elseif ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) - { - if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode == 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null, 'warnings'); - if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode != 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null, 'warnings'); + } elseif ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) { + if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode == 'mail') { + setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null, 'warnings'); + } + if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode != 'mail') { + setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null, 'warnings'); + } // The feature is forbidden from GUI, we show just message to use from command line. setEventMessages($langs->trans("MailingNeedCommand"), null, 'warnings'); setEventMessages('', null, 'warnings'); - if ($conf->file->mailing_limit_sendbyweb != '-1') // MAILING_LIMIT_SENDBYWEB was set to -1 in database, but it is allowed ot increase it. - { + if ($conf->file->mailing_limit_sendbyweb != '-1') { // MAILING_LIMIT_SENDBYWEB was set to -1 in database, but it is allowed ot increase it. setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings'); // You can send online with constant... } $_GET["action"] = ''; } else { - if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode == 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null, 'warnings'); - if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode != 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null, 'warnings'); + if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode == 'mail') { + setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null, 'warnings'); + } + if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode != 'mail') { + setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null, 'warnings'); + } $text = ''; - if ($conf->global->MAILING_LIMIT_SENDBYCLI >= 0) - { + if ($conf->global->MAILING_LIMIT_SENDBYCLI >= 0) { $text .= $langs->trans("MailingNeedCommand"); $text .= '
'; $text .= '

'; @@ -834,13 +820,14 @@ if ($action == 'create') $morehtmlright = ''; $nbtry = $nbok = 0; - if ($object->statut == 2 || $object->statut == 3) - { + if ($object->statut == 2 || $object->statut == 3) { $nbtry = $object->countNbOfTargets('alreadysent'); $nbko = $object->countNbOfTargets('alreadysentko'); $morehtmlright .= ' ('.$nbtry.'/'.$object->nbemail; - if ($nbko) $morehtmlright .= ' - '.$nbko.' '.$langs->trans("Error"); + if ($nbko) { + $morehtmlright .= ' - '.$nbko.' '.$langs->trans("Error"); + } $morehtmlright .= ')   '; } @@ -894,21 +881,19 @@ if ($action == 'create') print $langs->trans("TotalNbOfDistinctRecipients"); print ''; $nbemail = ($object->nbemail ? $object->nbemail : 0); - if (is_numeric($nbemail)) - { + if (is_numeric($nbemail)) { $text = ''; - if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail))) - { - if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) - { + if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail))) { + if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) { $text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); } else { $text .= $langs->trans('SendingFromWebInterfaceIsNotAllowed'); } } - if (empty($nbemail)) $nbemail .= ' '.img_warning('').' '.$langs->trans("NoTargetYet").''; - if ($text) - { + if (empty($nbemail)) { + $nbemail .= ' '.img_warning('').' '.$langs->trans("NoTargetYet").''; + } + if ($text) { print $form->textwithpicto($nbemail, $text, 1, 'warning'); } else { print $nbemail; @@ -927,8 +912,7 @@ if ($action == 'create') // Clone confirmation - if ($action == 'clone') - { + if ($action == 'clone') { // Create an array for form $formquestion = array( 'text' => $langs->trans("ConfirmClone"), @@ -943,81 +927,67 @@ if ($action == 'create') * Actions Buttons */ - if (GETPOST('cancel', 'alpha') || $confirm == 'no' || $action == '' || in_array($action, array('settodraft', 'valid', 'delete', 'sendall', 'clone', 'test'))) - { + if (GETPOST('cancel', 'alpha') || $confirm == 'no' || $action == '' || in_array($action, array('settodraft', 'valid', 'delete', 'sendall', 'clone', 'test'))) { print "\n\n
\n"; - if (($object->statut == 1) && ($user->rights->mailing->valider || $object->fk_user_valid == $user->id)) - { + if (($object->statut == 1) && ($user->rights->mailing->valider || $object->fk_user_valid == $user->id)) { print ''.$langs->trans("SetToDraft").''; } - if (($object->statut == 0 || $object->statut == 1 || $object->statut == 2) && $user->rights->mailing->creer) - { - if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_MAILING)) - { + if (($object->statut == 0 || $object->statut == 1 || $object->statut == 2) && $user->rights->mailing->creer) { + if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_MAILING)) { print ''.$langs->trans("EditWithEditor").''; } else { print ''.$langs->trans("EditWithTextEditor").''; } - if (!empty($conf->use_javascript_ajax)) print ''.$langs->trans("EditHTMLSource").''; + if (!empty($conf->use_javascript_ajax)) { + print ''.$langs->trans("EditHTMLSource").''; + } } //print ''.$langs->trans("PreviewMailing").''; - if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) - { + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) { print ''.$langs->trans("TestMailing").''; } else { print ''.$langs->trans("TestMailing").''; } - if ($object->statut == 0) - { - if ($object->nbemail <= 0) - { + if ($object->statut == 0) { + if ($object->nbemail <= 0) { print ''.$langs->trans("ValidMailing").''; - } elseif (empty($user->rights->mailing->valider)) - { + } elseif (empty($user->rights->mailing->valider)) { print ''.$langs->trans("ValidMailing").''; } else { print ''.$langs->trans("ValidMailing").''; } } - if (($object->statut == 1 || $object->statut == 2) && $object->nbemail > 0 && $user->rights->mailing->valider) - { - if ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) - { + if (($object->statut == 1 || $object->statut == 2) && $object->nbemail > 0 && $user->rights->mailing->valider) { + if ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) { print ''.$langs->trans("SendMailing").''; - } elseif (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) - { + } elseif (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) { print ''.$langs->trans("SendMailing").''; } else { print ''.$langs->trans("SendMailing").''; } } - if ($user->rights->mailing->creer) - { + if ($user->rights->mailing->creer) { print ''.$langs->trans("ToClone").''; } - if (($object->statut == 2 || $object->statut == 3) && $user->rights->mailing->valider) - { - if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) - { + if (($object->statut == 2 || $object->statut == 3) && $user->rights->mailing->valider) { + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) { print ''.$langs->trans("ResetMailing").''; } else { print ''.$langs->trans("ResetMailing").''; } } - if (($object->statut <= 1 && $user->rights->mailing->creer) || $user->rights->mailing->supprimer) - { - if ($object->statut > 0 && (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->delete)) - { + if (($object->statut <= 1 && $user->rights->mailing->creer) || $user->rights->mailing->supprimer) { + if ($object->statut > 0 && (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->delete)) { print ''.$langs->trans("DeleteMailing").''; } else { print ''.$langs->trans("DeleteMailing").''; @@ -1028,8 +998,7 @@ if ($action == 'create') } // Display of the TEST form - if ($action == 'test') - { + if ($action == 'test') { print '
'; print load_fiche_titre($langs->trans("TestMailing")); @@ -1071,8 +1040,7 @@ if ($action == 'create') $htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").':
'; - foreach ($object->substitutionarray as $key => $val) - { + foreach ($object->substitutionarray as $key => $val) { $htmltext .= $key.' = '.$langs->trans($val).'
'; } $htmltext .= '
'; @@ -1091,10 +1059,8 @@ if ($action == 'create') print ''.$langs->trans("MailFile").''; // List of files $listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0); - if (count($listofpaths)) - { - foreach ($listofpaths as $key => $val) - { + if (count($listofpaths)) { + foreach ($listofpaths as $key => $val) { print img_mime($listofpaths[$key]['name']).' '.$listofpaths[$key]['name']; print '
'; } @@ -1105,21 +1071,22 @@ if ($action == 'create') // Background color /*print ''.$langs->trans("BackgroundColorByDefault").''; - print $htmlother->selectColor($object->bgcolor,'bgcolor','',0); - print '';*/ + print $htmlother->selectColor($object->bgcolor,'bgcolor','',0); + print '';*/ print ''; // Message print '
'; - if (empty($object->bgcolor) || strtolower($object->bgcolor) == 'ffffff') // CKEditor does not apply the color of the div into its content area - { + if (empty($object->bgcolor) || strtolower($object->bgcolor) == 'ffffff') { // CKEditor does not apply the color of the div into its content area $readonly = 1; // wysiwyg editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', false, true, empty($conf->global->FCKEDITOR_ENABLE_MAILING) ? 0 : 1, 20, '90%', $readonly); $doleditor->Create(); - } else print dol_htmlentitiesbr($object->body); + } else { + print dol_htmlentitiesbr($object->body); + } print '
'; print dol_get_fiche_end(); @@ -1133,7 +1100,9 @@ if ($action == 'create') $linkback = ''.$langs->trans("BackToList").''; $morehtmlright = ''; - if ($object->statut == 2) $morehtmlright .= ' ('.$object->countNbOfTargets('alreadysent').'/'.$object->nbemail.') '; + if ($object->statut == 2) { + $morehtmlright .= ' ('.$object->countNbOfTargets('alreadysent').'/'.$object->nbemail.') '; + } dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', $morehtmlright); @@ -1161,21 +1130,19 @@ if ($action == 'create') print $langs->trans("TotalNbOfDistinctRecipients"); print ''; $nbemail = ($object->nbemail ? $object->nbemail : 0); - if (is_numeric($nbemail)) - { + if (is_numeric($nbemail)) { $text = ''; - if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || $object->statut == 2)) - { - if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) - { + if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || $object->statut == 2)) { + if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) { $text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); } else { $text .= $langs->trans('SendingFromWebInterfaceIsNotAllowed'); } } - if (empty($nbemail)) $nbemail .= ' '.img_warning('').' '.$langs->trans("NoTargetYet").''; - if ($text) - { + if (empty($nbemail)) { + $nbemail .= ' '.img_warning('').' '.$langs->trans("NoTargetYet").''; + } + if ($text) { print $form->textwithpicto($nbemail, $text, 1, 'warning'); } else { print $nbemail; @@ -1187,8 +1154,7 @@ if ($action == 'create') $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (empty($reshook)) - { + if (empty($reshook)) { print $object->showOptionals($extrafields, 'edit', $parameters); } @@ -1207,8 +1173,7 @@ if ($action == 'create') print ''; $htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").':
'; - foreach ($object->substitutionarray as $key => $val) - { + foreach ($object->substitutionarray as $key => $val) { $htmltext .= $key.' = '.$langs->trans($val).'
'; } $htmltext .= '
'; @@ -1242,10 +1207,8 @@ if ($action == 'create') $out .= ' });'; $out .= '})'; $out .= ''."\n"; - if (count($listofpaths)) - { - foreach ($listofpaths as $key => $val) - { + if (count($listofpaths)) { + foreach ($listofpaths as $key => $val) { $out .= '
'; $out .= img_mime($listofpaths[$key]['name']).' '.$listofpaths[$key]['name']; $out .= ' '; @@ -1271,15 +1234,13 @@ if ($action == 'create') // Message print '
'; - if ($action == 'edit') - { + if ($action == 'edit') { // wysiwyg editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, true, $conf->global->FCKEDITOR_ENABLE_MAILING, 20, '90%'); $doleditor->Create(); } - if ($action == 'edithtml') - { + if ($action == 'edithtml') { // HTML source editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, true, 'ace', 20, '90%'); From 391e643eb7381cece0612ed406f490f5ba0698d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 27 Nov 2020 20:33:40 +0100 Subject: [PATCH 033/214] doxygen --- htdocs/comm/mailing/class/mailing.class.php | 20 ++++++++++++++++++-- htdocs/comm/mailing/info.php | 19 ++++++++----------- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index 2f2b16bd119..b93030d0262 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -118,36 +118,48 @@ class Mailing extends CommonObject /** * @var int id of user create - * @deprecated */ public $user_creation; /** * @var int id of user create + * @deprecated */ public $user_creat; /** * @var int id of user validate - * @deprecated */ public $user_validation; /** * @var int id of user validate + * @deprecated */ public $user_valid; /** * @var integer|string date_creation + * @deprecated */ public $date_creat; + /** + * @var integer|string date_creation + */ + public $date_creation; + /** * @var int date validate + * @deprecated */ public $date_valid; + /** + * @var int date validate + */ + public $date_validation; + /** * @var array extraparams */ @@ -314,10 +326,14 @@ class Mailing extends CommonObject $this->email_errorsto = $obj->email_errorsto; $this->user_creat = $obj->fk_user_creat; + $this->user_creation = $obj->fk_user_creat; $this->user_valid = $obj->fk_user_valid; + $this->user_validation = $obj->fk_user_valid; $this->date_creat = $this->db->jdate($obj->date_creat); + $this->date_creation = $this->db->jdate($obj->date_creat); $this->date_valid = $this->db->jdate($obj->date_valid); + $this->date_validation = $this->db->jdate($obj->date_valid); $this->date_envoi = $this->db->jdate($obj->date_envoi); $this->extraparams = (array) json_decode($obj->extraparams, true); diff --git a/htdocs/comm/mailing/info.php b/htdocs/comm/mailing/info.php index 199a5caad8b..4bd39309701 100644 --- a/htdocs/comm/mailing/info.php +++ b/htdocs/comm/mailing/info.php @@ -33,8 +33,9 @@ $id = GETPOST('id', 'int'); $langs->load("mails"); // Security check -if (!$user->rights->mailing->lire || $user->socid > 0) -accessforbidden(); +if (!$user->rights->mailing->lire || $user->socid > 0) { + accessforbidden(); +} @@ -48,8 +49,7 @@ $form = new Form($db); $object = new Mailing($db); -if ($object->fetch($id) >= 0) -{ +if ($object->fetch($id) >= 0) { $head = emailing_prepare_head($object); print dol_get_fiche_head($head, 'info', $langs->trans("Mailing"), -1, 'email'); @@ -58,13 +58,14 @@ if ($object->fetch($id) >= 0) $morehtmlright = ''; $nbtry = $nbok = 0; - if ($object->statut == 2 || $object->statut == 3) - { + if ($object->statut == 2 || $object->statut == 3) { $nbtry = $object->countNbOfTargets('alreadysent'); $nbko = $object->countNbOfTargets('alreadysentko'); $morehtmlright .= ' ('.$nbtry.'/'.$object->nbemail; - if ($nbko) $morehtmlright .= ' - '.$nbko.' '.$langs->trans("Error"); + if ($nbko) { + $morehtmlright .= ' - '.$nbko.' '.$langs->trans("Error"); + } $morehtmlright .= ')   '; } @@ -73,10 +74,6 @@ if ($object->fetch($id) >= 0) print '

'; //print '
'; - $object->user_creation = $object->user_creat; - $object->date_creation = $object->date_creat; - $object->user_validation = $object->user_valid; - $object->date_validation = $object->date_valid; dol_print_object_info($object, 0); //print '
'; From f801dd7d662cc08b5928e258d612fe600e39cc94 Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Mon, 30 Nov 2020 14:54:44 +0100 Subject: [PATCH 034/214] PR toggle FCKeditor on public/private notes --- htdocs/admin/fckeditor.php | 58 ++++++++++++++++-------------- htdocs/comm/propal/card.php | 4 +-- htdocs/commande/card.php | 4 +-- htdocs/compta/deplacement/card.php | 8 ++--- htdocs/compta/facture/card-rec.php | 4 +-- htdocs/compta/facture/card.php | 4 +-- htdocs/contact/card.php | 4 +-- htdocs/contrat/card.php | 4 +-- htdocs/don/card.php | 4 +-- htdocs/expedition/card.php | 4 +-- htdocs/expensereport/card.php | 4 +-- htdocs/fichinter/card.php | 4 +-- htdocs/fourn/commande/card.php | 4 +-- htdocs/fourn/facture/card.php | 4 +-- htdocs/loan/card.php | 4 +-- htdocs/reception/card.php | 4 +-- 16 files changed, 64 insertions(+), 58 deletions(-) diff --git a/htdocs/admin/fckeditor.php b/htdocs/admin/fckeditor.php index bc6b0dc33ac..6523ec833b3 100644 --- a/htdocs/admin/fckeditor.php +++ b/htdocs/admin/fckeditor.php @@ -21,7 +21,7 @@ /** * \file htdocs/admin/fckeditor.php * \ingroup fckeditor - * \brief Page d'activation du module FCKeditor dans les autres modules + * \brief Activation page for the FCKeditor module in the other modules */ require '../main.inc.php'; @@ -43,35 +43,41 @@ $mode = GETPOST('mode') ?GETPOST('mode', 'alpha') : 'dolibarr_notes'; if (!$user->admin) accessforbidden(); -// Constante et traduction de la description du module +// Constant and translation of the module description $modules = array( -'SOCIETE' => 'FCKeditorForCompany', -'PRODUCTDESC' => 'FCKeditorForProduct', -'DETAILS' => 'FCKeditorForProductDetails', -'USERSIGN' => 'FCKeditorForUserSignature', -'MAILING' => 'FCKeditorForMailing', -'MAIL' => 'FCKeditorForMail', -'TICKET' => 'FCKeditorForTicket' + 'SOCIETE' => 'FCKeditorForCompany', + 'PRODUCTDESC' => 'FCKeditorForProduct', + 'DETAILS' => 'FCKeditorForProductDetails', + 'USERSIGN' => 'FCKeditorForUserSignature', + 'MAILING' => 'FCKeditorForMailing', + 'MAIL' => 'FCKeditorForMail', + 'TICKET' => 'FCKeditorForTicket', + 'NOTE_PUBLIC' => 'FCKeditorForNotePublic', + 'NOTE_PRIVATE' => 'FCKeditorForNotePrivate', ); -// Conditions pour que l'option soit proposee +// Conditions for the option to be offered $conditions = array( -'SOCIETE' => 1, -'PRODUCTDESC' => (!empty($conf->product->enabled) || !empty($conf->service->enabled)), -'DETAILS' => (!empty($conf->facture->enabled) || !empty($conf->propal->enabled) || !empty($conf->commande->enabled) || !empty($conf->supplier_proposal->enabled) || !empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)), -'USERSIGN' => 1, -'MAILING' => !empty($conf->mailing->enabled), -'MAIL' => (!empty($conf->facture->enabled) || !empty($conf->propal->enabled) || !empty($conf->commande->enabled)), -'TICKET' => !empty($conf->ticket->enabled) + 'SOCIETE' => 1, + 'PRODUCTDESC' => (!empty($conf->product->enabled) || !empty($conf->service->enabled)), + 'DETAILS' => (!empty($conf->facture->enabled) || !empty($conf->propal->enabled) || !empty($conf->commande->enabled) || !empty($conf->supplier_proposal->enabled) || !empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)), + 'USERSIGN' => 1, + 'MAILING' => !empty($conf->mailing->enabled), + 'MAIL' => (!empty($conf->facture->enabled) || !empty($conf->propal->enabled) || !empty($conf->commande->enabled)), + 'TICKET' => !empty($conf->ticket->enabled), + 'NOTE_PUBLIC' => 1, + 'NOTE_PRIVATE' => 1, ); // Picto $picto = array( -'SOCIETE' => 'generic', -'PRODUCTDESC' => 'product', -'DETAILS' => 'product', -'USERSIGN' => 'user', -'MAILING' => 'email', -'MAIL' => 'email', -'TICKET' => 'ticket' + 'SOCIETE' => 'generic', + 'PRODUCTDESC' => 'product', + 'DETAILS' => 'product', + 'USERSIGN' => 'user', + 'MAILING' => 'email', + 'MAIL' => 'email', + 'TICKET' => 'ticket', + 'NOTE_PUBLIC' => 'generic', + 'NOTE_PRIVATE' => 'generic', ); @@ -85,7 +91,7 @@ foreach ($modules as $const => $desc) if ($action == 'activate_'.strtolower($const)) { dolibarr_set_const($db, "FCKEDITOR_ENABLE_".$const, "1", 'chaine', 0, '', $conf->entity); - // Si fckeditor est active dans la description produit/service, on l'active dans les formulaires + // If fckeditor is active in the product/service description, it is activated in the forms if ($const == 'PRODUCTDESC' && !empty($conf->global->PRODUIT_DESC_IN_FORM)) { dolibarr_set_const($db, "FCKEDITOR_ENABLE_DETAILS", "1", 'chaine', 0, '', $conf->entity); @@ -154,7 +160,7 @@ if (empty($conf->use_javascript_ajax)) // Modules foreach ($modules as $const => $desc) { - // Si condition non remplie, on ne propose pas l'option + // If this condition is not met, the option is not offered if (!$conditions[$const]) continue; print ''; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 4742aebfde0..464f6aca20a 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1659,7 +1659,7 @@ if ($action == 'create') print ''.$langs->trans('NotePublic').''; print ''; $note_public = $object->getDefaultCreateValueFor('note_public', (is_object($objectsrc) ? $objectsrc->note_public : null)); - $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); // Private note @@ -1669,7 +1669,7 @@ if ($action == 'create') print ''.$langs->trans('NotePrivate').''; print ''; $note_private = $object->getDefaultCreateValueFor('note_private', ((!empty($origin) && !empty($originid) && is_object($objectsrc)) ? $objectsrc->note_private : null)); - $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); // print ' print ''; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 16e53e0a23b..f0a6d601a42 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1734,7 +1734,7 @@ if ($action == 'create' && $usercancreate) print ''.$langs->trans('NotePublic').''; print ''; - $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); // print ''; print ''; @@ -1745,7 +1745,7 @@ if ($action == 'create' && $usercancreate) print ''.$langs->trans('NotePrivate').''; print ''; - $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); // print ''; print ''; diff --git a/htdocs/compta/deplacement/card.php b/htdocs/compta/deplacement/card.php index 0a18d68b5db..f1e34e99985 100644 --- a/htdocs/compta/deplacement/card.php +++ b/htdocs/compta/deplacement/card.php @@ -252,7 +252,7 @@ if ($action == 'create') print ''.$langs->trans('NotePublic').''; print ''; - $doleditor = new DolEditor('note_public', GETPOST('note_public', 'restricthtml'), '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, '90%'); + $doleditor = new DolEditor('note_public', GETPOST('note_public', 'restricthtml'), '', 200, 'dolibarr_notes', 'In', false, true, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_8, '90%'); print $doleditor->Create(1); print ''; @@ -264,7 +264,7 @@ if ($action == 'create') print ''.$langs->trans('NotePrivate').''; print ''; - $doleditor = new DolEditor('note_private', GETPOST('note_private', 'restricthtml'), '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, '90%'); + $doleditor = new DolEditor('note_private', GETPOST('note_private', 'restricthtml'), '', 200, 'dolibarr_notes', 'In', false, true, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_8, '90%'); print $doleditor->Create(1); print ''; @@ -349,7 +349,7 @@ if ($action == 'create') print ''.$langs->trans("NotePublic").''; print ''; - $doleditor = new DolEditor('note_public', $object->note_public, '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, '90%'); + $doleditor = new DolEditor('note_public', $object->note_public, '', 200, 'dolibarr_notes', 'In', false, true, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_8, '90%'); print $doleditor->Create(1); print ""; @@ -360,7 +360,7 @@ if ($action == 'create') print ''.$langs->trans("NotePrivate").''; print ''; - $doleditor = new DolEditor('note_private', $object->note_private, '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, '90%'); + $doleditor = new DolEditor('note_private', $object->note_private, '', 200, 'dolibarr_notes', 'In', false, true, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_8, '90%'); print $doleditor->Create(1); print ""; diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 4f754fbd173..4c25d3df652 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -998,7 +998,7 @@ if ($action == 'create') print $form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic'); print ''; print ''; - $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); // Private note @@ -1009,7 +1009,7 @@ if ($action == 'create') print $form->textwithpicto($langs->trans('NotePrivate'), $htmltext, 1, 'help', '', 0, 2, 'noteprivate'); print ''; print ''; - $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); // print ' print ''; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index def74e173a3..37f236e875a 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3534,7 +3534,7 @@ if ($action == 'create') print $form->textwithpicto($langs->trans('NotePublic'), $htmltext); print ''; print ''; - $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); // Private note @@ -3545,7 +3545,7 @@ if ($action == 'create') print $form->textwithpicto($langs->trans('NotePrivate'), $htmltext); print ''; print ''; - $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); // print ' print ''; diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 752bdc4d642..23297438e19 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -1129,13 +1129,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) // Note Public print ''; - $doleditor = new DolEditor('note_public', $object->note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_public', $object->note_public, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); print ''; // Note Private print ''; - $doleditor = new DolEditor('note_private', $object->note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_private', $object->note_private, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); print ''; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index a92ac8a1e73..dcca2fe816c 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1174,14 +1174,14 @@ if ($action == 'create') } print ''.$langs->trans("NotePublic").''; - $doleditor = new DolEditor('note_public', $note_public, '', '100', 'dolibarr_notes', 'In', 1, true, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_public', $note_public, '', '100', 'dolibarr_notes', 'In', 1, true, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); print ''; if (empty($user->socid)) { print ''.$langs->trans("NotePrivate").''; - $doleditor = new DolEditor('note_private', $note_private, '', '100', 'dolibarr_notes', 'In', 1, true, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_private', $note_private, '', '100', 'dolibarr_notes', 'In', 1, true, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); print ''; } diff --git a/htdocs/don/card.php b/htdocs/don/card.php index c55751e913f..cd3175cdce0 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -443,7 +443,7 @@ if ($action == 'create') print ''.$langs->trans('NotePublic').''; print ''; - $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); print ''; @@ -453,7 +453,7 @@ if ($action == 'create') print ''.$langs->trans('NotePrivate').''; print ''; - $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); print ''; } diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index fd1e38e2438..a0541120ec6 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -942,7 +942,7 @@ if ($action == 'create') // Note Public print ''.$langs->trans("NotePublic").''; print ''; - $doleditor = new DolEditor('note_public', $object->note_public, '', 60, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_public', $object->note_public, '', 60, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); print ""; @@ -951,7 +951,7 @@ if ($action == 'create') { print ''.$langs->trans("NotePrivate").''; print ''; - $doleditor = new DolEditor('note_private', $object->note_private, '', 60, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_private', $object->note_private, '', 60, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); print ""; } diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 83e1173fcb4..71f190a08f9 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1457,7 +1457,7 @@ if ($action == 'create') print ''.$langs->trans('NotePublic').''; print ''; - $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); print ''; @@ -1467,7 +1467,7 @@ if ($action == 'create') print ''.$langs->trans('NotePrivate').''; print ''; - $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); print ''; } diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 07c0146c2a8..f96bab63e2f 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -941,7 +941,7 @@ if ($action == 'create') print ''; print ''.$langs->trans('NotePublic').''; print ''; - $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); //print ''; print ''; @@ -952,7 +952,7 @@ if ($action == 'create') print ''; print ''.$langs->trans('NotePrivate').''; print ''; - $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); //print ''; print ''; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index cf6543c96e0..470a5cf0b0c 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1708,7 +1708,7 @@ if ($action == 'create') print ''.$langs->trans('NotePublic').''; print ''; - $doleditor = new DolEditor('note_public', isset($note_public) ? $note_public : GETPOST('note_public', 'restricthtml'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_public', isset($note_public) ? $note_public : GETPOST('note_public', 'restricthtml'), '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); print ''; //print ''; @@ -1716,7 +1716,7 @@ if ($action == 'create') print ''.$langs->trans('NotePrivate').''; print ''; - $doleditor = new DolEditor('note_private', isset($note_private) ? $note_private : GETPOST('note_private', 'restricthtml'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_private', isset($note_private) ? $note_private : GETPOST('note_private', 'restricthtml'), '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); print ''; //print ''; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index b439e5cad45..d9a8be9903c 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2109,7 +2109,7 @@ if ($action == 'create') // Public note print ''.$langs->trans('NotePublic').''; print ''; - $doleditor = new DolEditor('note_public', (GETPOSTISSET('note_public') ?GETPOST('note_public', 'restricthtml') : $note_public), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_public', (GETPOSTISSET('note_public') ?GETPOST('note_public', 'restricthtml') : $note_public), '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); print ''; // print ''; @@ -2118,7 +2118,7 @@ if ($action == 'create') // Private note print ''.$langs->trans('NotePrivate').''; print ''; - $doleditor = new DolEditor('note_private', (GETPOSTISSET('note_private') ?GETPOST('note_private', 'restricthtml') : $note_private), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_private', (GETPOSTISSET('note_private') ?GETPOST('note_private', 'restricthtml') : $note_private), '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); print ''; // print ''; diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 17454356c76..29cae07e11d 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -315,7 +315,7 @@ if ($action == 'create') print ''.$langs->trans('NotePrivate').''; print ''; - $doleditor = new DolEditor('note_private', GETPOST('note_private', 'alpha'), '', 160, 'dolibarr_notes', 'In', false, true, true, ROWS_6, '90%'); + $doleditor = new DolEditor('note_private', GETPOST('note_private', 'alpha'), '', 160, 'dolibarr_notes', 'In', false, true, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_6, '90%'); print $doleditor->Create(1); print ''; @@ -324,7 +324,7 @@ if ($action == 'create') print ''; print ''.$langs->trans('NotePublic').''; print ''; - $doleditor = new DolEditor('note_public', GETPOST('note_public', 'alpha'), '', 160, 'dolibarr_notes', 'In', false, true, true, ROWS_6, '90%'); + $doleditor = new DolEditor('note_public', GETPOST('note_public', 'alpha'), '', 160, 'dolibarr_notes', 'In', false, true, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_6, '90%'); print $doleditor->Create(1); print ''; diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 3bac7265606..0cf53b7dd4f 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -785,7 +785,7 @@ if ($action == 'create') // Note Public print ''.$langs->trans("NotePublic").''; print ''; - $doleditor = new DolEditor('note_public', $object->note_public, '', 60, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_public', $object->note_public, '', 60, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); print ""; @@ -794,7 +794,7 @@ if ($action == 'create') { print ''.$langs->trans("NotePrivate").''; print ''; - $doleditor = new DolEditor('note_private', $object->note_private, '', 60, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_private', $object->note_private, '', 60, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); print ""; } From 574f1f0336e43205cd1c5059d51e986d5dfab9f9 Mon Sep 17 00:00:00 2001 From: StephaneLesage Date: Sat, 21 Nov 2020 22:40:31 +0100 Subject: [PATCH 035/214] Add edit/delete action icons on categories list pages + classes for icons + format color as in latest commits --- htdocs/categories/edit.php | 23 +++++++++++++---- htdocs/categories/index.php | 40 +++++++++++++++++++++-------- htdocs/categories/viewcat.php | 48 ++++++++++++++++++++++++++--------- 3 files changed, 83 insertions(+), 28 deletions(-) diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index f4b7e12cc30..acb0aef2793 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -39,6 +39,7 @@ $type = GETPOST('type', 'aZ09'); // Can be int or string $action = (GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'edit'); $confirm = GETPOST('confirm'); $cancel = GETPOST('cancel', 'alpha'); +$backtopage = GETPOST('backtopage', 'alpha'); $socid = (int) GETPOST('socid', 'int'); $label = (string) GETPOST('label', 'alphanohtml'); @@ -74,8 +75,13 @@ $error = 0; */ if ($cancel) { - header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type); - exit; + if ($backtopage) { + header("Location: ".$backtopage); + exit; + } else { + header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type); + exit; + } } // Action mise a jour d'une categorie @@ -98,9 +104,15 @@ if ($action == 'update' && $user->rights->categorie->creer) { $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; - if (!$error && $object->update($user) > 0) { - header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type); - exit; + if (!$error && $object->update($user) > 0) + { + if ($backtopage) { + header("Location: ".$backtopage); + exit; + } else { + header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type); + exit; + } } else { setEventMessages($object->error, $object->errors, 'errors'); } @@ -131,6 +143,7 @@ print ''; print ''; print ''; print ''; +print ''; print dol_get_fiche_head(''); diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index 5adc7bbb17b..ff897db86a7 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -109,7 +109,7 @@ if (empty($nosearch)) { foreach ($cats as $cat) { - $color = $categstatic->color ? ' style="background: #'.$categstatic->color.';"' : ' style="background: #bbb"'; + $color = $categstatic->color ? ' style="background: #'.sprintf("%06s", $categstatic->color).';"' : ' style="background: #bbb"'; print "\t".''."\n"; print "\t\t"; @@ -160,26 +160,45 @@ foreach ($fulltree as $key => $val) $categstatic->ref = $val['label']; $categstatic->color = $val['color']; $categstatic->type = $type; - $li = $categstatic->getNomUrl(1, '', 60, $moreparam.'&backtolist='.urlencode($_SERVER["PHP_SELF"].'?type='.$type.$moreparam)); $desc = dol_htmlcleanlastbr($val['description']); $counter = ''; - if ($conf->global->CATEGORY_SHOW_COUNTS) { // we need only a count of the elements, so it is enough to consume only the id's from the database - $elements = $categstatic->getObjectsInCateg($type, 1); + $elements = $type == Categorie::TYPE_ACCOUNT + ? $categstatic->getObjectsInCateg("account", 1) // Categorie::TYPE_ACCOUNT is "bank_account" instead of "account" + : $categstatic->getObjectsInCateg($type, 1); + $counter = "".(is_countable($elements) ? count($elements) : '0').""; } $color = $categstatic->color ? ' style="background: #'.sprintf("%06s", $categstatic->color).';"' : ' style="background: #bbb"'; + $li = $categstatic->getNomUrl(1, '', 60, '&backtolist='.urlencode($_SERVER["PHP_SELF"].'?type='.$type.$moreparam)); - $data[] = array( - 'rowid'=>$val['rowid'], - 'fk_menu'=>$val['fk_parent'], - 'entry'=>''.$counter. - '
'.$li.''.img_view().'
' - ); + $entry = ''; + $entry .= ''; + + $entry .= ''; + + $entry .= $counter; + + $entry .= ''; + $entry .= ''; + $entry .= ''; + + $entry .= ''; + $entry .= '
'; + $entry .= ''.$li.''; + $entry .= ''; + $entry .= ''.img_view().''; + $entry .= ''; + $entry .= ''.img_edit().''; + $entry .= ''; + $entry .= ''.img_delete().''; + $entry .= '
'; + + $data[] = array('rowid' => $val['rowid'], 'fk_menu' => $val['fk_parent'], 'entry' => $entry); } @@ -194,7 +213,6 @@ if (!empty($conf->use_javascript_ajax)) print ''; $nbofentries = (count($data) - 1); - if ($nbofentries > 0) { print ''; diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 864de6e2e98..b376b3d3320 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -104,6 +104,14 @@ if ($objecttype != $type) { * Actions */ +if ($confirm == 'no') +{ + if ($backtopage) { + header("Location: ".$backtopage); + exit; + } +} + $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks // Remove element from category @@ -164,8 +172,13 @@ if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confi { if ($object->delete($user) >= 0) { - header("Location: ".DOL_URL_ROOT.'/categories/index.php?type='.$type); - exit; + if ($backtopage) { + header("Location: ".$backtopage); + exit; + } else { + header("Location: ".DOL_URL_ROOT.'/categories/index.php?type='.$type); + exit; + } } else { setEventMessages($object->error, $object->errors, 'errors'); } @@ -250,7 +263,11 @@ dol_banner_tab($object, 'label', $linkback, ($user->socid ? 0 : 1), 'label', 'la if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type, $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete', '', '', 1); + if ($backtopage) { + print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type.'&backtopage='.urlencode($backtopage), $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete', '', '', 2); + } else { + print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type, $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete', '', '', 1); + } } print '
'; @@ -294,7 +311,7 @@ if ($user->rights->categorie->creer) if ($user->rights->categorie->supprimer) { - print 'id.'&type='.$type.'">'.$langs->trans("Delete").''; + print 'id.'&type='.$type.'&backtolist='.urlencode($backtolist).'">'.$langs->trans("Delete").''; } print "
"; @@ -376,8 +393,7 @@ if ($cats < 0) $categstatic->type = $type; $desc = dol_htmlcleanlastbr($val['description']); - $counter = 0; - + $counter = ''; if ($conf->global->CATEGORY_SHOW_COUNTS) { // we need only a count of the elements, so it is enough to consume only the id's from the database @@ -385,22 +401,29 @@ if ($cats < 0) ? $categstatic->getObjectsInCateg("account", 1) // Categorie::TYPE_ACCOUNT is "bank_account" instead of "account" : $categstatic->getObjectsInCateg($type, 1); - $counter = is_countable($elements) ? count($elements) : 0; + $counter = "".(is_countable($elements) ? count($elements) : '0').""; } - $color = $categstatic->color ? ' style="background: #'.$categstatic->color.';"' : ' style="background: #aaa"'; + $color = $categstatic->color ? ' style="background: #'.sprintf("%06s", $categstatic->color).';"' : ' style="background: #bbb"'; + $li = $categstatic->getNomUrl(1, '', 60, '&backtolist='.urlencode($_SERVER["PHP_SELF"].'?id='.$id.'&type='.$type)); $entry = ''; $entry .= ''; $entry .= ''; - $entry .= ''; + $entry .= $counter; $entry .= ''; + $entry .= ''; + $entry .= ''; $entry .= ''; @@ -409,7 +432,8 @@ if ($cats < 0) $data[] = array('rowid' => $val['rowid'], 'fk_menu' => $val['fk_parent'], 'entry' => $entry); } - if ((count($data) - 1)) + $nbofentries = (count($data) - 1); + if ($nbofentries > 0) { require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; print ''; From 7749138a810a01470cb9327455b4f7be82498195 Mon Sep 17 00:00:00 2001 From: StephaneLesage Date: Sat, 21 Nov 2020 13:28:37 +0100 Subject: [PATCH 036/214] Fix /categories/edit.php which used type parameter instead of object's type Do not read type parameter Security check, display error and exit Get type from category object --- htdocs/categories/edit.php | 9 ++++++--- htdocs/categories/info.php | 7 ++++--- htdocs/categories/photos.php | 7 ++++--- htdocs/categories/traduction.php | 4 ++-- htdocs/categories/viewcat.php | 14 ++------------ 5 files changed, 18 insertions(+), 23 deletions(-) diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index f4b7e12cc30..ba04cde0b54 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -35,7 +35,6 @@ $langs->load("categories"); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alphanohtml'); -$type = GETPOST('type', 'aZ09'); // Can be int or string $action = (GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'edit'); $confirm = GETPOST('confirm'); $cancel = GETPOST('cancel', 'alpha'); @@ -56,10 +55,14 @@ if ($id == "") { $result = restrictedArea($user, 'categorie', $id, '&category'); $object = new Categorie($db); -if ($id > 0) { - $result = $object->fetch($id); +$result = $object->fetch($id, $label); +if ($result <= 0) { + dol_print_error($db, $object->error); exit; } +$type = $object->type; +if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility + $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($object->table_element); diff --git a/htdocs/categories/info.php b/htdocs/categories/info.php index f64f3be8f9e..2dd0476c5cd 100644 --- a/htdocs/categories/info.php +++ b/htdocs/categories/info.php @@ -43,10 +43,11 @@ if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'categorie', $id, '&category'); $object = new Categorie($db); -if (!$object->fetch($id) > 0) { - dol_print_error($db); - exit; +$result = $object->fetch($id); +if ($result <= 0) { + dol_print_error($db, $object->error); exit; } + $type = $object->type; if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index 73c7664f6c2..d09cf595620 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -38,7 +38,6 @@ $langs->loadlangs(array('categories', 'bills')); $id = GETPOST('id', 'int'); $label = GETPOST('label', 'alpha'); -$type = GETPOST('type'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm'); @@ -52,7 +51,7 @@ if ($id == '' && $label == '') $result = restrictedArea($user, 'categorie', $id, '&category'); $object = new Categorie($db); -$result = $object->fetch($id, $label, $type); +$result = $object->fetch($id, $label); if ($result <= 0) { dol_print_error($db, $object->error); exit; } @@ -60,10 +59,12 @@ $object->fetch_optionals(); if ($result <= 0) { dol_print_error($db, $object->error); exit; } -$upload_dir = $conf->categorie->multidir_output[$object->entity]; +$type = $object->type; if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility +$upload_dir = $conf->categorie->multidir_output[$object->entity]; + /* * Actions */ diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php index 423819c49ac..825f52f5b80 100644 --- a/htdocs/categories/traduction.php +++ b/htdocs/categories/traduction.php @@ -39,7 +39,6 @@ $id = GETPOST('id', 'int'); $label = GETPOST('label', 'alpha'); $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'alpha'); -$type = GETPOST('type', 'aZ09'); if ($id == '' && $label == '') { @@ -51,7 +50,7 @@ if ($id == '' && $label == '') $result = restrictedArea($user, 'categorie', $id, '&category'); $object = new Categorie($db); -$result = $object->fetch($id, $label, $type); +$result = $object->fetch($id, $label); if ($result <= 0) { dol_print_error($db, $object->error); exit; } @@ -60,6 +59,7 @@ if ($result <= 0) { dol_print_error($db, $object->error); exit; } +$type = $object->type; if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility /* diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 864de6e2e98..5503a7977be 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -38,7 +38,6 @@ $langs->load("categories"); $id = GETPOST('id', 'int'); $label = GETPOST('label', 'alpha'); -$type = GETPOST('type', 'aZ09'); $removeelem = GETPOST('removeelem', 'int'); $elemid = GETPOST('elemid', 'int'); @@ -73,7 +72,7 @@ if ($id == "" && $label == "") $result = restrictedArea($user, 'categorie', $id, '&category'); $object = new Categorie($db); -$result = $object->fetch($id, $label, $type); +$result = $object->fetch($id, $label); if ($result <= 0) { dol_print_error($db, $object->error); exit; } @@ -82,10 +81,7 @@ if ($result <= 0) { dol_print_error($db, $object->error); exit; } -$objecttype = $object->type; -if (is_numeric($objecttype)) $objecttype = Categorie::$MAP_ID_TO_CODE[$objecttype]; -if ($type === '') $type = $objecttype; - +$type = $object->type; if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility $extrafields = new ExtraFields($db); @@ -94,12 +90,6 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('categorycard', 'globalcard')); -// Protection when type provided is not similare to type of category -if ($objecttype != $type) { - print 'Error: Value for type parameter does not match value of the type of the category with id='.$id; - exit; -} - /* * Actions */ From 49225f3f57a2196915c2942cb43b2b1b8f79edbd Mon Sep 17 00:00:00 2001 From: StephaneLesage Date: Sat, 21 Nov 2020 15:57:11 +0100 Subject: [PATCH 037/214] Fix /categories/info.php navigation --- htdocs/categories/info.php | 7 ++++--- htdocs/categories/photos.php | 6 ------ htdocs/categories/traduction.php | 4 ---- htdocs/categories/viewcat.php | 7 +------ htdocs/core/lib/categories.lib.php | 2 +- 5 files changed, 6 insertions(+), 20 deletions(-) diff --git a/htdocs/categories/info.php b/htdocs/categories/info.php index 2dd0476c5cd..536b0c20a2c 100644 --- a/htdocs/categories/info.php +++ b/htdocs/categories/info.php @@ -37,13 +37,14 @@ $langs->loadLangs(array('categories', 'sendings')); $socid = 0; $id = GETPOST('id', 'int'); +$label = GETPOST('label', 'alpha'); // Security check if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'categorie', $id, '&category'); $object = new Categorie($db); -$result = $object->fetch($id); +$result = $object->fetch($id, $label); if ($result <= 0) { dol_print_error($db, $object->error); exit; } @@ -64,11 +65,11 @@ llxHeader('', $langs->trans('Categories'), ''); $title = Categorie::$MAP_TYPE_TITLE_AREA[$type]; $head = categories_prepare_head($object, $type); - print dol_get_fiche_head($head, 'info', $langs->trans($title), -1, 'category'); + $backtolist = (GETPOST('backtolist') ? GETPOST('backtolist') : DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type); $linkback = ''.$langs->trans("BackToList").''; -$object->next_prev_filter = ' type = '.$type; +$object->next_prev_filter = ' type = '.$object->type; $object->ref = $object->label; $morehtmlref = '
'.$langs->trans("Root").' >> '; $ways = $object->print_all_ways(" >> ", '', 1); diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index d09cf595620..6bb5d79980c 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -55,10 +55,6 @@ $result = $object->fetch($id, $label); if ($result <= 0) { dol_print_error($db, $object->error); exit; } -$object->fetch_optionals(); -if ($result <= 0) { - dol_print_error($db, $object->error); exit; -} $type = $object->type; if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility @@ -116,8 +112,6 @@ if ($object->id) $title = Categorie::$MAP_TYPE_TITLE_AREA[$type]; $head = categories_prepare_head($object, $type); - - print dol_get_fiche_head($head, 'photos', $langs->trans($title), -1, 'category'); $linkback = ''.$langs->trans("BackToList").''; diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php index 825f52f5b80..898484d0d51 100644 --- a/htdocs/categories/traduction.php +++ b/htdocs/categories/traduction.php @@ -54,10 +54,6 @@ $result = $object->fetch($id, $label); if ($result <= 0) { dol_print_error($db, $object->error); exit; } -$object->fetch_optionals(); -if ($result <= 0) { - dol_print_error($db, $object->error); exit; -} $type = $object->type; if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 5503a7977be..20f54a40788 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -76,10 +76,6 @@ $result = $object->fetch($id, $label); if ($result <= 0) { dol_print_error($db, $object->error); exit; } -$object->fetch_optionals(); -if ($result <= 0) { - dol_print_error($db, $object->error); exit; -} $type = $object->type; if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility @@ -216,9 +212,8 @@ llxHeader("", $langs->trans("Categories"), $helpurl, '', 0, 0, $arrayofjs, $arra $title = Categorie::$MAP_TYPE_TITLE_AREA[$type]; $head = categories_prepare_head($object, $type); - - print dol_get_fiche_head($head, 'card', $langs->trans($title), -1, 'category'); + $backtolist = (GETPOST('backtolist') ? GETPOST('backtolist') : DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type); $linkback = ''.$langs->trans("BackToList").''; $object->next_prev_filter = ' type = '.$object->type; diff --git a/htdocs/core/lib/categories.lib.php b/htdocs/core/lib/categories.lib.php index e900e6ff424..f6942cb5265 100644 --- a/htdocs/core/lib/categories.lib.php +++ b/htdocs/core/lib/categories.lib.php @@ -57,7 +57,7 @@ function categories_prepare_head(Categorie $object, $type) $h++; } - $head[$h][0] = DOL_URL_ROOT.'/categories/info.php?id='.$object->id; + $head[$h][0] = DOL_URL_ROOT.'/categories/info.php?id='.$object->id.'&type='.$type; $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; From c5ee976c7ea63ec1c7ea7b430fba788187eac600 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 16 Dec 2020 06:38:17 +0100 Subject: [PATCH 038/214] NEW: Accountancy - In ledger & journals, show link on bank transaction --- htdocs/accountancy/bookkeeping/list.php | 9 +++++++++ htdocs/accountancy/bookkeeping/listbyaccount.php | 9 +++++++++ htdocs/accountancy/bookkeeping/listbysubaccount.php | 9 +++++++++ 3 files changed, 27 insertions(+) diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index b3cec7710a4..ebd768de1dc 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -937,6 +937,11 @@ while ($i < min($num, $limit)) $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + } elseif ($line->doc_type == 'bank') + { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + $objectstatic = new AccountLine($db); + $objectstatic->fetch($line->fk_doc); } else { // Other type } @@ -951,6 +956,10 @@ while ($i < min($num, $limit)) { print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); print $documentlink; + } elseif ($line->doc_type == 'bank') { + print $objectstatic->getNomUrl(1); + $bank_ref = strstr($line->doc_ref, '-'); + print " " . $bank_ref; } else { print $line->doc_ref; } diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 7b8467f60bd..21ae4d9a22f 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -661,6 +661,11 @@ while ($i < min($num, $limit)) $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + } elseif ($line->doc_type == 'bank') + { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + $objectstatic = new AccountLine($db); + $objectstatic->fetch($line->fk_doc); } else { // Other type } @@ -675,6 +680,10 @@ while ($i < min($num, $limit)) { print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); print $documentlink; + } elseif ($line->doc_type == 'bank') { + print $objectstatic->getNomUrl(1); + $bank_ref = strstr($line->doc_ref, '-'); + print " " . $bank_ref; } else { print $line->doc_ref; } diff --git a/htdocs/accountancy/bookkeeping/listbysubaccount.php b/htdocs/accountancy/bookkeeping/listbysubaccount.php index 48c449df43e..535f1e94937 100644 --- a/htdocs/accountancy/bookkeeping/listbysubaccount.php +++ b/htdocs/accountancy/bookkeeping/listbysubaccount.php @@ -672,6 +672,11 @@ while ($i < min($num, $limit)) $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + } elseif ($line->doc_type == 'bank') + { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + $objectstatic = new AccountLine($db); + $objectstatic->fetch($line->fk_doc); } else { // Other type } @@ -686,6 +691,10 @@ while ($i < min($num, $limit)) { print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); print $documentlink; + } elseif ($line->doc_type == 'bank') { + print $objectstatic->getNomUrl(1); + $bank_ref = strstr($line->doc_ref, '-'); + print " " . $bank_ref; } else { print $line->doc_ref; } From 196fb07830e154f017639a45c35a9e10705549f7 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Mon, 21 Dec 2020 18:47:43 +0100 Subject: [PATCH 039/214] Fix edit variant v13+ after add, edit have same mistakes --- htdocs/variants/card.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/htdocs/variants/card.php b/htdocs/variants/card.php index 6cda745056a..9355b62f83b 100644 --- a/htdocs/variants/card.php +++ b/htdocs/variants/card.php @@ -44,7 +44,7 @@ if ($object->fetch($id) < 1) { if ($cancel) $action = ''; if ($action) { - if ($action == 'edit') { + if ($action == 'update') { $object->ref = $ref; $object->label = $label; @@ -55,7 +55,7 @@ if ($action) { header('Location: '.dol_buildpath('/variants/card.php?id='.$id, 2)); exit(); } - } elseif ($action == 'update') { + } elseif ($action == 'update_value') { if ($objectval->fetch($valueid) > 0) { $objectval->ref = $ref; $objectval->value = GETPOST('value', 'alpha'); @@ -139,8 +139,13 @@ $h++; print dol_get_fiche_head($head, 'variant', $langs->trans('ProductAttributeName'), -1, 'generic'); if ($action == 'edit') { - print '
'; -} + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } if ($action != 'edit') { @@ -232,7 +237,7 @@ if ($action == 'edit') { if ($action == 'edit_value') { print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; From 0e629204f29397125f0b76773921066c06a370e3 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 21 Dec 2020 17:49:49 +0000 Subject: [PATCH 040/214] Fixing style errors. --- htdocs/variants/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/variants/card.php b/htdocs/variants/card.php index 9355b62f83b..986db1b14bc 100644 --- a/htdocs/variants/card.php +++ b/htdocs/variants/card.php @@ -145,7 +145,7 @@ if ($action == 'edit') { print ''; print ''; print ''; - } +} if ($action != 'edit') { From f273273129526bb0ecaccf2a42932a96166fa449 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 22 Dec 2020 06:57:55 +0100 Subject: [PATCH 041/214] 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 '
'; - $entry .= ''.$categstatic->getNomUrl(1, '', 60).''; + $entry .= ''.$li.''; $entry .= ''.$counter.''; - $entry .= ''.img_view().''; + $entry .= ''.img_view().''; + $entry .= ''; + $entry .= ''.img_edit().''; + $entry .= ''; + $entry .= ''.img_delete().''; $entry .= '
'; 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 042/214] 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 0068c1fb78138fdad96dea92911ac36aed3f2636 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Dec 2020 10:56:27 +0100 Subject: [PATCH 043/214] Trans --- htdocs/langs/en_US/admin.lang | 1 - htdocs/langs/en_US/main.lang | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 537da1102e8..e3512280644 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -87,7 +87,6 @@ ShowPreview=Show preview ShowHideDetails=Show-Hide details PreviewNotAvailable=Preview not available ThemeCurrentlyActive=Theme currently active -CurrentTimeZone=TimeZone PHP (server) MySQLTimeZone=TimeZone MySql (database) TZHasNoEffect=Dates are stored and returned by database server as if they were kept as submitted string. The timezone has effect only when using the UNIX_TIMESTAMP function (that should not be used by Dolibarr, so database TZ should have no effect, even if changed after data was entered). Space=Space diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index c2eae911053..c6ce8ca9be0 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -28,6 +28,7 @@ NoTemplateDefined=No template available for this email type AvailableVariables=Available substitution variables NoTranslation=No translation Translation=Translation +CurrentTimeZone=TimeZone PHP (server) EmptySearchString=Enter non empty search criterias EnterADateCriteria=Enter a date criteria NoRecordFound=No record found From ef2bd563e281a629ea5325f42ef12b39290d4090 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Dec 2020 16:55:51 +0100 Subject: [PATCH 044/214] trans --- htdocs/langs/en_US/admin.lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index e3512280644..6fb096be175 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1988,8 +1988,8 @@ EmailcollectorOperations=Operations to do by collector MaxEmailCollectPerCollect=Max number of emails collected per collect CollectNow=Collect now ConfirmCloneEmailCollector=Are you sure you want to clone the Email collector %s ? -DateLastCollectResult=Date latest collect tried -DateLastcollectResultOk=Date latest collect successfull +DateLastCollectResult=Date of latest collect try +DateLastcollectResultOk=Date of latest collect success LastResult=Latest result EmailCollectorConfirmCollectTitle=Email collect confirmation EmailCollectorConfirmCollect=Do you want to run the collection for this collector now ? From 6fad9c2d3bb633d503f2274149ce4e7375ad5750 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Dec 2020 16:29:21 +0100 Subject: [PATCH 045/214] Fix edition of operation into email collector --- htdocs/admin/emailcollector_card.php | 57 ++++++++++++------- .../class/emailcollector.class.php | 5 +- htdocs/langs/en_US/admin.lang | 3 +- htdocs/langs/en_US/errors.lang | 3 +- htdocs/langs/en_US/mails.lang | 1 + htdocs/langs/en_US/main.lang | 1 + 6 files changed, 46 insertions(+), 24 deletions(-) diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index adfaaf4f816..6525013c6bc 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -153,13 +153,21 @@ if (GETPOST('addoperation', 'alpha')) $emailcollectoroperation->status = 1; $emailcollectoroperation->position = 50; - $result = $emailcollectoroperation->create($user); + if (in_array($emailcollectoroperation->type, array('loadthirdparty', 'loadandcreatethirdparty')) + && empty($emailcollectoroperation->actionparam)) { + $error++; + setEventMessages($langs->trans("ErrorAParameterIsRequiredForThisOperation"), null, 'errors'); + } - if ($result > 0) - { - $object->fetchActions(); - } else { - setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors'); + if (!$error) { + $result = $emailcollectoroperation->create($user); + + if ($result > 0) { + $object->fetchActions(); + } else { + $error++; + setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors'); + } } } @@ -170,13 +178,22 @@ if ($action == 'updateoperation') $emailcollectoroperation->actionparam = GETPOST('operationparam2', 'restricthtml'); - $result = $emailcollectoroperation->update($user); + if (in_array($emailcollectoroperation->type, array('loadthirdparty', 'loadandcreatethirdparty')) + && empty($emailcollectoroperation->actionparam)) { + $error++; + setEventMessages($langs->trans("ErrorAParameterIsRequiredForThisOperation"), null, 'errors'); + } - if ($result > 0) - { - $object->fetchActions(); - } else { - setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors'); + if (!$error) { + $result = $emailcollectoroperation->update($user); + + if ($result > 0) + { + $object->fetchActions(); + } else { + $error++; + setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors'); + } } } if ($action == 'deleteoperation') @@ -458,7 +475,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; 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 ''; print ''; // Add filter print ''; @@ -491,7 +508,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea 'isnotanswer'=>array('label'=>'IsNotAnAnswer', 'data-noparam'=>1), 'isanswer'=>array('label'=>'IsAnAnswer', 'data-noparam'=>1) ); - print $form->selectarray('filtertype', $arrayoftypes, '', 1, 0, 0, '', 1, 0, 0, '', 'maxwidth500', 0, '', 2); + print $form->selectarray('filtertype', $arrayoftypes, '', 1, 0, 0, '', 1, 0, 0, '', 'maxwidth500', 1, '', 2); print "\n"; print ''; - if ($acceptdelayedhtml) - { + if ($acceptdelayedhtml) { $delayedhtmlcontent .= $outdelayed; } else { $out .= $outdelayed; diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index 230c9a6b3bf..7fd93be7b71 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -174,5 +174,4 @@ Unanswered=Unanswered Answered=Answered IsNotAnAnswer=Is not answer (initial email) IsAnAnswer=Is an answer of an initial email -RecordCreatedByEmailCollector=Record created by the Email Collector %s from -email %s +RecordCreatedByEmailCollector=Record created by the Email Collector %s from email %s From eb3b0ad6729abf46f078489fe3acee2049351e82 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Jan 2021 13:24:06 +0100 Subject: [PATCH 202/214] Fix warning --- htdocs/webservices/server_thirdparty.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/webservices/server_thirdparty.php b/htdocs/webservices/server_thirdparty.php index 7c97159d0bb..a4f7e21221d 100644 --- a/htdocs/webservices/server_thirdparty.php +++ b/htdocs/webservices/server_thirdparty.php @@ -329,8 +329,9 @@ function getThirdParty($authentication, $id = '', $ref = '', $ref_ext = '') 'supplier_code' => $thirdparty->code_fournisseur, 'customer_code_accountancy' => $thirdparty->code_compta, 'supplier_code_accountancy' => $thirdparty->code_compta_fournisseur, - 'fk_user_author' => $thirdparty->fk_user_author, + 'user_creation' => $thirdparty->fk_user_creat, 'date_creation' => dol_print_date($thirdparty->date_creation, 'dayhourrfc'), + 'user_modification' => $thirdparty->fk_user_modif, 'date_modification' => dol_print_date($thirdparty->date_modification, 'dayhourrfc'), 'address' => $thirdparty->address, 'zip' => $thirdparty->zip, From 791a509c6c0c7dd9e1aa6d9b9a7be5d9fac01401 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Jan 2021 13:26:50 +0100 Subject: [PATCH 203/214] Fix warning --- htdocs/webservices/server_thirdparty.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/webservices/server_thirdparty.php b/htdocs/webservices/server_thirdparty.php index a4f7e21221d..6d44fe41ff6 100644 --- a/htdocs/webservices/server_thirdparty.php +++ b/htdocs/webservices/server_thirdparty.php @@ -370,7 +370,9 @@ function getThirdParty($authentication, $id = '', $ref = '', $ref_ext = '') { foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) { - $thirdparty_result_fields = array_merge($thirdparty_result_fields, array('options_'.$key => $thirdparty->array_options['options_'.$key])); + if (isset($thirdparty->array_options['options_'.$key])) { + $thirdparty_result_fields = array_merge($thirdparty_result_fields, array('options_'.$key => $thirdparty->array_options['options_'.$key])); + } } } @@ -623,7 +625,9 @@ function updateThirdParty($authentication, $thirdparty) foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) { $key = 'options_'.$key; - $object->array_options[$key] = $thirdparty[$key]; + if (isset($thirdparty[$key])) { + $object->array_options[$key] = $thirdparty[$key]; + } } } @@ -728,7 +732,9 @@ function getListOfThirdParties($authentication, $filterthirdparty) { foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) { - $extrafieldsOptions['options_'.$key] = $obj->{$key}; + if (isset($obj->{$key})) { + $extrafieldsOptions['options_'.$key] = $obj->{$key}; + } } } From 2727fd70b7167025154922ae1b1094d802c34951 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 2 Jan 2021 14:00:24 +0100 Subject: [PATCH 204/214] FIX: Accountancy - Debug experimental function to validate movements --- htdocs/accountancy/closure/index.php | 88 ++++++++++++- htdocs/accountancy/closure/validate.php | 156 ------------------------ htdocs/core/menus/standard/eldy.lib.php | 4 - htdocs/langs/en_US/accountancy.lang | 4 +- 4 files changed, 89 insertions(+), 163 deletions(-) delete mode 100644 htdocs/accountancy/closure/validate.php diff --git a/htdocs/accountancy/closure/index.php b/htdocs/accountancy/closure/index.php index ed8fc8ecc7e..a8531ca0887 100644 --- a/htdocs/accountancy/closure/index.php +++ b/htdocs/accountancy/closure/index.php @@ -25,11 +25,16 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; // Load translation files required by the page $langs->loadLangs(array("compta", "bills", "other", "main", "accountancy")); +$socid = GETPOST('socid', 'int'); + +$action = GETPOST('action', 'aZ09'); + // Security check if (empty($conf->accounting->enabled)) { accessforbidden(); @@ -39,6 +44,7 @@ if ($user->socid > 0) if (!$user->rights->accounting->fiscalyear->write) accessforbidden(); +$object = new BookKeeping($db); $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); @@ -60,14 +66,91 @@ $year_current = $year_start; /* * Actions */ +if ($action == 'validate_movements_confirm' && $user->rights->accounting->fiscalyear->write) { + $result = $object->fetchAll(); + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + } else { + // Specify as export : update field date_validated on selected month/year + $error = 0; + $db->begin(); + + $date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int')); + $date_end = dol_mktime(23, 59, 59, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int')); + + if (is_array($object->lines)) + { + foreach ($object->lines as $movement) + { + $now = dol_now(); + + $sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping"; + $sql .= " SET date_validated = '".$db->idate($now)."'"; + $sql .= " WHERE rowid = ".$movement->id; + $sql .= " AND doc_date >= '" . dol_print_date($date_start, 'dayrfc') . "'"; + $sql .= " AND doc_date <= '" . dol_print_date($date_end, 'dayrfc') . "'"; + + dol_syslog("/accountancy/closure/index.php :: Function validate_movement_confirm Specify movements as validated sql=".$sql, LOG_DEBUG); + $result = $db->query($sql); + if (!$result) + { + $error++; + break; + } + } + } + + if (!$error) + { + $db->commit(); + setEventMessages($langs->trans("AllMovementsWereRecordedAsValidated"), null, 'mesgs'); + } else { + $error++; + $db->rollback(); + setEventMessages($langs->trans("NotAllMovementsCouldBeRecordedAsValidated"), null, 'errors'); + } + header("Location: ".$_SERVER['PHP_SELF']."?year=".$year_start); + exit; + } +} /* * View */ +$form = new Form($db); +$formaccounting = new FormAccounting($db); + llxHeader('', $langs->trans("Closure")); +if ($action == 'validate_movements') { + $form_question = array(); + + $month = isset($conf->global->SOCIETE_FISCAL_MONTH_START) ? intval($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; + $date_start = new DateTime(sprintf('%04d-%02d-%02d', $year_start, $month, 1)); + $date_end = new DateTime(sprintf('%04d-%02d-%02d', $year_start, $month, 1)); + $date_end->add(new DateInterval('P1Y')); + $date_end->sub(new DateInterval('P1D')); + + $form_question['date_start'] = array( + 'name' => 'date_start', + 'type' => 'date', + 'label' => $langs->trans('DateStart'), + 'value' => $date_start->format('Y-m-d') + ); + $form_question['date_end'] = array( + 'name' => 'date_end', + 'type' => 'date', + 'label' => $langs->trans('DateEnd'), + 'value' => $date_end->format('Y-m-d') + ); + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?year='.$year_start, $langs->trans('ValidateMovements'), $langs->trans('DescValidateMovements', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'validate_movements_confirm', $form_question, '', 1, 300); + print $formconfirm; +} + $textprevyear = ''.img_previous().''; $textnextyear = ' '.img_next().''; @@ -80,9 +163,9 @@ print '
'; $y = $year_current; -$buttonbind = ''.$langs->trans("ValidateMovements").''; +$buttonvalidate = ''.$langs->trans("ValidateMovements").''; -print_barre_liste($langs->trans("OverviewOfMovementsNotValidated"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1); +print_barre_liste($langs->trans("OverviewOfMovementsNotValidated"), '', '', '', '', '', '', -1, '', '', 0, $buttonvalidate, '', 0, 1, 1); print '
'; print '
'.$langs->trans("Filters").''.$form->textwithpicto($langs->trans("Filters"), $langs->trans("EmailCollectorFilterDesc")).'
'; @@ -104,6 +187,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; $sql .= " WHERE b.doc_date >= '".$db->idate($search_date_start)."'"; $sql .= " AND b.doc_date <= '".$db->idate($search_date_end)."'"; $sql .= " AND b.entity IN (".getEntity('bookkeeping', 0).")"; // We don't share object for accountancy +$sql .= " AND date_validated IS NULL"; dol_syslog('htdocs/accountancy/closure/index.php sql='.$sql, LOG_DEBUG); $resql = $db->query($sql); diff --git a/htdocs/accountancy/closure/validate.php b/htdocs/accountancy/closure/validate.php deleted file mode 100644 index 1013ad1b6ce..00000000000 --- a/htdocs/accountancy/closure/validate.php +++ /dev/null @@ -1,156 +0,0 @@ - - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -/** - * \file htdocs/accountancy/closure/validate.php - * \ingroup Accountancy - * \brief Validate entries page - */ - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; - -// Load translation files required by the page -$langs->loadLangs(array("compta", "bills", "other", "main", "accountancy")); - -// Security check -if (empty($conf->accounting->enabled)) { - accessforbidden(); -} -if ($user->socid > 0) - accessforbidden(); - if (!$user->rights->accounting->fiscalyear->write) - accessforbidden(); - - -$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); -if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int'); -else { - $year_start = dol_print_date(dol_now(), '%Y'); - if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year -} -$year_end = $year_start + 1; -$month_end = $month_start - 1; -if ($month_end < 1) -{ - $month_end = 12; - $year_end--; -} -$search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start); -$search_date_end = dol_get_last_day($year_end, $month_end); -$year_current = $year_start; - -/* - * Actions - */ - -if ($action == 'validate') -{ - $now = dol_now(); - - // Update database - $db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; - $sql .= " SET b.date_validated = '".$db->idate($now)."'"; - $sql .= ' WHERE b.date_validated IS NULL'; - - dol_syslog("htdocs/accountancy/closure/validate.php validate", LOG_DEBUG); - $resql = $db->query($sql); - if (!$resql1) { - $error++; - $db->rollback(); - setEventMessages($db->lasterror(), null, 'errors'); - } else { - $db->commit(); - } - // End clean database -} - - -/* - * View - */ - -llxHeader('', $langs->trans("ValidateMovements")); - -$textprevyear = ''.img_previous().''; -$textnextyear = ' '.img_next().''; - - -print load_fiche_titre($langs->trans("ValidateMovements")." ".$textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, '', 'title_accountancy'); - -print $langs->trans("DescValidateMovements").'
'; -print '
'; - - -$y = $year_current; - -print_barre_liste($langs->trans("SelectMonthAndValidate"), '', '', '', '', '', '', -1, '', '', 0, '', 'class="right"', 0, 1, 1); - -print '
'; -print '
'; -print ''; -for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; - if ($j > 12) $j -= 12; - print ''; -} -print ''; - -print ''; -$sql = "SELECT COUNT(b.rowid) as detail,"; -for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; - if ($j > 12) $j -= 12; - $sql .= " SUM(".$db->ifsql('MONTH(b.doc_date)='.$j, '1', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; -} -$sql .= " COUNT(b.rowid) as total"; -$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; -$sql .= " WHERE b.doc_date >= '".$db->idate($search_date_start)."'"; -$sql .= " AND b.doc_date <= '".$db->idate($search_date_end)."'"; -$sql .= " AND b.entity IN (".getEntity('bookkeeping', 0).")"; // We don't share object for accountancy - -dol_syslog('htdocs/accountancy/closure/index.php sql='.$sql, LOG_DEBUG); -$resql = $db->query($sql); -if ($resql) { - $num = $db->num_rows($resql); - - while ($row = $db->fetch_row($resql)) { - for ($i = 1; $i <= 12; $i++) { - print ''; - } - print ''; - } - - $db->free($resql); -} else { - print $db->lasterror(); // Show last sql error -} -print ''; -print "
'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).''.$langs->trans("Total").'
'.$row[$i].'

'; - print ''; - print '
'.$row[13].'
\n"; - -print '
'; -print '
'; - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 85b63a6f4e3..46950bdc50c 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1334,10 +1334,6 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Closure if (!empty($conf->global->MAIN_FEATURES_LEVEL) && $conf->global->MAIN_FEATURES_LEVEL >= 2) { $newmenu->add("/accountancy/closure/index.php?mainmenu=accountancy&leftmenu=accountancy_closure", $langs->trans("MenuAccountancyClosure"), 1, $user->rights->accounting->fiscalyear->write, '', $mainmenu, 'closure'); - - if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_closure/', $leftmenu)) { - $newmenu->add("/accountancy/closure/validate.php?leftmenu=accountancy_closure", $langs->trans("MenuAccountancyValidationMovements"), 2, $user->rights->accounting->fiscalyear->write); - } } // Reports diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index c7ce4ac6b0b..bda6502aeed 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -274,11 +274,13 @@ DescVentilExpenseReport=Consult here the list of expense report lines bound (or DescVentilExpenseReportMore=If you setup accounting account on type of expense report lines, the application will be able to make all the binding between your expense report lines and the accounting account of your chart of accounts, just in one click with the button "%s". If account was not set on fees dictionary or if you still have some lines not bound to any account, you will have to make a manual binding from the menu "%s". DescVentilDoneExpenseReport=Consult here the list of the lines of expenses reports and their fees accounting account +Closure=Annual closure DescClosure=Consult here the number of movements by month who are not validated & fiscal years already open OverviewOfMovementsNotValidated=Step 1/ Overview of movements not validated. (Necessary to close a fiscal year) +AllMovementsWereRecordedAsValidated=All movements were recorded as validated +NotAllMovementsCouldBeRecordedAsValidated=Not all movements could be recorded as validated ValidateMovements=Validate movements DescValidateMovements=Any modification or deletion of writing, lettering and deletes will be prohibited. All entries for an exercise must be validated otherwise closing will not be possible -SelectMonthAndValidate=Select month and validate movements ValidateHistory=Bind Automatically AutomaticBindingDone=Automatic binding done From a8d15fafd22707600afb54339ca1b6aef03914ad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Jan 2021 14:17:54 +0100 Subject: [PATCH 205/214] Fix missing span --- htdocs/admin/limits.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/limits.php b/htdocs/admin/limits.php index caf2192a9a3..ed3578522d4 100644 --- a/htdocs/admin/limits.php +++ b/htdocs/admin/limits.php @@ -293,7 +293,7 @@ if (empty($mysoc->country_code)) print ''.$langs->trans("UnitPriceOfProduct").": ".price2num($s, 'MU'); print " x ".$langs->trans("Quantity").": ".$qty; print " - ".$langs->trans("VAT").": ".$vat.'%'; - print '   ->   '.$langs->trans("TotalPriceAfterRounding").": ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."
\n"; + print '   ->   '.$langs->trans("TotalPriceAfterRounding").": ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."
\n"; $s = 10 / 3; $qty = 2; $vat = 10; $tmparray = calcul_price_total($qty, price2num($s, 'MU'), 0, $vat, -1, -1, 0, 'HT', 0, 0, $mysoc, $localtax_array); From 601d4618d4c7bd50ab2e287df8f8ba1a3161cb76 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Jan 2021 14:52:37 +0100 Subject: [PATCH 206/214] Missing vat rates --- htdocs/install/mysql/data/llx_c_tva.sql | 27 ++++++++++++++++--------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/htdocs/install/mysql/data/llx_c_tva.sql b/htdocs/install/mysql/data/llx_c_tva.sql index 793b29ab640..7156812fb01 100644 --- a/htdocs/install/mysql/data/llx_c_tva.sql +++ b/htdocs/install/mysql/data/llx_c_tva.sql @@ -35,6 +35,16 @@ delete from llx_c_tva; +-- ALGERIA (id country=13) +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 131, 13, '0','0','TVA 0%', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 132, 13, '9','0','TVA 9%',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 133, 13, '19','0','TVA 19%', 1); + +-- ANGOLA (id country=35) +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 351, 35, '0','0','VAT Rate 0', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 352, 35, '7','0','VAT reduced rate',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 353, 35, '14','0','VAT standard rate',1); + -- ARGENTINA (id country=23) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (231, 23, '0','0','IVA Rate 0', 1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (232, 23,'10.5','0','IVA reduced rate',1); @@ -202,6 +212,13 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 1 insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 173, 17, '19','0','Algemeen BTW tarief',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 174, 17, '21','0','Algemeen BTW tarief (vanaf 1 oktober 2012)',0); +-- NEW CALEDONIA (id country=165) +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1651, 165, '0','0','VAT Rate 0', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1652, 165, '3','0','VAT standard 3', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1653, 165, '6','0','VAT standard 6', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1654, 165, '11','0','VAT standard rate', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1655, 165, '22','0','VAT standard high', 1); + -- NEW ZEALAND (id country=166) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1661, 166, '0','0','VAT Rate 0', 1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1662, 166, '15','0','VAT standard rate', 1); @@ -361,16 +378,6 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (23 insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2322,232, '12','0','VAT 12%',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2323,232, '8','0','VAT 8%',1); --- ALGERIA(id country=13) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 131, 13, '0','0','TVA 0%', 1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 132, 13, '9','0','TVA 9%',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 133, 13, '19','0','TVA 19%', 1); - --- ANGOLA (id country=35) -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 351, 35, '0','0','VAT Rate 0', 1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 352, 35, '7','0','VAT reduced rate',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 353, 35, '14','0','VAT standard rate',1); - -- Example of code to insert a vat rate 0 for each country --delete from llx_c_tva where rowid = 1181; -- to delete a record that does not follow rules for rowid (fk_pays+'1') --insert into llx_c_tva(rowid, fk_pays, taux, recuperableonly, note, active) SELECT CONCAT(c.rowid, '1'), c.rowid, 0, 0, 'No VAT', 1 from llx_c_country as c where c.rowid not in (select fk_pays from llx_c_tva); From d46eb08083a5239a0e9196d968e3b2b4bb556363 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Jan 2021 15:36:19 +0100 Subject: [PATCH 207/214] More log and use id to refresh/reload an invoice. --- htdocs/takepos/index.php | 5 +++-- htdocs/takepos/invoice.php | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 4bfeaa57b75..51b6334a2c9 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -155,6 +155,7 @@ var pageactions=0; var place=""; var editaction="qty"; var editnumber=""; +var invoiceid=0; /* var app = this; @@ -448,8 +449,8 @@ function TakeposOrderNotes() { } function Refresh() { - console.log("Refresh by reloading place="+place); - $("#poslines").load("invoice.php?place="+place, function() { + console.log("Refresh by reloading place="+place+" invoiceid="+invoiceid); + $("#poslines").load("invoice.php?place="+place+"&invoiceid="+invoiceid, function() { //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); }); } diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 0909f1b3cca..f31bb90bfcd 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -742,7 +742,7 @@ function DolibarrTakeposPrinting(id) { $( document ).ready(function() { - console.log("Set customer info and sales in header"); + console.log("Set customer info and sales in header placeid= status=statut; ?>"); trans("Customer"); @@ -757,7 +757,14 @@ $( document ).ready(function() { global->TAKEPOS_CAN_EDIT_IF_ALREADY_VALIDATED)) { + // By default, only invoices with a ref not already defined can in list of open invoice we can edit. + $sql .= " WHERE ref LIKE '(PROV-POS".$_SESSION["takeposterminal"]."-0%'"; + } else { + // If TAKEPOS_CAN_EDIT_IF_ALREADY_VALIDATED set, we show also draft invoice that already has a reference defined + $sql .= " WHERE pos_source = ".$_SESSION["takeposterminal"]; + $sql .= " AND module_source = 'takepos'"; + } $sql .= $db->order('datec', 'ASC'); $resql = $db->query($sql); if ($resql) { @@ -767,7 +774,9 @@ $( document ).ready(function() { $num_sale = str_replace(")", "", str_replace("(PROV-POS".$_SESSION["takeposterminal"]."-", "", $obj->ref)); echo $num_sale; if (str_replace("-", "", $num_sale) > $max_sale) $max_sale = str_replace("-", "", $num_sale); - echo '\\\';Refresh();">'; + echo '\\\'; invoiceid=\\\''; + echo $obj->rowid; + echo '\\\'; Refresh();">'; if ($placeid == $obj->rowid) echo ""; echo dol_print_date($db->jdate($obj->datec), '%H:%M', 'tzuser'); if ($placeid == $obj->rowid) echo ""; @@ -775,7 +784,7 @@ $( document ).ready(function() { } echo '$("#customerandsales").append(\'\');'; + echo '\\\'; invoiceid=0; Refresh();">\');'; } else { dol_print_error($db); } From 02ae06f24abdd2e7c45f704568c61e3778ef03a8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Jan 2021 15:52:12 +0100 Subject: [PATCH 208/214] Fix warning --- htdocs/webservices/server_thirdparty.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/webservices/server_thirdparty.php b/htdocs/webservices/server_thirdparty.php index 6d44fe41ff6..d7ded82cc3f 100644 --- a/htdocs/webservices/server_thirdparty.php +++ b/htdocs/webservices/server_thirdparty.php @@ -329,9 +329,9 @@ function getThirdParty($authentication, $id = '', $ref = '', $ref_ext = '') 'supplier_code' => $thirdparty->code_fournisseur, 'customer_code_accountancy' => $thirdparty->code_compta, 'supplier_code_accountancy' => $thirdparty->code_compta_fournisseur, - 'user_creation' => $thirdparty->fk_user_creat, + 'user_creation' => $thirdparty->user_creation, 'date_creation' => dol_print_date($thirdparty->date_creation, 'dayhourrfc'), - 'user_modification' => $thirdparty->fk_user_modif, + 'user_modification' => $thirdparty->user_modification, 'date_modification' => dol_print_date($thirdparty->date_modification, 'dayhourrfc'), 'address' => $thirdparty->address, 'zip' => $thirdparty->zip, From 2d22c1d5d167622b46f97765cfd7b31dd5bfdc80 Mon Sep 17 00:00:00 2001 From: Aisuko <17001223+AisukoWasTaken@users.noreply.github.com> Date: Fri, 1 Jan 2021 22:53:01 +0100 Subject: [PATCH 209/214] Fix wrong cast for pos_change The variable pos_change was cast in "int" where it should be cast in "float". It results in rounded value making the receipt showing wrong cash exchange. --- htdocs/compta/paiement/class/paiement.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 28635a2df60..6b7f1612836 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -294,7 +294,7 @@ class Paiement extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, ref_ext, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, ext_payment_id, ext_payment_site, fk_user_creat, pos_change)"; $sql .= " VALUES (".$conf->entity.", '".$this->db->escape($this->ref)."', '".$this->db->escape($this->ref_ext)."', '".$this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', ".$total.", ".$mtotal.", ".$this->paiementid.", "; - $sql .= "'".$this->db->escape($num_payment)."', '".$this->db->escape($note)."', ".($this->ext_payment_id ? "'".$this->db->escape($this->ext_payment_id)."'" : "null").", ".($this->ext_payment_site ? "'".$this->db->escape($this->ext_payment_site)."'" : "null").", ".$user->id.", ".((int) $this->pos_change).")"; + $sql .= "'".$this->db->escape($num_payment)."', '".$this->db->escape($note)."', ".($this->ext_payment_id ? "'".$this->db->escape($this->ext_payment_id)."'" : "null").", ".($this->ext_payment_site ? "'".$this->db->escape($this->ext_payment_site)."'" : "null").", ".$user->id.", ".((float) $this->pos_change).")"; $resql = $this->db->query($sql); if ($resql) From ce0abd17fe543c12606f585ca9085925072deb5a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Jan 2021 16:18:16 +0100 Subject: [PATCH 210/214] Debug v13 --- htdocs/commande/card.php | 6 +++--- htdocs/compta/facture/card-rec.php | 8 ++++---- htdocs/contrat/card.php | 8 ++++---- htdocs/core/lib/functions.lib.php | 18 +++++++++++++----- htdocs/fourn/commande/card.php | 10 +++++----- htdocs/fourn/facture/card.php | 10 +++++----- htdocs/supplier_proposal/card.php | 10 +++++----- 7 files changed, 39 insertions(+), 31 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 213819b0915..2ea5c37bf39 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -631,9 +631,9 @@ if (empty($reshook)) // Set if we used free entry or predefined product $predef = ''; - $product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : ''); - $price_ht = GETPOST('price_ht'); - $price_ht_devise = GETPOST('multicurrency_price_ht'); + $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); + $price_ht = price2num(GETPOST('price_ht'), 'MU'); + $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CR'); $prod_entry_mode = GETPOST('prod_entry_mode'); if ($prod_entry_mode == 'free') { diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index b978de677a9..097585dbea0 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -437,9 +437,9 @@ if (empty($reshook)) // Set if we used free entry or predefined product $predef = ''; - $product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : ''); - $price_ht = GETPOST('price_ht'); - $price_ht_devise = GETPOST('multicurrency_price_ht'); + $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); + $price_ht = price2num(GETPOST('price_ht'), 'MU'); + $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CR'); $prod_entry_mode = GETPOST('prod_entry_mode', 'alpha'); if ($prod_entry_mode == 'free') { @@ -450,7 +450,7 @@ if (empty($reshook)) $tva_tx = ''; } - $qty = GETPOST('qty'.$predef); + $qty = price2num(GETPOST('qty'.$predef), 'alpha'); $remise_percent = GETPOST('remise_percent'.$predef); // Extrafields diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 2e692dc25c4..d07b8dcc60e 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -383,9 +383,9 @@ if (empty($reshook)) { // Set if we used free entry or predefined product $predef = ''; - $product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : ''); - $price_ht = price2num(GETPOST('price_ht')); - $price_ht_devise = price2num(GETPOST('multicurrency_price_ht')); + $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); + $price_ht = price2num(GETPOST('price_ht'), 'MU'); + $price_ht_devise = price2num(GETPOST('multicurrency_price_ht', 'CR'); if (GETPOST('prod_entry_mode', 'alpha') == 'free') { $idprod = 0; @@ -395,7 +395,7 @@ if (empty($reshook)) $tva_tx = ''; } - $qty = price2num(GETPOST('qty'.$predef)); + $qty = price2num(GETPOST('qty'.$predef), 'alpha'); $remise_percent = ((GETPOST('remise_percent'.$predef) != '') ? GETPOST('remise_percent'.$predef) : 0); if ($qty == '') diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a156f35292e..8c1765620ec 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4810,7 +4810,7 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $ * 'MU'=Round to Max unit price (MAIN_MAX_DECIMALS_UNIT) * 'MT'=Round to Max for totals with Tax (MAIN_MAX_DECIMALS_TOT) * 'MS'=Round to Max for stock quantity (MAIN_MAX_DECIMALS_STOCK) - * 'CR'=Currency rate + * 'CR'=Foreign currency accurancy * Numeric = Nb of digits for rounding * @param int $option Put 1 if you know that content is already universal format number (so no correction on decimal will be done) * Put 2 if you know that number is a user input (so we know we don't have to fix decimal separator). @@ -4871,10 +4871,18 @@ function price2num($amount, $rounding = '', $option = 0) if ($rounding) { $nbofdectoround = ''; - if ($rounding == 'MU') $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_UNIT; - elseif ($rounding == 'MT') $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_TOT; - elseif ($rounding == 'MS') $nbofdectoround = empty($conf->global->MAIN_MAX_DECIMALS_STOCK) ? 5 : $conf->global->MAIN_MAX_DECIMALS_STOCK; - elseif ($rounding == 'CR') $nbofdectoround = 8; + if ($rounding == 'MU') { + $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_UNIT; + } + elseif ($rounding == 'MT') { + $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_TOT; + } + elseif ($rounding == 'MS') { + $nbofdectoround = empty($conf->global->MAIN_MAX_DECIMALS_STOCK) ? 5 : $conf->global->MAIN_MAX_DECIMALS_STOCK; + } + elseif ($rounding == 'CR') { + $nbofdectoround = max($conf->global->MAIN_MAX_DECIMALS_TOT, 8); + } elseif (is_numeric($rounding)) $nbofdectoround = $rounding; //print "RR".$amount.' - '.$nbofdectoround.'
'; if (dol_strlen($nbofdectoround)) $amount = round(is_string($amount) ? (float) $amount : $amount, $nbofdectoround); // $nbofdectoround can be 0. diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 987b80aa3ea..710657e1c16 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -356,24 +356,24 @@ if (empty($reshook)) // Set if we used free entry or predefined product $predef = ''; - $product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : ''); + $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); $prod_entry_mode = GETPOST('prod_entry_mode'); if ($prod_entry_mode == 'free') { $idprod = 0; - $price_ht = GETPOST('price_ht'); + $price_ht = price2num(GETPOST('price_ht'), 'MU'); $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); } else { $idprod = GETPOST('idprod', 'int'); - $price_ht = GETPOST('price_ht'); + $price_ht = price2num(GETPOST('price_ht'), 'MU'); $tva_tx = ''; } - $qty = GETPOST('qty'.$predef); + $qty = price2num(GETPOST('qty'.$predef), 'alpha'); $remise_percent = GETPOST('remise_percent'.$predef); - $price_ht_devise = GETPOST('multicurrency_price_ht'); + $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CR'); // Extrafields $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index c615817e36f..998ef884766 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1175,7 +1175,7 @@ if (empty($reshook)) // Set if we used free entry or predefined product $predef = ''; - $product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : ''); + $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); @@ -1183,17 +1183,17 @@ if (empty($reshook)) if ($prod_entry_mode == 'free') { $idprod = 0; - $price_ht = GETPOST('price_ht'); + $price_ht = price2num(GETPOST('price_ht'), 'MU'); $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); } else { $idprod = GETPOST('idprod', 'int'); - $price_ht = GETPOST('price_ht'); + $price_ht = price2num(GETPOST('price_ht'), 'MU'); $tva_tx = ''; } - $qty = GETPOST('qty'.$predef); + $qty = price2num(GETPOST('qty'.$predef), 'alpha'); $remise_percent = GETPOST('remise_percent'.$predef); - $price_ht_devise = GETPOST('multicurrency_price_ht'); + $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CR'); // Extrafields $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index ae40784aa68..a571a207bc5 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -540,24 +540,24 @@ if (empty($reshook)) // Set if we used free entry or predefined product $predef = ''; - $product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : ''); + $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); $ref_supplier = GETPOST('fourn_ref', 'alpha'); $prod_entry_mode = GETPOST('prod_entry_mode'); if ($prod_entry_mode == 'free') { $idprod = 0; - $price_ht = GETPOST('price_ht'); + $price_ht = price2num(GETPOST('price_ht'), 'MU'); $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); } else { $idprod = GETPOST('idprod', 'int'); - $price_ht = GETPOST('price_ht'); + $price_ht = price2num(GETPOST('price_ht'), 'MU'); $tva_tx = ''; } - $qty = GETPOST('qty'.$predef); + $qty = price2num(GETPOST('qty'.$predef), 'alpha'); $remise_percent = GETPOST('remise_percent'.$predef); - $price_ht_devise = GETPOST('multicurrency_price_ht'); + $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CR'); // Extrafields $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); From fd4dab495f010fc170c94ab3e6d5a47be7e7f605 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Jan 2021 16:51:34 +0100 Subject: [PATCH 211/214] FIX Bad cleaning of VAT rate when numbers are into code --- htdocs/comm/propal/class/propal.class.php | 5 ++++- htdocs/commande/class/commande.class.php | 4 +++- htdocs/compta/facture/class/facture-rec.class.php | 11 ++++++++--- htdocs/compta/facture/class/facture.class.php | 4 +++- htdocs/contrat/class/contrat.class.php | 1 - htdocs/fichinter/class/fichinterrec.class.php | 4 +++- htdocs/fourn/class/fournisseur.commande.class.php | 4 +++- .../class/supplier_proposal.class.php | 11 ++++++++--- 8 files changed, 32 insertions(+), 12 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 144374ab47c..9d6b6c201c5 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -602,6 +602,7 @@ class Propal extends CommonObject // Clean vat code $vat_src_code = ''; + $reg = array(); if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; @@ -779,7 +780,9 @@ class Propal extends CommonObject $qty = price2num($qty); $pu = price2num($pu); $pu_ht_devise = price2num($pu_ht_devise); - $txtva = price2num($txtva); + if (!preg_match('/\((.*)\)/', $txtva)) { + $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' + } $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); $pa_ht = price2num($pa_ht); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 5402d31ba7d..49f8005980f 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3120,7 +3120,9 @@ class Commande extends CommonOrder $pu = price2num($pu); $pa_ht = price2num($pa_ht); $pu_ht_devise = price2num($pu_ht_devise); - $txtva = price2num($txtva); + if (!preg_match('/\((.*)\)/', $txtva)) { + $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' + } $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index c5bd8a987ac..85ecb3f969d 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -849,7 +849,9 @@ class FactureRec extends CommonInvoice $qty = price2num($qty); $pu_ht = price2num($pu_ht); $pu_ttc = price2num($pu_ttc); - $txtva = price2num($txtva); + if (!preg_match('/\((.*)\)/', $txtva)) { + $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' + } $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); if (empty($txtva)) $txtva = 0; @@ -1031,8 +1033,10 @@ class FactureRec extends CommonInvoice $pu_ht = price2num($pu_ht); $pu_ttc = price2num($pu_ttc); $pu_ht_devise = price2num($pu_ht_devise); - $txtva = price2num($txtva); - $txlocaltax1 = price2num($txlocaltax1); + if (!preg_match('/\((.*)\)/', $txtva)) { + $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' + } + $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); if (empty($txlocaltax1)) $txlocaltax1 = 0; if (empty($txlocaltax2)) $txlocaltax2 = 0; @@ -1059,6 +1063,7 @@ class FactureRec extends CommonInvoice // Clean vat code $vat_src_code = ''; + $reg = array(); if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 4bfc36a3e78..392817b0368 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3311,7 +3311,9 @@ class Facture extends CommonInvoice $pu = price2num($pu); $pu_ht_devise = price2num($pu_ht_devise); $pa_ht = price2num($pa_ht); - $txtva = price2num($txtva); + if (!preg_match('/\((.*)\)/', $txtva)) { + $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' + } $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index e38c24565dd..13f0ba644d0 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1502,7 +1502,6 @@ class Contrat extends CommonObject $vat_src_code = $reg[1]; $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } - $txtva = price2num($txtva); $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); diff --git a/htdocs/fichinter/class/fichinterrec.class.php b/htdocs/fichinter/class/fichinterrec.class.php index 5b3dfb3a2fc..2d678514182 100644 --- a/htdocs/fichinter/class/fichinterrec.class.php +++ b/htdocs/fichinter/class/fichinterrec.class.php @@ -473,7 +473,9 @@ class FichinterRec extends Fichinter if (!$info_bits) $info_bits = 0; $pu_ht = price2num($pu_ht); $pu_ttc = price2num($pu_ttc); - $txtva = price2num($txtva); + if (!preg_match('/\((.*)\)/', $txtva)) { + $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' + } if ($price_base_type == 'HT') { $pu = $pu_ht; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index af283d8cdf0..123b1eb0046 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2633,7 +2633,9 @@ class CommandeFournisseur extends CommonOrder if (!$qty) $qty = 1; $pu = price2num($pu); $pu_ht_devise = price2num($pu_ht_devise); - $txtva = price2num($txtva); + if (!preg_match('/\((.*)\)/', $txtva)) { + $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' + } $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 33c80f9b6b1..9822c171cd8 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -423,10 +423,13 @@ class SupplierProposal extends CommonObject $qty = price2num($qty); $pu_ht = price2num($pu_ht); $pu_ttc = price2num($pu_ttc); - $txtva = price2num($txtva); + if (!preg_match('/\((.*)\)/', $txtva)) { + $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' + } $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); - $pa_ht = price2num($pa_ht); + + $pa_ht = price2num($pa_ht); if ($price_base_type == 'HT') { $pu = $pu_ht; @@ -682,7 +685,9 @@ class SupplierProposal extends CommonObject $remise_percent = price2num($remise_percent); $qty = price2num($qty); $pu = price2num($pu); - $txtva = price2num($txtva); + if (!preg_match('/\((.*)\)/', $txtva)) { + $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' + } $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); $pa_ht = price2num($pa_ht); From 982f8eb95d2be6300cbcdc2400a8bdf016a76335 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Jan 2021 17:03:26 +0100 Subject: [PATCH 212/214] Fix syntax error --- htdocs/contrat/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index d07b8dcc60e..9b1a3b34808 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -385,7 +385,7 @@ if (empty($reshook)) $predef = ''; $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); $price_ht = price2num(GETPOST('price_ht'), 'MU'); - $price_ht_devise = price2num(GETPOST('multicurrency_price_ht', 'CR'); + $price_ht_devise = price2num(GETPOST('multicurrency_price_ht', 'CR')); if (GETPOST('prod_entry_mode', 'alpha') == 'free') { $idprod = 0; From 2d1121031a886398a31594684785ed8040bc8558 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Jan 2021 17:04:08 +0100 Subject: [PATCH 213/214] var not defined --- htdocs/contrat/card.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 9b1a3b34808..64f8fd92477 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -89,6 +89,7 @@ $extralabelslines = $extrafields->fetch_name_optionals_label($object->table_elem $permissionnote = $user->rights->contrat->creer; // Used by the include of actions_setnotes.inc.php $permissiondellink = $user->rights->contrat->creer; // Used by the include of actions_dellink.inc.php +$error = 0; /* From 821ef72d482c4669d2d3c3e286551cb9d8a9063b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Jan 2021 17:43:02 +0100 Subject: [PATCH 214/214] Fix warnings --- .../email_expire_services_to_customers.php | 24 +++++++++----- ...ail_expire_services_to_representatives.php | 23 ++++++++----- .../email_unpaid_invoices_to_customers.php | 32 ++++++++++++------- ...ail_unpaid_invoices_to_representatives.php | 11 ++++--- 4 files changed, 57 insertions(+), 33 deletions(-) diff --git a/scripts/contracts/email_expire_services_to_customers.php b/scripts/contracts/email_expire_services_to_customers.php index 5c98dc2913b..596a5794d70 100755 --- a/scripts/contracts/email_expire_services_to_customers.php +++ b/scripts/contracts/email_expire_services_to_customers.php @@ -74,8 +74,9 @@ $duration_value2 = isset($argv[4]) ? $argv[4] : 'none'; $error = 0; print $script_file." launched with mode ".$mode." default lang=".$langs->defaultlang.(is_numeric($duration_value) ? " delay=".$duration_value : "").(is_numeric($duration_value2) ? " after=".$duration_value2 : "")."\n"; -if ($mode != 'confirm') +if ($mode != 'confirm') { $conf->global->MAIN_DISABLE_ALL_MAILS = 1; +} $sql = "SELECT c.ref, cd.date_fin_validite, cd.total_ttc, cd.description as description, p.label as plabel,"; $sql .= " s.rowid as sid, s.nom as name, s.email, s.default_lang"; @@ -115,6 +116,7 @@ if ($resql) { print "We found ".$num." couples (services to expire-".$targettype.") qualified\n"; dol_syslog("We found ".$num." couples (services to expire-".$targettype.") qualified"); $message = ''; + $oldtarget = ''; if ($num) { while ($i < $num) { @@ -124,12 +126,17 @@ if ($resql) { // Check if this record is a break after previous one $startbreak = false; - if ($newemail != $oldemail || $oldemail == 'none') + if ($newemail != $oldemail || $oldemail == 'none') { $startbreak = true; - if ($obj->sid && $obj->sid != $oldsid) - $startbreak = true; - if ($obj->cid && $obj->cid != $oldcid) + } + if ($obj->sid && $obj->sid != $oldsid) { $startbreak = true; + } + if ($targettype == 'contacts') { + if ($obj->cid && $obj->cid != $oldcid) { + $startbreak = true; + } + } if ($startbreak) { // Break onto sales representative (new email or cid) @@ -145,13 +152,14 @@ if ($resql) { } $oldemail = $newemail; $oldsid = $obj->sid; - $oldcid = $obj->cid; + if ($targettype == 'contacts') { + $oldcid = $obj->cid; + } $oldlang = $obj->lang; $oldtarget = (empty($obj->cfirstname) && empty($obj->clastname)) ? $obj->name : ($obj->clastname." ".$obj->cfirstname); $message = ''; $total = 0; $foundtoprocess = 0; - $target = (empty($obj->cfirstname) && empty($obj->clastname)) ? $obj->name : ($obj->clastname." ".$obj->cfirstname); // if (empty($newemail)) print "Warning: Customer ".$target." has no email. Notice disabled.\n"; } @@ -167,7 +175,7 @@ if ($resql) { dol_syslog("email_expire_services_to_customers.php: ".$newemail." ".$message); $foundtoprocess++; } - print "Service to expire ".$obj->ref.", label ".dol_concatdesc($obj->plabel, $obj->description).", due date ".dol_print_date($db->jdate($obj->date_fin_validite), 'day').", customer id ".$obj->sid." ".$obj->name.", ".($obj->cid ? "contact id ".$obj->cid." ".$obj->clastname." ".$obj->cfirstname.", " : "")."email ".$newemail.", lang ".$outputlangs->defaultlang.": "; + print "Service to expire ".$obj->ref.", label ".dol_concatdesc($obj->plabel, $obj->description).", due date ".dol_print_date($db->jdate($obj->date_fin_validite), 'day').", customer id ".$obj->sid." ".$obj->name.", ".(isset($obj->cid) ? "contact id ".$obj->cid." ".$obj->clastname." ".$obj->cfirstname.", " : "")."email ".$newemail.", lang ".$outputlangs->defaultlang.": "; if (dol_strlen($newemail)) print "qualified."; else print "disqualified (no email)."; diff --git a/scripts/contracts/email_expire_services_to_representatives.php b/scripts/contracts/email_expire_services_to_representatives.php index eec151376ee..2c8429b6256 100755 --- a/scripts/contracts/email_expire_services_to_representatives.php +++ b/scripts/contracts/email_expire_services_to_representatives.php @@ -70,8 +70,9 @@ $duration_value = isset($argv[2]) ? $argv[2] : 'none'; print $script_file." launched with mode ".$mode." default lang=".$langs->defaultlang.(is_numeric($duration_value) ? " delay=".$duration_value : "")."\n"; -if ($mode != 'confirm') +if ($mode != 'confirm') { $conf->global->MAIN_DISABLE_ALL_MAILS = 1; +} $sql = "SELECT DISTINCT c.ref, c.fk_soc, cd.date_fin_validite, cd.total_ttc, cd.description as description, p.label as plabel, s.rowid, s.nom as name, s.email, s.default_lang,"; $sql .= " u.rowid as uid, u.lastname, u.firstname, u.email, u.lang"; @@ -192,25 +193,31 @@ function envoi_mail($mode, $oldemail, $message, $total, $userlang, $oldsalerepre $newlangs->load("contracts"); if ($duration_value) { - if ($duration_value > 0) + if ($duration_value > 0) { $title = $newlangs->transnoentities("ListOfServicesToExpireWithDuration", $duration_value); - else $title = $newlangs->transnoentities("ListOfServicesToExpireWithDurationNeg", $duration_value); - } else $title = $newlangs->transnoentities("ListOfServicesToExpire"); + } else { + $title = $newlangs->transnoentities("ListOfServicesToExpireWithDurationNeg", $duration_value); + } + } else { + $title = $newlangs->transnoentities("ListOfServicesToExpire"); + } $subject = (empty($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_SUBJECT) ? $title : $conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_SUBJECT); $sendto = $oldemail; - $from = $conf->global->MAIN_MAIL_EMAIL_FROM; - $errorsto = $conf->global->MAIN_MAIL_ERRORS_TO; + $from = empty($conf->global->MAIN_MAIL_EMAIL_FROM) ? '' : $conf->global->MAIN_MAIL_EMAIL_FROM; + $errorsto = empty($conf->global->MAIN_MAIL_ERRORS_TO) ? '' : $conf->global->MAIN_MAIL_ERRORS_TO; $msgishtml = - 1; print "- Send email for ".$oldsalerepresentative." (".$oldemail."), total: ".$total."\n"; dol_syslog("email_expire_services_to_representatives.php: send mail to ".$oldemail); $usehtml = 0; - if (dol_textishtml($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_FOOTER)) + if (!empty($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_FOOTER) && dol_textishtml($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_FOOTER)) { $usehtml += 1; - if (dol_textishtml($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_HEADER)) + } + if (!empty($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_HEADER) && dol_textishtml($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_HEADER)) { $usehtml += 1; + } $allmessage = ''; if (!empty($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_HEADER)) { diff --git a/scripts/invoices/email_unpaid_invoices_to_customers.php b/scripts/invoices/email_unpaid_invoices_to_customers.php index 9b59fcab6f7..a569a34d0fa 100755 --- a/scripts/invoices/email_unpaid_invoices_to_customers.php +++ b/scripts/invoices/email_unpaid_invoices_to_customers.php @@ -74,8 +74,9 @@ $duration_value2 = isset($argv[4]) ? $argv[4] : 'none'; $error = 0; print $script_file." launched with mode ".$mode." default lang=".$langs->defaultlang.(is_numeric($duration_value) ? " delay=".$duration_value : "").(is_numeric($duration_value2) ? " after=".$duration_value2 : "")."\n"; -if ($mode != 'confirm') +if ($mode != 'confirm') { $conf->global->MAIN_DISABLE_ALL_MAILS = 1; +} $sql = "SELECT f.ref, f.total_ttc, f.date_lim_reglement as due_date,"; $sql .= " s.rowid as sid, s.nom as name, s.email, s.default_lang"; @@ -113,6 +114,7 @@ if ($resql) { print "We found ".$num." couples (unpayed validated invoices-".$targettype.") qualified\n"; dol_syslog("We found ".$num." couples (unpayed validated invoices-".$targettype.") qualified"); $message = ''; + $oldtarget = ''; if ($num) { while ($i < $num) { @@ -122,12 +124,17 @@ if ($resql) { // Check if this record is a break after previous one $startbreak = false; - if ($newemail != $oldemail || $oldemail == 'none') + if ($newemail != $oldemail || $oldemail == 'none') { $startbreak = true; - if ($obj->sid && $obj->sid != $oldsid) - $startbreak = true; - if ($obj->cid && $obj->cid != $oldcid) + } + if ($obj->sid && $obj->sid != $oldsid) { $startbreak = true; + } + if ($targettype == 'contacts') { + if ($obj->cid && $obj->cid != $oldcid) { + $startbreak = true; + } + } if ($startbreak) { // Break onto sales representative (new email or cid) @@ -143,13 +150,14 @@ if ($resql) { } $oldemail = $newemail; $oldsid = $obj->sid; - $oldcid = $obj->cid; + if ($targettype == 'contacts') { + $oldcid = $obj->cid; + } $oldlang = $obj->lang; $oldtarget = (empty($obj->cfirstname) && empty($obj->clastname)) ? $obj->name : ($obj->clastname." ".$obj->cfirstname); $message = ''; $total = 0; $foundtoprocess = 0; - $target = (empty($obj->cfirstname) && empty($obj->clastname)) ? $obj->name : ($obj->clastname." ".$obj->cfirstname); // if (empty($newemail)) print "Warning: Customer ".$target." has no email. Notice disabled.\n"; } @@ -165,7 +173,7 @@ if ($resql) { dol_syslog("email_unpaid_invoices_to_customers.php: ".$newemail." ".$message); $foundtoprocess++; } - print "Unpaid invoice ".$obj->ref.", price ".price2num($obj->total_ttc).", due date ".dol_print_date($db->jdate($obj->due_date), 'day').", customer id ".$obj->sid." ".$obj->name.", ".($obj->cid ? "contact id ".$obj->cid." ".$obj->clastname." ".$obj->cfirstname.", " : "")."email ".$newemail.", lang ".$outputlangs->defaultlang.": "; + print "Unpaid invoice ".$obj->ref.", price ".price2num($obj->total_ttc).", due date ".dol_print_date($db->jdate($obj->due_date), 'day').", customer id ".$obj->sid." ".$obj->name.", ".(isset($obj->cid) ? "contact id ".$obj->cid." ".$obj->clastname." ".$obj->cfirstname.", " : "")."email ".$newemail.", lang ".$outputlangs->defaultlang.": "; if (dol_strlen($newemail)) print "qualified."; else print "disqualified (no email)."; @@ -229,17 +237,17 @@ function envoi_mail($mode, $oldemail, $message, $total, $userlang, $oldtarget) $subject = (empty($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_SUBJECT) ? $newlangs->trans("ListOfYourUnpaidInvoices") : $conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_SUBJECT); $sendto = $oldemail; - $from = $conf->global->MAIN_MAIL_EMAIL_FROM; - $errorsto = $conf->global->MAIN_MAIL_ERRORS_TO; + $from = empty($conf->global->MAIN_MAIL_EMAIL_FROM) ? '' : $conf->global->MAIN_MAIL_EMAIL_FROM; + $errorsto = empty($conf->global->MAIN_MAIL_ERRORS_TO) ? '' : $conf->global->MAIN_MAIL_ERRORS_TO; $msgishtml = - 1; print "- Send email to '".$oldtarget."' (".$oldemail."), total: ".$total."\n"; dol_syslog("email_unpaid_invoices_to_customers.php: send mail to ".$oldemail); $usehtml = 0; - if (dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_FOOTER)) + if (!empty($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_FOOTER) && dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_FOOTER)) $usehtml += 1; - if (dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_HEADER)) + if (!empty($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_HEADER) && dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_CUSTOMERS_HEADER)) $usehtml += 1; $allmessage = ''; diff --git a/scripts/invoices/email_unpaid_invoices_to_representatives.php b/scripts/invoices/email_unpaid_invoices_to_representatives.php index d401894363d..d5c71c70565 100755 --- a/scripts/invoices/email_unpaid_invoices_to_representatives.php +++ b/scripts/invoices/email_unpaid_invoices_to_representatives.php @@ -70,8 +70,9 @@ $duration_value = isset($argv[2]) ? $argv[2] : 'none'; print $script_file." launched with mode ".$mode." default lang=".$langs->defaultlang.(is_numeric($duration_value) ? " delay=".$duration_value : "")."\n"; -if ($mode != 'confirm') +if ($mode != 'confirm') { $conf->global->MAIN_DISABLE_ALL_MAILS = 1; +} $sql = "SELECT f.ref, f.total_ttc, f.date_lim_reglement as due_date, s.nom as name, s.email, s.default_lang,"; $sql .= " u.rowid as uid, u.lastname, u.firstname, u.email, u.lang"; @@ -196,17 +197,17 @@ function envoi_mail($mode, $oldemail, $message, $total, $userlang, $oldsalerepre $subject = (empty($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_SUBJECT) ? $newlangs->trans("ListOfYourUnpaidInvoices") : $conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_SUBJECT); $sendto = $oldemail; - $from = $conf->global->MAIN_MAIL_EMAIL_FROM; - $errorsto = $conf->global->MAIN_MAIL_ERRORS_TO; + $from = empty($conf->global->MAIN_MAIL_EMAIL_FROM) ? '' : $conf->global->MAIN_MAIL_EMAIL_FROM; + $errorsto = empty($conf->global->MAIN_MAIL_ERRORS_TO) ? '' : $conf->global->MAIN_MAIL_ERRORS_TO; $msgishtml = - 1; print "- Send email for ".$oldsalerepresentative." (".$oldemail."), total: ".$total."\n"; dol_syslog("email_unpaid_invoices_to_representatives.php: send mail to ".$oldemail); $usehtml = 0; - if (dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_FOOTER)) + if (!empty($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_FOOTER) && dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_FOOTER)) $usehtml += 1; - if (dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_HEADER)) + if (!empty($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_HEADER) && dol_textishtml($conf->global->SCRIPT_EMAIL_UNPAID_INVOICES_SALESREPRESENTATIVES_HEADER)) $usehtml += 1; $allmessage = '';