Passed
Branch develop (42ca3b)
by
unknown
27:32
created

FormAccounting::select_bookkeeping_importkey()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 23
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 13
c 0
b 0
f 0
nc 3
nop 2
dl 0
loc 23
rs 9.8333
1
<?php
2
/* Copyright (C) 2013-2016 Florian Henry        <[email protected]>
3
 * Copyright (C) 2013-2014 Olivier Geffroy      <[email protected]>
4
 * Copyright (C) 2015      Ari Elbaz (elarifr)  <[email protected]>
5
 * Copyright (C) 2016      Marcos García        <[email protected]>
6
 * Copyright (C) 2016-2020 Alexandre Spangaro   <[email protected]>
7
 *
8
 * This program is free software; you can redistribute it and/or modify
9
 * it under the terms of the GNU General Public License as published by
10
 * the Free Software Foundation; either version 3 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20
 */
21
22
/**
23
 *	\file       htdocs/core/class/html.formaccounting.class.php
24
 *  \ingroup    Accountancy (Double entries)
25
 *	\brief      File of class with all html predefined components
26
 */
27
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
28
29
30
/**
31
 *	Class to manage generation of HTML components for accounting management
32
 */
33
class FormAccounting extends Form
34
{
35
36
	private $options_cache = array();
37
38
	/**
39
	 * @var DoliDB Database handler.
40
	 */
41
	public $db;
42
43
	/**
44
	 * @var string Error code (or message)
45
	 */
46
	public $error = '';
47
48
	/**
49
	 * Constructor
50
	 *
51
	 * @param		DoliDB		$db      Database handler
52
	 */
53
	public function __construct($db)
54
	{
55
		$this->db = $db;
56
	}
57
58
	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
59
	/**
60
	 * Return list of journals with label by nature
61
	 *
62
	 * @param	string	$selectid	Preselected journal code
63
	 * @param	string	$htmlname	Name of field in html form
64
	 * @param	int		$nature		Limit the list to a particular type of journals (1:various operations / 2:sale / 3:purchase / 4:bank / 9: has-new)
65
	 * @param	int		$showempty	Add an empty field
66
	 * @param	int		$select_in	0=selectid value is the journal rowid (default) or 1=selectid is journal code
67
	 * @param	int		$select_out	Set value returned by select. 0=rowid (default), 1=code
68
	 * @param	string	$morecss	More css non HTML object
69
	 * @param	string	$usecache	Key to use to store result into a cache. Next call with same key will reuse the cache.
70
	 * @param   int     $disabledajaxcombo Disable ajax combo box.
71
	 * @return	string				String with HTML select
72
	 */
73
	public function select_journal($selectid, $htmlname = 'journal', $nature = 0, $showempty = 0, $select_in = 0, $select_out = 0, $morecss = 'maxwidth300 maxwidthonsmartphone', $usecache = '', $disabledajaxcombo = 0)
74
	{
75
		// phpcs:enable
76
		global $conf, $langs;
77
78
		$out = '';
79
80
		$options = array();
81
		if ($usecache && !empty($this->options_cache[$usecache]))
82
		{
83
			$options = $this->options_cache[$usecache];
84
			$selected = $selectid;
85
		} else {
86
			$sql = "SELECT rowid, code, label, nature, entity, active";
87
			$sql .= " FROM ".MAIN_DB_PREFIX."accounting_journal";
88
			$sql .= " WHERE active = 1";
89
			$sql .= " AND entity = ".$conf->entity;
90
			if ($nature && is_numeric($nature))   $sql .= " AND nature = ".$nature;
91
			$sql .= " ORDER BY code";
92
93
			dol_syslog(get_class($this)."::select_journal", LOG_DEBUG);
94
			$resql = $this->db->query($sql);
95
96
			if (!$resql) {
97
				$this->error = "Error ".$this->db->lasterror();
98
				dol_syslog(get_class($this)."::select_journal ".$this->error, LOG_ERR);
99
				return -1;
100
			}
101
102
			$selected = 0;
103
			$langs->load('accountancy');
104
			while ($obj = $this->db->fetch_object($resql))
105
			{
106
				$label = $obj->code.' - '.$langs->trans($obj->label);
107
108
				$select_value_in = $obj->rowid;
109
				$select_value_out = $obj->rowid;
110
111
				// Try to guess if we have found default value
112
				if ($select_in == 1) {
113
					$select_value_in = $obj->code;
114
				}
115
				if ($select_out == 1) {
116
					$select_value_out = $obj->code;
117
				}
118
				// Remember guy's we store in database llx_accounting_bookkeeping the code of accounting_journal and not the rowid
119
				if ($selectid != '' && $selectid == $select_value_in) {
120
					//var_dump("Found ".$selectid." ".$select_value_in);
121
					$selected = $select_value_out;
122
				}
123
124
				$options[$select_value_out] = $label;
125
			}
126
			$this->db->free($resql);
127
128
			if ($usecache)
129
			{
130
				$this->options_cache[$usecache] = $options;
131
			}
132
		}
133
134
		$out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, ($disabledajaxcombo ? 0 : 1));
135
136
		return $out;
137
	}
