From 941043dd67356c7d40eefa83cb995c7707f30530 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Nov 2019 00:17:08 +0100 Subject: [PATCH] Fix navigation on resources --- htdocs/comm/mailing/info.php | 11 +++- .../template/myobject_agenda.php | 13 ++--- htdocs/resource/agenda.php | 55 +++++++++---------- htdocs/resource/card.php | 17 +++--- htdocs/resource/document.php | 4 +- 5 files changed, 53 insertions(+), 47 deletions(-) diff --git a/htdocs/comm/mailing/info.php b/htdocs/comm/mailing/info.php index 7b270e460c8..8d15f86915d 100644 --- a/htdocs/comm/mailing/info.php +++ b/htdocs/comm/mailing/info.php @@ -57,7 +57,16 @@ if ($object->fetch($id) >= 0) $linkback = ''.$langs->trans("BackToList").''; $morehtmlright=''; - if ($object->statut == 2) $morehtmlright.=' ('.$object->countNbOfTargets('alreadysent').'/'.$object->nbemail.') '; + $nbtry = $nbok = 0; + if ($object->statut == 2 || $object->statut == 3) + { + $nbtry = $object->countNbOfTargets('alreadysent'); + $nbko = $object->countNbOfTargets('alreadysentko'); + + $morehtmlright.=' ('.$nbtry.'/'.$object->nbemail; + if ($nbko) $morehtmlright.=' - '.$nbko.' '.$langs->trans("Error"); + $morehtmlright.=')   '; + } dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', $morehtmlright); diff --git a/htdocs/modulebuilder/template/myobject_agenda.php b/htdocs/modulebuilder/template/myobject_agenda.php index 8abb3623909..90a14061cdc 100644 --- a/htdocs/modulebuilder/template/myobject_agenda.php +++ b/htdocs/modulebuilder/template/myobject_agenda.php @@ -65,11 +65,6 @@ else } $search_agenda_label=GETPOST('search_agenda_label'); -// Security check - Protection if external user -//if ($user->societe_id > 0) access_forbidden(); -//if ($user->societe_id > 0) $socid = $user->societe_id; -//$result = restrictedArea($user, 'mymodule', $id); - $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); @@ -79,7 +74,7 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortfield) $sortfield='a.datep,a.id'; -if (! $sortorder) $sortorder='DESC'; +if (! $sortorder) $sortorder='DESC,DESC'; // Initialize technical objects $object=new MyObject($db); @@ -93,13 +88,17 @@ $extrafields->fetch_name_optionals_label($object->table_element); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mymodule->multidir_output[$object->entity] . "/" . $object->id; +// Security check - Protection if external user +//if ($user->societe_id > 0) access_forbidden(); +//if ($user->societe_id > 0) $socid = $user->societe_id; +//$result = restrictedArea($user, 'mymodule', $object->id); /* * Actions */ -$parameters=array('id'=>$socid); +$parameters=array('id'=>$id); $reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); diff --git a/htdocs/resource/agenda.php b/htdocs/resource/agenda.php index 0f2e79ef86f..303db5ec7b3 100644 --- a/htdocs/resource/agenda.php +++ b/htdocs/resource/agenda.php @@ -37,6 +37,13 @@ require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; // Load translation files required by the page $langs->load("companies"); +// Get parameters +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$backtopage = GETPOST('backtopage', 'alpha'); + if (GETPOST('actioncode', 'array')) { $actioncode=GETPOST('actioncode', 'array', 3); @@ -48,21 +55,6 @@ else } $search_agenda_label=GETPOST('search_agenda_label'); -// Security check -$id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); -if ($user->societe_id) $id=$user->societe_id; -// Protection if external user -if ($user->socid > 0) -{ - accessforbidden(); -} - -if( ! $user->rights->resource->read) -{ - accessforbidden(); -} - $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); @@ -74,9 +66,20 @@ $pagenext = $page + 1; if (! $sortfield) $sortfield='a.datep,a.id'; if (! $sortorder) $sortorder='DESC,DESC'; -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$object = new DolResource($db); +$object->fetch($id, $ref); + +// Initialize technical objects +//$object=new MyObject($db); +$extrafields = new ExtraFields($db); $hookmanager->initHooks(array('agendaresource')); +// Security check +if( ! $user->rights->resource->read) +{ + accessforbidden(); +} + /* * Actions @@ -110,10 +113,9 @@ if (empty($reshook)) */ $contactstatic = new Contact($db); - $form = new Form($db); -if ($id > 0 || $ref) +if ($object->id > 0) { require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -121,9 +123,6 @@ if ($id > 0 || $ref) $langs->load("companies"); $picto = 'resource'; - $object = new Dolresource($db); - $result = $object->fetch($id); - $title=$langs->trans("Agenda"); if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/productnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->ref." - ".$title; llxHeader('', $title); @@ -138,13 +137,15 @@ if ($id > 0 || $ref) $linkback = ''.$langs->trans("BackToList").''; + $morehtmlref='
'; + $morehtmlref.='
'; + $shownav = 1; if ($user->societe_id && ! in_array('resource', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; - dol_banner_tab($object, 'id', $linkback, $shownav, 'id'); + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); print '
'; - print '
'; print '
'; @@ -153,11 +154,9 @@ if ($id > 0 || $ref) if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) { - print '
'; - - $param='&id='.$id; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + $param='&id='.$object->id.'&socid='.$socid; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); print_barre_liste($langs->trans("ActionsOnResource"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlcenter, '', 0, 1, 1); diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index 2b4092671dc..f52da4934b0 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -63,9 +63,9 @@ $extrafields->fetch_name_optionals_label($object->table_element); -/******************************************************************* - * ACTIONS - ********************************************************************/ +/* + * Actions + */ $hookmanager->initHooks(array('resource', 'resource_card','globalcard')); $parameters=array('resource_id'=>$id); @@ -211,18 +211,17 @@ if (empty($reshook)) } -/*************************************************** -* VIEW -* -* Put here all code to build page -****************************************************/ +/* + * View + */ + $title = $langs->trans($action == 'create' ? 'AddResource' : 'ResourceSingular'); llxHeader('', $title, ''); $form = new Form($db); $formresource = new FormResource($db); -if ($action == 'create' || $object->fetch($id) > 0) +if ($action == 'create' || $object->fetch($id, $ref) > 0) { if ($action == 'create') { diff --git a/htdocs/resource/document.php b/htdocs/resource/document.php index fef78e8088c..9f1b5af4322 100644 --- a/htdocs/resource/document.php +++ b/htdocs/resource/document.php @@ -82,7 +82,7 @@ $form = new Form($db); llxHeader('', $langs->trans("Resource")); -if ($object->id) +if ($object->id > 0) { $object->fetch_thirdparty(); @@ -100,7 +100,7 @@ if ($object->id) } - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = '' . $langs->trans("BackToList") . ''; $morehtmlref='
';