|
1
|
|
|
<?php |
|
2
|
|
|
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <[email protected]> |
|
3
|
|
|
* Copyright (C) 2004-2010 Laurent Destailleur <[email protected]> |
|
4
|
|
|
* Copyright (C) 2004 Eric Seigne <[email protected]> |
|
5
|
|
|
* Copyright (C) 2005-2012 Regis Houssin <[email protected]> |
|
6
|
|
|
* Copyright (C) 2015 Marcos García <[email protected]> |
|
7
|
|
|
* Copyright (C) 2016 Charlie Benke <[email protected]> |
|
8
|
|
|
* |
|
9
|
|
|
* This program is free software; you can redistribute it and/or modify |
|
10
|
|
|
* it under the terms of the GNU General Public License as published by |
|
11
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
|
12
|
|
|
* (at your option) any later version. |
|
13
|
|
|
* |
|
14
|
|
|
* This program is distributed in the hope that it will be useful, |
|
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17
|
|
|
* GNU General Public License for more details. |
|
18
|
|
|
* |
|
19
|
|
|
* You should have received a copy of the GNU General Public License |
|
20
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
21
|
|
|
* or see http://www.gnu.org/ |
|
22
|
|
|
*/ |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* \file htdocs/core/class/commondocgenerator.class.php |
|
26
|
|
|
* \ingroup core |
|
27
|
|
|
* \brief File of parent class for documents generators |
|
28
|
|
|
*/ |
|
29
|
|
|
|
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Parent class for documents generators |
|
33
|
|
|
*/ |
|
34
|
|
|
abstract class CommonDocGenerator |
|
35
|
|
|
{ |
|
36
|
|
|
var $error=''; |
|
37
|
|
|
protected $db; |
|
38
|
|
|
|
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Constructor |
|
42
|
|
|
* |
|
43
|
|
|
* @param DoliDB $db Database handler |
|
44
|
|
|
*/ |
|
45
|
|
|
public function __construct($db) { |
|
46
|
|
|
$this->db = $db; |
|
47
|
|
|
return 1; |
|
|
|
|
|
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Define array with couple subtitution key => subtitution value |
|
53
|
|
|
* |
|
54
|
|
|
* @param User $user User |
|
55
|
|
|
* @param Translate $outputlangs Language object for output |
|
56
|
|
|
* @return array Array of substitution key->code |
|
57
|
|
|
*/ |
|
58
|
|
|
function get_substitutionarray_user($user,$outputlangs) |
|
59
|
|
|
{ |
|
60
|
|
|
global $conf; |
|
61
|
|
|
|
|
62
|
|
|
$logotouse=$conf->user->dir_output.'/'.get_exdir($user->id, 2, 0, 1, $user, 'user').'/'.$user->photo; |
|
63
|
|
|
|
|
64
|
|
|
return array( |
|
65
|
|
|
'myuser_lastname'=>$user->lastname, |
|
66
|
|
|
'myuser_firstname'=>$user->firstname, |
|
67
|
|
|
'myuser_fullname'=>$user->getFullName($outputlangs,1), |
|
68
|
|
|
'myuser_login'=>$user->login, |
|
69
|
|
|
'myuser_phone'=>$user->office_phone, |
|
70
|
|
|
'myuser_address'=>$user->address, |
|
71
|
|
|
'myuser_zip'=>$user->zip, |
|
72
|
|
|
'myuser_town'=>$user->town, |
|
73
|
|
|
'myuser_country'=>$user->country, |
|
74
|
|
|
'myuser_country_code'=>$user->country_code, |
|
75
|
|
|
'myuser_state'=>$user->state, |
|
76
|
|
|
'myuser_state_code'=>$user->state_code, |
|
77
|
|
|
'myuser_fax'=>$user->office_fax, |
|
78
|
|
|
'myuser_mobile'=>$user->user_mobile, |
|
79
|
|
|
'myuser_email'=>$user->email, |
|
80
|
|
|
'myuser_logo'=>$logotouse, |
|
81
|
|
|
'myuser_job'=>$user->job, |
|
82
|
|
|
'myuser_web'=>'' // url not exist in $user object |
|
83
|
|
|
); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Define array with couple subtitution key => subtitution value |
|
89
|
|
|
* |
|
90
|
|
|
* @param Societe $mysoc Object thirdparty |
|
91
|
|
|
* @param Translate $outputlangs Language object for output |
|
92
|
|
|
* @return array Array of substitution key->code |
|
93
|
|
|
*/ |
|
94
|
|
|
function get_substitutionarray_mysoc($mysoc,$outputlangs) |
|
95
|
|
|
{ |
|
96
|
|
|
global $conf; |
|
97
|
|
|
|
|
98
|
|
|
if (empty($mysoc->forme_juridique) && ! empty($mysoc->forme_juridique_code)) |
|
99
|
|
|
{ |
|
100
|
|
|
$mysoc->forme_juridique=getFormeJuridiqueLabel($mysoc->forme_juridique_code); |
|
101
|
|
|
} |
|
102
|
|
|
if (empty($mysoc->country) && ! empty($mysoc->country_code)) |
|
103
|
|
|
{ |
|
104
|
|
|
$mysoc->country=$outputlangs->transnoentitiesnoconv("Country".$mysoc->country_code); |
|
105
|
|
|
} |
|
106
|
|
|
if (empty($mysoc->state) && ! empty($mysoc->state_code)) |
|
107
|
|
|
{ |
|
108
|
|
|
$mysoc->state=getState($mysoc->state_code,0); |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
$logotouse=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small; |
|
112
|
|
|
|
|
113
|
|
|
return array( |
|
114
|
|
|
'mycompany_logo'=>$logotouse, |
|
115
|
|
|
'mycompany_name'=>$mysoc->name, |
|
116
|
|
|
'mycompany_email'=>$mysoc->email, |
|
117
|
|
|
'mycompany_phone'=>$mysoc->phone, |
|
118
|
|
|
'mycompany_fax'=>$mysoc->fax, |
|
119
|
|
|
'mycompany_address'=>$mysoc->address, |
|
120
|
|
|
'mycompany_zip'=>$mysoc->zip, |
|
121
|
|
|
'mycompany_town'=>$mysoc->town, |
|
122
|
|
|
'mycompany_country'=>$mysoc->country, |
|
123
|
|
|
'mycompany_country_code'=>$mysoc->country_code, |
|
124
|
|
|
'mycompany_state'=>$mysoc->state, |
|
125
|
|
|
'mycompany_state_code'=>$mysoc->state_code, |
|
126
|
|
|
'mycompany_web'=>$mysoc->url, |
|
127
|
|
|
'mycompany_juridicalstatus'=>$mysoc->forme_juridique, |
|
128
|
|
|
'mycompany_managers'=>$mysoc->managers, |
|
129
|
|
|
'mycompany_capital'=>$mysoc->capital, |
|
130
|
|
|
'mycompany_barcode'=>$mysoc->barcode, |
|
131
|
|
|
'mycompany_idprof1'=>$mysoc->idprof1, |
|
132
|
|
|
'mycompany_idprof2'=>$mysoc->idprof2, |
|
133
|
|
|
'mycompany_idprof3'=>$mysoc->idprof3, |
|
134
|
|
|
'mycompany_idprof4'=>$mysoc->idprof4, |
|
135
|
|
|
'mycompany_idprof5'=>$mysoc->idprof5, |
|
136
|
|
|
'mycompany_idprof6'=>$mysoc->idprof6, |
|
137
|
|
|
'mycompany_vatnumber'=>$mysoc->tva_intra, |
|
138
|
|
|
'mycompany_object'=>$mysoc->object, |
|
139
|
|
|
'mycompany_note_private'=>$mysoc->note_private, |
|
140
|
|
|
//'mycompany_note_public'=>$mysoc->note_public, // Only private not exists for "mysoc" but both for thirdparties |
|
141
|
|
|
); |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
|
|
145
|
|
|
/** |
|
146
|
|
|
* Define array with couple subtitution key => subtitution value |
|
147
|
|
|
* |
|
148
|
|
|
* @param Object $object Object |
|
149
|
|
|
* @param Translate $outputlangs Language object for output |
|
150
|
|
|
* @return array Array of substitution key->code |
|
151
|
|
|
*/ |
|
152
|
|
|
function get_substitutionarray_thirdparty($object,$outputlangs) |
|
153
|
|
|
{ |
|
154
|
|
|
global $conf; |
|
155
|
|
|
|
|
156
|
|
|
if (empty($object->country) && ! empty($object->country_code)) |
|
157
|
|
|
{ |
|
158
|
|
|
$object->country=$outputlangs->transnoentitiesnoconv("Country".$object->country_code); |
|
159
|
|
|
} |
|
160
|
|
|
if (empty($object->state) && ! empty($object->state_code)) |
|
161
|
|
|
{ |
|
162
|
|
|
$object->state=getState($object->state_code,0); |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
|
|
$array_thirdparty = array( |
|
166
|
|
|
'company_name'=>$object->name, |
|
167
|
|
|
'company_name_alias' => $object->name_alias, |
|
168
|
|
|
'company_email'=>$object->email, |
|
169
|
|
|
'company_phone'=>$object->phone, |
|
170
|
|
|
'company_fax'=>$object->fax, |
|
171
|
|
|
'company_address'=>$object->address, |
|
172
|
|
|
'company_zip'=>$object->zip, |
|
173
|
|
|
'company_town'=>$object->town, |
|
174
|
|
|
'company_country'=>$object->country, |
|
175
|
|
|
'company_country_code'=>$object->country_code, |
|
176
|
|
|
'company_state'=>$object->state, |
|
177
|
|
|
'company_state_code'=>$object->state_code, |
|
178
|
|
|
'company_web'=>$object->url, |
|
179
|
|
|
'company_barcode'=>$object->barcode, |
|
180
|
|
|
'company_vatnumber'=>$object->tva_intra, |
|
181
|
|
|
'company_customercode'=>$object->code_client, |
|
182
|
|
|
'company_suppliercode'=>$object->code_fournisseur, |
|
183
|
|
|
'company_customeraccountancycode'=>$object->code_compta, |
|
184
|
|
|
'company_supplieraccountancycode'=>$object->code_compta_fournisseur, |
|
185
|
|
|
'company_juridicalstatus'=>$object->forme_juridique, |
|
186
|
|
|
'company_outstanding_limit'=>$object->outstanding_limit, |
|
187
|
|
|
'company_capital'=>$object->capital, |
|
188
|
|
|
'company_idprof1'=>$object->idprof1, |
|
189
|
|
|
'company_idprof2'=>$object->idprof2, |
|
190
|
|
|
'company_idprof3'=>$object->idprof3, |
|
191
|
|
|
'company_idprof4'=>$object->idprof4, |
|
192
|
|
|
'company_idprof5'=>$object->idprof5, |
|
193
|
|
|
'company_idprof6'=>$object->idprof6, |
|
194
|
|
|
'company_note_public'=>$object->note_public, |
|
195
|
|
|
'company_note_private'=>$object->note_private, |
|
196
|
|
|
'company_default_bank_iban'=>$object->bank_account->iban, |
|
197
|
|
|
'company_default_bank_bic'=>$object->bank_account->bic |
|
198
|
|
|
); |
|
199
|
|
|
|
|
200
|
|
|
// Retrieve extrafields |
|
201
|
|
|
if(is_array($object->array_options) && count($object->array_options)) |
|
202
|
|
|
{ |
|
203
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
|
204
|
|
|
$extrafields = new ExtraFields($this->db); |
|
205
|
|
|
$extralabels = $extrafields->fetch_name_optionals_label('societe',true); |
|
206
|
|
|
$object->fetch_optionals(); |
|
207
|
|
|
|
|
208
|
|
|
foreach($extrafields->attribute_label as $key=>$label) |
|
209
|
|
|
{ |
|
210
|
|
|
if($extrafields->attribute_type[$key] == 'price') |
|
211
|
|
|
{ |
|
212
|
|
|
$object->array_options['options_'.$key] = price($object->array_options['options_'.$key],0,$outputlangs,0,0,-1,$conf->currency); |
|
213
|
|
|
} |
|
214
|
|
|
else if($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
215
|
|
|
{ |
|
216
|
|
|
$object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]]; |
|
217
|
|
|
} |
|
218
|
|
|
$array_thirdparty = array_merge($array_thirdparty, array ('company_options_'.$key => $object->array_options ['options_' . $key])); |
|
219
|
|
|
} |
|
220
|
|
|
} |
|
221
|
|
|
return $array_thirdparty; |
|
222
|
|
|
} |
|
223
|
|
|
|
|
224
|
|
|
/** |
|
225
|
|
|
* Define array with couple subtitution key => subtitution value |
|
226
|
|
|
* |
|
227
|
|
|
* @param Contact $object contact |
|
228
|
|
|
* @param Translate $outputlangs object for output |
|
229
|
|
|
* @param array_key $array_key Name of the key for return array |
|
230
|
|
|
* @return array of substitution key->code |
|
231
|
|
|
*/ |
|
232
|
|
|
function get_substitutionarray_contact($object, $outputlangs, $array_key = 'object') { |
|
233
|
|
|
global $conf; |
|
234
|
|
|
|
|
235
|
|
|
if(empty($object->country) && ! empty($object->country_code)) |
|
236
|
|
|
{ |
|
237
|
|
|
$object->country = $outputlangs->transnoentitiesnoconv("Country" . $object->country_code); |
|
238
|
|
|
} |
|
239
|
|
|
if(empty($object->state) && ! empty($object->state_code)) |
|
240
|
|
|
{ |
|
241
|
|
|
$object->state = getState($object->state_code, 0); |
|
242
|
|
|
} |
|
243
|
|
|
|
|
244
|
|
|
$array_contact = array ( |
|
245
|
|
|
$array_key . '_fullname' => $object->getFullName($outputlangs, 1), |
|
246
|
|
|
$array_key . '_lastname' => $object->lastname, |
|
247
|
|
|
$array_key . '_firstname' => $object->firstname, |
|
248
|
|
|
$array_key . '_address' => $object->address, |
|
249
|
|
|
$array_key . '_zip' => $object->zip, |
|
250
|
|
|
$array_key . '_town' => $object->town, |
|
251
|
|
|
$array_key . '_state_id' => $object->state_id, |
|
252
|
|
|
$array_key . '_state_code' => $object->state_code, |
|
253
|
|
|
$array_key . '_state' => $object->state, |
|
254
|
|
|
$array_key . '_country_id' => $object->country_id, |
|
255
|
|
|
$array_key . '_country_code' => $object->country_code, |
|
256
|
|
|
$array_key . '_country' => $object->country, |
|
257
|
|
|
$array_key . '_poste' => $object->poste, |
|
258
|
|
|
$array_key . '_socid' => $object->socid, |
|
259
|
|
|
$array_key . '_statut' => $object->statut, |
|
260
|
|
|
$array_key . '_code' => $object->code, |
|
261
|
|
|
$array_key . '_email' => $object->email, |
|
262
|
|
|
$array_key . '_jabberid' => $object->jabberid, |
|
263
|
|
|
$array_key . '_phone_pro' => $object->phone_pro, |
|
264
|
|
|
$array_key . '_phone_perso' => $object->phone_perso, |
|
265
|
|
|
$array_key . '_phone_mobile' => $object->phone_mobile, |
|
266
|
|
|
$array_key . '_fax' => $object->fax, |
|
267
|
|
|
$array_key . '_birthday' => $object->birthday, |
|
268
|
|
|
$array_key . '_default_lang' => $object->default_lang, |
|
269
|
|
|
$array_key . '_note_public' => $object->note_public, |
|
270
|
|
|
$array_key . '_note_private' => $object->note_private |
|
271
|
|
|
); |
|
272
|
|
|
|
|
273
|
|
|
// Retrieve extrafields |
|
274
|
|
|
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; |
|
275
|
|
|
$extrafields = new ExtraFields($this->db); |
|
276
|
|
|
$extralabels = $extrafields->fetch_name_optionals_label('socpeople', true); |
|
277
|
|
|
$object->fetch_optionals(); |
|
278
|
|
|
|
|
279
|
|
|
foreach($extrafields->attribute_label as $key => $label) |
|
280
|
|
|
{ |
|
281
|
|
|
if ($extrafields->attribute_type[$key] == 'price') |
|
282
|
|
|
{ |
|
283
|
|
|
$object->array_options['options_' . $key] = price($object->array_options ['options_' . $key], 0, $outputlangs, 0, 0, - 1, $conf->currency); |
|
284
|
|
|
} |
|
285
|
|
|
elseif($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
286
|
|
|
{ |
|
287
|
|
|
$object->array_options['options_' . $key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_' . $key]]; |
|
288
|
|
|
} |
|
289
|
|
|
$array_contact = array_merge($array_contact, array($array_key.'_options_' . $key => $object->array_options['options_'. $key])); |
|
290
|
|
|
} |
|
291
|
|
|
return $array_contact; |
|
292
|
|
|
} |
|
293
|
|
|
|
|
294
|
|
|
|
|
295
|
|
|
/** |
|
296
|
|
|
* Define array with couple subtitution key => subtitution value |
|
297
|
|
|
* |
|
298
|
|
|
* @param Translate $outputlangs Language object for output |
|
299
|
|
|
* @return array Array of substitution key->code |
|
300
|
|
|
*/ |
|
301
|
|
|
function get_substitutionarray_other($outputlangs) |
|
302
|
|
|
{ |
|
303
|
|
|
global $conf; |
|
304
|
|
|
|
|
305
|
|
|
$now=dol_now('gmt'); // gmt |
|
306
|
|
|
$array_other = array( |
|
307
|
|
|
// Date in default language |
|
308
|
|
|
'current_date'=>dol_print_date($now,'day','tzuser'), |
|
309
|
|
|
'current_datehour'=>dol_print_date($now,'dayhour','tzuser'), |
|
310
|
|
|
'current_server_date'=>dol_print_date($now,'day','tzserver'), |
|
311
|
|
|
'current_server_datehour'=>dol_print_date($now,'dayhour','tzserver'), |
|
312
|
|
|
// Date in requested output language |
|
313
|
|
|
'current_date_locale'=>dol_print_date($now,'day','tzuser',$outputlangs), |
|
314
|
|
|
'current_datehour_locale'=>dol_print_date($now,'dayhour','tzuser',$outputlangs), |
|
315
|
|
|
'current_server_date_locale'=>dol_print_date($now,'day','tzserver',$outputlangs), |
|
316
|
|
|
'current_server_datehour_locale'=>dol_print_date($now,'dayhour','tzserver',$outputlangs), |
|
317
|
|
|
); |
|
318
|
|
|
|
|
319
|
|
|
|
|
320
|
|
|
foreach($conf->global as $key => $val) |
|
321
|
|
|
{ |
|
322
|
|
|
if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound)) $newval = '*****forbidden*****'; |
|
|
|
|
|
|
323
|
|
|
else $newval = $val; |
|
324
|
|
|
$array_other['__['.$key.']__'] = $newval; |
|
325
|
|
|
} |
|
326
|
|
|
|
|
327
|
|
|
return $array_other; |
|
328
|
|
|
} |
|
329
|
|
|
|
|
330
|
|
|
|
|
331
|
|
|
/** |
|
332
|
|
|
* Define array with couple substitution key => substitution value |
|
333
|
|
|
* |
|
334
|
|
|
* @param Object $object Main object to use as data source |
|
335
|
|
|
* @param Translate $outputlangs Lang object to use for output |
|
336
|
|
|
* @param string $array_key Name of the key for return array |
|
337
|
|
|
* @return array Array of substitution |
|
338
|
|
|
*/ |
|
339
|
|
|
function get_substitutionarray_object($object,$outputlangs,$array_key='object') |
|
340
|
|
|
{ |
|
341
|
|
|
global $conf; |
|
342
|
|
|
|
|
343
|
|
|
$sumpayed=$sumdeposit=$sumcreditnote=''; |
|
344
|
|
|
if ($object->element == 'facture') |
|
345
|
|
|
{ |
|
346
|
|
|
$invoice_source=new Facture($this->db); |
|
347
|
|
|
if ($object->fk_facture_source > 0) |
|
348
|
|
|
{ |
|
349
|
|
|
$invoice_source->fetch($object->fk_facture_source); |
|
350
|
|
|
} |
|
351
|
|
|
$sumpayed = $object->getSommePaiement(); |
|
352
|
|
|
$sumdeposit = $object->getSumDepositsUsed(); |
|
353
|
|
|
$sumcreditnote = $object->getSumCreditNotesUsed(); |
|
354
|
|
|
} |
|
355
|
|
|
|
|
356
|
|
|
$date = ($object->element == 'contrat' ? $object->date_contrat : $object->date); |
|
357
|
|
|
|
|
358
|
|
|
$resarray=array( |
|
359
|
|
|
$array_key.'_id'=>$object->id, |
|
360
|
|
|
$array_key.'_ref'=>$object->ref, |
|
361
|
|
|
$array_key.'_ref_ext'=>$object->ref_ext, |
|
362
|
|
|
$array_key.'_ref_customer'=>(! empty($object->ref_client) ? $object->ref_client : (empty($object->ref_customer) ? '' : $object->ref_customer)), |
|
363
|
|
|
$array_key.'_ref_supplier'=>(! empty($object->ref_fournisseur) ? $object->ref_fournisseur : (empty($object->ref_supplier) ? '' : $object->ref_supplier)), |
|
364
|
|
|
$array_key.'_source_invoice_ref'=>$invoice_source->ref, |
|
|
|
|
|
|
365
|
|
|
// Dates |
|
366
|
|
|
$array_key.'_hour'=>dol_print_date($date,'hour'), |
|
367
|
|
|
$array_key.'_date'=>dol_print_date($date,'day'), |
|
368
|
|
|
$array_key.'_date_rfc'=>dol_print_date($date,'dayrfc'), |
|
369
|
|
|
$array_key.'_date_limit'=>(! empty($object->date_lim_reglement)?dol_print_date($object->date_lim_reglement,'day'):''), |
|
370
|
|
|
$array_key.'_date_end'=>(! empty($object->fin_validite)?dol_print_date($object->fin_validite,'day'):''), |
|
371
|
|
|
$array_key.'_date_creation'=>dol_print_date($object->date_creation,'day'), |
|
372
|
|
|
$array_key.'_date_modification'=>(! empty($object->date_modification)?dol_print_date($object->date_modification,'day'):''), |
|
373
|
|
|
$array_key.'_date_validation'=>(! empty($object->date_validation)?dol_print_date($object->date_validation,'dayhour'):''), |
|
374
|
|
|
$array_key.'_date_delivery_planed'=>(! empty($object->date_livraison)?dol_print_date($object->date_livraison,'day'):''), |
|
375
|
|
|
$array_key.'_date_close'=>(! empty($object->date_cloture)?dol_print_date($object->date_cloture,'dayhour'):''), |
|
376
|
|
|
|
|
377
|
|
|
$array_key.'_payment_mode_code'=>$object->mode_reglement_code, |
|
378
|
|
|
$array_key.'_payment_mode'=>($outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code)!='PaymentType'.$object->mode_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code):$object->mode_reglement), |
|
379
|
|
|
$array_key.'_payment_term_code'=>$object->cond_reglement_code, |
|
380
|
|
|
$array_key.'_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code)!='PaymentCondition'.$object->cond_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code):$object->cond_reglement), |
|
381
|
|
|
|
|
382
|
|
|
$array_key.'_total_ht_locale'=>price($object->total_ht, 0, $outputlangs), |
|
383
|
|
|
$array_key.'_total_vat_locale'=>(! empty($object->total_vat)?price($object->total_vat, 0, $outputlangs):price($object->total_tva, 0, $outputlangs)), |
|
384
|
|
|
$array_key.'_total_localtax1_locale'=>price($object->total_localtax1, 0, $outputlangs), |
|
385
|
|
|
$array_key.'_total_localtax2_locale'=>price($object->total_localtax2, 0, $outputlangs), |
|
386
|
|
|
$array_key.'_total_ttc_locale'=>price($object->total_ttc, 0, $outputlangs), |
|
387
|
|
|
|
|
388
|
|
|
$array_key.'_total_ht'=>price2num($object->total_ht), |
|
389
|
|
|
$array_key.'_total_vat'=>(! empty($object->total_vat)?price2num($object->total_vat):price2num($object->total_tva)), |
|
390
|
|
|
$array_key.'_total_localtax1'=>price2num($object->total_localtax1), |
|
391
|
|
|
$array_key.'_total_localtax2'=>price2num($object->total_localtax2), |
|
392
|
|
|
$array_key.'_total_ttc'=>price2num($object->total_ttc), |
|
393
|
|
|
|
|
394
|
|
|
$array_key.'_multicurrency_code' => price2num($object->multicurrency_code), |
|
395
|
|
|
$array_key.'_multicurrency_tx' => price2num($object->multicurrency_tx), |
|
396
|
|
|
$array_key.'_multicurrency_total_ht' => price2num($object->multicurrency_total_ht), |
|
397
|
|
|
$array_key.'_multicurrency_total_tva' => price2num($object->multicurrency_total_tva), |
|
398
|
|
|
$array_key.'_multicurrency_total_ttc' => price2num($object->multicurrency_total_ttc), |
|
399
|
|
|
$array_key.'_multicurrency_total_ht_locale' => price($object->multicurrency_total_ht, 0, $outputlangs), |
|
400
|
|
|
$array_key.'_multicurrency_total_tva_locale' => price($object->multicurrency_total_tva, 0, $outputlangs), |
|
401
|
|
|
$array_key.'_multicurrency_total_ttc_locale' => price($object->multicurrency_total_ttc, 0, $outputlangs), |
|
402
|
|
|
|
|
403
|
|
|
$array_key.'_note_private'=>$object->note, |
|
404
|
|
|
$array_key.'_note_public'=>$object->note_public, |
|
405
|
|
|
$array_key.'_note'=>$object->note_public, // For backward compatibility |
|
406
|
|
|
|
|
407
|
|
|
// Payments |
|
408
|
|
|
$array_key.'_already_payed_locale'=>price($sumpayed, 0, $outputlangs), |
|
409
|
|
|
$array_key.'_already_payed'=>price2num($sumpayed), |
|
410
|
|
|
$array_key.'_already_deposit_locale'=>price($sumdeposit, 0, $outputlangs), |
|
411
|
|
|
$array_key.'_already_deposit'=>price2num($sumdeposit), |
|
412
|
|
|
$array_key.'_already_creditnote_locale'=>price($sumcreditnote, 0, $outputlangs), |
|
413
|
|
|
$array_key.'_already_creditnote'=>price2num($sumcreditnote), |
|
414
|
|
|
|
|
415
|
|
|
$array_key.'_already_payed_all_locale'=>price(price2num($sumpayed + $sumdeposit + $sumcreditnote, 'MT'), 0, $outputlangs), |
|
416
|
|
|
$array_key.'_already_payed_all'=> price2num(($sumpayed + $sumdeposit + $sumcreditnote), 'MT'), |
|
417
|
|
|
|
|
418
|
|
|
// Remain to pay with all know infrmation (except open direct debit requests) |
|
419
|
|
|
$array_key.'_remain_to_pay_locale'=>price(price2num($object->total_ttc - $sumpayed - $sumdeposit - $sumcreditnote, 'MT'), 0, $outputlangs), |
|
420
|
|
|
$array_key.'_remain_to_pay'=>price2num($object->total_ttc - $sumpayed - $sumdeposit - $sumcreditnote, 'MT') |
|
421
|
|
|
); |
|
422
|
|
|
|
|
423
|
|
|
if (method_exists($object, 'getTotalDiscount')) { |
|
424
|
|
|
$resarray[$array_key.'_total_discount_ht_locale'] = price($object->getTotalDiscount(), 0, $outputlangs); |
|
425
|
|
|
$resarray[$array_key.'_total_discount_ht'] = price2num($object->getTotalDiscount()); |
|
426
|
|
|
} else { |
|
427
|
|
|
$resarray[$array_key.'_total_discount_ht_locale'] = ''; |
|
428
|
|
|
$resarray[$array_key.'_total_discount_ht'] = ''; |
|
429
|
|
|
} |
|
430
|
|
|
|
|
431
|
|
|
// Fetch project information if there is a project assigned to this object |
|
432
|
|
|
if ($object->element != "project" && ! empty($object->fk_project) && $object->fk_project > 0) |
|
433
|
|
|
{ |
|
434
|
|
|
if (! is_object($object->project)) |
|
435
|
|
|
{ |
|
436
|
|
|
$object->fetch_projet(); |
|
437
|
|
|
} |
|
438
|
|
|
|
|
439
|
|
|
$resarray[$array_key.'_project_ref'] = $object->project->ref; |
|
440
|
|
|
$resarray[$array_key.'_project_title'] = $object->project->title; |
|
441
|
|
|
$resarray[$array_key.'_project_description'] = $object->project->description; |
|
442
|
|
|
$resarray[$array_key.'_project_date_start'] = dol_print_date($object->project->date_start, 'day'); |
|
443
|
|
|
$resarray[$array_key.'_project_date_end'] = dol_print_date($object->project->date_end, 'day'); |
|
444
|
|
|
} |
|
445
|
|
|
|
|
446
|
|
|
// Add vat by rates |
|
447
|
|
|
if (is_array($object->lines) && count($object->lines)>0) |
|
448
|
|
|
{ |
|
449
|
|
|
foreach ($object->lines as $line) |
|
450
|
|
|
{ |
|
451
|
|
|
// $line->tva_tx format depends on database field accuraty, no reliable. This is kept for backward comaptibility |
|
452
|
|
|
if (empty($resarray[$array_key.'_total_vat_'.$line->tva_tx])) $resarray[$array_key.'_total_vat_'.$line->tva_tx]=0; |
|
453
|
|
|
$resarray[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva; |
|
454
|
|
|
$resarray[$array_key.'_total_vat_locale_'.$line->tva_tx]=price($resarray[$array_key.'_total_vat_'.$line->tva_tx]); |
|
455
|
|
|
// $vatformated is vat without not expected chars (so 20, or 8.5 or 5.99 for example) |
|
456
|
|
|
$vatformated=vatrate($line->tva_tx); |
|
457
|
|
|
if (empty($resarray[$array_key.'_total_vat_'.$vatformated])) $resarray[$array_key.'_total_vat_'.$vatformated]=0; |
|
458
|
|
|
$resarray[$array_key.'_total_vat_'.$vatformated]+=$line->total_tva; |
|
459
|
|
|
$resarray[$array_key.'_total_vat_locale_'.$vatformated]=price($resarray[$array_key.'_total_vat_'.$vatformated]); |
|
460
|
|
|
} |
|
461
|
|
|
} |
|
462
|
|
|
// Retrieve extrafields |
|
463
|
|
|
if (is_array($object->array_options) && count($object->array_options)) |
|
464
|
|
|
{ |
|
465
|
|
|
$extrafieldkey=$object->element; |
|
466
|
|
|
|
|
467
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
|
468
|
|
|
$extrafields = new ExtraFields($this->db); |
|
469
|
|
|
$extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey,true); |
|
470
|
|
|
$object->fetch_optionals(); |
|
471
|
|
|
|
|
472
|
|
|
$resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key,$outputlangs); |
|
473
|
|
|
} |
|
474
|
|
|
return $resarray; |
|
475
|
|
|
} |
|
476
|
|
|
|
|
477
|
|
|
/** |
|
478
|
|
|
* Define array with couple substitution key => substitution value |
|
479
|
|
|
* |
|
480
|
|
|
* @param array $line Array of lines |
|
481
|
|
|
* @param Translate $outputlangs Lang object to use for output |
|
482
|
|
|
* @return array Return a substitution array |
|
483
|
|
|
*/ |
|
484
|
|
|
function get_substitutionarray_lines($line,$outputlangs) |
|
485
|
|
|
{ |
|
486
|
|
|
global $conf; |
|
487
|
|
|
|
|
488
|
|
|
$resarray= array( |
|
489
|
|
|
'line_fulldesc'=>doc_getlinedesc($line,$outputlangs), |
|
490
|
|
|
'line_product_ref'=>$line->product_ref, |
|
491
|
|
|
'line_product_label'=>$line->product_label, |
|
492
|
|
|
'line_product_type'=>$line->product_type, |
|
493
|
|
|
'line_desc'=>$line->desc, |
|
494
|
|
|
'line_vatrate'=>vatrate($line->tva_tx,true,$line->info_bits), |
|
495
|
|
|
'line_up'=>price2num($line->subprice), |
|
496
|
|
|
'line_up_locale'=>price($line->subprice, 0, $outputlangs), |
|
497
|
|
|
'line_qty'=>$line->qty, |
|
498
|
|
|
'line_discount_percent'=>($line->remise_percent?$line->remise_percent.'%':''), |
|
499
|
|
|
'line_price_ht'=>price2num($line->total_ht), |
|
500
|
|
|
'line_price_ttc'=>price2num($line->total_ttc), |
|
501
|
|
|
'line_price_vat'=>price2num($line->total_tva), |
|
502
|
|
|
'line_price_ht_locale'=>price($line->total_ht, 0, $outputlangs), |
|
503
|
|
|
'line_price_ttc_locale'=>price($line->total_ttc, 0, $outputlangs), |
|
504
|
|
|
'line_price_vat_locale'=>price($line->total_tva, 0, $outputlangs), |
|
505
|
|
|
// Dates |
|
506
|
|
|
'line_date_start'=>dol_print_date($line->date_start, 'day', 'tzuser'), |
|
507
|
|
|
'line_date_start_locale'=>dol_print_date($line->date_start, 'day', 'tzuser', $outputlangs), |
|
508
|
|
|
'line_date_start_rfc'=>dol_print_date($line->date_start, 'dayrfc', 'tzuser'), |
|
509
|
|
|
'line_date_end'=>dol_print_date($line->date_end, 'day', 'tzuser'), |
|
510
|
|
|
'line_date_end_locale'=>dol_print_date($line->date_end, 'day', 'tzuser', $outputlangs), |
|
511
|
|
|
'line_date_end_rfc'=>dol_print_date($line->date_end, 'dayrfc', 'tzuser'), |
|
512
|
|
|
|
|
513
|
|
|
'line_multicurrency_code' => price2num($line->multicurrency_code), |
|
514
|
|
|
'line_multicurrency_subprice' => price2num($line->multicurrency_subprice), |
|
515
|
|
|
'line_multicurrency_total_ht' => price2num($line->multicurrency_total_ht), |
|
516
|
|
|
'line_multicurrency_total_tva' => price2num($line->multicurrency_total_tva), |
|
517
|
|
|
'line_multicurrency_total_ttc' => price2num($line->multicurrency_total_ttc), |
|
518
|
|
|
'line_multicurrency_subprice_locale' => price($line->multicurrency_subprice, 0, $outputlangs), |
|
519
|
|
|
'line_multicurrency_total_ht_locale' => price($line->multicurrency_total_ht, 0, $outputlangs), |
|
520
|
|
|
'line_multicurrency_total_tva_locale' => price($line->multicurrency_total_tva, 0, $outputlangs), |
|
521
|
|
|
'line_multicurrency_total_ttc_locale' => price($line->multicurrency_total_ttc, 0, $outputlangs), |
|
522
|
|
|
); |
|
523
|
|
|
|
|
524
|
|
|
// Units |
|
525
|
|
|
if ($conf->global->PRODUCT_USE_UNITS) |
|
526
|
|
|
{ |
|
527
|
|
|
$resarray['line_unit']=$outputlangs->trans($line->getLabelOfUnit('long')); |
|
|
|
|
|
|
528
|
|
|
$resarray['line_unit_short']=$outputlangs->trans($line->getLabelOfUnit('short')); |
|
|
|
|
|
|
529
|
|
|
} |
|
530
|
|
|
|
|
531
|
|
|
// Retrieve extrafields |
|
532
|
|
|
$extrafieldkey=$line->element; |
|
533
|
|
|
$array_key="line"; |
|
534
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
|
535
|
|
|
$extrafields = new ExtraFields($this->db); |
|
536
|
|
|
$extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey,true); |
|
537
|
|
|
$line->fetch_optionals(); |
|
|
|
|
|
|
538
|
|
|
|
|
539
|
|
|
$resarray = $this->fill_substitutionarray_with_extrafields($line,$resarray,$extrafields,$array_key=$array_key,$outputlangs); |
|
540
|
|
|
|
|
541
|
|
|
// Load product data optional fields to the line -> enables to use "line_options_{extrafield}" |
|
542
|
|
|
if (isset($line->fk_product) && $line->fk_product > 0) |
|
543
|
|
|
{ |
|
544
|
|
|
$tmpproduct = new Product($this->db); |
|
545
|
|
|
$result = $tmpproduct->fetch($line->fk_product); |
|
546
|
|
|
foreach($tmpproduct->array_options as $key=>$label) |
|
547
|
|
|
$resarray["line_".$key] = $label; |
|
548
|
|
|
} |
|
549
|
|
|
|
|
550
|
|
|
return $resarray; |
|
551
|
|
|
} |
|
552
|
|
|
|
|
553
|
|
|
/** |
|
554
|
|
|
* Define array with couple substitution key => substitution value |
|
555
|
|
|
* |
|
556
|
|
|
* @param Expedition $object Main object to use as data source |
|
557
|
|
|
* @param Translate $outputlangs Lang object to use for output |
|
558
|
|
|
* @param array_key $array_key Name of the key for return array |
|
559
|
|
|
* @return array Array of substitution |
|
560
|
|
|
*/ |
|
561
|
|
|
function get_substitutionarray_shipment($object,$outputlangs,$array_key='object') |
|
562
|
|
|
{ |
|
563
|
|
|
global $conf; |
|
564
|
|
|
dol_include_once('/core/lib/product.lib.php'); |
|
565
|
|
|
$object->list_delivery_methods($object->shipping_method_id); |
|
566
|
|
|
$calculatedVolume=($object->trueWidth * $object->trueHeight * $object->trueDepth); |
|
567
|
|
|
|
|
568
|
|
|
$array_shipment=array( |
|
569
|
|
|
$array_key.'_id'=>$object->id, |
|
570
|
|
|
$array_key.'_ref'=>$object->ref, |
|
571
|
|
|
$array_key.'_ref_ext'=>$object->ref_ext, |
|
572
|
|
|
$array_key.'_ref_customer'=>$object->ref_customer, |
|
573
|
|
|
$array_key.'_date_delivery'=>dol_print_date($object->date_delivery,'day'), |
|
574
|
|
|
$array_key.'_hour_delivery'=>dol_print_date($object->date_delivery,'hour'), |
|
575
|
|
|
$array_key.'_date_creation'=>dol_print_date($object->date_creation,'day'), |
|
576
|
|
|
$array_key.'_total_ht'=>price($object->total_ht), |
|
577
|
|
|
$array_key.'_total_vat'=>price($object->total_tva), |
|
578
|
|
|
$array_key.'_total_ttc'=>price($object->total_ttc), |
|
579
|
|
|
$array_key.'_total_discount_ht' => price($object->getTotalDiscount()), |
|
580
|
|
|
$array_key.'_note_private'=>$object->note_private, |
|
581
|
|
|
$array_key.'_note'=>$object->note_public, |
|
582
|
|
|
$array_key.'_tracking_number'=>$object->tracking_number, |
|
583
|
|
|
$array_key.'_tracking_url'=>$object->tracking_url, |
|
584
|
|
|
$array_key.'_shipping_method'=>$object->listmeths[0]['libelle'], |
|
585
|
|
|
$array_key.'_weight'=>$object->trueWeight.' '.measuring_units_string($object->weight_units, 'weight'), |
|
586
|
|
|
$array_key.'_width'=>$object->trueWidth.' '.measuring_units_string($object->width_units, 'size'), |
|
587
|
|
|
$array_key.'_height'=>$object->trueHeight.' '.measuring_units_string($object->height_units, 'size'), |
|
588
|
|
|
$array_key.'_depth'=>$object->trueDepth.' '.measuring_units_string($object->depth_units, 'size'), |
|
589
|
|
|
$array_key.'_size'=>$calculatedVolume.' '.measuring_units_string(0, 'volume'), |
|
590
|
|
|
); |
|
591
|
|
|
|
|
592
|
|
|
// Add vat by rates |
|
593
|
|
|
foreach ($object->lines as $line) |
|
594
|
|
|
{ |
|
595
|
|
|
if (empty($array_shipment[$array_key.'_total_vat_'.$line->tva_tx])) $array_shipment[$array_key.'_total_vat_'.$line->tva_tx]=0; |
|
596
|
|
|
$array_shipment[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva; |
|
597
|
|
|
} |
|
598
|
|
|
|
|
599
|
|
|
// Retrieve extrafields |
|
600
|
|
|
/*if(is_array($object->array_options) && count($object->array_options)) |
|
601
|
|
|
{ |
|
602
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
|
603
|
|
|
$extrafields = new ExtraFields($this->db); |
|
604
|
|
|
$extralabels = $extrafields->fetch_name_optionals_label('shipment',true); |
|
605
|
|
|
$object->fetch_optionals(); |
|
606
|
|
|
|
|
607
|
|
|
$array_shipment = $this->fill_substitutionarray_with_extrafields($object,$array_shipment,$extrafields,$array_key,$outputlangs); |
|
608
|
|
|
}*/ |
|
609
|
|
|
return $array_shipment; |
|
610
|
|
|
} |
|
611
|
|
|
|
|
612
|
|
|
|
|
613
|
|
|
/** |
|
614
|
|
|
* Define array with couple substitution key => substitution value |
|
615
|
|
|
* |
|
616
|
|
|
* @param array $line Array of lines |
|
617
|
|
|
* @param Translate $outputlangs Lang object to use for output |
|
618
|
|
|
* @return array Substitution array |
|
619
|
|
|
*/ |
|
620
|
|
|
function get_substitutionarray_shipment_lines($line,$outputlangs) |
|
621
|
|
|
{ |
|
622
|
|
|
global $conf; |
|
623
|
|
|
dol_include_once('/core/lib/product.lib.php'); |
|
624
|
|
|
|
|
625
|
|
|
return array( |
|
626
|
|
|
'line_fulldesc'=>doc_getlinedesc($line,$outputlangs), |
|
627
|
|
|
'line_product_ref'=>$line->product_ref, |
|
628
|
|
|
'line_product_label'=>$line->product_label, |
|
629
|
|
|
'line_desc'=>$line->desc, |
|
630
|
|
|
'line_vatrate'=>vatrate($line->tva_tx,true,$line->info_bits), |
|
631
|
|
|
'line_up'=>price($line->subprice), |
|
632
|
|
|
'line_qty'=>$line->qty, |
|
633
|
|
|
'line_qty_shipped'=>$line->qty_shipped, |
|
634
|
|
|
'line_qty_asked'=>$line->qty_asked, |
|
635
|
|
|
'line_discount_percent'=>($line->remise_percent?$line->remise_percent.'%':''), |
|
636
|
|
|
'line_price_ht'=>price($line->total_ht), |
|
637
|
|
|
'line_price_ttc'=>price($line->total_ttc), |
|
638
|
|
|
'line_price_vat'=>price($line->total_tva), |
|
639
|
|
|
'line_weight'=>empty($line->weight) ? '' : $line->weight*$line->qty_shipped.' '.measuring_units_string($line->weight_units, 'weight'), |
|
640
|
|
|
'line_length'=>empty($line->length) ? '' : $line->length*$line->qty_shipped.' '.measuring_units_string($line->length_units, 'size'), |
|
641
|
|
|
'line_surface'=>empty($line->surface) ? '' : $line->surface*$line->qty_shipped.' '.measuring_units_string($line->surface_units, 'surface'), |
|
642
|
|
|
'line_volume'=>empty($line->volume) ? '' : $line->volume*$line->qty_shipped.' '.measuring_units_string($line->volume_units, 'volume'), |
|
643
|
|
|
); |
|
644
|
|
|
} |
|
645
|
|
|
|
|
646
|
|
|
|
|
647
|
|
|
/** |
|
648
|
|
|
* Define array with couple subtitution key => subtitution value |
|
649
|
|
|
* |
|
650
|
|
|
* @param Object $object Dolibarr Object |
|
651
|
|
|
* @param Translate $outputlangs Language object for output |
|
652
|
|
|
* @param boolean $recursive Want to fetch child array or child object |
|
653
|
|
|
* @return array Array of substitution key->code |
|
654
|
|
|
*/ |
|
655
|
|
|
function get_substitutionarray_each_var_object(&$object,$outputlangs,$recursive=true) { |
|
656
|
|
|
$array_other = array(); |
|
657
|
|
|
if(!empty($object)) { |
|
658
|
|
|
foreach($object as $key => $value) { |
|
659
|
|
|
if(!empty($value)) { |
|
660
|
|
|
if(!is_array($value) && !is_object($value)) { |
|
661
|
|
|
$array_other['object_'.$key] = $value; |
|
662
|
|
|
} |
|
663
|
|
|
if(is_array($value) && $recursive){ |
|
664
|
|
|
$array_other['object_'.$key] = $this->get_substitutionarray_each_var_object($value,$outputlangs,false); |
|
665
|
|
|
} |
|
666
|
|
|
} |
|
667
|
|
|
} |
|
668
|
|
|
} |
|
669
|
|
|
return $array_other; |
|
670
|
|
|
} |
|
671
|
|
|
|
|
672
|
|
|
|
|
673
|
|
|
/** |
|
674
|
|
|
* Fill array with couple extrafield key => extrafield value |
|
675
|
|
|
* |
|
676
|
|
|
* @param Object $object Object with extrafields (must have $object->array_options filled) |
|
677
|
|
|
* @param array $array_to_fill Substitution array |
|
678
|
|
|
* @param Extrafields $extrafields Extrafields object |
|
679
|
|
|
* @param string $array_key Prefix for name of the keys into returned array |
|
680
|
|
|
* @param Translate $outputlangs Lang object to use for output |
|
681
|
|
|
* @return array Substitution array |
|
682
|
|
|
*/ |
|
683
|
|
|
function fill_substitutionarray_with_extrafields($object,$array_to_fill,$extrafields,$array_key,$outputlangs) |
|
684
|
|
|
{ |
|
685
|
|
|
global $conf; |
|
686
|
|
|
foreach($extrafields->attribute_label as $key=>$label) |
|
687
|
|
|
{ |
|
688
|
|
|
if($extrafields->attribute_type[$key] == 'price') |
|
689
|
|
|
{ |
|
690
|
|
|
$object->array_options['options_'.$key] = price2num($object->array_options['options_'.$key]); |
|
691
|
|
|
$object->array_options['options_'.$key.'_currency'] = price($object->array_options['options_'.$key],0,$outputlangs,0,0,-1,$conf->currency); |
|
692
|
|
|
//Add value to store price with currency |
|
693
|
|
|
$array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_currency' => $object->array_options['options_'.$key.'_currency'])); |
|
694
|
|
|
} |
|
695
|
|
|
else if($extrafields->attribute_type[$key] == 'select' || $extrafields->attribute_type[$key] == 'checkbox') |
|
696
|
|
|
{ |
|
697
|
|
|
$object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]]; |
|
698
|
|
|
} |
|
699
|
|
|
else if($extrafields->attribute_type[$key] == 'date') |
|
700
|
|
|
{ |
|
701
|
|
|
if (strlen($object->array_options['options_'.$key])>0) |
|
702
|
|
|
{ |
|
703
|
|
|
$date = $object->array_options['options_'.$key]; |
|
704
|
|
|
$object->array_options['options_'.$key] = dol_print_date($date,'day'); // using company output language |
|
705
|
|
|
$object->array_options['options_'.$key.'_locale'] = dol_print_date($date,'day','tzserver',$outputlangs); // using output language format |
|
706
|
|
|
$object->array_options['options_'.$key.'_rfc'] = dol_print_date($date,'dayrfc'); // international format |
|
707
|
|
|
} |
|
708
|
|
|
else |
|
709
|
|
|
{ |
|
710
|
|
|
$object->array_options['options_'.$key] = ''; |
|
711
|
|
|
$object->array_options['options_'.$key.'_locale'] = ''; |
|
712
|
|
|
$object->array_options['options_'.$key.'_rfc'] = ''; |
|
713
|
|
|
} |
|
714
|
|
|
$array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); |
|
715
|
|
|
$array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); |
|
716
|
|
|
} |
|
717
|
|
|
else if($extrafields->attribute_type[$key] == 'datetime') |
|
718
|
|
|
{ |
|
719
|
|
|
$datetime = $object->array_options['options_'.$key]; |
|
720
|
|
|
$object->array_options['options_'.$key] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key],'dayhour'):''); // using company output language |
|
721
|
|
|
$object->array_options['options_'.$key.'_locale'] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key],'dayhour','tzserver',$outputlangs):''); // using output language format |
|
722
|
|
|
$object->array_options['options_'.$key.'_rfc'] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key],'dayhourrfc'):''); // international format |
|
723
|
|
|
$array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); |
|
724
|
|
|
$array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); |
|
725
|
|
|
} |
|
726
|
|
|
$array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key => $object->array_options['options_'.$key])); |
|
727
|
|
|
} |
|
728
|
|
|
|
|
729
|
|
|
return $array_to_fill; |
|
730
|
|
|
|
|
731
|
|
|
} |
|
732
|
|
|
|
|
733
|
|
|
|
|
734
|
|
|
/** |
|
735
|
|
|
* Rect pdf |
|
736
|
|
|
* |
|
737
|
|
|
* @param PDF $pdf Object PDF |
|
738
|
|
|
* @param float $x Abscissa of first point |
|
739
|
|
|
* @param float $y Ordinate of first point |
|
740
|
|
|
* @param float $l ?? |
|
741
|
|
|
* @param float $h ?? |
|
742
|
|
|
* @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title |
|
743
|
|
|
* @param int $hidebottom Hide bottom |
|
744
|
|
|
* @return void |
|
745
|
|
|
*/ |
|
746
|
|
|
function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0) |
|
747
|
|
|
{ |
|
748
|
|
|
if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y); |
|
749
|
|
|
$pdf->line($x+$l, $y, $x+$l, $y+$h); |
|
750
|
|
|
if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
751
|
|
|
$pdf->line($x, $y+$h, $x, $y); |
|
752
|
|
|
} |
|
753
|
|
|
} |
|
754
|
|
|
|
|
755
|
|
|
|