Clean code

This commit is contained in:
Laurent Destailleur 2026-01-23 22:34:17 +01:00
parent b79814f864
commit ebbaeb5129
5 changed files with 47 additions and 26 deletions

View file

@ -1532,22 +1532,22 @@ if ($action == 'create' && $usercancreate) {
print $langs->trans("Weight");
print '</td><td colspan="3">';
print img_picto('', 'fa-balance-scale', 'class="pictofixedwidth"');
print '<input name="weight" size="4" value="' . GETPOSTINT('weight') . '"> ';
$text = $formproduct->selectMeasuringUnits("weight_units", "weight", (string) GETPOSTINT('weight_units'), 0, 2);
print '<input name="weight" size="4" value="' . GETPOST('weight') . '"> '; // Do not use GETPOSTINT here, we must accept '' also.
$text = $formproduct->selectMeasuringUnits("weight_units", "weight", GETPOST('weight_units'), 0, 2);
$htmltext = $langs->trans("KeepEmptyForAutoCalculation");
print $form->textwithpicto($text, $htmltext);
print '</td></tr>';
// Dim
// Dim width x height x depth
print '<tr><td>';
print $langs->trans("Width") . ' x ' . $langs->trans("Height") . ' x ' . $langs->trans("Depth");
print ' </td><td colspan="3">';
print img_picto('', 'fa-ruler', 'class="pictofixedwidth"');
print '<input name="sizeW" size="4" value="' . GETPOSTINT('sizeW') . '">';
print ' x <input name="sizeH" size="4" value="' . GETPOSTINT('sizeH') . '">';
print ' x <input name="sizeS" size="4" value="' . GETPOSTINT('sizeS') . '">';
print '<input name="sizeW" size="4" value="' . GETPOST('sizeW') . '">';
print ' x <input name="sizeH" size="4" value="' . GETPOST('sizeH') . '">';
print ' x <input name="sizeS" size="4" value="' . GETPOST('sizeS') . '">';
print ' ';
$text = $formproduct->selectMeasuringUnits("size_units", "size", (string) GETPOSTINT('size_units'), 0, 2);
$text = $formproduct->selectMeasuringUnits("size_units", "size", GETPOST('size_units'), 0, 2);
$htmltext = $langs->trans("KeepEmptyForAutoCalculation");
print $form->textwithpicto($text, $htmltext);
print '</td></tr>';
@ -1756,22 +1756,22 @@ if ($action == 'create' && $usercancreate) {
print $langs->trans("Weight");
print '</td><td colspan="3">';
print img_picto('', 'fa-balance-scale', 'class="pictofixedwidth"');
print '<input name="weight" size="4" value="' . GETPOSTINT('weight') . '"> ';
$text = $formproduct->selectMeasuringUnits("weight_units", "weight", (string) GETPOSTINT('weight_units'), 0, 2);
print '<input name="weight" size="4" value="' . GETPOST('weight') . '"> '; // Do not use GETPOSTINT here, we must accept '' also.
$text = $formproduct->selectMeasuringUnits("weight_units", "weight", GETPOST('weight_units'), 0, 2);
$htmltext = $langs->trans("KeepEmptyForAutoCalculation");
print $form->textwithpicto($text, $htmltext);
print '</td></tr>';
// Dim
// Dim Width x Height x Depth
print '<tr><td>';
print $langs->trans("Width") . ' x ' . $langs->trans("Height") . ' x ' . $langs->trans("Depth");
print ' </td><td colspan="3">';
print img_picto('', 'fa-ruler', 'class="pictofixedwidth"');
print '<input name="sizeW" size="4" value="' . GETPOSTINT('sizeW') . '">';
print ' x <input name="sizeH" size="4" value="' . GETPOSTINT('sizeH') . '">';
print ' x <input name="sizeS" size="4" value="' . GETPOSTINT('sizeS') . '">';
print '<input name="sizeW" size="4" value="' . GETPOST('sizeW') . '">';
print ' x <input name="sizeH" size="4" value="' . GETPOST('sizeH') . '">';
print ' x <input name="sizeS" size="4" value="' . GETPOST('sizeS') . '">';
print ' ';
$text = $formproduct->selectMeasuringUnits("size_units", "size", (string) GETPOSTINT('size_units'), 0, 2);
$text = $formproduct->selectMeasuringUnits("size_units", "size", GETPOST('size_units'), 0, 2);
$htmltext = $langs->trans("KeepEmptyForAutoCalculation");
print $form->textwithpicto($text, $htmltext);
print '</td></tr>';
@ -2026,14 +2026,18 @@ if ($action == 'create' && $usercancreate) {
// Qty
print '<td class="center">' . $line->qty;
print '<input name="qtyasked' . $indiceAsked . '" id="qtyasked' . $indiceAsked . '" type="hidden" value="' . $line->qty . '">';
print '' . $unit_order . '</td>';
if ($line->qty) {
print ' ' . $unit_order . '</td>';
}
// Qty already shipped
print '<td class="center">';
$quantityDelivered = isset($object->expeditions[$line->id]) ? $object->expeditions[$line->id] : '';
print $quantityDelivered;
print '<input name="qtydelivered' . $indiceAsked . '" id="qtydelivered' . $indiceAsked . '" type="hidden" value="' . $quantityDelivered . '">';
print '' . $unit_order . '</td>';
if ($quantityDelivered) {
print ' ' . $unit_order . '</td>';
}
// Qty to ship
$quantityAsked = $line->qty;
@ -2512,17 +2516,19 @@ if ($action == 'create' && $usercancreate) {
if ($line->product_type == Product::TYPE_PRODUCT || getDolGlobalString('STOCK_SUPPORTS_SERVICES')) {
$disabled = '';
$alt = '';
if (isModEnabled('productbatch') && $product->hasbatch()) {
$disabled = 'disabled="disabled"';
$alt = 'Product need serial or batch number';
}
if ($warehouse_selected_id <= 0) { // We did not force a given warehouse, so we won't have no warehouse to change qty.
$disabled = 'disabled="disabled"';
}
// finally we overwrite the input with the product status stockable_product if it's disabled
if ($product->stockable_product == Product::DISABLED_STOCK) {
if ($product->stockable_product == Product::ENABLED_STOCK) {
$disabled = '';
}
print '<input class="qtyl right" name="qtyl'.$indiceAsked.'_'.$subj.'" id="qtyl'.$indiceAsked.'_'.$subj.'" type="text" size="4" value="0"'.($disabled ? ' '.$disabled : '').'> ';
print '<input class="qtyl right" name="qtyl'.$indiceAsked.'_'.$subj.'" id="qtyl'.$indiceAsked.'_'.$subj.'" type="text" size="4" value="0"'.($disabled ? ' '.$disabled : '').($alt ? ' title="'.dolPrintHTMLForAttribute($alt).'"' : '').'> ';
if (empty($disabled) && (!getDolGlobalInt('STOCK_DISALLOW_NEGATIVE_TRANSFER') || $product->stockable_product == Product::DISABLED_STOCK)) {
print '<input name="ent1' . $indiceAsked . '_' . $subj . '" type="hidden" value="' . $warehouse_selected_id . '">';
}
@ -2545,16 +2551,17 @@ if ($action == 'create' && $usercancreate) {
print '<td class="left">';
if ($line->product_type == Product::TYPE_PRODUCT || getDolGlobalString('STOCK_SUPPORTS_SERVICES')) {
if ($warehouse_selected_id > 0 && $product->stockable_product == Product::ENABLED_STOCK) {
// product may use stock management
if (($warehouse_selected_id > 0 && $product->stockable_product == Product::ENABLED_STOCK)) {
$warehouseObject = new Entrepot($db);
$warehouseObject->fetch($warehouse_selected_id);
print img_warning() . ' ' . $langs->trans("NoProductToShipFoundIntoStock", $warehouseObject->label);
} else {
if ($line->fk_product) {
if ($product->stockable_product == Product::ENABLED_STOCK) {
print img_warning() . ' ' . $langs->trans('StockTooLow');
} else {
if ($product->stockable_product != Product::ENABLED_STOCK) {
print img_warning() . ' ' . $langs->trans('StockDisabled');
} else {
print img_warning() . ' ' . $langs->trans('StockTooLow');
}
} else {
print '';

View file

@ -2891,7 +2891,7 @@ class Expedition extends CommonObject
$resql = $this->db->query($sql);
if ($resql) {
// Set order billed if 100% of order is shipped (qty in shipment lines match qty in order lines)
if ($this->origin == 'commande' && $this->origin_id > 0) {
if ($this->origin_type == 'commande' && $this->origin_id > 0) {
$order = new Commande($this->db);
$order->fetch($this->origin_id);
@ -2921,6 +2921,7 @@ class Expedition extends CommonObject
// If stock increment is done on closing
if (isModEnabled('stock') && getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT_CLOSE')) {
$result = $this->manageStockMvtOnEvt($user);
if ($result < 0) {
$error++;
}

View file

@ -919,7 +919,7 @@ if ($order_id > 0 || !empty($ref)) {
if ($toBeShippedTotal <= 0) {
print ' '.img_warning($langs->trans("WarningNoQtyLeftToSend"));
}
print '<br><br>';
print '</div>';
print "</form>\n";

View file

@ -5787,13 +5787,16 @@ class Product extends CommonObject
$datas['ref'] = '<br><b>'.$langs->trans('ProductRef').':</b> '.$this->ref;
}
if (!empty($this->label)) {
$datas['label'] = '<br><b>'.$langs->trans('ProductLabel').':</b> '.$this->label;
$datas['label'] = '<br><b>'.$langs->trans('ProductLabel').':</b> '.$this->label.'<br>';
}
if ($permissiontoreadproduct) {
if (!empty($this->description)) {
if (!empty($this->description) && getDolGlobalString('PRODUCT_SHOW_DESCRIPTION_IN_TOOLTIP')) {
$datas['description'] = '<br><b>'.$langs->trans('ProductDescription').':</b> '.dolGetFirstLineOfText($this->description, 5);
}
$datas['stockmanaged'] = "<br><b>".$langs->trans("StockableProduct").'</b>: '.yn($this->isStockManaged());
if ($this->isStockManaged()) {
if (isModEnabled('productbatch')) {
$langs->load("productbatch");

View file

@ -1382,6 +1382,16 @@ if (getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUS
}
}
} else {
// Type
if (isModEnabled("product") && isModEnabled("service")) {
$typeformat = 'select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service");
print '<tr><td class="">';
print (!getDolGlobalString('PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey("Type", 'fk_product_type', (string) $object->type, $object, 0, $typeformat) : $langs->trans('Type');
print '</td><td>';
print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, 0, $typeformat);
print '</td></tr>';
}
// TVA
print '<tr><td class="titlefield">'.$langs->trans("DefaultTaxRate").'</td><td>';