Fix regression

This commit is contained in:
Laurent Destailleur 2023-03-15 10:45:16 +01:00
commit a9e8a3ed93
4 changed files with 171 additions and 158 deletions

View File

@ -261,6 +261,11 @@ if ($object->id > 0) {
$param .= '&limit='.$limit; $param .= '&limit='.$limit;
} }
// Try to know count of actioncomm from cache
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
$cachekey = 'count_events_thirdparty_'.$object->id;
$nbEvent = dol_getcache($cachekey);
print load_fiche_titre($langs->trans("ActionsOnContract"), $newcardbutton, ''); print load_fiche_titre($langs->trans("ActionsOnContract"), $newcardbutton, '');
//print_barre_liste($langs->trans("ActionsOnCompany"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $newcardbutton, '', 0, 1, 1); //print_barre_liste($langs->trans("ActionsOnCompany"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $newcardbutton, '', 0, 1, 1);

View File

@ -88,7 +88,7 @@ function contract_prepare_head(Contrat $object)
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/contract/agenda.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/contrat/agenda.php?id='.$object->id;
$head[$h][1] = $langs->trans("Events"); $head[$h][1] = $langs->trans("Events");
if (isModEnabled('agenda')&& (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { if (isModEnabled('agenda')&& (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
$nbEvent = 0; $nbEvent = 0;

View File

@ -5413,7 +5413,7 @@ function load_fiche_titre($titre, $morehtmlright = '', $picto = 'generic', $pict
* @param string $morecss More css to the table * @param string $morecss More css to the table
* @param int $limit Max number of lines (-1 = use default, 0 = no limit, > 0 = limit). * @param int $limit Max number of lines (-1 = use default, 0 = no limit, > 0 = limit).
* @param int $hideselectlimit Force to hide select limit * @param int $hideselectlimit Force to hide select limit
* @param int $hidenavigation Force to hide all navigation tools * @param int $hidenavigation Force to hide the arrows and page for navigation
* @param int $pagenavastextinput 1=Do not suggest list of pages to navigate but suggest the page number into an input field. * @param int $pagenavastextinput 1=Do not suggest list of pages to navigate but suggest the page number into an input field.
* @param string $morehtmlrightbeforearrow More html to show (before arrows) * @param string $morehtmlrightbeforearrow More html to show (before arrows)
* @return void * @return void
@ -5536,8 +5536,8 @@ function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '',
} }
} }
if (($savlimit || $morehtmlright || $morehtmlrightbeforearrow) && empty($hidenavigation)) { if ($savlimit || $morehtmlright || $morehtmlrightbeforearrow) {
print_fleche_navigation((int) $page, $file, $options, $nextpage, $pagelist, $morehtmlright, $savlimit, $totalnboflines, $hideselectlimit, $morehtmlrightbeforearrow); // output the div and ul for previous/last completed with page numbers into $pagelist print_fleche_navigation((int) $page, $file, $options, $nextpage, $pagelist, $morehtmlright, $savlimit, $totalnboflines, $hideselectlimit, $morehtmlrightbeforearrow, $hidenavigation); // output the div and ul for previous/last completed with page numbers into $pagelist
} }
// js to autoselect page field on focus // js to autoselect page field on focus
@ -5571,9 +5571,10 @@ function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '',
* @param int $totalnboflines Total number of records/lines for all pages (if known) * @param int $totalnboflines Total number of records/lines for all pages (if known)
* @param int $hideselectlimit Force to hide select limit * @param int $hideselectlimit Force to hide select limit
* @param string $beforearrows HTML content to show before arrows. Must NOT contains '<li> </li>' tags. * @param string $beforearrows HTML content to show before arrows. Must NOT contains '<li> </li>' tags.
* @param int $hidenavigation Force to hide the arrows and page for navigation
* @return void * @return void
*/ */
function print_fleche_navigation($page, $file, $options = '', $nextpage = 0, $betweenarrows = '', $afterarrows = '', $limit = -1, $totalnboflines = 0, $hideselectlimit = 0, $beforearrows = '') function print_fleche_navigation($page, $file, $options = '', $nextpage = 0, $betweenarrows = '', $afterarrows = '', $limit = -1, $totalnboflines = 0, $hideselectlimit = 0, $beforearrows = '', $hidenavigation = 0)
{ {
global $conf, $langs; global $conf, $langs;
@ -5583,6 +5584,7 @@ function print_fleche_navigation($page, $file, $options = '', $nextpage = 0, $be
print $beforearrows; print $beforearrows;
print '</li>'; print '</li>';
} }
if (!empty($hidenavigation)) {
if ((int) $limit > 0 && empty($hideselectlimit)) { if ((int) $limit > 0 && empty($hideselectlimit)) {
$pagesizechoices = '10:10,15:15,20:20,30:30,40:40,50:50,100:100,250:250,500:500,1000:1000'; $pagesizechoices = '10:10,15:15,20:20,30:30,40:40,50:50,100:100,250:250,500:500,1000:1000';
$pagesizechoices .= ',5000:5000,10000:10000,20000:20000'; $pagesizechoices .= ',5000:5000,10000:10000,20000:20000';
@ -5647,6 +5649,7 @@ function print_fleche_navigation($page, $file, $options = '', $nextpage = 0, $be
print $afterarrows; print $afterarrows;
print '</li>'; print '</li>';
} }
}
print '</ul></div>'."\n"; print '</ul></div>'."\n";
} }

View File

@ -38,6 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('agenda', 'bills', 'companies', 'orders', 'propal')); $langs->loadLangs(array('agenda', 'bills', 'companies', 'orders', 'propal'));
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'thirdpartyagenda';
if (GETPOST('actioncode', 'array')) { if (GETPOST('actioncode', 'array')) {
$actioncode = GETPOST('actioncode', 'array', 3); $actioncode = GETPOST('actioncode', 'array', 3);
@ -79,9 +80,16 @@ $socid = GETPOST('socid', 'int');
if ($user->socid) { if ($user->socid) {
$socid = $user->socid; $socid = $user->socid;
} }
$result = $object->fetch($socid);
if ($result <= 0) {
accessforbidden('Third party not found');
}
$result = restrictedArea($user, 'societe', $socid, '&societe'); $result = restrictedArea($user, 'societe', $socid, '&societe');
/* /*
* Actions * Actions
*/ */
@ -114,82 +122,79 @@ if (empty($reshook)) {
$form = new Form($db); $form = new Form($db);
if ($socid > 0) { $title = $langs->trans("Agenda");
$result = $object->fetch($socid); if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
$title = $langs->trans("Agenda");
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
$title = $object->name." - ".$title; $title = $object->name." - ".$title;
} }
$help_url = ''; $help_url = '';
llxHeader('', $title, $help_url); llxHeader('', $title, $help_url);
if (isModEnabled('notification')) { if (isModEnabled('notification')) {
$langs->load("mails"); $langs->load("mails");
} }
$head = societe_prepare_head($object); $head = societe_prepare_head($object);
print dol_get_fiche_head($head, 'agenda', $langs->trans("ThirdParty"), -1, $object->picto); print dol_get_fiche_head($head, 'agenda', $langs->trans("ThirdParty"), -1, $object->picto);
$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$morehtmlref = ''; $morehtmlref = '';
dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom', $morehtmlref); dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom', $morehtmlref);
print '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
$object->info($socid); $object->info($socid);
dol_print_object_info($object, 1); dol_print_object_info($object, 1);
print '</div>'; print '</div>';
print dol_get_fiche_end(); print dol_get_fiche_end();
// Actions buttons // Actions buttons
$objthirdparty = $object; $objthirdparty = $object;
$objcon = new stdClass(); $objcon = new stdClass();
$out = ''; $out = '';
$permok = $user->hasRight('agenda', 'myactions', 'create'); $permok = $user->hasRight('agenda', 'myactions', 'create');
if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) {
if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') { if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') {
$out .= '&amp;originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&amp;socid='.$objthirdparty->id : '').'&amp;backtopage='.urlencode($_SERVER['PHP_SELF'].($objthirdparty->id > 0 ? '?socid='.$objthirdparty->id : '')); $out .= '&amp;originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&amp;socid='.$objthirdparty->id : '').'&amp;backtopage='.urlencode($_SERVER['PHP_SELF'].($objthirdparty->id > 0 ? '?socid='.$objthirdparty->id : ''));
} }
$out .= (!empty($objcon->id) ? '&amp;contactid='.$objcon->id : ''); $out .= (!empty($objcon->id) ? '&amp;contactid='.$objcon->id : '');
$out .= '&amp;datep='.dol_print_date(dol_now(), 'dayhourlog'); $out .= '&amp;datep='.dol_print_date(dol_now(), 'dayhourlog');
} }
$morehtmlright = ''; $morehtmlright = '';
$messagingUrl = DOL_URL_ROOT.'/societe/messaging.php?socid='.$object->id; $messagingUrl = DOL_URL_ROOT.'/societe/messaging.php?socid='.$object->id;
$morehtmlright .= dolGetButtonTitle($langs->trans('ShowAsConversation'), '', 'fa fa-comments imgforviewmode', $messagingUrl, '', 1); $morehtmlright .= dolGetButtonTitle($langs->trans('ShowAsConversation'), '', 'fa fa-comments imgforviewmode', $messagingUrl, '', 1);
$messagingUrl = DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id; $messagingUrl = DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id;
$morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-bars imgforviewmode', $messagingUrl, '', 2); $morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-bars imgforviewmode', $messagingUrl, '', 2);
// // Show link to send an email (if read and not closed) // // Show link to send an email (if read and not closed)
// $btnstatus = $object->status < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage"; // $btnstatus = $object->status < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage";
// $url = 'card.php?track_id='.$object->track_id.'&action=presend_addmessage&mode=init&private_message=0&send_email=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?track_id='.$object->track_id).'#formmailbeforetitle'; // $url = 'card.php?track_id='.$object->track_id.'&action=presend_addmessage&mode=init&private_message=0&send_email=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?track_id='.$object->track_id).'#formmailbeforetitle';
// $morehtmlright .= dolGetButtonTitle($langs->trans('SendMail'), '', 'fa fa-paper-plane', $url, 'email-title-button', $btnstatus); // $morehtmlright .= dolGetButtonTitle($langs->trans('SendMail'), '', 'fa fa-paper-plane', $url, 'email-title-button', $btnstatus);
// // Show link to add a private message (if read and not closed) // // Show link to add a private message (if read and not closed)
// $btnstatus = $object->status < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage"; // $btnstatus = $object->status < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage";
// $url = 'card.php?track_id='.$object->track_id.'&action=presend_addmessage&mode=init&backtopage='.urlencode($_SERVER["PHP_SELF"].'?track_id='.$object->track_id).'#formmailbeforetitle'; // $url = 'card.php?track_id='.$object->track_id.'&action=presend_addmessage&mode=init&backtopage='.urlencode($_SERVER["PHP_SELF"].'?track_id='.$object->track_id).'#formmailbeforetitle';
// $morehtmlright .= dolGetButtonTitle($langs->trans('TicketAddMessage'), '', 'fa fa-comment-dots', $url, 'add-new-ticket-title-button', $btnstatus); // $morehtmlright .= dolGetButtonTitle($langs->trans('TicketAddMessage'), '', 'fa fa-comment-dots', $url, 'add-new-ticket-title-button', $btnstatus);
if (isModEnabled('agenda')) { if (isModEnabled('agenda')) {
if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) {
$morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out); $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out);
} }
} }
if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
print '<br>'; print '<br>';
$param = '&socid='.urlencode($socid); $param = '&socid='.urlencode($socid);
@ -214,9 +219,9 @@ if ($socid > 0) {
// TODO Replace this with same code than into list.php // TODO Replace this with same code than into list.php
show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module); show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module);
}
} }
// End of page // End of page
llxFooter(); llxFooter();
$db->close(); $db->close();