diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index e084757fe28..c5248fdf490 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -7408,7 +7408,7 @@ class Form
}
}
- $lis = '';
+ $listoffieldsforselection = '';
$listcheckedstring = '';
foreach ($array as $key => $val) {
@@ -7419,13 +7419,18 @@ class Form
unset($array[$key]); // We don't want this field
continue;
}
+ if (!empty($val['type']) && $val['type'] == 'separate') {
+ // Field remains in array but we don't add it into $listoffieldsforselection
+ //$listoffieldsforselection .= '
-----
';
+ continue;
+ }
if ($val['label']) {
if (!empty($val['langfile']) && is_object($langs)) {
$langs->load($val['langfile']);
}
// Note: $val['checked'] <> 0 means we must show the field into the combo list
- $lis .= '';
+ $listoffieldsforselection .= '';
$listcheckedstring .= (empty($val['checked']) ? '' : $key.',');
}
}
@@ -7442,7 +7447,7 @@ class Form
- '.$lis.'
+ '.$listoffieldsforselection.'
diff --git a/htdocs/core/tpl/extrafields_list_array_fields.tpl.php b/htdocs/core/tpl/extrafields_list_array_fields.tpl.php
index ebab4e8608a..f7c9fc201f4 100644
--- a/htdocs/core/tpl/extrafields_list_array_fields.tpl.php
+++ b/htdocs/core/tpl/extrafields_list_array_fields.tpl.php
@@ -23,6 +23,7 @@ if (!empty($extrafieldsobjectkey)) { // $extrafieldsobject is the $object->table
if (!empty($extrafields->attributes[$extrafieldsobjectkey]['list'][$key])) {
$arrayfields[$extrafieldsobjectprefix.$key] = array(
'label' => $extrafields->attributes[$extrafieldsobjectkey]['label'][$key],
+ 'type' => $extrafields->attributes[$extrafieldsobjectkey]['type'][$key],
'checked' => (($extrafields->attributes[$extrafieldsobjectkey]['list'][$key] < 0) ? 0 : 1),
'position' => $extrafields->attributes[$extrafieldsobjectkey]['pos'][$key],
'enabled' => (abs((int) $extrafields->attributes[$extrafieldsobjectkey]['list'][$key]) != 3 && $extrafields->attributes[$extrafieldsobjectkey]['perms'][$key]),
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index 1afd1e74e23..381d92c52f7 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -426,6 +426,31 @@ class Product extends CommonObject
public $is_object_used;
+ /**
+ * 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password')
+ * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)"
+ * 'label' the translation key.
+ * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM)
+ * 'position' is the sort order of field.
+ * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
+ * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing)
+ * 'noteditable' says if field is not editable (1 or 0)
+ * 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created.
+ * 'index' if we want an index in database.
+ * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
+ * 'searchall' is 1 if we want to search in this field when making a search from the quick search button.
+ * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8).
+ * 'css' is the CSS style to use on field. For example: 'maxwidth200'
+ * 'help' is a string visible as a tooltip on field
+ * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record
+ * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code.
+ * 'arrayofkeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel")
+ * 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1.
+ * 'comment' is not used. You can store here any text of your choice. It is not used by application.
+ *
+ * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor.
+ */
+
/**
* @var array fields of object product
*/
diff --git a/htdocs/product/list.php b/htdocs/product/list.php
index 0c922fab0dd..8000eac356b 100644
--- a/htdocs/product/list.php
+++ b/htdocs/product/list.php
@@ -58,6 +58,7 @@ $confirm = GETPOST('confirm', 'alpha');
$toselect = GETPOST('toselect', 'array');
$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
+$search_id = GETPOST("search_id", 'alpha');
$search_ref = GETPOST("search_ref", 'alpha');
$search_ref_supplier = GETPOST("search_ref_supplier", 'alpha');
$search_barcode = GETPOST("search_barcode", 'alpha');
@@ -193,9 +194,10 @@ $isInEEC = isInEEC($mysoc);
$alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "ppe";
-// Definition of fields for lists
+// Definition of array of fields for columns
$arrayfields = array(
- 'p.ref'=>array('label'=>"Ref", 'checked'=>1),
+ 'p.rowid'=>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'noteditable'=>1, 'notnull'=> 1, 'index'=>1, 'position'=>1, 'comment'=>'Id', 'css'=>'left'),
+ 'p.ref'=>array('label'=>"Ref", 'checked'=>1, 'position'=>10),
//'pfp.ref_fourn'=>array('label'=>$langs->trans("RefSupplier"), 'checked'=>1, 'enabled'=>(! empty($conf->barcode->enabled))),
'p.label'=>array('label'=>"Label", 'checked'=>1, 'position'=>10),
'p.fk_product_type'=>array('label'=>"Type", 'checked'=>0, 'enabled'=>(!empty($conf->product->enabled) && !empty($conf->service->enabled)), 'position'=>11),
@@ -239,6 +241,19 @@ $arrayfields = array(
'p.tosell'=>array('label'=>$langs->transnoentitiesnoconv("Status").' ('.$langs->transnoentitiesnoconv("Sell").')', 'checked'=>1, 'position'=>1000),
'p.tobuy'=>array('label'=>$langs->transnoentitiesnoconv("Status").' ('.$langs->transnoentitiesnoconv("Buy").')', 'checked'=>1, 'position'=>1000)
);
+/*foreach ($object->fields as $key => $val) {
+ // If $val['visible']==0, then we never show the field
+ if (!empty($val['visible'])) {
+ $visible = dol_eval($val['visible'], 1);
+ $arrayfields['p.'.$key] = array(
+ 'label'=>$val['label'],
+ 'checked'=>(($visible < 0) ? 0 : 1),
+ 'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1)),
+ 'position'=>$val['position']
+ );
+ }
+}*/
+
// MultiPrices
if ($conf->global->PRODUIT_MULTIPRICES) {
@@ -300,6 +315,7 @@ if (empty($reshook)) {
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
$sall = "";
+ $search_id = '';
$search_ref = "";
$search_ref_supplier = "";
$search_label = "";
@@ -426,6 +442,9 @@ if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTE
$sql .= " AND pac.rowid IS NULL";
}
+if ($search_id) {
+ $sql .= natural_search('p.rowid', $search_id, 1);
+}
if ($search_ref) {
$sql .= natural_search('p.ref', $search_ref);
}
@@ -705,6 +724,7 @@ if ($resql) {
$perm = $user->rights->service->creer;
} elseif ($type == Product::TYPE_PRODUCT) {
$perm = $user->rights->produit->creer;
+
}
$oldtype = $type;
$params = array();
@@ -801,6 +821,7 @@ if ($resql) {
}
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
+
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
if ($massactionbutton) {
$selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
@@ -811,6 +832,11 @@ if ($resql) {
// Lines with input filters
print '
';
+ if (!empty($arrayfields['p.rowid']['checked'])) {
+ print '
';
+ print '';
+ print '
';
+ }
if (!empty($arrayfields['p.ref']['checked'])) {
print '