Add resources tab for products/services
This commit is contained in:
parent
71f30266dc
commit
b64cb4129f
@ -127,6 +127,25 @@ function product_prepare_head($object)
|
||||
$h++;
|
||||
}
|
||||
}
|
||||
|
||||
// Tab to link resources
|
||||
if (!empty($conf->resource->enabled))
|
||||
{
|
||||
if ($object->isProduct() && ! empty($conf->global->RESOURCE_ON_PRODUCTS))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT . '/resource/element_resource.php?element=product&ref=' . $object->ref;
|
||||
$head[$h][1] = $langs->trans("Resources");
|
||||
$head[$h][2] = 'resources';
|
||||
$h++;
|
||||
}
|
||||
if ($object->isService() && ! empty($conf->global->RESOURCE_ON_SERVICES))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT . '/resource/element_resource.php?element=service&ref=' . $object->ref;
|
||||
$head[$h][1] = $langs->trans("Resources");
|
||||
$head[$h][2] = 'resources';
|
||||
$h++;
|
||||
}
|
||||
}
|
||||
|
||||
// Show more tabs from modules
|
||||
// Entries must be declared in modules descriptor with line
|
||||
|
||||
@ -21,6 +21,7 @@ $out .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
$out .= '<input type="hidden" name="action" value="add_element_resource">';
|
||||
$out .= '<input type="hidden" name="element" value="'.$element.'">';
|
||||
$out .= '<input type="hidden" name="element_id" value="'.$element_id.'">';
|
||||
$out .= '<input type="hidden" name="ref" value="'.$element_ref.'">';
|
||||
$out .= '<input type="hidden" name="resource_type" value="'.(empty($resource_type) ? 'dolresource' : $resource_type).'">';
|
||||
|
||||
|
||||
|
||||
@ -31,6 +31,9 @@ if (! empty($conf->projet->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
|
||||
}
|
||||
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
|
||||
}
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('resource', 'other', 'interventions'));
|
||||
@ -79,7 +82,6 @@ if ($socid > 0) // Special for thirdparty
|
||||
|
||||
if ($action == 'add_element_resource' && ! $cancel)
|
||||
{
|
||||
$error++;
|
||||
$res = 0;
|
||||
if (! ($resource_id > 0))
|
||||
{
|
||||
@ -89,16 +91,20 @@ if ($action == 'add_element_resource' && ! $cancel)
|
||||
}
|
||||
else
|
||||
{
|
||||
$objstat = fetchObjectByElement($element_id, $element);
|
||||
$objstat = fetchObjectByElement($element_id, $element, $element_ref);
|
||||
$objstat->element = $element; // For externals module, we need to keep @xx
|
||||
$res = $objstat->add_element_resource($resource_id, $resource_type, $busy, $mandatory);
|
||||
}
|
||||
if (! $error && $res > 0)
|
||||
{
|
||||
setEventMessages($langs->trans('ResourceLinkedWithSuccess'), null, 'mesgs');
|
||||
header("Location: ".$_SERVER['PHP_SELF'].'?element='.$element.'&element_id='.$element_id);
|
||||
header("Location: ".$_SERVER['PHP_SELF'].'?element='.$element.'&element_id='.$objstat->id);
|
||||
exit;
|
||||
}
|
||||
else if ($objstat)
|
||||
{
|
||||
setEventMessages($objstat->error, $objstat->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
// Update ressource
|
||||
@ -415,6 +421,31 @@ else
|
||||
dol_fiche_end();
|
||||
}
|
||||
}
|
||||
|
||||
// Specific to product/service module
|
||||
if (($element_id || $element_ref) && ($element == 'product' || $element == 'service'))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
|
||||
|
||||
$product = new Product($db);
|
||||
$product->fetch($element_id, $element_ref);
|
||||
|
||||
if (is_object($product))
|
||||
{
|
||||
|
||||
$head = product_prepare_head($product);
|
||||
$titre=$langs->trans("CardProduct".$product->type);
|
||||
$picto=($product->type==Product::TYPE_SERVICE?'service':'product');
|
||||
|
||||
dol_fiche_head($head, 'resources', $titre, -1, $picto);
|
||||
|
||||
$shownav = 1;
|
||||
if ($user->societe_id && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0;
|
||||
dol_banner_tab($product, 'ref', '', $shownav, 'ref', 'ref', '', '&element='.$element);
|
||||
|
||||
dol_fiche_end();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// hook for other elements linked
|
||||
|
||||
Loading…
Reference in New Issue
Block a user