diff --git a/htdocs/core/tpl/resource_view.tpl.php b/htdocs/core/tpl/resource_view.tpl.php
index ef2963b28c1..d57b66cc331 100644
--- a/htdocs/core/tpl/resource_view.tpl.php
+++ b/htdocs/core/tpl/resource_view.tpl.php
@@ -32,7 +32,7 @@ if( (array) $linked_resources && count($linked_resources) > 0)
print '
'.$langs->trans('Resource').'
';
print ''.$langs->trans('Busy').'
';
print ''.$langs->trans('Mandatory').'
';
- print ''.$langs->trans('Edit').'
';
+ print ''.$langs->trans('Action').'
';
print '';
//print '';
@@ -86,8 +86,13 @@ if( (array) $linked_resources && count($linked_resources) > 0)
print '';
print '';
print '';
@@ -105,4 +110,4 @@ else {
print ''.$langs->trans('NoResourceLinked').'
';
}
-// FIN DU TPL
+// FIN DU TPL
\ No newline at end of file
diff --git a/htdocs/resource/add.php b/htdocs/resource/add.php
index fde152b6185..679644ac9e0 100644
--- a/htdocs/resource/add.php
+++ b/htdocs/resource/add.php
@@ -32,7 +32,7 @@ if (! $res) die("Include of main fails");
require_once 'class/resource.class.php';
require_once 'class/html.formresource.class.php';
-// Load traductions files requiredby by page
+// Load traductions files required by page
$langs->load("resource");
$langs->load("companies");
$langs->load("other");
@@ -41,6 +41,7 @@ $langs->load("resource@resource");
// Get parameters
$id = GETPOST('id','int');
$action = GETPOST('action','alpha');
+$cancel = GETPOST('cancel','alpha');
if (empty($sortorder)) $sortorder="DESC";
if (empty($sortfield)) $sortfield="t.rowid";
if (empty($arch)) $arch = 0;
@@ -65,57 +66,64 @@ $object = new Resource($db);
if ($action == 'confirm_add_resource')
{
- $error='';
-
- $ref=GETPOST('ref','alpha');
- $description=GETPOST('description','alpha');
- $fk_code_type_resource=GETPOST('fk_code_type_resource','alpha');
-
- if (empty($ref))
+ if (! $cancel)
{
- $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref"));
- setEventMessage($mesg, 'errors');
- $error++;
- }
-
- if (! $error)
- {
- $object=new Resource($db);
- $object->ref=$ref;
- $object->description=$description;
- $object->fk_code_type_resource=$fk_code_type_resource;
+ $error='';
- $result=$object->create($user);
- if ($result > 0)
+ $ref=GETPOST('ref','alpha');
+ $description=GETPOST('description','alpha');
+ $fk_code_type_resource=GETPOST('fk_code_type_resource','alpha');
+
+ if (empty($ref))
{
- // Creation OK
- $db->commit();
- setEventMessage($langs->trans('ResourceCreatedWithSuccess'));
- Header("Location: card.php?id=" . $object->id);
- return;
+ $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref"));
+ setEventMessage($mesg, 'errors');
+ $error++;
+ }
+
+ if (! $error)
+ {
+ $object=new Resource($db);
+ $object->ref=$ref;
+ $object->description=$description;
+ $object->fk_code_type_resource=$fk_code_type_resource;
+
+ $result=$object->create($user);
+ if ($result > 0)
+ {
+ // Creation OK
+ $db->commit();
+ setEventMessage($langs->trans('ResourceCreatedWithSuccess'));
+ Header("Location: card.php?id=" . $object->id);
+ return;
+ }
+ else
+ {
+ // Creation KO
+ setEventMessage($object->error, 'errors');
+ $action = '';
+ }
}
else
{
- // Creation KO
- setEventMessage($object->error, 'errors');
$action = '';
}
}
else
{
- $action = '';
+ Header("Location: list.php");
}
}
-/***************************************************
-* VIEW
-*
-****************************************************/
+/*
+ * View
+ *
+ */
$form=new Form($db);
$formresource = new FormResource($db);
-if ( !$action )
+if (! $action)
{
$pagetitle=$langs->trans('AddResource');
llxHeader('',$pagetitle,'');
@@ -161,8 +169,10 @@ if ( !$action )
print '';
- echo '';
}
}
- if ($action != "delete" )
+ if ($action != "delete" && $action != "edit")
{
- // Edit resource
+ // Delete resource
if($user->rights->resource->delete)
{
print '';
diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php
index 02a24735454..d50c9a4ec6f 100644
--- a/htdocs/resource/element_resource.php
+++ b/htdocs/resource/element_resource.php
@@ -1,6 +1,5 @@
+/* Copyright (C) 2013 Jean-François Ferry
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -32,7 +31,7 @@ require 'class/resource.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
// Load traductions files requiredby by page
-$langs->load("resource@resource");
+$langs->load("resource");
$langs->load("other");
// Get parameters
@@ -70,8 +69,9 @@ $resource_id = GETPOST('fk_resource','int');
$resource_type = GETPOST('resource_type','alpha');
$busy = GETPOST('busy','int');
$mandatory = GETPOST('mandatory','int');
+$cancel = GETPOST('cancel','alpha');
-if($action == 'add_element_resource' && !GETPOST('cancel'))
+if($action == 'add_element_resource' && ! $cancel)
{
$objstat = fetchObjectByElement($element_id,$element);
$res = $objstat->add_element_resource($resource_id,$resource_type,$busy,$mandatory);
@@ -251,9 +251,6 @@ else
foreach ($object->available_resources as $modresources => $resources)
{
- $langs->load($resources);
- //print ''.$modresources.'
';
-
$resources=(array) $resources; // To be sure $resources is an array
foreach($resources as $resource_obj)
{
@@ -301,7 +298,7 @@ else
{
print '';
}
diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php
index 9a0fca19781..ab70bc9a338 100644
--- a/htdocs/resource/list.php
+++ b/htdocs/resource/list.php
@@ -1,6 +1,5 @@
+/* Copyright (C) 2013-2014 Jean-François Ferry
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -116,7 +115,7 @@ else
print_liste_field_titre($langs->trans('Id'),$_SERVER['PHP_SELF'],'t.rowid','',$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans('Ref'),$_SERVER['PHP_SELF'],'t.ref','',$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans('ResourceType'),$_SERVER['PHP_SELF'],'ty.code','',$param,'',$sortfield,$sortorder);
- print_liste_field_titre($langs->trans('Edit'));
+ print_liste_field_titre($langs->trans('Action'),"","","","",'width="60" align="center"',"","");
print '';
foreach ($object->lines as $resource)
@@ -128,7 +127,7 @@ else
$style='style="background: orange;"';
print '| ';
- print $resource->id;
+ print ''.$resource->id.'';
print ' | ';
print '';
@@ -139,9 +138,14 @@ else
print $resource->type_label;
print ' | ';
- print '';
- print ''.$langs->trans('View').' ';
- print ''.$langs->trans('Edit').'';
+ print ' | ';
+ print '';
+ print img_edit();
+ print '';
+ print ' ';
+ print '';
+ print img_delete();
+ print '';
print ' | ';
print '
';