From 518a225f7baa8f577877392562f1906aa86723ab Mon Sep 17 00:00:00 2001 From: jcp Date: Tue, 3 Nov 2020 19:48:23 +0100 Subject: [PATCH 001/392] 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/392] 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/392] 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/392] 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/392] 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/392] 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/392] 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/392] 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/392] 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 f161b47cba0eae757700aa88c8c59b938e46432e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 Dec 2020 01:45:08 +0100 Subject: [PATCH 035/392] Debug v13 --- ChangeLog | 6 +++--- htdocs/theme/eldy/info-box.inc.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 20b3a514342..fbb36f221c6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -56,7 +56,6 @@ NEW: add option TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT NEW: add option to define a default warehouse at user level NEW: add option to include products without alert in replenish NEW: add order by lastname and firstname by default in get sales representatives -NEW: add param to not show links when output tags NEW: add PDF document templates for warehouses (list of stock) NEW: add a prospect status for the contact with managment of custom icon NEW: add public note on products ; this also partially fix the #14342 @@ -79,7 +78,7 @@ NEW: appearance tab in TakePOS with more visual parameters NEW: better currency rate editor NEW: can build vendor invoice from vendor orders NEW: can change a product in lines of a recurring invoice or contract -NEW: can change size of logo on PDF documents +NEW: can set the size of the logo on PDF documents NEW: can change VAT rate of all lines of a draft object in one step NEW: can define date range of validity of a login during creation NEW: can disable, from edit page, the whole web site @@ -188,7 +187,7 @@ NEW: show line number on intervention card (via MAIN_VIEW_LINE_NUMBER) NEW: Add some fields to link website page to an other object NEW: fill ECM src object fields in dol_add_file_process NEW: conf to allow to show the full tree in warehouse popup -NEW: can use THEME_DARKMODEENABLED=2 for a preview of theme in dark mode +NEW: can use parameter ?THEME_DARKMODEENABLED=2 for a preview of theme in dark mode NEW: can force the antivirus from conf file or autoprepend ini setup NEW: can add event to log into blockedlog module with a constant NEW: add property cssview when declaring fields of an object @@ -212,6 +211,7 @@ NEW: add a message in error_log after detection of SQL or script injection NEW: add validation of MX domain for emails NEW: calculate the virtual stock in transverse mode ( not on getEntity('commande'), ... but on getEntity('stock') ) NEW: Graphics can be horizontal bars +NEW: add param to not show links when output tags APIs NEW: API get contacts list of a given order diff --git a/htdocs/theme/eldy/info-box.inc.php b/htdocs/theme/eldy/info-box.inc.php index 1bb6ae7c67e..2da8de5cff3 100644 --- a/htdocs/theme/eldy/info-box.inc.php +++ b/htdocs/theme/eldy/info-box.inc.php @@ -25,7 +25,7 @@ if (!defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> .info-box.info-box-sm { min-height: 80px; margin-bottom: 10px; - background: #fff; + /* background: #fff; */ } .opened-dash-board-wrap .info-box.info-box-sm { border-radius: 0 0 0 20px; From 44d3bc2e646292a09d858a7ba73d1679b82ec24b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 14 Dec 2020 08:39:08 +0100 Subject: [PATCH 036/392] add work --- htdocs/intracommreport/card.php | 55 +++++++++++-------- .../class/intracommreport.class.php | 47 +++++++++++++--- htdocs/intracommreport/list.php | 4 +- 3 files changed, 75 insertions(+), 31 deletions(-) diff --git a/htdocs/intracommreport/card.php b/htdocs/intracommreport/card.php index f0a4bd5f070..077f793d649 100644 --- a/htdocs/intracommreport/card.php +++ b/htdocs/intracommreport/card.php @@ -27,28 +27,41 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; require_once DOL_DOCUMENT_ROOT.'/intracommreport/class/intracommreport.class.php'; $langs->loadLangs(array("intracommreport")); - +var_dump($_POST); $action = GETPOST('action'); -$exporttype = GETPOST('exporttype'); // DEB ou DES -if (empty($exporttype)) { - $exporttype = 'deb'; -} - -$form = new Form($db); -$formother = new FormOther($db); -$year = GETPOST('year'); -$month = GETPOST('month'); +$exporttype = GETPOSTISSET('exporttype') ? GETPOST('exporttype', 'alphanohtml') : 'deb'; // DEB ou DES +$year = GETPOSTINT('year'); +$month = GETPOSTINT('month'); $label = (string) GETPOST('label', 'alphanohtml'); -$type_declaration = GETPOSTINT('type'); +$type_declaration = (string) GETPOST('type_declaration', 'alphanohtml'); $backtopage = GETPOST('backtopage', 'alpha'); $declaration = array( "deb" => $langs->trans("DEB"), "des" => $langs->trans("DES"), ); +$typeOfDeclaration = array( + "introduction" => $langs->trans("Introduction"), + "expedition" => $langs->trans("Expedition"), +); +$object = new IntracommReport($db); +if ($id > 0) { + $object->fetch($id); +} +$form = new Form($db); +$formother = new FormOther($db); + +// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array +$hookmanager->initHooks(array('intracommcard', 'globalcard')); /* * Actions */ +$parameters = array('id' => $id); +// Note that $action and $object may have been modified by some hooks +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} if ($user->rights->intracommreport->delete && $action == 'confirm_delete' && $confirm == 'yes') { $result = $object->delete($id, $user); @@ -72,16 +85,16 @@ if ($action == 'add' && $user->rights->intracommreport->write) { $object->subscription = (int) $subscription; // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); - if ($ret < 0) { - $error++; - } + // $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + // if ($ret < 0) { + // $error++; + // } if (empty($object->label)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); } else { - $sql = "SELECT libelle FROM ".MAIN_DB_PREFIX."adherent_type WHERE libelle='".$db->escape($object->label)."'"; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."intracommreport WHERE ref='".$db->escape($object->label)."'"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); @@ -96,7 +109,7 @@ if ($action == 'add' && $user->rights->intracommreport->write) { if (!$error) { $id = $object->create($user); if ($id > 0) { - header("Location: ".$_SERVER["PHP_SELF"]); + header("Location: ".$_SERVER["PHP_SELF"].'?id='.$id); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); @@ -145,10 +158,8 @@ if ($action == 'create') { print ''; // Type of declaration - $typeOfDeclaration["introduction"] = $langs->trans("Introduction"); - $typeOfDeclaration["expedition"] = $langs->trans("Expedition"); print ''.$langs->trans("TypeOfDeclaration")."\n"; - print $form->selectarray("type_declaration", $typeOfDeclaration, GETPOST('type_declaration', 'alpha') ?GETPOST('type_declaration', 'alpha') : $object->type_declaration, 0); + print $form->selectarray("type_declaration", $typeOfDeclaration, GETPOST('type_declaration', 'alpha') ? GETPOST('type_declaration', 'alpha') : $object->type_declaration, 0); print "\n"; print ''; @@ -177,9 +188,9 @@ if ($id > 0 && $action != 'edit') { /* * Show tabs */ - $head = intracommreport_prepare_head($object); + //$head = intracommreport_prepare_head($object); - print dol_get_fiche_head($head, 'general', $langs->trans("IntracommReport"), -1, 'user'); + print dol_get_fiche_head("", 'general', $langs->trans("IntracommReport"), -1, 'user'); // Confirm remove report if ($action == 'delete') { diff --git a/htdocs/intracommreport/class/intracommreport.class.php b/htdocs/intracommreport/class/intracommreport.class.php index d1145dcf806..0cf5a71c27a 100644 --- a/htdocs/intracommreport/class/intracommreport.class.php +++ b/htdocs/intracommreport/class/intracommreport.class.php @@ -81,13 +81,46 @@ class IntracommReport extends CommonObject $this->exporttype = 'deb'; } + /** + * Fonction create + * @param User $user User + * @param int $notrigger notrigger + * @return int + */ + public function create($user, $notrigger = 0) + { + return 1; + } + + /** + * Fonction fetch + * @param int $id object ID + * @return int + */ + public function fetch($id) + { + return 1; + } + + /** + * Fonction delete + * @param int $id object ID + * @param User $user User + * @param int $notrigger notrigger + * @return int + */ + public function delete($id, $user, $notrigger = 0) + { + return 1; + } + /** * Generate XML file * - * @param int $mode O for create, R for regenerate (Look always 0 ment toujours 0 within the framework of XML exchanges according to documentation) - * @param string $type Declaration type by default - introduction or expedition (always 'expedition' for Des) - * @param string $period_reference Period of reference - * @return void + * @param int $mode O for create, R for regenerate (Look always 0 ment toujours 0 within the framework of XML exchanges according to documentation) + * @param string $type Declaration type by default - introduction or expedition (always 'expedition' for Des) + * @param string $period_reference Period of reference + * @return SimpleXMLElement|int */ public function getXML($mode = 'O', $type = 'introduction', $period_reference = '') { @@ -149,7 +182,7 @@ class IntracommReport extends CommonObject * @param int $period_year Year of declaration * @param int $period_month Month of declaration * @param string $type_declaration Declaration type by default - introduction or expedition (always 'expedition' for Des) - * @return void + * @return SimpleXMLElement|int */ public function getXMLDes($period_year, $period_month, $type_declaration = 'expedition') { @@ -246,7 +279,7 @@ class IntracommReport extends CommonObject * @param string $type Declaration type by default - introduction or expedition (always 'expedition' for Des) * @param int $period_reference Reference declaration * @param string $exporttype deb=DEB, des=DES - * @return int <0 if KO, >0 if OK + * @return string <0 if KO, >0 if OK */ public function getSQLFactLines($type, $period_reference, $exporttype = 'deb') { @@ -325,7 +358,7 @@ class IntracommReport extends CommonObject * Add item for DES * * @param SimpleXMLElement $declaration Reference declaration - * @param esurce $res Result of request SQL + * @param Resource $res Result of request SQL * @param int $i Line Id * @return void */ diff --git a/htdocs/intracommreport/list.php b/htdocs/intracommreport/list.php index 1530e07d84e..d3346e344f4 100644 --- a/htdocs/intracommreport/list.php +++ b/htdocs/intracommreport/list.php @@ -121,8 +121,8 @@ $isInEEC = isInEEC($mysoc); // Definition of fields for lists $arrayfields = array( - 'i.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), - 'i.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), + 'i.ref' => array('label'=>$langs->trans("Ref"), 'checked'=>1), + 'i.label' => array('label'=>$langs->trans("Label"), 'checked'=>1), 'i.fk_product_type'=>array('label'=>$langs->trans("Type"), 'checked'=>0, 'enabled'=>(!empty($conf->produit->enabled) && !empty($conf->service->enabled))), ); /* From 943f1022c01da67fe383134efb6f5d33092dc1da Mon Sep 17 00:00:00 2001 From: zuiko Date: Tue, 15 Dec 2020 09:26:27 +0100 Subject: [PATCH 037/392] Update fournisseurs.php Product: purchase price tab, the supplier price table with its list of products is not "responsive", as a result, the right-clickable areas, including the "Add purchase price" button, disappear to the right of the screens that are not full HD which forces the user to drag his window with the mouse. The solution is to change the CSS class of the table to adopt the CSS class of the equivalent table of the selling price tab, which is "responsive" to it. We therefore replace : print ''; by : print '
'; Knowing that the class is used in 24 files, there might be other places where this class poses the same ergonomic problem. I don't know enough Dolibarr to generalize the correction ... --- htdocs/product/fournisseurs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 3e43937e697..b6f09346385 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -877,7 +877,7 @@ SCRIPT; // Suppliers list title print '
'; - print '
'; + print '
'; $param = "&id=".$object->id; From 5ec7b01fb4817badfeb51205caa6a1960c12306c Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 15 Dec 2020 09:34:46 +0100 Subject: [PATCH 038/392] FIX: Link to subaccount ledger --- htdocs/accountancy/bookkeeping/listbyaccount.php | 2 +- htdocs/langs/en_US/accountancy.lang | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 18661f8a887..cd15eea52be 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -380,7 +380,7 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { $newcardbutton = dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param); - $newcardbutton .= dolGetButtonTitle($langs->trans('VueByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); + $newcardbutton .= dolGetButtonTitle($langs->trans('VueBySubAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbysubaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); $newcardbutton .= '   '; diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 41a4cfa59d5..82338c8f98d 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -48,6 +48,7 @@ CountriesExceptMe=All countries except %s AccountantFiles=Export source documents ExportAccountingSourceDocHelp=With this tool, you can export the source events (list and PDFs) that were used to generate your accountancy. To export your journals, use the menu entry %s - %s. VueByAccountAccounting=View by accounting account +VueBySubAccountAccounting=View by accounting subaccount MainAccountForCustomersNotDefined=Main accounting account for customers not defined in setup MainAccountForSuppliersNotDefined=Main accounting account for vendors not defined in setup From 50b27239a7dcb80b882d7998701931280a404fcd Mon Sep 17 00:00:00 2001 From: ATM john Date: Tue, 15 Dec 2020 11:34:04 +0100 Subject: [PATCH 039/392] Fix missing hook for project overview control --- htdocs/projet/class/project.class.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index a0b6e38423b..335b06a0456 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -576,6 +576,9 @@ class Project extends CommonObject public function get_element_list($type, $tablename, $datefieldname = '', $dates = '', $datee = '', $projectkey = 'fk_projet') { // phpcs:enable + + global $hookmanager; + $elements = array(); if ($this->id <= 0) return $elements; @@ -630,6 +633,21 @@ class Project extends CommonObject if (empty($datefieldname)) return 'Error this object has no date field defined'; $sql .= " AND (".$datefieldname." <= '".$this->db->idate($datee)."' OR ".$datefieldname." IS NULL)"; } + + $hookmanager->initHooks(array('projectdao')); + $parameters = array( + 'sql'=>$sql, + 'type' => $type, + 'tablename' => $tablename, + 'datefieldname' => $datefieldname, + 'dates' => $dates, + 'datee' => $datee, + 'fk_projet' => $projectkey + ); + $reshook = $hookmanager->executeHooks('getElementList', $parameters, $object, $action); + if ($reshook > 0) $sql = $hookmanager->resPrint; + else $sql .= $hookmanager->resPrint; + if (!$sql) return -1; //print $sql; From 37fe5bb3efc4aa986fa97ef22b37fb40bac3cd05 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 15 Dec 2020 15:18:01 +0100 Subject: [PATCH 040/392] Solve blocking feature. Can increase stock of a Kit without changing subproduct stock. --- htdocs/langs/en_US/main.lang | 1 + htdocs/langs/en_US/stocks.lang | 1 + htdocs/product/class/product.class.php | 16 ++-- htdocs/product/composition/card.php | 18 ++--- .../stock/class/mouvementstock.class.php | 41 ++++++----- htdocs/product/stock/product.php | 73 ++++++++++++------- htdocs/product/stock/stockatdate.php | 10 ++- .../product/stock/tpl/stockcorrection.tpl.php | 15 +++- .../product/stock/tpl/stocktransfer.tpl.php | 5 +- 9 files changed, 109 insertions(+), 71 deletions(-) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index c32e4d01ddd..73c9964000e 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -29,6 +29,7 @@ AvailableVariables=Available substitution variables NoTranslation=No translation Translation=Translation EmptySearchString=Enter non empty search criterias +EnterADateCriteria=Enter a date criteria NoRecordFound=No record found NoRecordDeleted=No record deleted NotEnoughDataYet=Not enough data diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index d2c1b2cb382..1b54e53d6de 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -240,3 +240,4 @@ InventoryRealQtyHelp=Set value to 0 to reset qty
Keep field empty, or remove UpdateByScaning=Update by scaning UpdateByScaningProductBarcode=Update by scan (product barcode) UpdateByScaningLot=Update by scan (lot|serial barcode) +DisableStockChangeOfSubProduct=Deactivate the stock change for all the subproducts of this Kit during this movement. \ No newline at end of file diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 7d0d82ec147..e1b25b9e3b7 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4229,9 +4229,9 @@ class Product extends CommonObject // phpcs:enable $this->res = array(); if (isset($this->sousprods) && is_array($this->sousprods)) { - foreach ($this->sousprods as $prod_name => $desc_product) - { - if (is_array($desc_product)) { $this->fetch_prod_arbo($desc_product, "", $multiply, 1, $this->id); + foreach ($this->sousprods as $prod_name => $desc_product) { + if (is_array($desc_product)) { + $this->fetch_prod_arbo($desc_product, "", $multiply, 1, $this->id); } } } @@ -4777,9 +4777,10 @@ class Product extends CommonObject * @param string $inventorycode Inventory code * @param string $origin_element Origin element type * @param int $origin_id Origin id of element + * @param int $disablestockchangeforsubproduct Disable stock change for sub-products of kit (usefull only if product is a subproduct) * @return int <0 if KO, >0 if OK */ - public function correct_stock($user, $id_entrepot, $nbpiece, $movement, $label = '', $price = 0, $inventorycode = '', $origin_element = '', $origin_id = null) + public function correct_stock($user, $id_entrepot, $nbpiece, $movement, $label = '', $price = 0, $inventorycode = '', $origin_element = '', $origin_id = null, $disablestockchangeforsubproduct = 0) { // phpcs:enable if ($id_entrepot) { @@ -4792,7 +4793,7 @@ class Product extends CommonObject $movementstock = new MouvementStock($this->db); $movementstock->setOrigin($origin_element, $origin_id); // Set ->origin and ->origin->id - $result = $movementstock->_create($user, $this->id, $id_entrepot, $op[$movement], $movement, $price, $label, $inventorycode); + $result = $movementstock->_create($user, $this->id, $id_entrepot, $op[$movement], $movement, $price, $label, $inventorycode, '', '', '', '', false, 0, $disablestockchangeforsubproduct); if ($result >= 0) { $this->db->commit(); @@ -4823,9 +4824,10 @@ class Product extends CommonObject * @param string $inventorycode Inventory code * @param string $origin_element Origin element type * @param int $origin_id Origin id of element + * @param int $disablestockchangeforsubproduct Disable stock change for sub-products of kit (usefull only if product is a subproduct) * @return int <0 if KO, >0 if OK */ - public function correct_stock_batch($user, $id_entrepot, $nbpiece, $movement, $label = '', $price = 0, $dlc = '', $dluo = '', $lot = '', $inventorycode = '', $origin_element = '', $origin_id = null) + public function correct_stock_batch($user, $id_entrepot, $nbpiece, $movement, $label = '', $price = 0, $dlc = '', $dluo = '', $lot = '', $inventorycode = '', $origin_element = '', $origin_id = null, $disablestockchangeforsubproduct = 0) { // phpcs:enable if ($id_entrepot) { @@ -4838,7 +4840,7 @@ class Product extends CommonObject $movementstock = new MouvementStock($this->db); $movementstock->setOrigin($origin_element, $origin_id); - $result = $movementstock->_create($user, $this->id, $id_entrepot, $op[$movement], $movement, $price, $label, $inventorycode, '', $dlc, $dluo, $lot); + $result = $movementstock->_create($user, $this->id, $id_entrepot, $op[$movement], $movement, $price, $label, $inventorycode, '', $dlc, $dluo, $lot, false, 0, $disablestockchangeforsubproduct); if ($result >= 0) { $this->db->commit(); diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index 13ef4582d20..8459fa3e479 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2017 Laurent Destailleur + * Copyright (C) 2004-2020 Laurent Destailleur * Copyright (C) 2005 Eric Seigne * Copyright (C) 2005-2018 Regis Houssin * Copyright (C) 2006 Andre Cianfarani @@ -137,7 +137,7 @@ if ($action == 'search') $current_lang = $langs->getDefaultLang(); $sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.fk_product_type as type, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,'; - $sql .= ' p.fk_product_type, p.tms as datem'; + $sql .= ' p.fk_product_type, p.tms as datem, p.tobatch'; if (!empty($conf->global->MAIN_MULTILANGS)) $sql .= ', pl.label as labelm, pl.description as descriptionm'; $sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON p.rowid = cp.fk_product'; @@ -204,7 +204,7 @@ if ($id > 0 || !empty($ref)) dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', '', '', '', 0, '', '', 0); - if ($object->type != Product::TYPE_SERVICE || empty($conf->global->PRODUIT_MULTIPRICES)) + if ($object->type != Product::TYPE_SERVICE || !empty($conf->global->STOCK_SUPPORTS_SERVICES) || empty($conf->global->PRODUIT_MULTIPRICES)) { print '
'; print '
'; @@ -320,14 +320,11 @@ if ($id > 0 || !empty($ref)) print ''."\n"; $totalsell = 0; - if (count($prods_arbo)) - { - foreach ($prods_arbo as $value) - { + if (count($prods_arbo)) { + foreach ($prods_arbo as $value) { $productstatic->fetch($value['id']); - if ($value['level'] <= 1) - { + if ($value['level'] <= 1) { print '
'; $notdefined = 0; @@ -380,7 +377,7 @@ if ($id > 0 || !empty($ref)) // Qty + IncDec if ($user->rights->produit->creer || $user->rights->service->creer) { - print ''; + print ''; print ''; } else { print ''; @@ -566,6 +563,7 @@ if ($id > 0 || !empty($ref)) $productstatic->label = $objp->label; $productstatic->type = $objp->type; $productstatic->entity = $objp->entity; + $productstatic->status_batch = $objp->tobatch; print ''; $labeltoshow = $objp->label; diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index c97c56b2887..631cedd0a25 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -128,26 +128,27 @@ class MouvementStock extends CommonObject * Add a movement of stock (in one direction only). * $this->origin can be also be set to save the source object of movement. * - * @param User $user User object - * @param int $fk_product Id of product - * @param int $entrepot_id Id of warehouse - * @param int $qty Qty of movement (can be <0 or >0 depending on parameter type) - * @param int $type Direction of movement: - * 0=input (stock increase by a stock transfer), 1=output (stock decrease by a stock transfer), - * 2=output (stock decrease), 3=input (stock increase) - * Note that qty should be > 0 with 0 or 3, < 0 with 1 or 2. - * @param int $price Unit price HT of product, used to calculate average weighted price (AWP or PMP in french). If 0, average weighted price is not changed. - * @param string $label Label of stock movement - * @param string $inventorycode Inventory code - * @param string $datem Force date of movement - * @param integer $eatby eat-by date. Will be used if lot does not exists yet and will be created. - * @param integer $sellby sell-by date. Will be used if lot does not exists yet and will be created. - * @param string $batch batch number - * @param boolean $skip_batch If set to true, stock movement is done without impacting batch record + * @param User $user User object + * @param int $fk_product Id of product + * @param int $entrepot_id Id of warehouse + * @param int $qty Qty of movement (can be <0 or >0 depending on parameter type) + * @param int $type Direction of movement: + * 0=input (stock increase by a stock transfer), 1=output (stock decrease by a stock transfer), + * 2=output (stock decrease), 3=input (stock increase) + * Note that qty should be > 0 with 0 or 3, < 0 with 1 or 2. + * @param int $price Unit price HT of product, used to calculate average weighted price (AWP or PMP in french). If 0, average weighted price is not changed. + * @param string $label Label of stock movement + * @param string $inventorycode Inventory code + * @param string $datem Force date of movement + * @param integer $eatby eat-by date. Will be used if lot does not exists yet and will be created. + * @param integer $sellby sell-by date. Will be used if lot does not exists yet and will be created. + * @param string $batch batch number + * @param boolean $skip_batch If set to true, stock movement is done without impacting batch record * @param int $id_product_batch Id product_batch (when skip_batch is false and we already know which record of product_batch to use) - * @return int <0 if KO, 0 if fk_product is null or product id does not exists, >0 if OK + * @param int $disablestockchangeforsubproduct Disable stock change for sub-products of kit (usefull only if product is a subproduct) + * @return int <0 if KO, 0 if fk_product is null or product id does not exists, >0 if OK */ - public function _create($user, $fk_product, $entrepot_id, $qty, $type, $price = 0, $label = '', $inventorycode = '', $datem = '', $eatby = '', $sellby = '', $batch = '', $skip_batch = false, $id_product_batch = 0) + public function _create($user, $fk_product, $entrepot_id, $qty, $type, $price = 0, $label = '', $inventorycode = '', $datem = '', $eatby = '', $sellby = '', $batch = '', $skip_batch = false, $id_product_batch = 0, $disablestockchangeforsubproduct = 0) { // phpcs:disable global $conf, $langs; @@ -571,9 +572,9 @@ class MouvementStock extends CommonObject } // Add movement for sub products (recursive call) - if (!$error && !empty($conf->global->PRODUIT_SOUSPRODUITS) && empty($conf->global->INDEPENDANT_SUBPRODUCT_STOCK)) + if (!$error && !empty($conf->global->PRODUIT_SOUSPRODUITS) && empty($conf->global->INDEPENDANT_SUBPRODUCT_STOCK) && empty($disablestockchangeforsubproduct)) { - $error = $this->_createSubProduct($user, $fk_product, $entrepot_id, $qty, $type, 0, $label, $inventorycode); // we use 0 as price, because pmp is not changed for subproduct + $error = $this->_createSubProduct($user, $fk_product, $entrepot_id, $qty, $type, 0, $label, $inventorycode); // we use 0 as price, because AWP must not change for subproduct } if ($movestock && !$error) diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 0ea05495e5a..89df906feda 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -108,6 +108,8 @@ if (!empty($canvas)) // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('stockproductcard', 'globalcard')); +$error = 0; + /* * Actions @@ -221,17 +223,14 @@ if ($action == "correct_stock" && !$cancel) } } - if (!$error) - { + if (!$error) { $priceunit = price2num(GETPOST("unitprice")); $nbpiece = price2num(GETPOST("nbpiece", 'alphanohtml')); - if (is_numeric($nbpiece) && $nbpiece != 0 && $id) - { + if (is_numeric($nbpiece) && $nbpiece != 0 && $id) { $origin_element = ''; $origin_id = null; - if (GETPOST('projectid', 'int')) - { + if (GETPOST('projectid', 'int')) { $origin_element = 'project'; $origin_id = GETPOST('projectid', 'int'); } @@ -240,8 +239,13 @@ if ($action == "correct_stock" && !$cancel) $object = new Product($db); $result = $object->fetch($id); } - if ($object->hasbatch()) - { + + $disablestockchangeforsubproduct = 0; + if (GETPOST('disablesubproductstockchange')) { + $disablestockchangeforsubproduct = 1; + } + + if ($object->hasbatch()) { $result = $object->correct_stock_batch( $user, GETPOST("id_entrepot", 'int'), @@ -254,7 +258,8 @@ if ($action == "correct_stock" && !$cancel) $batchnumber, GETPOST('inventorycode', 'alphanohtml'), $origin_element, - $origin_id + $origin_id, + $disablestockchangeforsubproduct ); // We do not change value of stock for a correction } else { $result = $object->correct_stock( @@ -266,14 +271,13 @@ if ($action == "correct_stock" && !$cancel) $priceunit, GETPOST('inventorycode', 'alphanohtml'), $origin_element, - $origin_id + $origin_id, + $disablestockchangeforsubproduct ); // We do not change value of stock for a correction } - if ($result > 0) - { - if ($backtopage) - { + if ($result > 0) { + if ($backtopage) { header("Location: ".$backtopage); exit; } else { @@ -535,12 +539,14 @@ if ($id > 0 || $ref) dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); - print '
'; - - print '
'; - print '
'.$nb_of_subproduct.''.$productstatic->getNomUrl(1, '', 24).'
'; - if (!$variants) { + print '
'; + + print '
'; + print '
'; + + print '
'; + if ($conf->productbatch->enabled) { print ''; } - // Stock alert threshold - print ''; - // Hook formObject $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; + print '
'.$langs->trans("ManageLotSerial").''; print $object->getLibStatut(0, 2); @@ -604,16 +610,23 @@ if ($id > 0 || $ref) print '
'.$form->editfieldkey($form->textwithpicto($langs->trans("StockLimit"), $langs->trans("StockLimitDesc"), 1), 'seuil_stock_alerte', $object->seuil_stock_alerte, $object, $user->rights->produit->creer).''; - print $form->editfieldval("StockLimit", 'seuil_stock_alerte', $object->seuil_stock_alerte, $object, $user->rights->produit->creer, 'string'); - print '
'; + + print '
'; + print '
'; + + print ''; + + // Stock alert threshold + print ''; + // Desired stock print '"; } - } - print "
'.$form->editfieldkey($form->textwithpicto($langs->trans("StockLimit"), $langs->trans("StockLimitDesc"), 1), 'seuil_stock_alerte', $object->seuil_stock_alerte, $object, $user->rights->produit->creer).''; + print $form->editfieldval("StockLimit", 'seuil_stock_alerte', $object->seuil_stock_alerte, $object, $user->rights->produit->creer, 'string'); + print '
'.$form->editfieldkey($form->textwithpicto($langs->trans("DesiredStock"), $langs->trans("DesiredStockDesc"), 1), 'desiredstock', $object->desiredstock, $object, $user->rights->produit->creer); print ''; @@ -727,11 +740,15 @@ if ($id > 0 || $ref) } print "
"; - print '
'; - print '
'; + print ""; + + print '
'; + print '
'; + print '
'; + + print '
'; + } print dol_get_fiche_end(); } diff --git a/htdocs/product/stock/stockatdate.php b/htdocs/product/stock/stockatdate.php index f48ac986d20..91159984a35 100644 --- a/htdocs/product/stock/stockatdate.php +++ b/htdocs/product/stock/stockatdate.php @@ -347,10 +347,14 @@ print ''; print '
'; print ''.$langs->trans('Date').' '.$form->selectDate(($date ? $date : -1), 'date'); -print '   '.$langs->trans('Product').' '; +print '   '; +print img_picto('', 'product').' '; +print $langs->trans('Product').' '; $form->select_produits($productid, 'productid', '', 0, 0, -1, 2, '', 0, array(), 0, '1', 0, 'maxwidth300'); -print '   '.$langs->trans('Warehouse').' '; +print '   '; +print img_picto('', 'stock').' '; +print $langs->trans('Warehouse').' '; print $formproduct->selectWarehouses((GETPOSTISSET('fk_warehouse') ? $fk_warehouse : 'ifone'), 'fk_warehouse', '', 1); print '
'; @@ -558,7 +562,7 @@ print $hookmanager->resPrint; if (empty($date) || ! $dateIsValid) { $colspan = 6; if ($mode == 'future') $colspan++; - print ''.$langs->trans("EmptySearchString").''; + print ''.$langs->trans("EnterADateCriteria").''; } print ''; diff --git a/htdocs/product/stock/tpl/stockcorrection.tpl.php b/htdocs/product/stock/tpl/stockcorrection.tpl.php index 0885e9ef777..4f88b448239 100644 --- a/htdocs/product/stock/tpl/stockcorrection.tpl.php +++ b/htdocs/product/stock/tpl/stockcorrection.tpl.php @@ -70,7 +70,7 @@ if ($object->element == 'product') { print ''; $ident = (GETPOST("dwid") ?GETPOST("dwid", 'int') : (GETPOST('id_entrepot') ? GETPOST('id_entrepot', 'int') : ($object->element == 'product' && $object->fk_default_warehouse ? $object->fk_default_warehouse : 'ifone'))); if (empty($ident) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)) $ident = $conf->global->MAIN_DEFAULT_WAREHOUSE; - print $formproduct->selectWarehouses($ident, 'id_entrepot', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'minwidth100'); + print img_picto('', 'stock').$formproduct->selectWarehouses($ident, 'id_entrepot', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'minwidth100'); print '   '; print ''; @@ -91,6 +92,17 @@ print ''.$langs->trans("NumberOfUnit").''; print ''; print ''; +// If product is a Kit, we ask if we must disable stock change of subproducts +if (!empty($conf->global->PRODUIT_SOUSPRODUITS) && $object->element == 'product' && $object->hasFatherOrChild(1)) { + print ''; + print ''; + print ''; + print ''; + print ' '; + print ''; + print ''; +} + // Serial / Eat-by date if (!empty($conf->productbatch->enabled) && (($object->element == 'product' && $object->hasbatch()) @@ -126,6 +138,7 @@ if (!empty($conf->projet->enabled)) { print ''.$langs->trans('Project').''; print ''; + print img_picto('', 'project'); $formproject->select_projects(-1, '', 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, 'maxwidth300'); print ''; } diff --git a/htdocs/product/stock/tpl/stocktransfer.tpl.php b/htdocs/product/stock/tpl/stocktransfer.tpl.php index 7e159a35b32..20445445e8e 100644 --- a/htdocs/product/stock/tpl/stocktransfer.tpl.php +++ b/htdocs/product/stock/tpl/stocktransfer.tpl.php @@ -71,18 +71,19 @@ print ''; if ($object->element == 'product') { print ''.$langs->trans("WarehouseSource").''; print ''; - print $formproduct->selectWarehouses((GETPOST("dwid") ?GETPOST("dwid", 'int') : (GETPOST('id_entrepot') ?GETPOST('id_entrepot', 'int') : ($object->element == 'product' && $object->fk_default_warehouse ? $object->fk_default_warehouse : 'ifone'))), 'id_entrepot', 'warehouseopen,warehouseinternal', 1); + print img_picto('', 'stock').$formproduct->selectWarehouses((GETPOST("dwid") ?GETPOST("dwid", 'int') : (GETPOST('id_entrepot') ?GETPOST('id_entrepot', 'int') : ($object->element == 'product' && $object->fk_default_warehouse ? $object->fk_default_warehouse : 'ifone'))), 'id_entrepot', 'warehouseopen,warehouseinternal', 1); print ''; } if ($object->element == 'stock') { print ''.$langs->trans("Product").''; print ''; + print img_picto('', 'product'); $form->select_produits(GETPOST('product_id', 'int'), 'product_id', (empty($conf->global->STOCK_SUPPORTS_SERVICES) ? '0' : ''), 0, 0, -1, 2, '', 0, null, 0, 1, 0, 'maxwidth500'); print ''; } print ''.$langs->trans("WarehouseTarget").''; -print $formproduct->selectWarehouses(GETPOST('id_entrepot_destination'), 'id_entrepot_destination', 'warehouseopen,warehouseinternal', 1); +print img_picto('', 'stock').$formproduct->selectWarehouses(GETPOST('id_entrepot_destination'), 'id_entrepot_destination', 'warehouseopen,warehouseinternal', 1); print ''; print ''.$langs->trans("NumberOfUnit").''; print ''; From a5b86f74ce62e2a0f9b91af89bad9fa48777a985 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 15 Dec 2020 15:18:41 +0100 Subject: [PATCH 041/392] Update doc --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 82f82c0b051..8b3b3c97157 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,6 +18,7 @@ NEW: Accountancy - change menu disposition NEW: Accountancy - on transfers, select the periodicity by default NEW: Accountancy - Add export for Gestinum (v3 & v5) NEW: new currency rate editor +NEW: Solve blocking feature. Can increase stock of a Kit without changing subproduct stock. NEW: add a widget to show the customers with outstanding limits reached NEW: add 2 rules for emailcollector: Message send/not sent from Dolibarr NEW: add a counter of number of words for pages in website module From 574f1f0336e43205cd1c5059d51e986d5dfab9f9 Mon Sep 17 00:00:00 2001 From: StephaneLesage Date: Sat, 21 Nov 2020 22:40:31 +0100 Subject: [PATCH 042/392] 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 695eacf099e8d4b8cde3412e74467fa13f81b22b Mon Sep 17 00:00:00 2001 From: Stephane Lesage Date: Tue, 1 Dec 2020 19:30:09 +0100 Subject: [PATCH 043/392] Create/Edit extra-field with multi-line text area for computed value --- htdocs/core/tpl/admin_extrafields_add.tpl.php | 7 +++++-- htdocs/core/tpl/admin_extrafields_edit.tpl.php | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index 2a9438f4413..de16915fe3c 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -182,11 +182,14 @@ $listofexamplesforlink = 'Societe:societe/class/societe.class.php
Contact:con
+global->MAIN_STORE_COMPUTED_EXTRAFIELDS)) { ?> - + - + + + diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index 8990f75951d..9e893bf93e3 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -265,11 +265,14 @@ if (in_array($type, array_keys($typewecanchangeinto))) +global->MAIN_STORE_COMPUTED_EXTRAFIELDS)) { ?> - + - + + + From 7853e77d3f61d971af9f09707a54629f5fff5b10 Mon Sep 17 00:00:00 2001 From: Stephane Lesage Date: Mon, 30 Nov 2020 11:01:56 +0100 Subject: [PATCH 044/392] Export/Import categories missing fields and clean --- htdocs/categories/class/categorie.class.php | 8 +- htdocs/core/modules/modCategorie.class.php | 667 +++++++++++--------- htdocs/langs/en_US/categories.lang | 16 +- htdocs/langs/fr_FR/categories.lang | 10 +- 4 files changed, 408 insertions(+), 293 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index f55b3403546..e49e0ae8838 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -98,6 +98,7 @@ class Categorie extends CommonObject 8 => 'bank_line', 9 => 'warehouse', 10 => 'actioncomm', + 11 => 'website_page' ); /** @@ -221,7 +222,6 @@ class Categorie extends CommonObject /** * @var string Category type * - * @see Categorie::TYPE_ACCOUNT * @see Categorie::TYPE_PRODUCT * @see Categorie::TYPE_SUPPLIER * @see Categorie::TYPE_CUSTOMER @@ -229,9 +229,11 @@ class Categorie extends CommonObject * @see Categorie::TYPE_CONTACT * @see Categorie::TYPE_USER * @see Categorie::TYPE_PROJECT + * @see Categorie::TYPE_ACCOUNT * @see Categorie::TYPE_BANK_LINE - * @see Categorie::TYPE_WAREHOUSE - * @see Categorie::TYPE_ACTIONCOMM + * @see Categorie::TYPE_WAREHOUSE + * @see Categorie::TYPE_ACTIONCOMM + * @see Categorie::TYPE_WEBSITE_PAGE */ public $type; diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index bb6c36b353c..d2218d33483 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005 Matthieu Valleton * Copyright (C) 2005-2014 Laurent Destailleur * Copyright (C) 2012-2016 Juanjo Menent + * Copyright (C) 2020 Stéphane Lesage * * 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,6 +26,7 @@ * \brief Fichier de description et activation du module Categorie */ include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; +include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; /** @@ -64,7 +66,7 @@ class modCategorie extends DolibarrModules // Config pages $this->config_page_url = array('categorie.php@categories'); - $this->langfiles = array("products", "companies", "categories", "members"); + $this->langfiles = array("products", "companies", "categories", "members", "stocks", "website"); // Constants $this->const = array(); @@ -116,265 +118,297 @@ class modCategorie extends DolibarrModules //-------- $r = 0; + // All Categories List $r++; - $this->export_code[$r] = 'category_'.$r; - $this->export_label[$r] = 'CatSupList'; - $this->export_icon[$r] = 'category'; - $this->export_enabled[$r] = '!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)'; - $this->export_permission[$r] = array(array("categorie", "lire"), array("fournisseur", "lire")); - $this->export_fields_array[$r] = array( - 'u.rowid'=>"CategId", 'u.label'=>"Label", 'u.description'=>"Description", 's.rowid'=>'IdThirdParty', 's.nom'=>'Name', 's.prefix_comm'=>"Prefix", - 's.client'=>"Customer", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification", 's.code_client'=>"CustomerCode", 's.address'=>"Address", - 's.zip'=>"Zip", 's.town'=>"Town", 'c.label'=>"Country", 'c.code'=>"CountryCode", 's.phone'=>"Phone", 's.fax'=>"Fax", 's.url'=>"Url", 's.email'=>"Email", - 's.siret'=>"ProfId1", 's.siren'=>"ProfId2", 's.ape'=>"ProfId3", 's.idprof4'=>"ProfId4", 's.tva_intra'=>"VATIntraShort", 's.capital'=>"Capital", - 's.note_public'=>"NotePublic" - ); - $this->export_TypeFields_array[$r] = array( - 'u.label'=>"Text", 'u.description'=>"Text", 's.rowid'=>'List:societe:nom', 's.nom'=>'Text', 's.prefix_comm'=>"Text", 's.client'=>"Text", 's.datec'=>"Date", - 's.tms'=>"Date", 's.code_client'=>"Text", 's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text", 'c.label'=>"List:c_country:label:label", 'c.code'=>"Text", - 's.phone'=>"Text", 's.fax'=>"Text", 's.url'=>"Text", 's.email'=>"Text", 's.siret'=>"Text", 's.siren'=>"Text", 's.ape'=>"Text", 's.idprof4'=>"Text", - 's.tva_intra'=>"Text", 's.capital'=>"Numeric", 's.note_public'=>"Text" - ); - $this->export_entities_array[$r] = array( - 's.rowid'=>'company', 's.nom'=>'company', 's.prefix_comm'=>"company", 's.client'=>"company", 's.datec'=>"company", 's.tms'=>"company", - 's.code_client'=>"company", 's.address'=>"company", 's.zip'=>"company", 's.town'=>"company", 'c.label'=>"company", 'c.code'=>"company", - 's.phone'=>"company", 's.fax'=>"company", 's.url'=>"company", 's.email'=>"company", 's.siret'=>"company", 's.siren'=>"company", 's.ape'=>"company", - 's.idprof4'=>"company", 's.tva_intra'=>"company", 's.capital'=>"company", 's.note_public'=>"company" - ); // We define here only fields that use another picto + $this->export_code[$r] = $this->rights_class.'_list'; + $this->export_label[$r] = 'CatList'; + $this->export_icon[$r] = $this->picto; + $this->export_enabled[$r] = 'true'; + $this->export_permission[$r] = array(array("categorie", "lire")); + + $typeexample = ""; + if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { $typeexample .= ($typeexample ? "/" : "")."0=Product-Service"; } + if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) { $typeexample .= ($typeexample ? "/" : "")."1=Supplier"; } + if (!empty($conf->societe->enabled)) { $typeexample .= ($typeexample ? "/" : "")."2=Customer-Prospect"; } + if (!empty($conf->adherent->enabled)) { $typeexample .= ($typeexample ? "/" : "")."3=Member"; } + if (!empty($conf->societe->enabled)) { $typeexample .= ($typeexample ? "/" : "")."4=Contact"; } + if (!empty($conf->bank->enabled)) { $typeexample .= ($typeexample ? "/" : "")."5=Bank account"; } + if (!empty($conf->projet->enabled)) { $typeexample .= ($typeexample ? "/" : "")."6=Project"; } + if (!empty($conf->user->enabled)) { $typeexample .= ($typeexample ? "/" : "")."7=User"; } + if (!empty($conf->bank->enabled)) { $typeexample .= ($typeexample ? "/" : "")."8=Bank line"; } + if (!empty($conf->stock->enabled)) { $typeexample .= ($typeexample ? "/" : "")."9=Warehouse"; } + if (!empty($conf->agenda->enabled)) { $typeexample .= ($typeexample ? "/" : "")."10=Agenda event"; } + if (!empty($conf->website->enabled)) { $typeexample .= ($typeexample ? "/" : "")."11=Website page"; } + + $this->export_fields_array[$r] = array('cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.type'=>"Type ".$typeexample, 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategory", 'pcat.label'=>"ParentCategoryLabel" ); + $this->export_TypeFields_array[$r] = array('cat.label'=>"Text", 'cat.type'=>"Numeric", 'cat.description'=>"Text", 'cat.fk_parent'=>'List:categorie:label:rowid', 'pcat.label'=>'Text' ); + $this->export_entities_array[$r] = array(); // We define here only fields that use another picto + $this->export_sql_start[$r] = 'SELECT DISTINCT '; - $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as u, '; - $this->export_sql_end[$r] .= MAIN_DB_PREFIX.'categorie_fournisseur as cf, '; - $this->export_sql_end[$r] .= MAIN_DB_PREFIX.'societe as s LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code'; - $this->export_sql_end[$r] .= ' WHERE u.rowid = cf.fk_categorie AND cf.fk_soc = s.rowid'; - $this->export_sql_end[$r] .= ' AND u.entity IN ('.getEntity('category').')'; - $this->export_sql_end[$r] .= ' AND u.type = 1'; // Supplier categories + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as cat'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as pcat ON pcat.rowid = cat.fk_parent'; + $this->export_sql_end[$r] .= ' WHERE cat.entity IN ('.getEntity('category').')'; + // 0 Products $r++; - $this->export_code[$r] = 'category_'.$r; - $this->export_label[$r] = 'CatCusList'; - $this->export_icon[$r] = 'category'; - $this->export_enabled[$r] = '$conf->societe->enabled'; - $this->export_permission[$r] = array(array("categorie", "lire"), array("societe", "lire")); - $this->export_fields_array[$r] = array( - 'u.rowid'=>"CategId", 'u.label'=>"Label", 'u.description'=>"Description", 's.rowid'=>'IdThirdParty', 's.nom'=>'Name', 's.prefix_comm'=>"Prefix", - 's.client'=>"Customer", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification", 's.code_client'=>"CustomerCode", 's.address'=>"Address", - 's.zip'=>"Zip", 's.town'=>"Town", 'c.label'=>"Country", 'c.code'=>"CountryCode", 's.phone'=>"Phone", 's.fax'=>"Fax", 's.url'=>"Url", 's.email'=>"Email", - 's.siret'=>"ProfId1", 's.siren'=>"ProfId2", 's.ape'=>"ProfId3", 's.idprof4'=>"ProfId4", 's.tva_intra'=>"VATIntraShort", 's.capital'=>"Capital", - 's.note_public'=>"NotePublic", 's.fk_prospectlevel'=>'ProspectLevel', 's.fk_stcomm'=>'ProspectStatus' - ); - $this->export_TypeFields_array[$r] = array( - 'u.label'=>"Text", 'u.description'=>"Text", 's.rowid'=>'List:societe:nom', 's.nom'=>'Text', 's.prefix_comm'=>"Text", 's.client'=>"Text", - 's.datec'=>"Date", 's.tms'=>"Date", 's.code_client'=>"Text", 's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text", 'c.label'=>"List:c_country:label:label", - 'c.code'=>"Text", 's.phone'=>"Text", 's.fax'=>"Text", 's.url'=>"Text", 's.email'=>"Text", 's.siret'=>"Text", 's.siren'=>"Text", 's.ape'=>"Text", - 's.idprof4'=>"Text", 's.tva_intra'=>"Text", 's.capital'=>"Numeric", 's.note_public'=>"Text", 's.fk_prospectlevel'=>'List:c_prospectlevel:label:code', - 's.fk_stcomm'=>'List:c_stcomm:libelle:code' - ); - $this->export_entities_array[$r] = array( - 's.rowid'=>'company', 's.nom'=>'company', 's.prefix_comm'=>"company", 's.client'=>"company", 's.datec'=>"company", 's.tms'=>"company", - 's.code_client'=>"company", 's.address'=>"company", 's.zip'=>"company", 's.town'=>"company", 'c.label'=>"company", 'c.code'=>"company", - 's.phone'=>"company", 's.fax'=>"company", 's.url'=>"company", 's.email'=>"company", 's.siret'=>"company", 's.siren'=>"company", 's.ape'=>"company", - 's.idprof4'=>"company", 's.tva_intra'=>"company", 's.capital'=>"company", 's.note_public'=>"company", 's.fk_prospectlevel'=>'company', - 's.fk_stcomm'=>'company' - ); // We define here only fields that use another picto + $this->export_code[$r] = $this->rights_class.'_0_'.Categorie::$MAP_ID_TO_CODE[0]; + $this->export_label[$r] = 'CatProdList'; + $this->export_icon[$r] = $this->picto; + $this->export_enabled[$r] = '!empty($conf->product->enabled) || !empty($conf->service->abled)'; + $this->export_permission[$r] = array(array("categorie", "lire"), array("produit", "export")); + $this->export_fields_array[$r] = array('cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategory", 'p.rowid'=>'ProductId', 'p.ref'=>'Ref', 'p.label'=>'Label'); + $this->export_TypeFields_array[$r] = array('cat.label'=>"Text", 'cat.description'=>"Text", 'cat.fk_parent'=>'List:categorie:label:rowid', 'p.ref'=>'Text', 'p.label'=>'Text'); + $this->export_entities_array[$r] = array('p.rowid'=>'product', 'p.ref'=>'product', 'p.label'=>'product'); // We define here only fields that use another picto - $keyforselect = 'societe'; $keyforelement = 'company'; $keyforaliasextra = 'extrasoc'; + $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_sql_start[$r] = 'SELECT DISTINCT '; - $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as u, '; - $this->export_sql_end[$r] .= MAIN_DB_PREFIX.'categorie_societe as cf, '; - $this->export_sql_end[$r] .= MAIN_DB_PREFIX.'societe as s'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extrasoc ON s.rowid = extrasoc.fk_object '; - $this->export_sql_end[$r] .= ' WHERE u.rowid = cf.fk_categorie AND cf.fk_soc = s.rowid'; - $this->export_sql_end[$r] .= ' AND u.entity IN ('.getEntity('category').')'; - $this->export_sql_end[$r] .= ' AND u.type = 2'; // Customer/Prospect categories + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as cat'; + $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_categorie = cat.rowid'; + $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'product as p ON p.rowid = cp.fk_product'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON extra.fk_object = p.rowid'; + $this->export_sql_end[$r] .= ' WHERE cat.entity IN ('.getEntity('category').')'; + $this->export_sql_end[$r] .= ' AND cat.type = 0'; + // 1 Suppliers $r++; - $this->export_code[$r] = 'category_'.$r; - $this->export_label[$r] = 'CatProdList'; - $this->export_icon[$r] = 'category'; - $this->export_enabled[$r] = '$conf->product->enabled || $conf->service->enabled'; - $this->export_permission[$r] = array(array("categorie", "lire"), array("produit", "lire")); - $this->export_fields_array[$r] = array('u.rowid'=>"CategId", 'u.label'=>"Label", 'u.description'=>"Description", 'p.rowid'=>'ProductId', 'p.ref'=>'Ref'); - $this->export_TypeFields_array[$r] = array('u.label'=>"Text", 'u.description'=>"Text", 'p.ref'=>'Text'); - $this->export_entities_array[$r] = array('p.rowid'=>'product', 'p.ref'=>'product'); // We define here only fields that use another picto - $this->export_sql_start[$r] = 'SELECT DISTINCT '; - $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_product as cp, '.MAIN_DB_PREFIX.'product as p'; - $this->export_sql_end[$r] .= ' WHERE u.rowid = cp.fk_categorie AND cp.fk_product = p.rowid'; - $this->export_sql_end[$r] .= ' AND u.entity IN ('.getEntity('category').')'; - $this->export_sql_end[$r] .= ' AND u.type = 0'; // Supplier categories - - $r++; - $this->export_code[$r] = 'category_'.$r; - $this->export_label[$r] = 'CatMemberList'; - $this->export_icon[$r] = 'category'; - $this->export_enabled[$r] = '$conf->adherent->enabled'; - $this->export_permission[$r] = array(array("categorie", "lire"), array("adherent", "lire")); - $this->export_fields_array[$r] = array('u.rowid'=>"CategId", 'u.label'=>"Label", 'u.description'=>"Description", 'p.rowid'=>'MemberId', 'p.lastname'=>'LastName', 'p.firstname'=>'Firstname'); - $this->export_TypeFields_array[$r] = array('u.label'=>"Text", 'u.description'=>"Text", 'p.lastname'=>'Text', 'p.firstname'=>'Text'); - $this->export_entities_array[$r] = array('p.rowid'=>'member', 'p.lastname'=>'member', 'p.firstname'=>'member'); // We define here only fields that use another picto - $this->export_sql_start[$r] = 'SELECT DISTINCT '; - $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_member as cp, '.MAIN_DB_PREFIX.'adherent as p'; - $this->export_sql_end[$r] .= ' WHERE u.rowid = cp.fk_categorie AND cp.fk_member = p.rowid'; - $this->export_sql_end[$r] .= ' AND u.entity IN ('.getEntity('category').')'; - $this->export_sql_end[$r] .= ' AND u.type = 3'; // Member categories - - $r++; - $this->export_code[$r] = 'category_'.$r; - $this->export_label[$r] = 'CatContactList'; - $this->export_icon[$r] = 'category'; - $this->export_enabled[$r] = '$conf->societe->enabled'; - $this->export_permission[$r] = array(array("categorie", "lire"), array("societe", "lire")); + $this->export_code[$r] = $this->rights_class.'_1_'.Categorie::$MAP_ID_TO_CODE[1]; + $this->export_label[$r] = 'CatSupList'; + $this->export_icon[$r] = $this->picto; + $this->export_enabled[$r] = '!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)'; + $this->export_permission[$r] = array(array("categorie", "lire"), array("fournisseur", "lire")); $this->export_fields_array[$r] = array( - 'u.rowid' => "CategId", - 'u.label' => "Label", - 'u.description' => "Description", - 'p.rowid' => 'ContactId', - 'p.civility' => 'UserTitle', - 'p.lastname' => 'LastName', - 'p.firstname' => 'Firstname', - 'p.address' => 'Address', - 'p.zip' => 'Zip', - 'p.town' => 'Town', - 'country.code' => 'CountryCode', - 'country.label' => 'Country', - 'p.birthday' => 'DateOfBirth', - 'p.poste' => 'PostOrFunction', - 'p.phone' => 'Phone', - 'p.phone_perso' => 'PhonePerso', - 'p.phone_mobile' => 'PhoneMobile', - 'p.fax' => 'Fax', - 'p.email' => 'Email', - 'p.note_private' => 'NotePrivate', - 'p.note_public' => 'NotePublic', - 'p.statut' => 'Status', - 's.nom'=>"Name", - 's.client'=>"Customer", - 's.fournisseur'=>"Supplier", - 's.status'=>"Status", - 's.address'=>"Address", - 's.zip'=>"Zip", - 's.town'=>"Town", - 's.phone'=>"Phone", - 's.fax'=>"Fax", - 's.url'=>"Url", - 's.email'=>"Email" + 'cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategory", + 's.rowid'=>'IdThirdParty', 's.nom'=>'Name', 's.prefix_comm'=>"Prefix", 's.fournisseur'=>"Supplier", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification", 's.code_fournisseur'=>"SupplierCode", + 's.address'=>"Address", 's.zip'=>"Zip", 's.town'=>"Town", 'c.label'=>"Country", 'c.code'=>"CountryCode", + 's.phone'=>"Phone", 's.fax'=>"Fax", 's.url'=>"Url", 's.email'=>"Email", + 's.siret'=>"ProfId1", 's.siren'=>"ProfId2", 's.ape'=>"ProfId3", 's.idprof4'=>"ProfId4", 's.tva_intra'=>"VATIntraShort", 's.capital'=>"Capital", 's.note_public'=>"NotePublic", + 't.libelle'=>'ThirdPartyType' ); $this->export_TypeFields_array[$r] = array( - 'u.label' => "Text", - 'u.description' => "Text", - 'p.lastname' => 'Text', - 'p.firstname' => 'Text', - 'p.statut'=>"Numeric", - 's.nom'=>"Text", - 's.status'=>"Text", - 's.address'=>"Text", - 's.zip'=>"Text", - 's.town'=>"Text", - 's.phone'=>"Text", - 's.fax'=>"Text", - 's.url'=>"Text", - 's.email'=>"Text" + 'cat.label'=>"Text", 'cat.description'=>"Text", 'cat.fk_parent'=>'List:categorie:label:rowid', + 's.rowid'=>'List:societe:nom', 's.nom'=>'Text', 's.prefix_comm'=>"Text", 's.fournisseur'=>"Text", 's.datec'=>"Date", 's.tms'=>"Date", 's.code_fournisseur'=>"Text", + 's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text", 'c.label'=>"List:c_country:label:label", 'c.code'=>"Text", + 's.phone'=>"Text", 's.fax'=>"Text", 's.url'=>"Text", 's.email'=>"Text", + 's.siret'=>"Text", 's.siren'=>"Text", 's.ape'=>"Text", 's.idprof4'=>"Text", 's.tva_intra'=>"Text", 's.capital'=>"Numeric", 's.note_public'=>"Text", + 't.libelle'=>'List:c_typent:libelle:code' ); $this->export_entities_array[$r] = array( - 'u.rowid' => "category", - 'u.label' => "category", - 'u.description' => "category", - 'p.rowid' => 'contact', - 'p.civility' => 'contact', - 'p.lastname' => 'contact', - 'p.firstname' => 'contact', - 'p.address' => 'contact', - 'p.zip' => 'contact', - 'p.town' => 'contact', - 'country.code' => 'contact', - 'country.label' => 'contact', - 'p.birthday' => 'contact', - 'p.poste' => 'contact', - 'p.phone' => 'contact', - 'p.phone_perso' => 'contact', - 'p.phone_mobile' => 'contact', - 'p.fax' => 'contact', - 'p.email' => 'contact', - 'p.note_private' => 'contact', - 'p.note_public' => 'contact', - 'p.statut' => 'contact', - 's.nom'=>"company", - 's.client'=>"company", - 's.fournisseur'=>"company", - 's.status'=>"company", - 's.address'=>"company", - 's.zip'=>"company", - 's.town'=>"company", - 's.phone'=>"company", - 's.fax'=>"company", - 's.url'=>"company", - 's.email'=>"company" + 's.rowid'=>'company', 's.nom'=>'company', 's.prefix_comm'=>"company", 's.fournisseur'=>"company", 's.datec'=>"company", 's.tms'=>"company", 's.code_fournisseur'=>"company", + 's.address'=>"company", 's.zip'=>"company", 's.town'=>"company", 'c.label'=>"company", 'c.code'=>"company", + 's.phone'=>"company", 's.fax'=>"company", 's.url'=>"company", 's.email'=>"company", + 's.siret'=>"company", 's.siren'=>"company", 's.ape'=>"company", 's.idprof4'=>"company", 's.tva_intra'=>"company", 's.capital'=>"company", 's.note_public'=>"company", + 't.libelle'=>'company' ); // We define here only fields that use another picto - // Add extra fields - $sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople' AND entity IN (0, ".$conf->entity.")"; - $resql = $this->db->query($sql); - if ($resql) // This can fail when class is used on old database (during migration for example) - { - while ($obj = $this->db->fetch_object($resql)) - { - $fieldname = 'extra.'.$obj->name; - $fieldlabel = ucfirst($obj->label); - $typeFilter = "Text"; - switch ($obj->type) - { - case 'int': - case 'double': - case 'price': - $typeFilter = "Numeric"; - break; - case 'date': - case 'datetime': - $typeFilter = "Date"; - break; - case 'boolean': - $typeFilter = "Boolean"; - break; - case 'sellist': - $typeFilter = "List:".$obj->param; - break; - case 'select': - $typeFilter = "Select:".$obj->param; - break; - } - $this->export_fields_array[$r][$fieldname] = $fieldlabel; - $this->export_TypeFields_array[$r][$fieldname] = $typeFilter; - $this->export_entities_array[$r][$fieldname] = 'contact'; - } - } - // End add axtra fields + $keyforselect = 'societe'; $keyforelement = 'company'; $keyforaliasextra = 'extra'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_sql_start[$r] = 'SELECT DISTINCT '; - $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_contact as cp, '.MAIN_DB_PREFIX.'socpeople as p'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as country ON p.fk_pays = country.rowid'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc'; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as cat'; + $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'categorie_fournisseur as cf ON cf.fk_categorie = cat.rowid'; + $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = cf.fk_soc'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra ON s.rowid = extra.fk_object'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id'; + $this->export_sql_end[$r] .= ' WHERE cat.entity IN ('.getEntity('category').')'; + $this->export_sql_end[$r] .= ' AND cat.type = 1'; + + // 2 Customers/Prospects + $r++; + $this->export_code[$r] = $this->rights_class.'_2_'.Categorie::$MAP_ID_TO_CODE[2]; + $this->export_label[$r] = 'CatCusList'; + $this->export_icon[$r] = $this->picto; + $this->export_enabled[$r] = '!empty($conf->societe->enabled)'; + $this->export_permission[$r] = array(array("categorie", "lire"), array("societe", "export")); + $this->export_fields_array[$r] = array( + 'cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategory", + 's.rowid'=>'IdThirdParty', 's.nom'=>'Name', 's.prefix_comm'=>"Prefix", 's.client'=>"Customer", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification", 's.code_client'=>"CustomerCode", + 's.address'=>"Address", 's.zip'=>"Zip", 's.town'=>"Town", 'c.label'=>"Country", 'c.code'=>"CountryCode", + 's.phone'=>"Phone", 's.fax'=>"Fax", 's.url'=>"Url", 's.email'=>"Email", + 's.siret'=>"ProfId1", 's.siren'=>"ProfId2", 's.ape'=>"ProfId3", 's.idprof4'=>"ProfId4", 's.tva_intra'=>"VATIntraShort", 's.capital'=>"Capital", 's.note_public'=>"NotePublic", + 't.libelle'=>'ThirdPartyType', 'pl.code'=>'ProspectLevel', 'st.code'=>'ProspectStatus' + ); + $this->export_TypeFields_array[$r] = array( + 'cat.label'=>"Text", 'cat.description'=>"Text", 'cat.fk_parent'=>'List:categorie:label:rowid', + 's.rowid'=>'List:societe:nom', 's.nom'=>'Text', 's.prefix_comm'=>"Text", 's.client'=>"Text", 's.datec'=>"Date", 's.tms'=>"Date", 's.code_client'=>"Text", + 's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text", 'c.label'=>"List:c_country:label:label", 'c.code'=>"Text", + 's.phone'=>"Text", 's.fax'=>"Text", 's.url'=>"Text", 's.email'=>"Text", + 's.siret'=>"Text", 's.siren'=>"Text", 's.ape'=>"Text", 's.idprof4'=>"Text", 's.tva_intra'=>"Text", 's.capital'=>"Numeric", 's.note_public'=>"Text", + 't.libelle'=>'List:c_typent:libelle:code', 'pl.code'=>'List:c_prospectlevel:label:code', 'st.code'=>'List:c_stcomm:libelle:code' + ); + $this->export_entities_array[$r] = array( + 's.rowid'=>'company', 's.nom'=>'company', 's.prefix_comm'=>"company", 's.client'=>"company", 's.datec'=>"company", 's.tms'=>"company", 's.code_client'=>"company", + 's.address'=>"company", 's.zip'=>"company", 's.town'=>"company", 'c.label'=>"company", 'c.code'=>"company", + 's.phone'=>"company", 's.fax'=>"company", 's.url'=>"company", 's.email'=>"company", + 's.siret'=>"company", 's.siren'=>"company", 's.ape'=>"company", 's.idprof4'=>"company", 's.tva_intra'=>"company", 's.capital'=>"company", 's.note_public'=>"company", + 't.libelle'=>'company', 'pl.code'=>'company', 'st.code'=>'company' + ); // We define here only fields that use another picto + + $keyforselect = 'societe'; $keyforelement = 'company'; $keyforaliasextra = 'extra'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as cat'; + $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'categorie_societe as cs ON cs.fk_categorie = cat.rowid'; + $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = cs.fk_soc'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra ON s.rowid = extra.fk_object'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_prospectlevel as pl ON s.fk_prospectlevel = pl.code'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcomm as st ON s.fk_stcomm = st.id'; + $this->export_sql_end[$r] .= ' WHERE cat.entity IN ('.getEntity('category').')'; + $this->export_sql_end[$r] .= ' AND cat.type = 2'; + + // 3 Members + $r++; + $this->export_code[$r] = $this->rights_class.'_3_'.Categorie::$MAP_ID_TO_CODE[3]; + $this->export_label[$r] = 'CatMemberList'; + $this->export_icon[$r] = $this->picto; + $this->export_enabled[$r] = '!empty($conf->adherent->enabled)'; + $this->export_permission[$r] = array(array("categorie", "lire"), array("adherent", "export")); + $this->export_fields_array[$r] = array('cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategory", 'p.rowid'=>'MemberId', 'p.lastname'=>'LastName', 'p.firstname'=>'Firstname'); + $this->export_TypeFields_array[$r] = array('cat.label'=>"Text", 'cat.description'=>"Text", 'cat.fk_parent'=>'List:categorie:label:rowid', 'p.lastname'=>'Text', 'p.firstname'=>'Text'); + $this->export_entities_array[$r] = array('p.rowid'=>'member', 'p.lastname'=>'member', 'p.firstname'=>'member'); // We define here only fields that use another picto + + $keyforselect = 'adherent'; $keyforelement = 'member'; $keyforaliasextra = 'extra'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as cat'; + $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'categorie_member as cm ON cm.fk_categorie = cat.rowid'; + $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'adherent as p ON p.rowid = cm.fk_member'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'adherent_extrafields as extra ON cat.rowid = extra.fk_object '; + $this->export_sql_end[$r] .= ' WHERE cat.entity IN ('.getEntity('category').')'; + $this->export_sql_end[$r] .= ' AND cat.type = 3'; + + // 4 Contacts + $r++; + $this->export_code[$r] = $this->rights_class.'_4_'.Categorie::$MAP_ID_TO_CODE[4]; + $this->export_label[$r] = 'CatContactList'; + $this->export_icon[$r] = $this->picto; + $this->export_enabled[$r] = '!empty($conf->societe->enabled)'; + $this->export_permission[$r] = array(array("categorie", "lire"), array("societe", "contact", "export")); + $this->export_fields_array[$r] = array( + 'cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategory", + 'p.rowid' => 'ContactId', 'civ.label' => 'UserTitle', 'p.lastname' => 'LastName', 'p.firstname' => 'Firstname', + 'p.address' => 'Address', 'p.zip' => 'Zip', 'p.town' => 'Town', 'c.code' => 'CountryCode', 'c.label' => 'Country', + 'p.birthday' => 'DateOfBirth', 'p.poste' => 'PostOrFunction', + 'p.phone' => 'Phone', 'p.phone_perso' => 'PhonePerso', 'p.phone_mobile' => 'PhoneMobile', 'p.fax' => 'Fax', 'p.email' => 'Email', + 'p.note_private' => 'NotePrivate', 'p.note_public' => 'NotePublic', 'p.statut' => 'Status', + 's.nom'=>"Name", 's.client'=>"Customer", 's.fournisseur'=>"Supplier", 's.status'=>"Status", + 's.address'=>"Address", 's.zip'=>"Zip", 's.town'=>"Town", + 's.phone'=>"Phone", 's.fax'=>"Fax", 's.url'=>"Url", 's.email'=>"Email" + ); + $this->export_TypeFields_array[$r] = array( + 'cat.label'=>"Text", 'cat.description'=>"Text", 'cat.fk_parent'=>'List:categorie:label:rowid', + 'civ.label' => 'List:c_civility:label:label', 'p.lastname' => 'Text', 'p.firstname' => 'Text', + 'p.address' => 'Text', 'p.zip' => 'Text', 'p.town' => 'Text', 'c.code' => 'Text', 'c.label' => 'List:c_country:label:label', + 'p.birthday' => 'Date', 'p.poste' => 'Text', + 'p.phone' => 'Text', 'p.phone_perso' => 'Text', 'p.phone_mobile' => 'Text', 'p.fax' => 'Text', 'p.email' => 'Text', + 'p.note_private' => 'Text', 'p.note_public' => 'Text', 'p.statut' => 'Boolean', + 's.nom'=>"Text", 's.client'=>"Boolean", 's.fournisseur'=>"Boolean", 's.status'=>"Boolean", + 's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text", + 's.phone'=>"Text", 's.fax'=>"Text", 's.url'=>"Text", 's.email'=>"Text" + ); + $this->export_entities_array[$r] = array( + 'p.rowid' => 'contact', 'civ.label' => 'contact', 'p.lastname' => 'contact', 'p.firstname' => 'contact', + 'p.address' => 'contact', 'p.zip' => 'contact', 'p.town' => 'contact', 'c.code' => 'contact', 'c.label' => 'contact', + 'p.birthday' => 'contact', 'p.poste' => 'contact', + 'p.phone' => 'contact', 'p.phone_perso' => 'contact', 'p.phone_mobile' => 'contact', 'p.fax' => 'contact', 'p.email' => 'contact', + 'p.note_private' => 'contact', 'p.note_public' => 'contact', 'p.statut' => 'contact', + 's.nom'=>"company", 's.client'=>"company", 's.fournisseur'=>"company", 's.status'=>"company", + 's.address'=>"company", 's.zip'=>"company", 's.town'=>"company", + 's.phone'=>"company", 's.fax'=>"company", 's.url'=>"company", 's.email'=>"company" + ); // We define here only fields that use another picto + + $keyforselect = 'socpeople'; $keyforelement = 'contact'; $keyforaliasextra = 'extra'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as cat'; + $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'categorie_contact as cc ON cc.fk_categorie = cat.rowid'; + $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'socpeople as p ON p.rowid = cc.fk_socpeople'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = p.rowid'; - $this->export_sql_end[$r] .= ' WHERE u.rowid = cp.fk_categorie AND cp.fk_socpeople = p.rowid AND u.entity IN ('.getEntity('category').')'; - $this->export_sql_end[$r] .= ' AND u.type = 4'; // contact categories + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_civility as civ ON civ.rowid = p.civility'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON c.rowid = p.fk_pays'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc'; + $this->export_sql_end[$r] .= ' WHERE cat.entity IN ('.getEntity('category').')'; + $this->export_sql_end[$r] .= ' AND cat.type = 4'; + + // 5 Bank accounts, TODO ? + + // 6 Projects + $r++; + $this->export_code[$r] = $this->rights_class.'_6_'.Categorie::$MAP_ID_TO_CODE[6]; + $this->export_label[$r] = 'CatProjectsList'; + $this->export_icon[$r] = $this->picto; + $this->export_enabled[$r] = '!empty($conf->projet->enabled)'; + $this->export_permission[$r] = array(array("categorie", "lire"), array("projet", "export")); + $this->export_fields_array[$r] = array('cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategory", 'p.rowid'=>'ProjectId', 'p.ref'=>'Ref', 's.rowid'=>"IdThirdParty", 's.nom'=>"Name"); + $this->export_TypeFields_array[$r] = array('cat.label'=>"Text", 'cat.description'=>"Text", 'cat.fk_parent'=>'List:categorie:label:rowid', 'p.ref'=>'Text', 's.rowid'=>"List:societe:nom:rowid", 's.nom'=>"Text"); + $this->export_entities_array[$r] = array('p.rowid'=>'project', 'p.ref'=>'project', 's.rowid'=>"company", 's.nom'=>"company"); // We define here only fields that use another picto + + $keyforselect = 'projet'; $keyforelement = 'project'; $keyforaliasextra = 'extra'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as cat'; + $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'categorie_project as cp ON cp.fk_categorie = cat.rowid'; + $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'projet as p ON p.rowid = cp.fk_project'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet_extrafields as extra ON extra.fk_object = p.rowid'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc'; + $this->export_sql_end[$r] .= ' WHERE cat.entity IN ('.getEntity('category').')'; + $this->export_sql_end[$r] .= ' AND cat.type = 6'; + + // 7 Users + $r++; + $this->export_code[$r] = $this->rights_class.'_7_'.Categorie::$MAP_ID_TO_CODE[7]; + $this->export_label[$r] = 'CatUsersList'; + $this->export_icon[$r] = $this->picto; + $this->export_enabled[$r] = '!empty($conf->user->enabled)'; + $this->export_permission[$r] = array(array("categorie", "lire"), array("user", "export")); + $this->export_fields_array[$r] = array('cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategory", 'p.rowid'=>'TechnicalID', 'p.login'=>'Login', 'p.lastname'=>'Lastname', 'p.firstname'=>'Firstname'); + $this->export_TypeFields_array[$r] = array('cat.label'=>"Text", 'cat.description'=>"Text", 'cat.fk_parent'=>'List:categorie:label:rowid', 'p.login'=>'Text', 'p.lastname'=>'Text', 'p.firstname'=>'Text'); + $this->export_entities_array[$r] = array('p.rowid'=>'user', 'p.login'=>'user', 'p.lastname'=>'user', 'p.firstname'=>'user'); // We define here only fields that use another picto + + $keyforselect = 'user'; $keyforelement = 'user'; $keyforaliasextra = 'extra'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as cat'; + $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'categorie_user as cu ON cu.fk_categorie = cat.rowid'; + $this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'user as p ON p.rowid = cu.fk_user'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user_extrafields as extra ON extra.fk_object = p.rowid'; + $this->export_sql_end[$r] .= ' WHERE cat.entity IN ('.getEntity('category').')'; + $this->export_sql_end[$r] .= ' AND cat.type = 7'; + + // 8 Bank Lines, TODO ? + + // 9 Warehouses, TODO ? + + // 10 Agenda Events, TODO ? + + // 11 Website Pages, TODO ? // Imports //-------- $r = 0; + // Categories $r++; - $this->import_code[$r] = $this->rights_class.'_'.$r; + $this->import_code[$r] = $this->rights_class.'_list'; $this->import_label[$r] = "CatList"; // Translation key $this->import_icon[$r] = $this->picto; $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r] = array('ca'=>MAIN_DB_PREFIX.'categorie'); $this->import_fields_array[$r] = array( 'ca.label'=>"Label*", 'ca.type'=>"Type*", 'ca.description'=>"Description", - 'ca.fk_parent' => 'Parent' + 'ca.fk_parent' => 'ParentCategory' ); - $this->import_regex_array[$r] = array('ca.type'=>'^\d+$'); + $this->import_regex_array[$r] = array('ca.type'=>'^(0|1|2|3|4|5|6|7|8|9|10|11)$'); $this->import_convertvalue_array[$r] = array( 'ca.fk_parent' => array( 'rule' => 'fetchidfromcodeandlabel', @@ -385,21 +419,18 @@ class modCategorie extends DolibarrModules 'codefromfield' => 'ca.type' ) ); - $typeexample = ""; - if (!empty($conf->product->enabled)) { $typeexample .= ($typeexample ? "/" : "")."0=Product"; } - if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) { $typeexample .= ($typeexample ? "/" : "")."1=Supplier"; } - if (!empty($conf->societe->enabled)) { $typeexample .= ($typeexample ? "/" : "")."2=Customer-Prospect"; } - if (!empty($conf->adherent->enabled)) { $typeexample .= ($typeexample ? "/" : "")."3=Member"; } - $this->import_examplevalues_array[$r] = array( - 'ca.label'=>"Supplier Category", 'ca.type'=>$typeexample, 'ca.description'=>"My Category description", - 'ca.fk_parent' => '0' - ); + $this->import_examplevalues_array[$r] = array( + 'ca.label'=>"My Category Label", 'ca.type'=>$typeexample, 'ca.description'=>"My Category description", // $typeexample built above in exports + 'ca.fk_parent' => 'rowid or label' + ); + $this->import_updatekeys_array[$r] = array('ca.label'=>'Label'); + + // 0 Products if (!empty($conf->product->enabled)) { - //Products $r++; - $this->import_code[$r] = $this->rights_class.'_'.$r; + $this->import_code[$r] = $this->rights_class.'_0_'.Categorie::$MAP_ID_TO_CODE[0]; $this->import_label[$r] = "CatProdLinks"; // Translation key $this->import_icon[$r] = $this->picto; $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon @@ -409,57 +440,16 @@ class modCategorie extends DolibarrModules $this->import_convertvalue_array[$r] = array( 'cp.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'), - 'cp.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'product') + 'cp.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') ); - $this->import_examplevalues_array[$r] = array('cp.fk_categorie'=>"Imported category", 'cp.fk_product'=>"PREF123456"); - } - - if (!empty($conf->societe->enabled)) - { - // Customers - $r++; - $this->import_code[$r] = $this->rights_class.'_'.$r; - $this->import_label[$r] = "CatCusLinks"; // Translation key - $this->import_icon[$r] = $this->picto; - $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r] = array('cs'=>MAIN_DB_PREFIX.'categorie_societe'); - $this->import_fields_array[$r] = array('cs.fk_categorie'=>"Category*", 'cs.fk_soc'=>"ThirdParty*"); - $this->import_regex_array[$r] = array( - 'cs.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=2', - 'cs.fk_soc'=>'rowid@'.MAIN_DB_PREFIX.'societe:client>0' - ); - - $this->import_convertvalue_array[$r] = array( - 'cs.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'), - 'cs.fk_soc'=>array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty') - ); - $this->import_examplevalues_array[$r] = array('cs.fk_categorie'=>"Imported category", 'cs.fk_soc'=>"MyBigCompany"); - - // Contacts/Addresses - $r++; - $this->import_code[$r] = $this->rights_class.'_'.$r; - $this->import_label[$r] = "CatContactsLinks"; // Translation key - $this->import_icon[$r] = $this->picto; - $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon - $this->import_tables_array[$r] = array('cs'=>MAIN_DB_PREFIX.'categorie_contact'); - $this->import_fields_array[$r] = array('cs.fk_categorie'=>"Category*", 'cs.fk_socpeople'=>"Contact ID*"); - $this->import_regex_array[$r] = array( - 'cs.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=4' - //'cs.fk_socpeople'=>'rowid@'.MAIN_DB_PREFIX.'socpeople' - ); - - $this->import_convertvalue_array[$r] = array( - 'cs.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category') - //'cs.fk_socpeople'=>array('rule'=>'fetchidfromref','classfile'=>'/contact/class/contact.class.php','class'=>'Contact','method'=>'fetch','element'=>'Contact') - ); - $this->import_examplevalues_array[$r] = array('cs.fk_categorie'=>"Imported category", 'cs.fk_socpeople'=>"123"); + $this->import_examplevalues_array[$r] = array('cp.fk_categorie'=>"rowid or label", 'cp.fk_product'=>"rowid or ref"); } + // 1 Suppliers if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) { - // Suppliers $r++; - $this->import_code[$r] = $this->rights_class.'_'.$r; + $this->import_code[$r] = $this->rights_class.'_1_'.Categorie::$MAP_ID_TO_CODE[1]; $this->import_label[$r] = "CatSupLinks"; // Translation key $this->import_icon[$r] = $this->picto; $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon @@ -474,8 +464,119 @@ class modCategorie extends DolibarrModules 'cs.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'), 'cs.fk_soc'=>array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty') ); - $this->import_examplevalues_array[$r] = array('cs.fk_categorie'=>"Imported category", 'cs.fk_soc'=>"MyBigCompany"); + $this->import_examplevalues_array[$r] = array('cs.fk_categorie'=>"rowid or label", 'cs.fk_soc'=>"rowid or ref"); } + + // 2 Customers + if (!empty($conf->societe->enabled)) + { + $r++; + $this->import_code[$r] = $this->rights_class.'_2_'.Categorie::$MAP_ID_TO_CODE[2]; + $this->import_label[$r] = "CatCusLinks"; // Translation key + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('cs'=>MAIN_DB_PREFIX.'categorie_societe'); + $this->import_fields_array[$r] = array('cs.fk_categorie'=>"Category*", 'cs.fk_soc'=>"Customer*"); + $this->import_regex_array[$r] = array( + 'cs.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=2', + 'cs.fk_soc'=>'rowid@'.MAIN_DB_PREFIX.'societe:client>0' + ); + + $this->import_convertvalue_array[$r] = array( + 'cs.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'), + 'cs.fk_soc'=>array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty') + ); + $this->import_examplevalues_array[$r] = array('cs.fk_categorie'=>"rowid or label", 'cs.fk_soc'=>"rowid or ref"); + } + + // 3 Members + if (!empty($conf->adherent->enabled)) + { + $r++; + $this->import_code[$r] = $this->rights_class.'_3_'.Categorie::$MAP_ID_TO_CODE[3]; + $this->import_label[$r] = "CatMembersLinks"; // Translation key + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('cm'=>MAIN_DB_PREFIX.'categorie_contact'); + $this->import_fields_array[$r] = array('cm.fk_categorie'=>"Category*", 'cm.fk_member'=>"Member*"); + $this->import_regex_array[$r] = array('cm.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=3'); + + $this->import_convertvalue_array[$r] = array( + 'cs.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'), + 'cs.fk_member'=>array('rule'=>'fetchidfromref','classfile'=>'/adherents/class/adherent.class.php','class'=>'Adherent','method'=>'fetch','element'=>'Member') + ); + $this->import_examplevalues_array[$r] = array('cs.fk_categorie'=>"rowid or label", 'cs.fk_member'=>"rowid or ref"); + } + + // 4 Contacts/Addresses + if (!empty($conf->societe->enabled)) + { + $r++; + $this->import_code[$r] = $this->rights_class.'_4_'.Categorie::$MAP_ID_TO_CODE[4]; + $this->import_label[$r] = "CatContactsLinks"; // Translation key + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('cc'=>MAIN_DB_PREFIX.'categorie_contact'); + $this->import_fields_array[$r] = array('cc.fk_categorie'=>"Category*", 'cc.fk_socpeople'=>"IdContact*"); + $this->import_regex_array[$r] = array( + 'cc.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=4' + //'cc.fk_socpeople'=>'rowid@'.MAIN_DB_PREFIX.'socpeople' + ); + + $this->import_convertvalue_array[$r] = array( + 'cc.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'), + //'cc.fk_socpeople'=>array('rule'=>'fetchidfromref','classfile'=>'/contact/class/contact.class.php','class'=>'Contact','method'=>'fetch','element'=>'Contact') + ); + $this->import_examplevalues_array[$r] = array('cc.fk_categorie'=>"rowid or label", 'cc.fk_socpeople'=>"rowid"); + } + + // 5 Bank accounts, TODO ? + + // 6 Projects + if (!empty($conf->projet->enabled)) + { + $r++; + $this->import_code[$r] = $this->rights_class.'_6_'.Categorie::$MAP_ID_TO_CODE[6]; + $this->import_label[$r] = "CatProjectsLinks"; // Translation key + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('cp'=>MAIN_DB_PREFIX.'categorie_project'); + $this->import_fields_array[$r] = array('cp.fk_categorie'=>"Category*", 'cp.fk_project'=>"Project*"); + $this->import_regex_array[$r] = array('cp.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=6'); + + $this->import_convertvalue_array[$r] = array( + 'cs.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'), + 'cs.fk_project'=>array('rule'=>'fetchidfromref','classfile'=>'/projet/class/project.class.php','class'=>'Project','method'=>'fetch','element'=>'Project') + ); + $this->import_examplevalues_array[$r] = array('cp.fk_categorie'=>"rowid or label", 'cp.fk_project'=>"rowid or ref"); + } + + // 7 Users + if (!empty($conf->user->enabled)) + { + $r++; + $this->import_code[$r] = $this->rights_class.'_7_'.Categorie::$MAP_ID_TO_CODE[7]; + $this->import_label[$r] = "CatUsersLinks"; // Translation key + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon + $this->import_tables_array[$r] = array('cu'=>MAIN_DB_PREFIX.'categorie_user'); + $this->import_fields_array[$r] = array('cu.fk_categorie'=>"Category*", 'cu.fk_user'=>"User*"); + $this->import_regex_array[$r] = array('cu.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=7'); + + $this->import_convertvalue_array[$r] = array( + 'cu.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'), + 'cu.fk_user'=>array('rule'=>'fetchidfromref','classfile'=>'/user/class/user.class.php','class'=>'User','method'=>'fetch','element'=>'User') + ); + $this->import_examplevalues_array[$r] = array('cu.fk_categorie'=>"rowid or label", 'cu.fk_user'=>"rowid or login"); + } + + // 8 Bank Lines, TODO ? + + // 9 Warehouses, TODO ? + + // 10 Agenda Events, TODO ? + + // 11 Website Pages, TODO ? } diff --git a/htdocs/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang index ba37a43b4ec..36d1d3e545a 100644 --- a/htdocs/langs/en_US/categories.lang +++ b/htdocs/langs/en_US/categories.lang @@ -65,16 +65,22 @@ UsersCategoriesShort=Users tags/categories StockCategoriesShort=Warehouse tags/categories ThisCategoryHasNoItems=This category does not contain any items. CategId=Tag/category id -CatSupList=List of vendor tags/categories -CatCusList=List of customer/prospect tags/categories +ParentCategory=Parent tag/category +ParentCategoryLabel=Label of parent tag/category +CatSupList=List of vendors tags/categories +CatCusList=List of customers/prospects tags/categories CatProdList=List of products tags/categories CatMemberList=List of members tags/categories -CatContactList=List of contact tags/categories -CatSupLinks=Links between suppliers and tags/categories +CatContactList=List of contacts tags/categories +CatProjectsList=List of projects tags/categories +CatUsersList=List of users tags/categories +CatSupLinks=Links between vendors and tags/categories CatCusLinks=Links between customers/prospects and tags/categories CatContactsLinks=Links between contacts/addresses and tags/categories CatProdLinks=Links between products/services and tags/categories -CatProJectLinks=Links between projects and tags/categories +CatMembersLinks=Links between members and tags/categories +CatProjectsLinks=Links between projects and tags/categories +CatUsersLinks=Links between users and tags/categories DeleteFromCat=Remove from tags/category ExtraFieldsCategories=Complementary attributes CategoriesSetup=Tags/categories setup diff --git a/htdocs/langs/fr_FR/categories.lang b/htdocs/langs/fr_FR/categories.lang index 580e98a38e9..f69d8573827 100644 --- a/htdocs/langs/fr_FR/categories.lang +++ b/htdocs/langs/fr_FR/categories.lang @@ -65,16 +65,22 @@ UsersCategoriesShort=Tags utlisateurs StockCategoriesShort=Tags/catégories d’entrepôt ThisCategoryHasNoItems=Cette catégorie ne contient aucun élément. CategId=ID du(de la) tag/catégorie +ParentCategory=Tag/catégorie parent +ParentCategoryLabel=Libellé du/de la tag/catégorie parent CatSupList=Liste des tags/catégories de fournisseurs CatCusList=Liste des tags/catégories de clients/prospects CatProdList=Liste des tags/catégories de produits/services CatMemberList=Liste des tags/catégories de membres -CatContactList=Liste des tags/catégories de contact +CatContactList=Liste des tags/catégories de contacts +CatProjectsList=Liste des tags/catégories de projets +CatUsersList=Liste des tags/catégories d'utilisateurs CatSupLinks=Liens entre fournisseurs et tags/catégories CatCusLinks=Liens entre clients/prospects et tags/catégories CatContactsLinks=Liens entre contacts/adresses et tags/catégories CatProdLinks=Liens entre produits/services et tags/catégories -CatProJectLinks=Liens entre projets et tags/catégories +CatMembersLinks=Liens entre membres et tags/catégories +CatProjectsLinks=Liens entre projets et tags/catégories +CatUsersLinks=Liens entre utilisateurs et tags/catégories DeleteFromCat=Enlever des tags/catégories ExtraFieldsCategories=Attributs supplémentaires CategoriesSetup=Configuration des tags/catégories From 7749138a810a01470cb9327455b4f7be82498195 Mon Sep 17 00:00:00 2001 From: StephaneLesage Date: Sat, 21 Nov 2020 13:28:37 +0100 Subject: [PATCH 045/392] 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 046/392] 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 7a93c11ae0e2473918397646bdccbe09ab7256cd Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 15 Dec 2020 22:01:33 +0100 Subject: [PATCH 047/392] FIX : dupliacete customer or supplier code must be error dipslayed with new code proposed --- htdocs/societe/card.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index b8af6777daa..56793184f65 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -634,11 +634,16 @@ if (empty($reshook)) } else { - if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') // TODO Sometime errors on duplicate on profid and not on code, so we must manage this case + if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS' || ($result==-3 && in_array('ErrorCustomerCodeAlreadyUsed', $object->errors))) // TODO Sometime errors on duplicate on profid and not on code, so we must manage this case + { + $duplicate_code_error = true; + $object->code_client = null; + } + + if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS' || ($result==-3 && in_array('ErrorSupplierCodeAlreadyUsed',$object->errors))) // TODO Sometime errors on duplicate on profid and not on code, so we must manage this case { $duplicate_code_error = true; $object->code_fournisseur = null; - $object->code_client = null; } setEventMessages($object->error, $object->errors, 'errors'); From b80bd8d1f8af4ced9e3c978ed41f5dbc605169b0 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 15 Dec 2020 22:03:15 +0100 Subject: [PATCH 048/392] FIX : dupliacete customer or supplier code must be error dipslayed with new code proposed --- htdocs/societe/card.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 56793184f65..93e0196f1ae 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -634,18 +634,22 @@ if (empty($reshook)) } else { - if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS' || ($result==-3 && in_array('ErrorCustomerCodeAlreadyUsed', $object->errors))) // TODO Sometime errors on duplicate on profid and not on code, so we must manage this case + if ($result==-3 && in_array('ErrorCustomerCodeAlreadyUsed', $object->errors)) { $duplicate_code_error = true; $object->code_client = null; } - if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS' || ($result==-3 && in_array('ErrorSupplierCodeAlreadyUsed',$object->errors))) // TODO Sometime errors on duplicate on profid and not on code, so we must manage this case + if ($result==-3 && in_array('ErrorSupplierCodeAlreadyUsed',$object->errors)) { $duplicate_code_error = true; $object->code_fournisseur = null; } + if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + $duplicate_code_error = true; + } + setEventMessages($object->error, $object->errors, 'errors'); $error++; } From 9ca2e98a662a16bf57fb51f62729c1e6e4bca443 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 15 Dec 2020 21:12:52 +0000 Subject: [PATCH 049/392] Fixing style errors. --- htdocs/societe/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 93e0196f1ae..d79a5c1a9e0 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -640,7 +640,7 @@ if (empty($reshook)) $object->code_client = null; } - if ($result==-3 && in_array('ErrorSupplierCodeAlreadyUsed',$object->errors)) + if ($result==-3 && in_array('ErrorSupplierCodeAlreadyUsed', $object->errors)) { $duplicate_code_error = true; $object->code_fournisseur = null; From 5fe8c599d22c9c261b8cd4a5727c9bd6cf9499cb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Dec 2020 00:28:57 +0100 Subject: [PATCH 050/392] Fix warning --- htdocs/comm/propal/class/propal.class.php | 1 + htdocs/supplier_proposal/class/supplier_proposal.class.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 274c04b0698..f572f6110bf 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -598,6 +598,7 @@ class Propal extends CommonObject $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); // Clean vat code + $reg = array(); $vat_src_code = ''; if (preg_match('/\((.*)\)/', $txtva, $reg)) { diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index cf8e712a103..022c5a13354 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -593,8 +593,8 @@ class SupplierProposal extends CommonObject // Mise en option de la ligne if (empty($qty) && empty($special_code)) $this->line->special_code = 3; - if (is_array($array_option) && count($array_option) > 0) { - $this->line->array_options = $array_option; + if (is_array($array_options) && count($array_options) > 0) { + $this->line->array_options = $array_options; } $result = $this->line->insert(); From 834058a81669ab94c965e94ddfd82adb021ecf77 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Dec 2020 02:33:21 +0100 Subject: [PATCH 051/392] Debug api to create a document --- htdocs/api/class/api_documents.class.php | 44 ++++++++------- htdocs/core/lib/files.lib.php | 2 +- htdocs/core/lib/geturl.lib.php | 2 +- test/phpunit/AllTests.php | 2 + test/phpunit/RestAPIDocumentTest.php | 69 +++++++++++++++++++----- 5 files changed, 85 insertions(+), 34 deletions(-) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index da9545aa248..bdf86a5c2c9 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -535,13 +535,14 @@ class Documents extends DolibarrApi * Test sample for supplier invoice: { "filename": "mynewfile.txt", "modulepart": "supplier_invoice", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }. * Test sample for medias file: { "filename": "mynewfile.txt", "modulepart": "medias", "ref": "", "subdir": "image/mywebsite", "filecontent": "Y29udGVudCB0ZXh0Cg==", "fileencoding": "base64", "overwriteifexists": "0" }. * - * @param string $filename Name of file to create ('FA1705-0123.txt') - * @param string $modulepart Name of module or area concerned by file upload ('facture', 'project', 'project_task', ...) - * @param string $ref Reference of object (This will define subdir automatically and store submited file into it) - * @param string $subdir Subdirectory (Only if ref not provided) - * @param string $filecontent File content (string with file content. An empty file will be created if this parameter is not provided) - * @param string $fileencoding File encoding (''=no encoding, 'base64'=Base 64) - * @param int $overwriteifexists Overwrite file if exists (1 by default) + * @param string $filename Name of file to create ('FA1705-0123.txt') + * @param string $modulepart Name of module or area concerned by file upload ('facture', 'project', 'project_task', ...) + * @param string $ref Reference of object (This will define subdir automatically and store submited file into it) + * @param string $subdir Subdirectory (Only if ref not provided) + * @param string $filecontent File content (string with file content. An empty file will be created if this parameter is not provided) + * @param string $fileencoding File encoding (''=no encoding, 'base64'=Base 64) + * @param int $overwriteifexists Overwrite file if exists (1 by default) + * @param int $createdirifnotexists Create subdirectories if the doesn't exists (1 by default) * @return string * * @throws RestException 400 @@ -551,7 +552,7 @@ class Documents extends DolibarrApi * * @url POST /upload */ - public function post($filename, $modulepart, $ref = '', $subdir = '', $filecontent = '', $fileencoding = '', $overwriteifexists = 0) + public function post($filename, $modulepart, $ref = '', $subdir = '', $filecontent = '', $fileencoding = '', $overwriteifexists = 0, $createdirifnotexists = 1) { global $db, $conf; @@ -578,6 +579,8 @@ class Documents extends DolibarrApi // Define $uploadir $object = null; $entity = DolibarrApiAccess::$user->entity; + if (empty($entity)) $entity = 1; + if ($ref) { $tmpreldir = ''; @@ -663,8 +666,7 @@ class Documents extends DolibarrApi } } - if (!($object->id > 0)) - { + if (!($object->id > 0)) { throw new RestException(404, 'The object '.$modulepart." with ref '".$ref."' was not found."); } @@ -681,29 +683,32 @@ class Documents extends DolibarrApi if (empty($upload_dir) || $upload_dir == '/') { - throw new RestException(500, 'This value of modulepart does not support yet usage of ref. Check modulepart parameter or try to use subdir parameter instead of ref.'); + throw new RestException(500, 'This value of modulepart ('.$modulepart.') does not support yet usage of ref. Check modulepart parameter or try to use subdir parameter instead of ref.'); } } else { if ($modulepart == 'invoice') $modulepart = 'facture'; if ($modulepart == 'member') $modulepart = 'adherent'; $relativefile = $subdir; - $tmp = dol_check_secure_access_document($modulepart, $relativefile, $entity, DolibarrApiAccess::$user, '', 'write'); $upload_dir = $tmp['original_file']; // No dirname here, tmp['original_file'] is already the dir because dol_check_secure_access_document was called with param original_file that is only the dir - if (empty($upload_dir) || $upload_dir == '/') - { - throw new RestException(500, 'This value of modulepart does not support yet usage of ref. Check modulepart parameter or try to use subdir parameter instead of ref.'); + if (empty($upload_dir) || $upload_dir == '/') { + if (!empty($tmp['error'])) { + throw new RestException(401, 'Error returned by dol_check_secure_access_document: '.$tmp['error']); + } else { + throw new RestException(500, 'This value of modulepart ('.$modulepart.') is not allowed with this value of subdir ('.$relativefile.')'); + } } } // $original_file here is still value of filename without any dir. $upload_dir = dol_sanitizePathName($upload_dir); - if (dol_mkdir($upload_dir) < 0) // needed by products - { - throw new RestException(500, 'Error while trying to create directory.'); + if (!empty($createdirifnotexists)) { + if (dol_mkdir($upload_dir) < 0) { // needed by products + throw new RestException(500, 'Error while trying to create directory.'); + } } $destfile = $upload_dir.'/'.$original_file; @@ -715,8 +720,7 @@ class Documents extends DolibarrApi throw new RestException(401, 'Directory not exists : '.dirname($destfile)); } - if (!$overwriteifexists && dol_is_file($destfile)) - { + if (!$overwriteifexists && dol_is_file($destfile)) { throw new RestException(500, "File with name '".$original_file."' already exists."); } diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 0be1cfbc3bc..22545b78cf8 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2231,7 +2231,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, // Fix modulepart if ($modulepart == 'users') $modulepart = 'user'; - dol_syslog('modulepart='.$modulepart.' original_file='.$original_file.' entity='.$entity); + dol_syslog('dol_check_secure_access_document modulepart='.$modulepart.' original_file='.$original_file.' entity='.$entity); // We define $accessallowed and $sqlprotectagainstexternals $accessallowed = 0; diff --git a/htdocs/core/lib/geturl.lib.php b/htdocs/core/lib/geturl.lib.php index 8cfc08222cd..7e93623f3c1 100644 --- a/htdocs/core/lib/geturl.lib.php +++ b/htdocs/core/lib/geturl.lib.php @@ -33,7 +33,7 @@ * @param string[] $addheaders Array of string to add into header. Example: ('Accept: application/xrds+xml', ....) * @param string[] $allowedschemes List of schemes that are allowed ('http' + 'https' only by default) * @param int $localurl 0=Only external URL are possible, 1=Only local URL, 2=Both external and local URL are allowed. - * @return array Returns an associative array containing the response from the server array('content'=>response,'curl_error_no'=>errno,'curl_error_msg'=>errmsg...) + * @return array Returns an associative array containing the response from the server array('content'=>response, 'curl_error_no'=>errno, 'curl_error_msg'=>errmsg...) */ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = 1, $addheaders = array(), $allowedschemes = array('http', 'https'), $localurl = 0) { diff --git a/test/phpunit/AllTests.php b/test/phpunit/AllTests.php index 163bf320075..ce7f1074721 100644 --- a/test/phpunit/AllTests.php +++ b/test/phpunit/AllTests.php @@ -216,6 +216,8 @@ class AllTests require_once dirname(__FILE__).'/RestAPIUserTest.php'; $suite->addTestSuite('RestAPIUserTest'); + require_once dirname(__FILE__).'/RestAPIDocumentTest.php'; + $suite->addTestSuite('RestAPIDocumentTest'); // Test only with php7.2 or less //if ((float) phpversion() < 7.3) diff --git a/test/phpunit/RestAPIDocumentTest.php b/test/phpunit/RestAPIDocumentTest.php index 8dbaafab018..f45e0437ce5 100644 --- a/test/phpunit/RestAPIDocumentTest.php +++ b/test/phpunit/RestAPIDocumentTest.php @@ -152,35 +152,43 @@ class RestAPIDocumentTest extends PHPUnit\Framework\TestCase { global $conf,$user,$langs,$db; - $url = $this->api_url.'/documents/?api_key='.$this->api_key; + $url = $this->api_url.'/documents/upload?api_key='.$this->api_key; echo __METHOD__.' Request POST url='.$url."\n"; // Send to non existent directory - dol_delete_dir_recursive(DOL_DATA_ROOT.'/medias/tmpphpunit'); + dol_delete_dir_recursive(DOL_DATA_ROOT.'/medias/tmpphpunit/tmpphpunit1'); //$data = '{ "filename": "mynewfile.txt", "modulepart": "medias", "ref": "", "subdir": "mysubdir1/mysubdir2", "filecontent": "content text", "fileencoding": "" }'; $data = array( 'filename'=>"mynewfile.txt", 'modulepart'=>"medias", - 'ref'=>"", - 'subdir'=>"tmpphpunit/tmpphpunit2", + 'subdir'=>"tmpphpunit/tmpphpunit1", 'filecontent'=>"content text", - 'fileencoding'=>"" + 'fileencoding'=>"", + 'overwriteifexists'=>0, + 'createdirifnotexists'=>0 ); - $result = getURLContent($url, 'POST', $data, 1, array(), array('http', 'https'), 2); + $param = ''; + foreach($data as $key => $val) { + $param .= '&'.$key.'='.urlencode($val); + } + + $result = getURLContent($url, 'POST', $param, 1, array(), array('http', 'https'), 2); echo __METHOD__.' Result for sending document: '.var_export($result, true)."\n"; echo __METHOD__.' curl_error_no: '.$result['curl_error_no']."\n"; $object = json_decode($result['content'], true); - $this->assertNotNull($object, 'Parsing of json result must no be null'); - $this->assertEquals('401', $object['error']['code']); + $this->assertNotNull($object, 'Parsing of json result must not be null'); + $this->assertEquals('401', $result['http_code'], 'Return code is not 401'); + $this->assertEquals('401', empty($object['error']['code']) ? '' : $object['error']['code'], 'Error code is not 401'); // Send to existent directory + dol_delete_dir_recursive(DOL_DATA_ROOT.'/medias/tmpphpunit/tmpphpunit2'); dol_mkdir(DOL_DATA_ROOT.'/medias/tmpphpunit/tmpphpunit2'); $data = array( @@ -189,16 +197,53 @@ class RestAPIDocumentTest extends PHPUnit\Framework\TestCase 'ref'=>"", 'subdir'=>"tmpphpunit/tmpphpunit2", 'filecontent'=>"content text", - 'fileencoding'=>"" + 'fileencoding'=>"", + 'overwriteifexists'=>0, + 'createdirifnotexists'=>0 ); - $result2 = getURLContent($url, 'POST', $data, 1, array(), array('http', 'https'), 2); + $param = ''; + foreach($data as $key => $val) { + $param .= '&'.$key.'='.urlencode($val); + } + + $result2 = getURLContent($url, 'POST', $param, 1, array(), array('http', 'https'), 2); echo __METHOD__.' Result for sending document: '.var_export($result2, true)."\n"; echo __METHOD__.' curl_error_no: '.$result2['curl_error_no']."\n"; $object2 = json_decode($result2['content'], true); - $this->assertNotNull($object2, 'Parsing of json result must no be null'); + //$this->assertNotNull($object2, 'Parsing of json result must not be null'); + $this->assertEquals('200', $result2['http_code'], 'Return code must be 200'); $this->assertEquals($result2['curl_error_no'], ''); - $this->assertEquals($result2['content'], 'true'); + $this->assertEquals($object2, 'mynewfile.txt', 'Must contains basename of file'); + + + dol_delete_dir_recursive(DOL_DATA_ROOT.'/medias/tmpphpunit/tmpphpunit3'); + + $data = array( + 'filename'=>"mynewfile.txt", + 'modulepart'=>"medias", + 'ref'=>"", + 'subdir'=>"tmpphpunit/tmpphpunit3", + 'filecontent'=>"content text", + 'fileencoding'=>"", + 'overwriteifexists'=>0, + 'createdirifnotexists'=>1 + ); + + $param = ''; + foreach($data as $key => $val) { + $param .= '&'.$key.'='.urlencode($val); + } + + $result3 = getURLContent($url, 'POST', $param, 1, array(), array('http', 'https'), 2); + echo __METHOD__.' Result for sending document: '.var_export($result3, true)."\n"; + echo __METHOD__.' curl_error_no: '.$result3['curl_error_no']."\n"; + $object3 = json_decode($result3['content'], true); + //$this->assertNotNull($object2, 'Parsing of json result must not be null'); + $this->assertEquals('200', $result3['http_code'], 'Return code must be 200'); + $this->assertEquals($result3['curl_error_no'], ''); + $this->assertEquals($object3, 'mynewfile.txt', 'Must contains basename of file'); + dol_delete_dir_recursive(DOL_DATA_ROOT.'/medias/tmpphpunit'); } From 69061e422bab02386d0c6bf02f01befe3cb3f87b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Dec 2020 02:44:48 +0100 Subject: [PATCH 052/392] Removed warning --- htdocs/commande/class/commande.class.php | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 9ea05a13065..00cba2055f7 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -492,26 +492,21 @@ class Commande extends CommonOrder $error++; } - if (!$error) - { + if (!$error) { // If stock is incremented on validate order, we must increment it - if ($result >= 0 && !empty($conf->stock->enabled) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1) - { + if ($result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); // Loop on each line $cpt = count($this->lines); - for ($i = 0; $i < $cpt; $i++) - { - if ($this->lines[$i]->fk_product > 0) - { + for ($i = 0; $i < $cpt; $i++) { + if ($this->lines[$i]->fk_product > 0) { $mouvP = new MouvementStock($this->db); $mouvP->origin = &$this; // We decrement stock of product (and sub-products) $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("OrderValidatedInDolibarr", $num)); - if ($result < 0) - { + if ($result < 0) { $error++; $this->error = $mouvP->error; } @@ -521,16 +516,14 @@ class Commande extends CommonOrder } } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('ORDER_VALIDATE', $user); if ($result < 0) $error++; // End call triggers } - if (!$error) - { + if (!$error) { $this->oldref = $this->ref; // Rename directory if dir was a temporary ref From a03de433be4e962a7af509d945781e26cf572e0c Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 16 Dec 2020 05:03:37 +0100 Subject: [PATCH 053/392] FIX: Accountancy - Quadra export format - Manage negative amount --- .../class/accountancyexport.class.php | 56 +++++++++++-------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index f15a2a0c704..899eddc0e56 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -505,9 +505,9 @@ class AccountancyExport $end_line = "\r\n"; - //We should use dol_now function not time however this is wrong date to transfert in accounting - //$date_ecriture = dol_print_date(dol_now(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy - //$date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy + // We should use dol_now function not time however this is wrong date to transfert in accounting + // $date_ecriture = dol_print_date(dol_now(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy + // $date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy foreach ($TData as $data) { $code_compta = $data->numero_compte; if (!empty($data->subledger_account)) @@ -519,36 +519,46 @@ class AccountancyExport $Tab['code_journal'] = str_pad(self::trunc($data->code_journal, 2), 2); $Tab['folio'] = '000'; - //We use invoice date $data->doc_date not $date_ecriture which is the transfert date - //maybe we should set an option for customer who prefer to keep in accounting software the tranfert date instead of invoice date ? + // We use invoice date $data->doc_date not $date_ecriture which is the transfert date + // maybe we should set an option for customer who prefer to keep in accounting software the tranfert date instead of invoice date ? //$Tab['date_ecriture'] = $date_ecriture; $Tab['date_ecriture'] = dol_print_date($data->doc_date, '%d%m%y'); $Tab['filler'] = ' '; $Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).' '.dol_string_unaccent($data->label_operation), 20), 20); - $Tab['sens'] = $data->sens; // C or D - $Tab['signe_montant'] = '+'; - //elarifr le montant doit etre en centimes sans point decimal ! - $Tab['montant'] = str_pad(abs($data->montant * 100), 12, '0', STR_PAD_LEFT); // TODO manage negative amount - // $Tab['montant'] = str_pad(abs($data->montant), 12, '0', STR_PAD_LEFT); // TODO manage negative amount + // Credit invoice - invert sens + if ($data->montant < 0) { + if ($data->sens == 'C') { + $Tab['sens'] = 'D'; + } else { + $Tab['sens'] = 'C'; + } + $Tab['signe_montant'] = '-'; + } else { + $Tab['sens'] = $data->sens; // C or D + $Tab['signe_montant'] = '+'; + } + + // The amount must be in centimes without decimal points. + $Tab['montant'] = str_pad(abs($data->montant * 100), 12, '0', STR_PAD_LEFT); $Tab['contrepartie'] = str_repeat(' ', 8); - // elarifr: date format must be fixed format : 6 char ddmmyy = %d%m%yand not defined by user / dolibarr setting + // Force date format : %d%m%y if (!empty($data->date_echeance)) { //$Tab['date_echeance'] = dol_print_date($data->date_echeance, $conf->global->ACCOUNTING_EXPORT_DATE); - $Tab['date_echeance'] = dol_print_date($data->date_echeance, '%d%m%y'); // elarifr: format must be ddmmyy + $Tab['date_echeance'] = dol_print_date($data->date_echeance, '%d%m%y'); // Format must be ddmmyy } else { $Tab['date_echeance'] = '000000'; } - //elarifr please keep quadra named field lettrage(2) + codestat(3) instead of fake lettrage(5) - //$Tab['lettrage'] = str_repeat(' ', 5); + // Please keep quadra named field lettrage(2) + codestat(3) instead of fake lettrage(5) + // $Tab['lettrage'] = str_repeat(' ', 5); $Tab['lettrage'] = str_repeat(' ', 2); $Tab['codestat'] = str_repeat(' ', 3); $Tab['num_piece'] = str_pad(self::trunc($data->piece_num, 5), 5); - //elarifr keep correct quadra named field instead of anon filler - //$Tab['filler2'] = str_repeat(' ', 20); + // Keep correct quadra named field instead of anon filler + // $Tab['filler2'] = str_repeat(' ', 20); $Tab['affaire'] = str_repeat(' ', 10); $Tab['quantity1'] = str_repeat(' ', 10); $Tab['num_piece2'] = str_pad(self::trunc($data->piece_num, 8), 8); @@ -556,17 +566,17 @@ class AccountancyExport $Tab['code_journal2'] = str_pad(self::trunc($data->code_journal, 3), 3); $Tab['filler3'] = str_repeat(' ', 3); - //elarifr keep correct quadra named field instead of anon filler libelle_ecriture2 is 30 char not 32 !!!! - //as we use utf8, we must remove accent to have only one ascii char instead of utf8 2 chars for specials that report wrong line size that will exceed import format spec - //todo we should filter more than only accent to avoid wrong line size - //TODO: remove invoice number doc_ref in libelle, - //TODO: we should offer an option for customer to build the libelle using invoice number / name / date in accounting software + // Keep correct quadra named field instead of anon filler libelle_ecriture2 is 30 char not 32 !!!! + // as we use utf8, we must remove accent to have only one ascii char instead of utf8 2 chars for specials that report wrong line size that will exceed import format spec + // TODO: we should filter more than only accent to avoid wrong line size + // TODO: remove invoice number doc_ref in libelle, + // TODO: we should offer an option for customer to build the libelle using invoice number / name / date in accounting software //$Tab['libelle_ecriture2'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref) . ' ' . dol_string_unaccent($data->label_operation), 30), 30); $Tab['libelle_ecriture2'] = str_pad(self::trunc(dol_string_unaccent($data->label_operation), 30), 30); $Tab['codetva'] = str_repeat(' ', 2); - //elarifr we need to keep the 10 lastest number of invoice doc_ref not the beginning part that is the unusefull almost same part - //$Tab['num_piece3'] = str_pad(self::trunc($data->piece_num, 10), 10); + // We need to keep the 10 lastest number of invoice doc_ref not the beginning part that is the unusefull almost same part + // $Tab['num_piece3'] = str_pad(self::trunc($data->piece_num, 10), 10); $Tab['num_piece3'] = substr(self::trunc($data->doc_ref, 20), -10); $Tab['filler4'] = str_repeat(' ', 73); From ca40d5e52ada5507534c91a107374b5c0219a42b Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 16 Dec 2020 05:16:08 +0100 Subject: [PATCH 054/392] NEW: Accountancy - Introduce FEC "2" Format to resolve conflict with some software --- .../class/accountancyexport.class.php | 109 ++++++++++++++++++ htdocs/langs/en_US/accountancy.lang | 1 + 2 files changed, 110 insertions(+) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index f15a2a0c704..b9c4cc9c8ff 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -60,6 +60,7 @@ class AccountancyExport public static $EXPORT_TYPE_GESTINUMV3 = 130; public static $EXPORT_TYPE_GESTINUMV5 = 135; public static $EXPORT_TYPE_FEC = 1000; + public static $EXPORT_TYPE_FEC2 = 1010; /** @@ -121,6 +122,7 @@ class AccountancyExport self::$EXPORT_TYPE_GESTINUMV3 => $langs->trans('Modelcsv_Gestinum_v3'), self::$EXPORT_TYPE_GESTINUMV5 => $langs->trans('Modelcsv_Gestinum_v5'), self::$EXPORT_TYPE_FEC => $langs->trans('Modelcsv_FEC'), + self::$EXPORT_TYPE_FEC2 => $langs->trans('Modelcsv_FEC2'), ); ksort($listofexporttypes, SORT_NUMERIC); @@ -155,6 +157,7 @@ class AccountancyExport self::$EXPORT_TYPE_GESTINUMV3 => 'gestinumv3', self::$EXPORT_TYPE_GESTINUMV5 => 'gestinumv5', self::$EXPORT_TYPE_FEC => 'fec', + self::$EXPORT_TYPE_FEC2 => 'fec2', ); return $formatcode[$type]; @@ -234,6 +237,10 @@ class AccountancyExport 'label' => $langs->trans('Modelcsv_FEC'), 'ACCOUNTING_EXPORT_FORMAT' => 'txt', ), + self::$EXPORT_TYPE_FEC2 => array( + 'label' => $langs->trans('Modelcsv_FEC2'), + 'ACCOUNTING_EXPORT_FORMAT' => 'txt', + ), ), 'cr'=> array( '1' => $langs->trans("Unix"), @@ -322,6 +329,9 @@ class AccountancyExport case self::$EXPORT_TYPE_FEC : $this->exportFEC($TData); break; + case self::$EXPORT_TYPE_FEC2 : + $this->exportFEC2($TData); + break; default: $this->errors[] = $langs->trans('accountancy_error_modelnotfound'); break; @@ -891,6 +901,105 @@ class AccountancyExport } } + /** + * Export format : FEC2 + * + * @param array $objectLines data + * @return void + */ + public function exportFEC2($objectLines) + { + $separator = "\t"; + $end_line = "\r\n"; + + print "JournalCode".$separator; + print "JournalLib".$separator; + print "EcritureNum".$separator; + print "EcritureDate".$separator; + print "CompteNum".$separator; + print "CompteLib".$separator; + print "CompAuxNum".$separator; + print "CompAuxLib".$separator; + print "PieceRef".$separator; + print "PieceDate".$separator; + print "EcritureLib".$separator; + print "Debit".$separator; + print "Credit".$separator; + print "EcritureLet".$separator; + print "DateLet".$separator; + print "ValidDate".$separator; + print "Montantdevise".$separator; + print "Idevise"; + print $end_line; + + foreach ($objectLines as $line) { + if ($line->debit == 0 && $line->credit == 0) { + unset($array[$line]); + } else { + $date_creation = dol_print_date($line->date_creation, '%Y%m%d'); + $date_document = dol_print_date($line->doc_date, '%Y%m%d'); + $date_lettering = dol_print_date($line->date_lettering, '%Y%m%d'); + $date_validation = dol_print_date($line->date_validated, '%Y%m%d'); + + // FEC:JournalCode + print $line->code_journal . $separator; + + // FEC:JournalLib + print $line->journal_label . $separator; + + // FEC:EcritureNum + print $line->piece_num . $separator; + + // FEC:EcritureDate + print $date_creation . $separator; + + // FEC:CompteNum + print $line->numero_compte . $separator; + + // FEC:CompteLib + print dol_string_unaccent($line->label_compte) . $separator; + + // FEC:CompAuxNum + print $line->subledger_account . $separator; + + // FEC:CompAuxLib + print dol_string_unaccent($line->subledger_label) . $separator; + + // FEC:PieceRef + print $line->doc_ref . $separator; + + // FEC:PieceDate + print $date_document . $separator; + + // FEC:EcritureLib + print dol_string_unaccent($line->label_operation) . $separator; + + // FEC:Debit + print price2fec($line->debit) . $separator; + + // FEC:Credit + print price2fec($line->credit) . $separator; + + // FEC:EcritureLet + print $line->lettering_code . $separator; + + // FEC:DateLet + print $date_lettering . $separator; + + // FEC:ValidDate + print $date_validation . $separator; + + // FEC:Montantdevise + print $line->multicurrency_amount . $separator; + + // FEC:Idevise + print $line->multicurrency_code; + + print $end_line; + } + } + } + /** * Export format : SAGE50SWISS * diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 2a53a171962..83d20f59581 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -340,6 +340,7 @@ Modelcsv_LDCompta10=Export for LD Compta (v10 & higher) Modelcsv_openconcerto=Export for OpenConcerto (Test) Modelcsv_configurable=Export CSV Configurable Modelcsv_FEC=Export FEC +Modelcsv_FEC2=Export FEC (With dates generation writing / document reversed) Modelcsv_Sage50_Swiss=Export for Sage 50 Switzerland Modelcsv_winfic=Export Winfic - eWinfic - WinSis Compta Modelcsv_Gestinumv3=Export for Gestinum (v3) From b01a9d6cc307911886869ba8a4aeffee205d4b48 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 16 Dec 2020 05:32:36 +0100 Subject: [PATCH 055/392] FIX: Accountancy - Reconciled options not working on ledger et subaccount ledger --- .../accountancy/bookkeeping/listbyaccount.php | 26 +++++++++++++---- .../bookkeeping/listbysubaccount.php | 28 ++++++++++++++----- .../accountancy/class/bookkeeping.class.php | 4 +++ 3 files changed, 45 insertions(+), 13 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 7b8467f60bd..52bedeb73f2 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -543,8 +543,15 @@ while ($i < min($num, $limit)) // Is it a break ? if ($accountg != $displayed_account_number || !isset($displayed_account_number)) { - $colspan = $totalarray['nbfield'] - 3; - $colspanend = $totalarray['nbfield'] - 7; + if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) { + $colnumber = 3; + $colnumberend = 7; + } else { + $colnumber = 4; + $colnumberend = 7; + } + $colspan = $totalarray['nbfield'] - $colnumber; + $colspanend = $totalarray['nbfield'] - $colnumberend; // Show a subtotal by accounting account if (isset($displayed_account_number)) { print '
'; @@ -665,11 +672,11 @@ while ($i < min($num, $limit)) // Other type } - print '"; $texte .= '
'; - $entry .= ''.$categstatic->getNomUrl(1, '', 60).''; + $entry .= ''.$li.''; $entry .= ''.$counter.''; - $entry .= ''.img_view().''; + $entry .= ''.img_view().''; + $entry .= ''; + $entry .= ''.img_edit().''; + $entry .= ''; + $entry .= ''.img_delete().''; $entry .= '
trans("LanguageFile"); ?>
textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc"), 1, 'help', '', 0, 2, 'tooltipcompute'); ?>
textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc"), 1, 'help', '', 0, 2, 'tooltipcompute'); ?>
textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc")).$form->textwithpicto($langs->trans("Computedpersistent"), $langs->trans("ComputedpersistentDesc"), 1, 'warning'); ?>
textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc")).$form->textwithpicto($langs->trans("Computedpersistent"), $langs->trans("ComputedpersistentDesc"), 1, 'warning'); ?>
trans("DefaultValue").' ('.$langs->trans("Database").')'; ?>
trans("LanguageFile"); ?>
textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc"), 1, 'help', '', 0, 2, 'tooltipcompute'); ?>
textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc"), 1, 'help', '', 0, 2, 'tooltipcompute'); ?>
textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc")).$form->textwithpicto($langs->trans("Computedpersistent"), $langs->trans("ComputedpersistentDesc"), 1, 'warning'); ?>
textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc")).$form->textwithpicto($langs->trans("Computedpersistent"), $langs->trans("ComputedpersistentDesc"), 1, 'warning'); ?>
trans("DefaultValue").' ('.$langs->trans("Database").')'; ?>
'; + print ''; print ''; // Picto + Ref - print ''; print ''; print ''; diff --git a/htdocs/accountancy/bookkeeping/listbysubaccount.php b/htdocs/accountancy/bookkeeping/listbysubaccount.php index 48c449df43e..2bdf5e11d09 100644 --- a/htdocs/accountancy/bookkeeping/listbysubaccount.php +++ b/htdocs/accountancy/bookkeeping/listbysubaccount.php @@ -410,7 +410,7 @@ if (empty($reshook)) { if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); -print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit); +print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); print info_admin($langs->trans("WarningRecordWithoutSubledgerAreExcluded")); @@ -546,8 +546,15 @@ while ($i < min($num, $limit)) // Is it a break ? if ($accountg != $displayed_account_number || !isset($displayed_account_number)) { - $colspan = $totalarray['nbfield'] - 3; - $colspanend = $totalarray['nbfield'] - 7; + if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) { + $colnumber = 3; + $colnumberend = 7; + } else { + $colnumber = 4; + $colnumberend = 7; + } + $colspan = $totalarray['nbfield'] - $colnumber; + $colspanend = $totalarray['nbfield'] - $colnumberend; // Show a subtotal by accounting account if (isset($displayed_account_number)) { print ''; @@ -676,11 +683,11 @@ while ($i < min($num, $limit)) // Other type } - print '
'; + print ''; if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') { @@ -744,8 +751,15 @@ while ($i < min($num, $limit)) } // Show sub-total of last shown account -$colspan = $totalarray['nbfield'] - 3; -$colspanend = $totalarray['nbfield'] - 8; +if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) { + $colnumber = 3; + $colnumberend = 7; +} else { + $colnumber = 4; + $colnumberend = 7; +} +$colspan = $totalarray['nbfield'] - $colnumber; +$colspanend = $totalarray['nbfield'] - $colnumberend; print '
'.$langs->trans("TotalForAccount").' '.$accountg.':'.price($sous_total_debit).'
'; + print ''; print ''; // Picto + Ref - print ''; print ''; print ''; diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 8312b155b8b..72428762459 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -825,6 +825,10 @@ class BookKeeping extends CommonObject $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; } elseif ($key == 't.credit' || $key == 't.debit') { $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); } From c5ee976c7ea63ec1c7ea7b430fba788187eac600 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 16 Dec 2020 06:38:17 +0100 Subject: [PATCH 056/392] 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 02a15e03f7f3501bc3cc48786b95f8874a86ddf3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Dec 2020 10:37:34 +0100 Subject: [PATCH 057/392] Fix phpunit --- test/phpunit/RestAPIDocumentTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/phpunit/RestAPIDocumentTest.php b/test/phpunit/RestAPIDocumentTest.php index f45e0437ce5..e38f1fbae12 100644 --- a/test/phpunit/RestAPIDocumentTest.php +++ b/test/phpunit/RestAPIDocumentTest.php @@ -173,7 +173,7 @@ class RestAPIDocumentTest extends PHPUnit\Framework\TestCase ); $param = ''; - foreach($data as $key => $val) { + foreach ($data as $key => $val) { $param .= '&'.$key.'='.urlencode($val); } @@ -203,7 +203,7 @@ class RestAPIDocumentTest extends PHPUnit\Framework\TestCase ); $param = ''; - foreach($data as $key => $val) { + foreach ($data as $key => $val) { $param .= '&'.$key.'='.urlencode($val); } @@ -231,7 +231,7 @@ class RestAPIDocumentTest extends PHPUnit\Framework\TestCase ); $param = ''; - foreach($data as $key => $val) { + foreach ($data as $key => $val) { $param .= '&'.$key.'='.urlencode($val); } From 1b69b1c2fed2a347794a3ae0781dfead7cbb2ffa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Dec 2020 10:39:10 +0100 Subject: [PATCH 058/392] Fix phpcs --- htdocs/commande/class/commande.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 00cba2055f7..4ededdeacaf 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -624,7 +624,7 @@ class Commande extends CommonOrder } // If stock is decremented on validate order, we must reincrement it - if (!empty($conf->stock->enabled) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1) + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1) { $result = 0; @@ -810,7 +810,7 @@ class Commande extends CommonOrder if ($this->db->query($sql)) { // If stock is decremented on validate order, we must reincrement it - if (!empty($conf->stock->enabled) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1) + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1) { require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; $langs->load("agenda"); From cb2c1f3ecef1537f40617b4c2796b2a5a7c5f923 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Wed, 16 Dec 2020 10:54:32 +0100 Subject: [PATCH 059/392] FIX Facture Situation Out : status condition --- htdocs/compta/facture/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index fb5f7a6ac98..aa07de4867e 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2534,7 +2534,7 @@ if (empty($reshook)) { $object->fetch($id, '', '', '', true); - if ($object->statut == Facture::STATUS_VALIDATED + if (in_array($object->statut, array(Facture::STATUS_CLOSED, Facture::STATUS_VALIDATED)) && $object->type == Facture::TYPE_SITUATION && $usercancreate && !$objectidnext @@ -3872,7 +3872,7 @@ elseif ($id > 0 || !empty($ref)) $label = $langs->trans("ConfirmOuting"); $formquestion = array(); // remove situation from cycle - if ($object->statut == Facture::STATUS_VALIDATED + if (in_array($object->statut, array(Facture::STATUS_CLOSED, Facture::STATUS_VALIDATED)) && $usercancreate && !$objectidnext && $object->is_last_in_cycle() @@ -5387,7 +5387,7 @@ elseif ($id > 0 || !empty($ref)) } // Remove situation from cycle - if ($object->statut > Facture::STATUS_DRAFT + if (in_array($object->statut, array(Facture::STATUS_CLOSED, Facture::STATUS_VALIDATED)) && $object->type == Facture::TYPE_SITUATION && $usercancreate && !$objectidnext From bf01ad8790237fb28c39c12e6798b3c3567eaeb7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Dec 2020 10:55:33 +0100 Subject: [PATCH 060/392] Fix warning --- htdocs/compta/facture/class/facture.class.php | 6 +++--- htdocs/fourn/class/fournisseur.facture.class.php | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 5f7bf4fcf77..ec55810e2da 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -868,7 +868,7 @@ class Facture extends CommonInvoice $line->situation_percent, $line->fk_prev_id, $line->fk_unit, - $line->pu_ht_devise, + $line->multicurrency_subprice, $line->ref_ext ); if ($result < 0) @@ -968,7 +968,7 @@ class Facture extends CommonInvoice $_facrec->lines[$i]->situation_percent, '', $_facrec->lines[$i]->fk_unit, - $_facrec->lines[$i]->pu_ht_devise + $_facrec->lines[$i]->multicurrency_subprice ); if ($result_insert < 0) @@ -2971,7 +2971,7 @@ class Facture extends CommonInvoice * @param int $situation_percent Situation advance percentage * @param int $fk_prev_id Previous situation line id reference * @param string $fk_unit Code of the unit to use. Null to use the default one - * @param double $pu_ht_devise Unit price in currency + * @param double $pu_ht_devise Unit price in foreign currency * @param string $ref_ext External reference of the line * @return int <0 if KO, Id of line if OK */ diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index e3b65d8a8de..43075ba6760 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -398,7 +398,7 @@ class FactureFournisseur extends CommonInvoice $sql .= ", '".$this->db->escape($this->ref_supplier)."'"; $sql .= ", ".$conf->entity; $sql .= ", '".$this->db->escape($this->type)."'"; - $sql .= ", '".$this->db->escape($this->label ? $this->label : $this->libelle)."'"; + $sql .= ", '".$this->db->escape(isset($this->label) ? $this->label : (isset($this->libelle) ? $this->libelle : ''))."'"; $sql .= ", ".$this->socid; $sql .= ", '".$this->db->idate($now)."'"; $sql .= ", '".$this->db->idate($this->date)."'"; @@ -497,7 +497,7 @@ class FactureFournisseur extends CommonInvoice $this->lines[$i]->date_end, $this->lines[$i]->array_options, $this->lines[$i]->fk_unit, - $this->lines[$i]->pu_ht_devise + $this->lines[$i]->multicurrency_subprice ); } else { $this->error = $this->db->lasterror(); @@ -2467,7 +2467,7 @@ class FactureFournisseur extends CommonInvoice $xnbp = 0; while ($xnbp < $nbp) { - $line = new FactureLigne($this->db); + $line = new SupplierInvoiceLine($this->db); $line->desc = $langs->trans("Description")." ".$xnbp; $line->qty = 1; $line->subprice = 100; @@ -2807,8 +2807,7 @@ class SupplierInvoiceLine extends CommonObjectLine public $fk_facture_fourn; /** - * Product label - * This field may contains label of product (when invoice create from order) + * This field may contains label of line (when invoice create from order) * @var string */ public $label; @@ -2961,6 +2960,7 @@ class SupplierInvoiceLine extends CommonObjectLine public $multicurrency_total_tva; public $multicurrency_total_ttc; + /** * Constructor * From 2c7d8723202d988cd984d019525f950ea513fed4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Dec 2020 11:07:34 +0100 Subject: [PATCH 061/392] Fix warning --- htdocs/compta/facture/class/facture-rec.class.php | 10 +++++----- htdocs/core/lib/functions.lib.php | 2 +- htdocs/fourn/class/fournisseur.facture.class.php | 14 ++++++++------ 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 48e2ad574ed..c9157f7b43d 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -215,7 +215,7 @@ class FactureRec extends CommonInvoice $now = dol_now(); // Clean parameters - $this->titre = trim($this->titre); // deprecated + $this->titre = trim(isset($this->titre) ? $this->titre : $this->title); // deprecated $this->title = trim($this->title); $this->usenewprice = empty($this->usenewprice) ? 0 : $this->usenewprice; if (empty($this->suspended)) $this->suspended = 0; @@ -366,7 +366,7 @@ class FactureRec extends CommonInvoice } // Add object linked - if (!$error && $this->id && is_array($this->linked_objects) && !empty($this->linked_objects)) + if (!$error && $this->id && !empty($this->linked_objects) && is_array($this->linked_objects)) { foreach ($this->linked_objects as $origin => $tmp_origin_id) { @@ -702,7 +702,7 @@ class FactureRec extends CommonInvoice $line->total_ht = $objp->total_ht; $line->total_tva = $objp->total_tva; $line->total_ttc = $objp->total_ttc; - $line->code_ventilation = $objp->fk_code_ventilation; + //$line->code_ventilation = $objp->fk_code_ventilation; $line->fk_fournprice = $objp->fk_fournprice; $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); $line->pa_ht = $marginInfos[0]; @@ -1996,7 +1996,7 @@ class FactureLigneRec extends CommonInvoiceLine $this->localtax1_type = $objp->localtax1_type; $this->localtax2_type = $objp->localtax2_type; $this->remise_percent = $objp->remise_percent; - $this->fk_remise_except = $objp->fk_remise_except; + //$this->fk_remise_except = $objp->fk_remise_except; $this->fk_product = $objp->fk_product; $this->date_start_fill = $objp->date_start_fill; $this->date_end_fill = $objp->date_end_fill; @@ -2004,7 +2004,7 @@ class FactureLigneRec extends CommonInvoiceLine $this->total_ht = $objp->total_ht; $this->total_tva = $objp->total_tva; $this->total_ttc = $objp->total_ttc; - $this->code_ventilation = $objp->fk_code_ventilation; + //$this->code_ventilation = $objp->fk_code_ventilation; $this->rang = $objp->rang; $this->special_code = $objp->special_code; $this->fk_unit = $objp->fk_unit; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 4fd44ee6ba3..998cddea0f9 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5191,7 +5191,7 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi $sql .= ", ".MAIN_DB_PREFIX."c_country as c"; if ($mysoc->country_code == 'ES') $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($buyer->country_code)."'"; // local tax in spain use the buyer country ?? - else $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($seller->country_code)."'"; + else $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape(empty($seller->country_code) ? $mysoc->country_code : $seller->country_code)."'"; $sql .= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1"; if ($vatratecode) $sql .= " AND t.code = '".$db->escape($vatratecode)."'"; } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 43075ba6760..40ffb9024c5 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1856,6 +1856,7 @@ class FactureFournisseur extends CommonInvoice public function updateline($id, $desc, $pu, $vatrate, $txlocaltax1 = 0, $txlocaltax2 = 0, $qty = 1, $idproduct = 0, $price_base_type = 'HT', $info_bits = 0, $type = 0, $remise_percent = 0, $notrigger = false, $date_start = '', $date_end = '', $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $ref_supplier = '') { global $mysoc, $langs; + dol_syslog(get_class($this)."::updateline $id,$desc,$pu,$vatrate,$qty,$idproduct,$price_base_type,$info_bits,$type,$remise_percent,$notrigger,$date_start,$date_end,$fk_unit,$pu_ht_devise,$ref_supplier", LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -2809,6 +2810,7 @@ class SupplierInvoiceLine extends CommonObjectLine /** * This field may contains label of line (when invoice create from order) * @var string + * @deprecated */ public $label; @@ -3010,17 +3012,17 @@ class SupplierInvoiceLine extends CommonObjectLine $this->date_end = $obj->date_end; $this->product_ref = $obj->product_ref; $this->ref_supplier = $obj->ref_supplier; - $this->libelle = $obj->label; - $this->label = $obj->label; $this->product_desc = $obj->product_desc; - $this->subprice = $obj->pu_ht; - $this->pu_ht = $obj->pu_ht; + + $this->subprice = $obj->pu_ht; + $this->pu_ht = $obj->pu_ht; $this->pu_ttc = $obj->pu_ttc; $this->tva_tx = $obj->tva_tx; $this->localtax1_tx = $obj->localtax1_tx; $this->localtax2_tx = $obj->localtax2_tx; - $this->localtax1_type = $obj->localtax1_type; - $this->localtax2_type = $obj->localtax2_type; + $this->localtax1_type = $obj->localtax1_type; + $this->localtax2_type = $obj->localtax2_type; + $this->qty = $obj->qty; $this->remise_percent = $obj->remise_percent; $this->tva = $obj->total_tva; // deprecated From c6f83aaed72a25228047b9f2afb452ac3f86d8ad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Dec 2020 11:21:48 +0100 Subject: [PATCH 062/392] Fix warning --- htdocs/compta/bank/class/account.class.php | 36 ++++++++++++++-------- test/phpunit/BankAccountTest.php | 4 ++- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index e93491ceee4..b2d499c5f34 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1741,13 +1741,6 @@ class AccountLine extends CommonObject public $amount; - /** - * @var string bank transaction lines label - */ - public $label; - - public $note; - /** * @var int ID */ @@ -1763,11 +1756,6 @@ class AccountLine extends CommonObject */ public $fk_type; - public $rappro; // Is it conciliated - public $num_releve; // If conciliated, what is bank statement - public $num_chq; // Num of cheque - public $bank_chq; // Bank of cheque - /** * @var int ID of cheque receipt */ @@ -1778,16 +1766,40 @@ class AccountLine extends CommonObject */ public $fk_account; + /** + * @var string Ref of bank account + */ + public $bank_account_ref; + /** * @var string Label of bank account */ public $bank_account_label; + /** + * @var string Bank account numero + */ + public $numero_compte; + /** * @var string Name of check issuer */ public $emetteur; + public $rappro; // Is it conciliated + public $num_releve; // If conciliated, what is bank statement + public $num_chq; // Num of cheque + public $bank_chq; // Bank of cheque + + /** + * @var string bank transaction lines label + */ + public $label; + + public $note; + + + /** * Constructor * diff --git a/test/phpunit/BankAccountTest.php b/test/phpunit/BankAccountTest.php index 1007db02dad..fd92d242b31 100644 --- a/test/phpunit/BankAccountTest.php +++ b/test/phpunit/BankAccountTest.php @@ -200,8 +200,10 @@ class BankAccountTest extends PHPUnit\Framework\TestCase */ $localobject->info($localobject->id); + + $result = $localobject->needIBAN(); //print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n"; - //$this->assertNotEquals($localobject->date_creation, ''); + $this->assertEquals(1, $result); return $localobject->id; } From 5facd49a6c2ee4370783cffc8f37c10c25b71b61 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Dec 2020 11:33:31 +0100 Subject: [PATCH 063/392] Fix warnings --- htdocs/compta/sociales/class/chargesociales.class.php | 6 +++--- htdocs/product/stock/class/entrepot.class.php | 3 +-- test/phpunit/EntrepotTest.php | 3 ++- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 2ea2497efbb..ffb2d04e155 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -512,13 +512,13 @@ class ChargeSociales extends CommonObject * Return a link to the object card (with optionaly the picto) * * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param int $maxlen Max length of label + * @param string $option On what the link point to ('nolink', ...) * @param int $notooltip 1=Disable tooltip * @param int $short 1=Return just URL * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with link */ - public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0, $short = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $short = 0, $save_lastsearch_value = -1) { global $langs, $conf, $user, $form; @@ -569,7 +569,7 @@ class ChargeSociales extends CommonObject $result .= $linkstart; if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref); + if ($withpicto != 2) $result .= $this->ref; $result .= $linkend; return $result; diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 14e25bad513..d7a52cd1910 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -166,8 +166,7 @@ class Entrepot extends CommonObject $this->db = $db; $this->statuts[self::STATUS_CLOSED] = 'Closed2'; - if ($conf->global->ENTREPOT_EXTRA_STATUS) - { + if (!empty($conf->global->ENTREPOT_EXTRA_STATUS)) { $this->statuts[self::STATUS_OPEN_ALL] = 'OpenAll'; $this->statuts[self::STATUS_OPEN_INTERNAL] = 'OpenInternal'; } else { diff --git a/test/phpunit/EntrepotTest.php b/test/phpunit/EntrepotTest.php index 27fd3dabbf3..8cad99243cc 100644 --- a/test/phpunit/EntrepotTest.php +++ b/test/phpunit/EntrepotTest.php @@ -219,7 +219,8 @@ class EntrepotTest extends PHPUnit\Framework\TestCase $langs=$this->savlangs; $db=$this->savdb; - //$this->assertLessThan(1, 0); + $result = $localobject->get_full_arbo(); + $this->assertEquals('WAREHOUSE SPECIMEN', $result); return $localobject->id; } From 371a4609055ef3661620ebba9ef69d6ecf9e8012 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Dec 2020 12:26:01 +0100 Subject: [PATCH 064/392] More PHPUnit for movements --- htdocs/product/class/product.class.php | 2 +- htdocs/product/class/productbatch.class.php | 9 ++- .../stock/class/mouvementstock.class.php | 43 +++++++------- test/phpunit/MouvementStockTest.php | 56 ++++++++++++++----- 4 files changed, 70 insertions(+), 40 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index e1b25b9e3b7..a6d676a0f7b 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4893,7 +4893,7 @@ class Product extends CommonObject $sql .= " WHERE w.entity IN (".getEntity('stock').")"; $sql .= " AND w.rowid = ps.fk_entrepot"; $sql .= " AND ps.fk_product = ".$this->id; - if ($conf->global->ENTREPOT_EXTRA_STATUS && count($warehouseStatus)) { + if (!empty($conf->global->ENTREPOT_EXTRA_STATUS) && count($warehouseStatus)) { $sql .= " AND w.statut IN (".$this->db->sanitize($this->db->escape(implode(',', $warehouseStatus))).")"; } diff --git a/htdocs/product/class/productbatch.class.php b/htdocs/product/class/productbatch.class.php index f5a91ff2839..a97437f6a45 100644 --- a/htdocs/product/class/productbatch.class.php +++ b/htdocs/product/class/productbatch.class.php @@ -89,19 +89,18 @@ class Productbatch extends CommonObject // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_batch ("; $sql .= "fk_product_stock,"; - $sql .= "sellby,"; - $sql .= "eatby,"; + $sql .= "sellby,"; // no more used + $sql .= "eatby,"; // no more used $sql .= "batch,"; $sql .= "qty,"; $sql .= "import_key"; $sql .= ") VALUES ("; $sql .= " ".(!isset($this->fk_product_stock) ? 'NULL' : $this->fk_product_stock).","; - $sql .= " ".(!isset($this->sellby) || dol_strlen($this->sellby) == 0 ? 'NULL' : "'".$this->db->idate($this->sellby)."'").","; - $sql .= " ".(!isset($this->eatby) || dol_strlen($this->eatby) == 0 ? 'NULL' : "'".$this->db->idate($this->eatby)."'").","; + $sql .= " ".(!isset($this->sellby) || dol_strlen($this->sellby) == 0 ? 'NULL' : "'".$this->db->idate($this->sellby)."'").","; // no more used + $sql .= " ".(!isset($this->eatby) || dol_strlen($this->eatby) == 0 ? 'NULL' : "'".$this->db->idate($this->eatby)."'").","; // no more used $sql .= " ".(!isset($this->batch) ? 'NULL' : "'".$this->db->escape($this->batch)."'").","; $sql .= " ".(!isset($this->qty) ? 'NULL' : $this->qty).","; $sql .= " ".(!isset($this->import_key) ? 'NULL' : "'".$this->db->escape($this->import_key)."'").""; - $sql .= ")"; $this->db->begin(); diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 631cedd0a25..a23846c3e08 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -140,8 +140,8 @@ class MouvementStock extends CommonObject * @param string $label Label of stock movement * @param string $inventorycode Inventory code * @param string $datem Force date of movement - * @param integer $eatby eat-by date. Will be used if lot does not exists yet and will be created. - * @param integer $sellby sell-by date. Will be used if lot does not exists yet and will be created. + * @param integer|string $eatby eat-by date. Will be used if lot does not exists yet and will be created. + * @param integer|string $sellby sell-by date. Will be used if lot does not exists yet and will be created. * @param string $batch batch number * @param boolean $skip_batch If set to true, stock movement is done without impacting batch record * @param int $id_product_batch Id product_batch (when skip_batch is false and we already know which record of product_batch to use) @@ -166,13 +166,14 @@ class MouvementStock extends CommonObject // Check parameters if (empty($fk_product)) return 0; - if ($eatby < 0) - { + + if (is_numeric($eatby) && $eatby < 0) { + dol_syslog(get_class($this)."::_create start ErrorBadValueForParameterEatBy eatby = ".$eatby); $this->errors[] = 'ErrorBadValueForParameterEatBy'; return -1; } - if ($sellby < 0) - { + if (is_numeric($sellby) && $sellby < 0) { + dol_syslog(get_class($this)."::_create start ErrorBadValueForParameterSellBy sellby = ".$sellby); $this->errors[] = 'ErrorBadValueForParameterSellBy'; return -1; } @@ -786,19 +787,19 @@ class MouvementStock extends CommonObject /** * Increase stock for product and subproducts * - * @param User $user Object user - * @param int $fk_product Id product - * @param int $entrepot_id Warehouse id - * @param int $qty Quantity - * @param int $price Price - * @param string $label Label of stock movement - * @param integer $eatby eat-by date - * @param integer $sellby sell-by date - * @param string $batch batch number - * @param string $datem Force date of movement - * @param int $id_product_batch Id product_batch - * @param string $inventorycode Inventory code - * @return int <0 if KO, >0 if OK + * @param User $user Object user + * @param int $fk_product Id product + * @param int $entrepot_id Warehouse id + * @param int $qty Quantity + * @param int $price Price + * @param string $label Label of stock movement + * @param integer|string $eatby eat-by date + * @param integer|string $sellby sell-by date + * @param string $batch batch number + * @param string $datem Force date of movement + * @param int $id_product_batch Id product_batch + * @param string $inventorycode Inventory code + * @return int <0 if KO, >0 if OK */ public function reception($user, $fk_product, $entrepot_id, $qty, $price = 0, $label = '', $eatby = '', $sellby = '', $batch = '', $datem = '', $id_product_batch = 0, $inventorycode = '') { @@ -918,8 +919,8 @@ class MouvementStock extends CommonObject } else { // product_batch record not found $pdluo->fk_product_stock = $vfk_product_stock; $pdluo->qty = $qty; - $pdluo->eatby = $veatby; - $pdluo->sellby = $vsellby; + $pdluo->eatby = empty($dluo['eatby']) ? '' : $dluo['eatby']; // No more used. Now eatby date is store in table of lot, no more into prouct_batch table. + $pdluo->sellby = empty($dluo['sellby']) ? '' : $dluo['sellby']; // No more used. Now sellby date is store in table of lot, no more into prouct_batch table. $pdluo->batch = $vbatchnumber; $result = $pdluo->create($user, 1); diff --git a/test/phpunit/MouvementStockTest.php b/test/phpunit/MouvementStockTest.php index 23b6b2b0111..4570db5a1d5 100644 --- a/test/phpunit/MouvementStockTest.php +++ b/test/phpunit/MouvementStockTest.php @@ -130,7 +130,7 @@ class MouvementStockTest extends PHPUnit\Framework\TestCase /** * testMouvementCreate * - * @return int + * @return MouvementStock */ public function testMouvementCreate() { @@ -141,6 +141,13 @@ class MouvementStockTest extends PHPUnit\Framework\TestCase $db=$this->savdb; // We create a product for tests + $product0=new Product($db); + $product0->initAsSpecimen(); + $product0->ref.=' 0'; + $product0->label.=' 0'; + $product0->status_batch = 1; + $product0id=$product0->create($user); + $product1=new Product($db); $product1->initAsSpecimen(); $product1->ref.=' 1'; @@ -154,6 +161,13 @@ class MouvementStockTest extends PHPUnit\Framework\TestCase $product2id=$product2->create($user); // We create a product for tests + $warehouse0=new Entrepot($db); + $warehouse0->initAsSpecimen(); + $warehouse0->label.=' 0'; + $warehouse0->description.=' 0'; + $warehouse0->statut = 0; + $warehouse0id=$warehouse0->create($user); + $warehouse1=new Entrepot($db); $warehouse1->initAsSpecimen(); $warehouse1->label.=' 1'; @@ -168,32 +182,49 @@ class MouvementStockTest extends PHPUnit\Framework\TestCase $localobject=new MouvementStock($this->savdb); + $datetest1 = dol_mktime(0, 0, 0, 1, 1, 2000); + $datetest2 = dol_mktime(0, 0, 0, 1, 2, 2000); + + // Create an input movement movement (type = 3) with value for eatby date and a lot + $result=$localobject->reception($user, $product0id, $warehouse0id, 5, 999, 'Movement for unit test with batch', $datetest1, $datetest1, 'anotyetuselotnumberA', '', 0, 'Inventory Code Test with batch'); + print __METHOD__." result=".$result."\n"; + $this->assertGreaterThan(0, $result, 'Failed to create a movement with a lot number of product with status_batch=1'); + + $result=$localobject->reception($user, $product0id, $warehouse0id, 5, 999, 'Movement for unit test with batch', $datetest1, $datetest1, 'anotyetuselotnumberB', '', 0, 'Inventory Code Test with batch'); + print __METHOD__." result=".$result."\n"; + $this->assertGreaterThan(0, $result, 'Test to check we can create a movement a eatby dare different when lot number is different'); + + // Create same input movement movement (type = 3) with same lot but a different value of eatby date + $result=$localobject->reception($user, $product0id, $warehouse0id, 5, 999, 'Movement for unit test with batch', $datetest2, $datetest1, 'anotyetuselotnumberA', '', 0, 'Inventory Code Test with batch'); + print __METHOD__." result=".$result."\n"; + $this->assertEquals(-3, $result, 'Test to check we can t create a movement for a lot with a different eatby date'); + // Do a list of movement into warehouse 1 // Create an input movement (type = 3) of price 9.9 -> should update PMP to 9.9 $result=$localobject->reception($user, $product1id, $warehouse1id, 10, 9.9, 'Movement for unit test 1', '', '', '', '', 0, 'Inventory Code Test'); print __METHOD__." result=".$result."\n"; - $this->assertLessThan($result, 0); + $this->assertGreaterThan(0, $result, 'Return code of 0 was expected for the reception test 1'); // Create an input movement (type = 3) of price 9.7 -> should update PMP to 9.9/9.7 = 9.8 $result=$localobject->reception($user, $product1id, $warehouse1id, 10, 9.7, 'Movement for unit test 2', '', '', '', '', 0, 'Inventory Code Test'); print __METHOD__." result=".$result."\n"; - $this->assertLessThan($result, 0); + $this->assertGreaterThan(0, $result); // Create an output movement (type = 2) of price 9.7 -> should update PMP to 9.9/9.7 = 9.8 $result=$localobject->livraison($user, $product1id, $warehouse1id, 5, 999, 'Movement for unit test 3', '', '', '', '', 0, 'Inventory Code Test'); print __METHOD__." result=".$result."\n"; - $this->assertLessThan($result, 0); + $this->assertGreaterThan(0, $result); // Create an output movement (type = 1) of price 9.7 -> should update PMP to 9.9/9.7 = 9.8 $result=$localobject->_create($user, $product1id, $warehouse1id, 1, 0, 0, 'Input from transfer', 'Transfert X'); print __METHOD__." result=".$result."\n"; - $this->assertLessThan($result, 0); + $this->assertGreaterThan(0, $result); // Create an output movement (type = 1) of price 9.7 -> should update PMP to 9.9/9.7 = 9.8 $result=$localobject->_create($user, $product1id, $warehouse1id, -2, 1, 0, 'Output from transfer', 'Transfert Y'); print __METHOD__." result=".$result."\n"; - $this->assertLessThan($result, 0); + $this->assertGreaterThan(0, $result); // Do same but into warehouse 2 @@ -201,28 +232,27 @@ class MouvementStockTest extends PHPUnit\Framework\TestCase // Create an input movement (type = 3) of price 9.9 -> should update PMP to 9.9 $result=$localobject->reception($user, $product1id, $warehouse2id, 10, 9.9, 'Movement for unit test 1 wh 2', '', '', '', '', 0, 'Inventory Code Test 2'); print __METHOD__." result=".$result."\n"; - $this->assertLessThan($result, 0); + $this->assertGreaterThan(0, $result); // Create an input movement (type = 3) of price 9.7 -> should update PMP to 9.9/9.7 = 9.8 $result=$localobject->reception($user, $product1id, $warehouse2id, 10, 9.7, 'Movement for unit test 2 wh 2', '', '', '', '', 0, 'Inventory Code Test 2'); print __METHOD__." result=".$result."\n"; - $this->assertLessThan($result, 0); + $this->assertGreaterThan(0, $result); // Create an output movement (type = 2) of price 9.7 -> should update PMP to 9.9/9.7 = 9.8 $result=$localobject->livraison($user, $product1id, $warehouse2id, 5, 999, 'Movement for unit test 3 wh 2', '', '', '', '', 0, 'Inventory Code Test 2'); print __METHOD__." result=".$result."\n"; - $this->assertLessThan($result, 0); + $this->assertGreaterThan(0, $result); // Create an output movement (type = 1) of price 9.7 -> should update PMP to 9.9/9.7 = 9.8 $result=$localobject->_create($user, $product1id, $warehouse2id, 1, 0, 0, 'Input from transfer wh 2', 'Transfert X 2'); print __METHOD__." result=".$result."\n"; - $this->assertLessThan($result, 0); + $this->assertGreaterThan(0, $result); // Create an output movement (type = 1) of price 9.7 -> should update PMP to 9.9/9.7 = 9.8 $result=$localobject->_create($user, $product1id, $warehouse2id, -2, 1, 0, 'Output from transfer wh 2', 'Transfert Y 2'); print __METHOD__." result=".$result."\n"; - $this->assertLessThan($result, 0); - + $this->assertGreaterThan(0, $result); return $localobject; } @@ -231,7 +261,7 @@ class MouvementStockTest extends PHPUnit\Framework\TestCase * testMouvementCheck * * @param MouvementStock $localobject Movement object we created - * @return int + * @return MouvementStock * * @depends testMouvementCreate * The depends says test is run only if previous is ok From d781d78c4e960cea252fcdfe91a9289283ecdad7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Dec 2020 12:53:31 +0100 Subject: [PATCH 065/392] Fix warning --- htdocs/categories/class/categorie.class.php | 4 ++-- test/phpunit/CategorieTest.php | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index f55b3403546..63400aec45c 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -312,7 +312,7 @@ class Categorie extends CommonObject // Check parameters if (empty($id) && empty($label) && empty($ref_ext)) return -1; - if (!is_numeric($type)) $type = $this->MAP_ID[$type]; + if (!is_null($type) && !is_numeric($type)) $type = $this->MAP_ID[$type]; $sql = "SELECT rowid, fk_parent, entity, label, description, color, fk_soc, visible, type, ref_ext"; $sql .= ", date_creation, tms, fk_user_creat, fk_user_modif"; @@ -1058,7 +1058,7 @@ class Categorie extends CommonObject $current_lang = $langs->getDefaultLang(); // Init $this->cats array - $sql = "SELECT DISTINCT c.rowid, c.label, c.description, c.color, c.fk_parent, c.visible"; // Distinct reduce pb with old tables with duplicates + $sql = "SELECT DISTINCT c.rowid, c.label, c.ref_ext, c.description, c.color, c.fk_parent, c.visible"; // Distinct reduce pb with old tables with duplicates if (!empty($conf->global->MAIN_MULTILANGS)) $sql .= ", t.label as label_trans, t.description as description_trans"; $sql .= " FROM ".MAIN_DB_PREFIX."categorie as c"; if (!empty($conf->global->MAIN_MULTILANGS)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_lang as t ON t.fk_category=c.rowid AND t.lang='".$this->db->escape($current_lang)."'"; diff --git a/test/phpunit/CategorieTest.php b/test/phpunit/CategorieTest.php index 189ef10ecdc..11aff6b1a79 100644 --- a/test/phpunit/CategorieTest.php +++ b/test/phpunit/CategorieTest.php @@ -203,6 +203,7 @@ class CategorieTest extends PHPUnit\Framework\TestCase $result=$localobject2->create($user); $cat = new Categorie($this->savdb); $cat->id = $catid; + $cat->type = 0; $result=$cat->add_type($localobject2, "product"); print __METHOD__." result=".$result."\n"; From 4df0efa43d20cf4ed9470a10b50b2e02517078b7 Mon Sep 17 00:00:00 2001 From: Corentin Giroud-Argoud Date: Wed, 16 Dec 2020 10:47:28 +0100 Subject: [PATCH 066/392] [New] Add sendMail hook in subscription Added sendMail hook in subscription, before a mail is sent to confirm a subscription. It makes it more flexible for modules to interact with it. --- htdocs/adherents/subscription.php | 108 +++++++++++++++++------------- 1 file changed, 63 insertions(+), 45 deletions(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 1c4e42da1fe..a00c52b88e5 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -300,57 +300,75 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! if (!$error) { // Send confirmation Email if ($object->email && $sendalsoemail) { // $object is 'Adherent' - $subject = ''; - $msg = ''; - - // Send subscription email - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - // Set output language - $outputlangs = new Translate('', $conf); - $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); - // Load traductions files required by page - $outputlangs->loadLangs(array("main", "members")); - - // Get email content from template - $arraydefaultmessage = null; - $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION; - - if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); - - if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { - $subject = $arraydefaultmessage->topic; - $msg = $arraydefaultmessage->content; + $parameters = array( + 'datesubscription' => $datesubscription, + 'amount' => $amount, + 'ccountid' => $accountid, + 'operation' => $operation, + 'label' => $label, + 'num_chq' => $num_chq, + 'emetteur_nom' => $emetteur_nom, + 'emetteur_banque' => $emetteur_banque, + 'datesubend' => $datesubend + ); + $reshook = $hookmanager->executeHooks('sendMail', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } - $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); - complete_substitutions_array($substitutionarray, $outputlangs, $object); - $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); - $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs); + if (empty($reshook)) { + $subject = ''; + $msg = ''; - // Attach a file ? - $file = ''; - $listofpaths = array(); - $listofnames = array(); - $listofmimes = array(); - if (is_object($object->invoice) && (!is_object($arraydefaultmessage) || intval($arraydefaultmessage->joinfiles))) { - $invoicediroutput = $conf->facture->dir_output; - $fileparams = dol_most_recent_file($invoicediroutput.'/'.$object->invoice->ref, preg_quote($object->invoice->ref, '/').'[^\-]+'); - $file = $fileparams['fullname']; + // Send subscription email + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + // Set output language + $outputlangs = new Translate('', $conf); + $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); + // Load traductions files required by page + $outputlangs->loadLangs(array("main", "members")); - $listofpaths = array($file); - $listofnames = array(basename($file)); - $listofmimes = array(dol_mimetype($file)); - } + // Get email content from template + $arraydefaultmessage = null; + $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION; - $moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/subscription.php'."\r\n"; + if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); - $result = $object->send_an_email($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames, "", "", 0, -1, '', $moreinheader); - if ($result < 0) { - $errmsg = $object->error; - setEventMessages($object->error, $object->errors, 'errors'); - } else { - setEventMessages($langs->trans("EmailSentToMember", $object->email), null, 'mesgs'); + if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { + $subject = $arraydefaultmessage->topic; + $msg = $arraydefaultmessage->content; + } + + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); + $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs); + + // Attach a file ? + $file = ''; + $listofpaths = array(); + $listofnames = array(); + $listofmimes = array(); + if (is_object($object->invoice) && (!is_object($arraydefaultmessage) || intval($arraydefaultmessage->joinfiles))) { + $invoicediroutput = $conf->facture->dir_output; + $fileparams = dol_most_recent_file($invoicediroutput.'/'.$object->invoice->ref, preg_quote($object->invoice->ref, '/').'[^\-]+'); + $file = $fileparams['fullname']; + + $listofpaths = array($file); + $listofnames = array(basename($file)); + $listofmimes = array(dol_mimetype($file)); + } + + $moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/subscription.php'."\r\n"; + + $result = $object->send_an_email($texttosend, $subjecttosend, $listofpaths, $listofmimes, $listofnames, "", "", 0, -1, '', $moreinheader); + if ($result < 0) { + $errmsg = $object->error; + setEventMessages($object->error, $object->errors, 'errors'); + } else { + setEventMessages($langs->trans("EmailSentToMember", $object->email), null, 'mesgs'); + } } } else { setEventMessages($langs->trans("NoEmailSentToMember"), null, 'mesgs'); From a5a070705b91f67ad7b647aabe03c97f474de5b0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Dec 2020 14:53:04 +0100 Subject: [PATCH 067/392] Add test for phpunit env --- test/phpunit/MouvementStockTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/phpunit/MouvementStockTest.php b/test/phpunit/MouvementStockTest.php index 4570db5a1d5..1f27b4c71de 100644 --- a/test/phpunit/MouvementStockTest.php +++ b/test/phpunit/MouvementStockTest.php @@ -115,6 +115,8 @@ class MouvementStockTest extends PHPUnit\Framework\TestCase $langs=$this->savlangs; $db=$this->savdb; + if (empty($conf->productbatch->enabled)) { print "\n".__METHOD__." module Lot/Serial must be enabled.\n"; die(); } + print __METHOD__."\n"; } /** From 6f75e24fd704210a707731b81b32517816d50980 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Dec 2020 15:10:11 +0100 Subject: [PATCH 068/392] Fix better error management in migration --- .travis.yml | 3 ++- htdocs/install/upgrade2.php | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index a3e35dcfdab..bda2a9e9634 100644 --- a/.travis.yml +++ b/.travis.yml @@ -400,7 +400,8 @@ script: php step5.php 12.0.0 13.0.0 > $TRAVIS_BUILD_DIR/upgrade12001300-3.log # Enable modules not enabled into original dump - php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKET,MAIN_MODULE_ACCOUNTING,MAIN_MODULE_MRP,MAIN_MODULE_RECRUITMENT > $TRAVIS_BUILD_DIR/enablemodule.log + php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKET,MAIN_MODULE_ACCOUNTING,MAIN_MODULE_MRP > $TRAVIS_BUILD_DIR/enablemodule.log + php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_RECEPTION,MAIN_MODULE_RECRUITMENT > $TRAVIS_BUILD_DIR/enablemodule.log echo $? cd - set +e diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 2d84e234cf2..babb47de91a 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -509,7 +509,11 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ { $listofmodules[$value] = 'forceactivate'; } - migrate_reload_modules($db, $langs, $conf, $listofmodules, 1); + + $resultreloadmodules = migrate_reload_modules($db, $langs, $conf, $listofmodules, 1); + if ($resultreloadmodules < 0) { + $error++; + } } @@ -4283,7 +4287,7 @@ function migrate_delete_old_dir($db, $langs, $conf) * @param Conf $conf Object conf * @param array $listofmodule List of modules * @param int $force 1=Reload module even if not already loaded - * @return void + * @return int <0 if KO, >0 if OK */ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $force = 0) { @@ -4497,12 +4501,15 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo //$mod->remove('noboxes'); $mod->init($reloadmode); } else { - dolibarr_install_syslog('Failed to include '.strtolower($moduletoreloadshort).'/core/modules/mod'.$moduletoreloadshort.'.class.php'); + dolibarr_install_syslog('Failed to include '.strtolower($moduletoreloadshort).'/core/modules/mod'.$moduletoreloadshort.'.class.php', LOG_ERR); + print "Error, can't find module with name ".$moduletoreload."\n"; + return -1; } } } else { - dolibarr_install_syslog("Error, can't find module with name ".$moduletoreload, LOG_WARNING); - print "Error, can't find module with name ".$moduletoreload; + dolibarr_install_syslog("Error, can't find module with name ".$moduletoreload, LOG_ERR); + print "Error, can't find module with name ".$moduletoreload."\n"; + return -1; } } @@ -4516,6 +4523,8 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo print ''; } } + + return 1; } From 0a38f9e8aac7676d4e052660e541dccd3a65942f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Dec 2020 15:16:23 +0100 Subject: [PATCH 069/392] Fix add missing token --- htdocs/multicurrency/multicurrency_rate.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index ffab711e1cd..eae788b0587 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -241,6 +241,8 @@ if ($action != "updateRate") { $form = new Form($db); print '
'; + print ''; + print '
'; + print ''; if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') { @@ -755,8 +762,15 @@ while ($i < min($num, $limit)) } // Show sub-total of last shown account -$colspan = $totalarray['nbfield'] - 3; -$colspanend = $totalarray['nbfield'] - 8; +if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) { + $colnumber = 3; + $colnumberend = 7; +} else { + $colnumber = 4; + $colnumberend = 7; +} +$colspan = $totalarray['nbfield'] - $colnumber; +$colspanend = $totalarray['nbfield'] - $colnumberend; print '
'.$langs->trans("TotalForAccount").' '.$accountg.':'.price($sous_total_debit).'
'; print ' '; @@ -286,6 +288,8 @@ if ($action == "updateRate") { $form = new Form($db); print ''; + print ''; + print '
'.$langs->trans('Date').'
'; print ' '; print ''; print ''; $total_revenue_ht = 0; +$balance_ht = 0; +$balance_ttc = 0; foreach ($listofreferent as $key => $value) { + $parameters = array( + 'total_revenue_ht' =>& $total_revenue_ht, + 'balance_ht' =>& $balance_ht, + 'balance_ttc' =>& $balance_ttc, + 'key' => $key, + 'value' =>& $value, + 'dates' => $dates, + 'datee' => $datee + ); + $reshook = $hookmanager->executeHooks('printOverviewProfit', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + elseif ($reshook > 0){ + print $hookmanager->resPrint; + continue; + } + $name = $langs->trans($value['name']); $title = $value['title']; $classname = $value['class']; @@ -849,6 +869,22 @@ print '
'; // Detail foreach ($listofreferent as $key => $value) { + + $parameters = array( + 'key' => $key, + 'value' =>& $value, + 'dates' => $dates, + 'datee' => $datee + ); + $reshook = $hookmanager->executeHooks('printOverviewDetail', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + elseif ($reshook > 0){ + print $hookmanager->resPrint; + continue; + } + $title = $value['title']; $classname = $value['class']; $tablename = $value['table']; From e61b71bc93801a8771d4c0eead1f37838c201fa1 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 16 Dec 2020 15:40:38 +0000 Subject: [PATCH 074/392] Fixing style errors. --- htdocs/projet/element.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 975b8fcdbed..b334688558b 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -869,7 +869,6 @@ print '
'; // Detail foreach ($listofreferent as $key => $value) { - $parameters = array( 'key' => $key, 'value' =>& $value, From e4c853b162002338a4076a354f030301ff2288a3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Dec 2020 17:00:14 +0100 Subject: [PATCH 075/392] Enable module product batch --- htdocs/install/upgrade2.php | 68 +++++++++++++++---------------------- 1 file changed, 28 insertions(+), 40 deletions(-) diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index babb47de91a..ba24cf3a496 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -4295,14 +4295,12 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo dolibarr_install_syslog("upgrade2::migrate_reload_modules force=".$force.", listofmodule=".join(',', array_keys($listofmodule))); - foreach ($listofmodule as $moduletoreload => $reloadmode) // reloadmodule can be 'noboxes', 'newboxdefonly', 'forceactivate' - { + foreach ($listofmodule as $moduletoreload => $reloadmode) { // reloadmodule can be 'noboxes', 'newboxdefonly', 'forceactivate' if (empty($moduletoreload) || (empty($conf->global->$moduletoreload) && !$force)) continue; // Discard reload if module not enabled $mod = null; - if ($moduletoreload == 'MAIN_MODULE_AGENDA') - { + if ($moduletoreload == 'MAIN_MODULE_AGENDA') { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Agenda module"); $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modAgenda.class.php'; if ($res) { @@ -4310,8 +4308,7 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo $mod->remove('noboxes'); $mod->init($reloadmode); } - } elseif ($moduletoreload == 'MAIN_MODULE_API') - { + } elseif ($moduletoreload == 'MAIN_MODULE_API') { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Rest API module"); $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modApi.class.php'; if ($res) { @@ -4319,8 +4316,7 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo //$mod->remove('noboxes'); $mod->init($reloadmode); } - } elseif ($moduletoreload == 'MAIN_MODULE_BARCODE') - { + } elseif ($moduletoreload == 'MAIN_MODULE_BARCODE') { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Barcode module"); $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modBarcode.class.php'; if ($res) { @@ -4328,8 +4324,7 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo $mod->remove('noboxes'); $mod->init($reloadmode); } - } elseif ($moduletoreload == 'MAIN_MODULE_CRON') - { + } elseif ($moduletoreload == 'MAIN_MODULE_CRON') { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Cron module"); $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modCron.class.php'; if ($res) { @@ -4337,8 +4332,7 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo $mod->remove('noboxes'); $mod->init($reloadmode); } - } elseif ($moduletoreload == 'MAIN_MODULE_SOCIETE') - { + } elseif ($moduletoreload == 'MAIN_MODULE_SOCIETE') { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Societe module"); $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modSociete.class.php'; if ($res) { @@ -4346,8 +4340,7 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo $mod->remove('noboxes'); $mod->init($reloadmode); } - } elseif ($moduletoreload == 'MAIN_MODULE_PRODUIT') // Permission has changed into 2.7 - { + } elseif ($moduletoreload == 'MAIN_MODULE_PRODUIT') { // Permission has changed into 2.7 dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Produit module"); $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modProduct.class.php'; if ($res) { @@ -4355,8 +4348,7 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo //$mod->remove('noboxes'); $mod->init($reloadmode); } - } elseif ($moduletoreload == 'MAIN_MODULE_SERVICE') // Permission has changed into 2.7 - { + } elseif ($moduletoreload == 'MAIN_MODULE_SERVICE') { // Permission has changed into 2.7 dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Service module"); $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modService.class.php'; if ($res) { @@ -4364,8 +4356,7 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo //$mod->remove('noboxes'); $mod->init($reloadmode); } - } elseif ($moduletoreload == 'MAIN_MODULE_COMMANDE') // Permission has changed into 2.9 - { + } elseif ($moduletoreload == 'MAIN_MODULE_COMMANDE') { // Permission has changed into 2.9 dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Commande module"); $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modCommande.class.php'; if ($res) { @@ -4373,8 +4364,7 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo //$mod->remove('noboxes'); $mod->init($reloadmode); } - } elseif ($moduletoreload == 'MAIN_MODULE_FACTURE') // Permission has changed into 2.9 - { + } elseif ($moduletoreload == 'MAIN_MODULE_FACTURE') { // Permission has changed into 2.9 dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Facture module"); $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modFacture.class.php'; if ($res) { @@ -4382,8 +4372,7 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo //$mod->remove('noboxes'); $mod->init($reloadmode); } - } elseif ($moduletoreload == 'MAIN_MODULE_FOURNISSEUR') // Permission has changed into 2.9 - { + } elseif ($moduletoreload == 'MAIN_MODULE_FOURNISSEUR') { // Permission has changed into 2.9 dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Fournisseur module"); $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modFournisseur.class.php'; if ($res) { @@ -4391,8 +4380,7 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo //$mod->remove('noboxes'); $mod->init($reloadmode); } - } elseif ($moduletoreload == 'MAIN_MODULE_HOLIDAY') // Permission and tabs has changed into 3.8 - { + } elseif ($moduletoreload == 'MAIN_MODULE_HOLIDAY') { // Permission and tabs has changed into 3.8 dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Leave Request module"); $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modHoliday.class.php'; if ($res) { @@ -4400,8 +4388,7 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo $mod->remove('noboxes'); $mod->init($reloadmode); } - } elseif ($moduletoreload == 'MAIN_MODULE_DEPLACEMENT') // Permission has changed into 3.0 - { + } elseif ($moduletoreload == 'MAIN_MODULE_DEPLACEMENT') { // Permission has changed into 3.0 dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Deplacement module"); $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modDeplacement.class.php'; if ($res) { @@ -4409,8 +4396,7 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo //$mod->remove('noboxes'); $mod->init($reloadmode); } - } elseif ($moduletoreload == 'MAIN_MODULE_EXPENSEREPORT') - { + } elseif ($moduletoreload == 'MAIN_MODULE_EXPENSEREPORT') { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Expense Report module"); $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modExpenseReport.class.php'; if ($res) { @@ -4418,8 +4404,7 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo //$mod->remove('noboxes'); $mod->init($reloadmode); } - } elseif ($moduletoreload == 'MAIN_MODULE_DON') // Permission has changed into 3.0 - { + } elseif ($moduletoreload == 'MAIN_MODULE_DON') { // Permission has changed into 3.0 dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Don module"); $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modDon.class.php'; if ($res) { @@ -4427,8 +4412,7 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo //$mod->remove('noboxes'); $mod->init($reloadmode); } - } elseif ($moduletoreload == 'MAIN_MODULE_ECM') // Permission has changed into 3.0 and 3.1 - { + } elseif ($moduletoreload == 'MAIN_MODULE_ECM') { // Permission has changed into 3.0 and 3.1 dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate ECM module"); $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modECM.class.php'; if ($res) { @@ -4436,8 +4420,7 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo $mod->remove('noboxes'); // We need to remove because a permission id has been removed $mod->init($reloadmode); } - } elseif ($moduletoreload == 'MAIN_MODULE_PAYBOX') // Permission has changed into 3.0 - { + } elseif ($moduletoreload == 'MAIN_MODULE_PAYBOX') { // Permission has changed into 3.0 dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Paybox module"); $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modPaybox.class.php'; if ($res) { @@ -4445,8 +4428,7 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo $mod->remove('noboxes'); // We need to remove because id of module has changed $mod->init($reloadmode); } - } elseif ($moduletoreload == 'MAIN_MODULE_SUPPLIERPROPOSAL') // Module after 3.5 - { + } elseif ($moduletoreload == 'MAIN_MODULE_SUPPLIERPROPOSAL') { // Module after 3.5 dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Supplier Proposal module"); $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modSupplierProposal.class.php'; if ($res) { @@ -4454,8 +4436,7 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo $mod->remove('noboxes'); // We need to remove because id of module has changed $mod->init($reloadmode); } - } elseif ($moduletoreload == 'MAIN_MODULE_OPENSURVEY') // Permission has changed into 3.0 - { + } elseif ($moduletoreload == 'MAIN_MODULE_OPENSURVEY') { // Permission has changed into 3.0 dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Opensurvey module"); $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modOpenSurvey.class.php'; if ($res) { @@ -4463,8 +4444,15 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo $mod->remove('noboxes'); // We need to remove because menu entries has changed $mod->init($reloadmode); } - } elseif ($moduletoreload == 'MAIN_MODULE_TAKEPOS') // Permission has changed into 10.0 - { + } elseif ($moduletoreload == 'MAIN_MODULE_PRODUCTBATCH') { // Permission has changed into 10.0 + dolibarr_install_syslog("upgrade2::migrate_reload_modules ProductBatch module"); + $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modProductBatch.class.php'; + if ($res) { + $mod = new modProductBatch($db); + $mod->remove('noboxes'); // We need to remove because menu entries has changed + $mod->init($reloadmode); + } + } elseif ($moduletoreload == 'MAIN_MODULE_TAKEPOS') { // Permission has changed into 10.0 dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Takepos module"); $res = @include_once DOL_DOCUMENT_ROOT.'/core/modules/modTakePos.class.php'; if ($res) { From ec8fd130f4e7d0ce0d8bff990e5de3176c1283c8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Dec 2020 17:33:40 +0100 Subject: [PATCH 076/392] Update doc --- nightwatch.conf.js | 2 +- package.json | 2 +- test/acceptance/README.md | 32 +++++++++++++++++++++----------- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/nightwatch.conf.js b/nightwatch.conf.js index e72febea918..38178aadf92 100644 --- a/nightwatch.conf.js +++ b/nightwatch.conf.js @@ -1,5 +1,5 @@ const admin_username = process.env.ADMIN_USERNAME || 'admin'; -const admin_password = process.env.ADMIN_PASSWORD || 'password'; +const admin_password = process.env.ADMIN_PASSWORD || 'admin'; const launch_url = process.env.LAUNCH_URL || 'http://localhost/dolibarr/htdocs/'; module.exports = { page_objects_path : './test/acceptance/pageObjects/', // jshint ignore:line diff --git a/package.json b/package.json index 56f8ced1d4b..02c9b2abcb9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "devDependencies": { "cucumber": "^6.0.5", - "nightwatch": "^1.4.3", + "nightwatch": "^1.5.1", "nightwatch-api": "^3.0.1" }, "scripts": { diff --git a/test/acceptance/README.md b/test/acceptance/README.md index ada096c0b69..141370208d0 100644 --- a/test/acceptance/README.md +++ b/test/acceptance/README.md @@ -2,14 +2,21 @@ ### Run Selenium -Selenium has been used for automating the browser. +Create a working directory + `mkdir selenium; cd selenium;` + +Selenium has been used for automating the browser. + [Download](https://www.selenium.dev/downloads/) the `latest stable version` of the `Selenium standalone server JAR file`. + `wget https://selenium-release.storage.googleapis.com/3.141/selenium-server-standalone-3.141.59.jar` + Also [download](https://chromedriver.chromium.org/downloads) the `latest stable version` of `Chrome Driver`. Once you have downloaded Chrome Driver, you need to unzip it by running the following command: + `wget https://chromedriver.storage.googleapis.com/86.0.4240.22/chromedriver_linux64.zip` `unzip chromedriver_linux64.zip` Once you have unzipped it, you need to move the *chromedriver* file (shared library) and place it inside the same folder where you have placed the Selenium standalone server file. @@ -18,10 +25,9 @@ Now we can run selenium by two ways: * Start selenium server with a command which usually looks like: - `java -jar selenium-server-standalone-.jar -port 4444` + `java -jar selenium-server-standalone-*.jar -port 4444` - -* Run selenium in docker with +* Or run selenium in docker with `docker run -d -p 4444:4444 -p 5900:5900 -v /dev/shm:/dev/shm selenium/standalone-chrome-debug` @@ -34,16 +40,20 @@ Now we can run selenium by two ways: * Install *yarn*. For example on Ubuntu: ``` - apt install yarnpkg + sudo apt install yarnpkg ``` -* Install *nodejs* libraries. For example on Ubuntu: +* Install *npm* tools to manage *nodejs* libraries. For example on Ubuntu: ``` apt install npm - npm install cucumber - npm install nightwatch-api - npm install nightwatch + ``` + +* Go into the git local repository of the Dolibarr version to test. + + ``` + cd ~/git/dolibarr + npm install cucumber nightwatch-api nightwatch npm update ``` @@ -61,9 +71,9 @@ Now we can run selenium by two ways: `LAUNCH_URL=''; ADMIN_USERNAME=''; ADMIN_PASSWORD='';` - `yarn run test:e2e test/acceptance/features/` + `yarnpkg run test:e2e test/acceptance/features/` - For example: `yarn run test:e2e test/acceptance/features/WebUI/addUsers.feature` + For example: `yarnpkg run test:e2e test/acceptance/features/WebUI/addUsers.feature` Note: The script to run all the acceptance tests is specified in `scripts` object of `package.json` file inside the project's root directory as : From 21c2fae00cc37b446dd156c52272d29b7eee1ecb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Dec 2020 17:41:18 +0100 Subject: [PATCH 077/392] Fix setup of antivirus --- htdocs/admin/security_file.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/security_file.php b/htdocs/admin/security_file.php index 2669e741c6e..ea5ea2983fd 100644 --- a/htdocs/admin/security_file.php +++ b/htdocs/admin/security_file.php @@ -153,7 +153,7 @@ if (ini_get('safe_mode') && !empty($conf->global->MAIN_ANTIVIRUS_COMMAND)) dol_syslog("safe_mode is on, basedir is ".$basedir.", safe_mode_exec_dir is ".ini_get('safe_mode_exec_dir'), LOG_WARNING); } } -print ''; +print ''; if (defined('MAIN_ANTIVIRUS_COMMAND')) { print '
'.$langs->trans("ValueIsForcedBySystem").''; } @@ -167,7 +167,7 @@ print '
'; print '
'.$langs->trans('Date').''; From e7dda7bb4f0f06c851adf512c787b706b97ff24d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Dec 2020 15:46:54 +0100 Subject: [PATCH 070/392] Move help into tooltip help section --- htdocs/core/modules/modCategorie.class.php | 27 +++++++++++----------- htdocs/langs/en_US/categories.lang | 1 + 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index d2218d33483..7dae96253bb 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -121,28 +121,29 @@ class modCategorie extends DolibarrModules // All Categories List $r++; $this->export_code[$r] = $this->rights_class.'_list'; - $this->export_label[$r] = 'CatList'; + $this->export_label[$r] = 'CatListAll'; $this->export_icon[$r] = $this->picto; $this->export_enabled[$r] = 'true'; $this->export_permission[$r] = array(array("categorie", "lire")); $typeexample = ""; - if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { $typeexample .= ($typeexample ? "/" : "")."0=Product-Service"; } + if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { $typeexample .= ($typeexample ? " / " : "")."0=Product-Service"; } if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) { $typeexample .= ($typeexample ? "/" : "")."1=Supplier"; } - if (!empty($conf->societe->enabled)) { $typeexample .= ($typeexample ? "/" : "")."2=Customer-Prospect"; } - if (!empty($conf->adherent->enabled)) { $typeexample .= ($typeexample ? "/" : "")."3=Member"; } - if (!empty($conf->societe->enabled)) { $typeexample .= ($typeexample ? "/" : "")."4=Contact"; } - if (!empty($conf->bank->enabled)) { $typeexample .= ($typeexample ? "/" : "")."5=Bank account"; } - if (!empty($conf->projet->enabled)) { $typeexample .= ($typeexample ? "/" : "")."6=Project"; } - if (!empty($conf->user->enabled)) { $typeexample .= ($typeexample ? "/" : "")."7=User"; } - if (!empty($conf->bank->enabled)) { $typeexample .= ($typeexample ? "/" : "")."8=Bank line"; } - if (!empty($conf->stock->enabled)) { $typeexample .= ($typeexample ? "/" : "")."9=Warehouse"; } - if (!empty($conf->agenda->enabled)) { $typeexample .= ($typeexample ? "/" : "")."10=Agenda event"; } - if (!empty($conf->website->enabled)) { $typeexample .= ($typeexample ? "/" : "")."11=Website page"; } + if (!empty($conf->societe->enabled)) { $typeexample .= ($typeexample ? " / " : "")."2=Customer-Prospect"; } + if (!empty($conf->adherent->enabled)) { $typeexample .= ($typeexample ? " / " : "")."3=Member"; } + if (!empty($conf->societe->enabled)) { $typeexample .= ($typeexample ? " / " : "")."4=Contact"; } + if (!empty($conf->bank->enabled)) { $typeexample .= ($typeexample ? " / " : "")."5=Bank account"; } + if (!empty($conf->projet->enabled)) { $typeexample .= ($typeexample ? " / " : "")."6=Project"; } + if (!empty($conf->user->enabled)) { $typeexample .= ($typeexample ? " / " : "")."7=User"; } + if (!empty($conf->bank->enabled)) { $typeexample .= ($typeexample ? " / " : "")."8=Bank line"; } + if (!empty($conf->stock->enabled)) { $typeexample .= ($typeexample ? " / " : "")."9=Warehouse"; } + if (!empty($conf->agenda->enabled)) { $typeexample .= ($typeexample ? " / " : "")."10=Agenda event"; } + if (!empty($conf->website->enabled)) { $typeexample .= ($typeexample ? " / " : "")."11=Website page"; } - $this->export_fields_array[$r] = array('cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.type'=>"Type ".$typeexample, 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategory", 'pcat.label'=>"ParentCategoryLabel" ); + $this->export_fields_array[$r] = array('cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.type'=>"Type", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategory", 'pcat.label'=>"ParentCategoryLabel" ); $this->export_TypeFields_array[$r] = array('cat.label'=>"Text", 'cat.type'=>"Numeric", 'cat.description'=>"Text", 'cat.fk_parent'=>'List:categorie:label:rowid', 'pcat.label'=>'Text' ); $this->export_entities_array[$r] = array(); // We define here only fields that use another picto + $this->export_help_array[$r] = array('cat.type'=>$typeexample); $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as cat'; diff --git a/htdocs/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang index 36d1d3e545a..4ddf0d6093f 100644 --- a/htdocs/langs/en_US/categories.lang +++ b/htdocs/langs/en_US/categories.lang @@ -19,6 +19,7 @@ ProjectsCategoriesArea=Projects tags/categories area UsersCategoriesArea=Users tags/categories area SubCats=Sub-categories CatList=List of tags/categories +CatListAll=List of tags/categories (all types) NewCategory=New tag/category ModifCat=Modify tag/category CatCreated=Tag/category created From 1f9c597f269fef235e4404429cccc50ead6b0611 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Dec 2020 15:57:52 +0100 Subject: [PATCH 071/392] Fix default fields in list --- htdocs/societe/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 71f0f08cc9d..2e24f355b37 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -187,8 +187,8 @@ $arrayfields = array( 's.code_fournisseur'=>array('label'=>"SupplierCodeShort", 'position'=>11, 'checked'=>$checkedsuppliercode, 'enabled'=>(!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))), 's.code_compta'=>array('label'=>"CustomerAccountancyCodeShort", 'position'=>13, 'checked'=>$checkedcustomeraccountcode), 's.code_compta_fournisseur'=>array('label'=>"SupplierAccountancyCodeShort", 'position'=>14, 'checked'=>$checkedsupplieraccountcode, 'enabled'=>(!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))), - 's.address'=>array('label'=>"Address", 'position'=>19, 'checked'=>1), - 's.town'=>array('label'=>"Town", 'position'=>20, 'checked'=>1), + 's.address'=>array('label'=>"Address", 'position'=>19, 'checked'=>0), + 's.town'=>array('label'=>"Town", 'position'=>20, 'checked'=>0), 's.zip'=>array('label'=>"Zip", 'position'=>21, 'checked'=>1), 'state.nom'=>array('label'=>"State", 'position'=>22, 'checked'=>0), 'region.nom'=>array('label'=>"Region", 'position'=>23, 'checked'=>0), From 40ae1808de3e502f0bff5209e53b066901610565 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Dec 2020 16:06:33 +0100 Subject: [PATCH 072/392] Look and fell v13 --- htdocs/exports/export.php | 11 +++++------ htdocs/imports/import.php | 13 ++++++------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index b02ca2e10de..c9db970cd0b 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -429,8 +429,7 @@ if ($step == 1 || !$datatoexport) $hselected = $h; $h++; - print dol_get_fiche_head($head, $hselected, $langs->trans("NewExport"), -1); - + print dol_get_fiche_head($head, $hselected, '', -1); print '
'.$langs->trans("SelectExportDataSet").'

