diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 17fae31ef7d..6186e809543 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -125,9 +125,11 @@ if (empty($reshook)) $error = 0; // Set if we used free entry or predefined product - $idprod=GETPOST('idprod', 'int'); - $qty=GETPOST('qty', 'int'); - $efficiency=GETPOST('efficiency', 'int'); + $idprod = GETPOST('idprod', 'int'); + $qty = GETPOST('qty', 'int'); + $qty_frozen = GETPOST('qty_frozen', 'int'); + $disable_stock_change = GETPOST('disable_stock_change', 'int'); + $efficiency = GETPOST('efficiency', 'int'); if ($qty == '') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); @@ -138,17 +140,27 @@ if (empty($reshook)) $error++; } - $bomline = new BOMLine($db); - $bomline->fk_bom = $id; - $bomline->fk_product = $idprod; - $bomline->qty = $qty; - $bomline->efficiency = $efficiency; - - $result = $bomline->create($user); - if ($result <= 0) + if (! $error) { - setEventMessages($bomline->error, $bomline->errors, 'errors'); - $action = ''; + $bomline = new BOMLine($db); + $bomline->fk_bom = $id; + $bomline->fk_product = $idprod; + $bomline->qty = $qty; + $bomline->qty_frozen = $qty_frozen; + $bomline->disable_stock_change = $disable_stock_change; + $bomline->efficiency = $efficiency; + + $result = $bomline->create($user); + if ($result <= 0) + { + setEventMessages($bomline->error, $bomline->errors, 'errors'); + $action = ''; + } + else + { + unset($_POST['qty_frozen']); + unset($_POST['disable_stock_change']); + } } } @@ -160,6 +172,8 @@ if (empty($reshook)) // Set if we used free entry or predefined product $qty=GETPOST('qty', 'int'); + $qty_frozen = GETPOST('qty_frozen', 'int'); + $disable_stock_change = GETPOST('disable_stock_change', 'int'); $efficiency=GETPOST('efficiency', 'int'); if ($qty == '') { @@ -170,6 +184,8 @@ if (empty($reshook)) $bomline = new BOMLine($db); $bomline->fetch($lineid); $bomline->qty = $qty; + $bomline->qty_frozen = $qty_frozen; + $bomline->disable_stock_change = $disable_stock_change; $bomline->efficiency = $efficiency; $result = $bomline->update($user); @@ -178,6 +194,11 @@ if (empty($reshook)) setEventMessages($bomline->error, $bomline->errors, 'errors'); $action = ''; } + else + { + unset($_POST['qty_frozen']); + unset($_POST['disable_stock_change']); + } } } @@ -294,12 +315,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); } - $formconfirm = ''; - - // Confirmation to delete - if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1); - } // Confirmation of validation if ($action == 'validate') diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index b3163511150..444caa2a4da 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -240,9 +240,10 @@ class BOM extends CommonObject unset($object->import_key); // Clear fields - $object->ref = "copy_of_".$object->ref; - $object->title = $langs->trans("CopyOf")." ".$object->title; - + $object->ref = empty($this->fields['ref']['default']) ? $langs->trans("copy_of_").$object->ref: $this->fields['ref']['default']; + $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label: $this->fields['label']['default']; + $object->status = self::STATUS_DRAFT; + // ... // Clear extrafields that are unique if (is_array($object->array_options) && count($object->array_options) > 0) { @@ -1035,12 +1036,14 @@ class BOMLine extends CommonObject * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields=array( - 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), + 'rowid' => array('type'=>'integer', 'label'=>'LineID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), 'fk_bom' => array('type'=>'integer:BillOfMaterials:societe/class/bom.class.php', 'label'=>'BillOfMaterials', 'enabled'=>1, 'visible'=>1, 'position'=>10, 'notnull'=>1, 'index'=>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'=>1, 'css'=>'maxwidth50imp', 'help'=>'ValueOfMeansLoss'), + '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(8,4)', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>1, 'default'=>1, 'position'=>110, 'notnull'=>1, 'css'=>'maxwidth50imp', 'help'=>'ValueOfMeansLoss'), '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,), ); @@ -1049,6 +1052,8 @@ class BOMLine extends CommonObject public $fk_product; public $description; public $qty; + public $qty_frozen; + public $disable_stock_change; public $efficiency; public $position; public $import_key; @@ -1315,47 +1320,7 @@ class BOMLine extends CommonObject public function LibStatut($status, $mode = 0) { // phpcs:enable - if (empty($this->labelstatus)) - { - global $langs; - //$langs->load("mrp"); - $this->labelstatus[1] = $langs->trans('Enabled'); - $this->labelstatus[0] = $langs->trans('Disabled'); - } - - if ($mode == 0) - { - return $this->labelstatus[$status]; - } - elseif ($mode == 1) - { - return $this->labelstatus[$status]; - } - elseif ($mode == 2) - { - if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - } - elseif ($mode == 3) - { - if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); - elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); - } - elseif ($mode == 4) - { - if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - } - elseif ($mode == 5) - { - if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); - elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); - } - elseif ($mode == 6) - { - if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); - elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); - } + return ''; } /** diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index cd654c7a596..9f6bfee98f2 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -63,11 +63,13 @@ if ($nolinesbefore) { print ''.$langs->trans('Qty').''; if ($conf->global->PRODUCT_USE_UNITS) { - print ''; - print ''; - print $langs->trans('Unit'); - print ''; + print ''; + print ''; + print $langs->trans('Unit'); + print ''; } + print ''.$form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")).''; + print ''.$form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')).''; print ''.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')).''; print ' '; print ''; @@ -109,6 +111,7 @@ if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) $coldisplay++; print ''; print ''; + if($conf->global->PRODUCT_USE_UNITS) { $coldisplay++; @@ -118,7 +121,14 @@ if($conf->global->PRODUCT_USE_UNITS) } $coldisplay++; +print ''; +print ''; +$coldisplay++; +print ''; +print ''; + +$coldisplay++; print ''; print ''; print ''; diff --git a/htdocs/bom/tpl/objectline_edit.tpl.php b/htdocs/bom/tpl/objectline_edit.tpl.php index d887b9ab68d..c7fc4f73cd7 100644 --- a/htdocs/bom/tpl/objectline_edit.tpl.php +++ b/htdocs/bom/tpl/objectline_edit.tpl.php @@ -116,6 +116,14 @@ if ($conf->global->PRODUCT_USE_UNITS) print ''; } +$coldisplay++; +print 'qty_frozen?' checked="checked"':'')).'>'; +print ''; + +$coldisplay++; +print 'disable_stock_change?' checked="checked"':'')).'">'; +print ''; + $coldisplay++; print ''; print ''; diff --git a/htdocs/bom/tpl/objectline_title.tpl.php b/htdocs/bom/tpl/objectline_title.tpl.php index 721cc5b501f..138a0b9aa58 100644 --- a/htdocs/bom/tpl/objectline_title.tpl.php +++ b/htdocs/bom/tpl/objectline_title.tpl.php @@ -59,6 +59,13 @@ if ($conf->global->PRODUCT_USE_UNITS) print ''.$langs->trans('Unit').''; } +// Qty frozen +print ''.$form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")).''; + +// Disable stock change +print ''.$form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')).''; + +// Efficiency print ''.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')).''; print ''; // No width to allow autodim diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index f68372c721d..330f8ef8a33 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -87,6 +87,16 @@ if($conf->global->PRODUCT_USE_UNITS) } print ''; } + +print ''; +$coldisplay++; +echo $line->qty_frozen ? yn($line->qty_frozen) : ''; +print ''; +print ''; +$coldisplay++; +echo $line->disable_stock_change ? yn($line->disable_stock_change) : ''; // Yes, it is a quantity, not a price, but we just want the formating role of function price +print ''; + print ''; $coldisplay++; echo $line->efficiency; diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index d618a0702c8..72ad67db52e 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -56,7 +56,7 @@ if ($action == 'add' && ! empty($permissiontoadd)) $value = dol_mktime(12, 0, 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year')); } elseif ($object->fields[$key]['type']=='datetime') { $value = dol_mktime(GETPOST($key.'hour'), GETPOST($key.'min'), 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year')); - } elseif ($object->fields[$key]['type']=='price') { + } elseif (in_array($object->fields[$key]['type'], array('price', 'real'))) { $value = price2num(GETPOST($key)); } else { $value = GETPOST($key, 'alpha'); @@ -108,7 +108,7 @@ if ($action == 'update' && ! empty($permissiontoadd)) { if (! GETPOSTISSET($key)) continue; // The field was not submited to be edited if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields - + var_dump($object->fields[$key]['type']); // Set value to update if (in_array($object->fields[$key]['type'], array('text', 'html'))) { $value = GETPOST($key, 'none'); @@ -116,7 +116,7 @@ if ($action == 'update' && ! empty($permissiontoadd)) $value = dol_mktime(12, 0, 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year')); } elseif ($object->fields[$key]['type']=='datetime') { $value = dol_mktime(GETPOST($key.'hour'), GETPOST($key.'min'), 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year')); - } elseif ($object->fields[$key]['type']=='price') { + } elseif (in_array($object->fields[$key]['type'], array('price', 'real'))) { $value = price2num(GETPOST($key)); } else { $value = GETPOST($key, 'alpha'); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f8e65e2bb40..dd1076cc87c 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7483,6 +7483,7 @@ abstract class CommonObject { $sql="UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ref = '(PROV".$this->id.")' WHERE ref = '(PROV)' AND rowid = ".$this->id; $resqlupdate = $this->db->query($sql); + if ($resqlupdate===false) { $error++; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 865e06a4478..ca285642b2a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2416,10 +2416,12 @@ class Form // Units $outvalUnits = ''; - if ($conf->global->PRODUCT_USE_UNITS) { + if (! empty($conf->global->PRODUCT_USE_UNITS)) { if (!empty($objp->unit_short)) { $outvalUnits .= ' - ' . $objp->unit_short; } + } + if (! empty($conf->global->PRODUCT_SHOW_DIMENSIONS_IN_COMBO)) { if (!empty($objp->weight) && $objp->weight_units!==null) { $unitToShow = showDimensionInBestUnit($objp->weight, $objp->weight_units, 'weight', $langs); $outvalUnits .= ' - ' . $unitToShow; @@ -2436,17 +2438,17 @@ class Form $unitToShow = showDimensionInBestUnit($objp->volume, $objp->volume_units, 'volume', $langs); $outvalUnits .= ' - ' . $unitToShow; } - if ($outdurationvalue && $outdurationunit) { - $da = array( - 'h' => $langs->trans('Hour'), - 'd' => $langs->trans('Day'), - 'w' => $langs->trans('Week'), - 'm' => $langs->trans('Month'), - 'y' => $langs->trans('Year') - ); - if (isset($da[$outdurationunit])) { - $outvalUnits .= ' - ' . $outdurationvalue . ' ' . $langs->transnoentities($da[$outdurationunit].($outdurationvalue > 1 ? 's' : '')); - } + } + if ($outdurationvalue && $outdurationunit) { + $da = array( + 'h' => $langs->trans('Hour'), + 'd' => $langs->trans('Day'), + 'w' => $langs->trans('Week'), + 'm' => $langs->trans('Month'), + 'y' => $langs->trans('Year') + ); + if (isset($da[$outdurationunit])) { + $outvalUnits .= ' - ' . $outdurationvalue . ' ' . $langs->transnoentities($da[$outdurationunit].($outdurationvalue > 1 ? 's' : '')); } } @@ -2458,8 +2460,10 @@ class Form } if (! empty($conf->stock->enabled) && isset($objp->stock) && ($objp->fk_product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES))) { - if ($objp->stock > 0) $opt.= ' class="product_line_stock_ok"'; - elseif ($objp->stock <= 0) $opt.= ' class="product_line_stock_too_low"'; + if (! empty($user->rights->stock->lire)) { + if ($objp->stock > 0) $opt.= ' class="product_line_stock_ok"'; + elseif ($objp->stock <= 0) $opt.= ' class="product_line_stock_too_low"'; + } } $opt.= '>'; $opt.= $objp->ref; @@ -2602,37 +2606,39 @@ class Form if (! empty($conf->stock->enabled) && isset($objp->stock) && ($objp->fk_product_type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES))) { - $opt.= ' - '.$langs->trans("Stock").':'.$objp->stock; + if (! empty($user->rights->stock->lire)) { + $opt.= ' - '.$langs->trans("Stock").':'.$objp->stock; - if ($objp->stock > 0) { - $outval.= ' - '; - }elseif ($objp->stock <= 0) { - $outval.= ' - '; - } - $outval.= $langs->transnoentities("Stock").':'.$objp->stock; - $outval.= ''; - if (! empty($conf->global->STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO)) // Warning, this option may slow down combo list generation - { - $langs->load("stocks"); + if ($objp->stock > 0) { + $outval.= ' - '; + }elseif ($objp->stock <= 0) { + $outval.= ' - '; + } + $outval.= $langs->transnoentities("Stock").':'.$objp->stock; + $outval.= ''; + if (! empty($conf->global->STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO)) // Warning, this option may slow down combo list generation + { + $langs->load("stocks"); - $tmpproduct=new Product($this->db); - $tmpproduct->fetch($objp->rowid); - $tmpproduct->load_virtual_stock(); - $virtualstock = $tmpproduct->stock_theorique; + $tmpproduct=new Product($this->db); + $tmpproduct->fetch($objp->rowid); + $tmpproduct->load_virtual_stock(); + $virtualstock = $tmpproduct->stock_theorique; - $opt.= ' - '.$langs->trans("VirtualStock").':'.$virtualstock; + $opt.= ' - '.$langs->trans("VirtualStock").':'.$virtualstock; - $outval.=' - '.$langs->transnoentities("VirtualStock").':'; - if ($virtualstock > 0) { - $outval.= ' - '; - }elseif ($virtualstock <= 0) { - $outval.= ' - '; - } - $outval.=$virtualstock; - $outval.=''; + $outval.=' - '.$langs->transnoentities("VirtualStock").':'; + if ($virtualstock > 0) { + $outval.= ' - '; + }elseif ($virtualstock <= 0) { + $outval.= ' - '; + } + $outval.=$virtualstock; + $outval.=''; - unset($tmpproduct); - } + unset($tmpproduct); + } + } } $opt.= "\n"; diff --git a/htdocs/core/commonfieldsinexport.inc.php b/htdocs/core/commonfieldsinexport.inc.php index 9a84ae6c199..d68954fc568 100644 --- a/htdocs/core/commonfieldsinexport.inc.php +++ b/htdocs/core/commonfieldsinexport.inc.php @@ -6,6 +6,7 @@ if (empty($keyforclass) || empty($keyforclassfile) || empty($keyforelement)) dol_print_error('', 'include of file commonfieldsinexport.inc.php was done but var $keyforclass or $keyforclassfile or $keyforelement was not set'); exit; } +if (empty($keyforalias)) $keyforalias = 't'; dol_include_once($keyforclassfile); if (class_exists($keyforclass)) @@ -15,7 +16,7 @@ if (class_exists($keyforclass)) // Add common fields foreach($tmpobject->fields as $keyfield => $valuefield) { - $fieldname = 't' . '.' . $keyfield; + $fieldname = $keyforalias . '.' . $keyfield; $fieldlabel = ucfirst($valuefield['label']); $typeFilter = "Text"; $typefield=preg_replace('/\(.*$/', '', $valuefield['type']); // double(24,8) -> double diff --git a/htdocs/core/modules/modBom.class.php b/htdocs/core/modules/modBom.class.php index 92cd956a260..e333103fc8d 100644 --- a/htdocs/core/modules/modBom.class.php +++ b/htdocs/core/modules/modBom.class.php @@ -286,21 +286,26 @@ class modBom extends DolibarrModules $r=1; /* BEGIN MODULEBUILDER EXPORT BILLOFMATERIALS */ - /* - $langs->load("mrp@mrp"); + $langs->load("mrp"); $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]='BomLines'; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_label[$r]='BomAndBomLines'; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_icon[$r]='bom'; - $keyforclass = 'Bom'; $keyforclassfile='/mymobule/class/bom.class.php'; $keyforelement='bom'; + $keyforclass = 'BOM'; $keyforclassfile='/bom/class/bom.class.php'; $keyforelement='bom'; include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; - $keyforselect='bom'; $keyforaliasextra='extra'; $keyforelement='bom'; + $keyforclass = 'BOMLine'; $keyforclassfile='/bom/class/bom.class.php'; $keyforelement='bomline'; $keyforalias='tl'; + include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; + unset($this->export_fields_array[$r]['tl.fk_bom']); + $keyforselect ='bom_bom'; $keyforaliasextra='extra'; $keyforelement='bom'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) + $keyforselect ='bom_bomline'; $keyforaliasextra='extraline'; $keyforelement='bomline'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + $this->export_dependencies_array[$r]=array('bomline'=>'tl.rowid'); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'bom as t'; + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'bom_bom as t'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'bom_bomline as tl ON tl.fk_bom = t.rowid'; $this->export_sql_end[$r] .=' WHERE 1 = 1'; $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('bom').')'; - $r++; */ + $r++; /* END MODULEBUILDER EXPORT BILLOFMATERIALS */ } diff --git a/htdocs/core/modules/modDav.class.php b/htdocs/core/modules/modDav.class.php index fb0da933df5..c4c38898566 100644 --- a/htdocs/core/modules/modDav.class.php +++ b/htdocs/core/modules/modDav.class.php @@ -255,28 +255,6 @@ class modDav extends DolibarrModules 'target'=>'', 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both END MODULEBUILDER LEFTMENU MYOBJECT */ - - - // Exports - $r=1; - - /* BEGIN MODULEBUILDER EXPORT MYOBJECT */ - /* - $langs->load("dav@dav"); - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]='MyObjectLines'; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_icon[$r]='myobject@dav'; - $keyforclass = 'MyObject'; $keyforclassfile='/mymobule/class/myobject.class.php'; $keyforelement='myobject'; - include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; - $keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject'; - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'myobject as t'; - $this->export_sql_end[$r] .=' WHERE 1 = 1'; - $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')'; - $r++; */ - /* END MODULEBUILDER EXPORT MYOBJECT */ } /** diff --git a/htdocs/core/modules/modEmailCollector.class.php b/htdocs/core/modules/modEmailCollector.class.php index 19ad3f512e5..3c8bbcb5aec 100644 --- a/htdocs/core/modules/modEmailCollector.class.php +++ b/htdocs/core/modules/modEmailCollector.class.php @@ -252,28 +252,6 @@ class modEmailCollector extends DolibarrModules 'target'=>'', 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both END MODULEBUILDER LEFTMENU MYOBJECT */ - - - // Exports - $r=1; - - /* BEGIN MODULEBUILDER EXPORT MYOBJECT */ - /* - $langs->load("dav@dav"); - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]='MyObjectLines'; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_icon[$r]='myobject@dav'; - $keyforclass = 'MyObject'; $keyforclassfile='/mymobule/class/myobject.class.php'; $keyforelement='myobject'; - include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; - $keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject'; - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'myobject as t'; - $this->export_sql_end[$r] .=' WHERE 1 = 1'; - $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')'; - $r++; */ - /* END MODULEBUILDER EXPORT MYOBJECT */ } /** diff --git a/htdocs/core/modules/modTakePos.class.php b/htdocs/core/modules/modTakePos.class.php index 8c92d97710d..7024a151bb9 100644 --- a/htdocs/core/modules/modTakePos.class.php +++ b/htdocs/core/modules/modTakePos.class.php @@ -253,28 +253,6 @@ class modTakePos extends DolibarrModules 'target'=>'', 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both END MODULEBUILDER LEFTMENU MYOBJECT */ - - - // Exports - $r=1; - - /* BEGIN MODULEBUILDER EXPORT MYOBJECT */ - /* - $langs->load("cashdesk"); - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]='MyObjectLines'; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_icon[$r]='myobject@takepos'; - $keyforclass = 'MyObject'; $keyforclassfile='/mymobule/class/myobject.class.php'; $keyforelement='myobject'; - include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; - $keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject'; - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'myobject as t'; - $this->export_sql_end[$r] .=' WHERE 1 = 1'; - $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')'; - $r++; */ - /* END MODULEBUILDER EXPORT MYOBJECT */ } /** diff --git a/htdocs/core/modules/modWebsite.class.php b/htdocs/core/modules/modWebsite.class.php index 7c11a4b98b0..d4ffc02aaa8 100644 --- a/htdocs/core/modules/modWebsite.class.php +++ b/htdocs/core/modules/modWebsite.class.php @@ -134,7 +134,6 @@ class modWebsite extends DolibarrModules include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; //$keyforselect='myobject'; $keyforelement='myobject'; $keyforaliasextra='extra'; //include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'website_page as t, '.MAIN_DB_PREFIX.'website as p'; $this->export_sql_end[$r] .=' WHERE t.fk_website = p.rowid'; diff --git a/htdocs/core/modules/modZapier.class.php b/htdocs/core/modules/modZapier.class.php index fe8f43416f3..773298e9959 100644 --- a/htdocs/core/modules/modZapier.class.php +++ b/htdocs/core/modules/modZapier.class.php @@ -316,24 +316,6 @@ class modZapier extends DolibarrModules 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both ); */ - // Exports - $r=1; - /* EXPORT */ - /* - $langs->load("zapier@zapier"); - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]='MyObjectLines'; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_icon[$r]='myobject@zapier'; - $keyforclass = 'MyObject'; $keyforclassfile='/mymobule/class/myobject.class.php'; $keyforelement='myobject'; - include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; - $keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject'; - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'myobject as t'; - $this->export_sql_end[$r] .=' WHERE 1 = 1'; - $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')'; - $r++; */ } /** diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index 6190de933d7..ed6966eb083 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -73,7 +73,9 @@ $entitytoicon = array( 'expensereport_line'=> 'trip', 'holiday' => 'holiday', 'contract_line' => 'contract', - 'translation' => 'generic' + 'translation' => 'generic', + 'bomm' => 'bom', + 'bomline' => 'bom' ); // Translation code @@ -120,7 +122,9 @@ $entitytolang = array( 'holiday' => 'TitreRequestCP', 'contract' => 'Contract', 'contract_line'=> 'ContractLine', - 'translation' => 'Translation' + 'translation' => 'Translation', + 'bom' => 'BOM', + 'bomline' => 'BOMLine' ); $array_selected=isset($_SESSION["export_selected_fields"])?$_SESSION["export_selected_fields"]:array(); diff --git a/htdocs/install/mysql/data/llx_c_action_trigger.sql b/htdocs/install/mysql/data/llx_c_action_trigger.sql index abc961b49d5..406bfe88dbc 100644 --- a/htdocs/install/mysql/data/llx_c_action_trigger.sql +++ b/htdocs/install/mysql/data/llx_c_action_trigger.sql @@ -119,6 +119,14 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('FICHINTER_MODIFY','Intervention modified','Executed when a intervention is modified','ficheinter',19); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROJECT_CREATE','Project creation','Executed when a project is created','project',140); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROJECT_MODIFY','Project modified','Executed when a project is modified','project',142); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_VALIDATE','BOM validated','Executed when a BOM is validated','bom',400); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_UNVALIDATE','BOM unvalidated','Executed when a BOM is unvalidated','bom',401); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_CLOSE','BOM disabled','Executed when a BOM is disabled','bom',402); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_REOPEN','BOM reopen','Executed when a BOM is re-open','bom',403); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_DELETE','BOM deleted','Executed when a BOM deleted','bom',404); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_VALIDATE','MO validated','Executed when a MO is validated','bom',410); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_PRODUCED','MO disabled','Executed when a MO is produced','bom',411); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_DELETE','MO deleted','Executed when a MO is deleted','bom',412); -- actions not enabled by default : they are excluded when we enable the module Agenda (except TASK_...) insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TASK_CREATE','Task created','Executed when a project task is created','project',150); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TASK_MODIFY','Task modified','Executed when a project task is modified','project',151); diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 31ed3c7e693..13992a4c13c 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -58,6 +58,9 @@ UPDATE llx_rights_def SET subperms = 'write' WHERE perms = 'fiscalyear' AND modu ALTER TABLE llx_bom_bom ADD COLUMN duration double(8,4) DEFAULT NULL; ALTER TABLE llx_bom_bomline ADD COLUMN position integer NOT NULL DEFAULT 0; +ALTER TABLE llx_bom_bomline ADD COLUMN qty_frozen smallint DEFAULT 0; +ALTER TABLE llx_bom_bomline ADD COLUMN disable_stock_change smallint DEFAULT 0; + ALTER TABLE llx_bom_bomline DROP COLUMN rank; create table llx_categorie_warehouse @@ -410,3 +413,62 @@ create table llx_c_shipment_package_type entity integer DEFAULT 1 NOT NULL -- Multi company id )ENGINE=innodb; + +CREATE TABLE llx_mrp_mo( + -- BEGIN MODULEBUILDER FIELDS + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + ref varchar(128) DEFAULT '(PROV)' NOT NULL, + entity integer DEFAULT 1 NOT NULL, + label varchar(255), + qty real NOT NULL, + fk_warehouse integer, + fk_soc integer, + note_public text, + note_private text, + date_creation datetime NOT NULL, + tms timestamp, + fk_user_creat integer NOT NULL, + fk_user_modif integer, + import_key varchar(14), + status integer NOT NULL, + fk_product integer NOT NULL, + date_start_planned datetime, + date_end_planned datetime, + fk_bom integer, + fk_project integer + -- END MODULEBUILDER FIELDS +) ENGINE=innodb; + + +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_ref (ref); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_entity (entity); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_fk_soc (fk_soc); +ALTER TABLE llx_mrp_mo ADD CONSTRAINT llx_mrp_mo_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES user(rowid); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_status (status); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_fk_product (fk_product); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_date_start_planned (date_start_planned); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_date_end_planned (date_end_planned); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_fk_bom (fk_bom); +ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_fk_project (fk_project); + + +create table llx_mrp_myobject_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + +ALTER TABLE llx_mrp_myobject_extrafields ADD INDEX idx_fk_object(fk_object); + + +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_VALIDATE','BOM validated','Executed when a BOM is validated','bom',400); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_UNVALIDATE','BOM unvalidated','Executed when a BOM is unvalidated','bom',401); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_CLOSE','BOM disabled','Executed when a BOM is disabled','bom',402); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_REOPEN','BOM reopen','Executed when a BOM is re-open','bom',403); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_DELETE','BOM deleted','Executed when a BOM deleted','bom',404); + +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_VALIDATE','MO validated','Executed when a MO is validated','bom',410); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_PRODUCED','MO disabled','Executed when a MO is produced','bom',411); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_DELETE','MO deleted','Executed when a MO is deleted','bom',412); diff --git a/htdocs/install/mysql/tables/llx_bom_bomline.sql b/htdocs/install/mysql/tables/llx_bom_bomline.sql index 330f1bb18d6..3fa1c2be528 100644 --- a/htdocs/install/mysql/tables/llx_bom_bomline.sql +++ b/htdocs/install/mysql/tables/llx_bom_bomline.sql @@ -22,6 +22,8 @@ CREATE TABLE llx_bom_bomline( description text, import_key varchar(14), qty double(24,8) NOT NULL, + qty_frozen smallint DEFAULT 0, + disable_stock_change smallint DEFAULT 0, efficiency double(8,4) NOT NULL DEFAULT 1, position integer NOT NULL DEFAULT 0 -- END MODULEBUILDER FIELDS diff --git a/htdocs/mrp/sql/llx_mrp_mo.key.sql b/htdocs/install/mysql/tables/llx_mrp_mo.key.sql similarity index 93% rename from htdocs/mrp/sql/llx_mrp_mo.key.sql rename to htdocs/install/mysql/tables/llx_mrp_mo.key.sql index 071a663dd56..8cda73f9450 100644 --- a/htdocs/mrp/sql/llx_mrp_mo.key.sql +++ b/htdocs/install/mysql/tables/llx_mrp_mo.key.sql @@ -15,10 +15,8 @@ -- BEGIN MODULEBUILDER INDEXES -ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_rowid (rowid); ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_ref (ref); ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_entity (entity); -ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_qty (qty); ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_fk_soc (fk_soc); ALTER TABLE llx_mrp_mo ADD CONSTRAINT llx_mrp_mo_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES user(rowid); ALTER TABLE llx_mrp_mo ADD INDEX idx_mrp_mo_status (status); diff --git a/htdocs/mrp/sql/llx_mrp_mo.sql b/htdocs/install/mysql/tables/llx_mrp_mo.sql similarity index 96% rename from htdocs/mrp/sql/llx_mrp_mo.sql rename to htdocs/install/mysql/tables/llx_mrp_mo.sql index dbb8b0faa01..52a046191dc 100644 --- a/htdocs/mrp/sql/llx_mrp_mo.sql +++ b/htdocs/install/mysql/tables/llx_mrp_mo.sql @@ -20,7 +20,8 @@ CREATE TABLE llx_mrp_mo( ref varchar(128) DEFAULT '(PROV)' NOT NULL, entity integer DEFAULT 1 NOT NULL, label varchar(255), - qty real NOT NULL, + qty real NOT NULL, + fk_warehouse integer, fk_soc integer, note_public text, note_private text, diff --git a/htdocs/mrp/sql/llx_mrp_mo_extrafields.key.sql b/htdocs/install/mysql/tables/llx_mrp_mo_extrafields.key.sql similarity index 100% rename from htdocs/mrp/sql/llx_mrp_mo_extrafields.key.sql rename to htdocs/install/mysql/tables/llx_mrp_mo_extrafields.key.sql diff --git a/htdocs/mrp/sql/llx_mrp_mo_extrafields.sql b/htdocs/install/mysql/tables/llx_mrp_mo_extrafields.sql similarity index 100% rename from htdocs/mrp/sql/llx_mrp_mo_extrafields.sql rename to htdocs/install/mysql/tables/llx_mrp_mo_extrafields.sql diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 0b47f9b5e54..8bd954b306b 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -114,6 +114,7 @@ InformationToHelpDiagnose=This information can be useful for diagnostic purposes MoreInformation=More information TechnicalInformation=Technical information TechnicalID=Technical ID +LineID=Line ID NotePublic=Note (public) NotePrivate=Note (private) PrecisionUnitIsLimitedToXDecimals=Dolibarr was setup to limit precision of unit prices to %s decimals. diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index 5d51be56e56..1de5f40c79c 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -31,4 +31,13 @@ EstimatedDuration=Estimated duration EstimatedDurationDesc=Estimated duration to manufacture this product using this BOM ConfirmValidateBom=Are you sure you want to validate the BOM with the reference %s (you will be able to use it to build new Manufacturing Orders) ConfirmCloseBom=Are you sure you want to cancel this BOM (you won't be able to use it to build new Manufacturing Orders anymore) ? -ConfirmReopenBom=Are you sure you want to re-open this BOM (you will be able to use it to build new Manufacturing Orders) \ No newline at end of file +ConfirmReopenBom=Are you sure you want to re-open this BOM (you will be able to use it to build new Manufacturing Orders) +StatusMOProduced=Produced +QtyFrozen=Frozen Qty +QuantityFrozen=Frozen Quantity +QuantityConsumedInvariable=When this flag is set, the quantity consumed is always the value defined and is not relative to the quantity produced. +DisableStockChange=Disable stock change +DisableStockChangeHelp=When this flag is set, there is no stock change on this product, whatever is the quantity produced +BomAndBomLines=Bills Of Material and lines +BOMLine=Line of BOM +WarehouseForProduction=Warehouse for production \ No newline at end of file diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index d6474a480dc..41d0af33d46 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -71,7 +71,7 @@ class MyObject extends CommonObject * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). Using a negative value means field is not shown by default on list but can be selected for viewing) * 'noteditable' says if field is not editable (1 or 0) * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). - * 'default' is a default value for creation (can still be replaced by the global setup of default values) + * 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created. * 'index' if we want an index in database. * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). * 'position' is the sort order of field. @@ -283,8 +283,9 @@ class MyObject extends CommonObject // Clear fields - $object->ref = "copy_of_".$object->ref; - $object->title = $langs->trans("CopyOf")." ".$object->title; + $object->ref = empty($this->fields['ref']['default']) ? "copy_of_".$object->ref: $this->fields['ref']['default']; + $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label: $this->fields['label']['default']; + $object->status = self::STATUS_DRAFT; // ... // Clear extrafields that are unique if (is_array($object->array_options) && count($object->array_options) > 0) diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 026f46fb925..6b522a45364 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -336,11 +336,16 @@ class modMyModule extends DolibarrModules $this->export_icon[$r]='myobject@mymodule'; $keyforclass = 'MyObject'; $keyforclassfile='/mymobule/class/myobject.class.php'; $keyforelement='myobject'; include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; + //$keyforclass = 'MyObjectLine'; $keyforclassfile='/mymodule/class/myobject.class.php'; $keyforelement='myobjectline'; $keyforalias='tl'; + //include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; $keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) + //$keyforselect='myobjectline'; $keyforaliasextra='extraline'; $keyforelement='myobjectline'; + //include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + //$this->export_dependencies_array[$r]=array('myobjectline'=>array('tl.rowid','tl.ref')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'myobject as t'; + //$this->export_sql_end[$r] =' LEFT JOIN '.MAIN_DB_PREFIX.'myobject_line as tl ON tl.fk_myobject = t.rowid'; $this->export_sql_end[$r] .=' WHERE 1 = 1'; $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')'; $r++; */ diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 4f069e885bd..0525f71ab5f 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -61,7 +61,7 @@ class Mo extends CommonObject const STATUS_DRAFT = 0; const STATUS_VALIDATED = 1; // To produce const STATUS_INPROGRESS = 2; - const STATUS_DONE = 3; + const STATUS_PRODUCED = 3; const STATUS_CANCELED = -1; @@ -92,12 +92,13 @@ class Mo extends CommonObject */ public $fields=array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), - 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'position'=>10, 'notnull'=>1, 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'showoncombobox'=>'1',), - 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>-1, 'position'=>20, 'notnull'=>1, 'default'=>'1', 'index'=>1,), + 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>4, 'position'=>10, 'notnull'=>1, 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'showoncombobox'=>'1',), + 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'position'=>20, 'notnull'=>1, 'default'=>'1', 'index'=>1,), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1, 'showoncombobox'=>'1',), - 'qty' => array('type'=>'real', 'label'=>'QtyToProduce', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'notnull'=>1, 'index'=>1, 'comment'=>"Qty to produce",), + 'qty' => array('type'=>'real', 'label'=>'QtyToProduce', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'notnull'=>1, 'comment'=>"Qty to produce",), 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'position'=>50, 'notnull'=>-1, 'index'=>1), - 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61, 'notnull'=>-1,), + 'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php:0', 'label'=>'WarehouseForProduction', 'enabled'=>1, 'visible'=>-1, 'position'=>52), + 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61, 'notnull'=>-1,), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62, 'notnull'=>-1,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>500, 'notnull'=>1,), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'position'=>501, 'notnull'=>-1,), @@ -109,13 +110,14 @@ class Mo extends CommonObject 'date_end_planned' => array('type'=>'datetime', 'label'=>'DateEndPlannedMo', 'enabled'=>1, 'visible'=>1, 'position'=>56, 'notnull'=>-1, 'index'=>1,), 'fk_bom' => array('type'=>'integer:Bom:bom/class/bom.class.php:0:t.status=1', 'filter'=>'active=1', 'label'=>'BOM', 'enabled'=>1, 'visible'=>1, 'position'=>33, 'notnull'=>-1, 'index'=>1, 'comment'=>"Original BOM",), 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1,), - 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>4, 'position'=>1000, 'default'=>0, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Validated', '2'=>'InProgress', '3'=>'Done', '-1'=>'Canceled')), + 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>4, 'position'=>1000, 'default'=>0, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Validated', '2'=>'InProgress', '3'=>'StatusMOProduced', '-1'=>'Canceled')), ); public $rowid; public $ref; public $entity; public $label; public $qty; + public $fk_warehouse; public $fk_soc; public $note_public; public $note_private; @@ -246,10 +248,10 @@ class Mo extends CommonObject unset($object->fk_user_creat); unset($object->import_key); - // Clear fields - $object->ref = "copy_of_".$object->ref; - $object->title = $langs->trans("CopyOf")." ".$object->title; + $object->ref = empty($this->fields['ref']['default']) ? "copy_of_".$object->ref: $this->fields['ref']['default']; + $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label: $this->fields['label']['default']; + $object->status = self::STATUS_DRAFT; // ... // Clear extrafields that are unique if (is_array($object->array_options) && count($object->array_options) > 0) @@ -549,8 +551,10 @@ class Mo extends CommonObject global $langs; //$langs->load("mrp"); $this->labelstatus[self::STATUS_DRAFT] = $langs->trans('Draft'); - $this->labelstatus[self::STATUS_VALIDATED] = $langs->trans('Enabled'); - $this->labelstatus[self::STATUS_CANCELED] = $langs->trans('Disabled'); + $this->labelstatus[self::STATUS_VALIDATED] = $langs->trans('Validated'); + $this->labelstatus[self::STATUS_INPROGRESS] = $langs->trans('InProgress'); + $this->labelstatus[self::STATUS_PRODUCED] = $langs->trans('StatusMOProduced'); + $this->labelstatus[self::STATUS_CANCELED] = $langs->trans('Canceled'); } $statusType = 'status'.$status; diff --git a/htdocs/mrp/index.php b/htdocs/mrp/index.php index 2a3249efdd9..18cef7f75ea 100644 --- a/htdocs/mrp/index.php +++ b/htdocs/mrp/index.php @@ -28,6 +28,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; +require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; $hookmanager = new HookManager($db); @@ -46,6 +47,7 @@ $result=restrictedArea($user, 'bom|mrp'); */ $staticbom = new BOM($db); +$staticmo = new Mo($db); llxHeader('', $langs->trans("MRP"), ''); @@ -81,7 +83,7 @@ if ($conf->use_javascript_ajax) { //if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1)) { - $dataseries[$obj->status]=$obj->nb; + $dataseries[$obj->status]=array(0=>$staticmo->LibStatut($obj->status), $obj->nb); $totalnb+=$obj->nb; } } diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index 7a26660d6dc..356ea7bb07f 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -369,7 +369,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''."\n"; // Common attributes - $keyforbreak='qty'; + $keyforbreak='fk_warehouse'; unset($object->fields['fk_project']); unset($object->fields['fk_soc']); include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index 734af5cb7ff..b8d733789fc 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -144,7 +144,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele foreach($listofsearchfields as $key => $value) { if ($i == 0) print ''; - print ''; + print ''; print ''; if ($i == 0) print ''; print '';
'.$langs->trans("Search").'