|
1
|
|
|
<?php |
|
2
|
|
|
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <[email protected]> |
|
3
|
|
|
* Copyright (C) 2004-2007 Laurent Destailleur <[email protected]> |
|
4
|
|
|
* Copyright (C) 2005-2009 Regis Houssin <[email protected]> |
|
5
|
|
|
* Copyright (C) 2008 Raphael Bertrand (Resultic) <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* This program is free software; you can redistribute it and/or modify |
|
8
|
|
|
* it under the terms of the GNU General Public License as published by |
|
9
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
|
10
|
|
|
* (at your option) any later version. |
|
11
|
|
|
* |
|
12
|
|
|
* This program is distributed in the hope that it will be useful, |
|
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15
|
|
|
* GNU General Public License for more details. |
|
16
|
|
|
* |
|
17
|
|
|
* You should have received a copy of the GNU General Public License |
|
18
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
19
|
|
|
* or see http://www.gnu.org/ |
|
20
|
|
|
*/ |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* \file htdocs/core/modules/bom/mod_bom_advanced.php |
|
24
|
|
|
* \ingroup bom |
|
25
|
|
|
* \brief Fichier contenant la classe du modele de numerotation de reference de bom advanced |
|
26
|
|
|
*/ |
|
27
|
|
|
|
|
28
|
|
|
require_once DOL_DOCUMENT_ROOT .'/core/modules/bom/modules_bom.php'; |
|
29
|
|
|
|
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Class to manage customer Bom numbering rules advanced |
|
33
|
|
|
*/ |
|
34
|
|
|
class mod_bom_advanced extends ModeleNumRefboms |
|
35
|
|
|
{ |
|
36
|
|
|
/** |
|
37
|
|
|
* Dolibarr version of the loaded document |
|
38
|
|
|
* @public string |
|
39
|
|
|
*/ |
|
40
|
|
|
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @var string Error message |
|
44
|
|
|
*/ |
|
45
|
|
|
public $error = ''; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @var string name |
|
49
|
|
|
*/ |
|
50
|
|
|
public $name='advanced'; |
|
51
|
|
|
|
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Renvoi la description du modele de numerotation |
|
55
|
|
|
* |
|
56
|
|
|
* @return string Texte descripif |
|
57
|
|
|
*/ |
|
58
|
|
|
public function info() |
|
59
|
|
|
{ |
|
60
|
|
|
global $conf, $langs; |
|
61
|
|
|
|
|
62
|
|
|
$langs->load("bills"); |
|
63
|
|
|
|
|
64
|
|
|
$form = new Form($this->db); |
|
65
|
|
|
|
|
66
|
|
|
$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; |
|
67
|
|
|
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; |
|
68
|
|
|
$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
69
|
|
|
$texte.= '<input type="hidden" name="action" value="updateMask">'; |
|
70
|
|
|
$texte.= '<input type="hidden" name="maskconstBom" value="BOM_ADVANCED_MASK">'; |
|
71
|
|
|
$texte.= '<table class="nobordernopadding" width="100%">'; |
|
72
|
|
|
|
|
73
|
|
|
$tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("Bom"), $langs->transnoentities("Bom")); |
|
74
|
|
|
$tooltip.=$langs->trans("GenericMaskCodes2"); |
|
75
|
|
|
$tooltip.=$langs->trans("GenericMaskCodes3"); |
|
76
|
|
|
$tooltip.=$langs->trans("GenericMaskCodes4a", $langs->transnoentities("Bom"), $langs->transnoentities("Bom")); |
|
77
|
|
|
$tooltip.=$langs->trans("GenericMaskCodes5"); |
|
78
|
|
|
|
|
79
|
|
|
// Parametrage du prefix |
|
80
|
|
|
$texte.= '<tr><td>'.$langs->trans("Mask").':</td>'; |
|
81
|
|
|
$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskBom" value="'.$conf->global->BOM_ADVANCED_MASK.'">', $tooltip, 1, 1).'</td>'; |
|
82
|
|
|
|
|
83
|
|
|
$texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
84
|
|
|
|
|
85
|
|
|
$texte.= '</tr>'; |
|
86
|
|
|
|
|
87
|
|
|
$texte.= '</table>'; |
|
88
|
|
|
$texte.= '</form>'; |
|
89
|
|
|
|
|
90
|
|
|
return $texte; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* Renvoi un exemple de numerotation |
|
95
|
|
|
* |
|
96
|
|
|
* @return string Example |
|
97
|
|
|
*/ |
|
98
|
|
|
public function getExample() |
|
99
|
|
|
{ |
|
100
|
|
|
global $conf,$langs,$mysoc; |
|
101
|
|
|
|
|
102
|
|
|
$old_code_client=$mysoc->code_client; |
|
103
|
|
|
$old_code_type=$mysoc->typent_code; |
|
104
|
|
|
$mysoc->code_client='CCCCCCCCCC'; |
|
105
|
|
|
$mysoc->typent_code='TTTTTTTTTT'; |
|
106
|
|
|
$numExample = $this->getNextValue($mysoc, ''); |
|
107
|
|
|
$mysoc->code_client=$old_code_client; |
|
108
|
|
|
$mysoc->typent_code=$old_code_type; |
|
109
|
|
|
|
|
110
|
|
|
if (! $numExample) |
|
111
|
|
|
{ |
|
112
|
|
|
$numExample = $langs->trans('NotConfigured'); |
|
113
|
|
|
} |
|
114
|
|
|
return $numExample; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* Return next free value |
|
119
|
|
|
* |
|
120
|
|
|
* @param Societe $objsoc Object thirdparty |
|
121
|
|
|
* @param Object $object Object we need next value for |
|
122
|
|
|
* @return string Value if KO, <0 if KO |
|
123
|
|
|
*/ |
|
124
|
|
|
public function getNextValue($objsoc, $object) |
|
125
|
|
|
{ |
|
126
|
|
|
global $db,$conf; |
|
127
|
|
|
|
|
128
|
|
|
require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; |
|
129
|
|
|
|
|
130
|
|
|
// We get cursor rule |
|
131
|
|
|
$mask=$conf->global->BOM_ADVANCED_MASK; |
|
132
|
|
|
|
|
133
|
|
|
if (! $mask) |
|
134
|
|
|
{ |
|
135
|
|
|
$this->error='NotConfigured'; |
|
136
|
|
|
return 0; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
$date = ($object->date_bom ? $object->date_bom : $object->date); |
|
140
|
|
|
|
|
141
|
|
|
$numFinal=get_next_value($db, $mask, 'bom_bom', 'ref', '', $objsoc, $date); |
|
142
|
|
|
|
|
143
|
|
|
return $numFinal; |
|
144
|
|
|
} |
|
145
|
|
|
} |
|
146
|
|
|
|