'; @@ -492,7 +491,7 @@ if ($step == 2 && $datatoexport) $hselected = $h; $h++; - print dol_get_fiche_head($head, $hselected, $langs->trans("NewExport"), -2); + print dol_get_fiche_head($head, $hselected, '', -2); print '
'; print '
'; @@ -688,7 +687,7 @@ if ($step == 3 && $datatoexport) $hselected = $h; $h++; - print dol_get_fiche_head($head, $hselected, $langs->trans("NewExport"), -2); + print dol_get_fiche_head($head, $hselected, '', -2); print '
'; print '
'; @@ -875,7 +874,7 @@ if ($step == 4 && $datatoexport) $hselected = $h; $h++; - print dol_get_fiche_head($head, $hselected, $langs->trans("NewExport"), -2); + print dol_get_fiche_head($head, $hselected, '', -2); print '
'; print '
'; @@ -1134,7 +1133,7 @@ if ($step == 5 && $datatoexport) $hselected = $h; $h++; - print dol_get_fiche_head($head, $hselected, $langs->trans("NewExport"), -2); + print dol_get_fiche_head($head, $hselected, '', -2); /* * Confirmation suppression fichier diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 60134ab9b95..fbb17e15280 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -392,8 +392,7 @@ if ($step == 1 || !$datatoimport) $head = import_prepare_head($param, 1); - print dol_get_fiche_head($head, 'step1', $langs->trans("NewImport"), -1); - + print dol_get_fiche_head($head, 'step1', '', -1); print '
'.$langs->trans("SelectImportDataSet").'

