From 5f0999665f232ed6647931856b76939ce1516929 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 27 Jan 2022 02:27:36 +0100 Subject: [PATCH 01/14] FIX Invoice - Clone - Don't report contact on an another thirdparty --- htdocs/compta/facture/class/facture.class.php | 48 ++++++++++--------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index f8f246924e3..4feeb3d60b6 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1,22 +1,23 @@ - * Copyright (C) 2004-2013 Laurent Destailleur - * Copyright (C) 2004 Sebastien Di Cintio - * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2005 Marc Barilley / Ocebo - * Copyright (C) 2005-2014 Regis Houssin - * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2007 Franky Van Liedekerke - * Copyright (C) 2010-2020 Juanjo Menent - * Copyright (C) 2012-2014 Christophe Battarel - * Copyright (C) 2012-2015 Marcos García - * Copyright (C) 2012 Cédric Salvador - * Copyright (C) 2012-2014 Raphaël Doursenaud - * Copyright (C) 2013 Cedric Gross - * Copyright (C) 2013 Florian Henry - * Copyright (C) 2016 Ferran Marcet - * Copyright (C) 2018 Alexandre Spangaro - * Copyright (C) 2018 Nicolas ZABOURI +/* Copyright (C) 2002-2007 Rodolphe Quiedeville + * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2004 Sebastien Di Cintio + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005-2014 Regis Houssin + * Copyright (C) 2006 Andre Cianfarani + * Copyright (C) 2007 Franky Van Liedekerke + * Copyright (C) 2010-2020 Juanjo Menent + * Copyright (C) 2012-2014 Christophe Battarel + * Copyright (C) 2012-2015 Marcos García + * Copyright (C) 2012 Cédric Salvador + * Copyright (C) 2012-2014 Raphaël Doursenaud + * Copyright (C) 2013 Cedric Gross + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2018 Alexandre Spangaro + * Copyright (C) 2018 Nicolas ZABOURI + * Copyright (C) 2022 Sylvain Legrand * * 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 @@ -1159,6 +1160,9 @@ class Facture extends CommonInvoice $object->fetch($fromid); + // Load source object + $objFrom = clone $object; + // Change socid if needed if (!empty($this->socid) && $this->socid != $object->socid) { $objsoc = new Societe($this->db); @@ -1239,13 +1243,13 @@ class Facture extends CommonInvoice $this->errors = $object->errors; } else { // copy internal contacts - if ($object->copy_linked_contact($this, 'internal') < 0) { + if ($object->copy_linked_contact($objFrom, 'internal') < 0) { $error++; $this->error = $object->error; $this->errors = $object->errors; - } elseif ($this->socid == $object->socid) { + } elseif ($object->socid == $objFrom->socid) { // copy external contacts if same company - if ($object->copy_linked_contact($this, 'external') < 0) { + if ($object->copy_linked_contact($objFrom, 'external') < 0) { $error++; $this->error = $object->error; $this->errors = $object->errors; @@ -1256,7 +1260,7 @@ class Facture extends CommonInvoice if (!$error) { // Hook of thirdparty module if (is_object($hookmanager)) { - $parameters = array('objFrom'=>$this); + $parameters = array('objFrom'=>$objFrom); $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { From d167e022ebe31343a0620dcb43563d9cc5da4321 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 31 Jan 2022 12:02:48 +0100 Subject: [PATCH 02/14] Debug v15 --- htdocs/comm/mailing/cibles.php | 11 +- .../modules/mailings/contacts1.modules.php | 78 +++--- .../core/modules/mailings/fraise.modules.php | 39 ++- .../modules/mailings/partnership.modules.php | 264 ++++++++++++++++++ .../core/modules/mailings/pomme.modules.php | 12 +- .../modules/mailings/thirdparties.modules.php | 31 +- .../thirdparties_services_expired.modules.php | 6 +- .../partnership/class/partnership.class.php | 12 +- 8 files changed, 360 insertions(+), 93 deletions(-) create mode 100644 htdocs/core/modules/mailings/partnership.modules.php diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 340ac1dfc8c..9069b63179f 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -310,6 +310,8 @@ if ($object->fetch($id) >= 0) { print load_fiche_titre($langs->trans("ToAddRecipientsChooseHere"), ($user->admin ?info_admin($langs->trans("YouCanAddYourOwnPredefindedListHere"), 1) : ''), 'generic'); //print ''; + + print '
'; print '
'; //print '
'; @@ -323,7 +325,7 @@ if ($object->fetch($id) >= 0) { //print ''; print '
 
'; //print "\n"; - print ''; + print ''; // End tr clearstatcache(); @@ -424,9 +426,9 @@ if ($object->fetch($id) >= 0) { print '
'; if ($allowaddtarget) { - print ''; + print ''; } else { - print ''; + print ''; //print $langs->trans("MailNoChangePossible"); print " "; } @@ -445,6 +447,7 @@ if ($object->fetch($id) >= 0) { $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; + print '
'; // End table print ''; print '

