@@ -100,10 +100,10 @@ discard block |
||
100 | 100 | function dolGetRandomBytes($length) |
101 | 101 | { |
102 | 102 | if (function_exists('random_bytes')) { // Available with PHP 7 only. |
103 | - return bin2hex(random_bytes((int) floor($length / 2))); // the bin2hex will double the number of bytes so we take length / 2 |
|
103 | + return bin2hex(random_bytes((int) floor($length / 2))); // the bin2hex will double the number of bytes so we take length / 2 |
|
104 | 104 | } |
105 | 105 | |
106 | - return bin2hex(openssl_random_pseudo_bytes((int) floor($length / 2))); // the bin2hex will double the number of bytes so we take length / 2. May be very slow on Windows. |
|
106 | + return bin2hex(openssl_random_pseudo_bytes((int) floor($length / 2))); // the bin2hex will double the number of bytes so we take length / 2. May be very slow on Windows. |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | global $conf; |
283 | 283 | |
284 | 284 | if ($type == '0' && !empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'password_hash' && function_exists('password_verify')) { |
285 | - if (! empty($hash[0]) && $hash[0] == '$') { |
|
285 | + if (!empty($hash[0]) && $hash[0] == '$') { |
|
286 | 286 | return password_verify($chain, $hash); |
287 | 287 | } elseif (dol_strlen($hash) == 32) { |
288 | 288 | return dol_verifyHash($chain, $hash, '3'); // md5 |
@@ -312,31 +312,31 @@ discard block |
||
312 | 312 | $salt = substr(sha1(time()), 0, 8); |
313 | 313 | |
314 | 314 | if ($type === 'md5') { |
315 | - return '{MD5}' . base64_encode(hash("md5", $password, true)); //For OpenLdap with md5 (based on an unencrypted password in base) |
|
315 | + return '{MD5}'.base64_encode(hash("md5", $password, true)); //For OpenLdap with md5 (based on an unencrypted password in base) |
|
316 | 316 | } elseif ($type === 'md5frommd5') { |
317 | - return '{MD5}' . base64_encode(hex2bin($password)); // Create OpenLDAP MD5 password from Dolibarr MD5 password |
|
317 | + return '{MD5}'.base64_encode(hex2bin($password)); // Create OpenLDAP MD5 password from Dolibarr MD5 password |
|
318 | 318 | } elseif ($type === 'smd5') { |
319 | - return "{SMD5}" . base64_encode(hash("md5", $password . $salt, true) . $salt); |
|
319 | + return "{SMD5}".base64_encode(hash("md5", $password.$salt, true).$salt); |
|
320 | 320 | } elseif ($type === 'sha') { |
321 | - return '{SHA}' . base64_encode(hash("sha1", $password, true)); |
|
321 | + return '{SHA}'.base64_encode(hash("sha1", $password, true)); |
|
322 | 322 | } elseif ($type === 'ssha') { |
323 | - return "{SSHA}" . base64_encode(hash("sha1", $password . $salt, true) . $salt); |
|
323 | + return "{SSHA}".base64_encode(hash("sha1", $password.$salt, true).$salt); |
|
324 | 324 | } elseif ($type === 'sha256') { |
325 | - return "{SHA256}" . base64_encode(hash("sha256", $password, true)); |
|
325 | + return "{SHA256}".base64_encode(hash("sha256", $password, true)); |
|
326 | 326 | } elseif ($type === 'ssha256') { |
327 | - return "{SSHA256}" . base64_encode(hash("sha256", $password . $salt, true) . $salt); |
|
327 | + return "{SSHA256}".base64_encode(hash("sha256", $password.$salt, true).$salt); |
|
328 | 328 | } elseif ($type === 'sha384') { |
329 | - return "{SHA384}" . base64_encode(hash("sha384", $password, true)); |
|
329 | + return "{SHA384}".base64_encode(hash("sha384", $password, true)); |
|
330 | 330 | } elseif ($type === 'ssha384') { |
331 | - return "{SSHA384}" . base64_encode(hash("sha384", $password . $salt, true) . $salt); |
|
331 | + return "{SSHA384}".base64_encode(hash("sha384", $password.$salt, true).$salt); |
|
332 | 332 | } elseif ($type === 'sha512') { |
333 | - return "{SHA512}" . base64_encode(hash("sha512", $password, true)); |
|
333 | + return "{SHA512}".base64_encode(hash("sha512", $password, true)); |
|
334 | 334 | } elseif ($type === 'ssha512') { |
335 | - return "{SSHA512}" . base64_encode(hash("sha512", $password . $salt, true) . $salt); |
|
335 | + return "{SSHA512}".base64_encode(hash("sha512", $password.$salt, true).$salt); |
|
336 | 336 | } elseif ($type === 'crypt') { |
337 | - return '{CRYPT}' . crypt($password, $salt); |
|
337 | + return '{CRYPT}'.crypt($password, $salt); |
|
338 | 338 | } elseif ($type === 'clear') { |
339 | - return '{CLEAR}' . $password; // Just for test, plain text password is not secured ! |
|
339 | + return '{CLEAR}'.$password; // Just for test, plain text password is not secured ! |
|
340 | 340 | } |
341 | 341 | return ""; |
342 | 342 | } |
@@ -370,13 +370,13 @@ discard block |
||
370 | 370 | if (is_object($object)) { |
371 | 371 | $objectid = $object->id; |
372 | 372 | } else { |
373 | - $objectid = $object; // $objectid can be X or 'X,Y,Z' |
|
373 | + $objectid = $object; // $objectid can be X or 'X,Y,Z' |
|
374 | 374 | } |
375 | 375 | if ($objectid == "-1") { |
376 | 376 | $objectid = 0; |
377 | 377 | } |
378 | 378 | if ($objectid) { |
379 | - $objectid = preg_replace('/[^0-9\.\,]/', '', $objectid); // For the case value is coming from a non sanitized user input |
|
379 | + $objectid = preg_replace('/[^0-9\.\,]/', '', $objectid); // For the case value is coming from a non sanitized user input |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | //dol_syslog("functions.lib:restrictedArea $feature, $objectid, $dbtablename, $feature2, $dbt_socfield, $dbt_select, $isdraft"); |
@@ -853,9 +853,9 @@ discard block |
||
853 | 853 | if (is_object($object)) { |
854 | 854 | $objectid = $object->id; |
855 | 855 | } else { |
856 | - $objectid = $object; // $objectid can be X or 'X,Y,Z' |
|
856 | + $objectid = $object; // $objectid can be X or 'X,Y,Z' |
|
857 | 857 | } |
858 | - $objectid = preg_replace('/[^0-9\.\,]/', '', $objectid); // For the case value is coming from a non sanitized user input |
|
858 | + $objectid = preg_replace('/[^0-9\.\,]/', '', $objectid); // For the case value is coming from a non sanitized user input |
|
859 | 859 | |
860 | 860 | //dol_syslog("functions.lib:restrictedArea $feature, $objectid, $dbtablename, $feature2, $dbt_socfield, $dbt_select, $isdraft"); |
861 | 861 | //print "user_id=".$user->id.", features=".join(',', $featuresarray).", objectid=".$objectid; |
@@ -902,8 +902,8 @@ discard block |
||
902 | 902 | $checkparentsoc = array('agenda', 'contact', 'contrat'); // Test on entity + link to third party on field $dbt_keyfield. Allowed if link is empty (Ex: contacts...). |
903 | 903 | $checkproject = array('projet', 'project'); // Test for project object |
904 | 904 | $checktask = array('projet_task'); // Test for task object |
905 | - $checkhierarchy = array('expensereport', 'holiday'); // check permission among the hierarchy of user |
|
906 | - $checkuser = array('bookmark'); // check permission among the fk_user (must be myself or null) |
|
905 | + $checkhierarchy = array('expensereport', 'holiday'); // check permission among the hierarchy of user |
|
906 | + $checkuser = array('bookmark'); // check permission among the fk_user (must be myself or null) |
|
907 | 907 | $nocheck = array('barcode', 'stock'); // No test |
908 | 908 | |
909 | 909 | //$checkdefault = 'all other not already defined'; // Test on entity + link to third party on field $dbt_keyfield. Not allowed if link is empty (Ex: invoice, orders...). |
@@ -916,7 +916,7 @@ discard block |
||
916 | 916 | |
917 | 917 | // To avoid an access forbidden with a numeric ref |
918 | 918 | if ($dbt_select != 'rowid' && $dbt_select != 'id') { |
919 | - $objectid = "'".$objectid."'"; // Note: $objectid was already cast into int at begin of this method. |
|
919 | + $objectid = "'".$objectid."'"; // Note: $objectid was already cast into int at begin of this method. |
|
920 | 920 | } |
921 | 921 | // Check permission for objectid on entity only |
922 | 922 | if (in_array($feature, $check) && $objectid > 0) { // For $objectid = 0, no check |
@@ -96,18 +96,18 @@ discard block |
||
96 | 96 | $placeholder = ''; |
97 | 97 | |
98 | 98 | if ($selected && empty($selected_input_value)) { |
99 | - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
99 | + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
|
100 | 100 | $project = new Project($this->db); |
101 | 101 | $project->fetch($selected); |
102 | 102 | $selected_input_value = $project->ref; |
103 | 103 | } |
104 | - $urloption = 'socid=' . ((int) $socid) . '&htmlname=' . urlencode($htmlname) . '&discardclosed=' . ((int) $discard_closed); |
|
104 | + $urloption = 'socid='.((int) $socid).'&htmlname='.urlencode($htmlname).'&discardclosed='.((int) $discard_closed); |
|
105 | 105 | if ($morefilter == 'usage_organize_event=1') { |
106 | 106 | $urloption .= '&usage_organize_event=1'; |
107 | 107 | } |
108 | - $out .= '<input type="text" class="minwidth200' . ($morecss ? ' ' . $morecss : '') . '" name="search_' . $htmlname . '" id="search_' . $htmlname . '" value="' . $selected_input_value . '"' . $placeholder . ' />'; |
|
108 | + $out .= '<input type="text" class="minwidth200'.($morecss ? ' '.$morecss : '').'" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' />'; |
|
109 | 109 | |
110 | - $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT . '/projet/ajax/projects.php', $urloption, $conf->global->PROJECT_USE_SEARCH_TO_SELECT, 0, array()); |
|
110 | + $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projects.php', $urloption, $conf->global->PROJECT_USE_SEARCH_TO_SELECT, 0, array()); |
|
111 | 111 | } else { |
112 | 112 | $out .= $this->select_projects_list($socid, $selected, $htmlname, $maxlength, $option_only, $show_empty, abs($discard_closed), $forcefocus, $disabled, 0, $filterkey, 1, $forceaddid, $htmlid, $morecss, $morefilter); |
113 | 113 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | // phpcs:enable |
154 | 154 | global $user, $conf, $langs; |
155 | 155 | |
156 | - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
156 | + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
|
157 | 157 | |
158 | 158 | if (empty($htmlid)) { |
159 | 159 | $htmlid = $htmlname; |
@@ -175,26 +175,26 @@ discard block |
||
175 | 175 | |
176 | 176 | // Search all projects |
177 | 177 | $sql = "SELECT p.rowid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public, s.nom as name, s.name_alias"; |
178 | - $sql .= " FROM " . $this->db->prefix() . "projet as p LEFT JOIN " . $this->db->prefix() . "societe as s ON s.rowid = p.fk_soc"; |
|
179 | - $sql .= " WHERE p.entity IN (" . getEntity('project') . ")"; |
|
178 | + $sql .= " FROM ".$this->db->prefix()."projet as p LEFT JOIN ".$this->db->prefix()."societe as s ON s.rowid = p.fk_soc"; |
|
179 | + $sql .= " WHERE p.entity IN (".getEntity('project').")"; |
|
180 | 180 | if ($projectsListId !== false) { |
181 | - $sql .= " AND p.rowid IN (" . $this->db->sanitize($projectsListId) . ")"; |
|
181 | + $sql .= " AND p.rowid IN (".$this->db->sanitize($projectsListId).")"; |
|
182 | 182 | } |
183 | 183 | if ($socid == 0) { |
184 | 184 | $sql .= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)"; |
185 | 185 | } |
186 | 186 | if ($socid > 0) { |
187 | 187 | if (empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) { |
188 | - $sql .= " AND (p.fk_soc=" . ((int) $socid) . " OR p.fk_soc IS NULL)"; |
|
188 | + $sql .= " AND (p.fk_soc=".((int) $socid)." OR p.fk_soc IS NULL)"; |
|
189 | 189 | } elseif ($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all') { // PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY is 'all' or a list of ids separated by coma. |
190 | - $sql .= " AND (p.fk_soc IN (" . $this->db->sanitize(((int) $socid) . ", " . $conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY) . ") OR p.fk_soc IS NULL)"; |
|
190 | + $sql .= " AND (p.fk_soc IN (".$this->db->sanitize(((int) $socid).", ".$conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY).") OR p.fk_soc IS NULL)"; |
|
191 | 191 | } |
192 | 192 | } |
193 | 193 | if (!empty($filterkey)) { |
194 | 194 | $sql .= natural_search(array('p.title', 'p.ref'), $filterkey); |
195 | 195 | } |
196 | 196 | if ($morefilter) { |
197 | - $sql .= ' AND (' . $this->db->sanitize($morefilter, 0, 1) . ')'; |
|
197 | + $sql .= ' AND ('.$this->db->sanitize($morefilter, 0, 1).')'; |
|
198 | 198 | } |
199 | 199 | $sql .= " ORDER BY p.ref ASC"; |
200 | 200 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | $morecss .= ' minwidth100'; |
205 | 205 | } |
206 | 206 | if (empty($option_only)) { |
207 | - $out .= '<select class="flat' . ($morecss ? ' ' . $morecss : '') . '"' . ($disabled ? ' disabled="disabled"' : '') . ' id="' . $htmlid . '" name="' . $htmlname . '">'; |
|
207 | + $out .= '<select class="flat'.($morecss ? ' '.$morecss : '').'"'.($disabled ? ' disabled="disabled"' : '').' id="'.$htmlid.'" name="'.$htmlname.'">'; |
|
208 | 208 | } |
209 | 209 | if (!empty($show_empty)) { |
210 | 210 | if (is_numeric($show_empty)) { |
@@ -230,37 +230,37 @@ discard block |
||
230 | 230 | $labeltoshow = dol_trunc($obj->ref, 18); |
231 | 231 | //if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')'; |
232 | 232 | //else $labeltoshow.=' ('.$langs->trans("Private").')'; |
233 | - $labeltoshow .= ', ' . dol_trunc($obj->title, $maxlength); |
|
233 | + $labeltoshow .= ', '.dol_trunc($obj->title, $maxlength); |
|
234 | 234 | if ($obj->name) { |
235 | - $labeltoshow .= ' - ' . $obj->name; |
|
235 | + $labeltoshow .= ' - '.$obj->name; |
|
236 | 236 | if ($obj->name_alias) { |
237 | - $labeltoshow .= ' (' . $obj->name_alias . ')'; |
|
237 | + $labeltoshow .= ' ('.$obj->name_alias.')'; |
|
238 | 238 | } |
239 | 239 | } |
240 | 240 | |
241 | 241 | $disabled = 0; |
242 | 242 | if ($obj->fk_statut == 0) { |
243 | 243 | $disabled = 1; |
244 | - $labeltoshow .= ' - ' . $langs->trans("Draft"); |
|
244 | + $labeltoshow .= ' - '.$langs->trans("Draft"); |
|
245 | 245 | } elseif ($obj->fk_statut == 2) { |
246 | 246 | if ($discard_closed == 2) { |
247 | 247 | $disabled = 1; |
248 | 248 | } |
249 | - $labeltoshow .= ' - ' . $langs->trans("Closed"); |
|
249 | + $labeltoshow .= ' - '.$langs->trans("Closed"); |
|
250 | 250 | } elseif (empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY) && $socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) { |
251 | 251 | $disabled = 1; |
252 | - $labeltoshow .= ' - ' . $langs->trans("LinkedToAnotherCompany"); |
|
252 | + $labeltoshow .= ' - '.$langs->trans("LinkedToAnotherCompany"); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | if (!empty($selected) && $selected == $obj->rowid) { |
256 | - $out .= '<option value="' . $obj->rowid . '" selected'; |
|
256 | + $out .= '<option value="'.$obj->rowid.'" selected'; |
|
257 | 257 | //if ($disabled) $out.=' disabled'; // with select2, field can't be preselected if disabled |
258 | - $out .= '>' . $labeltoshow . '</option>'; |
|
258 | + $out .= '>'.$labeltoshow.'</option>'; |
|
259 | 259 | } else { |
260 | 260 | if ($hideunselectables && $disabled && ($selected != $obj->rowid)) { |
261 | 261 | $resultat = ''; |
262 | 262 | } else { |
263 | - $resultat = '<option value="' . $obj->rowid . '"'; |
|
263 | + $resultat = '<option value="'.$obj->rowid.'"'; |
|
264 | 264 | if ($disabled) { |
265 | 265 | $resultat .= ' disabled'; |
266 | 266 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | 'value' => $obj->ref, |
278 | 278 | 'ref' => $obj->ref, |
279 | 279 | 'labelx' => $labeltoshow, |
280 | - 'label' => ($disabled ? '<span class="opacitymedium">' . $labeltoshow . '</span>' : $labeltoshow), |
|
280 | + 'label' => ($disabled ? '<span class="opacitymedium">'.$labeltoshow.'</span>' : $labeltoshow), |
|
281 | 281 | 'disabled' => (bool) $disabled |
282 | 282 | ); |
283 | 283 | } |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | |
296 | 296 | // Use select2 selector |
297 | 297 | if (!empty($conf->use_javascript_ajax)) { |
298 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; |
|
298 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; |
|
299 | 299 | $comboenhancement = ajax_combobox($htmlid, array(), 0, $forcefocus); |
300 | 300 | $out .= $comboenhancement; |
301 | 301 | $morecss .= ' minwidth100'; |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | { |
339 | 339 | global $user, $conf, $langs; |
340 | 340 | |
341 | - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
341 | + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
|
342 | 342 | |
343 | 343 | if (is_null($usertofilter)) { |
344 | 344 | $usertofilter = $user; |
@@ -362,19 +362,19 @@ discard block |
||
362 | 362 | $sql = "SELECT t.rowid, t.ref as tref, t.label as tlabel, t.progress,"; |
363 | 363 | $sql .= " p.rowid as pid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public, p.usage_task,"; |
364 | 364 | $sql .= " s.nom as name"; |
365 | - $sql .= " FROM " . $this->db->prefix() . "projet as p"; |
|
366 | - $sql .= " LEFT JOIN " . $this->db->prefix() . "societe as s ON s.rowid = p.fk_soc,"; |
|
367 | - $sql .= " " . $this->db->prefix() . "projet_task as t"; |
|
368 | - $sql .= " WHERE p.entity IN (" . getEntity('project') . ")"; |
|
365 | + $sql .= " FROM ".$this->db->prefix()."projet as p"; |
|
366 | + $sql .= " LEFT JOIN ".$this->db->prefix()."societe as s ON s.rowid = p.fk_soc,"; |
|
367 | + $sql .= " ".$this->db->prefix()."projet_task as t"; |
|
368 | + $sql .= " WHERE p.entity IN (".getEntity('project').")"; |
|
369 | 369 | $sql .= " AND t.fk_projet = p.rowid"; |
370 | 370 | if ($projectsListId) { |
371 | - $sql .= " AND p.rowid IN (" . $this->db->sanitize($projectsListId) . ")"; |
|
371 | + $sql .= " AND p.rowid IN (".$this->db->sanitize($projectsListId).")"; |
|
372 | 372 | } |
373 | 373 | if ($socid == 0) { |
374 | 374 | $sql .= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)"; |
375 | 375 | } |
376 | 376 | if ($socid > 0) { |
377 | - $sql .= " AND (p.fk_soc=" . ((int) $socid) . " OR p.fk_soc IS NULL)"; |
|
377 | + $sql .= " AND (p.fk_soc=".((int) $socid)." OR p.fk_soc IS NULL)"; |
|
378 | 378 | } |
379 | 379 | $sql .= " ORDER BY p.ref, t.ref ASC"; |
380 | 380 | |
@@ -382,14 +382,14 @@ discard block |
||
382 | 382 | if ($resql) { |
383 | 383 | // Use select2 selector |
384 | 384 | if (empty($option_only) && !empty($conf->use_javascript_ajax)) { |
385 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; |
|
385 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; |
|
386 | 386 | $comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus); |
387 | 387 | $out .= $comboenhancement; |
388 | 388 | $morecss .= ' minwidth150imp'; |
389 | 389 | } |
390 | 390 | |
391 | 391 | if (empty($option_only)) { |
392 | - $out .= '<select class="valignmiddle flat' . ($morecss ? ' ' . $morecss : '') . '"' . ($disabled ? ' disabled="disabled"' : '') . ' id="' . $htmlname . '" name="' . $htmlname . '">'; |
|
392 | + $out .= '<select class="valignmiddle flat'.($morecss ? ' '.$morecss : '').'"'.($disabled ? ' disabled="disabled"' : '').' id="'.$htmlname.'" name="'.$htmlname.'">'; |
|
393 | 393 | } |
394 | 394 | if (!empty($show_empty)) { |
395 | 395 | $out .= '<option value="0" class="optiongrey">'; |
@@ -435,58 +435,58 @@ discard block |
||
435 | 435 | $labeltoshow .= dol_trunc($obj->ref, 18); // Project ref |
436 | 436 | //if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')'; |
437 | 437 | //else $labeltoshow.=' ('.$langs->trans("Private").')'; |
438 | - $labeltoshow .= ' ' . dol_trunc($obj->title, $maxlength); |
|
438 | + $labeltoshow .= ' '.dol_trunc($obj->title, $maxlength); |
|
439 | 439 | $titletoshow = $labeltoshow; |
440 | 440 | |
441 | 441 | if ($obj->name) { |
442 | - $labeltoshow .= ' (' . $obj->name . ')'; |
|
443 | - $titletoshow .= ' <span class="opacitymedium">(' . $obj->name . ')</span>'; |
|
442 | + $labeltoshow .= ' ('.$obj->name.')'; |
|
443 | + $titletoshow .= ' <span class="opacitymedium">('.$obj->name.')</span>'; |
|
444 | 444 | } |
445 | 445 | |
446 | 446 | $disabled = 0; |
447 | 447 | if ($obj->fk_statut == Project::STATUS_DRAFT) { |
448 | 448 | $disabled = 1; |
449 | - $labeltoshow .= ' - ' . $langs->trans("Draft"); |
|
450 | - $titletoshow .= ' - <span class="opacitymedium">' . $langs->trans("Draft") . '</span>'; |
|
449 | + $labeltoshow .= ' - '.$langs->trans("Draft"); |
|
450 | + $titletoshow .= ' - <span class="opacitymedium">'.$langs->trans("Draft").'</span>'; |
|
451 | 451 | } elseif ($obj->fk_statut == Project::STATUS_CLOSED) { |
452 | 452 | if ($discard_closed == 2) { |
453 | 453 | $disabled = 1; |
454 | 454 | } |
455 | - $labeltoshow .= ' - ' . $langs->trans("Closed"); |
|
456 | - $titletoshow .= ' - <span class="opacitymedium">' . $langs->trans("Closed") . '</span>'; |
|
455 | + $labeltoshow .= ' - '.$langs->trans("Closed"); |
|
456 | + $titletoshow .= ' - <span class="opacitymedium">'.$langs->trans("Closed").'</span>'; |
|
457 | 457 | } elseif ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) { |
458 | 458 | $disabled = 1; |
459 | - $labeltoshow .= ' - ' . $langs->trans("LinkedToAnotherCompany"); |
|
460 | - $titletoshow .= ' - <span class="opacitymedium">' . $langs->trans("LinkedToAnotherCompany") . '</span>'; |
|
459 | + $labeltoshow .= ' - '.$langs->trans("LinkedToAnotherCompany"); |
|
460 | + $titletoshow .= ' - <span class="opacitymedium">'.$langs->trans("LinkedToAnotherCompany").'</span>'; |
|
461 | 461 | } |
462 | 462 | $labeltoshow .= ' - '; |
463 | 463 | $titletoshow .= ' - '; |
464 | 464 | } |
465 | 465 | |
466 | 466 | // Label for task |
467 | - $labeltoshow .= $obj->tref . ' ' . dol_trunc($obj->tlabel, $maxlength); |
|
468 | - $titletoshow .= $obj->tref . ' ' . dol_trunc($obj->tlabel, $maxlength); |
|
467 | + $labeltoshow .= $obj->tref.' '.dol_trunc($obj->tlabel, $maxlength); |
|
468 | + $titletoshow .= $obj->tref.' '.dol_trunc($obj->tlabel, $maxlength); |
|
469 | 469 | if ($obj->usage_task && preg_match('/progress/', $showmore)) { |
470 | - $labeltoshow .= ' <span class="opacitymedium">(' . $obj->progress . '%)</span>'; |
|
471 | - $titletoshow .= ' <span class="opacitymedium">(' . $obj->progress . '%)</span>'; |
|
470 | + $labeltoshow .= ' <span class="opacitymedium">('.$obj->progress.'%)</span>'; |
|
471 | + $titletoshow .= ' <span class="opacitymedium">('.$obj->progress.'%)</span>'; |
|
472 | 472 | } |
473 | 473 | |
474 | 474 | if (!empty($selected) && $selected == $obj->rowid) { |
475 | - $out .= '<option value="' . $obj->rowid . '" selected'; |
|
476 | - $out .= ' data-html="' . dol_escape_htmltag($titletoshow) . '"'; |
|
475 | + $out .= '<option value="'.$obj->rowid.'" selected'; |
|
476 | + $out .= ' data-html="'.dol_escape_htmltag($titletoshow).'"'; |
|
477 | 477 | //if ($disabled) $out.=' disabled'; // with select2, field can't be preselected if disabled |
478 | - $out .= '>' . $labeltoshow . '</option>'; |
|
478 | + $out .= '>'.$labeltoshow.'</option>'; |
|
479 | 479 | } else { |
480 | 480 | if ($hideunselectables && $disabled && ($selected != $obj->rowid)) { |
481 | 481 | $resultat = ''; |
482 | 482 | } else { |
483 | - $resultat = '<option value="' . $obj->rowid . '"'; |
|
483 | + $resultat = '<option value="'.$obj->rowid.'"'; |
|
484 | 484 | if ($disabled) { |
485 | 485 | $resultat .= ' disabled'; |
486 | 486 | } |
487 | 487 | //if ($obj->public) $labeltoshow.=' ('.$langs->trans("Public").')'; |
488 | 488 | //else $labeltoshow.=' ('.$langs->trans("Private").')'; |
489 | - $resultat .= ' data-html="' . dol_escape_htmltag($titletoshow) . '"'; |
|
489 | + $resultat .= ' data-html="'.dol_escape_htmltag($titletoshow).'"'; |
|
490 | 490 | $resultat .= '>'; |
491 | 491 | $resultat .= $labeltoshow; |
492 | 492 | $resultat .= '</option>'; |
@@ -605,30 +605,30 @@ discard block |
||
605 | 605 | if ($linkedtothirdparty) { |
606 | 606 | $sql .= ", s.nom as name"; |
607 | 607 | } |
608 | - $sql .= " FROM " . $this->db->prefix() . $table_element . " as t"; |
|
608 | + $sql .= " FROM ".$this->db->prefix().$table_element." as t"; |
|
609 | 609 | if ($linkedtothirdparty) { |
610 | - $sql .= ", " . $this->db->prefix() . "societe as s"; |
|
610 | + $sql .= ", ".$this->db->prefix()."societe as s"; |
|
611 | 611 | } |
612 | - $sql .= " WHERE " . $projectkey . " is null"; |
|
612 | + $sql .= " WHERE ".$projectkey." is null"; |
|
613 | 613 | if (!empty($socid) && $linkedtothirdparty) { |
614 | 614 | if (is_numeric($socid)) { |
615 | - $sql .= " AND t.fk_soc = " . ((int) $socid); |
|
615 | + $sql .= " AND t.fk_soc = ".((int) $socid); |
|
616 | 616 | } else { |
617 | - $sql .= " AND t.fk_soc IN (" . $this->db->sanitize($socid) . ")"; |
|
617 | + $sql .= " AND t.fk_soc IN (".$this->db->sanitize($socid).")"; |
|
618 | 618 | } |
619 | 619 | } |
620 | 620 | if (!in_array($table_element, array('expensereport_det', 'stock_mouvement'))) { |
621 | - $sql .= ' AND t.entity IN (' . getEntity('project') . ')'; |
|
621 | + $sql .= ' AND t.entity IN ('.getEntity('project').')'; |
|
622 | 622 | } |
623 | 623 | if ($linkedtothirdparty) { |
624 | 624 | $sql .= " AND s.rowid = t.fk_soc"; |
625 | 625 | } |
626 | 626 | if ($sqlfilter) { |
627 | - $sql .= " AND " . $sqlfilter; |
|
627 | + $sql .= " AND ".$sqlfilter; |
|
628 | 628 | } |
629 | 629 | $sql .= " ORDER BY ref DESC"; |
630 | 630 | |
631 | - dol_syslog(get_class($this) . '::select_element', LOG_DEBUG); |
|
631 | + dol_syslog(get_class($this).'::select_element', LOG_DEBUG); |
|
632 | 632 | $resql = $this->db->query($sql); |
633 | 633 | if ($resql) { |
634 | 634 | $num = $this->db->num_rows($resql); |
@@ -636,18 +636,18 @@ discard block |
||
636 | 636 | $sellist = ''; |
637 | 637 | |
638 | 638 | if ($num > 0) { |
639 | - $sellist = '<select class="flat elementselect css' . $table_element . ($morecss ? ' ' . $morecss : '') . '" name="elementselect">'; |
|
640 | - $sellist .= '<option value="-1"' . ($placeholder ? ' class="optiongrey"' : '') . '>' . $placeholder . '</option>'; |
|
639 | + $sellist = '<select class="flat elementselect css'.$table_element.($morecss ? ' '.$morecss : '').'" name="elementselect">'; |
|
640 | + $sellist .= '<option value="-1"'.($placeholder ? ' class="optiongrey"' : '').'>'.$placeholder.'</option>'; |
|
641 | 641 | while ($i < $num) { |
642 | 642 | $obj = $this->db->fetch_object($resql); |
643 | 643 | $ref = $obj->ref ? $obj->ref : $obj->rowid; |
644 | 644 | if (!empty($obj->ref_supplier)) { |
645 | - $ref .= ' (' . $obj->ref_supplier . ')'; |
|
645 | + $ref .= ' ('.$obj->ref_supplier.')'; |
|
646 | 646 | } |
647 | 647 | if (!empty($obj->name)) { |
648 | - $ref .= ' - ' . $obj->name; |
|
648 | + $ref .= ' - '.$obj->name; |
|
649 | 649 | } |
650 | - $sellist .= '<option value="' . $obj->rowid . '">' . $ref . '</option>'; |
|
650 | + $sellist .= '<option value="'.$obj->rowid.'">'.$ref.'</option>'; |
|
651 | 651 | $i++; |
652 | 652 | } |
653 | 653 | $sellist .= '</select>'; |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | dol_print_error($this->db); |
666 | 666 | $this->error = $this->db->lasterror(); |
667 | 667 | $this->errors[] = $this->db->lasterror(); |
668 | - dol_syslog(get_class($this) . "::select_element " . $this->error, LOG_ERR); |
|
668 | + dol_syslog(get_class($this)."::select_element ".$this->error, LOG_ERR); |
|
669 | 669 | return -1; |
670 | 670 | } |
671 | 671 | } |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | global $conf, $langs, $user; |
691 | 691 | |
692 | 692 | $sql = "SELECT rowid, code, label, percent"; |
693 | - $sql .= " FROM " . $this->db->prefix() . 'c_lead_status'; |
|
693 | + $sql .= " FROM ".$this->db->prefix().'c_lead_status'; |
|
694 | 694 | $sql .= " WHERE active = 1"; |
695 | 695 | $sql .= " ORDER BY position"; |
696 | 696 | |
@@ -699,31 +699,31 @@ discard block |
||
699 | 699 | $num = $this->db->num_rows($resql); |
700 | 700 | $i = 0; |
701 | 701 | if ($num > 0) { |
702 | - $sellist = '<select class="flat oppstatus' . ($morecss ? ' ' . $morecss : '') . '" id="' . $htmlname . '" name="' . $htmlname . '">'; |
|
702 | + $sellist = '<select class="flat oppstatus'.($morecss ? ' '.$morecss : '').'" id="'.$htmlname.'" name="'.$htmlname.'">'; |
|
703 | 703 | if ($showempty) { |
704 | 704 | // Without  , strange move of screen when switching value |
705 | 705 | $sellist .= '<option value="-1"> </option>'; |
706 | 706 | } |
707 | 707 | if ($showallnone) { |
708 | - $sellist .= '<option value="all"' . ($preselected == 'all' ? ' selected="selected"' : '') . '>-- ' . $langs->trans("OnlyOpportunitiesShort") . '</option>'; |
|
709 | - $sellist .= '<option value="openedopp"' . ($preselected == 'openedopp' ? ' selected="selected"' : '') . '>-- ' . $langs->trans("OpenedOpportunitiesShort") . '</option>'; |
|
710 | - $sellist .= '<option value="notopenedopp"' . ($preselected == 'notopenedopp' ? ' selected="selected"' : '') . '>-- ' . $langs->trans("NotOpenedOpportunitiesShort") . '</option>'; |
|
711 | - $sellist .= '<option value="none"' . ($preselected == 'none' ? ' selected="selected"' : '') . '>-- ' . $langs->trans("NotAnOpportunityShort") . '</option>'; |
|
708 | + $sellist .= '<option value="all"'.($preselected == 'all' ? ' selected="selected"' : '').'>-- '.$langs->trans("OnlyOpportunitiesShort").'</option>'; |
|
709 | + $sellist .= '<option value="openedopp"'.($preselected == 'openedopp' ? ' selected="selected"' : '').'>-- '.$langs->trans("OpenedOpportunitiesShort").'</option>'; |
|
710 | + $sellist .= '<option value="notopenedopp"'.($preselected == 'notopenedopp' ? ' selected="selected"' : '').'>-- '.$langs->trans("NotOpenedOpportunitiesShort").'</option>'; |
|
711 | + $sellist .= '<option value="none"'.($preselected == 'none' ? ' selected="selected"' : '').'>-- '.$langs->trans("NotAnOpportunityShort").'</option>'; |
|
712 | 712 | } |
713 | 713 | while ($i < $num) { |
714 | 714 | $obj = $this->db->fetch_object($resql); |
715 | 715 | |
716 | - $sellist .= '<option value="' . $obj->rowid . '" defaultpercent="' . $obj->percent . '" elemcode="' . $obj->code . '"'; |
|
716 | + $sellist .= '<option value="'.$obj->rowid.'" defaultpercent="'.$obj->percent.'" elemcode="'.$obj->code.'"'; |
|
717 | 717 | if ($obj->rowid == $preselected) { |
718 | 718 | $sellist .= ' selected="selected"'; |
719 | 719 | } |
720 | 720 | $sellist .= '>'; |
721 | 721 | if ($useshortlabel) { |
722 | - $finallabel = ($langs->transnoentitiesnoconv("OppStatus" . $obj->code) != "OppStatus" . $obj->code ? $langs->transnoentitiesnoconv("OppStatus" . $obj->code) : $obj->label); |
|
722 | + $finallabel = ($langs->transnoentitiesnoconv("OppStatus".$obj->code) != "OppStatus".$obj->code ? $langs->transnoentitiesnoconv("OppStatus".$obj->code) : $obj->label); |
|
723 | 723 | } else { |
724 | - $finallabel = ($langs->transnoentitiesnoconv("OppStatus" . $obj->code) != "OppStatus" . $obj->code ? $langs->transnoentitiesnoconv("OppStatus" . $obj->code) : $obj->label); |
|
724 | + $finallabel = ($langs->transnoentitiesnoconv("OppStatus".$obj->code) != "OppStatus".$obj->code ? $langs->transnoentitiesnoconv("OppStatus".$obj->code) : $obj->label); |
|
725 | 725 | if ($showpercent) { |
726 | - $finallabel .= ' (' . $obj->percent . '%)'; |
|
726 | + $finallabel .= ' ('.$obj->percent.'%)'; |
|
727 | 727 | } |
728 | 728 | } |
729 | 729 | $sellist .= $finallabel; |
@@ -752,7 +752,7 @@ discard block |
||
752 | 752 | } else { |
753 | 753 | $this->error = $this->db->lasterror(); |
754 | 754 | $this->errors[] = $this->db->lasterror(); |
755 | - dol_syslog(get_class($this) . "::selectOpportunityStatus " . $this->error, LOG_ERR); |
|
755 | + dol_syslog(get_class($this)."::selectOpportunityStatus ".$this->error, LOG_ERR); |
|
756 | 756 | return -1; |
757 | 757 | } |
758 | 758 | } |
@@ -786,7 +786,7 @@ discard block |
||
786 | 786 | if (is_array($selected)) { |
787 | 787 | $selectedarray = $selected; |
788 | 788 | } elseif ($selected == 99) { |
789 | - $selectedarray = array(0,1); |
|
789 | + $selectedarray = array(0, 1); |
|
790 | 790 | } else { |
791 | 791 | $selectedarray = explode(',', $selected); |
792 | 792 | } |
@@ -810,24 +810,24 @@ discard block |
||
810 | 810 | { |
811 | 811 | global $user, $conf, $langs; |
812 | 812 | |
813 | - require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
|
813 | + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
|
814 | 814 | |
815 | 815 | $out = ''; |
816 | 816 | if (empty($lineOnly)) { |
817 | 817 | // Search Invoice |
818 | 818 | $sql = "SELECT f.rowid, f.ref as fref,"; |
819 | 819 | $sql .= ' s.nom as name'; |
820 | - $sql .= ' FROM ' . $this->db->prefix() . 'projet as p'; |
|
821 | - $sql .= ' INNER JOIN ' . $this->db->prefix() . 'societe as s ON s.rowid = p.fk_soc'; |
|
822 | - $sql .= ' INNER JOIN ' . $this->db->prefix() . 'facture as f ON f.fk_projet = p.rowid'; |
|
823 | - $sql .= " WHERE p.entity IN (" . getEntity('project') . ")"; |
|
820 | + $sql .= ' FROM '.$this->db->prefix().'projet as p'; |
|
821 | + $sql .= ' INNER JOIN '.$this->db->prefix().'societe as s ON s.rowid = p.fk_soc'; |
|
822 | + $sql .= ' INNER JOIN '.$this->db->prefix().'facture as f ON f.fk_projet = p.rowid'; |
|
823 | + $sql .= " WHERE p.entity IN (".getEntity('project').")"; |
|
824 | 824 | if (!empty($filters)) { |
825 | 825 | foreach ($filters as $key => $value) { |
826 | 826 | if ($key == 'p.rowid') { |
827 | - $sql .= " AND p.rowid=" . (int) $value; |
|
827 | + $sql .= " AND p.rowid=".(int) $value; |
|
828 | 828 | } |
829 | 829 | if ($key == 'f.rowid') { |
830 | - $sql .= " AND f.rowid=" . (int) $value; |
|
830 | + $sql .= " AND f.rowid=".(int) $value; |
|
831 | 831 | } |
832 | 832 | } |
833 | 833 | } |
@@ -837,26 +837,26 @@ discard block |
||
837 | 837 | if ($resql) { |
838 | 838 | // Use select2 selector |
839 | 839 | if (!empty($conf->use_javascript_ajax)) { |
840 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; |
|
840 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; |
|
841 | 841 | $comboenhancement = ajax_combobox($htmlNameInvoice, array(array('method'=>'getLines', 'url'=>dol_buildpath('/core/ajax/ajaxinvoiceline.php', 1), 'htmlname'=>$htmlNameInvoiceLine)), 0, 0); |
842 | 842 | $out .= $comboenhancement; |
843 | 843 | $morecss = 'minwidth200imp maxwidth500'; |
844 | 844 | } |
845 | 845 | |
846 | - $out .= '<select class="valignmiddle flat' . ($morecss ? ' ' . $morecss : '') . '" id="' . $htmlNameInvoice . '" name="' . $htmlNameInvoice . '">'; |
|
846 | + $out .= '<select class="valignmiddle flat'.($morecss ? ' '.$morecss : '').'" id="'.$htmlNameInvoice.'" name="'.$htmlNameInvoice.'">'; |
|
847 | 847 | $num = $this->db->num_rows($resql); |
848 | 848 | if ($num) { |
849 | 849 | while ($obj = $this->db->fetch_object($resql)) { |
850 | 850 | $labeltoshow = $obj->fref; // Invoice ref |
851 | 851 | if ($obj->name) { |
852 | - $labeltoshow .= ' - ' . $obj->name; |
|
852 | + $labeltoshow .= ' - '.$obj->name; |
|
853 | 853 | } |
854 | 854 | |
855 | - $out .= '<option value="' . $obj->rowid . '" '; |
|
855 | + $out .= '<option value="'.$obj->rowid.'" '; |
|
856 | 856 | if (!empty($selectedInvoiceId) && $selectedInvoiceId == $obj->rowid) { |
857 | 857 | $out .= ' selected '; |
858 | 858 | } |
859 | - $out .= '>' . $labeltoshow . '</option>'; |
|
859 | + $out .= '>'.$labeltoshow.'</option>'; |
|
860 | 860 | } |
861 | 861 | } |
862 | 862 | $out .= '</select>'; |
@@ -868,20 +868,20 @@ discard block |
||
868 | 868 | |
869 | 869 | // Search Invoice Line |
870 | 870 | $sql = "SELECT fd.rowid, fd.label, fd.description"; |
871 | - $sql .= ' FROM ' . $this->db->prefix() . 'projet as p'; |
|
872 | - $sql .= ' INNER JOIN ' . $this->db->prefix() . 'societe as s ON s.rowid = p.fk_soc'; |
|
873 | - $sql .= ' INNER JOIN ' . $this->db->prefix() . 'facture as f ON f.fk_projet = p.rowid'; |
|
874 | - $sql .= ' INNER JOIN ' . $this->db->prefix() . 'facturedet as fd ON fd.fk_facture = f.rowid'; |
|
875 | - $sql .= " WHERE p.entity IN (" . getEntity('project') . ")"; |
|
871 | + $sql .= ' FROM '.$this->db->prefix().'projet as p'; |
|
872 | + $sql .= ' INNER JOIN '.$this->db->prefix().'societe as s ON s.rowid = p.fk_soc'; |
|
873 | + $sql .= ' INNER JOIN '.$this->db->prefix().'facture as f ON f.fk_projet = p.rowid'; |
|
874 | + $sql .= ' INNER JOIN '.$this->db->prefix().'facturedet as fd ON fd.fk_facture = f.rowid'; |
|
875 | + $sql .= " WHERE p.entity IN (".getEntity('project').")"; |
|
876 | 876 | if (!empty($filters)) { |
877 | 877 | foreach ($filters as $key => $value) { |
878 | 878 | if ($key == 'p.rowid') { |
879 | - $sql .= " AND p.rowid=" . (int) $value; |
|
879 | + $sql .= " AND p.rowid=".(int) $value; |
|
880 | 880 | } |
881 | 881 | } |
882 | 882 | } |
883 | 883 | if (!empty($selectedInvoiceId)) { |
884 | - $sql .= " AND f.rowid=" . (int) $selectedInvoiceId; |
|
884 | + $sql .= " AND f.rowid=".(int) $selectedInvoiceId; |
|
885 | 885 | } |
886 | 886 | $sql .= " ORDER BY p.ref, f.ref ASC"; |
887 | 887 | $resql = $this->db->query($sql); |
@@ -889,24 +889,24 @@ discard block |
||
889 | 889 | // Use select2 selector |
890 | 890 | if (empty($lineOnly)) { |
891 | 891 | if (!empty($conf->use_javascript_ajax)) { |
892 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; |
|
892 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; |
|
893 | 893 | $comboenhancement = ajax_combobox($htmlNameInvoiceLine, '', 0, 0); |
894 | 894 | $out .= $comboenhancement; |
895 | 895 | $morecss = 'minwidth200imp maxwidth500'; |
896 | 896 | } |
897 | 897 | |
898 | - $out .= '<select class="valignmiddle flat' . ($morecss ? ' ' . $morecss : '') . '" id="' . $htmlNameInvoiceLine . '" name="' . $htmlNameInvoiceLine . '">'; |
|
898 | + $out .= '<select class="valignmiddle flat'.($morecss ? ' '.$morecss : '').'" id="'.$htmlNameInvoiceLine.'" name="'.$htmlNameInvoiceLine.'">'; |
|
899 | 899 | } |
900 | 900 | $num = $this->db->num_rows($resql); |
901 | 901 | if ($num) { |
902 | 902 | while ($obj = $this->db->fetch_object($resql)) { |
903 | 903 | $labeltoshow .= $obj->description; // Invoice ref |
904 | 904 | |
905 | - $out .= '<option value="' . $obj->rowid . '" '; |
|
905 | + $out .= '<option value="'.$obj->rowid.'" '; |
|
906 | 906 | if (!empty($selectedLineId) && $selectedLineId == $obj->rowid) { |
907 | 907 | $out .= ' selected '; |
908 | 908 | } |
909 | - $out .= '>' . $labeltoshow . '</option>'; |
|
909 | + $out .= '>'.$labeltoshow.'</option>'; |
|
910 | 910 | } |
911 | 911 | } |
912 | 912 | if (empty($lineOnly)) { |