From 3257e65d09cc147819df1b8e8daf52161b15c1d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 25 Oct 2020 18:51:05 +0100 Subject: [PATCH 1/2] Update don.class.php --- htdocs/don/class/don.class.php | 70 +++++++++++++++++----------------- 1 file changed, 34 insertions(+), 36 deletions(-) diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index b0e802ccc5e..eedd82fc7e0 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -6,7 +6,7 @@ * Copyright (C) 2015-2017 Alexandre Spangaro * Copyright (C) 2016 Juanjo Menent * Copyright (C) 2019 Thibault FOUCART - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019-2020 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 @@ -97,6 +97,10 @@ class Don extends CommonObject * @var string Email */ public $email; + + /** + * @var int 0 or 1 + */ public $public; /** @@ -111,7 +115,11 @@ class Don extends CommonObject public $num_payment; public $date_valid; - public $modepaymentid = 0; + + /** + * @var int payment mode id + */ + public $modepaymentid = 0; /** * @var array Array of status label @@ -230,7 +238,7 @@ class Don extends CommonObject $this->socid = 1; $this->date = $now; $this->date_valid = $now; - $this->amount = 100; + $this->amount = 100.90; $this->public = 1; $this->societe = 'The Company'; $this->address = 'Twist road'; @@ -239,7 +247,8 @@ class Don extends CommonObject $this->note_private = 'Private note'; $this->note_public = 'Public note'; $this->email = 'email@email.com'; - $this->note = ''; + $this->phone = '0123456789'; + $this->phone_mobile = '0606060606'; $this->statut = 1; } @@ -392,17 +401,17 @@ class Don extends CommonObject $sql .= ", '".$this->db->escape($this->address)."'"; $sql .= ", '".$this->db->escape($this->zip)."'"; $sql .= ", '".$this->db->escape($this->town)."'"; - $sql .= ", ".($this->country_id > 0 ? $this->country_id : '0'); - $sql .= ", ".((int) $this->public); - $sql .= ", ".($this->fk_project > 0 ? $this->fk_project : "null"); + $sql .= ", ".(int) $this->country_id; + $sql .= ", ".(int) $this->public; + $sql .= ", ".($this->fk_project > 0 ? (int) $this->fk_project : "null"); $sql .= ", ".(!empty($this->note_private) ? ("'".$this->db->escape($this->note_private)."'") : "NULL"); $sql .= ", ".(!empty($this->note_public) ? ("'".$this->db->escape($this->note_public)."'") : "NULL"); $sql .= ", ".$user->id; $sql .= ", null"; $sql .= ", '".$this->db->idate($this->date)."'"; - $sql .= ", '".$this->db->escape($this->email)."'"; - $sql .= ", '".$this->db->escape($this->phone)."'"; - $sql .= ", '".$this->db->escape($this->phone_mobile)."'"; + $sql .= ", '".$this->db->escape(trim($this->email))."'"; + $sql .= ", '".$this->db->escape(trim($this->phone))."'"; + $sql .= ", '".$this->db->escape(trim($this->phone_mobile))."'"; $sql .= ")"; $resql = $this->db->query($sql); @@ -426,13 +435,9 @@ class Don extends CommonObject // Update extrafield if (!$error) { - if (!$error) - { - $result = $this->insertExtraFields(); - if ($result < 0) - { - $error++; - } + $result = $this->insertExtraFields(); + if ($result < 0) { + $error++; } } @@ -490,9 +495,9 @@ class Don extends CommonObject $sql .= ",note_public=".(!empty($this->note_public) ? ("'".$this->db->escape($this->note_public)."'") : "NULL"); $sql .= ",datedon='".$this->db->idate($this->date)."'"; $sql .= ",date_valid=".($this->date_valid ? "'".$this->db->idate($this->date)."'" : "null"); - $sql .= ",email='".$this->db->escape($this->email)."'"; - $sql .= ",phone='".$this->db->escape($this->phone)."'"; - $sql .= ",phone_mobile='".$this->db->escape($this->phone_mobile)."'"; + $sql .= ",email='".$this->db->escape(trim($this->email))."'"; + $sql .= ",phone='".$this->db->escape(trim($this->phone))."'"; + $sql .= ",phone_mobile='".$this->db->escape(trim($this->phone_mobile))."'"; $sql .= ",fk_statut=".$this->statut; $sql .= " WHERE rowid = ".$this->id; @@ -511,13 +516,10 @@ class Don extends CommonObject // Update extrafield if (!$error) { - if (!$error) + $result = $this->insertExtraFields(); + if ($result < 0) { - $result = $this->insertExtraFields(); - if ($result < 0) - { - $error++; - } + $error++; } } @@ -555,18 +557,14 @@ class Don extends CommonObject $this->db->begin(); - if (!$error) - { - if (!$notrigger) - { - // Call trigger - $result = $this->call_trigger('DON_DELETE', $user); + if (!$error && !$notrigger) { + // Call trigger + $result = $this->call_trigger('DON_DELETE', $user); - if ($result < 0) { - $error++; - } - // End call triggers + if ($result < 0) { + $error++; } + // End call triggers } // Delete donation From 5e19483c99bed54895c2fee9a6ef279ac3a20dbc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Oct 2020 19:26:55 +0100 Subject: [PATCH 2/2] Update don.class.php --- htdocs/don/class/don.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index eedd82fc7e0..a6fa9fa987d 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -401,7 +401,7 @@ class Don extends CommonObject $sql .= ", '".$this->db->escape($this->address)."'"; $sql .= ", '".$this->db->escape($this->zip)."'"; $sql .= ", '".$this->db->escape($this->town)."'"; - $sql .= ", ".(int) $this->country_id; + $sql .= ", ".(int) ($this->country_id > 0 ? $this->country_id : 0); $sql .= ", ".(int) $this->public; $sql .= ", ".($this->fk_project > 0 ? (int) $this->fk_project : "null"); $sql .= ", ".(!empty($this->note_private) ? ("'".$this->db->escape($this->note_private)."'") : "NULL");