Merge pull request #20625 from Easya-Solutions/new-inventory-category-field
NEW Can use products categories to make inventory
This commit is contained in:
commit
da8a9e6082
@ -61,7 +61,7 @@ if ($action == 'add' && !empty($permissiontoadd)) {
|
|||||||
continue; // The field was not submited to be saved
|
continue; // The field was not submited to be saved
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!GETPOSTISSET($key)) {
|
if (!GETPOSTISSET($key) && !preg_match('/^chkbxlst:/', $object->fields[$key]['type'])) {
|
||||||
continue; // The field was not submited to be saved
|
continue; // The field was not submited to be saved
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,6 +91,12 @@ if ($action == 'add' && !empty($permissiontoadd)) {
|
|||||||
} elseif ($object->fields[$key]['type'] == 'reference') {
|
} elseif ($object->fields[$key]['type'] == 'reference') {
|
||||||
$tmparraykey = array_keys($object->param_list);
|
$tmparraykey = array_keys($object->param_list);
|
||||||
$value = $tmparraykey[GETPOST($key)].','.GETPOST($key.'2');
|
$value = $tmparraykey[GETPOST($key)].','.GETPOST($key.'2');
|
||||||
|
} elseif (preg_match('/^chkbxlst:(.*)/', $object->fields[$key]['type'])) {
|
||||||
|
$value = '';
|
||||||
|
$values_arr = GETPOST($key, 'array');
|
||||||
|
if (!empty($values_arr)) {
|
||||||
|
$value = implode(',', $values_arr);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($key == 'lang') {
|
if ($key == 'lang') {
|
||||||
$value = GETPOST($key, 'aZ09') ?GETPOST($key, 'aZ09') : "";
|
$value = GETPOST($key, 'aZ09') ?GETPOST($key, 'aZ09') : "";
|
||||||
@ -184,7 +190,7 @@ if ($action == 'update' && !empty($permissiontoadd)) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!GETPOSTISSET($key)) {
|
if (!GETPOSTISSET($key) && !preg_match('/^chkbxlst:/', $object->fields[$key]['type'])) {
|
||||||
continue; // The field was not submited to be saved
|
continue; // The field was not submited to be saved
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -222,6 +228,12 @@ if ($action == 'update' && !empty($permissiontoadd)) {
|
|||||||
$value = ((GETPOST($key, 'aZ09') == 'on' || GETPOST($key, 'aZ09') == '1') ? 1 : 0);
|
$value = ((GETPOST($key, 'aZ09') == 'on' || GETPOST($key, 'aZ09') == '1') ? 1 : 0);
|
||||||
} elseif ($object->fields[$key]['type'] == 'reference') {
|
} elseif ($object->fields[$key]['type'] == 'reference') {
|
||||||
$value = array_keys($object->param_list)[GETPOST($key)].','.GETPOST($key.'2');
|
$value = array_keys($object->param_list)[GETPOST($key)].','.GETPOST($key.'2');
|
||||||
|
} elseif (preg_match('/^chkbxlst:/', $object->fields[$key]['type'])) {
|
||||||
|
$value = '';
|
||||||
|
$values_arr = GETPOST($key, 'array');
|
||||||
|
if (!empty($values_arr)) {
|
||||||
|
$value = implode(',', $values_arr);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($key == 'lang') {
|
if ($key == 'lang') {
|
||||||
$value = GETPOST($key, 'aZ09');
|
$value = GETPOST($key, 'aZ09');
|
||||||
|
|||||||
@ -6763,6 +6763,9 @@ abstract class CommonObject
|
|||||||
} elseif (preg_match('/^(sellist):(.*):(.*)/i', $val['type'], $reg)) {
|
} elseif (preg_match('/^(sellist):(.*):(.*)/i', $val['type'], $reg)) {
|
||||||
$param['options'] = array($reg[2].':'.$reg[3] => 'N');
|
$param['options'] = array($reg[2].':'.$reg[3] => 'N');
|
||||||
$type = 'sellist';
|
$type = 'sellist';
|
||||||
|
} elseif (preg_match('/^chkbxlst:(.*)/i', $val['type'], $reg)) {
|
||||||
|
$param['options'] = array($reg[1] => 'N');
|
||||||
|
$type = 'chkbxlst';
|
||||||
} elseif (preg_match('/varchar\((\d+)\)/', $val['type'], $reg)) {
|
} elseif (preg_match('/varchar\((\d+)\)/', $val['type'], $reg)) {
|
||||||
$param['options'] = array();
|
$param['options'] = array();
|
||||||
$type = 'varchar';
|
$type = 'varchar';
|
||||||
@ -6941,6 +6944,8 @@ abstract class CommonObject
|
|||||||
// 2 : key fields name (if differ of rowid)
|
// 2 : key fields name (if differ of rowid)
|
||||||
// 3 : key field parent (for dependent lists)
|
// 3 : key field parent (for dependent lists)
|
||||||
// 4 : where clause filter on column or table extrafield, syntax field='value' or extra.field=value
|
// 4 : where clause filter on column or table extrafield, syntax field='value' or extra.field=value
|
||||||
|
// 5 : id category type
|
||||||
|
// 6 : ids categories list separated by comma for category root
|
||||||
$keyList = (empty($InfoFieldList[2]) ? 'rowid' : $InfoFieldList[2].' as rowid');
|
$keyList = (empty($InfoFieldList[2]) ? 'rowid' : $InfoFieldList[2].' as rowid');
|
||||||
|
|
||||||
if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) {
|
if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) {
|
||||||
@ -6955,112 +6960,130 @@ abstract class CommonObject
|
|||||||
$keyList .= ', '.$parentField;
|
$keyList .= ', '.$parentField;
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields_label = explode('|', $InfoFieldList[1]);
|
$filter_categorie = false;
|
||||||
if (is_array($fields_label)) {
|
if (count($InfoFieldList) > 5) {
|
||||||
$keyList .= ', ';
|
if ($InfoFieldList[0] == 'categorie') {
|
||||||
$keyList .= implode(', ', $fields_label);
|
$filter_categorie = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sqlwhere = '';
|
if ($filter_categorie === false) {
|
||||||
$sql = "SELECT ".$keyList;
|
$fields_label = explode('|', $InfoFieldList[1]);
|
||||||
$sql .= " FROM ".$this->db->prefix().$InfoFieldList[0];
|
if (is_array($fields_label)) {
|
||||||
if (!empty($InfoFieldList[4])) {
|
$keyList .= ', ';
|
||||||
// can use SELECT request
|
$keyList .= implode(', ', $fields_label);
|
||||||
if (strpos($InfoFieldList[4], '$SEL$') !== false) {
|
|
||||||
$InfoFieldList[4] = str_replace('$SEL$', 'SELECT', $InfoFieldList[4]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// current object id can be use into filter
|
$sqlwhere = '';
|
||||||
if (strpos($InfoFieldList[4], '$ID$') !== false && !empty($objectid)) {
|
$sql = "SELECT " . $keyList;
|
||||||
$InfoFieldList[4] = str_replace('$ID$', $objectid, $InfoFieldList[4]);
|
$sql .= " FROM " . $this->db->prefix() . $InfoFieldList[0];
|
||||||
} else {
|
if (!empty($InfoFieldList[4])) {
|
||||||
$InfoFieldList[4] = str_replace('$ID$', '0', $InfoFieldList[4]);
|
// can use SELECT request
|
||||||
}
|
if (strpos($InfoFieldList[4], '$SEL$') !== false) {
|
||||||
|
$InfoFieldList[4] = str_replace('$SEL$', 'SELECT', $InfoFieldList[4]);
|
||||||
//We have to join on extrafield table
|
|
||||||
if (strpos($InfoFieldList[4], 'extra') !== false) {
|
|
||||||
$sql .= " as main, ".$this->db->prefix().$InfoFieldList[0]."_extrafields as extra";
|
|
||||||
$sqlwhere .= " WHERE extra.fk_object=main.".$InfoFieldList[2]." AND ".$InfoFieldList[4];
|
|
||||||
} else {
|
|
||||||
$sqlwhere .= " WHERE ".$InfoFieldList[4];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$sqlwhere .= ' WHERE 1=1';
|
|
||||||
}
|
|
||||||
// Some tables may have field, some other not. For the moment we disable it.
|
|
||||||
if (in_array($InfoFieldList[0], array('tablewithentity'))) {
|
|
||||||
$sqlwhere .= " AND entity = ".((int) $conf->entity);
|
|
||||||
}
|
|
||||||
$sql .= $sqlwhere;
|
|
||||||
//print $sql;
|
|
||||||
|
|
||||||
$sql .= ' ORDER BY '.implode(', ', $fields_label);
|
|
||||||
|
|
||||||
dol_syslog(get_class($this).'::showInputField type=sellist', LOG_DEBUG);
|
|
||||||
$resql = $this->db->query($sql);
|
|
||||||
if ($resql) {
|
|
||||||
$out .= '<option value="0"> </option>';
|
|
||||||
$num = $this->db->num_rows($resql);
|
|
||||||
$i = 0;
|
|
||||||
while ($i < $num) {
|
|
||||||
$labeltoshow = '';
|
|
||||||
$obj = $this->db->fetch_object($resql);
|
|
||||||
|
|
||||||
// Several field into label (eq table:code|libelle:rowid)
|
|
||||||
$notrans = false;
|
|
||||||
$fields_label = explode('|', $InfoFieldList[1]);
|
|
||||||
if (count($fields_label) > 1) {
|
|
||||||
$notrans = true;
|
|
||||||
foreach ($fields_label as $field_toshow) {
|
|
||||||
$labeltoshow .= $obj->$field_toshow.' ';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$labeltoshow = $obj->{$InfoFieldList[1]};
|
|
||||||
}
|
}
|
||||||
$labeltoshow = dol_trunc($labeltoshow, 45);
|
|
||||||
|
|
||||||
if ($value == $obj->rowid) {
|
// current object id can be use into filter
|
||||||
foreach ($fields_label as $field_toshow) {
|
if (strpos($InfoFieldList[4], '$ID$') !== false && !empty($objectid)) {
|
||||||
$translabel = $langs->trans($obj->$field_toshow);
|
$InfoFieldList[4] = str_replace('$ID$', $objectid, $InfoFieldList[4]);
|
||||||
if ($translabel != $obj->$field_toshow) {
|
|
||||||
$labeltoshow = dol_trunc($translabel).' ';
|
|
||||||
} else {
|
|
||||||
$labeltoshow = dol_trunc($obj->$field_toshow).' ';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$out .= '<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>';
|
|
||||||
} else {
|
} else {
|
||||||
if (!$notrans) {
|
$InfoFieldList[4] = str_replace('$ID$', '0', $InfoFieldList[4]);
|
||||||
$translabel = $langs->trans($obj->{$InfoFieldList[1]});
|
}
|
||||||
if ($translabel != $obj->{$InfoFieldList[1]}) {
|
|
||||||
$labeltoshow = dol_trunc($translabel, 18);
|
//We have to join on extrafield table
|
||||||
} else {
|
if (strpos($InfoFieldList[4], 'extra') !== false) {
|
||||||
$labeltoshow = dol_trunc($obj->{$InfoFieldList[1]});
|
$sql .= " as main, " . $this->db->prefix() . $InfoFieldList[0] . "_extrafields as extra";
|
||||||
|
$sqlwhere .= " WHERE extra.fk_object=main." . $InfoFieldList[2] . " AND " . $InfoFieldList[4];
|
||||||
|
} else {
|
||||||
|
$sqlwhere .= " WHERE " . $InfoFieldList[4];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$sqlwhere .= ' WHERE 1=1';
|
||||||
|
}
|
||||||
|
// Some tables may have field, some other not. For the moment we disable it.
|
||||||
|
if (in_array($InfoFieldList[0], array('tablewithentity'))) {
|
||||||
|
$sqlwhere .= " AND entity = " . ((int) $conf->entity);
|
||||||
|
}
|
||||||
|
$sql .= $sqlwhere;
|
||||||
|
//print $sql;
|
||||||
|
|
||||||
|
$sql .= ' ORDER BY ' . implode(', ', $fields_label);
|
||||||
|
|
||||||
|
dol_syslog(get_class($this) . '::showInputField type=sellist', LOG_DEBUG);
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
if ($resql) {
|
||||||
|
$out .= '<option value="0"> </option>';
|
||||||
|
$num = $this->db->num_rows($resql);
|
||||||
|
$i = 0;
|
||||||
|
while ($i < $num) {
|
||||||
|
$labeltoshow = '';
|
||||||
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
|
// Several field into label (eq table:code|libelle:rowid)
|
||||||
|
$notrans = false;
|
||||||
|
$fields_label = explode('|', $InfoFieldList[1]);
|
||||||
|
if (count($fields_label) > 1) {
|
||||||
|
$notrans = true;
|
||||||
|
foreach ($fields_label as $field_toshow) {
|
||||||
|
$labeltoshow .= $obj->$field_toshow . ' ';
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$labeltoshow = $obj->{$InfoFieldList[1]};
|
||||||
}
|
}
|
||||||
if (empty($labeltoshow)) {
|
$labeltoshow = dol_trunc($labeltoshow, 45);
|
||||||
$labeltoshow = '(not defined)';
|
|
||||||
}
|
|
||||||
if ($value == $obj->rowid) {
|
if ($value == $obj->rowid) {
|
||||||
$out .= '<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>';
|
foreach ($fields_label as $field_toshow) {
|
||||||
|
$translabel = $langs->trans($obj->$field_toshow);
|
||||||
|
if ($translabel != $obj->$field_toshow) {
|
||||||
|
$labeltoshow = dol_trunc($translabel) . ' ';
|
||||||
|
} else {
|
||||||
|
$labeltoshow = dol_trunc($obj->$field_toshow) . ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$out .= '<option value="' . $obj->rowid . '" selected>' . $labeltoshow . '</option>';
|
||||||
|
} else {
|
||||||
|
if (!$notrans) {
|
||||||
|
$translabel = $langs->trans($obj->{$InfoFieldList[1]});
|
||||||
|
if ($translabel != $obj->{$InfoFieldList[1]}) {
|
||||||
|
$labeltoshow = dol_trunc($translabel, 18);
|
||||||
|
} else {
|
||||||
|
$labeltoshow = dol_trunc($obj->{$InfoFieldList[1]});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (empty($labeltoshow)) {
|
||||||
|
$labeltoshow = '(not defined)';
|
||||||
|
}
|
||||||
|
if ($value == $obj->rowid) {
|
||||||
|
$out .= '<option value="' . $obj->rowid . '" selected>' . $labeltoshow . '</option>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($InfoFieldList[3]) && $parentField) {
|
||||||
|
$parent = $parentName . ':' . $obj->{$parentField};
|
||||||
|
$isDependList = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$out .= '<option value="' . $obj->rowid . '"';
|
||||||
|
$out .= ($value == $obj->rowid ? ' selected' : '');
|
||||||
|
$out .= (!empty($parent) ? ' parent="' . $parent . '"' : '');
|
||||||
|
$out .= '>' . $labeltoshow . '</option>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($InfoFieldList[3]) && $parentField) {
|
$i++;
|
||||||
$parent = $parentName.':'.$obj->{$parentField};
|
|
||||||
$isDependList = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
$out .= '<option value="'.$obj->rowid.'"';
|
|
||||||
$out .= ($value == $obj->rowid ? ' selected' : '');
|
|
||||||
$out .= (!empty($parent) ? ' parent="'.$parent.'"' : '');
|
|
||||||
$out .= '>'.$labeltoshow.'</option>';
|
|
||||||
}
|
}
|
||||||
|
$this->db->free($resql);
|
||||||
$i++;
|
} else {
|
||||||
|
print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters.<br>';
|
||||||
}
|
}
|
||||||
$this->db->free($resql);
|
|
||||||
} else {
|
} else {
|
||||||
print 'Error in request '.$sql.' '.$this->db->lasterror().'. Check setup of extra parameters.<br>';
|
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||||
|
$data = $form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]], '', 'parent', 64, $InfoFieldList[6], 1, 1);
|
||||||
|
$out .= '<option value="0"> </option>';
|
||||||
|
foreach ($data as $data_key => $data_value) {
|
||||||
|
$out .= '<option value="' . $data_key . '"';
|
||||||
|
$out .= ($value == $data_key ? ' selected' : '');
|
||||||
|
$out .= '>' . $data_value . '</option>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$out .= '</select>';
|
$out .= '</select>';
|
||||||
@ -7093,6 +7116,8 @@ abstract class CommonObject
|
|||||||
// 2 : key fields name (if differ of rowid)
|
// 2 : key fields name (if differ of rowid)
|
||||||
// 3 : key field parent (for dependent lists)
|
// 3 : key field parent (for dependent lists)
|
||||||
// 4 : where clause filter on column or table extrafield, syntax field='value' or extra.field=value
|
// 4 : where clause filter on column or table extrafield, syntax field='value' or extra.field=value
|
||||||
|
// 5 : id category type
|
||||||
|
// 6 : ids categories list separated by comma for category root
|
||||||
$keyList = (empty($InfoFieldList[2]) ? 'rowid' : $InfoFieldList[2].' as rowid');
|
$keyList = (empty($InfoFieldList[2]) ? 'rowid' : $InfoFieldList[2].' as rowid');
|
||||||
|
|
||||||
if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) {
|
if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) {
|
||||||
@ -7107,114 +7132,127 @@ abstract class CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields_label = explode('|', $InfoFieldList[1]);
|
$filter_categorie = false;
|
||||||
if (is_array($fields_label)) {
|
if (count($InfoFieldList) > 5) {
|
||||||
$keyList .= ', ';
|
if ($InfoFieldList[0] == 'categorie') {
|
||||||
$keyList .= implode(', ', $fields_label);
|
$filter_categorie = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sqlwhere = '';
|
if ($filter_categorie === false) {
|
||||||
$sql = "SELECT ".$keyList;
|
$fields_label = explode('|', $InfoFieldList[1]);
|
||||||
$sql .= ' FROM '.$this->db->prefix().$InfoFieldList[0];
|
if (is_array($fields_label)) {
|
||||||
if (!empty($InfoFieldList[4])) {
|
$keyList .= ', ';
|
||||||
// can use SELECT request
|
$keyList .= implode(', ', $fields_label);
|
||||||
if (strpos($InfoFieldList[4], '$SEL$') !== false) {
|
|
||||||
$InfoFieldList[4] = str_replace('$SEL$', 'SELECT', $InfoFieldList[4]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// current object id can be use into filter
|
$sqlwhere = '';
|
||||||
if (strpos($InfoFieldList[4], '$ID$') !== false && !empty($objectid)) {
|
$sql = "SELECT " . $keyList;
|
||||||
$InfoFieldList[4] = str_replace('$ID$', $objectid, $InfoFieldList[4]);
|
$sql .= ' FROM ' . $this->db->prefix() . $InfoFieldList[0];
|
||||||
} else {
|
if (!empty($InfoFieldList[4])) {
|
||||||
$InfoFieldList[4] = str_replace('$ID$', '0', $InfoFieldList[4]);
|
// can use SELECT request
|
||||||
}
|
if (strpos($InfoFieldList[4], '$SEL$') !== false) {
|
||||||
|
$InfoFieldList[4] = str_replace('$SEL$', 'SELECT', $InfoFieldList[4]);
|
||||||
// We have to join on extrafield table
|
|
||||||
if (strpos($InfoFieldList[4], 'extra') !== false) {
|
|
||||||
$sql .= ' as main, '.$this->db->prefix().$InfoFieldList[0].'_extrafields as extra';
|
|
||||||
$sqlwhere .= " WHERE extra.fk_object=main.".$InfoFieldList[2]." AND ".$InfoFieldList[4];
|
|
||||||
} else {
|
|
||||||
$sqlwhere .= " WHERE ".$InfoFieldList[4];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$sqlwhere .= ' WHERE 1=1';
|
|
||||||
}
|
|
||||||
// Some tables may have field, some other not. For the moment we disable it.
|
|
||||||
if (in_array($InfoFieldList[0], array('tablewithentity'))) {
|
|
||||||
$sqlwhere .= " AND entity = ".((int) $conf->entity);
|
|
||||||
}
|
|
||||||
// $sql.=preg_replace('/^ AND /','',$sqlwhere);
|
|
||||||
// print $sql;
|
|
||||||
|
|
||||||
$sql .= $sqlwhere;
|
|
||||||
dol_syslog(get_class($this).'::showInputField type=chkbxlst', LOG_DEBUG);
|
|
||||||
$resql = $this->db->query($sql);
|
|
||||||
if ($resql) {
|
|
||||||
$num = $this->db->num_rows($resql);
|
|
||||||
$i = 0;
|
|
||||||
|
|
||||||
$data = array();
|
|
||||||
|
|
||||||
while ($i < $num) {
|
|
||||||
$labeltoshow = '';
|
|
||||||
$obj = $this->db->fetch_object($resql);
|
|
||||||
|
|
||||||
$notrans = false;
|
|
||||||
// Several field into label (eq table:code|libelle:rowid)
|
|
||||||
$fields_label = explode('|', $InfoFieldList[1]);
|
|
||||||
if (count($fields_label) > 1) {
|
|
||||||
$notrans = true;
|
|
||||||
foreach ($fields_label as $field_toshow) {
|
|
||||||
$labeltoshow .= $obj->$field_toshow.' ';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$labeltoshow = $obj->{$InfoFieldList[1]};
|
|
||||||
}
|
}
|
||||||
$labeltoshow = dol_trunc($labeltoshow, 45);
|
|
||||||
|
|
||||||
if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
|
// current object id can be use into filter
|
||||||
foreach ($fields_label as $field_toshow) {
|
if (strpos($InfoFieldList[4], '$ID$') !== false && !empty($objectid)) {
|
||||||
$translabel = $langs->trans($obj->$field_toshow);
|
$InfoFieldList[4] = str_replace('$ID$', $objectid, $InfoFieldList[4]);
|
||||||
if ($translabel != $obj->$field_toshow) {
|
|
||||||
$labeltoshow = dol_trunc($translabel, 18).' ';
|
|
||||||
} else {
|
|
||||||
$labeltoshow = dol_trunc($obj->$field_toshow, 18).' ';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$data[$obj->rowid] = $labeltoshow;
|
|
||||||
} else {
|
} else {
|
||||||
if (!$notrans) {
|
$InfoFieldList[4] = str_replace('$ID$', '0', $InfoFieldList[4]);
|
||||||
$translabel = $langs->trans($obj->{$InfoFieldList[1]});
|
}
|
||||||
if ($translabel != $obj->{$InfoFieldList[1]}) {
|
|
||||||
$labeltoshow = dol_trunc($translabel, 18);
|
// We have to join on extrafield table
|
||||||
} else {
|
if (strpos($InfoFieldList[4], 'extra') !== false) {
|
||||||
$labeltoshow = dol_trunc($obj->{$InfoFieldList[1]}, 18);
|
$sql .= ' as main, ' . $this->db->prefix() . $InfoFieldList[0] . '_extrafields as extra';
|
||||||
|
$sqlwhere .= " WHERE extra.fk_object=main." . $InfoFieldList[2] . " AND " . $InfoFieldList[4];
|
||||||
|
} else {
|
||||||
|
$sqlwhere .= " WHERE " . $InfoFieldList[4];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$sqlwhere .= ' WHERE 1=1';
|
||||||
|
}
|
||||||
|
// Some tables may have field, some other not. For the moment we disable it.
|
||||||
|
if (in_array($InfoFieldList[0], array('tablewithentity'))) {
|
||||||
|
$sqlwhere .= " AND entity = " . ((int) $conf->entity);
|
||||||
|
}
|
||||||
|
// $sql.=preg_replace('/^ AND /','',$sqlwhere);
|
||||||
|
// print $sql;
|
||||||
|
|
||||||
|
$sql .= $sqlwhere;
|
||||||
|
dol_syslog(get_class($this) . '::showInputField type=chkbxlst', LOG_DEBUG);
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
if ($resql) {
|
||||||
|
$num = $this->db->num_rows($resql);
|
||||||
|
$i = 0;
|
||||||
|
|
||||||
|
$data = array();
|
||||||
|
|
||||||
|
while ($i < $num) {
|
||||||
|
$labeltoshow = '';
|
||||||
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
|
$notrans = false;
|
||||||
|
// Several field into label (eq table:code|libelle:rowid)
|
||||||
|
$fields_label = explode('|', $InfoFieldList[1]);
|
||||||
|
if (count($fields_label) > 1) {
|
||||||
|
$notrans = true;
|
||||||
|
foreach ($fields_label as $field_toshow) {
|
||||||
|
$labeltoshow .= $obj->$field_toshow . ' ';
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$labeltoshow = $obj->{$InfoFieldList[1]};
|
||||||
}
|
}
|
||||||
if (empty($labeltoshow)) {
|
$labeltoshow = dol_trunc($labeltoshow, 45);
|
||||||
$labeltoshow = '(not defined)';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
|
if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
|
||||||
|
foreach ($fields_label as $field_toshow) {
|
||||||
|
$translabel = $langs->trans($obj->$field_toshow);
|
||||||
|
if ($translabel != $obj->$field_toshow) {
|
||||||
|
$labeltoshow = dol_trunc($translabel, 18) . ' ';
|
||||||
|
} else {
|
||||||
|
$labeltoshow = dol_trunc($obj->$field_toshow, 18) . ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$data[$obj->rowid] = $labeltoshow;
|
||||||
|
} else {
|
||||||
|
if (!$notrans) {
|
||||||
|
$translabel = $langs->trans($obj->{$InfoFieldList[1]});
|
||||||
|
if ($translabel != $obj->{$InfoFieldList[1]}) {
|
||||||
|
$labeltoshow = dol_trunc($translabel, 18);
|
||||||
|
} else {
|
||||||
|
$labeltoshow = dol_trunc($obj->{$InfoFieldList[1]}, 18);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (empty($labeltoshow)) {
|
||||||
|
$labeltoshow = '(not defined)';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
|
||||||
|
$data[$obj->rowid] = $labeltoshow;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($InfoFieldList[3]) && $parentField) {
|
||||||
|
$parent = $parentName . ':' . $obj->{$parentField};
|
||||||
|
$isDependList = 1;
|
||||||
|
}
|
||||||
|
|
||||||
$data[$obj->rowid] = $labeltoshow;
|
$data[$obj->rowid] = $labeltoshow;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($InfoFieldList[3]) && $parentField) {
|
$i++;
|
||||||
$parent = $parentName.':'.$obj->{$parentField};
|
|
||||||
$isDependList = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
$data[$obj->rowid] = $labeltoshow;
|
|
||||||
}
|
}
|
||||||
|
$this->db->free($resql);
|
||||||
|
|
||||||
$i++;
|
$out = $form->multiselectarray($keyprefix . $key . $keysuffix, $data, $value_arr, '', 0, $morecss, 0, '100%');
|
||||||
|
} else {
|
||||||
|
print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters.<br>';
|
||||||
}
|
}
|
||||||
$this->db->free($resql);
|
|
||||||
|
|
||||||
$out = $form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr, '', 0, '', 0, '100%');
|
|
||||||
} else {
|
} else {
|
||||||
print 'Error in request '.$sql.' '.$this->db->lasterror().'. Check setup of extra parameters.<br>';
|
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||||
|
$data = $form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]], '', 'parent', 64, $InfoFieldList[6], 1, 1);
|
||||||
|
$out = $form->multiselectarray($keyprefix . $key . $keysuffix, $data, $value_arr, '', 0, $morecss, 0, '100%');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif ($type == 'link') {
|
} elseif ($type == 'link') {
|
||||||
@ -7375,6 +7413,9 @@ abstract class CommonObject
|
|||||||
} elseif (preg_match('/^sellist:(.*):(.*)/i', $val['type'], $reg)) {
|
} elseif (preg_match('/^sellist:(.*):(.*)/i', $val['type'], $reg)) {
|
||||||
$param['options'] = array($reg[1].':'.$reg[2] => 'N');
|
$param['options'] = array($reg[1].':'.$reg[2] => 'N');
|
||||||
$type = 'sellist';
|
$type = 'sellist';
|
||||||
|
} elseif (preg_match('/^chkbxlst:(.*)/i', $val['type'], $reg)) {
|
||||||
|
$param['options'] = array($reg[1] => 'N');
|
||||||
|
$type = 'chkbxlst';
|
||||||
}
|
}
|
||||||
|
|
||||||
$langfile = empty($val['langfile']) ? '' : $val['langfile'];
|
$langfile = empty($val['langfile']) ? '' : $val['langfile'];
|
||||||
@ -7479,6 +7520,13 @@ abstract class CommonObject
|
|||||||
$keyList .= implode(', ', $fields_label);
|
$keyList .= implode(', ', $fields_label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$filter_categorie = false;
|
||||||
|
if (count($InfoFieldList) > 5) {
|
||||||
|
if ($InfoFieldList[0] == 'categorie') {
|
||||||
|
$filter_categorie = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "SELECT ".$keyList;
|
$sql = "SELECT ".$keyList;
|
||||||
$sql .= ' FROM '.$this->db->prefix().$InfoFieldList[0];
|
$sql .= ' FROM '.$this->db->prefix().$InfoFieldList[0];
|
||||||
if (strpos($InfoFieldList[4], 'extra') !== false) {
|
if (strpos($InfoFieldList[4], 'extra') !== false) {
|
||||||
@ -7497,37 +7545,51 @@ abstract class CommonObject
|
|||||||
dol_syslog(get_class($this).':showOutputField:$type=sellist', LOG_DEBUG);
|
dol_syslog(get_class($this).':showOutputField:$type=sellist', LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$value = ''; // value was used, so now we reste it to use it to build final output
|
if ($filter_categorie === false) {
|
||||||
$numrows = $this->db->num_rows($resql);
|
$value = ''; // value was used, so now we reste it to use it to build final output
|
||||||
if ($numrows) {
|
$numrows = $this->db->num_rows($resql);
|
||||||
$obj = $this->db->fetch_object($resql);
|
if ($numrows) {
|
||||||
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
// Several field into label (eq table:code|libelle:rowid)
|
// Several field into label (eq table:code|libelle:rowid)
|
||||||
$fields_label = explode('|', $InfoFieldList[1]);
|
$fields_label = explode('|', $InfoFieldList[1]);
|
||||||
|
|
||||||
if (is_array($fields_label) && count($fields_label) > 1) {
|
if (is_array($fields_label) && count($fields_label) > 1) {
|
||||||
foreach ($fields_label as $field_toshow) {
|
foreach ($fields_label as $field_toshow) {
|
||||||
$translabel = '';
|
$translabel = '';
|
||||||
if (!empty($obj->$field_toshow)) {
|
if (!empty($obj->$field_toshow)) {
|
||||||
$translabel = $langs->trans($obj->$field_toshow);
|
$translabel = $langs->trans($obj->$field_toshow);
|
||||||
|
}
|
||||||
|
if ($translabel != $field_toshow) {
|
||||||
|
$value .= dol_trunc($translabel, 18) . ' ';
|
||||||
|
} else {
|
||||||
|
$value .= $obj->$field_toshow . ' ';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($translabel != $field_toshow) {
|
|
||||||
$value .= dol_trunc($translabel, 18).' ';
|
|
||||||
} else {
|
|
||||||
$value .= $obj->$field_toshow.' ';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$translabel = '';
|
|
||||||
if (!empty($obj->{$InfoFieldList[1]})) {
|
|
||||||
$translabel = $langs->trans($obj->{$InfoFieldList[1]});
|
|
||||||
}
|
|
||||||
if ($translabel != $obj->{$InfoFieldList[1]}) {
|
|
||||||
$value = dol_trunc($translabel, 18);
|
|
||||||
} else {
|
} else {
|
||||||
$value = $obj->{$InfoFieldList[1]};
|
$translabel = '';
|
||||||
|
if (!empty($obj->{$InfoFieldList[1]})) {
|
||||||
|
$translabel = $langs->trans($obj->{$InfoFieldList[1]});
|
||||||
|
}
|
||||||
|
if ($translabel != $obj->{$InfoFieldList[1]}) {
|
||||||
|
$value = dol_trunc($translabel, 18);
|
||||||
|
} else {
|
||||||
|
$value = $obj->{$InfoFieldList[1]};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
|
||||||
|
|
||||||
|
$toprint = array();
|
||||||
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
$c = new Categorie($this->db);
|
||||||
|
$c->fetch($obj->rowid);
|
||||||
|
$ways = $c->print_all_ways(); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text
|
||||||
|
foreach ($ways as $way) {
|
||||||
|
$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #aaa"') . '>' . img_object('', 'category') . ' ' . $way . '</li>';
|
||||||
|
}
|
||||||
|
$value = '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(' ', $toprint).'</ul></div>';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dol_syslog(get_class($this).'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
|
dol_syslog(get_class($this).'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
|
||||||
@ -7564,6 +7626,13 @@ abstract class CommonObject
|
|||||||
$keyList .= implode(', ', $fields_label);
|
$keyList .= implode(', ', $fields_label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$filter_categorie = false;
|
||||||
|
if (count($InfoFieldList) > 5) {
|
||||||
|
if ($InfoFieldList[0] == 'categorie') {
|
||||||
|
$filter_categorie = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "SELECT ".$keyList;
|
$sql = "SELECT ".$keyList;
|
||||||
$sql .= ' FROM '.$this->db->prefix().$InfoFieldList[0];
|
$sql .= ' FROM '.$this->db->prefix().$InfoFieldList[0];
|
||||||
if (strpos($InfoFieldList[4], 'extra') !== false) {
|
if (strpos($InfoFieldList[4], 'extra') !== false) {
|
||||||
@ -7575,33 +7644,49 @@ abstract class CommonObject
|
|||||||
dol_syslog(get_class($this).':showOutputField:$type=chkbxlst', LOG_DEBUG);
|
dol_syslog(get_class($this).':showOutputField:$type=chkbxlst', LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$value = ''; // value was used, so now we reste it to use it to build final output
|
if ($filter_categorie === false) {
|
||||||
$toprint = array();
|
$value = ''; // value was used, so now we reste it to use it to build final output
|
||||||
while ($obj = $this->db->fetch_object($resql)) {
|
$toprint = array();
|
||||||
// Several field into label (eq table:code|libelle:rowid)
|
while ($obj = $this->db->fetch_object($resql)) {
|
||||||
$fields_label = explode('|', $InfoFieldList[1]);
|
// Several field into label (eq table:code|libelle:rowid)
|
||||||
if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
|
$fields_label = explode('|', $InfoFieldList[1]);
|
||||||
if (is_array($fields_label) && count($fields_label) > 1) {
|
if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
|
||||||
foreach ($fields_label as $field_toshow) {
|
if (is_array($fields_label) && count($fields_label) > 1) {
|
||||||
$translabel = '';
|
foreach ($fields_label as $field_toshow) {
|
||||||
if (!empty($obj->$field_toshow)) {
|
$translabel = '';
|
||||||
$translabel = $langs->trans($obj->$field_toshow);
|
if (!empty($obj->$field_toshow)) {
|
||||||
|
$translabel = $langs->trans($obj->$field_toshow);
|
||||||
|
}
|
||||||
|
if ($translabel != $field_toshow) {
|
||||||
|
$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">' . dol_trunc($translabel, 18) . '</li>';
|
||||||
|
} else {
|
||||||
|
$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">' . $obj->$field_toshow . '</li>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($translabel != $field_toshow) {
|
|
||||||
$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.dol_trunc($translabel, 18).'</li>';
|
|
||||||
} else {
|
|
||||||
$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.$obj->$field_toshow.'</li>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$translabel = '';
|
|
||||||
if (!empty($obj->{$InfoFieldList[1]})) {
|
|
||||||
$translabel = $langs->trans($obj->{$InfoFieldList[1]});
|
|
||||||
}
|
|
||||||
if ($translabel != $obj->{$InfoFieldList[1]}) {
|
|
||||||
$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.dol_trunc($translabel, 18).'</li>';
|
|
||||||
} else {
|
} else {
|
||||||
$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.$obj->{$InfoFieldList[1]}.'</li>';
|
$translabel = '';
|
||||||
|
if (!empty($obj->{$InfoFieldList[1]})) {
|
||||||
|
$translabel = $langs->trans($obj->{$InfoFieldList[1]});
|
||||||
|
}
|
||||||
|
if ($translabel != $obj->{$InfoFieldList[1]}) {
|
||||||
|
$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">' . dol_trunc($translabel, 18) . '</li>';
|
||||||
|
} else {
|
||||||
|
$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">' . $obj->{$InfoFieldList[1]} . '</li>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
|
||||||
|
|
||||||
|
$toprint = array();
|
||||||
|
while ($obj = $this->db->fetch_object($resql)) {
|
||||||
|
if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
|
||||||
|
$c = new Categorie($this->db);
|
||||||
|
$c->fetch($obj->rowid);
|
||||||
|
$ways = $c->print_all_ways(); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text
|
||||||
|
foreach ($ways as $way) {
|
||||||
|
$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #aaa"') . '>' . img_object('', 'category') . ' ' . $way . '</li>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,3 +55,5 @@ ALTER TABLE llx_facture_fourn ADD COLUMN close_missing_amount double(24, 8) afte
|
|||||||
|
|
||||||
-- Allow users to make subscriptions of any amount during membership subscription
|
-- Allow users to make subscriptions of any amount during membership subscription
|
||||||
ALTER TABLE llx_adherent_type ADD COLUMN caneditamount integer DEFAULT 0 AFTER amount;
|
ALTER TABLE llx_adherent_type ADD COLUMN caneditamount integer DEFAULT 0 AFTER amount;
|
||||||
|
|
||||||
|
ALTER TABLE llx_inventory ADD COLUMN categories_product VARCHAR(255) DEFAULT NULL AFTER fk_product;
|
||||||
|
|||||||
@ -29,6 +29,7 @@ CREATE TABLE llx_inventory
|
|||||||
fk_user_valid integer, -- valideur de la fiche
|
fk_user_valid integer, -- valideur de la fiche
|
||||||
fk_warehouse integer DEFAULT NULL,
|
fk_warehouse integer DEFAULT NULL,
|
||||||
fk_product integer DEFAULT NULL,
|
fk_product integer DEFAULT NULL,
|
||||||
|
categories_product varchar(255) DEFAULT NULL, -- product categories id separated by comma
|
||||||
status integer DEFAULT 0,
|
status integer DEFAULT 0,
|
||||||
title varchar(255) NOT NULL,
|
title varchar(255) NOT NULL,
|
||||||
date_inventory datetime DEFAULT NULL,
|
date_inventory datetime DEFAULT NULL,
|
||||||
|
|||||||
@ -427,3 +427,4 @@ RealValuation=Real Valuation
|
|||||||
ConfirmEditExtrafield = Select the extrafield you want modify
|
ConfirmEditExtrafield = Select the extrafield you want modify
|
||||||
ConfirmEditExtrafieldQuestion = Are you sure you want to modify this extrafield?
|
ConfirmEditExtrafieldQuestion = Are you sure you want to modify this extrafield?
|
||||||
ModifyValueExtrafields = Modify value of an extrafield
|
ModifyValueExtrafields = Modify value of an extrafield
|
||||||
|
OrProductsWithCategories=Or products with tags/categories
|
||||||
|
|||||||
@ -412,3 +412,4 @@ SwitchOnSaleStatus=Basculer le statut En vente
|
|||||||
SwitchOnPurchaseStatus=Basculer le statut En achat
|
SwitchOnPurchaseStatus=Basculer le statut En achat
|
||||||
StockMouvementExtraFields= Champs supplémentaires (mouvement de stock)
|
StockMouvementExtraFields= Champs supplémentaires (mouvement de stock)
|
||||||
PuttingPricesUpToDate=Mettre à jour les prix
|
PuttingPricesUpToDate=Mettre à jour les prix
|
||||||
|
OrProductsWithCategories=Ou produits avec tags/categories
|
||||||
|
|||||||
@ -102,6 +102,7 @@ class Inventory extends CommonObject
|
|||||||
'title' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>25, 'css'=>'minwidth300', 'csslist'=>'tdoverflowmax200'),
|
'title' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>25, 'css'=>'minwidth300', 'csslist'=>'tdoverflowmax200'),
|
||||||
'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Warehouse', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'index'=>1, 'help'=>'InventoryForASpecificWarehouse', 'picto'=>'stock', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'csslist'=>'tdoverflowmax200'),
|
'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Warehouse', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'index'=>1, 'help'=>'InventoryForASpecificWarehouse', 'picto'=>'stock', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'csslist'=>'tdoverflowmax200'),
|
||||||
'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'get_name_url_params' => '0::0:-1:0::1', 'visible'=>1, 'enabled'=>1, 'position'=>32, 'index'=>1, 'help'=>'InventoryForASpecificProduct', 'picto'=>'product', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'csslist'=>'tdoverflowmax200'),
|
'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'get_name_url_params' => '0::0:-1:0::1', 'visible'=>1, 'enabled'=>1, 'position'=>32, 'index'=>1, 'help'=>'InventoryForASpecificProduct', 'picto'=>'product', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'csslist'=>'tdoverflowmax200'),
|
||||||
|
'categories_product' => array('type'=>'chkbxlst:categorie:label:rowid::type=0:0:', 'label'=>'OrProductsWithCategories', 'visible'=>3, 'enabled'=>1, 'position'=>33, 'help'=>'', 'picto'=>'category', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx'),
|
||||||
'date_inventory' => array('type'=>'date', 'label'=>'DateValue', 'visible'=>1, 'enabled'=>'$conf->global->STOCK_INVENTORY_ADD_A_VALUE_DATE', 'position'=>35), // This date is not used so disabled by default.
|
'date_inventory' => array('type'=>'date', 'label'=>'DateValue', 'visible'=>1, 'enabled'=>'$conf->global->STOCK_INVENTORY_ADD_A_VALUE_DATE', 'position'=>35), // This date is not used so disabled by default.
|
||||||
'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500),
|
'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500),
|
||||||
'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501),
|
'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501),
|
||||||
@ -139,6 +140,11 @@ class Inventory extends CommonObject
|
|||||||
*/
|
*/
|
||||||
public $fk_product;
|
public $fk_product;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string Categories id separated by comma
|
||||||
|
*/
|
||||||
|
public $categories_product;
|
||||||
|
|
||||||
public $date_inventory;
|
public $date_inventory;
|
||||||
public $title;
|
public $title;
|
||||||
|
|
||||||
@ -291,6 +297,14 @@ class Inventory extends CommonObject
|
|||||||
if ($this->fk_warehouse > 0) {
|
if ($this->fk_warehouse > 0) {
|
||||||
$sql .= " AND ps.fk_entrepot = ".((int) $this->fk_warehouse);
|
$sql .= " AND ps.fk_entrepot = ".((int) $this->fk_warehouse);
|
||||||
}
|
}
|
||||||
|
if (!empty($this->categories_product)) {
|
||||||
|
$sql .= " AND EXISTS (";
|
||||||
|
$sql .= " SELECT cp.fk_product";
|
||||||
|
$sql .= " FROM ".$this->db->prefix()."categorie_product AS cp";
|
||||||
|
$sql .= " WHERE cp.fk_product = ps.fk_product";
|
||||||
|
$sql .= " AND cp.fk_categorie IN (".$this->db->sanitize($this->categories_product).")";
|
||||||
|
$sql .= ")";
|
||||||
|
}
|
||||||
|
|
||||||
$inventoryline = new InventoryLine($this->db);
|
$inventoryline = new InventoryLine($this->db);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user