29require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobjectline.class.php';
39 public $element =
'bomline';
44 public $table_element =
'bom_bomline';
59 public $picto =
'bomline';
85 public $fields = array(
86 'rowid' => array(
'type' =>
'integer',
'label' =>
'LineID',
'enabled' => 1,
'visible' => -1,
'position' => 1,
'notnull' => 1,
'index' => 1,
'comment' =>
"Id",),
87 'fk_bom' => array(
'type' =>
'integer:BillOfMaterials:societe/class/bom.class.php',
'label' =>
'BillOfMaterials',
'enabled' => 1,
'visible' => 1,
'position' => 10,
'notnull' => 1,
'index' => 1,),
88 'fk_product' => array(
'type' =>
'integer:Product:product/class/product.class.php',
'label' =>
'Product',
'enabled' => 1,
'visible' => 1,
'position' => 20,
'notnull' => 1,
'index' => 1,),
89 'fk_bom_child' => array(
'type' =>
'integer:BOM:bom/class/bom.class.php',
'label' =>
'BillOfMaterials',
'enabled' => 1,
'visible' => -1,
'position' => 40,
'notnull' => -1,),
90 'description' => array(
'type' =>
'text',
'label' =>
'Description',
'enabled' => 1,
'visible' => -1,
'position' => 60,
'notnull' => -1,),
91 'qty' => array(
'type' =>
'double(24,8)',
'label' =>
'Quantity',
'enabled' => 1,
'visible' => 1,
'position' => 100,
'notnull' => 1,
'isameasure' => 1,),
92 'qty_frozen' => array(
'type' =>
'smallint',
'label' =>
'QuantityFrozen',
'enabled' => 1,
'visible' => 1,
'default' =>
'0',
'position' => 105,
'css' =>
'maxwidth50imp',
'help' =>
'QuantityConsumedInvariable'),
93 'disable_stock_change' => array(
'type' =>
'smallint',
'label' =>
'DisableStockChange',
'enabled' => 1,
'visible' => 1,
'default' =>
'0',
'position' => 108,
'css' =>
'maxwidth50imp',
'help' =>
'DisableStockChangeHelp'),
94 'efficiency' => array(
'type' =>
'double(24,8)',
'label' =>
'ManufacturingEfficiency',
'enabled' => 1,
'visible' => 0,
'default' =>
'1',
'position' => 110,
'notnull' => 1,
'css' =>
'maxwidth50imp',
'help' =>
'ValueOfEfficiencyConsumedMeans'),
95 'fk_unit' => array(
'type' =>
'integer',
'label' =>
'Unit',
'enabled' => 1,
'visible' => 1,
'position' => 120,
'notnull' => -1,),
96 'position' => array(
'type' =>
'integer',
'label' =>
'Rank',
'enabled' => 1,
'visible' => 0,
'default' =>
'0',
'position' => 200,
'notnull' => 1,),
97 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'visible' => -2,
'position' => 1000,
'notnull' => -1,),
98 'fk_default_workstation' => array(
'type' =>
'integer',
'label' =>
'DefaultWorkstation',
'enabled' => 1,
'visible' => 1,
'notnull' => 0,
'position' => 1050)
119 public $fk_bom_child;
139 public $disable_stock_change;
156 public $fk_default_workstation;
172 public $total_cost = 0;
177 public $unit_cost = 0;
182 public $childBom = array();
197 $this->ismultientitymanaged = 0;
199 $this->isextrafieldmanaged = 1;
202 $this->fields[
'rowid'][
'visible'] = 0;
204 if (!
isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
205 $this->fields[
'entity'][
'enabled'] = 0;
209 foreach ($this->fields as $key => $val) {
210 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
211 unset($this->fields[$key]);
216 if (is_object($langs)) {
217 foreach ($this->fields as $key => $val) {
218 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
219 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
220 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
236 if ($this->efficiency < 0 || $this->efficiency > 1) {
237 $this->efficiency = 1;
250 public function fetch($id, $ref =
null)
269 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, $filter =
'', $filtermode =
'AND')
277 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
278 if ($this->ismultientitymanaged) {
279 $sql .=
' WHERE t.entity IN ('.getEntity($this->element).
')';
281 $sql .=
' WHERE 1 = 1';
288 $this->errors[] = $errormessage;
289 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
293 if (!empty($sortfield)) {
294 $sql .= $this->db->order($sortfield, $sortorder);
296 if (!empty($limit)) {
297 $sql .= $this->db->plimit($limit, $offset);
300 $resql = $this->db->query($sql);
302 $num = $this->db->num_rows($resql);
304 while ($obj = $this->db->fetch_object($resql)) {
305 $record =
new self($this->db);
306 $record->setVarsFromFetchObj($obj);
307 $record->fetch_optionals();
309 $records[$record->id] = $record;
311 $this->db->free($resql);
315 $this->errors[] =
'Error '.$this->db->lasterror();
316 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
331 if ($this->efficiency < 0 || $this->efficiency > 1) {
332 $this->efficiency = 1;
345 public function delete(
User $user, $notrigger = 0)
361 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
363 global $db,
$conf, $langs, $hookmanager;
365 if (!empty(
$conf->dol_no_mouse_hover)) {
371 $label =
'<u>'.$langs->trans(
"BillOfMaterialsLine").
'</u>';
373 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
375 $url = DOL_URL_ROOT.
'/bom/bomline_card.php?id='.$this->id;
377 if ($option !=
'nolink') {
379 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
380 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
381 $add_save_lastsearch_values = 1;
383 if ($add_save_lastsearch_values) {
384 $url .=
'&save_lastsearch_values=1';
389 if (empty($notooltip)) {
391 $label = $langs->trans(
"ShowBillOfMaterialsLine");
392 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label).
'"';
394 $linkclose .=
' title="'.dolPrintHTMLForAttribute($label).
'"';
395 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
397 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
400 $linkstart =
'<a href="'.$url.
'"';
401 $linkstart .= $linkclose.
'>';
404 $result .= $linkstart;
406 $result .= img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
408 if ($withpicto != 2) {
409 $result .= $this->ref;
414 global $action, $hookmanager;
415 $hookmanager->initHooks(array(
'bomlinedao'));
416 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
417 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
419 $result = $hookmanager->resPrint;
421 $result .= $hookmanager->resPrint;
460 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
461 $sql .=
' fk_user_creat, fk_user_modif';
462 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
463 $sql .=
' WHERE t.rowid = '.((int) $id);
464 $result = $this->db->query($sql);
466 if ($this->db->num_rows($result)) {
467 $obj = $this->db->fetch_object($result);
469 $this->
id = $obj->rowid;
471 $this->user_creation_id = $obj->fk_user_creat;
472 $this->user_modification_id = $obj->fk_user_modif;
473 $this->date_creation = $this->db->jdate($obj->datec);
474 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
476 $this->db->free($result);
478 dol_print_error($this->db);
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
fetch($id, $ref=null)
Load object in memory from the database.
getLibStatut($mode=0)
Return label of the status.
__construct(DoliDB $db)
Constructor.
update(User $user, $notrigger=0)
Update object into database.
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, $filter='', $filtermode='AND')
Load list of objects in memory from the database.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionally the picto)
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
info($id)
Load the info information in the object.
LibStatut($status, $mode=0)
Return the status.
create(User $user, $notrigger=0)
Create object into database.
createCommon(User $user, $notrigger=0)
Create object in the database.
getFieldList($alias='', $excludefields=array())
Function to concat keys of fields.
updateCommon(User $user, $notrigger=0)
Update object into database.
initAsSpecimenCommon()
Initialise object with example values Id must be 0 if object instance is a specimen.
fetchCommon($id, $ref=null, $morewhere='', $noextrafields=0)
Load object in memory from the database.
deleteCommon(User $user, $notrigger=0, $forcechilddeletion=0)
Delete object in database.
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
Class to manage Dolibarr database access.
Class to manage Dolibarr users.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0, $forbiddenfields=array())
forgeSQLFromUniversalSearchCriteria
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.