28require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobjectline.class.php';
38 public $element =
'mrp_production';
43 public $table_element =
'mrp_production';
96 'rowid' => array(
'type' =>
'integer',
'label' =>
'ID',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 10),
97 'fk_mo' => array(
'type' =>
'integer',
'label' =>
'Mo',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 15),
98 'origin_id' => array(
'type' =>
'integer',
'label' =>
'Origin',
'enabled' => 1,
'visible' => -1,
'notnull' => 0,
'position' => 17),
99 'origin_type' => array(
'type' =>
'varchar(10)',
'label' =>
'Origin type',
'enabled' => 1,
'visible' => -1,
'notnull' => 0,
'position' => 18),
100 'position' => array(
'type' =>
'integer',
'label' =>
'Position',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 20),
101 'fk_product' => array(
'type' =>
'integer',
'label' =>
'Product',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 25),
102 'fk_warehouse' => array(
'type' =>
'integer',
'label' =>
'Warehouse',
'enabled' => 1,
'visible' => -1,
'position' => 30),
103 'qty' => array(
'type' =>
'real',
'label' =>
'Qty',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 35),
104 'qty_frozen' => array(
'type' =>
'smallint',
'label' =>
'QuantityFrozen',
'enabled' => 1,
'visible' => 1,
'default' =>
'0',
'notnull' => 1,
'position' => 105,
'css' =>
'maxwidth50imp',
'help' =>
'QuantityConsumedInvariable'),
105 'disable_stock_change' => array(
'type' =>
'smallint',
'label' =>
'DisableStockChange',
'enabled' => 1,
'visible' => 1,
'default' =>
'0',
'notnull' => 1,
'position' => 108,
'css' =>
'maxwidth50imp',
'help' =>
'DisableStockChangeHelp'),
106 'batch' => array(
'type' =>
'varchar(30)',
'label' =>
'Batch',
'enabled' => 1,
'visible' => -1,
'position' => 140),
107 'role' => array(
'type' =>
'varchar(10)',
'label' =>
'Role',
'enabled' => 1,
'visible' => -1,
'position' => 145),
108 'fk_mrp_production' => array(
'type' =>
'integer',
'label' =>
'Fk mrp production',
'enabled' => 1,
'visible' => -1,
'position' => 150),
109 'fk_stock_movement' => array(
'type' =>
'integer',
'label' =>
'StockMovement',
'enabled' => 1,
'visible' => -1,
'position' => 155),
110 'date_creation' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'visible' => -2,
'notnull' => 1,
'position' => 160),
111 'tms' => array(
'type' =>
'timestamp',
'label' =>
'Tms',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 165),
112 'fk_user_creat' => array(
'type' =>
'integer',
'label' =>
'UserCreation',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 170),
113 'fk_user_modif' => array(
'type' =>
'integer',
'label' =>
'UserModification',
'enabled' => 1,
'visible' => -1,
'position' => 175),
114 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'visible' => -1,
'position' => 180),
115 'fk_default_workstation' => array(
'type' =>
'integer',
'label' =>
'DefaultWorkstation',
'enabled' => 1,
'visible' => 1,
'notnull' => 0,
'position' => 185),
116 'fk_unit' => array(
'type' =>
'int',
'label' =>
'Unit',
'enabled' => 1,
'visible' => 1,
'notnull' => 0,
'position' => 186)
146 public $fk_warehouse;
160 public $disable_stock_change;
177 public $fk_mrp_production;
181 public $fk_stock_movement;
189 public $fk_parent_line;
198 public $fk_default_workstation;
211 $this->ismultientitymanaged = 0;
212 $this->isextrafieldmanaged = 1;
215 $this->fields[
'rowid'][
'visible'] = 0;
217 if (!isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
218 $this->fields[
'entity'][
'enabled'] = 0;
222 foreach ($this->fields as $key => $val) {
223 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
224 unset($this->fields[$key]);
229 if (is_object($langs)) {
230 foreach ($this->fields as $key => $val) {
231 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
232 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
233 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
249 if (empty($this->qty)) {
250 $this->error =
'ErrorEmptyValueForQty';
264 public function fetch($id, $ref =
null)
281 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, $filter =
'', $filtermode =
'AND')
289 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
290 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
291 $sql .=
' WHERE t.entity IN ('.getEntity($this->element).
')';
293 $sql .=
' WHERE 1 = 1';
297 if (is_array($filter)) {
299 if (count($filter) > 0) {
300 foreach ($filter as $key => $value) {
301 if ($key ==
't.rowid') {
302 $sqlwhere[] = $key.
" = ".((int) $value);
303 } elseif (strpos($key,
'date') !==
false) {
304 $sqlwhere[] = $key.
" = '".$this->db->idate($value).
"'";
306 $sqlwhere[] = $key.
" LIKE '%".$this->db->escape($this->db->escapeforlike($value)).
"%'";
310 if (count($sqlwhere) > 0) {
311 $sql .=
' AND ('.implode(
' '.$this->db->escape($filtermode).
' ', $sqlwhere).
')';
321 $this->errors[] = $errormessage;
322 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
326 if (!empty($sortfield)) {
327 $sql .= $this->db->order($sortfield, $sortorder);
329 if (!empty($limit)) {
330 $sql .= $this->db->plimit($limit, $offset);
333 $resql = $this->db->query($sql);
335 $num = $this->db->num_rows($resql);
337 while ($i < ($limit ? min($limit, $num) : $num)) {
338 $obj = $this->db->fetch_object($resql);
340 $record =
new self($this->db);
341 $record->setVarsFromFetchObj($obj);
343 $records[$record->id] = $record;
347 $this->db->free($resql);
351 $this->errors[] =
'Error '.$this->db->lasterror();
352 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
377 public function delete(
User $user, $notrigger = 0)
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.
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.
update(User $user, $notrigger=0)
Update object into database.
create(User $user, $notrigger=0)
Create object into database.
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, $filter='', $filtermode='AND')
Load list of objects in memory from the database.
__construct(DoliDB $db)
Constructor.
fetch($id, $ref=null)
Load object in memory from the database.
$fields
'type' field format: 'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortf...
Class to manage Dolibarr users.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
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.