Skip to content

Commit

Permalink
Merge branch '6.0' of git@github.com:Dolibarr/dolibarr.git into 6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Aug 11, 2017
2 parents d37d1a0 + 5c53081 commit 9d4d85c
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 57 deletions.
118 changes: 63 additions & 55 deletions htdocs/resource/add.php
Expand Up @@ -66,63 +66,71 @@
// 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
Expand Down
7 changes: 5 additions & 2 deletions htdocs/resource/card.php
Expand Up @@ -54,10 +54,13 @@
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);

Expand Down Expand Up @@ -162,7 +165,7 @@
$form = new Form($db);
$formresource = new FormResource($db);

if ( $object->fetch($id) > 0 )
if ( $objectFetchRes > 0 )
{
$head=resource_prepare_head($object);

Expand Down

0 comments on commit 9d4d85c

Please sign in to comment.