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;
163 $options_array = array();
166 $sql_usr .=
"SELECT DISTINCT u2.rowid, u2.lastname as name, u2.firstname, u2.login";
167 $sql_usr .=
" FROM ".MAIN_DB_PREFIX.
"user as u2, ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
168 $sql_usr .=
" WHERE u2.entity IN (0,".$conf->entity.
")";
169 $sql_usr .=
" AND u2.rowid = sc.fk_user ";
171 if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX)) {
172 $sql_usr .=
" AND u2.statut<>0 ";
174 $sql_usr .=
" ORDER BY name ASC";
177 $resql_usr = $this->db->query($sql_usr);
179 while ($obj_usr = $this->db->fetch_object($resql_usr)) {
180 $label = $obj_usr->firstname.
" ".$obj_usr->name.
" (".$obj_usr->login.
')';
182 $options_array [$obj_usr->rowid] = $label;
184 $this->db->free($resql_usr);
202 global $conf, $langs;
204 $options_array = array();
206 $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 12);
208 foreach ($langs_available as $key => $value) {
210 $options_array[$key] = $label;
212 asort($options_array);
227 $options_array = array();
229 if (is_array($sqlqueryparam)) {
230 $param_list = array_keys($sqlqueryparam);
231 $InfoFieldList = explode(
":", $param_list [0]);
240 if (count($InfoFieldList) >= 3) {
241 if (strpos($InfoFieldList[3],
'extra.') !==
false) {
242 $keyList =
'main.'.$InfoFieldList[2].
' as rowid';
244 $keyList = $InfoFieldList[2].
' as rowid';
248 $sql =
"SELECT ".$keyList.
", ".$InfoFieldList[1];
249 $sql .=
" FROM ".MAIN_DB_PREFIX.$InfoFieldList[0];
250 if (!empty($InfoFieldList[3])) {
252 if (strpos($InfoFieldList[3],
'extra') !==
false) {
253 $sql .=
' as main, '.MAIN_DB_PREFIX.$InfoFieldList[0].
'_extrafields as extra';
254 $sql .=
" WHERE extra.fk_object=main.".$InfoFieldList[2].
" AND ".$InfoFieldList[3];
256 $sql .=
" WHERE ".$InfoFieldList[3];
259 if (!empty($InfoFieldList[1])) {
260 $sql .=
" ORDER BY nom";
264 $resql = $this->db->query($sql);
266 $num = $this->db->num_rows($resql);
270 $obj = $this->db->fetch_object($resql);
271 $labeltoshow =
dol_trunc($obj->$InfoFieldList[1], 90);
272 $options_array[$obj->rowid] = $labeltoshow;
276 $this->db->free($resql);
292 global $conf, $langs, $user;
293 $langs->load(
"dict");
295 $options_array = array();
297 $sql =
"SELECT rowid, code, label as civilite, active FROM ".MAIN_DB_PREFIX.
"c_civility";
298 $sql .=
" WHERE active = 1";
301 $resql = $this->db->query($sql);
303 $num = $this->db->num_rows($resql);
307 $obj = $this->db->fetch_object($resql);
309 $label = ($langs->trans(
"Civility".$obj->code) !=
"Civility".$obj->code ? $langs->trans(
"Civility".$obj->code) : ($obj->civilite !=
'-' ? $obj->civilite :
''));
311 $options_array[$obj->code] = $label;
332 public function advMultiselectarray($htmlname, $options_array = array(), $selected_array = array(), $showempty = 0)
334 global $conf, $langs;
336 $form =
new Form($this->db);
337 $return = $form->multiselectarray($htmlname, $options_array, $selected_array, 0, 0,
'', 0, 295);
353 global $conf, $user, $langs;
357 $sql =
"SELECT c.rowid, c.name, c.fk_element";
358 $sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing_advtarget as c";
359 $sql .=
" WHERE type_element = '".$this->db->escape($type_element).
"'";
360 $sql .=
" ORDER BY c.name";
363 $resql = $this->db->query($sql);
365 $out .=
'<select id="'.$htmlname.
'" class="flat'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
367 $out .=
'<option value=""></option>';
369 $num = $this->db->num_rows($resql);
373 $obj = $this->db->fetch_object($resql);
376 $label = $obj->fk_element;
379 if ($selected > 0 && $selected == $obj->rowid) {
380 $out .=
'<option value="'.$obj->rowid.
'" selected="selected">'.$label.
'</option>';
382 $out .=
'<option value="'.$obj->rowid.
'">'.$label.
'</option>';
391 $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.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.