63 $options_array = array();
65 $sql =
"SELECT code, label";
66 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_prospectlevel";
67 $sql .=
" WHERE active > 0";
68 $sql .=
" ORDER BY sortorder";
70 $resql = $this->db->query($sql);
72 $num = $this->db->num_rows($resql);
75 $obj = $this->db->fetch_object($resql);
77 $level = $langs->trans($obj->code);
78 if ($level == $obj->code) {
79 $level = $langs->trans($obj->label);
81 $options_array[$obj->code] = $level;
100 global $conf, $langs;
102 $langs->load(
"dict");
106 $stateArray = array();
109 $options_array = array();
111 $sql =
"SELECT d.rowid as rowid, d.code_departement as code, d.nom as department, r.nom as region";
112 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_departements d";
113 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_regions r on d.fk_region=r.code_region";
114 $sql .=
" WHERE d.active = 1 AND d.code_departement<>'' AND r.code_region<>''";
117 $resql = $this->db->query($sql);
119 $num = $this->db->num_rows($resql);
122 $foundselected =
false;
125 $obj = $this->db->fetch_object($resql);
126 $stateArray [$i] [
'rowid'] = $obj->rowid;
127 $stateArray [$i] [
'code'] = $obj->code;
128 $stateArray [$i] [
'label'] = $obj->region.
'/'.$obj->department;
129 $label[$i] = $stateArray[$i][
'label'];
133 $array1_sort_order = SORT_ASC;
134 array_multisort($label, $array1_sort_order, $stateArray);
136 foreach ($stateArray as $row) {
137 $label =
dol_trunc($row[
'label'], $maxlength,
'middle');
139 $label .=
' ('.$row[
'code'].
')';
142 $options_array[$row[
'rowid']] = $label;
161 global $conf, $langs;
163 $langs->load(
"dict");
167 $countryArray = array();
170 $options_array = array();
172 $sql =
"SELECT rowid, code as code_iso, label";
173 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_country";
174 $sql .=
" WHERE active = 1 AND code<>''";
175 $sql .=
" ORDER BY code ASC";
177 $resql = $this->db->query($sql);
179 $num = $this->db->num_rows($resql);
182 $foundselected =
false;
185 $obj = $this->db->fetch_object($resql);
186 $countryArray [$i] [
'rowid'] = $obj->rowid;
187 $countryArray [$i] [
'code_iso'] = $obj->code_iso;
188 $countryArray [$i] [
'label'] = ($obj->code_iso && $langs->transnoentitiesnoconv(
"Country".$obj->code_iso) !=
"Country".$obj->code_iso ? $langs->transnoentitiesnoconv(
"Country".$obj->code_iso) : ($obj->label !=
'-' ? $obj->label :
''));
189 $label[$i] = $countryArray[$i][
'label'];
193 $array1_sort_order = SORT_ASC;
194 array_multisort($label, $array1_sort_order, $countryArray);
196 foreach ($countryArray as $row) {
197 $label =
dol_trunc($row[
'label'], $maxlength,
'middle');
198 if ($row[
'code_iso']) {
199 $label .=
' ('.$row[
'code_iso'].
')';
202 $options_array[$row[
'rowid']] = $label;
224 $options_array = array();
227 $sql_usr .=
"SELECT DISTINCT u2.rowid, u2.lastname as name, u2.firstname, u2.login";
228 $sql_usr .=
" FROM ".MAIN_DB_PREFIX.
"user as u2, ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
229 $sql_usr .=
" WHERE u2.entity IN (0,".$conf->entity.
")";
230 $sql_usr .=
" AND u2.rowid = sc.fk_user";
232 $sql_usr .=
" AND u2.statut <> 0";
235 $sql_usr .=
" AND u2.employee<>0 ";
238 $sql_usr .=
" AND u2.fk_soc IS NULL ";
240 $sql_usr .=
" ORDER BY name ASC";
243 $resql_usr = $this->db->query($sql_usr);
245 while ($obj_usr = $this->db->fetch_object($resql_usr)) {
246 $label = $obj_usr->firstname.
" ".$obj_usr->name.
" (".$obj_usr->login.
')';
248 $options_array [$obj_usr->rowid] = $label;
250 $this->db->free($resql_usr);
267 global $conf, $langs;
269 $options_array = array();
271 $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 12);
273 foreach ($langs_available as $key => $value) {
275 $options_array[$key] = $label;
277 asort($options_array);
292 $options_array = array();
294 if (is_array($sqlqueryparam)) {
295 $param_list = array_keys($sqlqueryparam);
296 $InfoFieldList = explode(
":", $param_list[0], 4);
304 if (count($InfoFieldList) >= 3) {
305 if (strpos($InfoFieldList[3],
'extra.') !==
false) {
306 $keyList =
'main.'.$InfoFieldList[2].
' as rowid';
308 $keyList = $InfoFieldList[2].
' as rowid';
312 $sql =
"SELECT ".$this->db->sanitize($keyList).
", ".$this->db->sanitize($InfoFieldList[1]);
313 $sql .=
" FROM ".$this->db->sanitize(MAIN_DB_PREFIX.$InfoFieldList[0]);
314 if (!empty($InfoFieldList[3])) {
317 if (strpos($InfoFieldList[3],
'extra') !==
false) {
318 $sql .=
' as main, '.$this->db->sanitize(MAIN_DB_PREFIX.$InfoFieldList[0]).
'_extrafields as extra';
319 $sql .=
" WHERE extra.fk_object = main.".$this->db->sanitize(empty($InfoFieldList[2]) ?
'rowid' : $InfoFieldList[2]);
320 $sql .=
" AND ".forgeSQLFromUniversalSearchCriteria($InfoFieldList[3], $errorstr, 1);
322 $sql .=
" WHERE ".forgeSQLFromUniversalSearchCriteria($InfoFieldList[3], $errorstr, 1);
325 if (!empty($InfoFieldList[1])) {
326 $sql .=
" ORDER BY nom";
330 $resql = $this->db->query($sql);
332 $num = $this->db->num_rows($resql);
336 $obj = $this->db->fetch_object($resql);
337 $fieldtoread = $InfoFieldList[1];
338 $labeltoshow =
dol_trunc($obj->$fieldtoread, 90);
339 $options_array[$obj->rowid] = $labeltoshow;
343 $this->db->free($resql);
359 global $conf, $langs, $user;
360 $langs->load(
"dict");
362 $options_array = array();
364 $sql =
"SELECT rowid, code, label as civilite, active FROM ".MAIN_DB_PREFIX.
"c_civility";
365 $sql .=
" WHERE active = 1";
368 $resql = $this->db->query($sql);
370 $num = $this->db->num_rows($resql);
374 $obj = $this->db->fetch_object($resql);
376 $label = ($langs->trans(
"Civility".$obj->code) !=
"Civility".$obj->code ? $langs->trans(
"Civility".$obj->code) : ($obj->civilite !=
'-' ? $obj->civilite :
''));
378 $options_array[$obj->code] = $label;
399 public function advMultiselectarray($htmlname, $options_array = array(), $selected_array = array(), $showempty = 0)
401 global $conf, $langs;
403 $form =
new Form($this->db);
404 $return = $form->multiselectarray($htmlname, $options_array, $selected_array, 0, 0,
'', 0, 295);
420 global $conf, $user, $langs;
424 $sql =
"SELECT c.rowid, c.name, c.fk_element";
425 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing_advtarget as c";
426 $sql .=
" WHERE type_element = '".$this->db->escape($type_element).
"'";
427 $sql .=
" ORDER BY c.name";
430 $resql = $this->db->query($sql);
432 $out .=
'<select id="'.$htmlname.
'" class="flat'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
434 $out .=
'<option value=""></option>';
436 $num = $this->db->num_rows($resql);
440 $obj = $this->db->fetch_object($resql);
443 $label = $obj->fk_element;
446 if ($selected > 0 && $selected == $obj->rowid) {
447 $out .=
'<option value="'.$obj->rowid.
'" selected="selected">'.$label.
'</option>';
449 $out .=
'<option value="'.$obj->rowid.
'">'.$label.
'</option>';
458 $this->db->free($resql);
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.