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 foreach ($this->fields as $key => $val) {
217 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
218 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
219 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
234 if ($this->efficiency < 0 || $this->efficiency > 1) {
235 $this->efficiency = 1;
248 public function fetch($id, $ref =
null)
267 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, $filter =
'', $filtermode =
'AND')
275 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
276 if ($this->ismultientitymanaged) {
277 $sql .=
' WHERE t.entity IN ('.getEntity($this->element).
')';
279 $sql .=
' WHERE 1 = 1';
286 $this->errors[] = $errormessage;
287 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
291 if (!empty($sortfield)) {
292 $sql .= $this->db->order($sortfield, $sortorder);
294 if (!empty($limit)) {
295 $sql .= $this->db->plimit($limit, $offset);
298 $resql = $this->db->query($sql);
300 $num = $this->db->num_rows($resql);
302 while ($obj = $this->db->fetch_object($resql)) {
303 $record =
new self($this->db);
304 $record->setVarsFromFetchObj($obj);
305 $record->fetch_optionals();
307 $records[$record->id] = $record;
309 $this->db->free($resql);
313 $this->errors[] =
'Error '.$this->db->lasterror();
314 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
329 if ($this->efficiency < 0 || $this->efficiency > 1) {
330 $this->efficiency = 1;
343 public function delete(
User $user, $notrigger = 0)
359 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
361 global $db,
$conf, $langs, $hookmanager;
363 if (!empty(
$conf->dol_no_mouse_hover)) {
369 $label =
'<u>'.$langs->trans(
"BillOfMaterialsLine").
'</u>';
371 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
373 $url = DOL_URL_ROOT.
'/bom/bomline_card.php?id='.$this->id;
375 if ($option !=
'nolink') {
377 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
378 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
379 $add_save_lastsearch_values = 1;
381 if ($add_save_lastsearch_values) {
382 $url .=
'&save_lastsearch_values=1';
387 if (empty($notooltip)) {
389 $label = $langs->trans(
"ShowBillOfMaterialsLine");
390 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
392 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
393 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
395 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
398 $linkstart =
'<a href="'.$url.
'"';
399 $linkstart .= $linkclose.
'>';
402 $result .= $linkstart;
404 $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);
406 if ($withpicto != 2) {
407 $result .= $this->ref;
412 global $action, $hookmanager;
413 $hookmanager->initHooks(array(
'bomlinedao'));
414 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
415 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
417 $result = $hookmanager->resPrint;
419 $result .= $hookmanager->resPrint;
458 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
459 $sql .=
' fk_user_creat, fk_user_modif';
460 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
461 $sql .=
' WHERE t.rowid = '.((int) $id);
462 $result = $this->db->query($sql);
464 if ($this->db->num_rows($result)) {
465 $obj = $this->db->fetch_object($result);
467 $this->
id = $obj->rowid;
469 $this->user_creation_id = $obj->fk_user_creat;
470 $this->user_modification_id = $obj->fk_user_modif;
471 $this->date_creation = $this->db->jdate($obj->datec);
472 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
474 $this->db->free($result);
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...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...