138
139
	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
140
	/**
141
	 * Return list of journals with label by nature
142
	 *
143
	 * @param	array	$selectedIds	Preselected journal code array
144
	 * @param	string	$htmlname	Name of field in html form
145
	 * @param	int		$nature		Limit the list to a particular type of journals (1:various operations / 2:sale / 3:purchase / 4:bank / 9: has-new)
146
	 * @param	int		$showempty	Add an empty field
147
	 * @param	int		$select_in	0=selectid value is the journal rowid (default) or 1=selectid is journal code
148
	 * @param	int		$select_out	Set value returned by select. 0=rowid (default), 1=code
149
	 * @param	string	$morecss	More css non HTML object
150
	 * @param	string	$usecache	Key to use to store result into a cache. Next call with same key will reuse the cache.
151
	 * @param   int     $disabledajaxcombo Disable ajax combo box.
152
	 * @return	string				String with HTML select
153
	 */
154
	public function multi_select_journal($selectedIds = array(), $htmlname = 'journal', $nature = 0, $showempty = 0, $select_in = 0, $select_out = 0, $morecss = '', $usecache = '', $disabledajaxcombo = 0)
155
	{
156
		// phpcs:enable
157
		global $conf, $langs;
158
159
		$out = '';
160
161
		$options = array();
162
		if ($usecache && !empty($this->options_cache[$usecache]))
163
		{
164
			$options = $this->options_cache[$usecache];
165
			$selected = $selectedIds;
166
		} else {
167
			$sql = "SELECT rowid, code, label, nature, entity, active";
168
			$sql .= " FROM ".MAIN_DB_PREFIX."accounting_journal";
169
			$sql .= " WHERE active = 1";
170
			$sql .= " AND entity = ".$conf->entity;
171
			if ($nature && is_numeric($nature))   $sql .= " AND nature = ".$nature;
172
			$sql .= " ORDER BY code";
173
174
			dol_syslog(get_class($this)."::multi_select_journal", LOG_DEBUG);
175
			$resql = $this->db->query($sql);
176
177
			if (!$resql) {
178
				$this->error = "Error ".$this->db->lasterror();
179
				dol_syslog(get_class($this)."::multi_select_journal ".$this->error, LOG_ERR);
180
				return -1;
181
			}
182
183
			$selected = array();
184
			$langs->load('accountancy');
185
			while ($obj = $this->db->fetch_object($resql))
186
			{
187
				$label = $langs->trans($obj->label);
188
189
				$select_value_in = $obj->rowid;
190
				$select_value_out = $obj->rowid;
191
192
				// Try to guess if we have found default value
193
				if ($select_in == 1) {
194
					$select_value_in = $obj->code;
195
				}
196
				if ($select_out == 1) {
197
					$select_value_out = $obj->code;
198
				}
199
				// Remember guy's we store in database llx_accounting_bookkeeping the code of accounting_journal and not the rowid
200
				if (!empty($selectedIds) && in_array($select_value_in, $selectedIds)) {
201
					//var_dump("Found ".$selectid." ".$select_value_in);
202
					$selected[] = $select_value_out;
203
				}
204
				$options[$select_value_out] = $label;
205
			}
206
			$this->db->free($resql);
207
208
			if ($usecache)
209
			{
210
				$this->options_cache[$usecache] = $options;
211
			}
212
		}
213
214
		$out .= Form::multiselectarray($htmlname, $options, $selected, $showempty, 0, $morecss, 0, 0, 0, 'code_journal', '', ($disabledajaxcombo ? 0 : 1));
215
216
		return $out;
217
	}
218
219
	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
220
	/**
221
	 *	Return list of accounting category.
222
	 * 	Use mysoc->country_id or mysoc->country_code so they must be defined.
223
	 *
224
	 *	@param	string	$selected       Preselected type
225
	 *	@param  string	$htmlname       Name of field in form
226
	 * 	@param	int		$useempty		Set to 1 if we want an empty value
227
	 * 	@param	int		$maxlen			Max length of text in combo box
228
	 * 	@param	int		$help			Add or not the admin help picto
229
	 *  @param  int     $allcountries   All countries
230
	 * 	@return	void
231
	 */
