Fix separator extrafields must not appear as selected fields
This commit is contained in:
parent
bb48da988b
commit
abfc87c1de
@ -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 .= '<li>-----</li>';
|
||||
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 .= '<li><input type="checkbox" id="checkbox'.$key.'" value="'.$key.'"'.((empty($val['checked']) && $val['checked'] != '-1') ? '' : ' checked="checked"').'/><label for="checkbox'.$key.'">'.dol_escape_htmltag($langs->trans($val['label'])).'</label></li>';
|
||||
$listoffieldsforselection .= '<li><input type="checkbox" id="checkbox'.$key.'" value="'.$key.'"'.((empty($val['checked']) && $val['checked'] != '-1') ? '' : ' checked="checked"').'/><label for="checkbox'.$key.'">'.dol_escape_htmltag($langs->trans($val['label'])).'</label></li>';
|
||||
$listcheckedstring .= (empty($val['checked']) ? '' : $key.',');
|
||||
}
|
||||
}
|
||||
@ -7442,7 +7447,7 @@ class Form
|
||||
<dd class="dropdowndd">
|
||||
<div class="multiselectcheckbox'.$htmlname.'">
|
||||
<ul class="ul'.$htmlname.'">
|
||||
'.$lis.'
|
||||
'.$listoffieldsforselection.'
|
||||
</ul>
|
||||
</div>
|
||||
</dd>
|
||||
|
||||
@ -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]),
|
||||
|
||||
@ -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
|
||||
*/
|
||||
|
||||
@ -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 '<tr class="liste_titre_filter">';
|
||||
if (!empty($arrayfields['p.rowid']['checked'])) {
|
||||
print '<td class="liste_titre left">';
|
||||
print '<input class="flat" type="text" name="search_id" size="4" value="'.dol_escape_htmltag($search_id).'">';
|
||||
print '</td>';
|
||||
}
|
||||
if (!empty($arrayfields['p.ref']['checked'])) {
|
||||
print '<td class="liste_titre left">';
|
||||
print '<input class="flat" type="text" name="search_ref" size="8" value="'.dol_escape_htmltag($search_ref).'">';
|
||||
@ -1058,6 +1084,9 @@ if ($resql) {
|
||||
print '</tr>';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
if (!empty($arrayfields['p.rowid']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['p.rowid']['label'], $_SERVER["PHP_SELF"], "p.rowid", "", $param, "", $sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($arrayfields['p.ref']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, "", $sortfield, $sortorder);
|
||||
}
|
||||
@ -1281,6 +1310,16 @@ if ($resql) {
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
// Ref
|
||||
if (!empty($arrayfields['p.rowid']['checked'])) {
|
||||
print '<td class="nowraponall">';
|
||||
print $product_static->id;
|
||||
print "</td>\n";
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
|
||||
// Ref
|
||||
if (!empty($arrayfields['p.ref']['checked'])) {
|
||||
print '<td class="tdoverflowmax200">';
|
||||
|
||||
@ -113,19 +113,8 @@ foreach ($object->fields as $key => $val) {
|
||||
}
|
||||
}
|
||||
// Extra fields
|
||||
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) {
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
|
||||
if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) {
|
||||
$arrayfields["ef.".$key] = array(
|
||||
'label'=>$extrafields->attributes[$object->table_element]['label'][$key],
|
||||
'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1),
|
||||
'position'=>$extrafields->attributes[$object->table_element]['pos'][$key],
|
||||
'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]),
|
||||
'langfile'=>$extrafields->attributes[$object->table_element]['langfile'][$key]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
|
||||
|
||||
$object->fields = dol_sort_array($object->fields, 'position');
|
||||
$arrayfields = dol_sort_array($arrayfields, 'position');
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user