Update don.class.php

This commit is contained in:
Frédéric FRANCE 2020-10-25 18:51:05 +01:00 committed by GitHub
parent 6c1f60f6c0
commit 3257e65d09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,7 +6,7 @@
* Copyright (C) 2015-2017 Alexandre Spangaro <aspangaro@open-dsi.fr> * Copyright (C) 2015-2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2016 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2016 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2019 Thibault FOUCART <support@ptibogxiv.net> * Copyright (C) 2019 Thibault FOUCART <support@ptibogxiv.net>
* Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2019-2020 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -97,6 +97,10 @@ class Don extends CommonObject
* @var string Email * @var string Email
*/ */
public $email; public $email;
/**
* @var int 0 or 1
*/
public $public; public $public;
/** /**
@ -111,6 +115,10 @@ class Don extends CommonObject
public $num_payment; public $num_payment;
public $date_valid; public $date_valid;
/**
* @var int payment mode id
*/
public $modepaymentid = 0; public $modepaymentid = 0;
/** /**
@ -230,7 +238,7 @@ class Don extends CommonObject
$this->socid = 1; $this->socid = 1;
$this->date = $now; $this->date = $now;
$this->date_valid = $now; $this->date_valid = $now;
$this->amount = 100; $this->amount = 100.90;
$this->public = 1; $this->public = 1;
$this->societe = 'The Company'; $this->societe = 'The Company';
$this->address = 'Twist road'; $this->address = 'Twist road';
@ -239,7 +247,8 @@ class Don extends CommonObject
$this->note_private = 'Private note'; $this->note_private = 'Private note';
$this->note_public = 'Public note'; $this->note_public = 'Public note';
$this->email = 'email@email.com'; $this->email = 'email@email.com';
$this->note = ''; $this->phone = '0123456789';
$this->phone_mobile = '0606060606';
$this->statut = 1; $this->statut = 1;
} }
@ -392,17 +401,17 @@ class Don extends CommonObject
$sql .= ", '".$this->db->escape($this->address)."'"; $sql .= ", '".$this->db->escape($this->address)."'";
$sql .= ", '".$this->db->escape($this->zip)."'"; $sql .= ", '".$this->db->escape($this->zip)."'";
$sql .= ", '".$this->db->escape($this->town)."'"; $sql .= ", '".$this->db->escape($this->town)."'";
$sql .= ", ".($this->country_id > 0 ? $this->country_id : '0'); $sql .= ", ".(int) $this->country_id;
$sql .= ", ".((int) $this->public); $sql .= ", ".(int) $this->public;
$sql .= ", ".($this->fk_project > 0 ? $this->fk_project : "null"); $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_private) ? ("'".$this->db->escape($this->note_private)."'") : "NULL");
$sql .= ", ".(!empty($this->note_public) ? ("'".$this->db->escape($this->note_public)."'") : "NULL"); $sql .= ", ".(!empty($this->note_public) ? ("'".$this->db->escape($this->note_public)."'") : "NULL");
$sql .= ", ".$user->id; $sql .= ", ".$user->id;
$sql .= ", null"; $sql .= ", null";
$sql .= ", '".$this->db->idate($this->date)."'"; $sql .= ", '".$this->db->idate($this->date)."'";
$sql .= ", '".$this->db->escape($this->email)."'"; $sql .= ", '".$this->db->escape(trim($this->email))."'";
$sql .= ", '".$this->db->escape($this->phone)."'"; $sql .= ", '".$this->db->escape(trim($this->phone))."'";
$sql .= ", '".$this->db->escape($this->phone_mobile)."'"; $sql .= ", '".$this->db->escape(trim($this->phone_mobile))."'";
$sql .= ")"; $sql .= ")";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -426,15 +435,11 @@ class Don extends CommonObject
// Update extrafield // Update extrafield
if (!$error) { if (!$error) {
if (!$error)
{
$result = $this->insertExtraFields(); $result = $this->insertExtraFields();
if ($result < 0) if ($result < 0) {
{
$error++; $error++;
} }
} }
}
if (!$error && !empty($conf->global->MAIN_DISABLEDRAFTSTATUS)) if (!$error && !empty($conf->global->MAIN_DISABLEDRAFTSTATUS))
{ {
@ -490,9 +495,9 @@ class Don extends CommonObject
$sql .= ",note_public=".(!empty($this->note_public) ? ("'".$this->db->escape($this->note_public)."'") : "NULL"); $sql .= ",note_public=".(!empty($this->note_public) ? ("'".$this->db->escape($this->note_public)."'") : "NULL");
$sql .= ",datedon='".$this->db->idate($this->date)."'"; $sql .= ",datedon='".$this->db->idate($this->date)."'";
$sql .= ",date_valid=".($this->date_valid ? "'".$this->db->idate($this->date)."'" : "null"); $sql .= ",date_valid=".($this->date_valid ? "'".$this->db->idate($this->date)."'" : "null");
$sql .= ",email='".$this->db->escape($this->email)."'"; $sql .= ",email='".$this->db->escape(trim($this->email))."'";
$sql .= ",phone='".$this->db->escape($this->phone)."'"; $sql .= ",phone='".$this->db->escape(trim($this->phone))."'";
$sql .= ",phone_mobile='".$this->db->escape($this->phone_mobile)."'"; $sql .= ",phone_mobile='".$this->db->escape(trim($this->phone_mobile))."'";
$sql .= ",fk_statut=".$this->statut; $sql .= ",fk_statut=".$this->statut;
$sql .= " WHERE rowid = ".$this->id; $sql .= " WHERE rowid = ".$this->id;
@ -509,8 +514,6 @@ class Don extends CommonObject
} }
// Update extrafield // Update extrafield
if (!$error)
{
if (!$error) if (!$error)
{ {
$result = $this->insertExtraFields(); $result = $this->insertExtraFields();
@ -519,7 +522,6 @@ class Don extends CommonObject
$error++; $error++;
} }
} }
}
if (!$error) if (!$error)
{ {
@ -555,10 +557,7 @@ class Don extends CommonObject
$this->db->begin(); $this->db->begin();
if (!$error) if (!$error && !$notrigger) {
{
if (!$notrigger)
{
// Call trigger // Call trigger
$result = $this->call_trigger('DON_DELETE', $user); $result = $this->call_trigger('DON_DELETE', $user);
@ -567,7 +566,6 @@ class Don extends CommonObject
} }
// End call triggers // End call triggers
} }
}
// Delete donation // Delete donation
if (!$error) if (!$error)