'; @@ -535,7 +538,7 @@ if ($object->fetch($id) >= 0) { $morehtmlcenter = ''; if ($allowaddtarget) { - $morehtmlcenter = ''.$langs->trans("ToClearAllRecipientsClickHere").'id.'" class="button reposition smallpaddingimp">'.$langs->trans("TargetsReset").''; + $morehtmlcenter = ''.$langs->trans("ToClearAllRecipientsClickHere").'id.'" class="button reposition smallpaddingimp">'.$langs->trans("TargetsReset").''; } $morehtmlcenter .= '   id.'">'.$langs->trans("Download").''; diff --git a/htdocs/core/modules/mailings/contacts1.modules.php b/htdocs/core/modules/mailings/contacts1.modules.php index ef43f05b86a..4b928d8af07 100644 --- a/htdocs/core/modules/mailings/contacts1.modules.php +++ b/htdocs/core/modules/mailings/contacts1.modules.php @@ -138,9 +138,8 @@ class mailing_contacts1 extends MailingTargets $sql .= " ORDER BY sp.poste"; $resql = $this->db->query($sql); - $s .= $langs->trans("PostOrFunction").' '; - $s .= ''; + $s .= ''; if ($resql) { $num = $this->db->num_rows($resql); $i = 0; @@ -157,11 +156,10 @@ class mailing_contacts1 extends MailingTargets dol_print_error($this->db); } $s .= ''; - + $s .= ajax_combobox("filter_jobposition_contact"); $s .= ' '; // Filter on contact category - $s .= $langs->trans("ContactCategoriesShort").' '; $sql = "SELECT c.label, count(distinct(sp.email)) AS nb"; $sql .= " FROM "; $sql .= " ".MAIN_DB_PREFIX."socpeople as sp,"; @@ -176,8 +174,8 @@ class mailing_contacts1 extends MailingTargets $sql .= " ORDER BY c.label"; $resql = $this->db->query($sql); - $s .= ''; + $s .= ''; if ($resql) { $num = $this->db->num_rows($resql); if ($num) { @@ -194,12 +192,11 @@ class mailing_contacts1 extends MailingTargets dol_print_error($this->db); } $s .= ''; - + $s .= ajax_combobox("filter_category_contact"); $s .= '
'; // Add prospect of a particular level - $s .= $langs->trans("NatureOfThirdParty").' '; - $s .= ''; $sql = "SELECT code, label"; $sql .= " FROM ".MAIN_DB_PREFIX."c_prospectlevel"; $sql .= " WHERE active > 0"; @@ -208,9 +205,9 @@ class mailing_contacts1 extends MailingTargets if ($resql) { $num = $this->db->num_rows($resql); if ($num) { - $s .= ''; + $s .= ''; } else { - $s .= ''; + $s .= ''; } $s .= ''; @@ -231,11 +228,11 @@ class mailing_contacts1 extends MailingTargets //$s.=''; $s .= ''; $s .= ''; + $s .= ajax_combobox("filter_contact"); $s .= ' '; // Filter on thirdparty category - $s .= $langs->trans("CustomersProspectsCategoriesShort").' '; $sql = "SELECT c.label, count(distinct(sp.email)) AS nb"; $sql .= " FROM "; $sql .= " ".MAIN_DB_PREFIX."socpeople as sp,"; @@ -250,8 +247,8 @@ class mailing_contacts1 extends MailingTargets $sql .= " ORDER BY c.label"; $resql = $this->db->query($sql); - $s .= ''; + $s .= ''; if ($resql) { $num = $this->db->num_rows($resql); if ($num) { @@ -268,11 +265,11 @@ class mailing_contacts1 extends MailingTargets dol_print_error($this->db); } $s .= ''; + $s .= ajax_combobox("filter_category_customer_contact"); $s .= ' '; // Filter on thirdparty category - $s .= $langs->trans("SuppliersCategoriesShort").' '; $sql = "SELECT c.label, count(distinct(sp.email)) AS nb"; $sql .= " FROM "; $sql .= " ".MAIN_DB_PREFIX."socpeople as sp,"; @@ -287,8 +284,8 @@ class mailing_contacts1 extends MailingTargets $sql .= " ORDER BY c.label"; $resql = $this->db->query($sql); - $s .= ''; + $s .= ''; if ($resql) { $num = $this->db->num_rows($resql); if ($num) { @@ -305,7 +302,7 @@ class mailing_contacts1 extends MailingTargets dol_print_error($this->db); } $s .= ''; - + $s .= ajax_combobox("filter_category_supplier_contact"); return $s; } @@ -366,22 +363,16 @@ class mailing_contacts1 extends MailingTargets $sql .= " s.nom as companyname"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = sp.fk_soc"; - if ($filter_category <> 'all') { + if ($filter_category != 'all' && $filter_category != '-1') { $sql .= ", ".MAIN_DB_PREFIX."categorie as c"; - } - if ($filter_category <> 'all') { $sql .= ", ".MAIN_DB_PREFIX."categorie_contact as cs"; } - if ($filter_category_customer <> 'all') { + if ($filter_category_customer != 'all' && $filter_category_customer != '-1') { $sql .= ", ".MAIN_DB_PREFIX."categorie as c2"; - } - if ($filter_category_customer <> 'all') { $sql .= ", ".MAIN_DB_PREFIX."categorie_societe as c2s"; } - if ($filter_category_supplier <> 'all') { + if ($filter_category_supplier != 'all' && $filter_category_supplier != '-1') { $sql .= ", ".MAIN_DB_PREFIX."categorie as c3"; - } - if ($filter_category_supplier <> 'all') { $sql .= ", ".MAIN_DB_PREFIX."categorie_fournisseur as c3s"; } $sql .= " WHERE sp.entity IN (".getEntity('socpeople').")"; @@ -391,34 +382,28 @@ class mailing_contacts1 extends MailingTargets $sql .= " AND sp.statut = 1"; $sql .= " AND sp.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".((int) $mailing_id).")"; // Filter on category - if ($filter_category <> 'all') { + if ($filter_category != 'all' && $filter_category != '-1') { $sql .= " AND cs.fk_categorie = c.rowid AND cs.fk_socpeople = sp.rowid"; - } - if ($filter_category <> 'all') { $sql .= " AND c.label = '".$this->db->escape($filter_category)."'"; } - if ($filter_category_customer <> 'all') { + if ($filter_category_customer != 'all' && $filter_category_customer != '-1') { $sql .= " AND c2s.fk_categorie = c2.rowid AND c2s.fk_soc = sp.fk_soc"; - } - if ($filter_category_customer <> 'all') { $sql .= " AND c2.label = '".$this->db->escape($filter_category_customer)."'"; } - if ($filter_category_supplier <> 'all') { + if ($filter_category_supplier != 'all' && $filter_category_supplier != '-1') { $sql .= " AND c3s.fk_categorie = c3.rowid AND c3s.fk_soc = sp.fk_soc"; - } - if ($filter_category_supplier <> 'all') { $sql .= " AND c3.label = '".$this->db->escape($filter_category_supplier)."'"; } // Filter on nature $key = $filter; - { - //print "xx".$key; + + //print "xx".$key; if ($key == 'prospects') { $sql .= " AND s.client=2"; } foreach ($prospectlevel as $codelevel => $valuelevel) { if ($key == 'prospectslevel'.$codelevel) { - $sql .= " AND s.fk_prospectlevel='".$this->db->escape($codelevel)."'"; + $sql .= " AND s.fk_prospectlevel = '".$this->db->escape($codelevel)."'"; } } if ($key == 'customers') { @@ -427,17 +412,18 @@ class mailing_contacts1 extends MailingTargets if ($key == 'suppliers') { $sql .= " AND s.fournisseur=1"; } - } + // Filter on job position - $key = $filter_jobposition; - if (!empty($key) && $key != 'all') { - $sql .= " AND sp.poste ='".$this->db->escape($key)."'"; + $key = $filter_jobposition; + if (!empty($key) && $key != 'all' && $key != '-1') { + $sql .= " AND sp.poste = '".$this->db->escape($key)."'"; } - $sql .= " ORDER BY sp.email"; + + $sql .= " ORDER BY sp.email"; //print "wwwwwwx".$sql; // Stocke destinataires dans cibles - $result = $this->db->query($sql); + $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); $i = 0; diff --git a/htdocs/core/modules/mailings/fraise.modules.php b/htdocs/core/modules/mailings/fraise.modules.php index 09445264dc7..aa7c218417b 100644 --- a/htdocs/core/modules/mailings/fraise.modules.php +++ b/htdocs/core/modules/mailings/fraise.modules.php @@ -123,16 +123,16 @@ class mailing_fraise extends MailingTargets $s = ''; // Status - $s .= $langs->trans("Status").': '; - $s .= ''; + $s .= ''; + $s .= ''; $s .= ''; $s .= ''; $s .= ''; $s .= ' '; - $s .= $langs->trans("Type").': '; - $s .= ''; $sql = "SELECT rowid, libelle as label, statut"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type"; $sql .= " WHERE entity IN (".getEntity('member_type').")"; @@ -141,7 +141,7 @@ class mailing_fraise extends MailingTargets if ($resql) { $num = $this->db->num_rows($resql); - $s .= ''; + $s .= ''; if (!$num) { $s .= ''; } @@ -154,16 +154,17 @@ class mailing_fraise extends MailingTargets $s .= ''; $i++; } + $s .= ajax_combobox("filter_type"); } else { dol_print_error($this->db); } $s .= ''; + $s .= ajax_combobox("filter_type_fraise"); $s .= ' '; - $s .= $langs->trans("Category").': '; - $s .= ''; // Show categories $sql = "SELECT rowid, label, type, visible"; @@ -178,7 +179,7 @@ class mailing_fraise extends MailingTargets if ($resql) { $num = $this->db->num_rows($resql); - $s .= ''; + $s .= ''; if (!$num) { $s .= ''; } @@ -191,6 +192,7 @@ class mailing_fraise extends MailingTargets $s .= ''; $i++; } + $s .= ajax_combobox("filter_category_fraise"); } else { dol_print_error($this->db); } @@ -246,7 +248,7 @@ class mailing_fraise extends MailingTargets $sql .= " a.lastname, a.firstname,"; $sql .= " a.datefin, a.civility as civility_id, a.login, a.societe"; // Other fields $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a"; - if (GETPOST('filter_category')) { + if (GETPOST('filter_category', 'int') > 0) { $sql .= " INNER JOIN ".MAIN_DB_PREFIX."categorie_member as cm ON cm.fk_member = a.rowid"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."categorie as c ON c.rowid = cm.fk_categorie AND c.rowid = ".((int) GETPOST('filter_category', 'int')); } @@ -254,16 +256,13 @@ class mailing_fraise extends MailingTargets $sql .= " WHERE a.entity IN (".getEntity('member').") AND a.email <> ''"; // Note that null != '' is false $sql .= " AND a.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".((int) $mailing_id).")"; // Filter on status - if (GETPOST("filter") == '-1') { - $sql .= " AND a.statut=-1"; - } - if (GETPOST("filter", 'aZ09') == '1a') { + if (GETPOST("filter", 'aZ09') == 'draft') { + $sql .= " AND a.statut = -1"; + } elseif (GETPOST("filter", 'aZ09') == '1a') { $sql .= " AND a.statut=1 AND (a.datefin >= '".$this->db->idate($now)."' OR ta.subscription = 0)"; - } - if (GETPOST("filter", 'aZ09') == '1b') { + } elseif (GETPOST("filter", 'aZ09') == '1b') { $sql .= " AND a.statut=1 AND ((a.datefin IS NULL or a.datefin < '".$this->db->idate($now)."') AND ta.subscription = 1)"; - } - if (GETPOST("filter", 'aZ09') === '0') { + } elseif (GETPOST("filter", 'aZ09') === '0') { $sql .= " AND a.statut=0"; } // Filter on date @@ -276,7 +275,7 @@ class mailing_fraise extends MailingTargets $sql .= " AND a.fk_adherent_type = ta.rowid"; // Filter on type if (GETPOST('filter_type', 'int') > 0) { - $sql .= " AND ta.rowid='".$this->db->escape(GETPOST('filter_type', 'int'))."'"; + $sql .= " AND ta.rowid = ".((int) GETPOST('filter_type', 'int')); } $sql .= " ORDER BY a.email"; //print $sql; diff --git a/htdocs/core/modules/mailings/partnership.modules.php b/htdocs/core/modules/mailings/partnership.modules.php new file mode 100644 index 00000000000..b41a5e04c85 --- /dev/null +++ b/htdocs/core/modules/mailings/partnership.modules.php @@ -0,0 +1,264 @@ + + * Copyright (C) 2005-2010 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * + * This file is an example to follow to add your own email selector inside + * the Dolibarr email tool. + * Follow instructions given in README file to know what to change to build + * your own emailing list selector. + * Code that need to be changed in this file are marked by "CHANGE THIS" tag. + */ + +/** + * \file htdocs/core/modules/mailings/partnership.modules.php + * \ingroup mailing + * \brief Example file to provide a list of recipients for mailing module + */ + +include_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php'; + + +/** + * Class to manage a list of personalised recipients for mailing feature + */ +class mailing_partnership extends MailingTargets +{ + public $name = 'PartnershipThirdartiesOrMembers'; + // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found + public $desc = "Thirdparties or members included into a partnership program"; + public $require_admin = 0; + + public $require_module = array(); // This module allows to select by categories must be also enabled if category module is not activated + + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ + public $picto = 'partnership'; + + /** + * @var DoliDB Database handler. + */ + public $db; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + global $conf, $langs; + $langs->load("companies"); + + $this->db = $db; + } + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * This is the main function that returns the array of emails + * + * @param int $mailing_id Id of mailing. No need to use it. + * @return int <0 if error, number of emails added if ok + */ + public function add_to_target($mailing_id) + { + // phpcs:enable + global $conf, $langs; + + $cibles = array(); + $addDescription = ''; + + $sql = "SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact, null as firstname, pt.label as label, 'thirdparty' as source"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."partnership as p, ".MAIN_DB_PREFIX."c_partnership_type as pt"; + $sql .= " WHERE s.email <> ''"; + $sql .= " AND s.entity IN (".getEntity('societe').")"; + $sql .= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".((int) $mailing_id).")"; + $sql .= " AND p.fk_soc = s.rowid"; + $sql .= " AND pt.rowid = p.fk_type"; + if (GETPOST('filter', 'int') > 0) { + $sql .= " AND pt.rowid=".((int) GETPOST('filter', 'int')); + } + + $sql .= " UNION "; + + $sql .= "SELECT s.rowid as id, s.email as email, s.lastname as name, null as fk_contact, s.firstname as firstname, pt.label as label, 'member' as source"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as s, ".MAIN_DB_PREFIX."partnership as p, ".MAIN_DB_PREFIX."c_partnership_type as pt"; + $sql .= " WHERE s.email <> ''"; + $sql .= " AND s.entity IN (".getEntity('member').")"; + $sql .= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".((int) $mailing_id).")"; + $sql .= " AND p.fk_member = s.rowid"; + $sql .= " AND pt.rowid = p.fk_type"; + if (GETPOST('filter', 'int') > 0) { + $sql .= " AND pt.rowid=".((int) GETPOST('filter', 'int')); + } + + $sql .= " ORDER BY email"; + + // Stock recipients emails into targets table + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); + $i = 0; + $j = 0; + + dol_syslog(get_class($this)."::add_to_target mailing ".$num." targets found"); + + $old = ''; + while ($i < $num) { + $obj = $this->db->fetch_object($result); + if ($old <> $obj->email) { + $otherTxt = ($obj->label ? $langs->transnoentities("PartnershipType").'='.$obj->label : ''); + if (strlen($addDescription) > 0 && strlen($otherTxt) > 0) { + $otherTxt .= ";"; + } + $otherTxt .= $addDescription; + $cibles[$j] = array( + 'email' => $obj->email, + 'fk_contact' => $obj->fk_contact, + 'lastname' => $obj->name, // For a thirdparty, we must use name + 'firstname' => '', // For a thirdparty, lastname is '' + 'other' => $otherTxt, + 'source_url' => $this->url($obj->id, $obj->source), + 'source_id' => $obj->id, + 'source_type' => $obj->source + ); + $old = $obj->email; + $j++; + } + + $i++; + } + } else { + dol_syslog($this->db->error()); + $this->error = $this->db->error(); + return -1; + } + + return parent::addTargetsToDatabase($mailing_id, $cibles); + } + + + /** + * On the main mailing area, there is a box with statistics. + * If you want to add a line in this report you must provide an + * array of SQL request that returns two field: + * One called "label", One called "nb". + * + * @return array Array with SQL requests + */ + public function getSqlArrayForStats() + { + // CHANGE THIS: Optionnal + + //var $statssql=array(); + //$this->statssql[0]="SELECT field1 as label, count(distinct(email)) as nb FROM mytable WHERE email IS NOT NULL"; + return array(); + } + + + /** + * Return here number of distinct emails returned by your selector. + * For example if this selector is used to extract 500 different + * emails from a text file, this function must return 500. + * + * @param string $sql Requete sql de comptage + * @return int Nb of recipients + */ + public function getNbOfRecipients($sql = '') + { + global $conf; + + $sql = "SELECT count(distinct(s.email)) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."partnership as p, ".MAIN_DB_PREFIX."societe as s"; + $sql .= " WHERE s.rowid = p.fk_soc AND s.email <> ''"; + $sql .= " AND s.entity IN (".getEntity('societe').")"; + + $sql .= " UNION "; + + $sql .= "SELECT count(distinct(s.email)) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."partnership as p, ".MAIN_DB_PREFIX."adherent as s"; + $sql .= " WHERE s.rowid = p.fk_member AND s.email <> ''"; + $sql .= " AND s.entity IN (".getEntity('member').")"; + + //print $sql; + + // La requete doit retourner un champ "nb" pour etre comprise + // par parent::getNbOfRecipients + return parent::getNbOfRecipients($sql); + } + + /** + * This is to add a form filter to provide variant of selector + * If used, the HTML select must be called "filter" + * + * @return string A html select zone + */ + public function formFilter() + { + global $conf, $langs; + + $langs->load("companies"); + + $s = ' '; + + return $s; + } + + + /** + * Can include an URL link on each record provided by selector shown on target page. + * + * @param int $id ID + * @param string $sourcetype Source type + * @return string Url link + */ + public function url($id, $sourcetype = 'thirdparty') + { + if ($sourcetype == 'thirparty') { + return ''.img_object('', "societe").''; + } + if ($sourcetype == 'member') { + return ''.img_object('', "member").''; + } + + return ''; + } +} diff --git a/htdocs/core/modules/mailings/pomme.modules.php b/htdocs/core/modules/mailings/pomme.modules.php index 6880452a416..56d62449bcf 100644 --- a/htdocs/core/modules/mailings/pomme.modules.php +++ b/htdocs/core/modules/mailings/pomme.modules.php @@ -119,20 +119,20 @@ class mailing_pomme extends MailingTargets $langs->load("users"); $s = ''; - $s .= $langs->trans("Status").' '; - $s .= ''; + $s .= ''; $s .= ''; $s .= ''; $s .= ''; + $s .= ajax_combobox("filter_pomme"); $s .= ' '; - $s .= $langs->trans("Employee").' '; - $s .= ''; + $s .= ''; $s .= ''; $s .= ''; $s .= ''; + $s .= ajax_combobox("filteremployee_pomme"); return $s; } diff --git a/htdocs/core/modules/mailings/thirdparties.modules.php b/htdocs/core/modules/mailings/thirdparties.modules.php index ae26dfc19fd..8550440d5d1 100644 --- a/htdocs/core/modules/mailings/thirdparties.modules.php +++ b/htdocs/core/modules/mailings/thirdparties.modules.php @@ -115,7 +115,9 @@ class mailing_thirdparties extends MailingTargets $sql .= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".((int) $mailing_id).")"; $sql .= " AND cs.fk_soc = s.rowid"; $sql .= " AND c.rowid = cs.fk_categorie"; - $sql .= " AND c.rowid=".((int) GETPOST('filter', 'int')); + if (GETPOST('filter', 'int') > 0) { + $sql .= " AND c.rowid=".((int) GETPOST('filter', 'int')); + } $sql .= $addFilter; $sql .= " UNION "; $sql .= "SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact, null as firstname, c.label as label"; @@ -125,7 +127,9 @@ class mailing_thirdparties extends MailingTargets $sql .= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".((int) $mailing_id).")"; $sql .= " AND cs.fk_soc = s.rowid"; $sql .= " AND c.rowid = cs.fk_categorie"; - $sql .= " AND c.rowid=".((int) GETPOST('filter', 'int')); + if (GETPOST('filter', 'int') > 0) { + $sql .= " AND c.rowid=".((int) GETPOST('filter', 'int')); + } $sql .= $addFilter; } $sql .= " ORDER BY email"; @@ -206,7 +210,7 @@ class mailing_thirdparties extends MailingTargets $sql = "SELECT count(distinct(s.email)) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= " WHERE s.email != ''"; + $sql .= " WHERE s.email <> ''"; $sql .= " AND s.entity IN (".getEntity('societe').")"; // La requete doit retourner un champ "nb" pour etre comprise @@ -226,8 +230,7 @@ class mailing_thirdparties extends MailingTargets $langs->load("companies"); - $s = $langs->trans("Categories").' '; - $s .= ''; // Show categories $sql = "SELECT rowid, label, type, visible"; @@ -247,7 +250,7 @@ class mailing_thirdparties extends MailingTargets } if ($num) { - $s .= ''; + $s .= ''; } else { $s .= ''; } @@ -270,14 +273,15 @@ class mailing_thirdparties extends MailingTargets $s .= ''; $i++; } + $s .= ajax_combobox("filter_thirdparties"); } else { dol_print_error($this->db); } $s .= ' '; - $s .= $langs->trans('ProspectCustomer'); - $s .= ' '; + $s .= ''; if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) { $s .= ''; } @@ -290,13 +294,14 @@ class mailing_thirdparties extends MailingTargets $s .= ''; $s .= ' '; + $s .= ajax_combobox("filter_client_thirdparties"); - $s .= $langs->trans("Status"); - $s .= ' '; + $s .= ''; + $s .= ''; $s .= ''; $s .= ''; + $s .= ajax_combobox("filter_status_thirdparties"); return $s; } diff --git a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php index 4c848b69ac0..09f4cf76ae6 100644 --- a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php +++ b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php @@ -215,10 +215,9 @@ class mailing_thirdparties_services_expired extends MailingTargets { global $langs; - $s = $langs->trans("ProductOrService"); - $s .= ''; if (count($this->arrayofproducts)) { - $s .= ''; + $s .= ''; } else { $s .= ''; } @@ -226,6 +225,7 @@ class mailing_thirdparties_services_expired extends MailingTargets $s .= ''; } $s .= ''; + $s .= ajax_combobox("filter_services_expired"); return $s; } diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index 4981dde2b45..39cf2da2b2f 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -106,7 +106,7 @@ class Partnership extends CommonObject 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>4, 'noteditable'=>'1', 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of object"), 'entity' => array('type' => 'integer', 'label' => 'Entity', 'default' => 1, 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 15, 'index' => 1), - 'fk_type' => array('type' => 'integer:PartnershipType:partnership/class/partnership_type.class.php', 'label' => 'Type', 'enabled' => 1, 'visible' => 1, 'position' => 20), + 'fk_type' => array('type' => 'integer:PartnershipType:partnership/class/partnership_type.class.php', 'label' => 'Type', 'notnull'=>1, 'enabled' => 1, 'visible' => 1, 'position' => 20), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), @@ -245,6 +245,11 @@ class Partnership extends CommonObject */ public function create(User $user, $notrigger = false) { + if ($this->fk_soc <= 0 && $this->fk_member <= 0) { + $this->error[] = "ErrorThirpdartyOrMemberidIsManadatory"; + return -1; + } + $this->status = 0; return $this->createCommon($user, $notrigger); } @@ -547,6 +552,11 @@ class Partnership extends CommonObject */ public function update(User $user, $notrigger = false) { + if ($this->fk_soc <= 0 && $this->fk_member <= 0) { + $this->error[] = "ErrorThirpdartyOrMemberidIsManadatory"; + return -1; + } + return $this->updateCommon($user, $notrigger); } From f9cb2092620326c6987da53f29ab3cb222d5936c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 31 Jan 2022 12:18:04 +0100 Subject: [PATCH 03/14] Fix max nb of lines in supplier index page --- htdocs/fourn/facture/index.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/htdocs/fourn/facture/index.php b/htdocs/fourn/facture/index.php index 21d3e4cfa58..9546d434bb9 100644 --- a/htdocs/fourn/facture/index.php +++ b/htdocs/fourn/facture/index.php @@ -27,9 +27,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; -// Security check -restrictedArea($user, 'fournisseur', 0, '', 'facture'); - // Load translation files required by the page $langs->loadLangs(['bills', 'boxes']); @@ -47,9 +44,21 @@ $maxDraftCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->glob $maxLatestEditCount = 5; $maxOpenCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD; +// Security check +restrictedArea($user, 'fournisseur', 0, '', 'facture'); + + /* -* View -*/ + * Actions + */ + +// None + + + +/* + * View + */ llxHeader("", $langs->trans("SupplierInvoicesArea"), 'EN:Suppliers_Invoices|FR:FactureFournisseur|ES:Facturas_de_proveedores'); @@ -64,7 +73,7 @@ if ($tmp) { print '
'; } -$tmp = getDraftSupplierTable($maxDraftCount, $socid); +$tmp = getDraftSupplierTable($max, $socid); if ($tmp) { print $tmp; print '
'; From 3a40078149ec9e939e6ce9a8dd10d3edaad19e3a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 31 Jan 2022 14:03:40 +0100 Subject: [PATCH 04/14] Fix length of list --- htdocs/compta/facture/index.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/facture/index.php b/htdocs/compta/facture/index.php index 0a526e39e1e..1821d4720af 100644 --- a/htdocs/compta/facture/index.php +++ b/htdocs/compta/facture/index.php @@ -43,9 +43,8 @@ if (isset($user->socid) && $user->socid > 0) { $max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; // Maximum elements of the tables -$maxDraftCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD; -$maxLatestEditCount = 5; -$maxOpenCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD; +$maxDraftCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? $max : $conf->global->MAIN_MAXLIST_OVERLOAD; +$maxOpenCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? $max : $conf->global->MAIN_MAXLIST_OVERLOAD; /* @@ -64,7 +63,7 @@ if ($tmp) { print $tmp; print '
'; } -$tmp = getCustomerInvoiceDraftTable($max, $socid); +$tmp = getCustomerInvoiceDraftTable($maxDraftCount, $socid); if ($tmp) { print $tmp; print '
'; @@ -74,13 +73,13 @@ print ''; print '
'; -$tmp = getCustomerInvoiceLatestEditTable($maxLatestEditCount, $socid); +$tmp = getCustomerInvoiceLatestEditTable($max, $socid); if ($tmp) { print $tmp; print '
'; } -$tmp = getCustomerInvoiceUnpaidOpenTable($max, $socid); +$tmp = getCustomerInvoiceUnpaidOpenTable($maxOpenCount, $socid); if ($tmp) { print $tmp; print '
'; From 3b8ece6c0bbfe19312808a59569855af08591d5b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 31 Jan 2022 21:46:35 +0100 Subject: [PATCH 05/14] Fix php8 --- htdocs/product/class/product.class.php | 7 ++++--- test/phpunit/ProductTest.php | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 26bf4915d80..f6a201108ad 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -874,9 +874,10 @@ class Product extends CommonObject $arrayofnonnegativevalue = array('weight'=>'Weight', 'width'=>'Width', 'height'=>'Height', 'length'=>'Length', 'surface'=>'Surface', 'volume'=>'Volume'); foreach ($arrayofnonnegativevalue as $key => $value) { - if (property_exists($this, $key) && $this->$key < 0) { - $langs->load("other"); - $this->errors[] = $langs->trans("FieldCannotBeNegative", $langs->transnoentitiesnoconv($value)); + if (property_exists($this, $key) && !empty($this->$key) && ($this->$key < 0)) { + $langs->loadLangs(array("main", "other")); + $this->error = $langs->trans("FieldCannotBeNegative", $langs->transnoentitiesnoconv($value)); + $this->errors[] = $this->error; $result = -4; } } diff --git a/test/phpunit/ProductTest.php b/test/phpunit/ProductTest.php index 7eb6de57c02..90dfab3fe04 100644 --- a/test/phpunit/ProductTest.php +++ b/test/phpunit/ProductTest.php @@ -199,7 +199,7 @@ class ProductTest extends PHPUnit\Framework\TestCase $localobject->note_private = 'New private note after update'; $result=$localobject->update($localobject->id, $user); print __METHOD__." id=".$localobject->id." result=".$result."\n"; - $this->assertLessThan($result, 0); + $this->assertLessThan($result, 0, 'Error '.$localobject->error); return $localobject; } From 9db0b7d0ef19580855c85537e817eb7a4ca411ea Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 Feb 2022 11:57:33 +0100 Subject: [PATCH 06/14] Fix look and feel v15 --- htdocs/admin/mails_templates.php | 48 ++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 6ad1cdc6974..fb3a1ccf702 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -246,11 +246,14 @@ if ($reshook == 0) { } } +$permissiontoadd = 1; + //asort($elementList); $id = 25; + /* * Actions */ @@ -338,6 +341,7 @@ if (empty($reshook)) { } setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); + $action = 'add'; } } @@ -411,6 +415,7 @@ if (empty($reshook)) { } else { dol_print_error($db); } + $action = 'add'; } } @@ -489,6 +494,7 @@ if (empty($reshook)) { setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); } else { setEventMessages($db->error(), null, 'errors'); + $action = 'edit'; } } } @@ -515,7 +521,7 @@ if (empty($reshook)) { if ($action == $acts[0]) { $rowidcol = "rowid"; - $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."=".((int) $rowid); + $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE rowid = ".((int) $rowid); $result = $db->query($sql); if (!$result) { @@ -527,7 +533,7 @@ if (empty($reshook)) { if ($action == $acts[1]) { $rowidcol = "rowid"; - $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."=".((int) $rowid); + $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE rowid = ".((int) $rowid); $result = $db->query($sql); if (!$result) { @@ -545,18 +551,38 @@ $form = new Form($db); $formadmin = new FormAdmin($db); $help_url = ''; -$title = $langs->trans("EMailsSetup"); +if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) { + $title = $langs->trans("EMailsSetup"); +} else { + $title = $langs->trans("EMailsTemplates"); +} llxHeader('', $title, $help_url); $linkback = ''; $titlepicto = 'title_setup'; -print load_fiche_titre($title, $linkback, $titlepicto); -$head = email_admin_prepare_head(); +$url = DOL_URL_ROOT.'/admin/mails_templates.php?action=add'; +$newcardbutton = dolGetButtonTitle($langs->trans('NewEMailTemplate'), '', 'fa fa-plus-circle', $url, '', $permissiontoadd); + + +if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) { + print load_fiche_titre($title, '', $titlepicto); +} else { + print load_fiche_titre($title, $newcardbutton, $titlepicto); +} + +if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) { + $head = email_admin_prepare_head(); + + print dol_get_fiche_head($head, 'templates', '', -1); + + if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) { + print load_fiche_titre('', $newcardbutton, ''); + } +} -print dol_get_fiche_head($head, 'templates', '', -1); // Confirmation de la suppression de la ligne if ($action == 'delete') { @@ -599,7 +625,7 @@ $sql .= $db->plimit($listlimit + 1, $offset); $fieldlist = explode(',', $tabfield[$id]); -if ($action == 'view') { +if ($action == 'add') { // Form to add a new line print '
'; print ''; @@ -750,7 +776,8 @@ if ($action == 'view') { if ($tmpfieldlist == 'topic') { print '
'; } @@ -1142,7 +1169,10 @@ print ''; print ''; -print dol_get_fiche_end(); +if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) { + print dol_get_fiche_end(); +} + // End of page llxFooter(); From 6ddc4ba3a0e7fe64f488b05a402662d02790d5fc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 Feb 2022 13:23:52 +0100 Subject: [PATCH 07/14] Fix bad value for total VAT on PDF --- htdocs/core/modules/commande/doc/pdf_einstein.modules.php | 2 +- htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php | 2 +- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 4 ++-- htdocs/core/modules/facture/doc/pdf_sponge.modules.php | 4 ++-- htdocs/core/modules/propale/doc/pdf_azur.modules.php | 2 +- htdocs/core/modules/propale/doc/pdf_cyan.modules.php | 2 +- htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php | 2 +- .../core/modules/supplier_order/doc/pdf_muscadet.modules.php | 2 +- .../core/modules/supplier_proposal/doc/pdf_aurore.modules.php | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 0ed0134a944..20d38ed3805 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -575,7 +575,7 @@ class pdf_einstein extends ModelePDFCommandes } $this->tva[$vatrate] += $tvaligne; $vatcode = $object->lines[$i]->vat_src_code; - $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne); // Add line if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) { diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index a901a23cc69..5cf7ce6645b 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -800,7 +800,7 @@ class pdf_eratosthene extends ModelePDFCommandes } $this->tva[$vatrate] += $tvaligne; $vatcode = $object->lines[$i]->vat_src_code; - $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne); // Add line if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) { diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index be42ab002d5..b1ab0f671b9 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -749,9 +749,9 @@ class pdf_crabe extends ModelePDFFactures if (!isset($this->tva[$vatrate])) { $this->tva[$vatrate] = 0; } - $this->tva[$vatrate] += $tvaligne; + $this->tva[$vatrate] += $tvaligne; // ->tva is abandonned, we use now ->tva_array that is more complete $vatcode = $object->lines[$i]->vat_src_code; - $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne); if ($posYAfterImage > $posYAfterDescription) { $nexY = $posYAfterImage; diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 2def31cbf30..c1413a103f8 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -887,9 +887,9 @@ class pdf_sponge extends ModelePDFFactures if (!isset($this->tva[$vatrate])) { $this->tva[$vatrate] = 0; } - $this->tva[$vatrate] += $tvaligne; + $this->tva[$vatrate] += $tvaligne; // ->tva is abandonned, we use now ->tva_array that is more complete $vatcode = $object->lines[$i]->vat_src_code; - $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne); $nexY = max($nexY, $posYAfterImage); diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index ea2ea8add99..5e5a8ded7c5 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -685,7 +685,7 @@ class pdf_azur extends ModelePDFPropales } $this->tva[$vatrate] += $tvaligne; $vatcode = $object->lines[$i]->vat_src_code; - $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne); if ($posYAfterImage > $posYAfterDescription) { $nexY = $posYAfterImage; diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 9963ecd9527..01cc1eebc9f 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -810,7 +810,7 @@ class pdf_cyan extends ModelePDFPropales } $this->tva[$vatrate] += $tvaligne; $vatcode = $object->lines[$i]->vat_src_code; - $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne); if ($posYAfterImage > $posYAfterDescription) { $nexY = max($nexY, $posYAfterImage); diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index 59f4067cf31..f844a5fad55 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -746,7 +746,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders } $this->tva[$vatrate] += $tvaligne; $vatcode = $object->lines[$i]->vat_src_code; - $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne); if ($posYAfterImage > $posYAfterDescription) { $nexY = $posYAfterImage; diff --git a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php index 3f7e6181913..d5003c4b806 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php @@ -625,7 +625,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders } $this->tva[$vatrate] += $tvaligne; $vatcode = $object->lines[$i]->vat_src_code; - $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne); if ($posYAfterImage > $posYAfterDescription) { $nexY = $posYAfterImage; diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 7539d89167b..4a8598a4d4d 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -619,7 +619,7 @@ class pdf_aurore extends ModelePDFSupplierProposal } $this->tva[$vatrate] += $tvaligne; $vatcode = $object->lines[$i]->vat_src_code; - $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne); if ($posYAfterImage > $posYAfterDescription) { $nexY = $posYAfterImage; From 89a06014da90f9ee653c047794ff954345e68797 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 Feb 2022 15:55:04 +0100 Subject: [PATCH 08/14] Fix warnings --- htdocs/core/lib/functions2.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index fe6e8e0fa40..3a0b077be6b 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1368,6 +1368,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ $numFinal = $ref; } elseif ($mode == 'next') { $counter++; + $maskrefclient_counter = 0; // If value for $counter has a length higher than $maskcounter chars if ($counter >= pow(10, dol_strlen($maskcounter))) { @@ -1398,7 +1399,6 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ $maskrefclient_maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'), $maskrefclient_clientcode.str_pad("", dol_strlen($maskrefclient_maskcounter), "_"), $maskrefclient_maskLike); // Get counter in database - $maskrefclient_counter = 0; $maskrefclient_sql = "SELECT MAX(".$maskrefclient_sqlstring.") as val"; $maskrefclient_sql .= " FROM ".MAIN_DB_PREFIX.$table; //$sql.= " WHERE ".$field." not like '(%'"; From 1ca1f111b3a11f6373aac1483f46bf1d73328dad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 Feb 2022 16:12:51 +0100 Subject: [PATCH 09/14] Fix warnings --- htdocs/core/class/commoninvoice.class.php | 2 +- htdocs/core/modules/commande/doc/pdf_einstein.modules.php | 3 +++ .../core/modules/commande/doc/pdf_eratosthene.modules.php | 5 ++++- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 3 +++ htdocs/core/modules/facture/doc/pdf_sponge.modules.php | 5 ++++- htdocs/core/modules/propale/doc/pdf_azur.modules.php | 6 +++++- htdocs/core/modules/propale/doc/pdf_cyan.modules.php | 5 ++++- .../core/modules/supplier_order/doc/pdf_cornas.modules.php | 3 +++ .../modules/supplier_order/doc/pdf_muscadet.modules.php | 3 +++ .../modules/supplier_proposal/doc/pdf_aurore.modules.php | 3 +++ 10 files changed, 33 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 74ff2141820..6043814dc45 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -857,7 +857,7 @@ abstract class CommonInvoice extends CommonObject // Using TLV format $s = pack('C1', 1).pack('C1', strlen($this->thirdparty->name)).$this->thirdparty->name; $s .= pack('C1', 2).pack('C1', strlen($this->thirdparty->tva_intra)).$this->thirdparty->tva_intra; - $s .= pack('C1', 3).pack('C1', strlen($datestring)).$date; + $s .= pack('C1', 3).pack('C1', strlen($datestring)).$this->date; $s .= pack('C1', 4).pack('C1', strlen($pricewithtaxstring)).$pricewithtaxstring; $s .= pack('C1', 5).pack('C1', strlen($pricetaxstring)).$pricetaxstring; $s .= ''; // Hash of xml invoice diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 20d38ed3805..db961962ba6 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -575,6 +575,9 @@ class pdf_einstein extends ModelePDFCommandes } $this->tva[$vatrate] += $tvaligne; $vatcode = $object->lines[$i]->vat_src_code; + if (empty($this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'])) { + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] = 0; + } $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne); // Add line diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 5cf7ce6645b..210ef249ac2 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -259,7 +259,7 @@ class pdf_eratosthene extends ModelePDFCommandes $arephoto = false; foreach ($pdir as $midir) { if (!$arephoto) { - if ($conf->product->entity != $objphoto->entity) { + if ($conf->entity != $objphoto->entity) { $dir = $conf->product->multidir_output[$objphoto->entity].'/'.$midir; //Check repertories of current entities } else { $dir = $conf->product->dir_output.'/'.$midir; //Check repertory of the current product @@ -800,6 +800,9 @@ class pdf_eratosthene extends ModelePDFCommandes } $this->tva[$vatrate] += $tvaligne; $vatcode = $object->lines[$i]->vat_src_code; + if (empty($this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'])) { + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] = 0; + } $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne); // Add line diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index b1ab0f671b9..b9ceb3e346b 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -751,6 +751,9 @@ class pdf_crabe extends ModelePDFFactures } $this->tva[$vatrate] += $tvaligne; // ->tva is abandonned, we use now ->tva_array that is more complete $vatcode = $object->lines[$i]->vat_src_code; + if (empty($this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'])) { + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] = 0; + } $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne); if ($posYAfterImage > $posYAfterDescription) { diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index c1413a103f8..c1666545891 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -265,7 +265,7 @@ class pdf_sponge extends ModelePDFFactures $arephoto = false; foreach ($pdir as $midir) { if (!$arephoto) { - if ($conf->product->entity != $objphoto->entity) { + if ($conf->entity != $objphoto->entity) { $dir = $conf->product->multidir_output[$objphoto->entity].'/'.$midir; //Check repertories of current entities } else { $dir = $conf->product->dir_output.'/'.$midir; //Check repertory of the current product @@ -889,6 +889,9 @@ class pdf_sponge extends ModelePDFFactures } $this->tva[$vatrate] += $tvaligne; // ->tva is abandonned, we use now ->tva_array that is more complete $vatcode = $object->lines[$i]->vat_src_code; + if (empty($this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'])) { + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] = 0; + } $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne); $nexY = max($nexY, $posYAfterImage); diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 5e5a8ded7c5..0e30ec96e44 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -266,9 +266,10 @@ class pdf_azur extends ModelePDFPropales } $arephoto = false; + $realpath = ''; foreach ($pdir as $midir) { if (!$arephoto) { - if ($conf->product->entity != $objphoto->entity) { + if ($conf->entity != $objphoto->entity) { $dir = $conf->product->multidir_output[$objphoto->entity].'/'.$midir; //Check repertories of current entities } else { $dir = $conf->product->dir_output.'/'.$midir; //Check repertory of the current product @@ -685,6 +686,9 @@ class pdf_azur extends ModelePDFPropales } $this->tva[$vatrate] += $tvaligne; $vatcode = $object->lines[$i]->vat_src_code; + if (empty($this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'])) { + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] = 0; + } $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne); if ($posYAfterImage > $posYAfterDescription) { diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 01cc1eebc9f..86e311b1306 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -255,7 +255,7 @@ class pdf_cyan extends ModelePDFPropales $arephoto = false; foreach ($pdir as $midir) { if (!$arephoto) { - if ($conf->product->entity != $objphoto->entity) { + if ($conf->entity != $objphoto->entity) { $dir = $conf->product->multidir_output[$objphoto->entity].'/'.$midir; //Check repertories of current entities } else { $dir = $conf->product->dir_output.'/'.$midir; //Check repertory of the current product @@ -810,6 +810,9 @@ class pdf_cyan extends ModelePDFPropales } $this->tva[$vatrate] += $tvaligne; $vatcode = $object->lines[$i]->vat_src_code; + if (empty($this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'])) { + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] = 0; + } $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne); if ($posYAfterImage > $posYAfterDescription) { diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index f844a5fad55..5fcd0ee20de 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -746,6 +746,9 @@ class pdf_cornas extends ModelePDFSuppliersOrders } $this->tva[$vatrate] += $tvaligne; $vatcode = $object->lines[$i]->vat_src_code; + if (empty($this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'])) { + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] = 0; + } $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne); if ($posYAfterImage > $posYAfterDescription) { diff --git a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php index d5003c4b806..11ae04993eb 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php @@ -625,6 +625,9 @@ class pdf_muscadet extends ModelePDFSuppliersOrders } $this->tva[$vatrate] += $tvaligne; $vatcode = $object->lines[$i]->vat_src_code; + if (empty($this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'])) { + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] = 0; + } $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne); if ($posYAfterImage > $posYAfterDescription) { diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 4a8598a4d4d..0c708351acc 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -619,6 +619,9 @@ class pdf_aurore extends ModelePDFSupplierProposal } $this->tva[$vatrate] += $tvaligne; $vatcode = $object->lines[$i]->vat_src_code; + if (empty($this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'])) { + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] = 0; + } $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne); if ($posYAfterImage > $posYAfterDescription) { From b55830d20557c964af7a5d2df9b5ff0d0a51eb66 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 Feb 2022 14:03:09 +0100 Subject: [PATCH 10/14] Fix missing information propagated to trigger --- htdocs/compta/facture/card.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 4e2665ceca3..da438af9e01 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1135,6 +1135,8 @@ if (empty($reshook)) { $facture_source->fetchPreviousNextSituationInvoice(); } } + + $id = $object->create($user); if ($id < 0) { $error++; @@ -1262,6 +1264,7 @@ if (empty($reshook)) { $line->multicurrency_total_tva = -$line->multicurrency_total_tva; $line->multicurrency_total_ttc = -$line->multicurrency_total_ttc; + $line->context['createcreditnotefrominvoice'] = 1; $result = $line->insert(0, 1); // When creating credit note with same lines than source, we must ignore error if discount alreayd linked $object->lines[] = $line; // insert new line in current object From 815dd74de05b4394dae7bae9fdec840b85c06e13 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 Feb 2022 14:03:09 +0100 Subject: [PATCH 11/14] Fix missing information propagated to trigger --- htdocs/compta/facture/card.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 9df6688a4e5..4230a22daaf 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1109,6 +1109,8 @@ if (empty($reshook)) { $facture_source->fetchPreviousNextSituationInvoice(); } } + + $id = $object->create($user); if ($id < 0) { $error++; @@ -1236,6 +1238,7 @@ if (empty($reshook)) { $line->multicurrency_total_tva = -$line->multicurrency_total_tva; $line->multicurrency_total_ttc = -$line->multicurrency_total_ttc; + $line->context['createcreditnotefrominvoice'] = 1; $result = $line->insert(0, 1); // When creating credit note with same lines than source, we must ignore error if discount alreayd linked $object->lines[] = $line; // insert new line in current object From 73474a1cea29a7b7aa68f38c16be912b067e2aa5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 Feb 2022 17:57:20 +0100 Subject: [PATCH 12/14] Fix css --- htdocs/contact/class/contact.class.php | 6 +-- htdocs/core/class/html.formactions.class.php | 4 +- htdocs/core/lib/company.lib.php | 45 +++++++++++--------- htdocs/core/lib/functions.lib.php | 2 +- 4 files changed, 30 insertions(+), 27 deletions(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 00cbfc4158a..bb3f2ae035d 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1389,7 +1389,7 @@ class Contact extends CommonObject * Return name of contact with link (and eventually picto) * Use $this->id, $this->lastname, $this->firstname, this->civility_id * - * @param int $withpicto Include picto with link + * @param int $withpicto Include picto with link (1=picto + name, 2=picto only, -1=photo+name, -2=photo only) * @param string $option Where the link point to * @param int $maxlen Max length of * @param string $moreparam Add more param into URL @@ -1475,14 +1475,14 @@ class Contact extends CommonObject $result .= $linkstart; if ($withpicto) { - if ($withpicto == -2) { + if ($withpicto < 0) { $result .= ''.Form::showphoto('contact', $this, 0, 0, 0, 'userphoto'.($withpicto == -3 ? 'small' : ''), 'mini', 0, 1).''; } else { $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 && $withpicto != -2) { - $result .= ($maxlen ?dol_trunc($this->getFullName($langs), $maxlen) : $this->getFullName($langs)); + $result .= ''.($maxlen ? dol_trunc($this->getFullName($langs), $maxlen) : $this->getFullName($langs)).''; } $result .= $linkend; diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index f5502426b00..457d310492c 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -359,7 +359,7 @@ class FormActions * @param string $morecss More css to add to SELECT component. * @return string */ - public function select_type_actions($selected = '', $htmlname = 'actioncode', $excludetype = '', $onlyautoornot = 0, $hideinfohelp = 0, $multiselect = 0, $nooutput = 0, $morecss = '') + public function select_type_actions($selected = '', $htmlname = 'actioncode', $excludetype = '', $onlyautoornot = 0, $hideinfohelp = 0, $multiselect = 0, $nooutput = 0, $morecss = 'minwidth300') { // phpcs:enable global $langs, $user, $form, $conf; @@ -399,7 +399,7 @@ class FormActions } $out .= $form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0); } else { - $out .= $form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth300'.($morecss ? ' '.$morecss : ''), 1); + $out .= $form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', $morecss, 1); } if ($user->admin && empty($onlyautoornot) && $hideinfohelp <= 0) { diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 2902430bf82..5ffce5748fe 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1710,7 +1710,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin $out .= ''; $out .= ''; $out .= ''; $out .= ''; $out .= ''; @@ -1782,7 +1782,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin $out .= ''; // Author of event - $out .= ''; - // Title - $out .= ''; @@ -1888,13 +1890,8 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin $out .= ''; // Contact(s) for action - if (empty($objcon->id) && isset($histo[$key]['contact_id']) && $histo[$key]['contact_id'] > 0) { - $contactstatic->lastname = $histo[$key]['lastname']; - $contactstatic->firstname = $histo[$key]['firstname']; - $contactstatic->id = $histo[$key]['contact_id']; - $out .= ''; - } elseif (isset($histo[$key]['socpeopleassigned']) && is_array($histo[$key]['socpeopleassigned']) && count($histo[$key]['socpeopleassigned']) > 0) { - $out .= ''; + } elseif (empty($objcon->id) && isset($histo[$key]['contact_id']) && $histo[$key]['contact_id'] > 0) { + $contactstatic->lastname = $histo[$key]['lastname']; + $contactstatic->firstname = $histo[$key]['firstname']; + $contactstatic->id = $histo[$key]['contact_id']; + $contactstatic->photo = $histo[$key]['contact_photo']; + $out .= ''; } else { $out .= ''; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index df7fcc0f005..9f6ac13fbb3 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4775,6 +4775,7 @@ function getTitleFieldOfList($name, $thead = 0, $file = "", $field = "", $begin if ($field1 && ($sortfield1 == $field1 || $sortfield1 == preg_replace("/^[^\.]+\./", "", $field1))) { $liste_titre = 'liste_titre_sel'; } + $out .= '<'.$tag.' class="'.$prefix.$liste_titre.'" '.$moreattrib; //$out .= (($field && empty($conf->global->MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE) && preg_match('/^[a-zA-Z_0-9\s\.\-:&;]*$/', $name)) ? ' title="'.dol_escape_htmltag($langs->trans($name)).'"' : ''); $out .= ($name && empty($conf->global->MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE) && empty($forcenowrapcolumntitle) && !dol_textishtml($name)) ? ' title="'.dol_escape_htmltag($langs->trans($name)).'"' : ''; @@ -4809,7 +4810,6 @@ function getTitleFieldOfList($name, $thead = 0, $file = "", $field = "", $begin //$out .= (empty($conf->global->MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE) ? ' title="'.dol_escape_htmltag($langs->trans($name)).'"' : ''); $out .= '>'; } - if ($tooltip) { // You can also use 'TranslationString:keyfortooltiponlick' for a tooltip on click. $tmptooltip = explode(':', $tooltip); From 0259f094bd9b909131cc47eebb60f84810f904eb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 Feb 2022 18:04:11 +0100 Subject: [PATCH 13/14] Fix trans --- htdocs/core/lib/company.lib.php | 3 +-- htdocs/langs/en_US/bills.lang | 13 +++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 5ffce5748fe..2d46ee2a239 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -201,8 +201,7 @@ function societe_prepare_head(Societe $object) $foundonexternalonlinesystem = 0; $langs->load("banks"); - //$title = $langs->trans("BankAccounts"); - $title = $langs->trans("PaymentInformation"); + $title = $langs->trans("PaymentModes"); if (!empty($conf->stripe->enabled)) { //$langs->load("stripe"); diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 4f3308a6bf4..f7d0155f41e 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -81,13 +81,14 @@ PaymentsReports=Payments reports PaymentsAlreadyDone=Payments already done PaymentsBackAlreadyDone=Refunds already done PaymentRule=Payment rule -PaymentMode=Payment Type -DefaultPaymentMode=Default Payment Type +PaymentMode=Payment method +PaymentModes=Payment methods +DefaultPaymentMode=Default Payment method DefaultBankAccount=Default Bank Account -IdPaymentMode=Payment Type (id) -CodePaymentMode=Payment Type (code) -LabelPaymentMode=Payment Type (label) -PaymentModeShort=Payment Type +IdPaymentMode=Payment method (id) +CodePaymentMode=Payment method (code) +LabelPaymentMode=Payment method (label) +PaymentModeShort=Payment method PaymentTerm=Payment Term PaymentConditions=Payment Terms PaymentConditionsShort=Payment Terms From ef62cd0b181da89ec0ff2739cc1f96265f45c5e0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 Feb 2022 18:24:30 +0100 Subject: [PATCH 14/14] css --- htdocs/core/class/html.formfile.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 3539348e35a..296ef7eb251 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1415,7 +1415,7 @@ class FormFile } else { print ''; } - print ''; + print ''; print ''; } else { print ' ';
 
