Fixing style errors.

This commit is contained in:
stickler-ci 2022-02-21 14:51:57 +00:00
parent 76e2ee2dde
commit 0eb8eab7f0

View File

@ -176,8 +176,8 @@ if (empty($reshook)) {
$datemovement = ''; $datemovement = '';
//$inventorycode = 'INV'.$object->id; //$inventorycode = 'INV'.$object->id;
$inventorycode = 'INV-'.$object->ref; $inventorycode = 'INV-'.$object->ref;
$price = 0; $price = 0;
if(!empty($line->pmp_real) && !empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) $price = $line->pmp_real; if (!empty($line->pmp_real) && !empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) $price = $line->pmp_real;
$idstockmove = $stockmovment->_create($user, $line->fk_product, $line->fk_warehouse, $stock_movement_qty, $movement_type, $price, $langs->trans('LabelOfInventoryMovemement', $object->ref), $inventorycode, $datemovement, '', '', $line->batch); $idstockmove = $stockmovment->_create($user, $line->fk_product, $line->fk_warehouse, $stock_movement_qty, $movement_type, $price, $langs->trans('LabelOfInventoryMovemement', $object->ref), $inventorycode, $datemovement, '', '', $line->batch);
if ($idstockmove < 0) { if ($idstockmove < 0) {
@ -186,15 +186,15 @@ if (empty($reshook)) {
break; break;
} }
if(!empty($line->pmp_real) && !empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { if (!empty($line->pmp_real) && !empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) {
$sqlpmp = 'UPDATE '.MAIN_DB_PREFIX.'product SET pmp = '.((float) $line->pmp_real).' WHERE rowid = '.((int) $line->fk_product); $sqlpmp = 'UPDATE '.MAIN_DB_PREFIX.'product SET pmp = '.((float) $line->pmp_real).' WHERE rowid = '.((int) $line->fk_product);
$resqlpmp = $db->query($sqlpmp); $resqlpmp = $db->query($sqlpmp);
if(! $resqlpmp) { if (! $resqlpmp) {
$error++; $error++;
setEventMessages($db->lasterror(), null, 'errors'); setEventMessages($db->lasterror(), null, 'errors');
break; break;
} }
} }
// Update line with id of stock movement (and the start quantity if it has changed this last recording) // Update line with id of stock movement (and the start quantity if it has changed this last recording)
$sqlupdate = "UPDATE ".MAIN_DB_PREFIX."inventorydet"; $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."inventorydet";
@ -259,8 +259,8 @@ if (empty($reshook)) {
if ($result > 0) { if ($result > 0) {
$inventoryline->qty_stock = price2num(GETPOST('stock_qty_'.$lineid, 'alpha'), 'MS'); // The new value that was set in as hidden field $inventoryline->qty_stock = price2num(GETPOST('stock_qty_'.$lineid, 'alpha'), 'MS'); // The new value that was set in as hidden field
$inventoryline->qty_view = $qtytoupdate; // The new value we want $inventoryline->qty_view = $qtytoupdate; // The new value we want
$inventoryline->pmp_real = price2num(GETPOST('realpmp_'.$lineid, 'alpha'), 'MS'); $inventoryline->pmp_real = price2num(GETPOST('realpmp_'.$lineid, 'alpha'), 'MS');
$inventoryline->pmp_expected = price2num(GETPOST('expectedpmp_'.$lineid, 'alpha'), 'MS'); $inventoryline->pmp_expected = price2num(GETPOST('expectedpmp_'.$lineid, 'alpha'), 'MS');
$resultupdate = $inventoryline->update($user); $resultupdate = $inventoryline->update($user);
} }
} else { } else {
@ -880,7 +880,7 @@ if ($object->id > 0) {
print '<td class="right">'; print '<td class="right">';
print $form->textwithpicto($langs->trans("RealQty"), $langs->trans("InventoryRealQtyHelp")); print $form->textwithpicto($langs->trans("RealQty"), $langs->trans("InventoryRealQtyHelp"));
print '</td>'; print '</td>';
if(!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { if (!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) {
print '<td class="right">'.$langs->trans('PMPExpected').'</td>'; print '<td class="right">'.$langs->trans('PMPExpected').'</td>';
print '<td class="right">'.$langs->trans('ExpectedValuation').'</td>'; print '<td class="right">'.$langs->trans('ExpectedValuation').'</td>';
print '<td class="right">'.$langs->trans('PMPReal').'</td>'; print '<td class="right">'.$langs->trans('PMPReal').'</td>';
@ -916,7 +916,7 @@ if ($object->id > 0) {
print '<td class="right">'; print '<td class="right">';
print '<input type="text" name="qtytoadd" class="maxwidth75" value="">'; print '<input type="text" name="qtytoadd" class="maxwidth75" value="">';
print '</td>'; print '</td>';
if(!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { if (!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) {
print '<td class="right">'; print '<td class="right">';
print '</td>'; print '</td>';
print '<td class="right">'; print '<td class="right">';
@ -1021,9 +1021,9 @@ if ($object->id > 0) {
print '</a>'; print '</a>';
print '<input type="text" class="maxwidth75 right realqty" name="id_'.$obj->rowid.'" id="id_'.$obj->rowid.'_input" value="'.$qty_view.'">'; print '<input type="text" class="maxwidth75 right realqty" name="id_'.$obj->rowid.'" id="id_'.$obj->rowid.'_input" value="'.$qty_view.'">';
print '</td>'; print '</td>';
if(! empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { if (! empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) {
//PMP Expected //PMP Expected
if(! empty($obj->pmp_expected)) $pmp_expected = $obj->pmp_expected; if (! empty($obj->pmp_expected)) $pmp_expected = $obj->pmp_expected;
else $pmp_expected = $product_static->pmp; else $pmp_expected = $product_static->pmp;
$pmp_valuation = $pmp_expected * $valuetoshow; $pmp_valuation = $pmp_expected * $valuetoshow;
print '<td class="right">'; print '<td class="right">';
@ -1037,7 +1037,7 @@ if ($object->id > 0) {
print '<td class="right">'; print '<td class="right">';
if(! empty($obj->pmp_real)) $pmp_real = $obj->pmp_real; if (! empty($obj->pmp_real)) $pmp_real = $obj->pmp_real;
else $pmp_real = $product_static->pmp; else $pmp_real = $product_static->pmp;
$pmp_valuation_real = $pmp_real * $qty_view; $pmp_valuation_real = $pmp_real * $qty_view;
print '<input type="text" class="maxwidth75 right realpmp'.$obj->fk_product.'" name="realpmp_'.$obj->rowid.'" id="id_'.$obj->rowid.'_input_pmp" value="'.price2num($pmp_real).'">'; print '<input type="text" class="maxwidth75 right realpmp'.$obj->fk_product.'" name="realpmp_'.$obj->rowid.'" id="id_'.$obj->rowid.'_input_pmp" value="'.price2num($pmp_real).'">';
@ -1060,9 +1060,9 @@ if ($object->id > 0) {
print '<td class="right nowraponall">'; print '<td class="right nowraponall">';
print $obj->qty_view; // qty found print $obj->qty_view; // qty found
print '</td>'; print '</td>';
if(!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { if (!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) {
//PMP Expected //PMP Expected
if(! empty($obj->pmp_expected)) $pmp_expected = $obj->pmp_expected; if (! empty($obj->pmp_expected)) $pmp_expected = $obj->pmp_expected;
else $pmp_expected = $product_static->pmp; else $pmp_expected = $product_static->pmp;
$pmp_valuation = $pmp_expected * $valuetoshow; $pmp_valuation = $pmp_expected * $valuetoshow;
print '<td class="right">'; print '<td class="right">';
@ -1074,9 +1074,9 @@ if ($object->id > 0) {
//PMP Real //PMP Real
print '<td class="right">'; print '<td class="right">';
if(! empty($obj->pmp_real)) $pmp_real = $obj->pmp_real; if (! empty($obj->pmp_real)) $pmp_real = $obj->pmp_real;
else $pmp_real = $product_static->pmp; else $pmp_real = $product_static->pmp;
$pmp_valuation_real = $pmp_real * $obj->qty_view; $pmp_valuation_real = $pmp_real * $obj->qty_view;
print price($pmp_real); print price($pmp_real);
print '</td>'; print '</td>';
print '<td class="right">'; print '<td class="right">';
@ -1101,7 +1101,7 @@ if ($object->id > 0) {
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
if(!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { if (!empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) {
print '<tr class="liste_total">'; print '<tr class="liste_total">';
print '<td colspan="5">'.$langs->trans("Total").'</td>'; print '<td colspan="5">'.$langs->trans("Total").'</td>';
print '<td class="right" colspan="2">'.price($totalExpectedValuation).'</td>'; print '<td class="right" colspan="2">'.price($totalExpectedValuation).'</td>';
@ -1133,68 +1133,68 @@ if ($object->id > 0) {
print '</form>'; print '</form>';
if(! empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) { if (! empty($conf->global->INVENTORY_MANAGE_REAL_PMP)) {
?> ?>
<script type="text/javascript"> <script type="text/javascript">
$('.realqty').on('change', function () { $('.realqty').on('change', function () {
let realqty = $(this).closest('tr').find('.realqty').val(); let realqty = $(this).closest('tr').find('.realqty').val();
let inputPmp = $(this).closest('tr').find('input[class*=realpmp]'); let inputPmp = $(this).closest('tr').find('input[class*=realpmp]');
let realpmp = $(inputPmp).val(); let realpmp = $(inputPmp).val();
if (!isNaN(realqty) && !isNaN(realpmp)) { if (!isNaN(realqty) && !isNaN(realpmp)) {
let realval = realqty * realpmp; let realval = realqty * realpmp;
$(this).closest('tr').find('input[name^=realvaluation]').val(realval.toFixed(2)); $(this).closest('tr').find('input[name^=realvaluation]').val(realval.toFixed(2));
} }
updateTotalValuation(); updateTotalValuation();
}); });
$('input[class*=realpmp]').on('change', function () { $('input[class*=realpmp]').on('change', function () {
let inputQtyReal = $(this).closest('tr').find('.realqty'); let inputQtyReal = $(this).closest('tr').find('.realqty');
let realqty = $(inputQtyReal).val(); let realqty = $(inputQtyReal).val();
let inputPmp = $(this).closest('tr').find('input[class*=realpmp]'); let inputPmp = $(this).closest('tr').find('input[class*=realpmp]');
console.log(inputPmp); console.log(inputPmp);
let realPmpClassname = $(inputPmp).attr('class').match(/[\w-]*realpmp[\w-]*/g)[0]; let realPmpClassname = $(inputPmp).attr('class').match(/[\w-]*realpmp[\w-]*/g)[0];
let realpmp = $(inputPmp).val(); let realpmp = $(inputPmp).val();
if (!isNaN(realpmp)) { if (!isNaN(realpmp)) {
$('.'+realPmpClassname).val(realpmp); //For batch case if pmp is changed we change it everywhere it's same product and calc back everything $('.'+realPmpClassname).val(realpmp); //For batch case if pmp is changed we change it everywhere it's same product and calc back everything
if (!isNaN(realqty)) { if (!isNaN(realqty)) {
let realval = realqty * realpmp; let realval = realqty * realpmp;
$(this).closest('tr').find('input[name^=realvaluation]').val(realval.toFixed(2)); $(this).closest('tr').find('input[name^=realvaluation]').val(realval.toFixed(2));
} }
$('.realqty').trigger('change'); $('.realqty').trigger('change');
updateTotalValuation(); updateTotalValuation();
} }
}); });
$('input[name^=realvaluation]').on('change', function () { $('input[name^=realvaluation]').on('change', function () {
let inputQtyReal = $(this).closest('tr').find('.realqty'); let inputQtyReal = $(this).closest('tr').find('.realqty');
let realqty = $(inputQtyReal).val(); let realqty = $(inputQtyReal).val();
let inputPmp = $(this).closest('tr').find('input[class*=realpmp]'); let inputPmp = $(this).closest('tr').find('input[class*=realpmp]');
let inputRealValuation = $(this).closest('tr').find('input[name^=realvaluation]'); let inputRealValuation = $(this).closest('tr').find('input[name^=realvaluation]');
let realPmpClassname = $(inputPmp).attr('class').match(/[\w-]*realpmp[\w-]*/g)[0]; let realPmpClassname = $(inputPmp).attr('class').match(/[\w-]*realpmp[\w-]*/g)[0];
let realvaluation = $(inputRealValuation).val(); let realvaluation = $(inputRealValuation).val();
if (!isNaN(realvaluation) && !isNaN(realqty) && realvaluation !== '' && realqty !== '' && realqty !== 0) { if (!isNaN(realvaluation) && !isNaN(realqty) && realvaluation !== '' && realqty !== '' && realqty !== 0) {
let realpmp = realvaluation / realqty let realpmp = realvaluation / realqty
$('.'+realPmpClassname).val(realpmp); //For batch case if pmp is changed we change it everywhere it's same product and calc back everything $('.'+realPmpClassname).val(realpmp); //For batch case if pmp is changed we change it everywhere it's same product and calc back everything
$('.realqty').trigger('change'); $('.realqty').trigger('change');
updateTotalValuation(); updateTotalValuation();
} }
}); });
function updateTotalValuation() { function updateTotalValuation() {
let total = 0; let total = 0;
$('input[name^=realvaluation]').each(function( index ) { $('input[name^=realvaluation]').each(function( index ) {
let val = $(this).val(); let val = $(this).val();
if(!isNaN(val)) total += parseFloat($(this).val()); if(!isNaN(val)) total += parseFloat($(this).val());
}); });
let currencyFractionDigits = new Intl.NumberFormat('fr-FR', { let currencyFractionDigits = new Intl.NumberFormat('fr-FR', {
style: 'currency', style: 'currency',
currency: 'EUR', currency: 'EUR',
}).resolvedOptions().maximumFractionDigits; }).resolvedOptions().maximumFractionDigits;
$('#totalRealValuation').html(total.toLocaleString('fr-FR', { $('#totalRealValuation').html(total.toLocaleString('fr-FR', {
maximumFractionDigits: currencyFractionDigits maximumFractionDigits: currencyFractionDigits
})); }));
} }
</script> </script>
<?php <?php