Edit unit bom line service

This commit is contained in:
atm-lena 2022-07-06 15:00:07 +02:00
parent 55f0dada34
commit 6925dc2ae1
7 changed files with 39 additions and 20 deletions

View File

@ -167,7 +167,7 @@ if (empty($reshook)) {
$qty_frozen = price2num(GETPOST('qty_frozen', 'alpha'), 'MS');
$disable_stock_change = GETPOST('disable_stock_change', 'int');
$efficiency = price2num(GETPOST('efficiency', 'alpha'));
$duration_unit = GETPOST('duration_unit','alphanohtml');
if ($qty == '') {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors');
$error++;
@ -191,6 +191,7 @@ if (empty($reshook)) {
$bomline->qty_frozen = (int) $qty_frozen;
$bomline->disable_stock_change = (int) $disable_stock_change;
$bomline->efficiency = $efficiency;
$bomline->duration_unit = $duration_unit;
// Rang to use
$rangmax = $object->line_max(0);
@ -225,6 +226,7 @@ if (empty($reshook)) {
$qty_frozen = price2num(GETPOST('qty_frozen', 'alpha'), 'MS');
$disable_stock_change = GETPOST('disable_stock_change', 'int');
$efficiency = price2num(GETPOST('efficiency', 'alpha'));
$duration_unit = GETPOST('duration_unit','alphanohtml');
if ($qty == '') {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors');
@ -237,6 +239,7 @@ if (empty($reshook)) {
$bomline->qty_frozen = (int) $qty_frozen;
$bomline->disable_stock_change = (int) $disable_stock_change;
$bomline->efficiency = $efficiency;
$bomline->duration_unit = $duration_unit;
$result = $bomline->update($user);
if ($result <= 0) {
@ -577,7 +580,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Form to add new line
if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') {
if ($action != 'editline') {
// Add products/services form
// Add products form
$parameters = array();
@ -601,7 +604,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$filtertype = 1;
$res = $object->fetchLinesbytype(1);
$object->calculateCosts();
@ -609,7 +611,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print load_fiche_titre($langs->trans('BOMServicesList'), '', 'service');
print ' <form name="addproduct" id="addproduct" action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . (($action != 'editline') ? '' : '') . '" method="POST">
print ' <form name="addservice" id="addservice" action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . (($action != 'editline') ? '' : '') . '" method="POST">
<input type="hidden" name="token" value="' . newToken() . '">
<input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline') . '">
<input type="hidden" name="mode" value="">
@ -633,11 +635,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Form to add new line
if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') {
if ($action != 'editline') {
// Add products/services form
// Add services form
$parameters = array();
$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
$reshook = $hookmanager->executeHooks('formAddObjectServiceLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
$object->formAddObjectLine(1, $mysoc, null, '/bom/tpl');

View File

@ -1299,6 +1299,7 @@ class BOMLine extends CommonObjectLine
'qty_frozen' => array('type'=>'smallint', 'label'=>'QuantityFrozen', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>105, 'css'=>'maxwidth50imp', 'help'=>'QuantityConsumedInvariable'),
'disable_stock_change' => array('type'=>'smallint', 'label'=>'DisableStockChange', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>108, 'css'=>'maxwidth50imp', 'help'=>'DisableStockChangeHelp'),
'efficiency' => array('type'=>'double(24,8)', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'position'=>110, 'notnull'=>1, 'css'=>'maxwidth50imp', 'help'=>'ValueOfEfficiencyConsumedMeans'),
'duration_unit' => array('type'=>'varchar(6)', 'label'=>'Unit', 'enabled'=>1, 'visible'=>1, 'position'=>120, 'notnull'=>-1,),
'position' => array('type'=>'integer', 'label'=>'Rank', 'enabled'=>1, 'visible'=>0, 'default'=>0, 'position'=>200, 'notnull'=>1,),
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,),
);

View File

@ -29,6 +29,8 @@
* $forceall (0 by default, 1 for supplier invoices/orders)
*/
require_once DOL_DOCUMENT_ROOT."/product/class/html.formproduct.class.php";
// Protection to avoid direct call of template
if (empty($object) || !is_object($object)) {
print "Error: this template page cannot be called directly as an URL";
@ -47,6 +49,7 @@ if (!empty($object->element) && $object->element == 'contrat' && empty($conf->gl
$filtertype = -1;
}
$formproduct = new FormProduct($object->db);
// Define colspan for the button 'Add'
$colspan = 3; // Columns: total ht + col edit + col delete
@ -159,12 +162,12 @@ if($filtertype != 1) {
print '</td>';
} else {
$coldisplay++;
print '<td class="bordertop nobottom nowrap linecolcost right">';
print '&nbsp;';
print '<td class="bordertop nobottom nowrap linecolunit right">';
print $formproduct->selectMeasuringUnits("duration_unit", "time", (GETPOSTISSET('duration_value') ? GETPOST('duration_value', 'alpha') : 'h'), 0, 1);
print '</td>';
$coldisplay++;
print '<td class="bordertop nobottom nowrap linecolcost right">';
print '<td class="bordertop nobottom nowrap linecolworkstation right">';
print '&nbsp;';
print '</td>';

View File

@ -31,6 +31,9 @@
* $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax)
*/
require_once DOL_DOCUMENT_ROOT."/product/class/html.formproduct.class.php";
// Protection to avoid direct call of template
if (empty($object) || !is_object($object)) {
print "Error, template page can't be called as URL";
@ -46,6 +49,8 @@ if (empty($forceall)) {
if(empty($filtertype)) $filtertype = 0;
$formproduct = new FormProduct($object->db);
// Define colspan for the button 'Add'
$colspan = 3; // Columns: total ht + col edit + col delete
@ -135,20 +140,18 @@ if($filtertype != 1) {
} else {
$coldisplay++;
print '<td class="nobottom nowrap linecolcostprice right">';
print '<td class="nobottom nowrap linecolunit right">';
print $formproduct->selectMeasuringUnits("duration_unit", "time", (GETPOSTISSET('duration_value') ? GETPOST('duration_value', 'alpha') : 'h'), 0, 1);
print '</td>';
$coldisplay++;
print '<td class="nobottom nowrap linecolworkstation right">';
print '</td>';
$coldisplay++;
print '<td class="nobottom nowrap linecolcostprice right">';
print '</td>';
$coldisplay++;
print '<td class="nobottom nowrap linecolcostprice right">';
print '</td>';
$coldisplay++;
print '<td class="nobottom nowrap linecolcostprice right">';
print '</td>';
}
$coldisplay += $colspan;

View File

@ -135,7 +135,16 @@ if($filtertype != 1) {
//Unité
print '<td class="linecolunit nowrap right">';
$coldisplay++;
echo $product->duration_unit;
if ($line->qty > 1) {
$dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years"));
} elseif ($product->duration_value > 0) {
$dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year"));
}
if(!empty($line->duration_unit)){
print (isset($dur[$line->duration_unit]) ? "&nbsp;".$langs->trans($dur[$line->duration_unit])."&nbsp;" : '');
} else {
print (!empty($product->duration_unit) && isset($dur[$product->duration_unit]) ? "&nbsp;" . $langs->trans($dur[$product->duration_unit]) . "&nbsp;" : '');
}
print '</td>';
//Poste de travail

View File

@ -650,5 +650,7 @@ ALTER TABLE llx_prelevement_facture_demande MODIFY COLUMN ext_payment_id varchar
ALTER TABLE llx_product ADD COLUMN fk_default_workstation integer DEFAULT NULL;
ALTER TABLE llx_bom_bomline ADD COLUMN duration_unit varchar(6) DEFAULT NULL;

View File

@ -25,6 +25,7 @@ CREATE TABLE llx_bom_bomline(
qty_frozen smallint DEFAULT 0,
disable_stock_change smallint DEFAULT 0,
efficiency double(24,8) NOT NULL DEFAULT 1,
duration_unit varchar(6) NULL,
position integer NOT NULL DEFAULT 0
-- END MODULEBUILDER FIELDS
) ENGINE=innodb;