Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tk2408 3290 retours #502

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion htdocs/core/boxes/box_dolibarr_state_board.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public function loadBox($max = 5)
'expensereports' => DOL_DOCUMENT_ROOT . "/expensereport/class/expensereport.class.php",
'holidays' => DOL_DOCUMENT_ROOT . "/holiday/class/holiday.class.php",
'ticket' => DOL_DOCUMENT_ROOT . "/ticket/class/ticket.class.php",
'resource' => DOL_DOCUMENT_ROOT . "/resource/class/resource.class.php"
'resource' => DOL_DOCUMENT_ROOT . "/resource/class/dolresource.class.php"
);
$links = array(
'users' => DOL_URL_ROOT . '/user/list.php',
Expand Down
4 changes: 3 additions & 1 deletion htdocs/core/class/commonobject.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -7616,6 +7616,8 @@ public function showOutputField($val, $key, $value, $moreparam = '', $keysuffix
$selectkey = "rowid";
$keyList = 'rowid';

$selectkey = $InfoFieldList[2];

if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) {
$selectkey = $InfoFieldList[2];
$keyList = $InfoFieldList[2].' as rowid';
Expand All @@ -7636,7 +7638,7 @@ public function showOutputField($val, $key, $value, $moreparam = '', $keysuffix

$sql = "SELECT ".$keyList;
$sql .= ' FROM '.$this->db->prefix().$InfoFieldList[0];
if (strpos($InfoFieldList[4], 'extra') !== false) {
if (!empty($InfoFieldList[4]) && strpos($InfoFieldList[4], 'extra') !== false) {
$sql .= ' as main';
}
if ($selectkey == 'rowid' && empty($value)) {
Expand Down
2 changes: 2 additions & 0 deletions htdocs/core/lib/functions2.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2666,6 +2666,8 @@ function getModuleDirForApiClass($moduleobject)
$moduledirforclass = 'fichinter';
} elseif ($moduleobject == 'mos') {
$moduledirforclass = 'mrp';
} elseif ($moduleobject == 'resourcesapi') {
$moduledirforclass = 'resource';
} elseif (in_array($moduleobject, array('products', 'expensereports', 'users', 'tickets', 'boms', 'receptions'))) {
$moduledirforclass = preg_replace('/s$/', '', $moduleobject);
}
Expand Down
4 changes: 2 additions & 2 deletions htdocs/resource/agenda.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php';
require_once DOL_DOCUMENT_ROOT.'/resource/class/resource.class.php';
require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php';

// Load translation files required by the page
$langs->load('companies');
Expand Down Expand Up @@ -79,7 +79,7 @@
$extrafields = new ExtraFields($db);
$hookmanager->initHooks(array('agendaresource'));

$object = new Resource($db);
$object = new DolResource($db);

// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
Expand Down
5 changes: 3 additions & 2 deletions htdocs/resource/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
// Load Dolibarr environment
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.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';
require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
Expand All @@ -49,7 +49,7 @@
accessforbidden();
}

$object = new Resource($db);
$object = new DolResource($db);
$extrafields = new ExtraFields($db);

// fetch optionals attributes and labels
Expand Down Expand Up @@ -283,6 +283,7 @@

dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);

$object->loadTypeLabel();

print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
Expand Down
12 changes: 6 additions & 6 deletions htdocs/resource/class/api_resources.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

use Luracast\Restler\RestException;

require_once __DIR__ . '/resource.class.php';
require_once __DIR__ . '/dolresource.class.php';

/**
* API class for mymodule myobject
Expand All @@ -29,12 +29,12 @@
class ResourcesApi extends DolibarrApi
{
/**
* @var Resource $resource {@type Resource}
* @var DolResource $resource {@type DolResource}
*/
/*
* @var mixed TODO: set type
*/
public Resource $resource;
public DolResource $resource;

/**
* Constructor
Expand All @@ -46,7 +46,7 @@ public function __construct()
{
global $db;
$this->db = $db;
$this->resource = new Resource($this->db);
$this->resource = new DolResource($this->db);
}


Expand Down Expand Up @@ -106,7 +106,7 @@ public function get($id)
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '', $properties = '')
{
$obj_ret = array();
$tmpobject = new Resource($this->db);
$tmpobject = new DolResource($this->db);

if (!DolibarrApiAccess::$user->hasRight('resource', 'read')) {
throw new RestException(403);
Expand Down Expand Up @@ -167,7 +167,7 @@ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100,
$num = $this->db->num_rows($result);
while ($i < $num) {
$obj = $this->db->fetch_object($result);
$tmp_object = new Resource($this->db);
$tmp_object = new DolResource($this->db);
if ($tmp_object->fetch($obj->rowid)) {
$obj_ret[] = $this->_filterObjectProperties($this->_cleanObjectDatas($tmp_object), $properties);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

/**
* \file class/resource.class.php
* \file class/dolresource.class.php
* \ingroup resource
* \brief This file is a CRUD class file for Resource (Create/Read/Update/Delete)
*/
Expand All @@ -31,7 +31,7 @@
/**
* Class for Resource
*/
class Resource extends CommonObject
class DolResource extends CommonObject
{
/**
* @var string ID of module.
Expand Down Expand Up @@ -112,10 +112,10 @@ class Resource extends CommonObject
public $fields = array(
"rowid" => array("type" => "integer", "label" => "TechnicalID", "enabled" => "1", 'position' => 1, 'notnull' => 1, "visible" => "0", "noteditable" => "1", "index" => "1"),
"entity" => array("type" => "integer", "label" => "Entity", "enabled" => "1", 'position' => 2, 'notnull' => 1, "visible" => "0", "default" => "1", "index" => "1"),
"ref" => array("type" => "varchar(255)", "label" => "ResourceName", "enabled" => "1", 'position' => 20, 'notnull' => 1, "visible" => "1", "index" => "1", "validate" => "1"),
"ref" => array("type" => "varchar(255)", "label" => "ResourceFormLabel_ref", "enabled" => "1", 'position' => 20, 'notnull' => 1, "visible" => "1", "index" => "1", "validate" => "1"),
"description" => array("type" => "text", "label" => "Description", "enabled" => "1", 'position' => 30, 'notnull' => 0, "visible" => "1", "validate" => "1"),
"fk_code_type_resource" => array("type" => "sellist:c_type_resource:label", "label" => "ResourceType", "enabled" => "1", 'position' => 40, 'notnull' => 0, "visible" => "1"),
"fk_country" => array("type" => "integer:ccountry:/core/class/country.class.php", "label" => "Country", "enabled" => "1", 'position' => 230, 'notnull' => 0, "visible" => "1"),
"fk_code_type_resource" => array("type" => "sellist:c_type_resource:label:code", "label" => "ResourceType", "enabled" => "1", 'position' => 40, 'notnull' => 0, "visible" => "1"),
"fk_country" => array("type" => "integer:ccountry:/core/class/ccountry.class.php", "label" => "Country", "enabled" => "1", 'position' => 230, 'notnull' => 0, "visible" => "1"),
"datec" => array("type" => "datetime", "label" => "DateCreation", "enabled" => "1", 'position' => 130, 'notnull' => 0, "visible" => "-2"),
"date_valid" => array("type" => "datetime", "label" => "DateValid", "enabled" => "1", 'position' => 140, 'notnull' => 0, "visible" => "-2"),
"fk_user_author" => array("type" => "integer:User:user/class/user.class.php", "label" => "UserAuthor", "enabled" => "1", 'position' => 150, 'notnull' => 0, "visible" => "-2"),
Expand Down
6 changes: 3 additions & 3 deletions htdocs/resource/class/html.formresource.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* \brief Class file to manage forms into resource module
*/
require_once DOL_DOCUMENT_ROOT."/core/class/html.form.class.php";
require_once DOL_DOCUMENT_ROOT."/resource/class/resource.class.php";
require_once DOL_DOCUMENT_ROOT."/resource/class/dolresource.class.php";


/**
Expand Down Expand Up @@ -87,7 +87,7 @@ public function select_resource_list($selected = '', $htmlname = 'fk_resource',
$out = '';
$outarray = array();

$resourcestat = new Resource($this->db);
$resourcestat = new DolResource($this->db);

$resources_used = $resourcestat->fetchAll('ASC', 't.rowid', $limit, 0, $filter);

Expand Down Expand Up @@ -180,7 +180,7 @@ public function select_types_resource($selected = '', $htmlname = 'type_resource
// phpcs:enable
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);

Expand Down
4 changes: 2 additions & 2 deletions htdocs/resource/contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

// Load Dolibarr environment
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.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
Expand All @@ -41,7 +41,7 @@
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09');

$object = new Resource($db);
$object = new DolResource($db);


// Load object
Expand Down
4 changes: 2 additions & 2 deletions htdocs/resource/document.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

// Load Dolibarr environment
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.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php';
Expand Down Expand Up @@ -70,7 +70,7 @@
}


$object = new Resource($db);
$object = new DolResource($db);

// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
Expand Down
4 changes: 2 additions & 2 deletions htdocs/resource/element_resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

// Load Dolibarr environment
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.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
if (isModEnabled('project')) {
Expand All @@ -47,7 +47,7 @@
$page = GETPOST('page','int');
*/

$object = new Resource($db);
$object = new DolResource($db);

$hookmanager->initHooks(array('element_resource'));
$object->available_resources = array('resource');
Expand Down
Loading
Loading