Fix extrafields

This commit is contained in:
Laurent Destailleur 2018-01-31 14:01:58 +01:00
parent e9f8c7ba01
commit de0a8ba71f
9 changed files with 291 additions and 157 deletions

View File

@ -1245,7 +1245,7 @@ if ($id > 0)
print '</div>';
if (! empty($conf->global->MAIN_REPEATCONTACTONEACHTAB))
if (! empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_CUSTOMER_CARD))
{
// List of contacts
show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);

View File

@ -49,8 +49,8 @@ class Contact extends CommonObject
*/
public $fields=array(
'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'),
'lastname' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'),
'firstname' =>array('type'=>'varchar(128)', 'label'=>'Firstname', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>11, 'searchall'=>1, 'comment'=>'Reference of object'),
'lastname' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1),
'firstname' =>array('type'=>'varchar(128)', 'label'=>'Firstname', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>11, 'searchall'=>1),
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20),
'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>60),
'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>61),

View File

@ -33,14 +33,14 @@ if (GETPOST('formfilteraction') == 'listafterchangingselectedfields')
$tabparam=array();
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
if (GETPOST("selectedfields")) $tabparam["MAIN_SELECTEDFIELDS_".$varpage]=GETPOST("selectedfields");
else $tabparam["MAIN_SELECTEDFIELDS_".$varpage]='';
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$result=dol_set_user_param($db, $conf, $user, $tabparam);
//$action='list';
//var_dump($tabparam);exit;
}

View File

@ -259,9 +259,6 @@ class Conf
// Load translation object with current language
if (empty($this->global->MAIN_LANG_DEFAULT)) $this->global->MAIN_LANG_DEFAULT="en_US";
//if (! isset($this->global->MAIN_REPEATCONTACTONEACHTAB)) $this->global->MAIN_REPEATCONTACTONEACHTAB=1;
//if (! isset($this->global->MAIN_REPEATADDRESSONEACHTAB)) $this->global->MAIN_REPEATADDRESSONEACHTAB=1;
$rootfordata = DOL_DATA_ROOT;
$rootforuser = DOL_DATA_ROOT;
// If multicompany module is enabled, we redefine the root of data

View File

