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