'; if ($action != 'edit') { - print ''; + print '
'; + print ''; } print '
'; - $out .= $formactions->select_type_actions($actioncode, "actioncode", '', empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : -1, 0, (empty($conf->global->AGENDA_USE_MULTISELECT_TYPE) ? 0 : 1), 1); + $out .= $formactions->select_type_actions($actioncode, "actioncode", '', empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : -1, 0, (empty($conf->global->AGENDA_USE_MULTISELECT_TYPE) ? 0 : 1), 1, 'minwidth200'); $out .= ''; @@ -1741,14 +1741,14 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin } $out .= getTitleFieldOfList($tmp); } - $out .= getTitleFieldOfList($langs->trans("Ref"), 0, $_SERVER["PHP_SELF"], 'a.id', '', $param, '', $sortfield, $sortorder); - $out .= getTitleFieldOfList($langs->trans("Owner")); - $out .= getTitleFieldOfList($langs->trans("Type")); - $out .= getTitleFieldOfList($langs->trans("Label"), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); - $out .= getTitleFieldOfList($langs->trans("Date"), 0, $_SERVER["PHP_SELF"], 'a.datep,a.id', '', $param, 'align="center"', $sortfield, $sortorder); - $out .= getTitleFieldOfList($langs->trans("RelatedObjects"), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); - $out .= getTitleFieldOfList($langs->trans("ActionOnContact"), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); - $out .= getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], 'a.percent', '', $param, 'align="center"', $sortfield, $sortorder); + $out .= getTitleFieldOfList("Ref", 0, $_SERVER["PHP_SELF"], 'a.id', '', $param, '', $sortfield, $sortorder); + $out .= getTitleFieldOfList("Owner"); + $out .= getTitleFieldOfList("Type"); + $out .= getTitleFieldOfList("Label", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); + $out .= getTitleFieldOfList("Date", 0, $_SERVER["PHP_SELF"], 'a.datep,a.id', '', $param, '', $sortfield, $sortorder, 'center '); + $out .= getTitleFieldOfList("RelatedObjects", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); + $out .= getTitleFieldOfList("ActionOnContact", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'tdoverflowmax125 ', 0, '', 0); + $out .= getTitleFieldOfList("Status", 0, $_SERVER["PHP_SELF"], 'a.percent', '', $param, '', $sortfield, $sortorder, 'center '); $out .= getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'maxwidthsearch '); $out .= '
'; + $out .= ''; //$userstatic->id=$histo[$key]['userid']; //$userstatic->login=$histo[$key]['login']; //$out.=$userstatic->getLoginUrl(1); @@ -1813,25 +1813,27 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin $labeltype .= ' - '.$arraylist[$actionstatic->code]; // Use code in priority on type_code } } - $out .= ''; + $out .= ''; $out .= $actionstatic->getTypePicto(); $out .= $labeltype; $out .= ''; + // Title/Label of event + $out .= 'trans("Action".$histo[$key]['acode']); $libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : $histo[$key]['alabel']); //$actionstatic->libelle=$libelle; $libelle = $histo[$key]['note']; $actionstatic->id = $histo[$key]['id']; + $out .= ' title="'.dol_escape_htmltag($libelle).'">'; $out .= dol_trunc($libelle, 120); } if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') { $out .= ''.img_object($langs->trans("ShowEMailing"), "email").' '; $transcode = $langs->trans("Action".$histo[$key]['acode']); $libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : 'Send mass mailing'); + $out .= ' title="'.dol_escape_htmltag($libelle).'">'; $out .= dol_trunc($libelle, 120); } $out .= ''.$contactstatic->getNomUrl(1, '', 10).''; + if (isset($histo[$key]['socpeopleassigned']) && is_array($histo[$key]['socpeopleassigned']) && count($histo[$key]['socpeopleassigned']) > 0) { + $out .= ''; $contact = new Contact($db); foreach ($histo[$key]['socpeopleassigned'] as $cid => $value) { $result = $contact->fetch($cid); @@ -1904,7 +1901,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin } if ($result > 0) { - $out .= $contact->getNomUrl(1, '', 16); + $out .= $contact->getNomUrl(-3, '', 10, '', -1, 0, 'paddingright'); if (isset($histo[$key]['acode']) && $histo[$key]['acode'] == 'AC_TEL') { if (!empty($contact->phone_pro)) { $out .= '('.dol_print_phone($contact->phone_pro).')'; @@ -1914,6 +1911,12 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin } } $out .= ''.$contactstatic->getNomUrl(-1, '', 10).'