@ -1351,28 +1351,48 @@ class ExtraFields
/**
* Return HTML string to put an output field into a page
*
* @param string $key Key of attribute
* @param string $value Value to show
* @param string $moreparam To add more parameters on html input tag (only checkbox use html input for output rendering)
* @return string Formated value
* @param string $key Key of attribute
* @param string $value Value to show
* @param string $moreparam To add more parameters on html input tag (only checkbox use html input for output rendering)
* @param string $extrafieldsobjectkey If defined, use the new method to get extrafields data
* @return string Formated value
*/
function showOutputField($key,$value,$moreparam='')
function showOutputField($key, $value, $moreparam='', $extrafieldsobjectkey='')
{
global $conf,$langs;
$elementtype=$this->attribute_elementtype[$key]; // seems not used
$label=$this->attribute_label[$key];
$type=$this->attribute_type[$key];
$size=$this->attribute_size[$key];
$default=$this->attribute_default[$key];
$computed=$this->attribute_computed[$key];
$unique=$this->attribute_unique[$key];
$required=$this->attribute_required[$key];
$param=$this->attribute_param[$key];
$perms=$this->attribute_perms[$key];
$langfile=$this->attribute_langfile[$key];
$list=$this->attribute_list[$key];
$hidden=(($list == 0) ? 1 : 0); // If zero, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller)
if (! empty($extrafieldsobjectkey))
{
$elementtype=$this->attributes[$extrafieldsobjectkey]['elementtype'][$key]; // seems not used
$label=$this->attributes[$extrafieldsobjectkey]['label'][$key];
$type=$this->attributes[$extrafieldsobjectkey]['type'][$key];
$size=$this->attributes[$extrafieldsobjectkey]['size'][$key];
$default=$this->attributes[$extrafieldsobjectkey]['default'][$key];
$computed=$this->attributes[$extrafieldsobjectkey]['computed'][$key];
$unique=$this->attributes[$extrafieldsobjectkey]['unique'][$key];
$required=$this->attributes[$extrafieldsobjectkey]['required'][$key];
$param=$this->attributes[$extrafieldsobjectkey]['param'][$key];
$perms=$this->attributes[$extrafieldsobjectkey]['perms'][$key];
$langfile=$this->attributes[$extrafieldsobjectkey]['langfile'][$key];
$list=$this->attributes[$extrafieldsobjectkey]['list'][$key];
$hidden=(($list == 0) ? 1 : 0); // If zero, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller)
}
else
{
$elementtype=$this->attribute_elementtype[$key]; // seems not used
$label=$this->attribute_label[$key];
$type=$this->attribute_type[$key];
$size=$this->attribute_size[$key];
$default=$this->attribute_default[$key];
$computed=$this->attribute_computed[$key];
$unique=$this->attribute_unique[$key];
$required=$this->attribute_required[$key];
$param=$this->attribute_param[$key];
$perms=$this->attribute_perms[$key];
$langfile=$this->attribute_langfile[$key];
$list=$this->attribute_list[$key];
$hidden=(($list == 0) ? 1 : 0); // If zero, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller)
}
if ($hidden) return ''; // This is a protection. If field is hidden, we should just not call this method.
@ -1600,6 +1620,7 @@ class ExtraFields
elseif ($type == 'link')
{
$out='';
// only if something to display (perf)
if ($value)
{
@ -1648,14 +1669,16 @@ class ExtraFields
/**
* Return tag to describe alignement to use for this extrafield
*
* @param string $key Key of attribute
* @return string Formated value
* @param string $key Key of attribute
* @param string $extrafieldsobjectkey If defined, use the new method to get extrafields data
* @return string Formated value
*/
function getAlignFlag($key)
function getAlignFlag($key, $extrafieldsobjectkey='')
{
global $conf,$langs;
$type=$this->attribute_type[$key];
if (! empty($extrafieldsobjectkey)) $type=$this->attributes[$extrafieldsobjectkey]['type'][$key];
else $type=$this->attribute_type[$key];
$align='';

View File

@ -640,7 +640,6 @@ function isInEEC($object)
function show_projects($conf, $langs, $db, $object, $backtopage='', $nocreatelink=0, $morehtmlright='')
{
global $user;
global $bc;
$i = -1 ;
@ -768,10 +767,10 @@ function show_projects($conf, $langs, $db, $object, $backtopage='', $nocreatelin
*/
function show_contacts($conf,$langs,$db,$object,$backtopage='')
{
global $user,$conf;
global $bc;
global $user,$conf,$extrafields,$hookmanager;
global $contextpage;
$form= new Form($db);
$form = new Form($db);
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
@ -782,24 +781,67 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='')
$search_addressphone = GETPOST("search_addressphone",'alpha');
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="p.lastname";
if (! $sortfield) $sortfield="t.lastname";
if (! empty($conf->clicktodial->enabled))
{
$user->fetch_clicktodial(); // lecture des infos de clicktodial du user
}
$contactstatic = new Contact($db);
$extralabels=$extrafields->fetch_name_optionals_label($contactstatic->table_element);
$contactstatic->fields=array(
'name' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1),
'poste' =>array('type'=>'varchar(128)', 'label'=>'PostOfFunction', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20),
'address' =>array('type'=>'varchar(128)', 'label'=>'Address', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>30),
'statut' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>40, 'arrayofkeyval'=>array(0=>$contactstatic->LibStatut(0,1), 1=>$contactstatic->LibStatut(1,1))),
);
// Definition of fields for list
$arrayfields=array(
't.rowid'=>array('label'=>"TechnicalID", 'checked'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0), 'enabled'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0), 'position'=>1),
't.name'=>array('label'=>"Name", 'checked'=>1, 'position'=>10),
't.poste'=>array('label'=>"PostOrFunction", 'checked'=>1, 'position'=>20),
't.address'=>array('label'=>(empty($conf->dol_optimize_smallscreen) ? $langs->trans("Address").' / '.$langs->trans("Phone").' / '.$langs->trans("Email") : $langs->trans("Address")), 'checked'=>1, 'position'=>30),
't.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>40, 'align'=>'center'),
);
// Extra fields
if (is_array($extrafields->attributes[$contactstatic->table_element]['label']) && count($extrafields->attributes[$contactstatic->table_element]['label']))
{
foreach($extrafields->attributes[$contactstatic->table_element]['label'] as $key => $val)
{
if (! empty($extrafields->attributes[$contactstatic->table_element]['list'][$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$contactstatic->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$contactstatic->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$contactstatic->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$contactstatic->table_element]['list'][$key])!=3 && $extrafields->attributes[$contactstatic->table_element]['perms'][$key]));
}
}
// Initialize array of search criterias
$search=array();
foreach($contactstatic->fields as $key => $val)
{
if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha');
}
// 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
{
$search_status = '';
$search_name = '';
$search_addressphone = '';
$search_array_options=array();
foreach($contactstatic->fields as $key => $val)
{
$search[$key]='';
}
$toselect='';
}
$i=-1;
$contactstatic = new Contact($db);
if (! empty($conf->clicktodial->enabled))
{
$user->fetch_clicktodial(); // lecture des infos de clicktodial
}
$contactstatic->fields = dol_sort_array($contactstatic->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position');
$buttoncreate='';
if ($user->rights->societe->contact->creer)
@ -815,25 +857,30 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='')
print load_fiche_titre($title, $buttoncreate,'');
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'" name="formfilter">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="socid" value="'.$object->id.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
$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);
print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print "\n".'<table class="noborder" width="100%">'."\n";
print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print "\n".'<table class="tagtable liste">'."\n";
$param="socid=".$object->id;
if ($search_status != '') $param.='&amp;search_status='.$search_status;
if ($search_name != '') $param.='&amp;search_name='.urlencode($search_name);
$sql = "SELECT p.rowid, p.lastname, p.firstname, p.fk_pays as country_id, p.civility, p.poste, p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.email, p.skype, p.statut, p.photo,";
$sql .= " p.civility as civility_id, p.address, p.zip, p.town";
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p";
$sql .= " WHERE p.fk_soc = ".$object->id;
if ($search_status!='' && $search_status != '-1') $sql .= " AND p.statut = ".$db->escape($search_status);
if ($search_name) $sql .= " AND (p.lastname LIKE '%".$db->escape($search_name)."%' OR p.firstname LIKE '%".$db->escape($search_name)."%')";
$sql = "SELECT t.rowid, t.lastname, t.firstname, t.fk_pays as country_id, t.civility, t.poste, t.phone as phone_pro, t.phone_mobile, t.phone_perso, t.fax, t.email, t.skype, t.statut, t.photo,";
$sql .= " t.civility as civility_id, t.address, t.zip, t.town";
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as t";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople_extrafields as ef on (t.rowid = ef.fk_object)";
$sql .= " WHERE t.fk_soc = ".$object->id;
if ($search_status!='' && $search_status != '-1') $sql .= " AND t.statut = ".$db->escape($search_status);
if ($search_name) $sql .= " AND (t.lastname LIKE '%".$db->escape($search_name)."%' OR t.firstname LIKE '%".$db->escape($search_name)."%')";
$sql.= " ORDER BY $sortfield $sortorder";
dol_syslog('core/lib/company.lib.php :: show_contacts', LOG_DEBUG);
@ -842,59 +889,63 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='')
$num = $db->num_rows($result);
$colspan=9;
print '<tr class="liste_titre">';
// Photo - Name
print '<td class="liste_titre">';
print '<input type="text" class="flat minwidth75" name="search_name" value="'.dol_escape_htmltag($search_name).'">';
print '</td>';
// Position
print '<td class="liste_titre">';
print '</td>';
// Address - Phone - Email
print '<td class="liste_titre"></td>';
// Status
print '<td class="liste_titre maxwidthonsmartphone" align="center">';
print $form->selectarray('search_status', array('-1'=>'','0'=>$contactstatic->LibStatut(0,1),'1'=>$contactstatic->LibStatut(1,1)),$search_status);
print '</td>';
// Add to agenda
if (! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create)
{
$colspan++;
print '<td class="liste_titre"></td>';
}
// Action
print '<td class="liste_titre" align="right">';
$searchpicto=$form->showFilterButtons();
print $searchpicto;
print '</td>';
print "</tr>";
$titlefieldaddress=$langs->trans("Address").' / '.$langs->trans("Phone").' / '.$langs->trans("Email");
if (! empty($conf->dol_optimize_smallscreen)) $titlefieldaddress=$langs->trans("Address");
// Fields title search
// --------------------------------------------------------------------
print '<tr class="liste_titre">';
print_liste_field_titre("Name",$_SERVER["PHP_SELF"],"p.lastname","",$param,'',$sortfield,$sortorder);
print_liste_field_titre("Poste",$_SERVER["PHP_SELF"],"p.poste","",$param,'',$sortfield,$sortorder);
print_liste_field_titre($titlefieldaddress,$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder);
print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"p.statut","",$param,'align="center"',$sortfield,$sortorder);
// Add to agenda
if (! empty($conf->agenda->enabled) && ! empty($user->rights->agenda->myactions->create)) print_liste_field_titre('');
// Edit
print_liste_field_titre('');
print "</tr>\n";
foreach($contactstatic->fields as $key => $val)
{
$align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center';
if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap';
if ($key == 'status' || $key == 'statut') $align.=($align?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked']))
{
print '<td class="liste_titre'.($align?' '.$align:'').'">';
if (in_array($key, array('lastname','name'))) print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
elseif (in_array($key, array('statut'))) print $form->selectarray('search_status', array('-1'=>'','0'=>$contactstatic->LibStatut(0,1),'1'=>$contactstatic->LibStatut(1,1)),$search_status);
print '</td>';
}
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
// Fields from hook
$parameters=array('arrayfields'=>$arrayfields);
$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $contactstatic); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Action column
print '<td class="liste_titre" align="right">';
$searchpicto=$form->showFilterButtons();
print $searchpicto;
print '</td>';
print '</tr>'."\n";
// Fields title label
// --------------------------------------------------------------------
print '<tr class="liste_titre">';
foreach($contactstatic->fields as $key => $val)
{
$align='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center';
if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap';
if ($key == 'status' || $key == 'statut') $align.=($align?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n";
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
// Hook fields
$parameters=array('arrayfields'=>$arrayfields);
$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],'','','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n";
print '</tr>'."\n";
$i = -1;
if ($num || (GETPOST('button_search') || GETPOST('button_search.x') || GETPOST('button_search_x')))
{
$i=0;
$i = 0;
while ($i < $num)
{
@ -923,46 +974,81 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='')
$contactstatic->country_code = $country_code;
$contactstatic->setGenderFromCivility();
$contactstatic->fetch_optionals();
if (is_array($contactstatic->array_options))
{
foreach($contactstatic->array_options as $key => $val)
{
$obj->$key = $val;
}
}
print '<tr class="oddeven">';
// ID
if (! empty($arrayfields['t.rowid']['checked']))
{
print '<td>';
print $contactstatic->id;
print '</td>';
}
// Photo - Name
print '<td>';
print $form->showphoto('contact',$contactstatic,0,0,0,'photorefnoborder valignmiddle marginrightonly','small',1,0,1);
print $contactstatic->getNomUrl(0,'',0,'&backtopage='.urlencode($backtopage));
print '</td>';
if (! empty($arrayfields['t.name']['checked']))
{
print '<td>';
print $form->showphoto('contact',$contactstatic,0,0,0,'photorefnoborder valignmiddle marginrightonly','small',1,0,1);
print $contactstatic->getNomUrl(0,'',0,'&backtopage='.urlencode($backtopage));
print '</td>';
}
// Job position
print '<td>';
if ($obj->poste) print $obj->poste;
print '</td>';
if (! empty($arrayfields['t.poste']['checked']))
{
print '<td>';
if ($obj->poste) print $obj->poste;
print '</td>';
}
// Address - Phone - Email
print '<td>';
print $contactstatic->getBannerAddress('contact', $object);
print '</td>';
if (! empty($arrayfields['t.address']['checked']))
{
print '<td>';
print $contactstatic->getBannerAddress('contact', $object);
print '</td>';
}
// Status
print '<td align="center">'.$contactstatic->getLibStatut(5).'</td>';
if (! empty($arrayfields['t.statut']['checked']))
{
print '<td align="center">'.$contactstatic->getLibStatut(5).'</td>';
}
// Add to agenda
// Extra fields
$extrafieldsobjectkey='socpeople';
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Actions
print '<td align="right">';
// Add to agenda
if (! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create)
{
print '<td align="center">';
print '<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&actioncode=&contactid='.$obj->rowid.'&socid='.$object->id.'&backtopage='.urlencode($backtopage).'">';
print img_object($langs->trans("Event"),"action");
print '</a></td>';
print '</a> &nbsp; ';
}
// Edit
if ($user->rights->societe->contact->creer)
{
print '<td align="right">';
print '<a href="'.DOL_URL_ROOT.'/contact/card.php?action=edit&amp;id='.$obj->rowid.'&amp;backtopage='.urlencode($backtopage).'">';
print img_edit();
print '</a></td>';
print '</a>';
}
else print '<td>&nbsp;</td>';
print '</td>';
print "</tr>\n";
$i++;
@ -970,9 +1056,9 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='')
}
else
{
print '<tr class="oddeven">';
print '<td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("None").'</td>';
print "</tr>\n";
$colspan=1;
foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; }
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
}
print "\n</table>\n";
print '</div>';
@ -995,7 +1081,6 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='')
function show_addresses($conf,$langs,$db,$object,$backtopage='')
{
global $user;
global $bc;
require_once DOL_DOCUMENT_ROOT.'/societe/class/address.class.php';
@ -1087,7 +1172,7 @@ function show_addresses($conf,$langs,$db,$object,$backtopage='')
*/
function show_actions_todo($conf,$langs,$db,$filterobj,$objcon='',$noprint=0,$actioncode='')
{
global $bc,$user,$conf;
global $user,$conf;
$out = show_actions_done($conf,$langs,$db,$filterobj,$objcon,1,$actioncode, 'todo');
@ -1114,7 +1199,7 @@ function show_actions_todo($conf,$langs,$db,$filterobj,$objcon='',$noprint=0,$ac
*/
function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=0, $actioncode='', $donetodo='done', $filters=array(), $sortfield='a.datep,a.id', $sortorder='DESC')
{
global $bc,$user,$conf;
global $user,$conf;
global $form;
global $param;
@ -1560,7 +1645,6 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=
function show_subsidiaries($conf,$langs,$db,$object)
{
global $user;
global $bc;
$i=-1;

View File

@ -8,32 +8,69 @@ if (empty($conf) || ! is_object($conf))
}
// Loop to show all columns of extrafields from $obj, $extrafields and $db
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
if (! empty($extrafieldsobjectkey)) // New method: $extrafieldsobject can be 'societe', 'socpeople', ...
{
foreach($extrafields->attribute_label as $key => $val)
if (is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label']))
{
if (! empty($arrayfields["ef.".$key]['checked']))
foreach($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val)
{
$align=$extrafields->getAlignFlag($key);
print '<td';
if ($align) print ' align="'.$align.'"';
print '>';
$tmpkey='options_'.$key;
if (in_array($extrafields->attribute_type[$key], array('date', 'datetime', 'timestamp')))
if (! empty($arrayfields["ef.".$key]['checked']))
{
$value = $db->jdate($obj->$tmpkey);
$align=$extrafields->getAlignFlag($key, $extrafieldsobjectkey);
print '<td';
if ($align) print ' align="'.$align.'"';
print '>';
$tmpkey='options_'.$key;
if (in_array($extrafields->attributes[$extrafieldsobjectkey]['type'][$key], array('date', 'datetime', 'timestamp')))
{
$value = $db->jdate($obj->$tmpkey);
}
else
{
$value = $obj->$tmpkey;
}
print $extrafields->showOutputField($key, $value, '', $extrafieldsobjectkey);
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (! empty($val['isameasure']))
{
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='ef.'.$tmpkey;
$totalarray['val']['ef.'.$tmpkey] += $obj->$tmpkey;
}
}
else
}
}
}
else // Old method
{
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
if (! empty($arrayfields["ef.".$key]['checked']))
{
$value = $obj->$tmpkey;
}
print $extrafields->showOutputField($key, $value, '');
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (! empty($val['isameasure']))
{
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='ef.'.$tmpkey;
$totalarray['val']['ef.'.$tmpkey] += $obj->$tmpkey;
$align=$extrafields->getAlignFlag($key);
print '<td';
if ($align) print ' align="'.$align.'"';
print '>';
$tmpkey='options_'.$key;
if (in_array($extrafields->attribute_type[$key], array('date', 'datetime', 'timestamp')))
{
$value = $db->jdate($obj->$tmpkey);
}
else
{
$value = $obj->$tmpkey;
}
print $extrafields->showOutputField($key, $value, '');
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (! empty($val['isameasure']))
{
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='ef.'.$tmpkey;
$totalarray['val']['ef.'.$tmpkey] += $obj->$tmpkey;
}
}
}
}

View File

@ -779,7 +779,7 @@ if ($object->id > 0)
print '</div>';
if (! empty($conf->global->MAIN_REPEATCONTACTONEACHTAB))
if (! empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD))
{
print '<br>';
// List of contacts

View File

@ -44,11 +44,7 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$langs->load("companies");
$langs->load("commercial");
$langs->load("bills");
$langs->load("banks");
$langs->load("users");
$langs->loadLangs(array("companies","commercial","bills","banks","users"));
if (! empty($conf->categorie->enabled)) $langs->load("categories");
if (! empty($conf->incoterm->enabled)) $langs->load("incoterm");
if (! empty($conf->notification->enabled)) $langs->load("mails");
@ -115,6 +111,9 @@ if (empty($reshook))
exit;
}
}
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
}
@ -169,8 +168,6 @@ else
if ($action != 'presend')
{
print '<div class="fichecenter">';
// Contacts list
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
{
@ -182,10 +179,6 @@ else
{
$result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
}
print '</div>';
}
}