@@ -46,18 +46,26 @@ discard block |
||
46 | 46 | $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); |
47 | 47 | $head[$h][0] = dol_buildpath('/product/stock/stocktransfer/stocktransfer_contact.php', 1).'?id='.$object->id; |
48 | 48 | $head[$h][1] = $langs->trans('ContactsAddresses'); |
49 | - if ($nbContact > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>'; |
|
49 | + if ($nbContact > 0) { |
|
50 | + $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>'; |
|
51 | + } |
|
50 | 52 | $head[$h][2] = 'contact'; |
51 | 53 | $h++; |
52 | 54 | } |
53 | 55 | |
54 | 56 | if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) { |
55 | 57 | $nbNote = 0; |
56 | - if (!empty($object->note_private)) $nbNote++; |
|
57 | - if (!empty($object->note_public)) $nbNote++; |
|
58 | + if (!empty($object->note_private)) { |
|
59 | + $nbNote++; |
|
60 | + } |
|
61 | + if (!empty($object->note_public)) { |
|
62 | + $nbNote++; |
|
63 | + } |
|
58 | 64 | $head[$h][0] = dol_buildpath('/product/stock/stocktransfer/stocktransfer_note.php', 1).'?id='.$object->id; |
59 | 65 | $head[$h][1] = $langs->trans('Notes'); |
60 | - if ($nbNote > 0) $head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '<span class="badge marginleftonlyshort">'.$nbNote.'</span>' : ''); |
|
66 | + if ($nbNote > 0) { |
|
67 | + $head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '<span class="badge marginleftonlyshort">'.$nbNote.'</span>' : ''); |
|
68 | + } |
|
61 | 69 | $head[$h][2] = 'note'; |
62 | 70 | $h++; |
63 | 71 | } |
@@ -69,7 +77,9 @@ discard block |
||
69 | 77 | $nbLinks = Link::count($db, $object->element, $object->id); |
70 | 78 | $head[$h][0] = dol_buildpath("/product/stock/stocktransfer/stocktransfer_document.php", 1).'?id='.$object->id; |
71 | 79 | $head[$h][1] = $langs->trans('Documents'); |
72 | - if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>'; |
|
80 | + if (($nbFiles + $nbLinks) > 0) { |
|
81 | + $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>'; |
|
82 | + } |
|
73 | 83 | $head[$h][2] = 'document'; |
74 | 84 | $h++; |
75 | 85 |
@@ -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,28 +69,39 @@ 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(); |
84 | 91 | foreach ($object->fields as $key => $val) { |
85 | - if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; |
|
86 | -} |
|
92 | + if ($val['searchall']) { |
|
93 | + $fieldstosearchall['t.'.$key] = $val['label']; |
|
94 | + } |
|
95 | + } |
|
87 | 96 | |
88 | 97 | // Definition of fields for list |
89 | 98 | $arrayfields = array(); |
90 | 99 | foreach ($object->fields as $key => $val) { |
91 | 100 | // If $val['visible']==0, then we never show the field |
92 | - 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']); |
|
93 | -} |
|
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 | + } |
|
94 | 105 | //var_dump($object->fields); |
95 | 106 | // Extra fields |
96 | 107 | if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { |
@@ -114,14 +125,18 @@ discard block |
||
114 | 125 | $permissiontodelete = $user->rights->stocktransfer->stocktransfer->delete; |
115 | 126 | |
116 | 127 | // Security check |
117 | -if (empty($conf->stocktransfer->enabled)) accessforbidden('Module not enabled'); |
|
128 | +if (empty($conf->stocktransfer->enabled)) { |
|
129 | + accessforbidden('Module not enabled'); |
|
130 | +} |
|
118 | 131 | $socid = 0; |
119 | 132 | if ($user->socid > 0) { // Protection if external user |
120 | 133 | //$socid = $user->socid; |
121 | 134 | accessforbidden(); |
122 | 135 | } |
123 | 136 | //$result = restrictedArea($user, 'stocktransfer', $id, ''); |
124 | -if (!$permissiontoread) accessforbidden(); |
|
137 | +if (!$permissiontoread) { |
|
138 | + accessforbidden(); |
|
139 | +} |
|
125 | 140 | |
126 | 141 | |
127 | 142 | |
@@ -134,7 +149,9 @@ discard block |
||
134 | 149 | |
135 | 150 | $parameters = array(); |
136 | 151 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
137 | -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
152 | +if ($reshook < 0) { |
|
153 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
154 | +} |
|
138 | 155 | |
139 | 156 | if (empty($reshook)) { |
140 | 157 | // Selection of new fields |
@@ -191,19 +208,32 @@ discard block |
||
191 | 208 | $sql .= $hookmanager->resPrint; |
192 | 209 | $sql = preg_replace('/,\s*$/', '', $sql); |
193 | 210 | $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; |
194 | -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; |
|
195 | -if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; |
|
196 | -else $sql .= " WHERE 1 = 1"; |
|
211 | +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { |
|
212 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; |
|
213 | +} |
|
214 | +if ($object->ismultientitymanaged == 1) { |
|
215 | + $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; |
|
216 | +} else { |
|
217 | + $sql .= " WHERE 1 = 1"; |
|
218 | +} |
|
197 | 219 | foreach ($search as $key => $val) { |
198 | - if ($key == 'status' && $search[$key] == -1) continue; |
|
220 | + if ($key == 'status' && $search[$key] == -1) { |
|
221 | + continue; |
|
222 | + } |
|
199 | 223 | $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); |
200 | 224 | if (strpos($object->fields[$key]['type'], 'integer:') === 0) { |
201 | - if ($search[$key] == '-1') $search[$key] = ''; |
|
225 | + if ($search[$key] == '-1') { |
|
226 | + $search[$key] = ''; |
|
227 | + } |
|
202 | 228 | $mode_search = 2; |
203 | 229 | } |
204 | - 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); |
|
205 | 236 | } |
206 | -if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); |
|
207 | 237 | //$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear); |
208 | 238 | // Add where from extra fields |
209 | 239 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; |
@@ -245,7 +275,9 @@ discard block |
||
245 | 275 | if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { |
246 | 276 | $num = $nbtotalofrecords; |
247 | 277 | } else { |
248 | - if ($limit) $sql .= $db->plimit($limit + 1, $offset); |
|
278 | + if ($limit) { |
|
279 | + $sql .= $db->plimit($limit + 1, $offset); |
|
280 | + } |
|
249 | 281 | |
250 | 282 | $resql = $db->query($sql); |
251 | 283 | if (!$resql) { |
@@ -288,13 +320,22 @@ discard block |
||
288 | 320 | $arrayofselected = is_array($toselect) ? $toselect : array(); |
289 | 321 | |
290 | 322 | $param = ''; |
291 | -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); |
|
292 | -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 | +} |
|
293 | 329 | foreach ($search as $key => $val) { |
294 | - if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey); |
|
295 | - 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); |
|
296 | 338 | } |
297 | -if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); |
|
298 | 339 | // Add $param from extra fields |
299 | 340 | include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; |
300 | 341 | |
@@ -305,12 +346,18 @@ discard block |
||
305 | 346 | //'builddoc'=>$langs->trans("PDFMerge"), |
306 | 347 | //'presend'=>$langs->trans("SendByMail"), |
307 | 348 | ); |
308 | -if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); |
|
309 | -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 | +} |
|
310 | 355 | $massactionbutton = $form->selectMassAction('', $arrayofmassactions); |
311 | 356 | |
312 | 357 | print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n"; |
313 | -if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
358 | +if ($optioncss != '') { |
|
359 | + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; |
|
360 | +} |
|
314 | 361 | print '<input type="hidden" name="token" value="'.newToken().'">'; |
315 | 362 | print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; |
316 | 363 | print '<input type="hidden" name="action" value="list">'; |
@@ -331,7 +378,9 @@ discard block |
||
331 | 378 | include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; |
332 | 379 | |
333 | 380 | if ($search_all) { |
334 | - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); |
|
381 | + foreach ($fieldstosearchall as $key => $val) { |
|
382 | + $fieldstosearchall[$key] = $langs->trans($val); |
|
383 | + } |
|
335 | 384 | print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'; |
336 | 385 | } |
337 | 386 | |
@@ -342,8 +391,11 @@ discard block |
||
342 | 391 | |
343 | 392 | $parameters = array(); |
344 | 393 | $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook |
345 | -if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; |
|
346 | -else $moreforfilter = $hookmanager->resPrint; |
|
394 | +if (empty($reshook)) { |
|
395 | + $moreforfilter .= $hookmanager->resPrint; |
|
396 | +} else { |
|
397 | + $moreforfilter = $hookmanager->resPrint; |
|
398 | +} |
|
347 | 399 | |
348 | 400 | if (!empty($moreforfilter)) { |
349 | 401 | print '<div class="liste_titre liste_titre_bydiv centpercent">'; |
@@ -364,16 +416,24 @@ discard block |
||
364 | 416 | print '<tr class="liste_titre">'; |
365 | 417 | foreach ($object->fields as $key => $val) { |
366 | 418 | $cssforfield = (empty($val['css']) ? '' : $val['css']); |
367 | - if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
368 | - elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
369 | - elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
370 | - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; |
|
419 | + if ($key == 'status') { |
|
420 | + $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
421 | + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { |
|
422 | + $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
423 | + } elseif (in_array($val['type'], array('timestamp'))) { |
|
424 | + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
425 | + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { |
|
426 | + $cssforfield .= ($cssforfield ? ' ' : '').'right'; |
|
427 | + } |
|
371 | 428 | if (!empty($arrayfields['t.'.$key]['checked'])) { |
372 | 429 | print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">'; |
373 | - if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75'); |
|
374 | - elseif (strpos($val['type'], 'integer:') === 0) { |
|
430 | + if (is_array($val['arrayofkeyval'])) { |
|
431 | + print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75'); |
|
432 | + } elseif (strpos($val['type'], 'integer:') === 0) { |
|
375 | 433 | print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); |
376 | - } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">'; |
|
434 | + } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) { |
|
435 | + print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">'; |
|
436 | + } |
|
377 | 437 | print '</td>'; |
378 | 438 | } |
379 | 439 | } |
@@ -397,10 +457,15 @@ discard block |
||
397 | 457 | print '<tr class="liste_titre">'; |
398 | 458 | foreach ($object->fields as $key => $val) { |
399 | 459 | $cssforfield = (empty($val['css']) ? '' : $val['css']); |
400 | - if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
401 | - elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
402 | - elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
403 | - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; |
|
460 | + if ($key == 'status') { |
|
461 | + $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
462 | + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { |
|
463 | + $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
464 | + } elseif (in_array($val['type'], array('timestamp'))) { |
|
465 | + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
466 | + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { |
|
467 | + $cssforfield .= ($cssforfield ? ' ' : '').'right'; |
|
468 | + } |
|
404 | 469 | if (!empty($arrayfields['t.'.$key]['checked'])) { |
405 | 470 | print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; |
406 | 471 | } |
@@ -433,7 +498,10 @@ discard block |
||
433 | 498 | $totalarray = array(); |
434 | 499 | while ($i < ($limit ? min($num, $limit) : $num)) { |
435 | 500 | $obj = $db->fetch_object($resql); |
436 | - if (empty($obj)) break; // Should not happen |
|
501 | + if (empty($obj)) { |
|
502 | + break; |
|
503 | + } |
|
504 | + // Should not happen |
|
437 | 505 | |
438 | 506 | // Store properties in $object |
439 | 507 | $object->setVarsFromFetchObj($obj); |
@@ -442,31 +510,48 @@ discard block |
||
442 | 510 | print '<tr class="oddeven">'; |
443 | 511 | foreach ($object->fields as $key => $val) { |
444 | 512 | $cssforfield = (empty($val['css']) ? '' : $val['css']); |
445 | - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
446 | - elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
513 | + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { |
|
514 | + $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
515 | + } elseif ($key == 'status') { |
|
516 | + $cssforfield .= ($cssforfield ? ' ' : '').'center'; |
|
517 | + } |
|
447 | 518 | |
448 | - if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
449 | - elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
519 | + if (in_array($val['type'], array('timestamp'))) { |
|
520 | + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
521 | + } elseif ($key == 'ref') { |
|
522 | + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; |
|
523 | + } |
|
450 | 524 | |
451 | - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right'; |
|
525 | + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') { |
|
526 | + $cssforfield .= ($cssforfield ? ' ' : '').'right'; |
|
527 | + } |
|
452 | 528 | //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; |
453 | 529 | |
454 | 530 | if (!empty($arrayfields['t.'.$key]['checked'])) { |
455 | 531 | print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>'; |
456 | - if ($key == 'status') print $object->getLibStatut(5); |
|
457 | - else { |
|
532 | + if ($key == 'status') { |
|
533 | + print $object->getLibStatut(5); |
|
534 | + } else { |
|
458 | 535 | print $object->showOutputField($val, $key, $object->$key, ''); |
459 | 536 | if ($key === 'date_prevue_depart' && $object->lead_time_for_warning > 0 && $object->$key > 0) { |
460 | 537 | $date_prevue_depart = $object->$key; |
461 | 538 | $date_prevue_depart_plus_delai = $date_prevue_depart; |
462 | - 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'); |
|
463 | - if ($date_prevue_depart_plus_delai < strtotime(date('Y-m-d'))) print img_warning($langs->trans('Alert').' - '.$langs->trans('Late')); |
|
539 | + if ($object->lead_time_for_warning > 0) { |
|
540 | + $date_prevue_depart_plus_delai = strtotime(date('Y-m-d', $date_prevue_depart) . ' + '.$object->lead_time_for_warning.' day'); |
|
541 | + } |
|
542 | + if ($date_prevue_depart_plus_delai < strtotime(date('Y-m-d'))) { |
|
543 | + print img_warning($langs->trans('Alert').' - '.$langs->trans('Late')); |
|
544 | + } |
|
464 | 545 | } |
465 | 546 | } |
466 | 547 | print '</td>'; |
467 | - if (!$i) $totalarray['nbfield']++; |
|
548 | + if (!$i) { |
|
549 | + $totalarray['nbfield']++; |
|
550 | + } |
|
468 | 551 | if (!empty($val['isameasure'])) { |
469 | - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; |
|
552 | + if (!$i) { |
|
553 | + $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; |
|
554 | + } |
|
470 | 555 | $totalarray['val']['t.'.$key] += $object->$key; |
471 | 556 | } |
472 | 557 | } |
@@ -481,11 +566,15 @@ discard block |
||
481 | 566 | print '<td class="nowrap center">'; |
482 | 567 | if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined |
483 | 568 | $selected = 0; |
484 | - if (in_array($object->id, $arrayofselected)) $selected = 1; |
|
569 | + if (in_array($object->id, $arrayofselected)) { |
|
570 | + $selected = 1; |
|
571 | + } |
|
485 | 572 | print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>'; |
486 | 573 | } |
487 | 574 | print '</td>'; |
488 | - if (!$i) $totalarray['nbfield']++; |
|
575 | + if (!$i) { |
|
576 | + $totalarray['nbfield']++; |
|
577 | + } |
|
489 | 578 | |
490 | 579 | print '</tr>'."\n"; |
491 | 580 | |
@@ -498,7 +587,10 @@ discard block |
||
498 | 587 | // If no record found |
499 | 588 | if ($num == 0) { |
500 | 589 | $colspan = 1; |
501 | - foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } |
|
590 | + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) { |
|
591 | + $colspan++; |
|
592 | + } |
|
593 | + } |
|
502 | 594 | print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; |
503 | 595 | } |
504 | 596 | |
@@ -516,7 +608,9 @@ discard block |
||
516 | 608 | |
517 | 609 | if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { |
518 | 610 | $hidegeneratedfilelistifempty = 1; |
519 | - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; |
|
611 | + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { |
|
612 | + $hidegeneratedfilelistifempty = 0; |
|
613 | + } |
|
520 | 614 | |
521 | 615 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; |
522 | 616 | $formfile = new FormFile($db); |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | /** |
95 | 95 | * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. |
96 | 96 | */ |
97 | - public $fields=array( |
|
97 | + public $fields = array( |
|
98 | 98 | 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'comment'=>"Id"), |
99 | 99 | 'amount' => array('type'=>'price', 'label'=>'Amount', 'enabled'=>'1', 'position'=>40, 'notnull'=>0, 'visible'=>1, 'default'=>'null', 'isameasure'=>'1', 'help'=>"Help text for amount",), |
100 | 100 | 'qty' => array('type'=>'real', 'label'=>'Qty', 'enabled'=>'1', 'position'=>45, 'notnull'=>0, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'css'=>'maxwidth75imp', 'help'=>"Help text for quantity",), |
@@ -449,9 +449,9 @@ discard block |
||
449 | 449 | |
450 | 450 | global $conf, $user, $langs; |
451 | 451 | |
452 | - require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; |
|
453 | - include_once DOL_DOCUMENT_ROOT . '/product/stock/class/mouvementstock.class.php'; |
|
454 | - include_once DOL_DOCUMENT_ROOT . '/product/stock/stocktransfer/class/stocktransfer.class.php'; |
|
452 | + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
|
453 | + include_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; |
|
454 | + include_once DOL_DOCUMENT_ROOT.'/product/stock/stocktransfer/class/stocktransfer.class.php'; |
|
455 | 455 | |
456 | 456 | $p = new Product($this->db); |
457 | 457 | $p->fetch($this->fk_product); |
@@ -128,8 +128,12 @@ discard block |
||
128 | 128 | |
129 | 129 | $this->db = $db; |
130 | 130 | |
131 | - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0; |
|
132 | - if (!isModEnabled('multicompany') && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0; |
|
131 | + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) { |
|
132 | + $this->fields['rowid']['visible'] = 0; |
|
133 | + } |
|
134 | + if (!isModEnabled('multicompany') && isset($this->fields['entity'])) { |
|
135 | + $this->fields['entity']['enabled'] = 0; |
|
136 | + } |
|
133 | 137 | |
134 | 138 | // Example to show how to set values of fields definition dynamically |
135 | 139 | /*if ($user->rights->stocktransfer->stocktransferline->read) { |
@@ -188,7 +192,9 @@ discard block |
||
188 | 192 | |
189 | 193 | // Load source object |
190 | 194 | $result = $object->fetchCommon($fromid); |
191 | - if ($result > 0 && !empty($object->table_element_line)) $object->fetchLines(); |
|
195 | + if ($result > 0 && !empty($object->table_element_line)) { |
|
196 | + $object->fetchLines(); |
|
197 | + } |
|
192 | 198 | |
193 | 199 | // get lines so they will be clone |
194 | 200 | //foreach($this->lines as $line) |
@@ -235,8 +241,9 @@ discard block |
||
235 | 241 | if (!$error) { |
236 | 242 | // copy external contacts if same company |
237 | 243 | if (property_exists($this, 'socid') && $this->socid == $object->socid) { |
238 | - if ($this->copy_linked_contact($object, 'external') < 0) |
|
239 | - $error++; |
|
244 | + if ($this->copy_linked_contact($object, 'external') < 0) { |
|
245 | + $error++; |
|
246 | + } |
|
240 | 247 | } |
241 | 248 | } |
242 | 249 | |
@@ -262,7 +269,9 @@ discard block |
||
262 | 269 | public function fetch($id, $ref = null) |
263 | 270 | { |
264 | 271 | $result = $this->fetchCommon($id, $ref); |
265 | - if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines(); |
|
272 | + if ($result > 0 && !empty($this->table_element_line)) { |
|
273 | + $this->fetchLines(); |
|
274 | + } |
|
266 | 275 | return $result; |
267 | 276 | } |
268 | 277 | |
@@ -300,8 +309,11 @@ discard block |
||
300 | 309 | $sql = 'SELECT '; |
301 | 310 | $sql .= $this->getFieldList(); |
302 | 311 | $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; |
303 | - if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; |
|
304 | - else $sql .= ' WHERE 1 = 1'; |
|
312 | + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { |
|
313 | + $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; |
|
314 | + } else { |
|
315 | + $sql .= ' WHERE 1 = 1'; |
|
316 | + } |
|
305 | 317 | // Manage filter |
306 | 318 | $sqlwhere = array(); |
307 | 319 | if (count($filter) > 0) { |
@@ -548,8 +560,12 @@ discard block |
||
548 | 560 | $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; |
549 | 561 | $sql .= " SET ref = '".$this->db->escape($num)."',"; |
550 | 562 | $sql .= " status = ".self::STATUS_VALIDATED; |
551 | - if (!empty($this->fields['date_validation'])) $sql .= ", date_validation = '".$this->db->idate($now)."',"; |
|
552 | - if (!empty($this->fields['fk_user_valid'])) $sql .= ", fk_user_valid = ".((int) $user->id); |
|
563 | + if (!empty($this->fields['date_validation'])) { |
|
564 | + $sql .= ", date_validation = '".$this->db->idate($now)."',"; |
|
565 | + } |
|
566 | + if (!empty($this->fields['fk_user_valid'])) { |
|
567 | + $sql .= ", fk_user_valid = ".((int) $user->id); |
|
568 | + } |
|
553 | 569 | $sql .= " WHERE rowid = ".((int) $this->id); |
554 | 570 | |
555 | 571 | dol_syslog(get_class($this)."::validate()", LOG_DEBUG); |
@@ -563,7 +579,9 @@ discard block |
||
563 | 579 | if (!$error && !$notrigger) { |
564 | 580 | // Call trigger |
565 | 581 | $result = $this->call_trigger('STOCKTRANSFERLINE_VALIDATE', $user); |
566 | - if ($result < 0) $error++; |
|
582 | + if ($result < 0) { |
|
583 | + $error++; |
|
584 | + } |
|
567 | 585 | // End call triggers |
568 | 586 | } |
569 | 587 | } |
@@ -705,7 +723,10 @@ discard block |
||
705 | 723 | { |
706 | 724 | global $conf, $langs, $hookmanager; |
707 | 725 | |
708 | - if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips |
|
726 | + if (!empty($conf->dol_no_mouse_hover)) { |
|
727 | + $notooltip = 1; |
|
728 | + } |
|
729 | + // Force disable tooltips |
|
709 | 730 | |
710 | 731 | $result = ''; |
711 | 732 | |
@@ -737,7 +758,9 @@ discard block |
||
737 | 758 | } |
738 | 759 | $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; |
739 | 760 | $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; |
740 | - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); |
|
761 | + } else { |
|
762 | + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); |
|
763 | + } |
|
741 | 764 | |
742 | 765 | $linkstart = '<a href="'.$url.'"'; |
743 | 766 | $linkstart .= $linkclose.'>'; |
@@ -746,7 +769,9 @@ discard block |
||
746 | 769 | $result .= $linkstart; |
747 | 770 | |
748 | 771 | if (empty($this->showphoto_on_popup)) { |
749 | - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); |
|
772 | + if ($withpicto) { |
|
773 | + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); |
|
774 | + } |
|
750 | 775 | } else { |
751 | 776 | if ($withpicto) { |
752 | 777 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
@@ -772,7 +797,9 @@ discard block |
||
772 | 797 | } |
773 | 798 | } |
774 | 799 | |
775 | - if ($withpicto != 2) $result .= $this->ref; |
|
800 | + if ($withpicto != 2) { |
|
801 | + $result .= $this->ref; |
|
802 | + } |
|
776 | 803 | |
777 | 804 | $result .= $linkend; |
778 | 805 | //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); |
@@ -781,8 +808,11 @@ discard block |
||
781 | 808 | $hookmanager->initHooks(array('stocktransferlinedao')); |
782 | 809 | $parameters = array('id'=>$this->id, 'getnomurl'=>$result); |
783 | 810 | $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
784 | - if ($reshook > 0) $result = $hookmanager->resPrint; |
|
785 | - else $result .= $hookmanager->resPrint; |
|
811 | + if ($reshook > 0) { |
|
812 | + $result = $hookmanager->resPrint; |
|
813 | + } else { |
|
814 | + $result .= $hookmanager->resPrint; |
|
815 | + } |
|
786 | 816 | |
787 | 817 | return $result; |
788 | 818 | } |
@@ -822,7 +852,9 @@ discard block |
||
822 | 852 | |
823 | 853 | $statusType = 'status'.$status; |
824 | 854 | //if ($status == self::STATUS_VALIDATED) $statusType = 'status1'; |
825 | - if ($status == self::STATUS_CANCELED) $statusType = 'status6'; |
|
855 | + if ($status == self::STATUS_CANCELED) { |
|
856 | + $statusType = 'status6'; |
|
857 | + } |
|
826 | 858 | |
827 | 859 | return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); |
828 | 860 | } |
@@ -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>'; |
@@ -66,26 +66,26 @@ |
||
66 | 66 | $rep = new stdClass(); |
67 | 67 | $rep->response_status = 0; |
68 | 68 | $rep->data = null; |
69 | -$rep->error = '';//@todo deprecated use error_message instead |
|
69 | +$rep->error = ''; //@todo deprecated use error_message instead |
|
70 | 70 | $rep->errorMessage = ''; |
71 | 71 | |
72 | 72 | |
73 | 73 | if (empty($fk_expense) || $fk_expense < 0) { |
74 | - $rep->errorMessage = $langs->transnoentitiesnoconv('ErrorBadValueForParameter', $fk_expense, 'fk_expense'); |
|
74 | + $rep->errorMessage = $langs->transnoentitiesnoconv('ErrorBadValueForParameter', $fk_expense, 'fk_expense'); |
|
75 | 75 | } elseif (empty($fk_c_exp_tax_cat) || $fk_c_exp_tax_cat < 0) { |
76 | - $rep->errorMessage = $langs->transnoentitiesnoconv('ErrorBadValueForParameter', $fk_c_exp_tax_cat, 'fk_c_exp_tax_cat'); |
|
76 | + $rep->errorMessage = $langs->transnoentitiesnoconv('ErrorBadValueForParameter', $fk_c_exp_tax_cat, 'fk_c_exp_tax_cat'); |
|
77 | 77 | |
78 | 78 | $rep->response_status = 'error'; |
79 | 79 | } else { |
80 | 80 | // @see ndfp.class.php:3576 (method: compute_total_km) |
81 | 81 | $expense = new ExpenseReport($db); |
82 | 82 | if ($expense->fetch($fk_expense) <= 0) { |
83 | - $rep->errorMessage = $langs->transnoentitiesnoconv('ErrorRecordNotFound'); |
|
83 | + $rep->errorMessage = $langs->transnoentitiesnoconv('ErrorRecordNotFound'); |
|
84 | 84 | $rep->response_status = 'error'; |
85 | 85 | } else { |
86 | 86 | $userauthor = new User($db); |
87 | 87 | if ($userauthor->fetch($expense->fk_user_author) <= 0) { |
88 | - $rep->errorMessage = $langs->transnoentitiesnoconv('ErrorRecordNotFound'); |
|
88 | + $rep->errorMessage = $langs->transnoentitiesnoconv('ErrorRecordNotFound'); |
|
89 | 89 | $rep->response_status = 'error'; |
90 | 90 | } else { |
91 | 91 | $expense = new ExpenseReport($db); |