Debug v18

This commit is contained in:
Laurent Destailleur 2023-05-31 14:02:05 +02:00
parent 3f066ff6fb
commit f4eecdc8e3
2 changed files with 97 additions and 56 deletions

View file

@ -1706,22 +1706,22 @@ class Form
/**
* Return list of all contacts (for a third party or all)
*
* @param int $socid Id ot third party or 0 for all
* @param string $selected Id contact pre-selectionne
* @param string $htmlname Name of HTML field ('none' for a not editable field)
* @param int $showempty 0=no empty value, 1=add an empty value, 2=add line 'Internal' (used by user edit), 3=add an empty value only if more than one record into list
* @param string $exclude List of contacts id to exclude
* @param string $limitto Disable answers that are not id in this array list
* @param integer $showfunction Add function into label
* @param string $morecss Add more class to class style
* @param integer $showsoc Add company into label
* @param int $forcecombo Force to use combo box
* @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
* @param bool $options_only Return options only (for ajax treatment)
* @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container
* @param string $htmlid Html id to use instead of htmlname
* @return int <0 if KO, Nb of contact in list if OK
* @deprecated You can use selectcontacts directly (warning order of param was changed)
* @param int $socid Id ot third party or 0 for all
* @param string $selected Id contact pre-selectionne
* @param string $htmlname Name of HTML field ('none' for a not editable field)
* @param int $showempty 0=no empty value, 1=add an empty value, 2=add line 'Internal' (used by user edit), 3=add an empty value only if more than one record into list
* @param string $exclude List of contacts id to exclude
* @param string $limitto Disable answers that are not id in this array list
* @param integer $showfunction Add function into label
* @param string $morecss Add more class to class style
* @param integer $showsoc Add company into label
* @param int $forcecombo Force to use combo box
* @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
* @param bool $options_only Return options only (for ajax treatment)
* @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container
* @param string $htmlid Html id to use instead of htmlname
* @return int <0 if KO, Nb of contact in list if OK
* @deprecated You can use selectcontacts directly (warning order of param was changed)
*/
public function select_contacts($socid, $selected = '', $htmlname = 'contactid', $showempty = 0, $exclude = '', $limitto = '', $showfunction = 0, $morecss = '', $showsoc = 0, $forcecombo = 0, $events = array(), $options_only = false, $moreparam = '', $htmlid = '')
{
@ -1731,28 +1731,28 @@ class Form
}
/**
* Return HTML code of the SELECT of list of all contacts (for a third party or all).
* This also set the number of contacts found into $this->num
* Return HTML code of the SELECT of list of all contacts (for a third party or all).
* This also set the number of contacts found into $this->num
*
* @since 9.0 Add afterSelectContactOptions hook
*
* @param int $socid Id ot third party or 0 for all or -1 for empty list
* @param array|int $selected Array of ID of pre-selected contact id
* @param string $htmlname Name of HTML field ('none' for a not editable field)
* @param int|string $showempty 0=no empty value, 1=add an empty value, 2=add line 'Internal' (used by user edit), 3=add an empty value only if more than one record into list
* @param string $exclude List of contacts id to exclude
* @param string $limitto Disable answers that are not id in this array list
* @param integer $showfunction Add function into label
* @param string $morecss Add more class to class style
* @param bool $options_only Return options only (for ajax treatment)
* @param integer $showsoc Add company into label
* @param int $forcecombo Force to use combo box (so no ajax beautify effect)
* @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
* @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container
* @param string $htmlid Html id to use instead of htmlname
* @param bool $multiple add [] in the name of element and add 'multiple' attribut
* @param integer $disableifempty Set tag 'disabled' on select if there is no choice
* @return int|string <0 if KO, HTML with select string if OK.
* @param int $socid Id ot third party or 0 for all or -1 for empty list
* @param array|int $selected Array of ID of pre-selected contact id
* @param string $htmlname Name of HTML field ('none' for a not editable field)
* @param int|string $showempty 0=no empty value, 1=add an empty value, 2=add line 'Internal' (used by user edit), 3=add an empty value only if more than one record into list
* @param string $exclude List of contacts id to exclude
* @param string $limitto Disable answers that are not id in this array list
* @param integer $showfunction Add function into label
* @param string $morecss Add more class to class style
* @param bool $options_only Return options only (for ajax treatment)
* @param integer $showsoc Add company into label
* @param int $forcecombo Force to use combo box (so no ajax beautify effect)
* @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
* @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container
* @param string $htmlid Html id to use instead of htmlname
* @param bool $multiple add [] in the name of element and add 'multiple' attribut
* @param integer $disableifempty Set tag 'disabled' on select if there is no choice
* @return int|string <0 if KO, HTML with select string if OK.
*/
public function selectcontacts($socid, $selected = '', $htmlname = 'contactid', $showempty = 0, $exclude = '', $limitto = '', $showfunction = 0, $morecss = '', $options_only = false, $showsoc = 0, $forcecombo = 0, $events = array(), $moreparam = '', $htmlid = '', $multiple = false, $disableifempty = 0)
{

View file

@ -1097,9 +1097,12 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
$arrayofmassactions = array();
$mode = 'view';
$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);
$selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields
$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
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";
@ -1199,6 +1202,12 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl
// Fields title search
// --------------------------------------------------------------------
print '<tr class="liste_titre">';
// Action column
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '<td class="liste_titre" align="right">';
print $form->showFilterButtons();
print '</td>';
}
foreach ($contactstatic->fields as $key => $val) {
$align = '';
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
@ -1241,15 +1250,21 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl
$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">';
print $form->showFilterButtons();
print '</td>';
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '<td class="liste_titre" align="right">';
print $form->showFilterButtons();
print '</td>';
}
print '</tr>'."\n";
// Fields title label
// --------------------------------------------------------------------
print '<tr class="liste_titre">';
// Action column
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'maxwidthsearch center ')."\n";
}
foreach ($contactstatic->fields as $key => $val) {
$align = '';
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
@ -1281,7 +1296,10 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
$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";
// Action column
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'maxwidthsearch center ')."\n";
}
print '</tr>'."\n";
$i = -1;
@ -1331,6 +1349,27 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl
print '<tr class="oddeven">';
// Actions
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '<td class="nowrap center">';
// Add to agenda
if (isModEnabled('agenda')&& $user->hasRight('agenda', 'myactions', 'create')) {
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> &nbsp; ';
}
// Edit
if ($user->hasRight('societe', 'contact', 'creer')) {
print '<a class="editfielda paddingleft" href="'.DOL_URL_ROOT.'/contact/card.php?action=edit&token='.newToken().'&id='.$obj->rowid.'&backtopage='.urlencode($backtopage).'">';
print img_edit();
print '</a>';
}
print '</td>';
}
// ID
if (!empty($arrayfields['t.rowid']['checked'])) {
print '<td>';
@ -1406,24 +1445,26 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Actions
print '<td align="right">';
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '<td class="nowrap center">';
// Add to agenda
if (isModEnabled('agenda')&& $user->hasRight('agenda', 'myactions', 'create')) {
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> &nbsp; ';
// Add to agenda
if (isModEnabled('agenda')&& $user->hasRight('agenda', 'myactions', 'create')) {
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> &nbsp; ';
}
// Edit
if ($user->hasRight('societe', 'contact', 'creer')) {
print '<a class="editfielda paddingleft" href="'.DOL_URL_ROOT.'/contact/card.php?action=edit&token='.newToken().'&id='.$obj->rowid.'&backtopage='.urlencode($backtopage).'">';
print img_edit();
print '</a>';
}
print '</td>';
}
// Edit
if ($user->hasRight('societe', 'contact', 'creer')) {
print '<a class="editfielda paddingleft" href="'.DOL_URL_ROOT.'/contact/card.php?action=edit&token='.newToken().'&id='.$obj->rowid.'&backtopage='.urlencode($backtopage).'">';
print img_edit();
print '</a>';
}
print '</td>';
print "</tr>\n";
$i++;
}