@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | $also_cancel_consumed_and_produced_lines = (GETPOST('alsoCancelConsumedAndProducedLines', 'alpha') ? 1 : 0); |
137 | 137 | $result = $object->cancel($user, 0, $also_cancel_consumed_and_produced_lines); |
138 | 138 | if ($result > 0) { |
139 | - header("Location: " . DOL_URL_ROOT.'/mrp/mo_card.php?id=' . $object->id); |
|
139 | + header("Location: ".DOL_URL_ROOT.'/mrp/mo_card.php?id='.$object->id); |
|
140 | 140 | exit; |
141 | 141 | } else { |
142 | 142 | $action = ''; |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | $also_cancel_consumed_and_produced_lines = (GETPOST('alsoCancelConsumedAndProducedLines', 'alpha') ? 1 : 0); |
147 | 147 | $result = $object->delete($user, 0, $also_cancel_consumed_and_produced_lines); |
148 | 148 | if ($result > 0) { |
149 | - header("Location: " . $backurlforlist); |
|
149 | + header("Location: ".$backurlforlist); |
|
150 | 150 | exit; |
151 | 151 | } else { |
152 | 152 | $action = ''; |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | 'value' => !getDolGlobalString('MO_ALSO_CANCEL_CONSUMED_AND_PRODUCED_LINES_BY_DEFAULT') ? 0 : 1 |
607 | 607 | ), |
608 | 608 | ); |
609 | - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('CancelMo'), $langs->trans('ConfirmCancelMo'), 'confirm_cancel', $formquestion, 0, 1); |
|
609 | + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('CancelMo'), $langs->trans('ConfirmCancelMo'), 'confirm_cancel', $formquestion, 0, 1); |
|
610 | 610 | } |
611 | 611 | |
612 | 612 | // Call Hook formConfirm |
@@ -926,9 +926,9 @@ discard block |
||
926 | 926 | print '<td></td>'; |
927 | 927 | } |
928 | 928 | |
929 | - $colspan="3"; |
|
929 | + $colspan = "3"; |
|
930 | 930 | if (isModEnabled('stock')) { |
931 | - $colspan++;; |
|
931 | + $colspan++; ; |
|
932 | 932 | } |
933 | 933 | if (isModEnabled('productbatch')) { |
934 | 934 | $colspan++; |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | |
965 | 965 | // Lines to consume |
966 | 966 | |
967 | - $bomcostupdated = 0; // We will recalculate the unitary cost to produce a product using the real "products to consume into MO" |
|
967 | + $bomcostupdated = 0; // We will recalculate the unitary cost to produce a product using the real "products to consume into MO" |
|
968 | 968 | |
969 | 969 | if (!empty($object->lines)) { |
970 | 970 | $nblinetoconsume = 0; |
@@ -1011,15 +1011,15 @@ discard block |
||
1011 | 1011 | } |
1012 | 1012 | |
1013 | 1013 | if ($qtyhourservice && $qtyhourforline) { |
1014 | - $linecost = price2num(($qtyhourforline / $qtyhourservice * $costprice) / $object->qty, 'MT'); // price for line for all quantities |
|
1015 | - $bomcostupdated += price2num(($qtyhourforline / $qtyhourservice * $costprice) / $object->qty, 'MU'); // same but with full accuracy |
|
1014 | + $linecost = price2num(($qtyhourforline / $qtyhourservice * $costprice) / $object->qty, 'MT'); // price for line for all quantities |
|
1015 | + $bomcostupdated += price2num(($qtyhourforline / $qtyhourservice * $costprice) / $object->qty, 'MU'); // same but with full accuracy |
|
1016 | 1016 | } else { |
1017 | - $linecost = price2num(($line->qty * $costprice) / $object->qty, 'MT'); // price for line for all quantities |
|
1018 | - $bomcostupdated += price2num(($line->qty * $costprice) / $object->qty, 'MU'); // same but with full accuracy |
|
1017 | + $linecost = price2num(($line->qty * $costprice) / $object->qty, 'MT'); // price for line for all quantities |
|
1018 | + $bomcostupdated += price2num(($line->qty * $costprice) / $object->qty, 'MU'); // same but with full accuracy |
|
1019 | 1019 | } |
1020 | 1020 | } else { |
1021 | - $linecost = price2num(($line->qty * $costprice) / $object->qty, 'MT'); // price for line for all quantities |
|
1022 | - $bomcostupdated += price2num(($line->qty * $costprice) / $object->qty, 'MU'); // same but with full accuracy |
|
1021 | + $linecost = price2num(($line->qty * $costprice) / $object->qty, 'MT'); // price for line for all quantities |
|
1022 | + $bomcostupdated += price2num(($line->qty * $costprice) / $object->qty, 'MU'); // same but with full accuracy |
|
1023 | 1023 | } |
1024 | 1024 | } |
1025 | 1025 | |
@@ -1040,23 +1040,23 @@ discard block |
||
1040 | 1040 | $alreadyconsumed += $line2['qty']; |
1041 | 1041 | } |
1042 | 1042 | } |
1043 | - $suffix = '_' . $line->id; |
|
1044 | - print '<!-- Line to dispatch ' . $suffix . ' (line edited) -->' . "\n"; |
|
1043 | + $suffix = '_'.$line->id; |
|
1044 | + print '<!-- Line to dispatch '.$suffix.' (line edited) -->'."\n"; |
|
1045 | 1045 | // hidden fields for js function |
1046 | - print '<input id="qty_ordered' . $suffix . '" type="hidden" value="' . $line->qty . '">'; |
|
1046 | + print '<input id="qty_ordered'.$suffix.'" type="hidden" value="'.$line->qty.'">'; |
|
1047 | 1047 | // Duration - Time spent |
1048 | - print '<input id="qty_dispatched' . $suffix . '" type="hidden" value="' . $alreadyconsumed . '">'; |
|
1048 | + print '<input id="qty_dispatched'.$suffix.'" type="hidden" value="'.$alreadyconsumed.'">'; |
|
1049 | 1049 | print '<tr>'; |
1050 | - print '<input name="lineid" type="hidden" value="' . $line->id . '">'; |
|
1050 | + print '<input name="lineid" type="hidden" value="'.$line->id.'">'; |
|
1051 | 1051 | |
1052 | 1052 | // Product |
1053 | - print '<td>' . $tmpproduct->getNomUrl(1); |
|
1054 | - print '<br><div class="opacitymedium small tdoverflowmax150" title="' . dol_escape_htmltag($tmpproduct->label) . '">' . $tmpproduct->label . '</span>'; |
|
1053 | + print '<td>'.$tmpproduct->getNomUrl(1); |
|
1054 | + print '<br><div class="opacitymedium small tdoverflowmax150" title="'.dol_escape_htmltag($tmpproduct->label).'">'.$tmpproduct->label.'</span>'; |
|
1055 | 1055 | print '</td>'; |
1056 | 1056 | |
1057 | 1057 | // Qty |
1058 | 1058 | print '<td class="right nowraponall">'; |
1059 | - print '<input class="width40 right" name="qty_lineProduce" value="'. $line->qty.'">'; |
|
1059 | + print '<input class="width40 right" name="qty_lineProduce" value="'.$line->qty.'">'; |
|
1060 | 1060 | print '</td>'; |
1061 | 1061 | |
1062 | 1062 | // Unit |
@@ -1074,7 +1074,7 @@ discard block |
||
1074 | 1074 | |
1075 | 1075 | // Qty consumed |
1076 | 1076 | print '<td class="right">'; |
1077 | - print ' ' . price2num($alreadyconsumed, 'MS'); |
|
1077 | + print ' '.price2num($alreadyconsumed, 'MS'); |
|
1078 | 1078 | print '</td>'; |
1079 | 1079 | |
1080 | 1080 | // Entrepot |
@@ -1088,7 +1088,7 @@ discard block |
||
1088 | 1088 | if ($tmpproduct->stock_reel < ($line->qty - $alreadyconsumed)) { |
1089 | 1089 | print img_warning($langs->trans('StockTooLow')).' '; |
1090 | 1090 | } |
1091 | - print '<span class="left">'. $tmpproduct->stock_reel .' </span>'; |
|
1091 | + print '<span class="left">'.$tmpproduct->stock_reel.' </span>'; |
|
1092 | 1092 | } |
1093 | 1093 | print '</td>'; |
1094 | 1094 | } |
@@ -1099,8 +1099,8 @@ discard block |
||
1099 | 1099 | } |
1100 | 1100 | // Split + SplitAll + Edit line + Delete |
1101 | 1101 | print '<td colspan="'.(3 + ($object->status == Mo::STATUS_DRAFT ? 1 : 0) + ($permissiontodelete ? 1 : 0)).'">'; |
1102 | - print '<input type="submit" class="button buttongen button-add small nominwidth" name="save" value="' . $langs->trans("Save") . '">'; |
|
1103 | - print '<input type="submit" class="button buttongen button-cancel small nominwidth" name="cancel" value="' . $langs->trans("Cancel") . '">'; |
|
1102 | + print '<input type="submit" class="button buttongen button-add small nominwidth" name="save" value="'.$langs->trans("Save").'">'; |
|
1103 | + print '<input type="submit" class="button buttongen button-cancel small nominwidth" name="cancel" value="'.$langs->trans("Cancel").'">'; |
|
1104 | 1104 | print '</td>'; |
1105 | 1105 | |
1106 | 1106 | print '</tr>'; |
@@ -1117,29 +1117,29 @@ discard block |
||
1117 | 1117 | } |
1118 | 1118 | } |
1119 | 1119 | } else { |
1120 | - $suffix = '_' . $line->id; |
|
1121 | - print '<!-- Line to dispatch ' . $suffix . ' -->' . "\n"; |
|
1120 | + $suffix = '_'.$line->id; |
|
1121 | + print '<!-- Line to dispatch '.$suffix.' -->'."\n"; |
|
1122 | 1122 | // hidden fields for js function |
1123 | - print '<input id="qty_ordered' . $suffix . '" type="hidden" value="' . $line->qty . '">'; |
|
1124 | - print '<input id="qty_dispatched' . $suffix . '" type="hidden" value="' . $alreadyconsumed . '">'; |
|
1123 | + print '<input id="qty_ordered'.$suffix.'" type="hidden" value="'.$line->qty.'">'; |
|
1124 | + print '<input id="qty_dispatched'.$suffix.'" type="hidden" value="'.$alreadyconsumed.'">'; |
|
1125 | 1125 | |
1126 | - print '<tr data-line-id="' . $line->id . '">'; |
|
1126 | + print '<tr data-line-id="'.$line->id.'">'; |
|
1127 | 1127 | |
1128 | 1128 | // Product |
1129 | - print '<td>' . $tmpproduct->getNomUrl(1); |
|
1130 | - print '<br><div class="opacitymedium small tdoverflowmax150" title="' . dol_escape_htmltag($tmpproduct->label) . '">' . $tmpproduct->label . '</div>'; |
|
1129 | + print '<td>'.$tmpproduct->getNomUrl(1); |
|
1130 | + print '<br><div class="opacitymedium small tdoverflowmax150" title="'.dol_escape_htmltag($tmpproduct->label).'">'.$tmpproduct->label.'</div>'; |
|
1131 | 1131 | print '</td>'; |
1132 | 1132 | |
1133 | 1133 | // Qty |
1134 | 1134 | print '<td class="right nowraponall">'; |
1135 | 1135 | $help = ''; |
1136 | 1136 | if ($line->qty_frozen) { |
1137 | - $help = ($help ? '<br>' : '') . '<strong>' . $langs->trans("QuantityFrozen") . '</strong>: ' . yn(1) . ' (' . $langs->trans("QuantityConsumedInvariable") . ')'; |
|
1138 | - print $form->textwithpicto('', $help, -1, 'lock') . ' '; |
|
1137 | + $help = ($help ? '<br>' : '').'<strong>'.$langs->trans("QuantityFrozen").'</strong>: '.yn(1).' ('.$langs->trans("QuantityConsumedInvariable").')'; |
|
1138 | + print $form->textwithpicto('', $help, -1, 'lock').' '; |
|
1139 | 1139 | } |
1140 | 1140 | if ($line->disable_stock_change) { |
1141 | - $help = ($help ? '<br>' : '') . '<strong>' . $langs->trans("DisableStockChange") . '</strong>: ' . yn(1) . ' (' . (($tmpproduct->type == Product::TYPE_SERVICE && !getDolGlobalString('STOCK_SUPPORTS_SERVICES')) ? $langs->trans("NoStockChangeOnServices") : $langs->trans("DisableStockChangeHelp")) . ')'; |
|
1142 | - print $form->textwithpicto('', $help, -1, 'help') . ' '; |
|
1141 | + $help = ($help ? '<br>' : '').'<strong>'.$langs->trans("DisableStockChange").'</strong>: '.yn(1).' ('.(($tmpproduct->type == Product::TYPE_SERVICE && !getDolGlobalString('STOCK_SUPPORTS_SERVICES')) ? $langs->trans("NoStockChangeOnServices") : $langs->trans("DisableStockChangeHelp")).')'; |
|
1142 | + print $form->textwithpicto('', $help, -1, 'help').' '; |
|
1143 | 1143 | } |
1144 | 1144 | print price2num($line->qty, 'MS'); |
1145 | 1145 | print '</td>'; |
@@ -1164,9 +1164,9 @@ discard block |
||
1164 | 1164 | if ($alreadyconsumed) { |
1165 | 1165 | print '<script>'; |
1166 | 1166 | print 'jQuery(document).ready(function() { |
1167 | - jQuery("#expandtoproduce' . $line->id . '").click(function() { |
|
1168 | - console.log("Expand mrp_production line ' . $line->id . '"); |
|
1169 | - jQuery(".expanddetail' . $line->id . '").toggle();'; |
|
1167 | + jQuery("#expandtoproduce' . $line->id.'").click(function() { |
|
1168 | + console.log("Expand mrp_production line ' . $line->id.'"); |
|
1169 | + jQuery(".expanddetail' . $line->id.'").toggle();'; |
|
1170 | 1170 | if ($nblinetoconsume == $nblinetoconsumecursor) { // If it is the last line |
1171 | 1171 | print 'if (jQuery("#tablelines").hasClass("nobottom")) { jQuery("#tablelines").removeClass("nobottom"); } else { jQuery("#tablelines").addClass("nobottom"); }'; |
1172 | 1172 | } |
@@ -1175,9 +1175,9 @@ discard block |
||
1175 | 1175 | });'; |
1176 | 1176 | print '</script>'; |
1177 | 1177 | if (empty($conf->use_javascript_ajax)) { |
1178 | - print '<a href="' . $_SERVER["PHP_SELF"] . '?collapse=' . $collapse . ',' . $line->id . '">'; |
|
1178 | + print '<a href="'.$_SERVER["PHP_SELF"].'?collapse='.$collapse.','.$line->id.'">'; |
|
1179 | 1179 | } |
1180 | - print img_picto($langs->trans("ShowDetails"), "chevron-down", 'id="expandtoproduce' . $line->id . '"'); |
|
1180 | + print img_picto($langs->trans("ShowDetails"), "chevron-down", 'id="expandtoproduce'.$line->id.'"'); |
|
1181 | 1181 | if (empty($conf->use_javascript_ajax)) { |
1182 | 1182 | print '</a>'; |
1183 | 1183 | } |
@@ -1186,13 +1186,13 @@ discard block |
||
1186 | 1186 | print '<script>jQuery("#tablelines").removeClass("nobottom");</script>'; |
1187 | 1187 | } |
1188 | 1188 | } |
1189 | - print ' ' . price2num($alreadyconsumed, 'MS'); |
|
1189 | + print ' '.price2num($alreadyconsumed, 'MS'); |
|
1190 | 1190 | print '</td>'; |
1191 | 1191 | |
1192 | 1192 | // Warehouse and/or workstation |
1193 | 1193 | print '<td>'; |
1194 | 1194 | if (getDolGlobalString('STOCK_CONSUMPTION_FROM_MANUFACTURING_WAREHOUSE') && $tmpwarehouse->id > 0) { |
1195 | - print img_picto('', $tmpwarehouse->picto) . " " . $tmpwarehouse->label; |
|
1195 | + print img_picto('', $tmpwarehouse->picto)." ".$tmpwarehouse->label; |
|
1196 | 1196 | } |
1197 | 1197 | if (isModEnabled('workstation') && $line->fk_default_workstation > 0) { |
1198 | 1198 | $tmpworkstation = new Workstation($db); |
@@ -1206,7 +1206,7 @@ discard block |
||
1206 | 1206 | print '<td class="nowraponall right">'; |
1207 | 1207 | if (!getDolGlobalString('STOCK_SUPPORTS_SERVICES') && $tmpproduct->type != Product::TYPE_SERVICE) { |
1208 | 1208 | if (!$line->disable_stock_change && $tmpproduct->stock_reel < ($line->qty - $alreadyconsumed)) { |
1209 | - print img_warning($langs->trans('StockTooLow')) . ' '; |
|
1209 | + print img_warning($langs->trans('StockTooLow')).' '; |
|
1210 | 1210 | } |
1211 | 1211 | if (!getDolGlobalString('STOCK_CONSUMPTION_FROM_MANUFACTURING_WAREHOUSE') || empty($tmpwarehouse->id)) { |
1212 | 1212 | print price2num($tmpproduct->stock_reel, 'MS'); // Available |
@@ -1237,9 +1237,9 @@ discard block |
||
1237 | 1237 | |
1238 | 1238 | // Action Edit line |
1239 | 1239 | if ($object->status == Mo::STATUS_DRAFT) { |
1240 | - $href = $_SERVER["PHP_SELF"] . '?id=' . ((int) $object->id) . '&action=editline&token=' . newToken() . '&lineid=' . ((int) $line->id); |
|
1240 | + $href = $_SERVER["PHP_SELF"].'?id='.((int) $object->id).'&action=editline&token='.newToken().'&lineid='.((int) $line->id); |
|
1241 | 1241 | print '<td class="center">'; |
1242 | - print '<a class="reposition editfielda" href="' . $href . '">'; |
|
1242 | + print '<a class="reposition editfielda" href="'.$href.'">'; |
|
1243 | 1243 | print img_picto($langs->trans('TooltipEditAndRevertStockMovement'), 'edit'); |
1244 | 1244 | print '</a>'; |
1245 | 1245 | print '</td>'; |
@@ -1247,9 +1247,9 @@ discard block |
||
1247 | 1247 | |
1248 | 1248 | // Action delete line |
1249 | 1249 | if ($permissiontodelete) { |
1250 | - $href = $_SERVER["PHP_SELF"] . '?id=' . ((int) $object->id) . '&action=deleteline&token=' . newToken() . '&lineid=' . ((int) $line->id); |
|
1250 | + $href = $_SERVER["PHP_SELF"].'?id='.((int) $object->id).'&action=deleteline&token='.newToken().'&lineid='.((int) $line->id); |
|
1251 | 1251 | print '<td class="center">'; |
1252 | - print '<a class="reposition" href="' . $href . '">'; |
|
1252 | + print '<a class="reposition" href="'.$href.'">'; |
|
1253 | 1253 | print img_picto($langs->trans('TooltipDeleteAndRevertStockMovement'), 'delete'); |
1254 | 1254 | print '</a>'; |
1255 | 1255 | print '</td>'; |
@@ -1328,9 +1328,9 @@ discard block |
||
1328 | 1328 | |
1329 | 1329 | // Action Edit line |
1330 | 1330 | if ($object->status == Mo::STATUS_DRAFT) { |
1331 | - $href = $_SERVER["PHP_SELF"] . '?id=' . ((int) $object->id) . '&action=editline&token=' . newToken() . '&lineid=' . ((int) $line2['rowid']); |
|
1331 | + $href = $_SERVER["PHP_SELF"].'?id='.((int) $object->id).'&action=editline&token='.newToken().'&lineid='.((int) $line2['rowid']); |
|
1332 | 1332 | print '<td class="center">'; |
1333 | - print '<a class="reposition" href="' . $href . '">'; |
|
1333 | + print '<a class="reposition" href="'.$href.'">'; |
|
1334 | 1334 | print img_picto($langs->trans('TooltipEditAndRevertStockMovement'), 'edit'); |
1335 | 1335 | print '</a>'; |
1336 | 1336 | print '</td>'; |
@@ -1370,7 +1370,7 @@ discard block |
||
1370 | 1370 | print '<input type="hidden" name="product-'.$line->id.'-'.$i.'" value="'.$line->fk_product.'">'; |
1371 | 1371 | |
1372 | 1372 | // Qty |
1373 | - print '<td class="right"><input type="text" class="width50 right" id="qtytoconsume-' . $line->id . '-' . $i . '" name="qty-' . $line->id . '-' . $i . '" value="' . $preselected . '" ' . $disable . '></td>'; |
|
1373 | + print '<td class="right"><input type="text" class="width50 right" id="qtytoconsume-'.$line->id.'-'.$i.'" name="qty-'.$line->id.'-'.$i.'" value="'.$preselected.'" '.$disable.'></td>'; |
|
1374 | 1374 | |
1375 | 1375 | // Unit |
1376 | 1376 | print '<td></td>'; |
@@ -1882,7 +1882,7 @@ discard block |
||
1882 | 1882 | |
1883 | 1883 | $.ajax({ |
1884 | 1884 | type: "POST", |
1885 | - url: "<?php echo DOL_URL_ROOT . '/mrp/ajax/interface.php'; ?>", |
|
1885 | + url: "<?php echo DOL_URL_ROOT.'/mrp/ajax/interface.php'; ?>", |
|
1886 | 1886 | data: { |
1887 | 1887 | action: "updateselectbatchbywarehouse", |
1888 | 1888 | permissiontoproduce: <?php echo $permissiontoproduce ?>, |
@@ -1943,7 +1943,7 @@ discard block |
||
1943 | 1943 | |
1944 | 1944 | $.ajax({ |
1945 | 1945 | type: "POST", |
1946 | - url: "<?php echo DOL_URL_ROOT . '/mrp/ajax/interface.php'; ?>", |
|
1946 | + url: "<?php echo DOL_URL_ROOT.'/mrp/ajax/interface.php'; ?>", |
|
1947 | 1947 | data: { |
1948 | 1948 | action: "updateselectwarehousebybatch", |
1949 | 1949 | permissiontoproduce: <?php echo $permissiontoproduce ?>, |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | $langs->loadLangs(array("mrp", "other")); |
41 | 41 | |
42 | 42 | // Get parameters |
43 | -$id = GETPOSTINT('id'); |
|
43 | +$id = GETPOSTINT('id'); |
|
44 | 44 | $ref = GETPOST('ref', 'alpha'); |
45 | -$action = GETPOST('action', 'aZ09'); |
|
45 | +$action = GETPOST('action', 'aZ09'); |
|
46 | 46 | $cancel = GETPOST('cancel', 'aZ09'); |
47 | 47 | $backtopage = GETPOST('backtopage', 'alpha'); |
48 | 48 | $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'moagenda'; // To manage different context of search |
@@ -58,10 +58,10 @@ discard block |
||
58 | 58 | $search_rowid = GETPOST('search_rowid'); |
59 | 59 | $search_agenda_label = GETPOST('search_agenda_label'); |
60 | 60 | |
61 | -$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; |
|
61 | +$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; |
|
62 | 62 | $sortfield = GETPOST('sortfield', 'aZ09comma'); |
63 | 63 | $sortorder = GETPOST('sortorder', 'aZ09comma'); |
64 | -$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page"); |
|
64 | +$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page"); |
|
65 | 65 | if (empty($page) || $page == -1) { |
66 | 66 | $page = 0; |
67 | 67 | } // If $page is not defined, or '' or -1 |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public $picto = 'asset'; |
53 | 53 | |
54 | - const STATUS_DRAFT = 0; // In progress |
|
55 | - const STATUS_DISPOSED = 9; // Disposed |
|
54 | + const STATUS_DRAFT = 0; // In progress |
|
55 | + const STATUS_DISPOSED = 9; // Disposed |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * 'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]', 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter[:Sortfield]]]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') |
@@ -607,11 +607,11 @@ discard block |
||
607 | 607 | // Check parameters |
608 | 608 | $error = 0; |
609 | 609 | if (empty($this->id)) { |
610 | - $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Asset") . ' (' . $langs->transnoentitiesnoconv("TechnicalID") . ')'); |
|
610 | + $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Asset").' ('.$langs->transnoentitiesnoconv("TechnicalID").')'); |
|
611 | 611 | $error++; |
612 | 612 | } |
613 | 613 | if (empty($this->fk_asset_model)) { |
614 | - $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AssetModel") . ' (' . $langs->transnoentitiesnoconv("TechnicalID") . ')'); |
|
614 | + $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AssetModel").' ('.$langs->transnoentitiesnoconv("TechnicalID").')'); |
|
615 | 615 | $error++; |
616 | 616 | } |
617 | 617 | if ($error) { |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | |
623 | 623 | // Get depreciation options |
624 | 624 | //--------------------------- |
625 | - require_once DOL_DOCUMENT_ROOT . '/asset/class/assetdepreciationoptions.class.php'; |
|
625 | + require_once DOL_DOCUMENT_ROOT.'/asset/class/assetdepreciationoptions.class.php'; |
|
626 | 626 | $options_model = new AssetDepreciationOptions($this->db); |
627 | 627 | $result = $options_model->fetchDeprecationOptions(0, $this->fk_asset_model); |
628 | 628 | if ($result < 0) { |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | // Get accountancy codes |
658 | 658 | //--------------------------- |
659 | 659 | if (!$error) { |
660 | - require_once DOL_DOCUMENT_ROOT . '/asset/class/assetaccountancycodes.class.php'; |
|
660 | + require_once DOL_DOCUMENT_ROOT.'/asset/class/assetaccountancycodes.class.php'; |
|
661 | 661 | $accountancy_codes_model = new AssetAccountancyCodes($this->db); |
662 | 662 | $result = $accountancy_codes_model->fetchAccountancyCodes(0, $this->fk_asset_model); |
663 | 663 | if ($result < 0) { |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | // Check parameters |
717 | 717 | $error = 0; |
718 | 718 | if (empty($this->id)) { |
719 | - $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Asset") . ' (' . $langs->transnoentitiesnoconv("TechnicalID") . ')'); |
|
719 | + $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Asset").' ('.$langs->transnoentitiesnoconv("TechnicalID").')'); |
|
720 | 720 | $error++; |
721 | 721 | } |
722 | 722 | if ($error) { |
@@ -739,15 +739,15 @@ discard block |
||
739 | 739 | */ |
740 | 740 | |
741 | 741 | $sql = "SELECT ad.rowid, ad.depreciation_mode, ad.ref, ad.depreciation_date, ad.depreciation_ht, ad.cumulative_depreciation_ht"; |
742 | - $sql .= ", " . $this->db->ifsql('iab.fk_docdet IS NOT NULL', 1, 0) . " AS bookkeeping"; |
|
743 | - $sql .= " FROM " . MAIN_DB_PREFIX . "asset_depreciation AS ad"; |
|
744 | - $sql .= " LEFT JOIN (SELECT DISTINCT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE doc_type = 'asset') AS iab ON iab.fk_docdet = ad.rowid"; |
|
745 | - $sql .= " WHERE ad.fk_asset = " . (int) $this->id; |
|
742 | + $sql .= ", ".$this->db->ifsql('iab.fk_docdet IS NOT NULL', 1, 0)." AS bookkeeping"; |
|
743 | + $sql .= " FROM ".MAIN_DB_PREFIX."asset_depreciation AS ad"; |
|
744 | + $sql .= " LEFT JOIN (SELECT DISTINCT fk_docdet FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE doc_type = 'asset') AS iab ON iab.fk_docdet = ad.rowid"; |
|
745 | + $sql .= " WHERE ad.fk_asset = ".(int) $this->id; |
|
746 | 746 | $sql .= " ORDER BY ad.depreciation_date ASC"; |
747 | 747 | |
748 | 748 | $resql = $this->db->query($sql); |
749 | 749 | if (!$resql) { |
750 | - $this->errors[] = $langs->trans('AssetErrorFetchDepreciationLines') . ': ' . $this->db->lasterror(); |
|
750 | + $this->errors[] = $langs->trans('AssetErrorFetchDepreciationLines').': '.$this->db->lasterror(); |
|
751 | 751 | return -1; |
752 | 752 | } |
753 | 753 | |
@@ -784,7 +784,7 @@ discard block |
||
784 | 784 | // Check parameters |
785 | 785 | $error = 0; |
786 | 786 | if (empty($this->id)) { |
787 | - $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Asset") . ' (' . $langs->transnoentitiesnoconv("TechnicalID") . ')'); |
|
787 | + $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Asset").' ('.$langs->transnoentitiesnoconv("TechnicalID").')'); |
|
788 | 788 | $error++; |
789 | 789 | } |
790 | 790 | if ($error) { |
@@ -806,14 +806,14 @@ discard block |
||
806 | 806 | */ |
807 | 807 | |
808 | 808 | $sql = "SELECT COUNT(*) AS has_bookkeeping"; |
809 | - $sql .= " FROM " . MAIN_DB_PREFIX . "asset_depreciation AS ad"; |
|
810 | - $sql .= " LEFT JOIN (SELECT DISTINCT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE doc_type = 'asset') AS iab ON iab.fk_docdet = ad.rowid"; |
|
811 | - $sql .= " WHERE ad.fk_asset = " . (int) $this->id; |
|
809 | + $sql .= " FROM ".MAIN_DB_PREFIX."asset_depreciation AS ad"; |
|
810 | + $sql .= " LEFT JOIN (SELECT DISTINCT fk_docdet FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE doc_type = 'asset') AS iab ON iab.fk_docdet = ad.rowid"; |
|
811 | + $sql .= " WHERE ad.fk_asset = ".(int) $this->id; |
|
812 | 812 | $sql .= " AND iab.fk_docdet IS NOT NULL"; |
813 | 813 | |
814 | 814 | $resql = $this->db->query($sql); |
815 | 815 | if (!$resql) { |
816 | - $this->errors[] = $langs->trans('AssetErrorFetchDepreciationLines') . ': ' . $this->db->lasterror(); |
|
816 | + $this->errors[] = $langs->trans('AssetErrorFetchDepreciationLines').': '.$this->db->lasterror(); |
|
817 | 817 | return -1; |
818 | 818 | } |
819 | 819 | |
@@ -851,28 +851,28 @@ discard block |
||
851 | 851 | // Check parameters |
852 | 852 | $error = 0; |
853 | 853 | if (empty($this->id)) { |
854 | - $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Asset") . ' (' . $langs->transnoentitiesnoconv("TechnicalID") . ')'); |
|
854 | + $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Asset").' ('.$langs->transnoentitiesnoconv("TechnicalID").')'); |
|
855 | 855 | $error++; |
856 | 856 | } |
857 | 857 | if ($error) { |
858 | 858 | return -1; |
859 | 859 | } |
860 | 860 | |
861 | - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "asset_depreciation(fk_asset, depreciation_mode, ref, depreciation_date, depreciation_ht, cumulative_depreciation_ht, accountancy_code_debit, accountancy_code_credit)"; |
|
861 | + $sql = "INSERT INTO ".MAIN_DB_PREFIX."asset_depreciation(fk_asset, depreciation_mode, ref, depreciation_date, depreciation_ht, cumulative_depreciation_ht, accountancy_code_debit, accountancy_code_credit)"; |
|
862 | 862 | $sql .= " VALUES ( "; |
863 | - $sql .= " " . (int) $this->id; |
|
864 | - $sql .= ", '" . $this->db->escape($mode) . "'"; |
|
865 | - $sql .= ", '" . $this->db->escape($ref) . "'"; |
|
866 | - $sql .= ", '" . $this->db->idate($depreciation_date) . "'"; |
|
867 | - $sql .= ", " . (float) $depreciation_ht; |
|
868 | - $sql .= ", " . (float) $cumulative_depreciation_ht; |
|
869 | - $sql .= ", '" . $this->db->escape($accountancy_code_debit) . "'"; |
|
870 | - $sql .= ", '" . $this->db->escape($accountancy_code_credit) . "'"; |
|
863 | + $sql .= " ".(int) $this->id; |
|
864 | + $sql .= ", '".$this->db->escape($mode)."'"; |
|
865 | + $sql .= ", '".$this->db->escape($ref)."'"; |
|
866 | + $sql .= ", '".$this->db->idate($depreciation_date)."'"; |
|
867 | + $sql .= ", ".(float) $depreciation_ht; |
|
868 | + $sql .= ", ".(float) $cumulative_depreciation_ht; |
|
869 | + $sql .= ", '".$this->db->escape($accountancy_code_debit)."'"; |
|
870 | + $sql .= ", '".$this->db->escape($accountancy_code_credit)."'"; |
|
871 | 871 | $sql .= ")"; |
872 | 872 | |
873 | 873 | $resql = $this->db->query($sql); |
874 | 874 | if (!$resql) { |
875 | - $this->errors[] = $langs->trans('AssetErrorAddDepreciationLine') . ': ' . $this->db->lasterror(); |
|
875 | + $this->errors[] = $langs->trans('AssetErrorAddDepreciationLine').': '.$this->db->lasterror(); |
|
876 | 876 | return -1; |
877 | 877 | } |
878 | 878 | |
@@ -895,7 +895,7 @@ discard block |
||
895 | 895 | // Check parameters |
896 | 896 | $error = 0; |
897 | 897 | if (empty($this->id)) { |
898 | - $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Asset") . ' (' . $langs->transnoentitiesnoconv("TechnicalID") . ')'); |
|
898 | + $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Asset").' ('.$langs->transnoentitiesnoconv("TechnicalID").')'); |
|
899 | 899 | $error++; |
900 | 900 | } |
901 | 901 | if ($error) { |
@@ -904,7 +904,7 @@ discard block |
||
904 | 904 | |
905 | 905 | // Get depreciation options |
906 | 906 | //--------------------------- |
907 | - require_once DOL_DOCUMENT_ROOT . '/asset/class/assetdepreciationoptions.class.php'; |
|
907 | + require_once DOL_DOCUMENT_ROOT.'/asset/class/assetdepreciationoptions.class.php'; |
|
908 | 908 | $options = new AssetDepreciationOptions($this->db); |
909 | 909 | $result = $options->fetchDeprecationOptions($this->id); |
910 | 910 | if ($result < 0) { |
@@ -915,7 +915,7 @@ discard block |
||
915 | 915 | |
916 | 916 | // Get accountancy codes |
917 | 917 | //--------------------------- |
918 | - require_once DOL_DOCUMENT_ROOT . '/asset/class/assetaccountancycodes.class.php'; |
|
918 | + require_once DOL_DOCUMENT_ROOT.'/asset/class/assetaccountancycodes.class.php'; |
|
919 | 919 | $accountancy_codes = new AssetAccountancyCodes($this->db); |
920 | 920 | $result = $accountancy_codes->fetchAccountancyCodes($this->id); |
921 | 921 | if ($result < 0) { |
@@ -931,20 +931,20 @@ discard block |
||
931 | 931 | foreach ($options->deprecation_options as $mode_key => $fields) { |
932 | 932 | $modes[$mode_key] = $this->db->escape($mode_key); |
933 | 933 | } |
934 | - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "asset_depreciation"; |
|
935 | - $sql .= " WHERE fk_asset = " . (int) $this->id; |
|
936 | - $sql .= " AND depreciation_mode NOT IN ('" . $this->db->sanitize(implode("', '", $modes)) . "')"; |
|
934 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX."asset_depreciation"; |
|
935 | + $sql .= " WHERE fk_asset = ".(int) $this->id; |
|
936 | + $sql .= " AND depreciation_mode NOT IN ('".$this->db->sanitize(implode("', '", $modes))."')"; |
|
937 | 937 | |
938 | 938 | $resql = $this->db->query($sql); |
939 | 939 | if (!$resql) { |
940 | - $this->errors[] = $langs->trans('AssetErrorClearDepreciationLines') . ': ' . $this->db->lasterror(); |
|
940 | + $this->errors[] = $langs->trans('AssetErrorClearDepreciationLines').': '.$this->db->lasterror(); |
|
941 | 941 | $error++; |
942 | 942 | } |
943 | 943 | |
944 | 944 | if (!$error) { |
945 | 945 | // Get fiscal period |
946 | - require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; |
|
947 | - require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; |
|
946 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; |
|
947 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; |
|
948 | 948 | // @FIXME getCurrentPeriodOfFiscalYear return the first period found. What if there is several ? And what if not closed ? And what if end date not yet defined. |
949 | 949 | $dates = getCurrentPeriodOfFiscalYear($this->db, $conf, $this->date_start > $this->date_acquisition ? $this->date_start : $this->date_acquisition); |
950 | 950 | $init_fiscal_period_start = $dates['date_start']; |
@@ -978,17 +978,17 @@ discard block |
||
978 | 978 | */ |
979 | 979 | |
980 | 980 | $sql = "SELECT ad.depreciation_date, ad.cumulative_depreciation_ht"; |
981 | - $sql .= " FROM " . MAIN_DB_PREFIX . "asset_depreciation AS ad"; |
|
982 | - $sql .= " LEFT JOIN (SELECT DISTINCT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE doc_type = 'asset') AS iab ON iab.fk_docdet = ad.rowid"; |
|
983 | - $sql .= " WHERE ad.fk_asset = " . (int) $this->id; |
|
984 | - $sql .= " AND ad.depreciation_mode = '" . $this->db->escape($mode_key) . "'"; |
|
981 | + $sql .= " FROM ".MAIN_DB_PREFIX."asset_depreciation AS ad"; |
|
982 | + $sql .= " LEFT JOIN (SELECT DISTINCT fk_docdet FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE doc_type = 'asset') AS iab ON iab.fk_docdet = ad.rowid"; |
|
983 | + $sql .= " WHERE ad.fk_asset = ".(int) $this->id; |
|
984 | + $sql .= " AND ad.depreciation_mode = '".$this->db->escape($mode_key)."'"; |
|
985 | 985 | $sql .= " AND iab.fk_docdet IS NOT NULL"; |
986 | 986 | $sql .= " ORDER BY ad.depreciation_date DESC"; |
987 | 987 | $sql .= " LIMIT 1"; |
988 | 988 | |
989 | 989 | $resql = $this->db->query($sql); |
990 | 990 | if (!$resql) { |
991 | - $this->errors[] = $langs->trans('AssetErrorFetchMaxDepreciationDateForMode', $mode_key) . ': ' . $this->db->lasterror(); |
|
991 | + $this->errors[] = $langs->trans('AssetErrorFetchMaxDepreciationDateForMode', $mode_key).': '.$this->db->lasterror(); |
|
992 | 992 | $error++; |
993 | 993 | break; |
994 | 994 | } |
@@ -1000,28 +1000,28 @@ discard block |
||
1000 | 1000 | } |
1001 | 1001 | |
1002 | 1002 | // Set last cumulative depreciation |
1003 | - $sql = "UPDATE " . MAIN_DB_PREFIX . $options->deprecation_options_fields[$mode_key]['table']; |
|
1004 | - $sql .= " SET total_amount_last_depreciation_ht = " . (empty($last_cumulative_depreciation_ht) ? 0 : $last_cumulative_depreciation_ht); |
|
1005 | - $sql .= " WHERE fk_asset = " . (int) $this->id; |
|
1003 | + $sql = "UPDATE ".MAIN_DB_PREFIX.$options->deprecation_options_fields[$mode_key]['table']; |
|
1004 | + $sql .= " SET total_amount_last_depreciation_ht = ".(empty($last_cumulative_depreciation_ht) ? 0 : $last_cumulative_depreciation_ht); |
|
1005 | + $sql .= " WHERE fk_asset = ".(int) $this->id; |
|
1006 | 1006 | $resql = $this->db->query($sql); |
1007 | 1007 | if (!$resql) { |
1008 | - $this->errors[] = $langs->trans('AssetErrorSetLastCumulativeDepreciation') . ': ' . $this->db->lasterror(); |
|
1008 | + $this->errors[] = $langs->trans('AssetErrorSetLastCumulativeDepreciation').': '.$this->db->lasterror(); |
|
1009 | 1009 | $error++; |
1010 | 1010 | break; |
1011 | 1011 | } |
1012 | 1012 | |
1013 | 1013 | // Delete old lines |
1014 | - $sql = "DELETE " . MAIN_DB_PREFIX . "asset_depreciation FROM " . MAIN_DB_PREFIX . "asset_depreciation"; |
|
1015 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab ON ab.doc_type = 'asset' AND ab.fk_docdet = " . MAIN_DB_PREFIX . "asset_depreciation.rowid"; |
|
1016 | - $sql .= " WHERE " . MAIN_DB_PREFIX . "asset_depreciation.fk_asset = " . (int) $this->id; |
|
1017 | - $sql .= " AND " . MAIN_DB_PREFIX . "asset_depreciation.depreciation_mode = '" . $this->db->escape($mode_key) . "'"; |
|
1014 | + $sql = "DELETE ".MAIN_DB_PREFIX."asset_depreciation FROM ".MAIN_DB_PREFIX."asset_depreciation"; |
|
1015 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_bookkeeping as ab ON ab.doc_type = 'asset' AND ab.fk_docdet = ".MAIN_DB_PREFIX."asset_depreciation.rowid"; |
|
1016 | + $sql .= " WHERE ".MAIN_DB_PREFIX."asset_depreciation.fk_asset = ".(int) $this->id; |
|
1017 | + $sql .= " AND ".MAIN_DB_PREFIX."asset_depreciation.depreciation_mode = '".$this->db->escape($mode_key)."'"; |
|
1018 | 1018 | $sql .= " AND ab.fk_docdet IS NULL"; |
1019 | 1019 | if ($last_depreciation_date !== "") { |
1020 | - $sql .= " AND " . MAIN_DB_PREFIX . "asset_depreciation.ref != ''"; |
|
1020 | + $sql .= " AND ".MAIN_DB_PREFIX."asset_depreciation.ref != ''"; |
|
1021 | 1021 | } |
1022 | 1022 | $resql = $this->db->query($sql); |
1023 | 1023 | if (!$resql) { |
1024 | - $this->errors[] = $langs->trans('AssetErrorClearDepreciationLines') . ': ' . $this->db->lasterror(); |
|
1024 | + $this->errors[] = $langs->trans('AssetErrorClearDepreciationLines').': '.$this->db->lasterror(); |
|
1025 | 1025 | $error++; |
1026 | 1026 | break; |
1027 | 1027 | } |
@@ -1089,7 +1089,7 @@ discard block |
||
1089 | 1089 | // TODO fix declaration of $begin_period |
1090 | 1090 | $first_period_date = isset($begin_period) && $begin_period > $fiscal_period_start ? $begin_period : $fiscal_period_start; |
1091 | 1091 | |
1092 | - $ref_date_format = "%Y" . ($fields['duration_type'] == 1 || $fields['duration_type'] == 2 ? '-%m' : '') . ($fields['duration_type'] == 2 ? '-%d' : ''); |
|
1092 | + $ref_date_format = "%Y".($fields['duration_type'] == 1 || $fields['duration_type'] == 2 ? '-%m' : '').($fields['duration_type'] == 2 ? '-%d' : ''); |
|
1093 | 1093 | |
1094 | 1094 | // Loop security |
1095 | 1095 | $idx_loop = 0; |
@@ -1111,9 +1111,9 @@ discard block |
||
1111 | 1111 | |
1112 | 1112 | $period_begin = dol_print_date($fiscal_period_start, $ref_date_format); |
1113 | 1113 | $period_end = dol_print_date($fiscal_period_end, $ref_date_format); |
1114 | - $ref = $period_begin . ($period_begin != $period_end ? ' - ' . $period_end : ''); |
|
1114 | + $ref = $period_begin.($period_begin != $period_end ? ' - '.$period_end : ''); |
|
1115 | 1115 | if ($fiscal_period_start <= $disposal_date && $disposal_date <= $fiscal_period_end) { |
1116 | - $ref .= ' - ' . $langs->transnoentitiesnoconv('AssetDisposal'); |
|
1116 | + $ref .= ' - '.$langs->transnoentitiesnoconv('AssetDisposal'); |
|
1117 | 1117 | } |
1118 | 1118 | |
1119 | 1119 | $begin_date = $fiscal_period_start < $start_date && $start_date <= $fiscal_period_end ? $start_date : $fiscal_period_start; |
@@ -1192,7 +1192,7 @@ discard block |
||
1192 | 1192 | // Check parameters |
1193 | 1193 | $error = 0; |
1194 | 1194 | if (empty($asset_depreciation_id)) { |
1195 | - $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AssetDepreciation") . ' (' . $langs->transnoentitiesnoconv("TechnicalID") . ')'); |
|
1195 | + $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AssetDepreciation").' ('.$langs->transnoentitiesnoconv("TechnicalID").')'); |
|
1196 | 1196 | $error++; |
1197 | 1197 | } |
1198 | 1198 | if ($error) { |
@@ -1201,28 +1201,28 @@ discard block |
||
1201 | 1201 | |
1202 | 1202 | $this->db->begin(); |
1203 | 1203 | |
1204 | - require_once DOL_DOCUMENT_ROOT . '/asset/class/assetdepreciationoptions.class.php'; |
|
1204 | + require_once DOL_DOCUMENT_ROOT.'/asset/class/assetdepreciationoptions.class.php'; |
|
1205 | 1205 | $options = new AssetDepreciationOptions($this->db); |
1206 | 1206 | |
1207 | 1207 | // Get last depreciation lines save in bookkeeping |
1208 | 1208 | //----------------------------------------------------- |
1209 | 1209 | $sql = "SELECT fk_asset, depreciation_mode, cumulative_depreciation_ht"; |
1210 | - $sql .= " FROM " . MAIN_DB_PREFIX . "asset_depreciation"; |
|
1211 | - $sql .= " WHERE rowid = " . (int) $asset_depreciation_id; |
|
1210 | + $sql .= " FROM ".MAIN_DB_PREFIX."asset_depreciation"; |
|
1211 | + $sql .= " WHERE rowid = ".(int) $asset_depreciation_id; |
|
1212 | 1212 | $resql = $this->db->query($sql); |
1213 | 1213 | if (!$resql) { |
1214 | - $this->errors[] = $langs->trans('AssetErrorFetchCumulativeDepreciation') . ': ' . $this->db->lasterror(); |
|
1214 | + $this->errors[] = $langs->trans('AssetErrorFetchCumulativeDepreciation').': '.$this->db->lasterror(); |
|
1215 | 1215 | $error++; |
1216 | 1216 | } else { |
1217 | 1217 | if ($obj = $this->db->fetch_object($resql)) { |
1218 | 1218 | $mode_key = $obj->depreciation_mode; |
1219 | 1219 | if (!empty($options->deprecation_options_fields[$mode_key])) { |
1220 | - $sql = "UPDATE " . MAIN_DB_PREFIX . $options->deprecation_options_fields[$mode_key]['table']; |
|
1221 | - $sql .= " SET total_amount_last_depreciation_ht = " . $obj->cumulative_depreciation_ht; |
|
1222 | - $sql .= " WHERE fk_asset = " . (int) $obj->fk_asset; |
|
1220 | + $sql = "UPDATE ".MAIN_DB_PREFIX.$options->deprecation_options_fields[$mode_key]['table']; |
|
1221 | + $sql .= " SET total_amount_last_depreciation_ht = ".$obj->cumulative_depreciation_ht; |
|
1222 | + $sql .= " WHERE fk_asset = ".(int) $obj->fk_asset; |
|
1223 | 1223 | $resql = $this->db->query($sql); |
1224 | 1224 | if (!$resql) { |
1225 | - $this->errors[] = $langs->trans('AssetErrorSetLastCumulativeDepreciation') . ': ' . $this->db->lasterror(); |
|
1225 | + $this->errors[] = $langs->trans('AssetErrorSetLastCumulativeDepreciation').': '.$this->db->lasterror(); |
|
1226 | 1226 | $error++; |
1227 | 1227 | } |
1228 | 1228 | } |
@@ -1475,7 +1475,7 @@ discard block |
||
1475 | 1475 | if ($option == 'label') { |
1476 | 1476 | $name = $this->label; |
1477 | 1477 | } elseif ($option == 'with_label') { |
1478 | - $name .= ' - ' . $this->label; |
|
1478 | + $name .= ' - '.$this->label; |
|
1479 | 1479 | } |
1480 | 1480 | $result .= dol_escape_htmltag($maxlen ? dol_trunc($name, $maxlen) : $name); |
1481 | 1481 | } |
@@ -1484,7 +1484,7 @@ discard block |
||
1484 | 1484 | //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); |
1485 | 1485 | |
1486 | 1486 | global $action; |
1487 | - $hookmanager->initHooks(array($this->element . 'dao')); |
|
1487 | + $hookmanager->initHooks(array($this->element.'dao')); |
|
1488 | 1488 | $parameters = array('id' => $this->id, 'getnomurl' => &$result); |
1489 | 1489 | $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
1490 | 1490 | if ($reshook > 0) { |
@@ -1620,7 +1620,7 @@ discard block |
||
1620 | 1620 | if (getDolGlobalString('ASSET_ASSET_ADDON')) { |
1621 | 1621 | $mybool = false; |
1622 | 1622 | |
1623 | - $file = getDolGlobalString('ASSET_ASSET_ADDON') . ".php"; |
|
1623 | + $file = getDolGlobalString('ASSET_ASSET_ADDON').".php"; |
|
1624 | 1624 | $classname = getDolGlobalString('ASSET_ASSET_ADDON'); |
1625 | 1625 | |
1626 | 1626 | // Include file with class |