NEW The field "visible" on extrafield can accept expression as condition
This commit is contained in:
parent
486a372d44
commit
0bf4381226
@ -1001,13 +1001,7 @@ else
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
print $object->showOptionals($extrafields,'edit');
|
||||
}
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
|
||||
|
||||
print '<tbody>';
|
||||
print "</table>\n";
|
||||
@ -1277,13 +1271,7 @@ else
|
||||
print '</td></tr>';
|
||||
|
||||
// Other attributes
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
print $object->showOptionals($extrafields,'edit',$parameters);
|
||||
}
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
|
||||
|
||||
print '</table>';
|
||||
|
||||
|
||||
@ -5938,8 +5938,16 @@ abstract class CommonObject
|
||||
$e = 0;
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
if (empty($extrafields->attribute_list[$key])) continue; // 0 = Never visible field
|
||||
if (($mode == 'create' || $mode == 'edit') && abs($extrafields->attribute_list[$key]) != 1 && abs($extrafields->attribute_list[$key]) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list
|
||||
$enabled = $extrafields->attribute_list[$key];
|
||||
if (empty($enabled)) continue; // 0 = Never visible field
|
||||
if (! is_numeric($enabled))
|
||||
{
|
||||
$enabled=dol_eval($enabled, 1);
|
||||
if (empty($enabled)) continue;
|
||||
else $enabled = 1;
|
||||
}
|
||||
|
||||
if (($mode == 'create' || $mode == 'edit') && abs($enabled) != 1 && abs($enabled) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list
|
||||
|
||||
// Load language if required
|
||||
if (! empty($extrafields->attributes[$this->table_element]['langfile'][$key])) $langs->load($extrafields->attributes[$this->table_element]['langfile'][$key]);
|
||||
|
||||
@ -144,7 +144,7 @@ class ExtraFields
|
||||
* @param array|string $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) )
|
||||
* @param int $alwayseditable Is attribute always editable regardless of the document status
|
||||
* @param string $perms Permission to check
|
||||
* @param int $list Visibilty (0=never visible, 1=visible on list+forms, 2=list onyl, 3=form only)
|
||||
* @param string $list Visibilty ('0'=never visible, '1'=visible on list+forms, '2'=list only, '3'=form only or 'eval string')
|
||||
* @param int $notused Deprecated.
|
||||
* @param string $computed Computed value
|
||||
* @param string $entity Entity of extrafields (for multicompany modules)
|
||||
@ -152,7 +152,7 @@ class ExtraFields
|
||||
* @param string $enabled Condition to have the field enabled or not
|
||||
* @return int <=0 if KO, >0 if OK
|
||||
*/
|
||||
function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param='', $alwayseditable=0, $perms='', $list=-1, $notused=0, $computed='', $entity='', $langfile='', $enabled='1')
|
||||
function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param='', $alwayseditable=0, $perms='', $list='-1', $notused=0, $computed='', $entity='', $langfile='', $enabled='1')
|
||||
{
|
||||
if (empty($attrname)) return -1;
|
||||
if (empty($label)) return -1;
|
||||
@ -198,11 +198,11 @@ class ExtraFields
|
||||
* @param string $default_value Default value for field (in database)
|
||||
* @param array $param Params for field (ex for select list : array('options'=>array('value'=>'label of option'))
|
||||
* @param string $perms Permission
|
||||
* @param int $list Into list view by default
|
||||
* @param string $list Into list view by default
|
||||
* @param string $computed Computed value
|
||||
* @return int <=0 if KO, >0 if OK
|
||||
*/
|
||||
private function create($attrname, $type='varchar', $length=255, $elementtype='member', $unique=0, $required=0, $default_value='',$param='', $perms='', $list=0, $computed='')
|
||||
private function create($attrname, $type='varchar', $length=255, $elementtype='member', $unique=0, $required=0, $default_value='',$param='', $perms='', $list='0', $computed='')
|
||||
{
|
||||
if ($elementtype == 'thirdparty') $elementtype='societe';
|
||||
if ($elementtype == 'contact') $elementtype='socpeople';
|
||||
@ -288,7 +288,7 @@ class ExtraFields
|
||||
* @param array|string $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) )
|
||||
* @param int $alwayseditable Is attribute always editable regardless of the document status
|
||||
* @param string $perms Permission to check
|
||||
* @param int $list Visibily
|
||||
* @param string $list Visibily
|
||||
* @param int $notused Deprecated.
|
||||
* @param string $default Default value (in database. use the default_value feature for default value on screen).
|
||||
* @param string $computed Computed value
|
||||
@ -297,7 +297,7 @@ class ExtraFields
|
||||
* @param string $enabled Condition to have the field enabled or not
|
||||
* @return int <=0 if KO, >0 if OK
|
||||
*/
|
||||
private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='', $list=-1, $notused=0, $default='', $computed='',$entity='', $langfile='', $enabled='1')
|
||||
private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='', $list='-1', $notused=0, $default='', $computed='',$entity='', $langfile='', $enabled='1')
|
||||
{
|
||||
global $conf,$user;
|
||||
|
||||
@ -306,7 +306,7 @@ class ExtraFields
|
||||
|
||||
// Clean parameters
|
||||
if (empty($pos)) $pos=0;
|
||||
if (empty($list)) $list=0;
|
||||
if (empty($list)) $list='0';
|
||||
if (empty($required)) $required=0;
|
||||
if (empty($unique)) $unique=0;
|
||||
if (empty($alwayseditable)) $alwayseditable=0;
|
||||
@ -361,7 +361,7 @@ class ExtraFields
|
||||
$sql.= " ".$alwayseditable.",";
|
||||
$sql.= " ".($perms?"'".$this->db->escape($perms)."'":"null").",";
|
||||
$sql.= " ".($langfile?"'".$this->db->escape($langfile)."'":"null").",";
|
||||
$sql.= " ".$list.",";
|
||||
$sql.= " '".$this->db->escape($list)."',";
|
||||
$sql.= " ".($default?"'".$this->db->escape($default)."'":"null").",";
|
||||
$sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null").",";
|
||||
$sql .= " " . $user->id . ",";
|
||||
@ -496,7 +496,7 @@ class ExtraFields
|
||||
* @param array $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) )
|
||||
* @param int $alwayseditable Is attribute always editable regardless of the document status
|
||||
* @param string $perms Permission to check
|
||||
* @param int $list Visibility
|
||||
* @param string $list Visibility
|
||||
* @param int $notused Deprecated.
|
||||
* @param string $default Default value (in database. use the default_value feature for default value on screen).
|
||||
* @param string $computed Computed value
|
||||
@ -605,7 +605,7 @@ class ExtraFields
|
||||
* @param array $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) )
|
||||
* @param int $alwayseditable Is attribute always editable regardless of the document status
|
||||
* @param string $perms Permission to check
|
||||
* @param int $list Visiblity
|
||||
* @param string $list Visiblity
|
||||
* @param int $notused Deprecated.
|
||||
* @param string $default Default value (in database. use the default_value feature for default value on screen).
|
||||
* @param string $computed Computed value
|
||||
@ -614,7 +614,7 @@ class ExtraFields
|
||||
* @param string $enabled Condition to have the field enabled or not
|
||||
* @return int <=0 if KO, >0 if OK
|
||||
*/
|
||||
private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0,$perms='',$list=0,$notused=0,$default='',$computed='',$entity='',$langfile='',$enabled='1')
|
||||
private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0,$perms='',$list='0',$notused=0,$default='',$computed='',$entity='',$langfile='',$enabled='1')
|
||||
{
|
||||
global $conf, $user;
|
||||
dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required.", ".$pos.", ".$alwayseditable.", ".$perms.", ".$list.", ".$notused.", ".$default.", ".$computed.", ".$entity.", ".$langfile.", ".$enabled);
|
||||
@ -624,7 +624,7 @@ class ExtraFields
|
||||
if ($elementtype == 'contact') $elementtype='socpeople';
|
||||
|
||||
if (empty($pos)) $pos=0;
|
||||
if (empty($list)) $list=0;
|
||||
if (empty($list)) $list='0';
|
||||
if (empty($required)) $required=0;
|
||||
if (empty($unique)) $unique=0;
|
||||
if (empty($alwayseditable)) $alwayseditable=0;
|
||||
@ -688,7 +688,7 @@ class ExtraFields
|
||||
$sql.= " ".$pos.",";
|
||||
$sql.= " '".$this->db->escape($alwayseditable)."',";
|
||||
$sql.= " '".$this->db->escape($params)."',";
|
||||
$sql.= " ".$list.", ";
|
||||
$sql.= " '".$this->db->escape($list)."', ";
|
||||
$sql.= " ".(($default!='')?"'".$this->db->escape($default)."'":"null").",";
|
||||
$sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null").",";
|
||||
$sql .= " " . $user->id . ",";
|
||||
|
||||
@ -252,7 +252,7 @@ else
|
||||
<?php } ?>
|
||||
<!-- Visibility -->
|
||||
<tr><td class="extra_list"><?php echo $form->textwithpicto($langs->trans("Visibility"), $langs->trans("VisibleDesc")); ?>
|
||||
</td><td class="valeur"><input id="list" size="1" type="text" name="list" value="<?php echo ($list!=''?$list:'1'); ?>"></td></tr>
|
||||
</td><td class="valeur"><input id="list" class="minwidth100" type="text" name="list" value="<?php echo ($list!=''?$list:'1'); ?>"></td></tr>
|
||||
</table>
|
||||
|
||||
<?php dol_fiche_end(); ?>
|
||||
|
||||
@ -411,3 +411,5 @@ UPDATE llx_accounting_account set account_parent = 0 WHERE account_parent = '' O
|
||||
ALTER TABLE llx_accounting_account MODIFY COLUMN account_parent integer DEFAULT 0;
|
||||
ALTER TABLE llx_accounting_account ADD INDEX idx_accounting_account_account_parent (account_parent);
|
||||
|
||||
ALTER TABLE llx_extrafields MODIFY COLUMN list VARCHAR(128);
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ create table llx_extrafields
|
||||
pos integer DEFAULT 0,
|
||||
alwayseditable integer DEFAULT 0, -- 1 if field can be edited whatever is element status
|
||||
param text, -- extra parameters to define possible values of field
|
||||
list integer DEFAULT 1, -- visibility of field. 0=Never visible, 1=Visible on list and forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing
|
||||
list varchar(255) DEFAULT '1', -- visibility of field. 0=Never visible, 1=Visible on list and forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing
|
||||
langs varchar(64), -- example: fileofmymodule@mymodule
|
||||
fk_user_author integer, -- user making creation
|
||||
fk_user_modif integer, -- user making last change
|
||||
|
||||
@ -59,11 +59,7 @@ $backtopage=GETPOST('backtopage','alpha');
|
||||
$action=GETPOST('action','alpha');
|
||||
|
||||
// Load translation files
|
||||
$langs->load("main");
|
||||
$langs->load("members");
|
||||
$langs->load("companies");
|
||||
$langs->load("install");
|
||||
$langs->load("other");
|
||||
$langs->loadLangs(array("main","members","companies","install","other"));
|
||||
|
||||
// Security check
|
||||
if (empty($conf->adherent->enabled)) accessforbidden('',0,0,1);
|
||||
@ -76,6 +72,8 @@ if (empty($conf->global->MEMBER_ENABLE_PUBLIC))
|
||||
|
||||
$extrafields = new ExtraFields($db);
|
||||
|
||||
$object = new Adherent($db);
|
||||
|
||||
|
||||
/**
|
||||
* Show header for new member
|
||||
@ -487,17 +485,17 @@ llxHeaderVierge($langs->trans("NewSubscription"));
|
||||
|
||||
print load_fiche_titre($langs->trans("NewSubscription"), '', '', 0, 0, 'center');
|
||||
|
||||
print '<div class="center subscriptionformhelptext">';
|
||||
|
||||
print '<div align="center">';
|
||||
print '<div id="divsubscribe">';
|
||||
|
||||
print '<div class="center subscriptionformhelptext justify">';
|
||||
if (! empty($conf->global->MEMBER_NEWFORM_TEXT)) print $langs->trans($conf->global->MEMBER_NEWFORM_TEXT)."<br>\n";
|
||||
else print $langs->trans("NewSubscriptionDesc",$conf->global->MAIN_INFO_SOCIETE_MAIL)."<br>\n";
|
||||
print '</div>';
|
||||
|
||||
dol_htmloutput_errors($errmsg);
|
||||
|
||||
print '<div align="center">';
|
||||
print '<div id="divsubscribe">';
|
||||
|
||||
|
||||
// Print form
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" name="newmember">'."\n";
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" / >';
|
||||
@ -631,13 +629,8 @@ print '</td></tr>'."\n";
|
||||
print '<tr><td>'.$langs->trans("URLPhoto").'</td><td><input type="text" name="photo" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('photo')).'"></td></tr>'."\n";
|
||||
// Public
|
||||
print '<tr><td>'.$langs->trans("Public").'</td><td><input type="checkbox" name="public"></td></tr>'."\n";
|
||||
// Extrafields
|
||||
foreach($extrafields->attribute_label as $key=>$value)
|
||||
{
|
||||
print "<tr><td>".$value."</td><td>";
|
||||
print $extrafields->showInputField($key,GETPOST('options_'.$key));
|
||||
print "</td></tr>\n";
|
||||
}
|
||||
// Other attributes
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
|
||||
// Comments
|
||||
print '<tr>';
|
||||
print '<td class="tdtop">'.$langs->trans("Comments").'</td>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user