Calculate potential kits stock from components#38012
Calculate potential kits stock from components#38012edupulpillo wants to merge 18 commits intoDolibarr:developfrom
Conversation
Added calculation for potential kits stock based on component quantities and available stock displayed at the bottom of the components list
edupulpillo
left a comment
There was a problem hiding this comment.
Indentation fix
edupulpillo
left a comment
There was a problem hiding this comment.
indentation fix
edupulpillo
left a comment
There was a problem hiding this comment.
[Calculate potential kits stock from components
type mitsmatch fix
| $colspan_counter = null; | ||
| print '<tr class="total-row right">'; | ||
| print '<td></td><td></td><td></td>'; | ||
| print '<td colspan="' . ($colspan_counter + 4) . '" class="titlefield">' . $langs->trans("PotentialKitsFromStock") . '</td>'; |
There was a problem hiding this comment.
FYI: there are several methods to potentially fix the phan error
card.php: PhanTypeInvalidLeftOperandOfAdd: Invalid operator: left operand of + is null (expected array or number)
You could use The PHP ternary operator to make a 1 liner, and I would make that line just before using the variable `colspan_counter``
Something like
$colspan_counter = (is_null($colspan_counter) ? (0) : ($colspan_counter);
print '<td colspan="' . ($colspan_counter + 4) . '" class="titlefield">' . $langs->trans("PotentialKitsFromStock") . '</td>';
But it may just be much more interesting to figure out why $colspan_counter was null to begin with.
There was a problem hiding this comment.
$colspan_counter in null only about my ignorance. Should i assign a value = 0 (integer) am i right ?
So now your review is not needed anymore. Kindly accept the latest version, it pased already allt he tests of code.
There was a problem hiding this comment.
@edupulpillo I am not sure what the colspan_counter is for, but if you want to do addition, then starting with 0 is a good bet, but if you only do the addition once - why even have a variable?
There was a problem hiding this comment.
you are right, better to use a constant
So now your review is not needed anymore. Kindly accept the latest version, it pased already allt he tests of code. Please complete your review is not possible to cancel a request review accidentally requested
edupulpillo
left a comment
There was a problem hiding this comment.
potential_kit_stock = 0 instead null
Updated stock display logic to show potential kit stock directly.
Added calculation for potential kits stock based on component quantities and available stock displayed at the bottom of the components list
Fix #38010
[The stock qty of product-kits are not displayed neither in the product sheet or the kit Tab with the list of components]