Merge branch 'dol_resource' of https://github.com/aternatik/dolibarr
into aternatik-dol_resource Conflicts: dev/initdata/img/printcompany.png htdocs/compta/bank/card.php
This commit is contained in:
commit
8fe799f424
@ -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.* *****
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -13,7 +13,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="resource_type" value="'.(empty($resource_type) ? 'resource' : $resource_type).'">';
|
||||
$out .= '<input type="hidden" name="resource_type" value="'.(empty($resource_type) ? 'dolresource' : $resource_type).'">';
|
||||
|
||||
|
||||
// Place
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||
* Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2013 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||
* Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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 '<form method="post" action="'.$_SERVER['PHP_SELF'].'" name="add_resource">';
|
||||
print '<input type="hidden" name="action" value="confirm_add_resource" />';
|
||||
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" name="add_resource">';
|
||||
print '<input type="hidden" name="action" value="confirm_add_resource" />';
|
||||
|
||||
dol_fiche_head('');
|
||||
dol_fiche_head('');
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref / label
|
||||
$field = 'ref';
|
||||
print '<tr>';
|
||||
print '<td class="fieldrequired">';
|
||||
print $langs->trans('ResourceFormLabel_'.$field);
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print '<input type="text" name="'.$field.'" value="'.$$field.'" />';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
// Ref / label
|
||||
$field = 'ref';
|
||||
print '<tr>';
|
||||
print '<td class="fieldrequired">';
|
||||
print $langs->trans('ResourceFormLabel_'.$field);
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print '<input type="text" name="'.$field.'" value="'.$$field.'" />';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Type
|
||||
print '<tr><td width="20%">'.$langs->trans("ResourceType").'</td>';
|
||||
print '<td>';
|
||||
$ret = $formresource->select_types_resource($object->fk_code_type_resource, 'fk_code_type_resource', '', 2, 1);
|
||||
print '</td></tr>';
|
||||
// Type
|
||||
print '<tr><td width="20%">'.$langs->trans("ResourceType").'</td>';
|
||||
print '<td>';
|
||||
$ret = $formresource->select_types_resource($object->fk_code_type_resource, 'fk_code_type_resource', '', 2, 1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Description
|
||||
$field = 'description';
|
||||
print '<tr>';
|
||||
print '<td class="tdtop">';
|
||||
print $langs->trans('ResourceFormLabel_'.$field);
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
$doleditor = new DolEditor($field, $$field, 160, '', '', false);
|
||||
$doleditor->Create();
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
// Description
|
||||
$field = 'description';
|
||||
print '<tr>';
|
||||
print '<td class="tdtop">';
|
||||
print $langs->trans('ResourceFormLabel_'.$field);
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
$doleditor = new DolEditor($field, $$field, 160, '', '', false);
|
||||
$doleditor->Create();
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</table>';
|
||||
print '</table>';
|
||||
|
||||
dol_fiche_end('');
|
||||
dol_fiche_end('');
|
||||
|
||||
echo '<div align="center">',
|
||||
'<input type="submit" class="button" name="add" value="'.$langs->trans('Save').'" />',
|
||||
' ',
|
||||
'<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'" />',
|
||||
'</div>';
|
||||
echo '<div align="center">',
|
||||
'<input type="submit" class="button" name="add" value="'.$langs->trans('Save').'" />',
|
||||
' ',
|
||||
'<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'" />',
|
||||
'</div>';
|
||||
|
||||
print '</form>';
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
/* Copyright (C) 2013-2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
*
|
||||
* 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;
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) - 2013 Jean-François FERRY <jfefe@aternatik.fr>
|
||||
/* Copyright (C) - 2013-2015 Jean-François FERRY <jfefe@aternatik.fr>
|
||||
*
|
||||
* 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);
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
/* Copyright (C) 2013 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
*
|
||||
* 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 '<div class="warning">'.$langs->trans('NoResourceInDatabase').'</div>';
|
||||
print '<div class="warning">'.$langs->trans('NoResourceInDatabase').'</div>';
|
||||
}
|
||||
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 '<table class="border" width="100%">';
|
||||
// Affichage fiche action en mode visu
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/comm/action/listactions.php">'.$langs->trans("BackToList").'</a>';
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/comm/action/listactions.php">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td colspan="3">';
|
||||
print $form->showrefnav($act, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', '');
|
||||
print '</td></tr>';
|
||||
// Ref
|
||||
print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td colspan="3">';
|
||||
print $form->showrefnav($act, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', '');
|
||||
print '</td></tr>';
|
||||
|
||||
// Type
|
||||
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Type").'</td><td colspan="3">'.$act->type.'</td></tr>';
|
||||
}
|
||||
// Type
|
||||
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Type").'</td><td colspan="3">'.$act->type.'</td></tr>';
|
||||
}
|
||||
|
||||
// Title
|
||||
print '<tr><td>'.$langs->trans("Title").'</td><td colspan="3">'.$act->label.'</td></tr>';
|
||||
print '</table>';
|
||||
// Title
|
||||
print '<tr><td>'.$langs->trans("Title").'</td><td colspan="3">'.$act->label.'</td></tr>';
|
||||
print '</table>';
|
||||
|
||||
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 '<div class="fichecenter">';
|
||||
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Alias name (commercial, trademark or alias name)
|
||||
print '<tr><td class="titelfield">'.$langs->trans('AliasNames').'</td><td colspan="3">';
|
||||
print $socstatic->name_alias;
|
||||
print "</td></tr>";
|
||||
|
||||
print '</table>';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '</div>';
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
$object = $savobject;
|
||||
}
|
||||
}
|
||||
// Alias name (commercial, trademark or alias name)
|
||||
print '<tr><td class="titelfield">'.$langs->trans('AliasNames').'</td><td colspan="3">';
|
||||
print $socstatic->name_alias;
|
||||
print "</td></tr>";
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '</div>';
|
||||
|
||||
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<br />';
|
||||
//print '/'.$modresources.'/class/'.$resource_obj.'.class.php<br />';
|
||||
|
||||
$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();
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013-2014 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
/* Copyright (C) 2013-2014 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
*
|
||||
* 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 '<div class="warning">'.$langs->trans('NoResourceInDatabase').'</div>';
|
||||
print '<div class="warning">'.$langs->trans('NoResourceInDatabase').'</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$var=true;
|
||||
$var=true;
|
||||
|
||||
print '<table class="noborder" width="100%">'."\n";
|
||||
print '<tr class="liste_titre">';
|
||||
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 "</tr>\n";
|
||||
print '<table class="noborder" width="100%">'."\n";
|
||||
print '<tr class="liste_titre">';
|
||||
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 "</tr>\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 '<tr '.$bc[$var].' '.$style.'><td>';
|
||||
print '<a href="./card.php?id='.$resource->id.'">'.$resource->id.'</a>';
|
||||
print '</td>';
|
||||
print '<tr '.$bc[$var].' '.$style.'><td>';
|
||||
print '<a href="./card.php?id='.$resource->id.'">'.$resource->id.'</a>';
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
print $resource->ref;
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print $resource->ref;
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
print $resource->type_label;
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print $resource->type_label;
|
||||
print '</td>';
|
||||
|
||||
print '<td align="center">';
|
||||
print '<a href="./card.php?action=edit&id='.$resource->id.'">';
|
||||
print img_edit();
|
||||
print '</a>';
|
||||
print ' ';
|
||||
print '<a href="./card.php?action=delete&id='.$resource->id.'">';
|
||||
print img_delete();
|
||||
print '</a>';
|
||||
print '</td>';
|
||||
print '<td align="center">';
|
||||
print '<a href="./card.php?action=edit&id='.$resource->id.'">';
|
||||
print img_edit();
|
||||
print '</a>';
|
||||
print ' ';
|
||||
print '<a href="./card.php?action=delete&id='.$resource->id.'">';
|
||||
print img_delete();
|
||||
print '</a>';
|
||||
print '</td>';
|
||||
|
||||
print '</tr>';
|
||||
}
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
print '</table>';
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Boutons actions
|
||||
*/
|
||||
print '<div class="tabsAction">';
|
||||
$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 '<div class="inline-block divButAction">';
|
||||
print '<a href="add.php" class="butAction">'.$langs->trans('AddResource').'</a>';
|
||||
print '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
print '</div>';
|
||||
|
||||
llxFooter();
|
||||
|
||||
$db->close();
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user