232
	public function select_accounting_category($selected = '', $htmlname = 'account_category', $useempty = 0, $maxlen = 0, $help = 1, $allcountries = 0)
233
	{
234
		// phpcs:enable
235
		global $db, $langs, $user, $mysoc;
236
237
		if (empty($mysoc->country_id) && empty($mysoc->country_code) && empty($allcountries))
238
		{
239
			dol_print_error('', 'Call to select_accounting_account with mysoc country not yet defined');
240
			exit;
241
		}
242
243
		if (!empty($mysoc->country_id))
244
		{
245
			$sql = "SELECT c.rowid, c.label as type, c.range_account";
246
			$sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c";
247
			$sql .= " WHERE c.active = 1";
248
			$sql .= " AND c.category_type = 0";
249
			if (empty($allcountries)) $sql .= " AND c.fk_country = ".$mysoc->country_id;
250
			$sql .= " ORDER BY c.label ASC";
251
		} else {
252
			$sql = "SELECT c.rowid, c.label as type, c.range_account";
253
			$sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c, ".MAIN_DB_PREFIX."c_country as co";
254
			$sql .= " WHERE c.active = 1";
255
			$sql .= " AND c.category_type = 0";
256
			$sql .= " AND c.fk_country = co.rowid";
257
			if (empty($allcountries)) $sql .= " AND co.code = '".$this->db->escape($mysoc->country_code)."'";
258
			$sql .= " ORDER BY c.label ASC";
259
		}
260
261
		dol_syslog(get_class($this).'::'.__METHOD__, LOG_DEBUG);
262
		$resql = $this->db->query($sql);
263
		if ($resql)
264
		{
265
			$num = $this->db->num_rows($resql);
266
			if ($num)
267
			{
268
				$out = '<select class="flat minwidth200" id="'.$htmlname.'" name="'.$htmlname.'">';
269
				$i = 0;
270
271
				if ($useempty) $out .= '<option value="0">&nbsp;</option>';
272
				while ($i < $num)
273
				{
274
					$obj = $this->db->fetch_object($resql);
275
					$out .= '<option value="'.$obj->rowid.'"';
276
					if ($obj->rowid == $selected) $out .= ' selected';
277
					$out .= '>'.($maxlen ? dol_trunc($obj->type, $maxlen) : $obj->type);
278
					$out .= ' ('.$obj->range_account.')';
279
					$i++;
280
				}
281
				$out .= '</select>';
282
				//if ($user->admin && $help) $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
283
			} else {
284
				$out .= $langs->trans("ErrorNoAccountingCategoryForThisCountry", $mysoc->country_code);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $out seems to be never defined.
Loading history...
285
			}
286
		} else {
287
			dol_print_error($this->db);
288
		}
289
290
		$out .= ajax_combobox($htmlname, array());
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $out does not seem to be defined for all execution paths leading up to this point.
Loading history...
291
292
		print $out;
293
	}
294
295
	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
296
	/**
297
	 * Return select filter with date of transaction
298
	 *
299
	 * @param string $htmlname         Name of select field
300
	 * @param string $selectedkey      Value
301
	 * @return string                  HTML edit field
302
	 */
303
	public function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey = '')
304
	{
305
		// phpcs:enable
306
		$options = array();
307
308
		$sql = 'SELECT DISTINCT import_key from '.MAIN_DB_PREFIX.'accounting_bookkeeping';
309
		$sql .= " WHERE entity IN (".getEntity('accountancy').")";
310
		$sql .= ' ORDER BY import_key DESC';
311
312
		dol_syslog(get_class($this)."::select_bookkeeping_importkey", LOG_DEBUG);
313
		$resql = $this->db->query($sql);
314
315
		if (!$resql) {
316
			$this->error = "Error ".$this->db->lasterror();
317
			dol_syslog(get_class($this)."::select_bookkeeping_importkey ".$this->error, LOG_ERR);
318
			return -1;
319
		}
320
321
		while ($obj = $this->db->fetch_object($resql)) {
322
			$options[$obj->import_key] = $obj->import_key;
323
		}
324
325
		return Form::selectarray($htmlname, $options, $selectedkey);
326
	}
327
328
	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
