diff --git a/ChangeLog b/ChangeLog index 3418d0c834b..e812e4dd422 100644 --- a/ChangeLog +++ b/ChangeLog @@ -31,7 +31,7 @@ Dolibarr better: So if you included it into your module, change your code like this to be compatible with all version: $res=@include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; if (! $res) include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php'; - +- Class Resource was renamed into DolResource to avoid conflict with a reserved PHP word. ***** ChangeLog for 3.9.1 compared to 3.9.* ***** diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 5de04c6718e..85ebe30dec6 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1963,6 +1963,11 @@ function getElementProperties($element_type) $module='ficheinter'; $subelement='fichinter'; } + if ($element_type == 'dolresource') { + $classpath = 'resource/class'; + $module='resource'; + $subelement='dolresource'; + } $classfile = strtolower($subelement); $classname = ucfirst($subelement); diff --git a/htdocs/core/tpl/resource_add.tpl.php b/htdocs/core/tpl/resource_add.tpl.php index e2add5fb266..482dad50085 100644 --- a/htdocs/core/tpl/resource_add.tpl.php +++ b/htdocs/core/tpl/resource_add.tpl.php @@ -13,7 +13,7 @@ $out .= ''; $out .= ''; $out .= ''; $out .= ''; -$out .= ''; +$out .= ''; // Place diff --git a/htdocs/resource/add.php b/htdocs/resource/add.php index 679ef545442..cf13c79560f 100644 --- a/htdocs/resource/add.php +++ b/htdocs/resource/add.php @@ -1,7 +1,7 @@ - * Copyright (C) 2015 Alexandre Spangaro - * Copyright (C) 2015 Laurent Destailleur +/* Copyright (C) 2013 Jean-François Ferry + * Copyright (C) 2015 Alexandre Spangaro + * Copyright (C) 2015 Laurent Destailleur * * 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 @@ -18,15 +18,14 @@ */ /** - * \file resource/add.php - * \ingroup resource - * \brief Page to manage resource object - * Initialy built by build_class_from_table on 2013-07-24 16:03 + * \file resource/add.php + * \ingroup resource + * \brief Page to manage resource object */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/resource/class/resource.class.php'; +require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; require_once DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php'; // Load traductions files required by page @@ -36,15 +35,15 @@ $langs->load("other"); $langs->load("resource"); // Get parameters -$id = GETPOST('id','int'); -$action = GETPOST('action','alpha'); -$cancel = GETPOST('cancel','alpha'); +$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; if ($page == -1) { - $page = 0 ; + $page = 0 ; } $limit = $conf->global->limit; @@ -56,60 +55,60 @@ $pagenext = $page + 1; // Protection if external user if ($user->societe_id > 0) { - accessforbidden(); + accessforbidden(); } -$object = new Resource($db); +$object = new DolResource($db); if ($action == 'confirm_add_resource') { - if (! $cancel) - { - $error=''; + if (! $cancel) + { + $error=''; - $ref=GETPOST('ref','alpha'); - $description=GETPOST('description','alpha'); - $fk_code_type_resource=GETPOST('fk_code_type_resource','alpha'); + $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 (empty($ref)) + { + $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")); + setEventMessages($mesg, null, 'errors'); + $error++; + } - if (! $error) - { - $object=new Resource($db); - $object->ref=$ref; - $object->description=$description; - $object->fk_code_type_resource=$fk_code_type_resource; + if (! $error) + { + $object=new Dolresource($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(); - 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"); - } + $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"); + } } @@ -122,58 +121,58 @@ $formresource = new FormResource($db); if (! $action) { - $pagetitle=$langs->trans('AddResource'); - llxHeader('',$pagetitle,''); - print load_fiche_titre($pagetitle,'','title_generic'); + $pagetitle=$langs->trans('AddResource'); + llxHeader('',$pagetitle,''); + print load_fiche_titre($pagetitle,'','title_generic'); - print '
'; - print ''; + print ''; + print ''; - dol_fiche_head(''); + dol_fiche_head(''); - print ''; + print '
'; - // Ref / label - $field = 'ref'; - print ''; - print ''; - print ''; - print ''; + // Ref / label + $field = 'ref'; + print ''; + print ''; + print ''; + print ''; - // Type - print ''; - print ''; + // Type + print ''; + print ''; - // Description - $field = 'description'; - print ''; - print ''; - print ''; - print ''; + // Description + $field = 'description'; + print ''; + print ''; + print ''; + print ''; - print '
'; - print $langs->trans('ResourceFormLabel_'.$field); - print ''; - print ''; - print '
'; + print $langs->trans('ResourceFormLabel_'.$field); + print ''; + print ''; + print '
'.$langs->trans("ResourceType").''; - $ret = $formresource->select_types_resource($object->fk_code_type_resource, 'fk_code_type_resource', '', 2, 1); - print '
'.$langs->trans("ResourceType").''; + $ret = $formresource->select_types_resource($object->fk_code_type_resource, 'fk_code_type_resource', '', 2, 1); + print '
'; - print $langs->trans('ResourceFormLabel_'.$field); - print ''; - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor($field, $$field, 160, '', '', false); - $doleditor->Create(); - print '
'; + print $langs->trans('ResourceFormLabel_'.$field); + print ''; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor($field, $$field, 160, '', '', false); + $doleditor->Create(); + print '
'; + print ''; - dol_fiche_end(''); + dol_fiche_end(''); - echo '
', - '', - '   ', - '', - '
'; + echo '
', + '', + '   ', + '', + '
'; - print '
'; + print ''; } diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index 31fb6a955b1..206c2eea644 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -29,7 +29,7 @@ if (! $res) $res=@include("../../main.inc.php"); // For "custom" directory if (! $res) die("Include of main fails"); require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; -require_once 'class/resource.class.php'; +require_once 'class/dolresource.class.php'; require_once 'class/html.formresource.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php'; @@ -56,7 +56,7 @@ if ($user->societe_id > 0) if( ! $user->rights->resource->read) accessforbidden(); -$object = new Resource($db); +$object = new Dolresource($db); $hookmanager->initHooks(array('resource_card','globalcard')); $parameters=array('resource_id'=>$id); diff --git a/htdocs/resource/class/resource.class.php b/htdocs/resource/class/dolresource.class.php similarity index 99% rename from htdocs/resource/class/resource.class.php rename to htdocs/resource/class/dolresource.class.php index bfd4f04c3e5..b6b4eec8be2 100644 --- a/htdocs/resource/class/resource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2013-2015 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 @@ -28,7 +28,7 @@ require_once DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php"; /** * DAO Resource object */ -class Resource extends CommonObject +class Dolresource extends CommonObject { var $element='resource'; //!< Id that identify managed objects var $table_element='resource'; //!< Name of table without prefix where object is stored @@ -414,7 +414,7 @@ class Resource extends CommonObject while ($i < $num) { $obj = $this->db->fetch_object($resql); - $line = new Resource($this->db); + $line = new Dolresource($this->db); $line->id = $obj->rowid; $line->ref = $obj->ref; $line->description = $obj->description; @@ -488,7 +488,7 @@ class Resource extends CommonObject while ($i < $num) { $obj = $this->db->fetch_object($resql); - $line = new Resource($this->db); + $line = new Dolresource($this->db); $line->id = $obj->rowid; $line->resource_id = $obj->resource_id; $line->resource_type = $obj->resource_type; @@ -574,7 +574,7 @@ class Resource extends CommonObject while ($i < $num) { $obj = $this->db->fetch_object($resql); - $line = new Resource($this->db); + $line = new Dolresource($this->db); $line->id = $obj->rowid; $line->resource_id = $obj->resource_id; $line->resource_type = $obj->resource_type; diff --git a/htdocs/resource/class/html.formresource.class.php b/htdocs/resource/class/html.formresource.class.php index 4128de6fead..82b0ebe7d1a 100644 --- a/htdocs/resource/class/html.formresource.class.php +++ b/htdocs/resource/class/html.formresource.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) - 2013-2015 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 @@ -17,7 +17,7 @@ */ /** - * \file place/class/html.place.class.php + * \file place/class/html.formresource.class.php * \ingroup core * \brief Class file to manage forms into resource module */ @@ -75,7 +75,7 @@ class FormResource $out=''; $outarray=array(); - $resourcestat = new Resource($this->db); + $resourcestat = new Dolresource($this->db); $resources_used = $resourcestat->fetch_all('ASC', 't.rowid', $limit, $offset, $filter=''); @@ -159,7 +159,7 @@ class FormResource { global $langs,$user; - $resourcestat = new Resource($this->db); + $resourcestat = new Dolresource($this->db); dol_syslog(get_class($this)."::select_types_resource ".$selected.", ".$htmlname.", ".$filtertype.", ".$format,LOG_DEBUG); diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index e4477e1674a..62caa43f428 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -1,5 +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 @@ -16,18 +16,18 @@ */ /** - * \file resource/element_resource.php - * \ingroup resource - * \brief Page to show and manage linked resources to an element + * \file resource/element_resource.php + * \ingroup resource + * \brief Page to show and manage linked resources to an element */ $res=0; -$res=@include("../main.inc.php"); // For root directory -if (! $res) $res=@include("../../main.inc.php"); // For "custom" directory +$res=@include("../main.inc.php"); // For root directory +if (! $res) $res=@include("../../main.inc.php"); // For "custom" directory if (! $res) die("Include of main fails"); -require 'class/resource.class.php'; +require 'class/dolresource.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // Load traductions files requiredby by page @@ -35,92 +35,92 @@ $langs->load("resource"); $langs->load("other"); /* -$sortorder = GETPOST('sortorder','alpha'); -$sortfield = GETPOST('sortfield','alpha'); -$page = GETPOST('page','int'); +$sortorder = GETPOST('sortorder','alpha'); +$sortfield = GETPOST('sortfield','alpha'); +$page = GETPOST('page','int'); */ if( ! $user->rights->resource->read) - accessforbidden(); + accessforbidden(); -$object=new Resource($db); +$object=new Dolresource($db); $hookmanager->initHooks(array('element_resource')); -$object->available_resources = array('resource'); +$object->available_resources = array('dolresource'); // Get parameters -$id = GETPOST('id','int'); -$action = GETPOST('action','alpha'); -$mode = GETPOST('mode','alpha'); -$lineid = GETPOST('lineid','int'); -$element = GETPOST('element','alpha'); // element_type -$element_id = GETPOST('element_id','int'); -$resource_id = GETPOST('fk_resource','int'); -$resource_type = GETPOST('resource_type','alpha'); -$busy = GETPOST('busy','int'); -$mandatory = GETPOST('mandatory','int'); -$cancel = GETPOST('cancel','alpha'); -$confirm = GETPOST('confirm','alpha'); -$socid = GETPOST('socid','int'); +$id = GETPOST('id','int'); +$action = GETPOST('action','alpha'); +$mode = GETPOST('mode','alpha'); +$lineid = GETPOST('lineid','int'); +$element = GETPOST('element','alpha'); // element_type +$element_id = GETPOST('element_id','int'); +$resource_id = GETPOST('fk_resource','int'); +$resource_type = GETPOST('resource_type','alpha'); +$busy = GETPOST('busy','int'); +$mandatory = GETPOST('mandatory','int'); +$cancel = GETPOST('cancel','alpha'); +$confirm = GETPOST('confirm','alpha'); +$socid = GETPOST('socid','int'); -if ($socid > 0) +if ($socid > 0) { $element_id = $socid; $element = 'societe'; } - - + + /* * Actions */ if ($action == 'add_element_resource' && ! $cancel) { - $error++; - $res = 0; - if (! ($resource_id > 0)) - { - $error++; + $error++; + $res = 0; + if (! ($resource_id > 0)) + { + $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Resource")), null, 'errors'); $action=''; - } - else - { + } + else + { $objstat = fetchObjectByElement($element_id, $element); - + $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); - exit; - } + } + if (! $error && $res > 0) + { + setEventMessages($langs->trans('ResourceLinkedWithSuccess'), null, 'mesgs'); + header("Location: ".$_SERVER['PHP_SELF'].'?element='.$element.'&element_id='.$element_id); + exit; + } } // Update ressource if ($action == 'update_linked_resource' && $user->rights->resource->write && !GETPOST('cancel') ) { - $res = $object->fetch_element_resource($lineid); - if($res) - { - $object->busy = $busy; - $object->mandatory = $mandatory; + $res = $object->fetch_element_resource($lineid); + if($res) + { + $object->busy = $busy; + $object->mandatory = $mandatory; - $result = $object->update_element_resource($user); + $result = $object->update_element_resource($user); - if ($result >= 0) - { - setEventMessages($langs->trans('RessourceLineSuccessfullyUpdated'), null, 'mesgs'); - header("Location: ".$_SERVER['PHP_SELF']."?element=".$element."&element_id=".$element_id); - exit; - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - } - } + if ($result >= 0) + { + setEventMessages($langs->trans('RessourceLineSuccessfullyUpdated'), null, 'mesgs'); + header("Location: ".$_SERVER['PHP_SELF']."?element=".$element."&element_id=".$element_id); + exit; + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } } // Delete a resource linked to an element @@ -134,7 +134,7 @@ if ($action == 'confirm_delete_linked_resource' && $user->rights->resource->dele header("Location: ".$_SERVER['PHP_SELF']."?element=".$element."&element_id=".$element_id); exit; } - else + else { setEventMessages($object->error, $object->errors, 'errors'); } @@ -164,149 +164,149 @@ llxHeader('',$pagetitle,''); // Load available resource, declared by modules $ret = count($object->available_resources); if($ret == -1) { - dol_print_error($db,$object->error); - exit; + dol_print_error($db,$object->error); + exit; } if(!$ret) { - print '
'.$langs->trans('NoResourceInDatabase').'
'; + print '
'.$langs->trans('NoResourceInDatabase').'
'; } else { - // Confirmation suppression resource line - if ($action == 'delete_resource') - { - print $form->formconfirm("element_resource.php?element=".$element."&element_id=".$element_id."&id=".$id."&lineid=".$lineid,$langs->trans("DeleteResource"),$langs->trans("ConfirmDeleteResourceElement"),"confirm_delete_linked_resource",'','',1); - } + // Confirmation suppression resource line + if ($action == 'delete_resource') + { + print $form->formconfirm("element_resource.php?element=".$element."&element_id=".$element_id."&id=".$id."&lineid=".$lineid,$langs->trans("DeleteResource"),$langs->trans("ConfirmDeleteResourceElement"),"confirm_delete_linked_resource",'','',1); + } - /* - * Specific to agenda module - */ - if ($element_id && $element == 'action') - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; + /* + * Specific to agenda module + */ + if ($element_id && $element == 'action') + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; - $act = fetchObjectByElement($element_id,$element); - if (is_object($act)) - { + $act = fetchObjectByElement($element_id,$element); + if (is_object($act)) + { - $head=actions_prepare_head($act); + $head=actions_prepare_head($act); - dol_fiche_head($head, 'resources', $langs->trans("Action"),0,'action'); + dol_fiche_head($head, 'resources', $langs->trans("Action"),0,'action'); - // Affichage fiche action en mode visu - print ''; + // Affichage fiche action en mode visu + print '
'; - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - // Ref - print ''; + // Ref + print ''; - // Type - if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) - { - print ''; - } + // Type + if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) + { + print ''; + } - // Title - print ''; - print '
'.$langs->trans("Ref").''; - print $form->showrefnav($act, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', ''); - print '
'.$langs->trans("Ref").''; + print $form->showrefnav($act, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', ''); + print '
'.$langs->trans("Type").''.$act->type.'
'.$langs->trans("Type").''.$act->type.'
'.$langs->trans("Title").''.$act->label.'
'; + // Title + print ''.$langs->trans("Title").''.$act->label.''; + print ''; - dol_fiche_end(); - } - } + dol_fiche_end(); + } + } - /* - * Specific to thirdparty module - */ - if ($element_id && $element == 'societe') - { - $socstatic = fetchObjectByElement($element_id,$element); - if (is_object($socstatic)) - { - $savobject = $object; - - $object = $socstatic; - - require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; - $head = societe_prepare_head($socstatic); + /* + * Specific to thirdparty module + */ + if ($element_id && $element == 'societe') + { + $socstatic = fetchObjectByElement($element_id,$element); + if (is_object($socstatic)) + { + $savobject = $object; - dol_fiche_head($head, 'resources', $langs->trans("ThirdParty"),0,'company'); + $object = $socstatic; + + require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; + $head = societe_prepare_head($socstatic); + + dol_fiche_head($head, 'resources', $langs->trans("ThirdParty"),0,'company'); dol_banner_tab($socstatic, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom'); - - print '
'; - + + print '
'; + print '
'; - print ''; - - // Alias name (commercial, trademark or alias name) - print '"; - - print '
'.$langs->trans('AliasNames').''; - print $socstatic->name_alias; - print "
'; + print ''; - print ''; - - dol_fiche_end(); - - $object = $savobject; - } - } + // Alias name (commercial, trademark or alias name) + print '"; + + print '
'.$langs->trans('AliasNames').''; + print $socstatic->name_alias; + print "
'; + + print '
'; + + dol_fiche_end(); + + $object = $savobject; + } + } - //print load_fiche_titre($langs->trans('ResourcesLinkedToElement'),'',''); + //print load_fiche_titre($langs->trans('ResourcesLinkedToElement'),'',''); - foreach ($object->available_resources as $modresources => $resources) - { - $resources=(array) $resources; // To be sure $resources is an array - foreach($resources as $resource_obj) - { - $element_prop = getElementProperties($resource_obj); + foreach ($object->available_resources as $modresources => $resources) + { + $resources=(array) $resources; // To be sure $resources is an array + foreach($resources as $resource_obj) + { + $element_prop = getElementProperties($resource_obj); - //print '/'.$modresources.'/class/'.$resource_obj.'.class.php
'; + //print '/'.$modresources.'/class/'.$resource_obj.'.class.php
'; - $path = ''; - if(strpos($resource_obj,'@')) - $path .= '/'.$element_prop['module']; + $path = ''; + if(strpos($resource_obj,'@')) + $path .= '/'.$element_prop['module']; - $linked_resources = $object->getElementResources($element,$element_id,$resource_obj); + $linked_resources = $object->getElementResources($element,$element_id,$resource_obj); - // If we have a specific template we use it - if(file_exists(dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_add.tpl.php'))) - { - $res=include dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_add.tpl.php'); - } - else - { - $res=include DOL_DOCUMENT_ROOT . '/core/tpl/resource_add.tpl.php'; - } + // If we have a specific template we use it + if(file_exists(dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_add.tpl.php'))) + { + $res=include dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_add.tpl.php'); + } + else + { + $res=include DOL_DOCUMENT_ROOT . '/core/tpl/resource_add.tpl.php'; + } //var_dump($element_id); - if ($mode != 'add' || $resource_obj != $resource_type) - { - //print load_fiche_titre($langs->trans(ucfirst($element_prop['element']).'Singular')); + if ($mode != 'add' || $resource_obj != $resource_type) + { + //print load_fiche_titre($langs->trans(ucfirst($element_prop['element']).'Singular')); - // If we have a specific template we use it - if(file_exists(dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_view.tpl.php'))) - { - $res=@include dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_view.tpl.php'); + // If we have a specific template we use it + if(file_exists(dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_view.tpl.php'))) + { + $res=@include dol_buildpath($path.'/core/tpl/resource_'.$element_prop['element'].'_view.tpl.php'); - } - else - { - $res=include DOL_DOCUMENT_ROOT . '/core/tpl/resource_view.tpl.php'; - } - } - } - } + } + else + { + $res=include DOL_DOCUMENT_ROOT . '/core/tpl/resource_view.tpl.php'; + } + } + } + } } llxFooter(); diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index 9bfa7309167..d5b56cc9781 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -1,5 +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 @@ -16,34 +16,34 @@ */ /** - * \file resource/index.php - * \ingroup resource - * \brief Page to manage resource objects + * \file resource/index.php + * \ingroup resource + * \brief Page to manage resource objects */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/resource/class/resource.class.php'; +require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; -// Load translations files requiredby by page +// Load translations files required by page $langs->load("resource"); $langs->load("companies"); $langs->load("other"); // Get parameters -$id = GETPOST('id','int'); -$action = GETPOST('action','alpha'); +$id = GETPOST('id','int'); +$action = GETPOST('action','alpha'); -$lineid = GETPOST('lineid','int'); -$element = GETPOST('element','alpha'); -$element_id = GETPOST('element_id','int'); -$resource_id = GETPOST('resource_id','int'); +$lineid = GETPOST('lineid','int'); +$element = GETPOST('element','alpha'); +$element_id = GETPOST('element_id','int'); +$resource_id = GETPOST('resource_id','int'); -$sortorder = GETPOST('sortorder','alpha'); -$sortfield = GETPOST('sortfield','alpha'); -$page = GETPOST('page','int'); +$sortorder = GETPOST('sortorder','alpha'); +$sortfield = GETPOST('sortfield','alpha'); +$page = GETPOST('page','int'); -$object = new Resource($db); +$object = new Dolresource($db); $hookmanager->initHooks(array('resource_list')); @@ -52,7 +52,7 @@ if (empty($sortfield)) $sortfield="t.rowid"; if (empty($arch)) $arch = 0; if ($page == -1) { - $page = 0 ; + $page = 0 ; } $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; @@ -61,7 +61,7 @@ $pageprev = $page - 1; $pagenext = $page + 1; if( ! $user->rights->resource->read) - accessforbidden(); + accessforbidden(); /* @@ -86,72 +86,91 @@ llxHeader('',$pagetitle,''); // Confirmation suppression resource line if ($action == 'delete_resource') { - print $form->formconfirm($_SERVER['PHP_SELF']."?element=".$element."&element_id=".$element_id."&lineid=".$lineid,$langs->trans("DeleteResource"),$langs->trans("ConfirmDeleteResourceElement"),"confirm_delete_resource",'','',1); + print $form->formconfirm($_SERVER['PHP_SELF']."?element=".$element."&element_id=".$element_id."&lineid=".$lineid,$langs->trans("DeleteResource"),$langs->trans("ConfirmDeleteResourceElement"),"confirm_delete_resource",'','',1); } // Load object list $ret = $object->fetch_all($sortorder, $sortfield, $limit, $offset); if($ret == -1) { - dol_print_error($db,$object->error); - exit; + dol_print_error($db,$object->error); + exit; } else { print_barre_liste($pagetitle, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $ret+1, $object->num_all,'title_generic.png'); } if(!$ret) { - print '
'.$langs->trans('NoResourceInDatabase').'
'; + print '
'.$langs->trans('NoResourceInDatabase').'
'; } else { - $var=true; + $var=true; - print ''."\n"; - print ''; - 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('Action'),"","","","",'width="60" align="center"',"",""); - print "\n"; + print '
'."\n"; + print ''; + 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('Action'),"","","","",'width="60" align="center"',"",""); + print "\n"; - foreach ($object->lines as $resource) - { - $var=!$var; + foreach ($object->lines as $resource) + { + $var=!$var; - $style=''; - if($resource->id == GETPOST('lineid')) - $style='style="background: orange;"'; + $style=''; + if($resource->id == GETPOST('lineid')) + $style='style="background: orange;"'; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; - } + print ''; + } - print '
'; - print ''.$resource->id.''; - print '
'; + print ''.$resource->id.''; + print ''; - print $resource->ref; - print ''; + print $resource->ref; + print ''; - print $resource->type_label; - print ''; + print $resource->type_label; + print ''; - print ''; - print img_edit(); - print ''; - print ' '; - print ''; - print img_delete(); - print ''; - print ''; + print ''; + print img_edit(); + print ''; + print ' '; + print ''; + print img_delete(); + print ''; + print '
'; + print ''; } +/* + * Boutons actions +*/ +print '
'; +$parameters = array(); +$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been +// modified by hook +if (empty($reshook)) +{ + if ($action != "edit" ) + { + // Edit resource + if($user->rights->resource->write) + { + print '
'; + print ''.$langs->trans('AddResource').''; + print '
'; + } + } +} +print '
'; llxFooter(); $db->close(); - -