mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Debug BOM module
This commit is contained in:
parent
a5865d3e4a
commit
9f9f3bda63
|
|
@ -110,8 +110,40 @@ if (empty($reshook))
|
|||
$autocopy='MAIN_MAIL_AUTOCOPY_BOM_TO';
|
||||
$trackid='bom'.$object->id;
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
|
||||
}
|
||||
|
||||
// Add line
|
||||
if ($action == 'addline' && $user->rights->bom->write)
|
||||
{
|
||||
$langs->load('errors');
|
||||
$error = 0;
|
||||
|
||||
// Set if we used free entry or predefined product
|
||||
$idprod=GETPOST('idprod', 'int');
|
||||
$qty=GETPOST('qty', 'int');
|
||||
$efficiency=GETPOST('efficiency', 'int');
|
||||
|
||||
if ($qty == '') {
|
||||
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
if (! ($idprod > 0)) {
|
||||
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Product')), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
|
||||
$bomline = new BOMLine($db);
|
||||
$bomline->fk_bom = $id;
|
||||
$bomline->fk_product = $prodid;
|
||||
$bomline->qty = $qty;
|
||||
$bomline->efficiency = $efficiency;
|
||||
|
||||
$result = $bomline->create($user);
|
||||
if ($result <= 0)
|
||||
{
|
||||
setEventMessages($bomline->error, $bomline->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -946,7 +946,7 @@ class BOMLine extends CommonObject
|
|||
/**
|
||||
* @var string String with name of icon for bomline. Must be the part after the 'object_' into object_bomline.png
|
||||
*/
|
||||
public $picto = 'bomline@bom';
|
||||
public $picto = 'bomline';
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -974,20 +974,22 @@ class BOMLine extends CommonObject
|
|||
*/
|
||||
public $fields=array(
|
||||
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",),
|
||||
'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-1, 'position'=>60, 'notnull'=>-1,),
|
||||
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,),
|
||||
'qty' => array('type'=>'double(24,8)', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'notnull'=>-1, 'isameasure'=>'1',),
|
||||
'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>20, 'notnull'=>-1, 'index'=>1,),
|
||||
'fk_bom' => array('type'=>'integer:BillOfMaterials:societe/class/bom.class.php', 'label'=>'BillOfMaterials', 'enabled'=>1, 'visible'=>1, 'position'=>10, 'notnull'=>-1, 'index'=>1,),
|
||||
'rank' => array('type'=>'integer', 'label'=>'Rank', 'enabled'=>1, 'visible'=>0, 'position'=>40, 'notnull'=>1,),
|
||||
'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>20, 'notnull'=>-1, 'index'=>1,),
|
||||
'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-1, 'position'=>60, 'notnull'=>-1,),
|
||||
'qty' => array('type'=>'double(24,8)', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'position'=>100, 'notnull'=>-1, 'isameasure'=>'1',),
|
||||
'efficiency' => array('type'=>'double(8,4)', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>1, 'default'=>1, 'position'=>110, 'notnull'=>0, 'css'=>'maxwidth50imp', 'help'=>'ValueOfMeansLoss'),
|
||||
'rank' => array('type'=>'integer', 'label'=>'Rank', 'enabled'=>1, 'visible'=>0, 'position'=>200, 'notnull'=>1,),
|
||||
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,),
|
||||
);
|
||||
public $rowid;
|
||||
public $description;
|
||||
public $import_key;
|
||||
public $qty;
|
||||
public $fk_product;
|
||||
public $fk_bom;
|
||||
public $fk_product;
|
||||
public $description;
|
||||
public $qty;
|
||||
public $efficiency;
|
||||
public $rank;
|
||||
public $import_key;
|
||||
// END MODULEBUILDER PROPERTIES
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ if ($nolinesbefore) {
|
|||
print '</span></td>';
|
||||
}
|
||||
?>
|
||||
<td class="linecollost right"><?php echo $langs->trans('Lost'); ?></td>
|
||||
<td class="linecollost right"><?php echo $langs->trans('ManufacturingEfficiency'); ?></td>
|
||||
<td class="linecoledit" colspan="<?php echo $colspan; ?>"> </td>
|
||||
</tr>
|
||||
<?php
|
||||
|
|
@ -144,7 +144,7 @@ if ($nolinesbefore) {
|
|||
|
||||
$coldisplay++;
|
||||
?>
|
||||
<td class="nobottom nowrap linecollost right"><input type="text" size="1" name="lost" id="lost" class="flat right" value="<?php echo (isset($_POST["lsot"])?GETPOST("lost", 'alpha', 2):$remise_percent); ?>"><span class="hideonsmartphone">%</span></td>
|
||||
<td class="nobottom nowrap linecollost right"><input type="text" size="1" name="efficiency" id="efficiency" class="flat right" value="<?php echo (GETPOSTISSET("efficiency")?GETPOST("efficiency", 'alpha'):1); ?>"></td>
|
||||
<?php
|
||||
|
||||
$coldisplay+=$colspan;
|
||||
|
|
@ -165,39 +165,12 @@ if (is_object($objectline)) {
|
|||
/* JQuery for product free or predefined select */
|
||||
jQuery(document).ready(function() {
|
||||
/* When changing predefined product, we reload list of supplier prices required for margin combo */
|
||||
$("#idprod, #idprodfournprice").change(function()
|
||||
$("#idprod").change(function()
|
||||
{
|
||||
console.log("#idprod, #idprodfournprice change triggered");
|
||||
|
||||
setforpredef(); // TODO Keep vat combo visible and set it to first entry into list that match result of get_default_tva
|
||||
|
||||
jQuery('#trlinefordates').show();
|
||||
|
||||
/* To process customer price per quantity */
|
||||
var pbq = parseInt($('option:selected', this).attr('data-pbq'));
|
||||
var pbqqty = parseFloat($('option:selected', this).attr('data-pbqqty'));
|
||||
var pbqpercent = parseFloat($('option:selected', this).attr('data-pbqpercent'));
|
||||
|
||||
if ((jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val()) && typeof pbq !== "undefined")
|
||||
{
|
||||
console.log("We choose a price by quanty price_by_qty id = "+pbq+" price_by_qty qty = "+pbqqty+" price_by_qty percent = "+pbqpercent);
|
||||
jQuery("#pbq").val(pbq);
|
||||
if (jQuery("#qty").val() < pbqqty)
|
||||
{
|
||||
jQuery("#qty").val(pbqqty);
|
||||
}
|
||||
if (jQuery("#remise_percent").val() < pbqpercent)
|
||||
{
|
||||
jQuery("#remise_percent").val(pbqpercent);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
jQuery("#pbq").val('');
|
||||
}
|
||||
console.log("#idprod change triggered");
|
||||
|
||||
/* To set focus */
|
||||
if (jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val() > 0)
|
||||
if (jQuery('#idprod').val() > 0)
|
||||
{
|
||||
/* focus work on a standard textarea but not if field was replaced with CKEDITOR */
|
||||
jQuery('#dp_desc').focus();
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ CREATE TABLE llx_bom_bom(
|
|||
-- END MODULEBUILDER FIELDS
|
||||
) ENGINE=innodb;
|
||||
|
||||
ALTER TABLE llx_bom_bom ADD COLUMN efficiency double(24,8) DEFAULT 1;
|
||||
ALTER TABLE llx_bom_bom ADD COLUMN efficiency double(8,4) DEFAULT 1;
|
||||
|
||||
create table llx_bom_bom_extrafields
|
||||
(
|
||||
|
|
@ -239,15 +239,19 @@ create table llx_bom_bom_extrafields
|
|||
CREATE TABLE llx_bom_bomline(
|
||||
-- BEGIN MODULEBUILDER FIELDS
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
|
||||
fk_bom integer,
|
||||
fk_product integer,
|
||||
description text,
|
||||
import_key varchar(14),
|
||||
qty double(24,8),
|
||||
fk_product integer,
|
||||
fk_bom integer,
|
||||
efficiency double(8,4) DEFAULT 1,
|
||||
rank integer NOT NULL
|
||||
-- END MODULEBUILDER FIELDS
|
||||
) ENGINE=innodb;
|
||||
|
||||
ALTER TABLE llx_bom_bomline ADD COLUMN efficiency double(8,4) DEFAULT 1;
|
||||
|
||||
|
||||
create table llx_bom_bomline_extrafields
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
|
|
|
|||
|
|
@ -17,11 +17,12 @@
|
|||
CREATE TABLE llx_bom_bomline(
|
||||
-- BEGIN MODULEBUILDER FIELDS
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
|
||||
fk_bom integer,
|
||||
fk_product integer,
|
||||
description text,
|
||||
import_key varchar(14),
|
||||
qty double(24,8),
|
||||
fk_product integer,
|
||||
fk_bom integer,
|
||||
efficiency double(8,4) DEFAULT 1,
|
||||
rank integer NOT NULL
|
||||
-- END MODULEBUILDER FIELDS
|
||||
) ENGINE=innodb;
|
||||
Loading…
Reference in New Issue
Block a user