Skip to content
Snippets Groups Projects
Commit 9d4d85ca authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Merge branch '6.0' of git@github.com:Dolibarr/dolibarr.git into 6.0

parents d37d1a03 5c530810
No related branches found
No related tags found
No related merge requests found
......@@ -66,63 +66,71 @@ $extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
if ($action == 'confirm_add_resource')
$hookmanager->initHooks(array('resource_card_add','globalcard'));
$parameters=array();
$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 (empty($reshook))
{
if (! $cancel)
{
$error='';
$ref=GETPOST('ref','alpha');
$description=GETPOST('description','alpha');
$fk_code_type_resource=GETPOST('fk_code_type_resource','alpha');
if (empty($ref))
{
$mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref"));
setEventMessages($mesg, null, 'errors');
$error++;
}
if (! $error)
{
$object=new Dolresource($db);
$object->ref=$ref;
$object->description=$description;
$object->fk_code_type_resource=$fk_code_type_resource;
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
if ($ret < 0) {
$error ++;
}
$result=$object->create($user);
if ($result > 0)
{
// Creation OK
$db->commit();
setEventMessages($langs->trans('ResourceCreatedWithSuccess'), null, 'mesgs');
Header("Location: card.php?id=" . $object->id);
return;
}
else
{
// Creation KO
setEventMessages($object->error, $object->errors, 'errors');
$action = '';
}
}
else
{
$action = '';
}
}
else
{
Header("Location: list.php");
}
}
if ($action == 'confirm_add_resource')
{
if (! $cancel)
{
$error='';
$ref=GETPOST('ref','alpha');
$description=GETPOST('description','alpha');
$fk_code_type_resource=GETPOST('fk_code_type_resource','alpha');
if (empty($ref))
{
$mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref"));
setEventMessages($mesg, null, 'errors');
$error++;
}
if (! $error)
{
$object=new Dolresource($db);
$object->ref=$ref;
$object->description=$description;
$object->fk_code_type_resource=$fk_code_type_resource;
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
if ($ret < 0) {
$error ++;
}
$result=$object->create($user);
if ($result > 0)
{
// Creation OK
$db->commit();
setEventMessages($langs->trans('ResourceCreatedWithSuccess'), null, 'mesgs');
Header("Location: card.php?id=" . $object->id);
return;
}
else
{
// Creation KO
setEventMessages($object->error, $object->errors, 'errors');
$action = '';
}
}
else
{
$action = '';
}
}
else
{
Header("Location: list.php");
}
}
}
/*
* View
......
......@@ -54,10 +54,13 @@ if ($user->societe_id > 0)
accessforbidden();
}
if( ! $user->rights->resource->read)
if (! $user->rights->resource->read)
accessforbidden();
$object = new Dolresource($db);
$objectFetchRes = $object->fetch($id);
if (! ($objectFetchRes > 0)) dol_print_error($db, $object->error);
$extrafields = new ExtraFields($db);
......@@ -162,7 +165,7 @@ llxHeader('',$pagetitle,'');
$form = new Form($db);
$formresource = new FormResource($db);
if ( $object->fetch($id) > 0 )
if ( $objectFetchRes > 0 )
{
$head=resource_prepare_head($object);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment