/
mod_contract_olive.php
107 lines (91 loc) · 3.13 KB
/
mod_contract_olive.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2014 Floran Henry <florian.henry@open-concept.pro>
*
* 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 <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/core/modules/contract/mod_contract_olive.php
* \ingroup contract
* \brief File of class to manage contract numbering rules Olive
*/
require_once DOL_DOCUMENT_ROOT .'/core/modules/contract/modules_contract.php';
/**
* Class to manage contract numbering rules Olive
*/
class mod_contract_olive extends ModelNumRefContracts
{
var $nom='Olive'; // Nom du modele
var $code_modifiable = 1; // Code modifiable
var $code_modifiable_invalide = 1; // Code modifiable si il est invalide
var $code_modifiable_null = 1; // Code modifiables si il est null
var $code_null = 1; // Code facultatif
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
var $code_auto = 0; // Numerotation automatique
/**
* Return description of module
*
* @param Translate $langs Object langs
* @return string Description of module
*/
function info()
{
global $langs;
$langs->load("companies");
return $langs->trans("LeopardNumRefModelDesc");
}
/**
* Return an example of result returned by getNextValue
*
* @param Societe $objsoc Object thirdparty
* @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect)
* @return string Return next value
*/
function getNextValue($objsoc,$contract)
{
global $langs;
return '';
}
/**
* Check validity of code according to its rules
*
* @param DoliDB $db Database handler
* @param string &$code Code to check/correct
* @param Product $product Object product
* @param int $type 0 = product , 1 = service
* @return int 0 if OK
* -1 ErrorBadProductCodeSyntax
* -2 ErrorProductCodeRequired
* -3 ErrorProductCodeAlreadyUsed
* -4 ErrorPrefixRequired
*/
function verif($db, &$code, $product, $type)
{
global $conf;
$result=0;
$code = strtoupper(trim($code));
if (empty($code) && $this->code_null && empty($conf->global->MAIN_CONTARCT_CODE_ALWAYS_REQUIRED))
{
$result=0;
}
else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_CONTARCT_CODE_ALWAYS_REQUIRED)) )
{
$result=-2;
}
dol_syslog("mod_contract_olive::verif type=".$type." result=".$result);
return $result;
}
}