329
	/**
330
	 * Return list of accounts with label by chart of accounts
331
	 *
332
	 * @param string   $selectid           Preselected id of accounting accounts (depends on $select_in)
333
	 * @param string   $htmlname           Name of HTML field id. If name start with '.', it is name of HTML css class, so several component with same name in different forms can be used.
334
	 * @param int      $showempty          1=Add an empty field, 2=Add an empty field+'None' field
335
	 * @param array    $event              Event options
336
	 * @param int      $select_in          0=selectid value is a aa.rowid (default) or 1=selectid is aa.account_number
337
	 * @param int      $select_out         Set value returned by select. 0=rowid (default), 1=account_number
338
	 * @param string   $morecss            More css non HTML object
339
	 * @param string   $usecache           Key to use to store result into a cache. Next call with same key will reuse the cache.
340
	 * @return string                      String with HTML select
341
	 */
342
	public function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $morecss = 'maxwidth300 maxwidthonsmartphone', $usecache = '')
343
	{
344
		// phpcs:enable
345
		global $conf, $langs;
346
347
		require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
348
349
		$out = '';
350
351
		$options = array();
352
353
		if ($showempty == 2)
354
		{
355
			$options['0'] = '--- '.$langs->trans("None").' ---';
356
		}
357
358
		if ($usecache && !empty($this->options_cache[$usecache]))
359
		{
360
			$options = $options + $this->options_cache[$usecache]; // We use + instead of array_merge because we don't want to reindex key from 0
361
			$selected = $selectid;
362
		} else {
363
			$trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT) ? 50 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT;
364
365
			$sql = "SELECT DISTINCT aa.account_number, aa.label, aa.labelshort, aa.rowid, aa.fk_pcg_version";
366
			$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa";
367
			$sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
368
			$sql .= " AND asy.rowid = ".$conf->global->CHARTOFACCOUNTS;
369
			$sql .= " AND aa.active = 1";
370
			$sql .= " AND aa.entity=".$conf->entity;
371
			$sql .= " ORDER BY aa.account_number";
372
373
			dol_syslog(get_class($this)."::select_account", LOG_DEBUG);
374
			$resql = $this->db->query($sql);
375
376
			if (!$resql) {
377
				$this->error = "Error ".$this->db->lasterror();
378
				dol_syslog(get_class($this)."::select_account ".$this->error, LOG_ERR);
379
				return -1;
380
			}
381
382
			$selected = $selectid; // selectid can be -1, 0, 123
383
			while ($obj = $this->db->fetch_object($resql))
384
			{
385
				if (empty($obj->labelshort))
386
				{
387
					$labeltoshow = $obj->label;
388
				} else {
389
					$labeltoshow = $obj->labelshort;
390
				}
391
392
				$label = length_accountg($obj->account_number).' - '.$labeltoshow;
393
				$label = dol_trunc($label, $trunclength);
394
395
				$select_value_in = $obj->rowid;
396
				$select_value_out = $obj->rowid;
397
398
				// Try to guess if we have found default value
399
				if ($select_in == 1) {
400
					$select_value_in = $obj->account_number;
401
				}
402
				if ($select_out == 1) {
403
					$select_value_out = $obj->account_number;
404
				}
405
				// Remember guy's we store in database llx_facturedet the rowid of accounting_account and not the account_number
406
				// Because same account_number can be share between different accounting_system and do have the same meaning
407
				if ($selectid != '' && $selectid == $select_value_in) {
408
					//var_dump("Found ".$selectid." ".$select_value_in);
409
					$selected = $select_value_out;
410
				}
411
412
				$options[$select_value_out] = $label;
413
			}
414
			$this->db->free($resql);
415
416
			if ($usecache)
417
			{
418
				$this->options_cache[$usecache] = $options;
419
				unset($this->options_cache[$usecache]['0']);
420
			}
421
		}
422
423
		$out .= Form::selectarray($htmlname, $options, $selected, ($showempty > 0 ? 1 : 0), 0, 0, '', 0, 0, 0, '', $morecss, 1);
424
425
		return $out;
426
	}
427
428
	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
429
	/**
430
	 * Return list of auxilary thirdparty accounts
431
	 *
432
	 * @param string   $selectid       Preselected pcg_type
433
	 * @param string   $htmlname       Name of field in html form
434
	 * @param int      $showempty      Add an empty field
435
	 * @param string   $morecss        More css
436
	 * @return string                  String with HTML select
437
	 */
438
	public function select_auxaccount($selectid, $htmlname = 'account_num_aux', $showempty = 0, $morecss = 'maxwidth200')
439
	{
440
		// phpcs:enable
441
442
		$aux_account = array();
443
444
		// Auxiliary customer account
445
		$sql = "SELECT DISTINCT code_compta, nom ";
446
		$sql .= " FROM ".MAIN_DB_PREFIX."societe";
447
		$sql .= " WHERE entity IN (".getEntity('societe').")";
448
		$sql .= " ORDER BY code_compta";
449
450
		dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG);
