|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <[email protected]> |
|
4
|
|
|
* Copyright (C) 2004-2010 Laurent Destailleur <[email protected]> |
|
5
|
|
|
* Copyright (C) 2004 Eric Seigne <[email protected]> |
|
6
|
|
|
* Copyright (C) 2005-2012 Regis Houssin <[email protected]> |
|
7
|
|
|
* Copyright (C) 2024 Frédéric France <[email protected]> |
|
8
|
|
|
* Copyright (C) 2024 MDW <[email protected]> |
|
9
|
|
|
* Copyright (C) 2024 Rafael San José <[email protected]> |
|
10
|
|
|
* |
|
11
|
|
|
* This program is free software; you can redistribute it and/or modify |
|
12
|
|
|
* it under the terms of the GNU General Public License as published by |
|
13
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
|
14
|
|
|
* (at your option) any later version. |
|
15
|
|
|
* |
|
16
|
|
|
* This program is distributed in the hope that it will be useful, |
|
17
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19
|
|
|
* GNU General Public License for more details. |
|
20
|
|
|
* |
|
21
|
|
|
* You should have received a copy of the GNU General Public License |
|
22
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
23
|
|
|
* or see https://www.gnu.org/ |
|
24
|
|
|
*/ |
|
25
|
|
|
|
|
26
|
|
|
namespace Dolibarr\Code\Societe\Classes; |
|
27
|
|
|
|
|
28
|
|
|
use Dolibarr\Code\Core\Classes\CommonNumRefGenerator; |
|
29
|
|
|
use Dolibarr\Code\Core\Classes\Translate; |
|
30
|
|
|
use DoliDB; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Parent class for third parties accountancy code generators |
|
34
|
|
|
*/ |
|
35
|
|
|
abstract class ModeleAccountancyCode extends CommonNumRefGenerator |
|
36
|
|
|
{ |
|
37
|
|
|
/** |
|
38
|
|
|
* @var string |
|
39
|
|
|
*/ |
|
40
|
|
|
public $code; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Return description of module parameters |
|
44
|
|
|
* |
|
45
|
|
|
* @param Translate $langs Output language |
|
46
|
|
|
* @param Societe $soc Third party object |
|
47
|
|
|
* @param int $type -1=Nothing, 0=Customer, 1=Supplier |
|
48
|
|
|
* @return string HTML translated description |
|
49
|
|
|
*/ |
|
50
|
|
|
public function getToolTip($langs, $soc, $type) |
|
51
|
|
|
{ |
|
52
|
|
|
global $db; |
|
53
|
|
|
|
|
54
|
|
|
$langs->load("admin"); |
|
55
|
|
|
|
|
56
|
|
|
$s = ''; |
|
57
|
|
|
if ($type == -1) { |
|
58
|
|
|
$s .= $langs->trans("Name") . ': <b>' . $this->name . '</b><br>'; |
|
59
|
|
|
$s .= $langs->trans("Version") . ': <b>' . $this->getVersion() . '</b><br>'; |
|
60
|
|
|
} |
|
61
|
|
|
//$s.='<br>'; |
|
62
|
|
|
//$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>'; |
|
63
|
|
|
$s .= '<br>'; |
|
64
|
|
|
if ($type == 0 || $type == -1) { |
|
65
|
|
|
$result = $this->get_code($db, $soc, 'customer'); |
|
66
|
|
|
$nextval = $this->code; |
|
67
|
|
|
if (empty($nextval)) { |
|
68
|
|
|
$nextval = $langs->trans("Undefined"); |
|
69
|
|
|
} |
|
70
|
|
|
$s .= $langs->trans("NextValue") . ($type == -1 ? ' (' . $langs->trans("Customer") . ')' : '') . ': <b>' . $nextval . '</b><br>'; |
|
71
|
|
|
} |
|
72
|
|
|
if ($type == 1 || $type == -1) { |
|
73
|
|
|
$result = $this->get_code($db, $soc, 'supplier'); |
|
74
|
|
|
$nextval = $this->code; |
|
75
|
|
|
if (empty($nextval)) { |
|
76
|
|
|
$nextval = $langs->trans("Undefined"); |
|
77
|
|
|
} |
|
78
|
|
|
$s .= $langs->trans("NextValue") . ($type == -1 ? ' (' . $langs->trans("Supplier") . ')' : '') . ': <b>' . $nextval . '</b>'; |
|
79
|
|
|
} |
|
80
|
|
|
return $s; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* Set accountancy account code for a third party into this->code |
|
87
|
|
|
* |
|
88
|
|
|
* @param DoliDB $db Database handler |
|
89
|
|
|
* @param Societe $societe Third party object |
|
90
|
|
|
* @param string $type 'customer' or 'supplier' |
|
91
|
|
|
* @return int<-1,1> >=0 if success, -1 if failure |
|
92
|
|
|
*/ |
|
93
|
|
|
public function get_code($db, $societe, $type = '') |
|
94
|
|
|
{ |
|
95
|
|
|
// phpcs:enable |
|
96
|
|
|
global $langs; |
|
97
|
|
|
|
|
98
|
|
|
dol_syslog(get_class($this) . "::get_code" . $langs->trans("NotAvailable"), LOG_ERR); |
|
99
|
|
|
return -1; |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
|