62 $options_array = array();
64 $sql =
"SELECT code, label";
65 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_prospectlevel";
66 $sql .=
" WHERE active > 0";
67 $sql .=
" ORDER BY sortorder";
69 $resql = $this->db->query($sql);
71 $num = $this->db->num_rows($resql);
74 $obj = $this->db->fetch_object($resql);
76 $level = $langs->trans($obj->code);
77 if ($level == $obj->code) {
78 $level = $langs->trans($obj->label);
80 $options_array[$obj->code] = $level;
101 $langs->load(
"dict");
105 $countryArray = array();
108 $options_array = array();
110 $sql =
"SELECT rowid, code as code_iso, label";
111 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_country";
112 $sql .=
" WHERE active = 1 AND code<>''";
113 $sql .=
" ORDER BY code ASC";
115 $resql = $this->db->query($sql);
117 $num = $this->db->num_rows($resql);
120 $foundselected =
false;
123 $obj = $this->db->fetch_object($resql);
124 $countryArray [$i] [
'rowid'] = $obj->rowid;
125 $countryArray [$i] [
'code_iso'] = $obj->code_iso;
126 $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 :
''));
127 $label[$i] = $countryArray[$i][
'label'];
131 $array1_sort_order = SORT_ASC;
132 array_multisort($label, $array1_sort_order, $countryArray);
134 foreach ($countryArray as $row) {
135 $label =
dol_trunc($row[
'label'], $maxlength,
'middle');
136 if ($row[
'code_iso']) {
137 $label .=
' ('.$row[
'code_iso'].
')';
140 $options_array[$row[
'rowid']] = $label;
162 $options_array = array();
165 $sql_usr .=
"SELECT DISTINCT u2.rowid, u2.lastname as name, u2.firstname, u2.login";
166 $sql_usr .=
" FROM ".MAIN_DB_PREFIX.
"user as u2, ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
167 $sql_usr .=
" WHERE u2.entity IN (0,".$conf->entity.
")";
168 $sql_usr .=
" AND u2.rowid = sc.fk_user ";
171 $sql_usr .=
" AND u2.statut<>0 ";
173 $sql_usr .=
" ORDER BY name ASC";
176 $resql_usr = $this->db->query($sql_usr);
178 while ($obj_usr = $this->db->fetch_object($resql_usr)) {
179 $label = $obj_usr->firstname.
" ".$obj_usr->name.
" (".$obj_usr->login.
')';
181 $options_array [$obj_usr->rowid] = $label;
183 $this->db->free($resql_usr);
200 global $conf, $langs;
202 $options_array = array();
204 $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 12);
206 foreach ($langs_available as $key => $value) {
208 $options_array[$key] = $label;
210 asort($options_array);
225 $options_array = array();
227 if (is_array($sqlqueryparam)) {
228 $param_list = array_keys($sqlqueryparam);
229 $InfoFieldList = explode(
":", $param_list [0]);
238 if (count($InfoFieldList) >= 3) {
239 if (strpos($InfoFieldList[3],
'extra.') !==
false) {
240 $keyList =
'main.'.$InfoFieldList[2].
' as rowid';
242 $keyList = $InfoFieldList[2].
' as rowid';
246 $sql =
"SELECT ".$keyList.
", ".$InfoFieldList[1];
247 $sql .=
" FROM ".MAIN_DB_PREFIX.$InfoFieldList[0];
248 if (!empty($InfoFieldList[3])) {
250 if (strpos($InfoFieldList[3],
'extra') !==
false) {
251 $sql .=
' as main, '.MAIN_DB_PREFIX.$InfoFieldList[0].
'_extrafields as extra';
252 $sql .=
" WHERE extra.fk_object=main.".$InfoFieldList[2].
" AND ".$InfoFieldList[3];
254 $sql .=
" WHERE ".$InfoFieldList[3];
257 if (!empty($InfoFieldList[1])) {
258 $sql .=
" ORDER BY nom";
262 $resql = $this->db->query($sql);
264 $num = $this->db->num_rows($resql);
268 $obj = $this->db->fetch_object($resql);
269 $labeltoshow =
dol_trunc($obj->$InfoFieldList[1], 90);
270 $options_array[$obj->rowid] = $labeltoshow;
274 $this->db->free($resql);
290 global $conf, $langs, $user;
291 $langs->load(
"dict");
293 $options_array = array();
295 $sql =
"SELECT rowid, code, label as civilite, active FROM ".MAIN_DB_PREFIX.
"c_civility";
296 $sql .=
" WHERE active = 1";
299 $resql = $this->db->query($sql);
301 $num = $this->db->num_rows($resql);
305 $obj = $this->db->fetch_object($resql);
307 $label = ($langs->trans(
"Civility".$obj->code) !=
"Civility".$obj->code ? $langs->trans(
"Civility".$obj->code) : ($obj->civilite !=
'-' ? $obj->civilite :
''));
309 $options_array[$obj->code] = $label;
330 public function advMultiselectarray($htmlname, $options_array = array(), $selected_array = array(), $showempty = 0)
332 global $conf, $langs;
334 $form =
new Form($this->db);
335 $return = $form->multiselectarray($htmlname, $options_array, $selected_array, 0, 0,
'', 0, 295);
351 global $conf, $user, $langs;
355 $sql =
"SELECT c.rowid, c.name, c.fk_element";
356 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing_advtarget as c";
357 $sql .=
" WHERE type_element = '".$this->db->escape($type_element).
"'";
358 $sql .=
" ORDER BY c.name";
361 $resql = $this->db->query($sql);
363 $out .=
'<select id="'.$htmlname.
'" class="flat'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
365 $out .=
'<option value=""></option>';
367 $num = $this->db->num_rows($resql);
371 $obj = $this->db->fetch_object($resql);
374 $label = $obj->fk_element;
377 if ($selected > 0 && $selected == $obj->rowid) {
378 $out .=
'<option value="'.$obj->rowid.
'" selected="selected">'.$label.
'</option>';
380 $out .=
'<option value="'.$obj->rowid.
'">'.$label.
'</option>';
389 $this->db->free($resql);
dol_print_error($db='', $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.