qual: use getDolGlobalString() in products/card.php (#30107)

* qual: use getDolGlobalString() in products/card.php

* fix phan warning

phan / Run phan: htdocs/product/card.php#L693
card.php: PhanNonClassMethodCall: Call to method getNextValue on non-class type ?object

* phan fix

* try phan fix

* fix phan warning

Avoid function calls in a FOR loop test part
This commit is contained in:
thibdrev 2024-06-22 15:41:13 +02:00 committed by GitHub
parent 9b6586ea64
commit 4dcf9b015d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -134,7 +134,7 @@ if (!empty($user->socid)) {
}
// Load object modCodeProduct
$module = (getDolGlobalString('PRODUCT_CODEPRODUCT_ADDON') ? $conf->global->PRODUCT_CODEPRODUCT_ADDON : 'mod_codeproduct_leopard');
$module = getDolGlobalString('PRODUCT_CODEPRODUCT_ADDON', 'mod_codeproduct_leopard');
if (substr($module, 0, 16) == 'mod_codeproduct_' && substr($module, -3) == 'php') {
$module = substr($module, 0, dol_strlen($module) - 4);
}
@ -672,7 +672,8 @@ if (empty($reshook)) {
// MultiPrix
if (getDolGlobalString('PRODUIT_MULTIPRICES')) {
for ($i = 2; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
$produit_multiprices_limit = getDolGlobalString('PRODUIT_MULTIPRICES_LIMIT');
for ($i = 2; $i <= $produit_multiprices_limit; $i++) {
if (GETPOSTISSET("price_".$i)) {
$object->multiprices["$i"] = price2num(GETPOST("price_".$i), 'MU');
$object->multiprices_base_type["$i"] = GETPOST("multiprices_base_type_".$i);
@ -690,6 +691,7 @@ if (empty($reshook)) {
if (!$ref && getDolGlobalString('PRODUCT_GENERATE_REF_AFTER_FORM')) {
// Generate ref...
'@phan-var ModeleProductCode $modCodeProduct';
$ref = $modCodeProduct->getNextValue($object, $type);
}
@ -1067,7 +1069,7 @@ if (empty($reshook)) {
$price_base_type = $object->price_base_type;
// If multiprice
if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level) {
if (getDolGlobalString('PRODUIT_MULTIPRICES') && $soc->price_level) {
$pu_ht = $object->multiprices[$soc->price_level];
$pu_ttc = $object->multiprices_ttc[$soc->price_level];
$price_base_type = $object->multiprices_base_type[$soc->price_level];
@ -1279,7 +1281,7 @@ llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-product page-card');
// Load object modBarCodeProduct
$res = 0;
if (isModEnabled('barcode') && getDolGlobalString('BARCODE_PRODUCT_ADDON_NUM')) {
$module = strtolower($conf->global->BARCODE_PRODUCT_ADDON_NUM);
$module = strtolower(getDolGlobalString('BARCODE_PRODUCT_ADDON_NUM'));
$dirbarcode = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']);
foreach ($dirbarcode as $dirroot) {
$res = dol_include_once($dirroot.$module.'.php');
@ -1323,7 +1325,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
}
// Load object modCodeProduct
$module = (getDolGlobalString('PRODUCT_CODEPRODUCT_ADDON') ? $conf->global->PRODUCT_CODEPRODUCT_ADDON : 'mod_codeproduct_leopard');
$module = getDolGlobalString('PRODUCT_CODEPRODUCT_ADDON', 'mod_codeproduct_leopard');
if (substr($module, 0, 16) == 'mod_codeproduct_' && substr($module, -3) == 'php') {
$module = substr($module, 0, dol_strlen($module) - 4);
}
@ -1440,7 +1442,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
}
';
}
if (isset($conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS) && getDolGlobalString('PRODUCTBATCH_SN_ADDON') == 'mod_sn_advanced') {
if (getDolGlobalString('PRODUCTBATCH_SN_USE_PRODUCT_MASKS') && getDolGlobalString('PRODUCTBATCH_SN_ADDON') == 'mod_sn_advanced') {
print '
if (this.value == 2) {
$("#field_mask, #mask_option").toggleClass("hideobject");
@ -1581,7 +1583,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
print '<tr><td>'.$langs->trans("Weight").'</td><td>';
print img_picto('', 'fa-balance-scale', 'class="pictofixedwidth"');
print '<input name="weight" size="4" value="'.GETPOST('weight').'">';
print $formproduct->selectMeasuringUnits("weight_units", "weight", GETPOSTISSET('weight_units') ? GETPOST('weight_units', 'alpha') : (!getDolGlobalString('MAIN_WEIGHT_DEFAULT_UNIT') ? 0 : $conf->global->MAIN_WEIGHT_DEFAULT_UNIT), 0, 2);
print $formproduct->selectMeasuringUnits("weight_units", "weight", GETPOSTISSET('weight_units') ? GETPOST('weight_units', 'alpha') : (!getDolGlobalString('MAIN_WEIGHT_DEFAULT_UNIT') ? 0 : getDolGlobalString('MAIN_WEIGHT_DEFAULT_UNIT')), 0, 2);
print '</td></tr>';
}
@ -1614,7 +1616,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
// Net Measure
print '<tr><td>'.$langs->trans("NetMeasure").'</td><td>';
print '<input name="net_measure" size="4" value="'.GETPOST('net_measure').'">';
print $formproduct->selectMeasuringUnits("net_measure_units", '', GETPOSTISSET('net_measure_units') ? GETPOST('net_measure_units', 'alpha') : (!getDolGlobalString('MAIN_WEIGHT_DEFAULT_UNIT') ? 0 : $conf->global->MAIN_WEIGHT_DEFAULT_UNIT), 0, 0);
print $formproduct->selectMeasuringUnits("net_measure_units", '', GETPOSTISSET('net_measure_units') ? GETPOST('net_measure_units', 'alpha') : (!getDolGlobalString('MAIN_WEIGHT_DEFAULT_UNIT') ? 0 : getDolGlobalString('MAIN_WEIGHT_DEFAULT_UNIT')), 0, 0);
print '</td></tr>';
}
}
@ -1623,7 +1625,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
if (getDolGlobalString('PRODUCT_USE_UNITS')) {
print '<tr><td>'.$langs->trans('DefaultUnitToShow').'</td>';
print '<td>';
print $form->selectUnits(empty($line->fk_unit) ? $conf->global->PRODUCT_USE_UNITS : $line->fk_unit, 'units');
print $form->selectUnits(empty($line->fk_unit) ? getDolGlobalString('PRODUCT_USE_UNITS') : $line->fk_unit, 'units');
print '</td></tr>';
}
@ -1671,7 +1673,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
}
// Note (private, no output on invoices, propales...)
//if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) available in create mode
//if (!empty(getDolGlobalString('MAIN_DISABLE_NOTES_TAB'))) available in create mode
//{
print '<tr><td class="tdtop">'.$langs->trans("NoteNotVisibleOnBill").'</td><td>';
@ -1714,7 +1716,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
// Price
print '<tr><td class="titlefieldcreate">'.$langs->trans("SellingPrice").'</td>';
print '<td><input name="price" class="maxwidth50" value="'.$object->price.'">';
print $form->selectPriceBaseType($conf->global->PRODUCT_PRICE_BASE_TYPE, "price_base_type");
print $form->selectPriceBaseType(getDolGlobalString('PRODUCT_PRICE_BASE_TYPE'), "price_base_type");
print '</td></tr>';
// Min price