@@ -335,7 +335,7 @@ |
||
335 | 335 | print '<tr class="oddeven" height="24">'; |
336 | 336 | print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$year.($socid > 0 ? '&socid='.$socid : '').($userid > 0 ? '&userid='.$userid : '').'">'.$year.'</a></td>'; |
337 | 337 | print '<td class="right">'.$val['nb'].'</td>'; |
338 | - print '<td class="right opacitylow" style="'.((!isset($val['nb_diff']) || $val['nb_diff'] >= 0) ? 'color: green;' : 'color: red;').'">'.(isset($val['nb_diff']) ? round($val['nb_diff']): "0").'%</td>'; |
|
338 | + print '<td class="right opacitylow" style="'.((!isset($val['nb_diff']) || $val['nb_diff'] >= 0) ? 'color: green;' : 'color: red;').'">'.(isset($val['nb_diff']) ? round($val['nb_diff']) : "0").'%</td>'; |
|
339 | 339 | print '<td class="right">'.price(price2num($val['total'], 'MT'), 1).'</td>'; |
340 | 340 | print '<td class="right opacitylow" style="'.((!isset($val['total_diff']) || $val['total_diff'] >= 0) ? 'color: green;' : 'color: red;').'">'.(isset($val['total_diff']) ? round($val['total_diff']) : "0").'%</td>'; |
341 | 341 | print '<td class="right">'.price(price2num($val['avg'], 'MT'), 1).'</td>'; |
@@ -494,7 +494,7 @@ |
||
494 | 494 | if ($key === 'date_prevue_depart' && $object->lead_time_for_warning > 0 && $object->$key > 0) { |
495 | 495 | $date_prevue_depart = $object->$key; |
496 | 496 | $date_prevue_depart_plus_delai = $date_prevue_depart; |
497 | - if ($object->lead_time_for_warning > 0) $date_prevue_depart_plus_delai = strtotime(date('Y-m-d', $date_prevue_depart) . ' + '.$object->lead_time_for_warning.' day'); |
|
497 | + if ($object->lead_time_for_warning > 0) $date_prevue_depart_plus_delai = strtotime(date('Y-m-d', $date_prevue_depart).' + '.$object->lead_time_for_warning.' day'); |
|
498 | 498 | if ($date_prevue_depart_plus_delai < strtotime(date('Y-m-d'))) print img_warning($langs->trans('Alert').' - '.$langs->trans('Late')); |
499 | 499 | } |
500 | 500 | } |
@@ -69,15 +69,22 @@ discard block |
||
69 | 69 | $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); |
70 | 70 | |
71 | 71 | // Default sort order (if not yet defined by previous GETPOST) |
72 | -if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. |
|
73 | -if (!$sortorder) $sortorder = "ASC"; |
|
72 | +if (!$sortfield) { |
|
73 | + $sortfield = "t.".key($object->fields); |
|
74 | +} |
|
75 | +// Set here default search field. By default 1st field in definition. |
|
76 | +if (!$sortorder) { |
|
77 | + $sortorder = "ASC"; |
|
78 | +} |
|
74 | 79 | |
75 | 80 | // Initialize array of search criterias |
76 | 81 | $search_all = GETPOST('search_all', 'alphanohtml') ? trim(GETPOST('search_all', 'alphanohtml')) : trim(GETPOST('sall', 'alphanohtml')); |
77 | 82 | $search = array(); |
78 | 83 | foreach ($object->fields as $key => $val) { |
79 | - if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha'); |
|
80 | -} |
|
84 | + if (GETPOST('search_'.$key, 'alpha') !== '') { |
|
85 | + $search[$key] = GETPOST('search_'.$key, 'alpha'); |
|
86 | + } |
|
87 | + } |
|
81 | 88 | |
82 | 89 | // List of fields to search into when doing a "search in all" |
83 | 90 | $fieldstosearchall = array(); |
@@ -91,8 +98,10 @@ discard block |
||
91 | 98 | $arrayfields = array(); |
92 | 99 | foreach ($object->fields as $key => $val) { |
93 | 100 | // If $val['visible']==0, then we never show the field |
94 | - if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>(verifCond($val['enabled']) && ($val['visible'] != 3)), 'position'=>$val['position']); |
|
95 | -} |
|
101 | + if (!empty($val['visible'])) { |
|
102 | + $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>(verifCond($val['enabled']) && ($val['visible'] != 3)), 'position'=>$val['position']); |
|
103 | + } |
|
104 | + } |
|
96 | 105 | //var_dump($object->fields); |
97 | 106 | // Extra fields |
98 | 107 | if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { |
@@ -116,14 +125,18 @@ discard block |
||
116 | 125 | $permissiontodelete = $user->hasRight('stocktransfer', 'stocktransfer', 'delete'); |
117 | 126 | |
118 | 127 | // Security check |
119 | -if (empty($conf->stocktransfer->enabled)) accessforbidden('Module not enabled'); |
|
128 | +if (empty($conf->stocktransfer->enabled)) { |
|
129 | + accessforbidden('Module not enabled'); |
|
130 | +} |
|
120 | 131 | $socid = 0; |
121 | 132 | if ($user->socid > 0) { // Protection if external user |
122 | 133 | //$socid = $user->socid; |
123 | 134 | accessforbidden(); |
124 | 135 | } |
125 | 136 | //$result = restrictedArea($user, 'stocktransfer', $id, ''); |
126 | -if (!$permissiontoread) accessforbidden(); |
|
137 | +if (!$permissiontoread) { |
|
138 | + accessforbidden(); |
|
139 | +} |
|
127 | 140 | |
128 | 141 | |
129 | 142 | |
@@ -136,7 +149,9 @@ discard block |
||
136 | 149 | |
137 | 150 | $parameters = array(); |
138 | 151 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
139 | -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
152 | +if ($reshook < 0) { |
|
153 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
154 | +} |
|
140 | 155 | |
141 | 156 | if (empty($reshook)) { |
142 | 157 | // Selection of new fields |
@@ -196,18 +211,29 @@ discard block |
||
196 | 211 | if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { |
197 | 212 | $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; |
198 | 213 | } |
199 | -if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; |
|
200 | -else $sql .= " WHERE 1 = 1"; |
|
214 | +if ($object->ismultientitymanaged == 1) { |
|
215 | + $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; |
|
216 | +} else { |
|
217 | + $sql .= " WHERE 1 = 1"; |
|
218 | +} |
|
201 | 219 | foreach ($search as $key => $val) { |
202 | - if ($key == 'status' && $search[$key] == -1) continue; |
|
220 | + if ($key == 'status' && $search[$key] == -1) { |
|
221 | + continue; |
|
222 | + } |
|
203 | 223 | $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); |
204 | 224 | if (strpos($object->fields[$key]['type'], 'integer:') === 0) { |
205 | - if ($search[$key] == '-1') $search[$key] = ''; |
|
225 | + if ($search[$key] == '-1') { |
|
226 | + $search[$key] = ''; |
|
227 | + } |
|
206 | 228 | $mode_search = 2; |
207 | 229 | } |
208 | - if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); |
|
230 | + if ($search[$key] != '') { |
|
231 | + $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); |
|
232 | + } |
|
233 | + } |
|
234 | +if ($search_all) { |
|
235 | + $sql .= natural_search(array_keys($fieldstosearchall), $search_all); |
|
209 | 236 | } |
210 | -if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); |
|
211 | 237 | //$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear); |
212 | 238 | // Add where from extra fields |
213 | 239 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; |
@@ -249,7 +275,9 @@ discard block |
||
249 | 275 | if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { |
250 | 276 | $num = $nbtotalofrecords; |
251 | 277 | } else { |
252 | - if ($limit) $sql .= $db->plimit($limit + 1, $offset); |
|
278 | + if ($limit) { |
|
279 | + $sql .= $db->plimit($limit + 1, $offset); |
|
280 | + } |
|
253 | 281 | |
254 | 282 | $resql = $db->query($sql); |
255 | 283 | if (!$resql) { |
@@ -292,13 +320,22 @@ discard block |
||
292 | 320 | $arrayofselected = is_array($toselect) ? $toselect : array(); |
293 | 321 | |
294 | 322 | $param = ''; |
295 | -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); |
|
296 | -if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.((int) $limit); |
|
323 | +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { |
|
324 | + $param .= '&contextpage='.urlencode($contextpage); |
|
325 | +} |
|
326 | +if ($limit > 0 && $limit != $conf->liste_limit) { |
|
327 | + $param .= '&limit='.((int) $limit); |
|
328 | +} |
|
297 | 329 | foreach ($search as $key => $val) { |
298 | - if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey); |
|
299 | - else $param .= '&search_'.$key.'='.urlencode($search[$key]); |
|
330 | + if (is_array($search[$key]) && count($search[$key])) { |
|
331 | + foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey); |
|
332 | + } else { |
|
333 | + $param .= '&search_'.$key.'='.urlencode($search[$key]); |
|
334 | + } |
|
335 | + } |
|
336 | +if ($optioncss != '') { |
|
337 | + $param .= '&optioncss='.urlencode($optioncss); |
|
300 | 338 | } |
301 | -if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); |
|
302 | 339 | // Add $param from extra fields |
303 | 340 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; |
304 | 341 | |
@@ -309,12 +346,18 @@ discard block |
||
309 | 346 | //'builddoc'=>$langs->trans("PDFMerge"), |
310 | 347 | //'presend'=>$langs->trans("SendByMail"), |
311 | 348 | ); |
312 | -if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); |
|
313 | -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); |
|
349 | +if ($permissiontodelete) { |
|
350 | + $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); |
|
351 | +} |
|
352 | +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { |
|
353 | + $arrayofmassactions = array(); |
|
354 | +} |
|
314 | 355 | $massactionbutton = $form->selectMassAction('', $arrayofmassactions); |
315 | 356 | |
316 | 357 | print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n"; |
317 | -if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
358 | +if ($optioncss != '') { |
|
359 | + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
360 | +} |
|
318 | 361 | print '<input type="hidden" name="token" value="'.newToken().'">'; |
319 | 362 | print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; |
320 | 363 | print '<input type="hidden" name="action" value="list">'; |
@@ -336,7 +379,9 @@ discard block |
||
336 | 379 | include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; |
337 | 380 | |
338 | 381 | if ($search_all) { |
339 | - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); |
|
382 | + foreach ($fieldstosearchall as $key => $val) { |
|
383 | + $fieldstosearchall[$key] = $langs->trans($val); |
|
384 | + } |
|
340 | 385 | print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'; |
341 | 386 | } |
342 | 387 | |
@@ -347,8 +392,11 @@ discard block |
||
347 | 392 | |
348 | 393 | $parameters = array(); |
349 | 394 | $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook |
350 | -if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; |
|
351 | -else $moreforfilter = $hookmanager->resPrint; |
|
395 | +if (empty($reshook)) { |
|
396 | + $moreforfilter .= $hookmanager->resPrint; |
|
397 | +} else { |
|
398 | + $moreforfilter = $hookmanager->resPrint; |
|
399 | +} |
|
352 | 400 | |
353 | 401 | if (!empty($moreforfilter)) { |
354 | 402 | print '<div class="liste_titre liste_titre_bydiv centpercent">'; |
@@ -369,10 +417,15 @@ discard block |
||
369 | 417 | print '<tr class="liste_titre">'; |
370 | 418 | foreach ($object->fields as $key => $val) { |
371 | 419 | $cssforfield = (empty($val['css']) ? '' : $val['css']); |
372 | - if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
373 | - elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
374 | - elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
375 | - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; |
|
420 | + if ($key == 'status') { |
|
421 | + $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
422 | + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { |
|
423 | + $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
424 | + } elseif (in_array($val['type'], array('timestamp'))) { |
|
425 | + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
426 | + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { |
|
427 | + $cssforfield .= ($cssforfield ? ' ' : '').'right'; |
|
428 | + } |
|
376 | 429 | if (!empty($arrayfields['t.'.$key]['checked'])) { |
377 | 430 | print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">'; |
378 | 431 | if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { |
@@ -405,10 +458,15 @@ discard block |
||
405 | 458 | print '<tr class="liste_titre">'; |
406 | 459 | foreach ($object->fields as $key => $val) { |
407 | 460 | $cssforfield = (empty($val['css']) ? '' : $val['css']); |
408 | - if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
409 | - elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
410 | - elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
411 | - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; |
|
461 | + if ($key == 'status') { |
|
462 | + $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
463 | + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { |
|
464 | + $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
465 | + } elseif (in_array($val['type'], array('timestamp'))) { |
|
466 | + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
467 | + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { |
|
468 | + $cssforfield .= ($cssforfield ? ' ' : '').'right'; |
|
469 | + } |
|
412 | 470 | if (!empty($arrayfields['t.'.$key]['checked'])) { |
413 | 471 | print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; |
414 | 472 | } |
@@ -441,7 +499,10 @@ discard block |
||
441 | 499 | $totalarray = array(); |
442 | 500 | while ($i < ($limit ? min($num, $limit) : $num)) { |
443 | 501 | $obj = $db->fetch_object($resql); |
444 | - if (empty($obj)) break; // Should not happen |
|
502 | + if (empty($obj)) { |
|
503 | + break; |
|
504 | + } |
|
505 | + // Should not happen |
|
445 | 506 | |
446 | 507 | // Store properties in $object |
447 | 508 | $object->setVarsFromFetchObj($obj); |
@@ -450,31 +511,48 @@ discard block |
||
450 | 511 | print '<tr class="oddeven">'; |
451 | 512 | foreach ($object->fields as $key => $val) { |
452 | 513 | $cssforfield = (empty($val['css']) ? '' : $val['css']); |
453 | - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
454 | - elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
514 | + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { |
|
515 | + $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
516 | + } elseif ($key == 'status') { |
|
517 | + $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
518 | + } |
|
455 | 519 | |
456 | - if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
457 | - elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
520 | + if (in_array($val['type'], array('timestamp'))) { |
|
521 | + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
522 | + } elseif ($key == 'ref') { |
|
523 | + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
524 | + } |
|
458 | 525 | |
459 | - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right'; |
|
526 | + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') { |
|
527 | + $cssforfield .= ($cssforfield ? ' ' : '').'right'; |
|
528 | + } |
|
460 | 529 | //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; |
461 | 530 | |
462 | 531 | if (!empty($arrayfields['t.'.$key]['checked'])) { |
463 | 532 | print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>'; |
464 | - if ($key == 'status') print $object->getLibStatut(5); |
|
465 | - else { |
|
533 | + if ($key == 'status') { |
|
534 | + print $object->getLibStatut(5); |
|
535 | + } else { |
|
466 | 536 | print $object->showOutputField($val, $key, $object->$key, ''); |
467 | 537 | if ($key === 'date_prevue_depart' && $object->lead_time_for_warning > 0 && $object->$key > 0) { |
468 | 538 | $date_prevue_depart = $object->$key; |
469 | 539 | $date_prevue_depart_plus_delai = $date_prevue_depart; |
470 | - if ($object->lead_time_for_warning > 0) $date_prevue_depart_plus_delai = strtotime(date('Y-m-d', $date_prevue_depart) . ' + '.$object->lead_time_for_warning.' day'); |
|
471 | - if ($date_prevue_depart_plus_delai < strtotime(date('Y-m-d'))) print img_warning($langs->trans('Alert').' - '.$langs->trans('Late')); |
|
540 | + if ($object->lead_time_for_warning > 0) { |
|
541 | + $date_prevue_depart_plus_delai = strtotime(date('Y-m-d', $date_prevue_depart) . ' + '.$object->lead_time_for_warning.' day'); |
|
542 | + } |
|
543 | + if ($date_prevue_depart_plus_delai < strtotime(date('Y-m-d'))) { |
|
544 | + print img_warning($langs->trans('Alert').' - '.$langs->trans('Late')); |
|
545 | + } |
|
472 | 546 | } |
473 | 547 | } |
474 | 548 | print '</td>'; |
475 | - if (!$i) $totalarray['nbfield']++; |
|
549 | + if (!$i) { |
|
550 | + $totalarray['nbfield']++; |
|
551 | + } |
|
476 | 552 | if (!empty($val['isameasure'])) { |
477 | - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; |
|
553 | + if (!$i) { |
|
554 | + $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; |
|
555 | + } |
|
478 | 556 | $totalarray['val']['t.'.$key] += $object->$key; |
479 | 557 | } |
480 | 558 | } |
@@ -489,11 +567,15 @@ discard block |
||
489 | 567 | print '<td class="nowrap center">'; |
490 | 568 | if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined |
491 | 569 | $selected = 0; |
492 | - if (in_array($object->id, $arrayofselected)) $selected = 1; |
|
570 | + if (in_array($object->id, $arrayofselected)) { |
|
571 | + $selected = 1; |
|
572 | + } |
|
493 | 573 | print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>'; |
494 | 574 | } |
495 | 575 | print '</td>'; |
496 | - if (!$i) $totalarray['nbfield']++; |
|
576 | + if (!$i) { |
|
577 | + $totalarray['nbfield']++; |
|
578 | + } |
|
497 | 579 | |
498 | 580 | print '</tr>'."\n"; |
499 | 581 | |
@@ -506,7 +588,10 @@ discard block |
||
506 | 588 | // If no record found |
507 | 589 | if ($num == 0) { |
508 | 590 | $colspan = 1; |
509 | - foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } |
|
591 | + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) { |
|
592 | + $colspan++; |
|
593 | + } |
|
594 | + } |
|
510 | 595 | print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>'; |
511 | 596 | } |
512 | 597 | |
@@ -524,7 +609,9 @@ discard block |
||
524 | 609 | |
525 | 610 | if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { |
526 | 611 | $hidegeneratedfilelistifempty = 1; |
527 | - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; |
|
612 | + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { |
|
613 | + $hidegeneratedfilelistifempty = 0; |
|
614 | + } |
|
528 | 615 | |
529 | 616 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; |
530 | 617 | $formfile = new FormFile($db); |
@@ -455,17 +455,17 @@ |
||
455 | 455 | // Rôles |
456 | 456 | $resql = $this->db->query('SELECT rowid FROM '.MAIN_DB_PREFIX.'c_type_contact WHERE code = "STDEST" AND element = "StockTransfer" AND source = "internal"'); |
457 | 457 | $res = $this->db->fetch_object($resql); |
458 | - $nextid=$this->getNextId(); |
|
458 | + $nextid = $this->getNextId(); |
|
459 | 459 | if (empty($res)) $this->db->query('INSERT INTO '.MAIN_DB_PREFIX.'c_type_contact(rowid, element, source, code, libelle, active, module, position) VALUES('.((int) $nextid).', "StockTransfer", "internal", "STRESP", "Responsable du transfert de stocks", 1, NULL, 0)'); |
460 | 460 | |
461 | 461 | $resql = $this->db->query('SELECT rowid FROM '.MAIN_DB_PREFIX.'c_type_contact WHERE code = "STFROM" AND element = "StockTransfer" AND source = "external"'); |
462 | 462 | $res = $this->db->fetch_object($resql); |
463 | - $nextid=$this->getNextId(); |
|
463 | + $nextid = $this->getNextId(); |
|
464 | 464 | if (empty($res)) $this->db->query('INSERT INTO '.MAIN_DB_PREFIX.'c_type_contact(rowid, element, source, code, libelle, active, module, position) VALUES('.((int) $nextid).', "StockTransfer", "external", "STFROM", "Contact expéditeur transfert de stocks", 1, NULL, 0)'); |
465 | 465 | |
466 | 466 | $resql = $this->db->query('SELECT rowid FROM '.MAIN_DB_PREFIX.'c_type_contact WHERE code = "STDEST" AND element = "StockTransfer" AND source = "external"'); |
467 | 467 | $res = $this->db->fetch_object($resql); |
468 | - $nextid=$this->getNextId(); |
|
468 | + $nextid = $this->getNextId(); |
|
469 | 469 | if (empty($res)) $this->db->query('INSERT INTO '.MAIN_DB_PREFIX.'c_type_contact(rowid, element, source, code, libelle, active, module, position) VALUES('.((int) $nextid).', "StockTransfer", "external", "STDEST", "Contact destinataire transfert de stocks", 1, NULL, 0)'); |
470 | 470 | |
471 | 471 | return $this->_init($sql, $options); |
@@ -426,7 +426,10 @@ discard block |
||
426 | 426 | global $conf, $langs; |
427 | 427 | |
428 | 428 | $result = $this->_load_tables('/install/mysql/tables/', 'stocktransfer'); |
429 | - if ($result < 0) return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default') |
|
429 | + if ($result < 0) { |
|
430 | + return -1; |
|
431 | + } |
|
432 | + // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default') |
|
430 | 433 | |
431 | 434 | // Permissions |
432 | 435 | $this->remove($options); |
@@ -437,17 +440,23 @@ discard block |
||
437 | 440 | $resql = $this->db->query('SELECT rowid FROM '.MAIN_DB_PREFIX.'c_type_contact WHERE code = "STDEST" AND element = "StockTransfer" AND source = "internal"'); |
438 | 441 | $res = $this->db->fetch_object($resql); |
439 | 442 | $nextid=$this->getNextId(); |
440 | - if (empty($res)) $this->db->query('INSERT INTO '.MAIN_DB_PREFIX.'c_type_contact(rowid, element, source, code, libelle, active, module, position) VALUES('.((int) $nextid).', "StockTransfer", "internal", "STRESP", "Responsable du transfert de stocks", 1, NULL, 0)'); |
|
443 | + if (empty($res)) { |
|
444 | + $this->db->query('INSERT INTO '.MAIN_DB_PREFIX.'c_type_contact(rowid, element, source, code, libelle, active, module, position) VALUES('.((int) $nextid).', "StockTransfer", "internal", "STRESP", "Responsable du transfert de stocks", 1, NULL, 0)'); |
|
445 | + } |
|
441 | 446 | |
442 | 447 | $resql = $this->db->query('SELECT rowid FROM '.MAIN_DB_PREFIX.'c_type_contact WHERE code = "STFROM" AND element = "StockTransfer" AND source = "external"'); |
443 | 448 | $res = $this->db->fetch_object($resql); |
444 | 449 | $nextid=$this->getNextId(); |
445 | - if (empty($res)) $this->db->query('INSERT INTO '.MAIN_DB_PREFIX.'c_type_contact(rowid, element, source, code, libelle, active, module, position) VALUES('.((int) $nextid).', "StockTransfer", "external", "STFROM", "Contact expéditeur transfert de stocks", 1, NULL, 0)'); |
|
450 | + if (empty($res)) { |
|
451 | + $this->db->query('INSERT INTO '.MAIN_DB_PREFIX.'c_type_contact(rowid, element, source, code, libelle, active, module, position) VALUES('.((int) $nextid).', "StockTransfer", "external", "STFROM", "Contact expéditeur transfert de stocks", 1, NULL, 0)'); |
|
452 | + } |
|
446 | 453 | |
447 | 454 | $resql = $this->db->query('SELECT rowid FROM '.MAIN_DB_PREFIX.'c_type_contact WHERE code = "STDEST" AND element = "StockTransfer" AND source = "external"'); |
448 | 455 | $res = $this->db->fetch_object($resql); |
449 | 456 | $nextid=$this->getNextId(); |
450 | - if (empty($res)) $this->db->query('INSERT INTO '.MAIN_DB_PREFIX.'c_type_contact(rowid, element, source, code, libelle, active, module, position) VALUES('.((int) $nextid).', "StockTransfer", "external", "STDEST", "Contact destinataire transfert de stocks", 1, NULL, 0)'); |
|
457 | + if (empty($res)) { |
|
458 | + $this->db->query('INSERT INTO '.MAIN_DB_PREFIX.'c_type_contact(rowid, element, source, code, libelle, active, module, position) VALUES('.((int) $nextid).', "StockTransfer", "external", "STDEST", "Contact destinataire transfert de stocks", 1, NULL, 0)'); |
|
459 | + } |
|
451 | 460 | |
452 | 461 | return $this->_init($sql, $options); |
453 | 462 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | * \ingroup stocktransfer |
24 | 24 | * \brief File of class to manage StockTransfer numbering rules standard |
25 | 25 | */ |
26 | -require_once DOL_DOCUMENT_ROOT . '/core/modules/stocktransfer/modules_stocktransfer.php'; |
|
26 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/stocktransfer/modules_stocktransfer.php'; |
|
27 | 27 | |
28 | 28 | |
29 | 29 | /** |
@@ -134,8 +134,11 @@ discard block |
||
134 | 134 | $resql = $db->query($sql); |
135 | 135 | if ($resql) { |
136 | 136 | $obj = $db->fetch_object($resql); |
137 | - if ($obj) $max = intval($obj->max); |
|
138 | - else $max = 0; |
|
137 | + if ($obj) { |
|
138 | + $max = intval($obj->max); |
|
139 | + } else { |
|
140 | + $max = 0; |
|
141 | + } |
|
139 | 142 | } else { |
140 | 143 | dol_syslog("mod_stocktransfer_standard::getNextValue", LOG_DEBUG); |
141 | 144 | return -1; |
@@ -145,8 +148,13 @@ discard block |
||
145 | 148 | $date = $object->date_creation; |
146 | 149 | $yymm = strftime("%y%m", $date); |
147 | 150 | |
148 | - if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
149 | - else $num = sprintf("%04s", $max + 1); |
|
151 | + if ($max >= (pow(10, 4) - 1)) { |
|
152 | + $num = $max + 1; |
|
153 | + } |
|
154 | + // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
155 | + else { |
|
156 | + $num = sprintf("%04s", $max + 1); |
|
157 | + } |
|
150 | 158 | |
151 | 159 | dol_syslog("mod_stocktransfer_standard::getNextValue return ".$this->prefix.$yymm."-".$num); |
152 | 160 | return $this->prefix.$yymm."-".$num; |
@@ -27,7 +27,7 @@ |
||
27 | 27 | * \brief File containing class for advanced numbering model of StockTransfer |
28 | 28 | */ |
29 | 29 | |
30 | -require_once DOL_DOCUMENT_ROOT . '/core/modules/stocktransfer/modules_stocktransfer.php'; |
|
30 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/stocktransfer/modules_stocktransfer.php'; |
|
31 | 31 | |
32 | 32 | |
33 | 33 | /** |
@@ -434,7 +434,7 @@ |
||
434 | 434 | $invoicecredits[] = $facavoir->getNomUrl(1); |
435 | 435 | } |
436 | 436 | print ' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities("InvoiceHasAvoir"); |
437 | - print ' '. (count($invoicecredits) ? ' ' : '') . implode(',', $invoicecredits); |
|
437 | + print ' '.(count($invoicecredits) ? ' ' : '').implode(',', $invoicecredits); |
|
438 | 438 | print '</span>'; |
439 | 439 | } |
440 | 440 | /* |
@@ -394,7 +394,7 @@ |
||
394 | 394 | print '<tr class="oddeven" height="24">'; |
395 | 395 | print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&mode='.$mode.($socid > 0 ? '&socid='.$socid : '').($userid > 0 ? '&userid='.$userid : '').'">'.$year.'</a></td>'; |
396 | 396 | print '<td class="right">'.$val['nb'].'</td>'; |
397 | - print '<td class="right opacitylow" style="'.((!isset($val['nb_diff']) || $val['nb_diff'] >= 0) ? 'color: green;' : 'color: red;').'">'.(isset($val['nb_diff']) ? round($val['nb_diff']): "0").'%</td>'; |
|
397 | + print '<td class="right opacitylow" style="'.((!isset($val['nb_diff']) || $val['nb_diff'] >= 0) ? 'color: green;' : 'color: red;').'">'.(isset($val['nb_diff']) ? round($val['nb_diff']) : "0").'%</td>'; |
|
398 | 398 | print '<td class="right">'.price(price2num($val['total'], 'MT'), 1).'</td>'; |
399 | 399 | print '<td class="right opacitylow" style="'.((!isset($val['total_diff']) || $val['total_diff'] >= 0) ? 'color: green;' : 'color: red;').'">'.(isset($val['total_diff']) ? round($val['total_diff']) : "0").'%</td>'; |
400 | 400 | print '<td class="right">'.price(price2num($val['avg'], 'MT'), 1).'</td>'; |
@@ -77,8 +77,12 @@ |
||
77 | 77 | //if ($user->socid > 0) $socid = $user->socid; |
78 | 78 | //$isdraft = (isset($object->status) && ($object->status == $object::STATUS_DRAFT) ? 1 : 0); |
79 | 79 | //restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); |
80 | -if (empty($conf->intracommreport->enabled)) accessforbidden(); |
|
81 | -if (!$permissiontoread) accessforbidden(); |
|
80 | +if (empty($conf->intracommreport->enabled)) { |
|
81 | + accessforbidden(); |
|
82 | +} |
|
83 | +if (!$permissiontoread) { |
|
84 | + accessforbidden(); |
|
85 | +} |
|
82 | 86 | |
83 | 87 | |
84 | 88 |
@@ -118,7 +118,7 @@ |
||
118 | 118 | if ($action == 'add' && $permissiontoadd) { |
119 | 119 | $object->label = trim($label); |
120 | 120 | $object->type = trim($exporttype); |
121 | - $object->type_declaration = $type_declaration; |
|
121 | + $object->type_declaration = $type_declaration; |
|
122 | 122 | //$object->subscription = (int) $subscription; |
123 | 123 | |
124 | 124 | // Fill array 'array_options' with data from add form |
@@ -615,7 +615,7 @@ |
||
615 | 615 | |
616 | 616 | $ref = dol_sanitizeFileName($newref); |
617 | 617 | $pdf_path = $dir_output."/".$ref.".pdf"; |
618 | - if (!dol_is_file($pdf_path)||(is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0 && !$arraydefaultmessage->joinfiles)) { |
|
618 | + if (!dol_is_file($pdf_path) || (is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0 && !$arraydefaultmessage->joinfiles)) { |
|
619 | 619 | // We can't add PDF as it is not generated yet. |
620 | 620 | $filepdf = ''; |
621 | 621 | } else { |