451
		$resql = $this->db->query($sql);
452
		if ($resql) {
453
			while ($obj = $this->db->fetch_object($resql)) {
454
				if (!empty($obj->code_compta)) {
455
					$aux_account[$obj->code_compta] = $obj->code_compta.' ('.$obj->nom.')';
456
				}
457
			}
458
		} else {
459
			$this->error = "Error ".$this->db->lasterror();
460
			dol_syslog(get_class($this)."::select_auxaccount ".$this->error, LOG_ERR);
461
			return -1;
462
		}
463
		$this->db->free($resql);
464
465
		// Auxiliary supplier account
466
		$sql = "SELECT DISTINCT code_compta_fournisseur, nom ";
467
		$sql .= " FROM ".MAIN_DB_PREFIX."societe";
468
		$sql .= " WHERE entity IN (".getEntity('societe').")";
469
		$sql .= " ORDER BY code_compta_fournisseur";
470
		dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG);
471
		$resql = $this->db->query($sql);
472
		if ($resql) {
473
			while ($obj = $this->db->fetch_object($resql)) {
474
				if ($obj->code_compta_fournisseur != "") {
475
					$aux_account[$obj->code_compta_fournisseur] = $obj->code_compta_fournisseur.' ('.$obj->nom.')';
476
				}
477
			}
478
		} else {
479
			$this->error = "Error ".$this->db->lasterror();
480
			dol_syslog(get_class($this)."::select_auxaccount ".$this->error, LOG_ERR);
481
			return -1;
482
		}
483
		$this->db->free($resql);
484
485
		// Auxiliary user account
486
		$sql = "SELECT DISTINCT accountancy_code, lastname, firstname ";
487
		$sql .= " FROM ".MAIN_DB_PREFIX."user";
488
		$sql .= " WHERE entity IN (".getEntity('user').")";
489
		$sql .= " ORDER BY accountancy_code";
490
		dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG);
491
		$resql = $this->db->query($sql);
492
		if ($resql) {
493
			while ($obj = $this->db->fetch_object($resql)) {
494
				if (!empty($obj->accountancy_code)) {
495
					$aux_account[$obj->accountancy_code] = $obj->accountancy_code.' ('.dolGetFirstLastname($obj->firstname, $obj->lastname).')';
496
				}
497
			}
498
		} else {
499
			$this->error = "Error ".$this->db->lasterror();
500
			dol_syslog(get_class($this)."::select_auxaccount ".$this->error, LOG_ERR);
501
			return -1;
502
		}
503
		$this->db->free($resql);
504
505
		// Build select
506
		$out .= Form::selectarray($htmlname, $aux_account, $selectid, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $out seems to be never defined.
Loading history...
507
508
		return $out;
509
	}
510
511
	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
512
	/**
513
	 * Return HTML combo list of years existing into book keepping
514
	 *
515
	 * @param string 	$selected 		Preselected value
516
	 * @param string 	$htmlname 		Name of HTML select object
517
	 * @param int 		$useempty 		Affiche valeur vide dans liste
518
	 * @param string 	$output_format 	(html/opton (for option html only)/array (to return options arrays
519
	 * @return string|array				HTML select component or array of select options
520
	 */
521
	public function selectyear_accountancy_bookkepping($selected = '', $htmlname = 'yearid', $useempty = 0, $output_format = 'html')
522
	{
523
		// phpcs:enable
524
		global $conf;
525
526
		$out_array = array();
527
528
		$sql = "SELECT DISTINCT date_format(doc_date, '%Y') as dtyear";
529
		$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping";
530
		$sql .= " WHERE entity IN (".getEntity('accountancy').")";
531
		$sql .= " ORDER BY date_format(doc_date, '%Y')";
532
		dol_syslog(__METHOD__, LOG_DEBUG);
533
		$resql = $this->db->query($sql);
534
535
		if (!$resql) {
536
			$this->error = "Error ".$this->db->lasterror();
537
			dol_syslog(__METHOD__.$this->error, LOG_ERR);
538
			return -1;
539
		}
540
		while ($obj = $this->db->fetch_object($resql)) {
541
			$out_array[$obj->dtyear] = $obj->dtyear;
542
		}
543
		$this->db->free($resql);
544
545
		if ($output_format == 'html') {
546
			return Form::selectarray($htmlname, $out_array, $selected, $useempty, 0, 0, 'placeholder="aa"');
547
		} else {
548
			return $out_array;
549
		}
550
	}
551
}
552