'; @@ -454,7 +453,7 @@ if ($step == 2 && $datatoimport) $head = import_prepare_head($param, 2); - print dol_get_fiche_head($head, 'step2', $langs->trans("NewImport"), -2); + print dol_get_fiche_head($head, 'step2', '', -2); print '
'; print '
'; @@ -540,7 +539,7 @@ if ($step == 3 && $datatoimport) $head = import_prepare_head($param, 3); - print dol_get_fiche_head($head, 'step3', $langs->trans("NewImport"), -2); + print dol_get_fiche_head($head, 'step3', '', -2); /* * Confirm delete file @@ -835,7 +834,7 @@ if ($step == 4 && $datatoimport) $head = import_prepare_head($param, 4); - print dol_get_fiche_head($head, 'step4', $langs->trans("NewImport"), -2); + print dol_get_fiche_head($head, 'step4', '', -2); print '
'; print '
'; @@ -1306,7 +1305,7 @@ if ($step == 5 && $datatoimport) print ''; // step 5 print ''; // step 5 - print dol_get_fiche_head($head, 'step5', $langs->trans("NewImport"), -2); + print dol_get_fiche_head($head, 'step5', '', -2); print '
'; print '
'; @@ -1730,7 +1729,7 @@ if ($step == 6 && $datatoimport) $head = import_prepare_head($param, 6); - print dol_get_fiche_head($head, 'step6', $langs->trans("NewImport"), -1); + print dol_get_fiche_head($head, 'step6', '', -1); print '
'; print '
'; From 1f29d4f5e8c47144db678abd0bf835e513f3964a Mon Sep 17 00:00:00 2001 From: ATM john Date: Wed, 16 Dec 2020 16:25:30 +0100 Subject: [PATCH 073/392] Add missing hooks --- htdocs/projet/element.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index c513123c9bf..975b8fcdbed 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -652,9 +652,29 @@ print '
'.$langs->trans("AmountTTC").'
'.$langs->trans("AntiVirusParam").'
'; print ''.$langs->trans("AntiVirusParamExample").''; print '
'; -print ''; +print ''; if (defined('MAIN_ANTIVIRUS_PARAM')) { print '
'.$langs->trans("ValueIsForcedBySystem").''; } From 82710e54a87a86aad87367c5fbdc2c647d02fe58 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Dec 2020 18:10:40 +0100 Subject: [PATCH 078/392] Fix get custom odt templates --- htdocs/core/lib/files.lib.php | 5 +++++ htdocs/core/lib/functions.lib.php | 2 +- .../commande/doc/doc_generic_order_odt.modules.php | 8 ++++++-- .../facture/doc/doc_generic_invoice_odt.modules.php | 5 +++-- .../propale/doc/doc_generic_proposal_odt.modules.php | 6 ++++-- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 22545b78cf8..c43a7eb890c 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2260,6 +2260,11 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $accessallowed = ($user->admin && basename($original_file) == $original_file && preg_match('/^dolibarr.*\.log$/', basename($original_file))); $original_file = $dolibarr_main_data_root.'/'.$original_file; } // Wrapping for *.log files, like when used with url http://.../document.php?modulepart=logs&file=dolibarr.log + elseif ($modulepart == 'doctemplates' && !empty($dolibarr_main_data_root)) + { + $accessallowed = $user->admin; + $original_file = $dolibarr_main_data_root.'/doctemplates/'.$original_file; + } // Wrapping for *.zip files, like when used with url http://.../document.php?modulepart=packages&file=module_myfile.zip elseif ($modulepart == 'doctemplateswebsite' && !empty($dolibarr_main_data_root)) { $accessallowed = ($fuser->rights->website->write && preg_match('/\.jpg$/i', basename($original_file))); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 998cddea0f9..04e096c4e3f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3210,7 +3210,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ '1downarrow', '1uparrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected', 'accountancy', 'account', 'accountline', 'action', 'add', 'address', 'bank_account', 'barcode', 'bank', 'bill', 'billa', 'billr', 'billd', 'bookmark', 'bom', 'building', 'cash-register', 'category', 'check', 'clock', 'close_title', 'company', 'contact', 'contract', 'cron', 'cubes', - 'delete', 'dolly', 'dollyrevert', 'donation', 'edit', 'ellipsis-h', 'email', 'eraser', 'external-link-alt', 'external-link-square-alt', + 'delete', 'dolly', 'dollyrevert', 'donation', 'download', 'edit', 'ellipsis-h', 'email', 'eraser', 'external-link-alt', 'external-link-square-alt', 'filter', 'file-code', 'file-export', 'file-import', 'file-upload', 'folder', 'folder-open', 'globe', 'globe-americas', 'grip', 'grip_title', 'group', 'help', 'holiday', 'intervention', 'label', 'language', 'list', 'listlight', 'lot', diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index 3165760b541..2b71f6896f5 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -169,10 +169,14 @@ class doc_generic_order_odt extends ModelePDFCommandes if ($nbofiles) { - $texte .= '

