WIP Complete module MRP
This commit is contained in:
parent
2b5866aca2
commit
9e479afff1
@ -4118,7 +4118,7 @@ abstract class CommonObject
|
||||
|
||||
$i = 0;
|
||||
|
||||
print "<tbody>\n";
|
||||
print "<!-- begin printObjectLines() --><tbody>\n";
|
||||
foreach ($this->lines as $line)
|
||||
{
|
||||
//Line extrafield
|
||||
|
||||
@ -157,32 +157,32 @@ class Mo extends CommonObject
|
||||
/**
|
||||
* @var int Name of subtable line
|
||||
*/
|
||||
//public $table_element_line = 'mrp_moline';
|
||||
public $table_element_line = 'mo_production';
|
||||
|
||||
/**
|
||||
* @var int Field with ID of parent key if this field has a parent
|
||||
*/
|
||||
//public $fk_element = 'fk_mo';
|
||||
public $fk_element = 'fk_mo';
|
||||
|
||||
/**
|
||||
* @var int Name of subtable class that manage subtable lines
|
||||
*/
|
||||
//public $class_element_line = 'Moline';
|
||||
public $class_element_line = 'MoLine';
|
||||
|
||||
/**
|
||||
* @var array List of child tables. To test if we can delete object.
|
||||
*/
|
||||
//protected $childtables=array();
|
||||
protected $childtables=array('mrp_production');
|
||||
|
||||
/**
|
||||
* @var array List of child tables. To know object to delete on cascade.
|
||||
*/
|
||||
//protected $childtablesoncascade=array('mrp_modet');
|
||||
protected $childtablesoncascade=array('mrp_production');
|
||||
|
||||
/**
|
||||
* @var MoLine[] Array of subtable lines
|
||||
*/
|
||||
//public $lines = array();
|
||||
public $lines = array();
|
||||
|
||||
|
||||
|
||||
@ -252,7 +252,7 @@ class Mo extends CommonObject
|
||||
{
|
||||
foreach($bom->lines as $line)
|
||||
{
|
||||
$moline = new MOLine($this->db);
|
||||
$moline = new MoLine($this->db);
|
||||
|
||||
$moline->fk_mo = $this->id;
|
||||
$moline->qty = $line->qty * $this->qty * $bom->efficiency;
|
||||
@ -1007,6 +1007,85 @@ class MoLine extends CommonObjectLine
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load list of objects in memory from the database.
|
||||
*
|
||||
* @param string $sortorder Sort Order
|
||||
* @param string $sortfield Sort field
|
||||
* @param int $limit limit
|
||||
* @param int $offset Offset
|
||||
* @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...)
|
||||
* @param string $filtermode Filter mode (AND or OR)
|
||||
* @return array|int int <0 if KO, array of pages if OK
|
||||
*/
|
||||
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
|
||||
$records = array();
|
||||
|
||||
$sql = 'SELECT ';
|
||||
$sql .= $this->getFieldList();
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
|
||||
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')';
|
||||
else $sql .= ' WHERE 1 = 1';
|
||||
// Manage filter
|
||||
$sqlwhere = array();
|
||||
if (count($filter) > 0) {
|
||||
foreach ($filter as $key => $value) {
|
||||
if ($key == 't.rowid') {
|
||||
$sqlwhere[] = $key.'='.$value;
|
||||
}
|
||||
elseif (strpos($key, 'date') !== false) {
|
||||
$sqlwhere[] = $key.' = \''.$this->db->idate($value).'\'';
|
||||
}
|
||||
elseif ($key == 'customsql') {
|
||||
$sqlwhere[] = $value;
|
||||
}
|
||||
else {
|
||||
$sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\'';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count($sqlwhere) > 0) {
|
||||
$sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')';
|
||||
}
|
||||
|
||||
if (!empty($sortfield)) {
|
||||
$sql .= $this->db->order($sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($limit)) {
|
||||
$sql .= ' '.$this->db->plimit($limit, $offset);
|
||||
}
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < min($limit, $num))
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$record = new self($this->db);
|
||||
$record->setVarsFromFetchObj($obj);
|
||||
|
||||
$records[$record->id] = $record;
|
||||
|
||||
$i++;
|
||||
}
|
||||
$this->db->free($resql);
|
||||
|
||||
return $records;
|
||||
} else {
|
||||
$this->errors[] = 'Error '.$this->db->lasterror();
|
||||
dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update object into database
|
||||
*
|
||||
|
||||
@ -504,9 +504,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
|
||||
{
|
||||
print '<table id="tablelines" class="noborder noshadow" width="100%">';
|
||||
|
||||
print '<tr><td>TODO...</td></tr>';
|
||||
}
|
||||
|
||||
if (!empty($object->lines))
|
||||
/*if (!empty($object->lines))
|
||||
{
|
||||
$object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/mrp/tpl');
|
||||
}
|
||||
@ -522,7 +524,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
|
||||
{
|
||||
@ -530,6 +532,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
}
|
||||
print '</div>';
|
||||
|
||||
|
||||
print "</form>\n";
|
||||
}
|
||||
|
||||
|
||||
@ -326,13 +326,20 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
|
||||
}
|
||||
|
||||
$object->fetchLines();
|
||||
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
|
||||
{
|
||||
print '<table id="tablelines" class="noborder noshadow" width="100%">';
|
||||
print '<table id="tablelines" class="noborder noshadow" width="100%">';
|
||||
|
||||
print '<tr><td>TODO...</td></tr>';
|
||||
|
||||
//var_dump($object->lines);
|
||||
|
||||
}
|
||||
|
||||
if (!empty($object->lines))
|
||||
/*if (!empty($object->lines))
|
||||
{
|
||||
$object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/mrp/tpl');
|
||||
}
|
||||
@ -348,7 +355,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user