Fix navigation on resources

This commit is contained in:
Laurent Destailleur 2019-11-02 00:17:08 +01:00
parent cea2c3a9f4
commit 941043dd67
5 changed files with 53 additions and 47 deletions

View File

@ -57,7 +57,16 @@ if ($object->fetch($id) >= 0)
$linkback = '<a href="'.DOL_URL_ROOT.'/comm/mailing/list.php">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/comm/mailing/list.php">'.$langs->trans("BackToList").'</a>';
$morehtmlright=''; $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.=') &nbsp; ';
}
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', $morehtmlright); dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', $morehtmlright);

View File

@ -65,11 +65,6 @@ else
} }
$search_agenda_label=GETPOST('search_agenda_label'); $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; $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
@ -79,7 +74,7 @@ $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (! $sortfield) $sortfield='a.datep,a.id'; if (! $sortfield) $sortfield='a.datep,a.id';
if (! $sortorder) $sortorder='DESC'; if (! $sortorder) $sortorder='DESC,DESC';
// Initialize technical objects // Initialize technical objects
$object=new MyObject($db); $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 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; 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 * 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 $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'); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');

View File

@ -37,6 +37,13 @@ require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->load("companies"); $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')) if (GETPOST('actioncode', 'array'))
{ {
$actioncode=GETPOST('actioncode', 'array', 3); $actioncode=GETPOST('actioncode', 'array', 3);
@ -48,21 +55,6 @@ else
} }
$search_agenda_label=GETPOST('search_agenda_label'); $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; $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
@ -74,9 +66,20 @@ $pagenext = $page + 1;
if (! $sortfield) $sortfield='a.datep,a.id'; if (! $sortfield) $sortfield='a.datep,a.id';
if (! $sortorder) $sortorder='DESC,DESC'; 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')); $hookmanager->initHooks(array('agendaresource'));
// Security check
if( ! $user->rights->resource->read)
{
accessforbidden();
}
/* /*
* Actions * Actions
@ -110,10 +113,9 @@ if (empty($reshook))
*/ */
$contactstatic = new Contact($db); $contactstatic = new Contact($db);
$form = new Form($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.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
@ -121,9 +123,6 @@ if ($id > 0 || $ref)
$langs->load("companies"); $langs->load("companies");
$picto = 'resource'; $picto = 'resource';
$object = new Dolresource($db);
$result = $object->fetch($id);
$title=$langs->trans("Agenda"); $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; if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/productnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->ref." - ".$title;
llxHeader('', $title); llxHeader('', $title);
@ -138,13 +137,15 @@ if ($id > 0 || $ref)
$linkback = '<a href="'.DOL_URL_ROOT.'/resource/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/resource/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
$morehtmlref.='</div>';
$shownav = 1; $shownav = 1;
if ($user->societe_id && ! in_array('resource', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; 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 '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '</div>'; print '</div>';
@ -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) )) if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
{ {
print '<br>'; $param='&id='.$object->id.'&socid='.$socid;
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
$param='&id='.$id; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
print_barre_liste($langs->trans("ActionsOnResource"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlcenter, '', 0, 1, 1); print_barre_liste($langs->trans("ActionsOnResource"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlcenter, '', 0, 1, 1);

View File

@ -63,9 +63,9 @@ $extrafields->fetch_name_optionals_label($object->table_element);
/******************************************************************* /*
* ACTIONS * Actions
********************************************************************/ */
$hookmanager->initHooks(array('resource', 'resource_card','globalcard')); $hookmanager->initHooks(array('resource', 'resource_card','globalcard'));
$parameters=array('resource_id'=>$id); $parameters=array('resource_id'=>$id);
@ -211,18 +211,17 @@ if (empty($reshook))
} }
/*************************************************** /*
* VIEW * View
* */
* Put here all code to build page
****************************************************/
$title = $langs->trans($action == 'create' ? 'AddResource' : 'ResourceSingular'); $title = $langs->trans($action == 'create' ? 'AddResource' : 'ResourceSingular');
llxHeader('', $title, ''); llxHeader('', $title, '');
$form = new Form($db); $form = new Form($db);
$formresource = new FormResource($db); $formresource = new FormResource($db);
if ($action == 'create' || $object->fetch($id) > 0) if ($action == 'create' || $object->fetch($id, $ref) > 0)
{ {
if ($action == 'create') if ($action == 'create')
{ {

View File

@ -82,7 +82,7 @@ $form = new Form($db);
llxHeader('', $langs->trans("Resource")); llxHeader('', $langs->trans("Resource"));
if ($object->id) if ($object->id > 0)
{ {
$object->fetch_thirdparty(); $object->fetch_thirdparty();