From 2e77b9fed9ef745a24d133d346478bfcc86aacd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 16 Oct 2018 22:42:18 +0200 Subject: [PATCH 1/7] fix phpunit --- htdocs/compta/paiement/class/paiement.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index cc60c2cba8e..50f7bc2c4e6 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -76,8 +76,8 @@ class Paiement extends CommonObject //paiement de llx_c_paiement public $num_paiement; // Numero du CHQ, VIR, etc... public $num_payment; // Numero du CHQ, VIR, etc... - public $payment_id; // Id of external modepayment - public $payment_site; // name of external modepayment + public $payment_id; // Id of external modepayment + public $payment_site; // name of external modepayment public $bank_account; // Id compte bancaire du paiement public $bank_line; // Id de la ligne d'ecriture bancaire // fk_paiement dans llx_paiement est l'id du type de paiement (7 pour CHQ, ...) @@ -233,11 +233,11 @@ class Paiement extends CommonObject $mtotal = $totalamount; } $note = ($this->note_public?$this->note_public:$this->note); - $payment_id = $this->payment_id ? $this->payment_id : null; - $payment_site = $this->payment_site ? $this->payment_site : null; + $payment_id = $this->payment_id ? $this->payment_id : null; + $payment_site = $this->payment_site ? $this->payment_site : null; $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, ext_payment_id, ext_payment_site, fk_user_creat)"; - $sql.= " VALUES (".$conf->entity.", '".$this->ref."', '". $this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', '".$total."', '".$mtotal."', ".$this->paiementid.", '".$this->num_paiement."', '".$this->db->escape($note)."', '".$this->payment_id."', '".$this->payment_site."', ".$user->id.")"; + $sql.= " VALUES (".$conf->entity.", '".$this->ref."', '". $this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', '".$total."', '".$mtotal."', ".$this->paiementid.", '".$this->num_paiement."', '".$this->db->escape($note)."', '".$this->db->escape($payment_id)."', '".$this->db->escape($payment_site)."', ".$user->id.")"; dol_syslog(get_class($this)."::Create insert paiement", LOG_DEBUG); $resql = $this->db->query($sql); From 7d8ff0429251f4860ca70c8aa5226e8266a4e0e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 17 Oct 2018 08:15:12 +0200 Subject: [PATCH 2/7] Update paiement.class.php --- htdocs/compta/paiement/class/paiement.class.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 50f7bc2c4e6..4fdc4a0ae63 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -138,8 +138,8 @@ class Paiement extends CommonObject $this->type_libelle = $obj->type_libelle; $this->type_code = $obj->type_code; $this->statut = $obj->statut; - $this->payment_id = $obj->ext_payment_id; - $this->payment_site = $obj->ext_payment_site; + $this->payment_id = $obj->ext_payment_id; + $this->payment_site = $obj->ext_payment_site; $this->bank_account = $obj->fk_account; // deprecated $this->fk_account = $obj->fk_account; @@ -233,11 +233,9 @@ class Paiement extends CommonObject $mtotal = $totalamount; } $note = ($this->note_public?$this->note_public:$this->note); - $payment_id = $this->payment_id ? $this->payment_id : null; - $payment_site = $this->payment_site ? $this->payment_site : null; $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, ext_payment_id, ext_payment_site, fk_user_creat)"; - $sql.= " VALUES (".$conf->entity.", '".$this->ref."', '". $this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', '".$total."', '".$mtotal."', ".$this->paiementid.", '".$this->num_paiement."', '".$this->db->escape($note)."', '".$this->db->escape($payment_id)."', '".$this->db->escape($payment_site)."', ".$user->id.")"; + $sql.= " VALUES (".$conf->entity.", '".$this->ref."', '". $this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', '".$total."', '".$mtotal."', ".$this->paiementid.", '".$this->num_paiement."', '".$this->db->escape($note)."', ".($this->payment_id?"'".$this->db->escape($this->payment_id)."'":"null").", ".($this->payment_site?"'".$this->db->escape($this->payment_site)."'":"null").", ".$user->id.")"; dol_syslog(get_class($this)."::Create insert paiement", LOG_DEBUG); $resql = $this->db->query($sql); From 456bdb5b8c6020480899165f4cbb34ee8ce40fd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 17 Oct 2018 20:04:48 +0200 Subject: [PATCH 3/7] do not trim int --- htdocs/ticket/class/ticketlogs.class.php | 33 ++++++++++++------------ 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/htdocs/ticket/class/ticketlogs.class.php b/htdocs/ticket/class/ticketlogs.class.php index 79a4c95efed..68ce6481b31 100644 --- a/htdocs/ticket/class/ticketlogs.class.php +++ b/htdocs/ticket/class/ticketlogs.class.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2013-2016 Jean-François FERRY + * Copyright (C) 2018 Frédéric France * * 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 @@ -63,12 +64,12 @@ class Ticketlogs// extends CommonObject public $id; /** - * @var int ID + * @var string trackid */ public $fk_track_id; /** - * @var int ID + * @var int user create ID */ public $fk_user_create; @@ -104,7 +105,7 @@ class Ticketlogs// extends CommonObject } if (isset($this->fk_user_create)) { - $this->fk_user_create = trim($this->fk_user_create); + $this->fk_user_create = (int) $this->fk_user_create; } if (isset($this->message)) { @@ -143,7 +144,7 @@ class Ticketlogs// extends CommonObject if (!$error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "ticket_logs"); - if (!$notrigger) { + //if (!$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. @@ -153,7 +154,7 @@ class Ticketlogs// extends CommonObject //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); //if ($result < 0) { $error++; $this->errors=$interface->errors; } //// End call triggers - } + //} } // Commit or rollback @@ -232,7 +233,7 @@ class Ticketlogs// extends CommonObject } if (isset($this->fk_user_create)) { - $this->fk_user_create = trim($this->fk_user_create); + $this->fk_user_create = (int) $this->fk_user_create; } if (isset($this->message)) { @@ -261,8 +262,8 @@ class Ticketlogs// extends CommonObject $this->errors[] = "Error " . $this->db->lasterror(); } - if (!$error) { - if (!$notrigger) { + //if (!$error) { + //if (!$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. @@ -272,8 +273,8 @@ class Ticketlogs// extends CommonObject //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); //if ($result < 0) { $error++; $this->errors=$interface->errors; } //// End call triggers - } - } + //} + //} // Commit or rollback if ($error) { @@ -303,8 +304,8 @@ class Ticketlogs// extends CommonObject $this->db->begin(); - if (!$error) { - if (!$notrigger) { + //if (!$error) { + //if (!$notrigger) { // Uncomment this and change MYOBJECT to your own tag if you // want this action calls a trigger. @@ -314,8 +315,8 @@ class Ticketlogs// extends CommonObject //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); //if ($result < 0) { $error++; $this->errors=$interface->errors; } //// End call triggers - } - } + //} + //} if (!$error) { $sql = "DELETE FROM " . MAIN_DB_PREFIX . "ticket_logs"; @@ -354,7 +355,7 @@ class Ticketlogs// extends CommonObject $this->id = 0; $this->fk_track_id = ''; - $this->fk_user_create = ''; + $this->fk_user_create = 1; $this->datec = ''; $this->message = ''; } From db732ddeddcfd3c6ae4d6ea56f5790eeb690d42e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 17 Oct 2018 20:36:45 +0200 Subject: [PATCH 4/7] code comment --- htdocs/categories/class/categorie.class.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 15cb254ed7d..a9432234793 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -10,6 +10,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2016 Charlie Benke + * Copyright (C) 2018 Frédéric France * * 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 @@ -805,7 +806,7 @@ class Categorie extends CommonObject * @param string $sortorder Sort order * @param int $limit Limit for list * @param int $page Page number - * @return array Array of categories + * @return array|int Array of categories, 0 if no cat, -1 on error */ function getListForItem($id, $type='customer', $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { @@ -974,7 +975,7 @@ class Categorie extends CommonObject * @param string $type Type of categories ('customer', 'supplier', 'contact', 'product', 'member') or (0, 1, 2, ...). * @param int $markafterid Removed all categories including the leaf $markafterid in category tree. * - * @return array Array of categories. this->cats and this->motherof are set. + * @return array|int Array of categories. this->cats and this->motherof are set, -1 on error */ function get_full_arbo($type, $markafterid=0) { @@ -1126,7 +1127,7 @@ class Categorie extends CommonObject * * @param int $type Type of category (0, 1, ...) * @param boolean $parent Just parent categories if true - * @return array Table of Object Category + * @return array|int Table of Object Category, -1 on error */ function get_all_categories($type=null, $parent=false) { @@ -1441,7 +1442,7 @@ class Categorie extends CommonObject * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact'). Old mode (0, 1, 2, ...) is deprecated. * @param boolean $exact Exact string search (true/false) * @param boolean $case Case sensitive (true/false) - * @return array Array of category id + * @return array|int Array of category id, -1 if error */ function rechercher($id, $nom, $type, $exact = false, $case = false) { From 6c85fbbc303d33c3fc19c18a56dc9864a983cc25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 18 Oct 2018 21:47:10 +0200 Subject: [PATCH 5/7] add log and comment --- .../core/class/commondocgenerator.class.php | 5 +++ .../doc/doc_generic_order_odt.modules.php | 45 +++++++++++-------- .../modules/commande/modules_commande.php | 4 -- 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index f75ced719a1..9c23badcf02 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -38,6 +38,11 @@ abstract class CommonDocGenerator */ public $error=''; + /** + * @var string[] Array of error strings + */ + public $errors = array(); + /** * @var DoliDB Database handler. */ 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 3839edb85c1..dff597c5593 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 @@ -4,21 +4,22 @@ * Copyright (C) 2014 Marcos García * Copyright (C) 2016 Charlie Benke * Copyright (C) 2018 Philippe Grand -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -* or see http://www.gnu.org/ -*/ + * Copyright (C) 2018 Frédéric France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ /** * \file htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -46,7 +47,7 @@ class doc_generic_order_odt extends ModelePDFCommandes public $emetteur; /** - * @var array() Minimum version of PHP required by module. + * @var array Minimum version of PHP required by module. * e.g.: PHP ≥ 5.4 = array(5, 4) */ public $phpmin = array(5, 4); @@ -351,6 +352,7 @@ class doc_generic_order_odt extends ModelePDFCommandes catch(Exception $e) { $this->error=$e->getMessage(); + dol_syslog($e->getMessage(), LOG_INFO); return -1; } // After construction $odfHandler->contentXml contains content and @@ -366,6 +368,7 @@ class doc_generic_order_odt extends ModelePDFCommandes } catch(OdfException $e) { + dol_syslog($e->getMessage(), LOG_INFO); } // Define substitution array @@ -402,6 +405,7 @@ class doc_generic_order_odt extends ModelePDFCommandes } catch(OdfException $e) { + dol_syslog($e->getMessage(), LOG_INFO); } } // Replace tags of lines @@ -434,9 +438,11 @@ class doc_generic_order_odt extends ModelePDFCommandes } catch(OdfException $e) { + dol_syslog($e->getMessage(), LOG_INFO); } catch(SegmentException $e) { + dol_syslog($e->getMessage(), LOG_INFO); } } $listlines->merge(); @@ -460,6 +466,7 @@ class doc_generic_order_odt extends ModelePDFCommandes } catch(OdfException $e) { + dol_syslog($e->getMessage(), LOG_INFO); } } @@ -473,7 +480,8 @@ class doc_generic_order_odt extends ModelePDFCommandes try { $odfHandler->exportAsAttachedPDF($file); }catch (Exception $e){ - $this->error=$e->getMessage(); + $this->error=$e->getMessage(); + dol_syslog($e->getMessage(), LOG_INFO); return -1; } } @@ -481,7 +489,8 @@ class doc_generic_order_odt extends ModelePDFCommandes try { $odfHandler->saveToDisk($file); }catch (Exception $e){ - $this->error=$e->getMessage(); + $this->error=$e->getMessage(); + dol_syslog($e->getMessage(), LOG_INFO); return -1; } } diff --git a/htdocs/core/modules/commande/modules_commande.php b/htdocs/core/modules/commande/modules_commande.php index 1a4b732246d..7a1ffea8792 100644 --- a/htdocs/core/modules/commande/modules_commande.php +++ b/htdocs/core/modules/commande/modules_commande.php @@ -39,10 +39,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; */ abstract class ModelePDFCommandes extends CommonDocGenerator { - /** - * @var string Error code (or message) - */ - public $error=''; // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** From 32a3779d23630237c5d820f0ba0f8432b4328817 Mon Sep 17 00:00:00 2001 From: Mavyre Date: Thu, 18 Oct 2018 22:08:23 +0200 Subject: [PATCH 6/7] Fixed all ressources displaying --- htdocs/core/tpl/resource_add.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/resource_add.tpl.php b/htdocs/core/tpl/resource_add.tpl.php index 688d3aba221..f9daffe33ed 100644 --- a/htdocs/core/tpl/resource_add.tpl.php +++ b/htdocs/core/tpl/resource_add.tpl.php @@ -28,7 +28,7 @@ $out .= ''.$langs->trans("SelectResource").''; $out .= '
'; $events=array(); -$out .= $formresources->select_resource_list('','fk_resource','',1,1,0,$events,'',2); +$out .= $formresources->select_resource_list('','fk_resource','',1,1,0,$events,'',2,null); $out .= '
'; $out .= '
'.$form->selectyesno('busy',(isset($_POST['busy'])?$_POST['busy']:1),1).'
'; From 4bdde9ad56108ff5ef57cb3074dffc6247394676 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 19 Oct 2018 12:51:14 +0200 Subject: [PATCH 7/7] Update ticketlogs.class.php --- htdocs/ticket/class/ticketlogs.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/ticket/class/ticketlogs.class.php b/htdocs/ticket/class/ticketlogs.class.php index 68ce6481b31..66cecd6eb5e 100644 --- a/htdocs/ticket/class/ticketlogs.class.php +++ b/htdocs/ticket/class/ticketlogs.class.php @@ -352,10 +352,12 @@ class Ticketlogs// extends CommonObject */ public function initAsSpecimen() { + global $user; + $this->id = 0; $this->fk_track_id = ''; - $this->fk_user_create = 1; + $this->fk_user_create = $user->id; $this->datec = ''; $this->message = ''; }