From 5f0999665f232ed6647931856b76939ce1516929 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 27 Jan 2022 02:27:36 +0100 Subject: [PATCH 1/3] 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 815dd74de05b4394dae7bae9fdec840b85c06e13 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 Feb 2022 14:03:09 +0100 Subject: [PATCH 2/3] 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 3/3] 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 .= $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 .= ''; $out .= ''; $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 .= ''; @@ -1782,7 +1782,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin $out .= ''; // Author of event - $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 - $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 .= ''; @@ -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 .= ''.$contactstatic->getNomUrl(1, '', 10).''; - } elseif (isset($histo[$key]['socpeopleassigned']) && is_array($histo[$key]['socpeopleassigned']) && count($histo[$key]['socpeopleassigned']) > 0) { - $out .= ''; + 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 .= ''; + } 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 .= ''.$contactstatic->getNomUrl(-1, '', 10).''; } 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);