\n"; /* @@ -377,6 +374,7 @@ if ($resql) } +print '
'; print "\n"; print "\n"; print ''; @@ -501,6 +499,7 @@ foreach ($dirmodels as $reldir) } print '
'.$langs->trans("Name").'
'; +print '
'; /* diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index c1546f1da2c..f7e72f53e7e 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -44,10 +44,13 @@ $type = 'ticket'; $error = 0; + /* * Actions */ +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + if ($action == 'updateMask') { $maskconstticket = GETPOST('maskconstticket', 'alpha'); $maskticket = GETPOST('maskticket', 'alpha'); @@ -66,7 +69,37 @@ if ($action == 'updateMask') { } else { setEventMessages($langs->trans("Error"), null, 'errors'); } -} elseif ($action == 'setmod') { +} + +// Activate a model +elseif ($action == 'set') { + $ret = addDocumentModel($value, $type, $label, $scandir); +} elseif ($action == 'del') { + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + if ($conf->global->TICKET_ADDON_PDF == "$value") dolibarr_del_const($db, 'TICKET_ADDON_PDF', $conf->entity); + } +} + +// Set default model +elseif ($action == 'setdoc') { + if (dolibarr_set_const($db, "TICKET_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) + { + // The constant that was read before the new set + // We therefore requires a variable to have a coherent view + $conf->global->TICKET_ADDON_PDF = $value; + } + + // On active le modele + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + $ret = addDocumentModel($value, $type, $label, $scandir); + } +} + +elseif ($action == 'setmod') { // TODO Verifier si module numerotation choisi peut etre active // par appel methode canBeActivated @@ -190,7 +223,7 @@ print dol_get_fiche_end(); /* - * Projects Numbering model + * Tickets numbering model */ print load_fiche_titre($langs->trans("TicketNumberingModules"), '', ''); @@ -291,6 +324,162 @@ print '
'; print ''; print '
'; + + +/* + * Document templates generators + */ + +print load_fiche_titre($langs->trans("TicketsModelModule"), '', ''); + +// Load array def with activated templates +$def = array(); +$sql = "SELECT nom"; +$sql .= " FROM ".MAIN_DB_PREFIX."document_model"; +$sql .= " WHERE type = '".$db->escape($type)."'"; +$sql .= " AND entity = ".$conf->entity; +$resql = $db->query($sql); +if ($resql) +{ + $i = 0; + $num_rows = $db->num_rows($resql); + while ($i < $num_rows) + { + $array = $db->fetch_array($resql); + array_push($def, $array[0]); + $i++; + } +} else { + dol_print_error($db); +} + + +print '
'; +print "\n"; +print "\n"; +print ''; +print ''; +print '\n"; +print '\n"; +print ''; +print ''; +print "\n"; + +clearstatcache(); + +foreach ($dirmodels as $reldir) +{ + foreach (array('', '/doc') as $valdir) + { + $realpath = $reldir."core/modules/ticket".$valdir; + $dir = dol_buildpath($realpath); + + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + $filelist[] = $file; + } + closedir($handle); + arsort($filelist); + + foreach ($filelist as $file) + { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) + { + if (file_exists($dir.'/'.$file)) + { + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); + + require_once $dir.'/'.$file; + $module = new $classname($db); + + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; + + if ($modulequalified) + { + print ''; + + // Active + if (in_array($name, $def)) + { + print ''; + } else { + print '"; + } + + // Default + print ''; + + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); + if ($module->type == 'pdf') + { + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; + + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + //$htmltooltip .= '
'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1); + //$htmltooltip .= '
'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1); + //$htmltooltip .= '
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); + + + print ''; + + // Preview + print ''; + + print "\n"; + } + } + } + } + } + } + } +} + +print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status")."'.$langs->trans("Default")."'.$langs->trans("ShortInfo").''.$langs->trans("Preview").'
'; + print (empty($module->name) ? $name : $module->name); + print "\n"; + if (method_exists($module, 'info')) print $module->info($langs); + else print $module->description; + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print "'; + if ($conf->global->TICKET_ADDON_PDF == $name) + { + print img_picto($langs->trans("Default"), 'on'); + } else { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; + } + print ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"), 'pdf').''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print '
'; +print '

'; + + if (!$conf->use_javascript_ajax) { print ''; print ''; diff --git a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php index b5e1fc80a1d..18f2d405acf 100644 --- a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php +++ b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php @@ -162,10 +162,10 @@ class doc_generic_bom_odt extends ModelePDFBom if ($nbofiles) { - $texte .= '
'; } - $texte .= '