Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2022-08-31 15:29:43 +02:00
commit e733f3d1a1
33 changed files with 130 additions and 77 deletions

View File

@ -526,7 +526,7 @@ $tabcond[40] = (isModEnabled("societe") && !empty($conf->global->THIRDPARTY_ENAB
$tabcond[41] = !empty($conf->intracommreport->enabled);
$tabcond[42] = isModEnabled("product");
$tabcond[43] = isModEnabled("product") && !empty($conf->productbatch->enabled) && $conf->global->MAIN_FEATURES_LEVEL >= 2;
$tabcond[44] = !empty($conf->asset->enabled);
$tabcond[44] = isModEnabled('asset');
// List of help for fields (no more used, help is defined into tabcomplete)
$tabhelp = array();

View File

@ -22,6 +22,8 @@
* \brief Page to setup ECM (GED) module
*/
// Load Dolibarr environment
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
@ -37,6 +39,8 @@ if (!$user->admin) {
/*
* Action
*/
// set
if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
$code = $reg[1];
if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) {
@ -47,6 +51,7 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
}
}
// delete
if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
$code = $reg[1];
if (dolibarr_del_const($db, $code, $conf->entity) > 0) {

View File

@ -58,7 +58,7 @@ $permissiontoadd = $user->rights->asset->write; // Used by the include of action
if ($user->socid > 0) accessforbidden();
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
if (empty($conf->asset->enabled)) accessforbidden();
if (!isModEnabled('asset')) accessforbidden();
$result = $assetaccountancycodes->fetchAccountancyCodes($object->id);
if ($result < 0) {

View File

@ -86,7 +86,7 @@ $permissiontoadd = $user->rights->asset->write; // Used by the include of action
if ($user->socid > 0) accessforbidden();
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
if (empty($conf->asset->enabled)) accessforbidden();
if (!isModEnabled('asset')) accessforbidden();
/*

View File

@ -80,7 +80,7 @@ if ($user->socid > 0) accessforbidden();
if ($user->socid > 0) $socid = $user->socid;
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
if (empty($conf->asset->enabled)) accessforbidden();
if (!isModEnabled('asset')) accessforbidden();
if (!$permissiontoread) accessforbidden();

View File

@ -56,7 +56,7 @@ if ($id > 0 || !empty($ref)) {
if ($user->socid > 0) accessforbidden();
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
if (empty($conf->asset->enabled)) accessforbidden();
if (!isModEnabled('asset')) accessforbidden();
if (!empty($object->not_depreciated)) accessforbidden();
$object->asset_depreciation_options = &$assetdepreciationoptions;

View File

@ -58,7 +58,7 @@ $permissiontoadd = $user->rights->asset->write; // Used by the include of action
if ($user->socid > 0) accessforbidden();
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
if (empty($conf->asset->enabled)) accessforbidden();
if (!isModEnabled('asset')) accessforbidden();
if (!empty($object->not_depreciated)) accessforbidden();
$object->asset_depreciation_options = &$assetdepreciationoptions;

View File

@ -57,7 +57,7 @@ $permissiontoadd = $user->rights->asset->write; // Used by the include of action
if ($user->socid > 0) accessforbidden();
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
if (empty($conf->asset->enabled)) accessforbidden();
if (!isModEnabled('asset')) accessforbidden();
if (!isset($object->disposal_date) || $object->disposal_date === "") accessforbidden();

View File

@ -78,7 +78,7 @@ $permissiontoadd = $user->rights->asset->asset->write; // Used by the include of
if ($user->socid > 0) accessforbidden();
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
if (empty($conf->asset->enabled)) accessforbidden();
if (!isModEnabled('asset')) accessforbidden();
/*

View File

@ -125,7 +125,7 @@ $permissiontoadd = $user->rights->asset->write;
$permissiontodelete = $user->rights->asset->delete;
// Security check
if (empty($conf->asset->enabled)) {
if (!isModEnabled('asset')) {
accessforbidden('Module not enabled');
}
@ -134,7 +134,7 @@ if ($user->socid > 0) accessforbidden();
$socid = 0; if ($user->socid > 0) $socid = $user->socid;
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
if (empty($conf->asset->enabled)) accessforbidden();
if (!isModEnabled('asset')) accessforbidden();
if (!$permissiontoread) accessforbidden();

View File

@ -59,7 +59,7 @@ $permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rig
if ($user->socid > 0) accessforbidden();
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
restrictedArea($user, 'asset', $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
if (empty($conf->asset->enabled)) accessforbidden();
if (!isModEnabled('asset')) accessforbidden();
if (!$permissiontoread) accessforbidden();
$result = $assetaccountancycodes->fetchAccountancyCodes(0, $object->id);

View File

@ -88,7 +88,7 @@ if ($user->socid > 0) accessforbidden();
if ($user->socid > 0) $socid = $user->socid;
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
restrictedArea($user, 'asset', $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
if (empty($conf->asset->enabled)) accessforbidden();
if (!isModEnabled('asset')) accessforbidden();
if (!$permissiontoread) accessforbidden();

View File

@ -80,7 +80,7 @@ if ($user->socid > 0) accessforbidden();
if ($user->socid > 0) $socid = $user->socid;
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
restrictedArea($user, 'asset', $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
if (empty($conf->asset->enabled)) accessforbidden();
if (!isModEnabled('asset')) accessforbidden();
if (!$permissiontoread) accessforbidden();

View File

@ -59,7 +59,7 @@ $permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rig
if ($user->socid > 0) accessforbidden();
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
restrictedArea($user, 'asset', $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
if (empty($conf->asset->enabled)) accessforbidden();
if (!isModEnabled('asset')) accessforbidden();
if (!$permissiontoread) accessforbidden();
$object->asset_depreciation_options = &$assetdepreciationoptions;

View File

@ -126,7 +126,7 @@ $permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rig
$permissiontodelete = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->delete) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->delete)));
// Security check
if (empty($conf->asset->enabled)) {
if (!isModEnabled('asset')) {
accessforbidden('Module not enabled');
}
@ -140,7 +140,7 @@ if ($user->socid > 0) {
}
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
restrictedArea($user, 'asset', $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
if (empty($conf->asset->enabled)) accessforbidden();
if (!isModEnabled('asset')) accessforbidden();
if (!$permissiontoread) accessforbidden();
/*

View File

@ -57,7 +57,7 @@ $permissiontoadd = $user->rights->asset->write; // Used by the include of action
if ($user->socid > 0) accessforbidden();
$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
if (empty($conf->asset->enabled)) accessforbidden();
if (!isModEnabled('asset')) accessforbidden();
/*

View File

@ -32,6 +32,8 @@
* \brief Card of a contact
*/
// Load Dolibarr environment
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
@ -52,14 +54,15 @@ $langs->loadLangs(array('companies', 'users', 'other', 'commercial'));
$mesg = ''; $error = 0; $errors = array();
// Get parameters
$action = (GETPOST('action', 'alpha') ? GETPOST('action', 'alpha') : 'view');
$confirm = GETPOST('confirm', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$cancel = GETPOST('cancel', 'alpha');
$id = GETPOST('id', 'int');
$socid = GETPOST('socid', 'int');
// Initialize technical object
$object = new Contact($db);
$extrafields = new ExtraFields($db);

View File

@ -22,9 +22,11 @@
/**
* \file htdocs/contact/consumption.php
* \ingroup societe
* \brief Add a tab on thirpdarty view to list all products/services bought or sells by thirdparty
* \brief Add a tab on thirdparty view to list all products/services bought or sells by thirdparty
*/
// Load Dolibarr environment
require "../main.inc.php";
require_once DOL_DOCUMENT_ROOT.'/core/lib/contact.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';

View File

@ -23,6 +23,8 @@
* \brief Page with attached files on contact
*/
// Load Dolibarr environment
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -33,6 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
// Load translation files required by the page
$langs->loadLangs(array('other', 'companies', 'contact'));
// Get parameters
$id = GETPOST('id', 'int');
$action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm', 'alpha');

View File

@ -33,6 +33,8 @@
* \brief Page to list all contacts
*/
// Load Dolibarr environment
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
@ -44,6 +46,7 @@ $langs->loadLangs(array("companies", "suppliers", "categories"));
$socialnetworks = getArrayOfSocialNetworks();
// Get parameters
$action = GETPOST('action', 'aZ09');
$massaction = GETPOST('massaction', 'alpha');
$show_files = GETPOST('show_files', 'int');

View File

@ -15,8 +15,8 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* or see https://www.gnu.org/
*/
/**
@ -24,6 +24,7 @@
* \ingroup takepos
* \brief File with Simple ref numbering module for takepos
*/
dol_include_once('/core/modules/takepos/modules_takepos.php');
/**
@ -80,10 +81,10 @@ class mod_takepos_ref_simple extends ModeleNumRefTakepos
}
/**
* Test si les numeros deja en vigueur dans la base ne provoquent pas de
* de conflits qui empechera cette numerotation de fonctionner.
* Test if the numbers already in the database do not cause any conflicts that will prevent this
* of conflicts that will prevent this numbering from working.
*
* @return boolean false si conflit, true si ok
* @return boolean false if KO (there is a conflict), true if OK
*/
public function canBeActivated()
{

View File

@ -17,8 +17,8 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* or see https://www.gnu.org/
*/
/**
@ -26,6 +26,7 @@
* \ingroup takepos
* \brief File with Universal ref numbering module for takepos
*/
dol_include_once('/core/modules/takepos/modules_takepos.php');
/**
@ -51,7 +52,7 @@ class mod_takepos_ref_universal extends ModeleNumRefTakepos
public $nom = 'Universal';
/**
* Renvoi la description du modele de numerotation
* return description of the numbering model
*
* @return string Texte descripif
*/
@ -77,7 +78,7 @@ class mod_takepos_ref_universal extends ModeleNumRefTakepos
$tooltip .= $langs->trans('GenericMaskCodes5');
$tooltip .= $langs->trans('CashDeskGenericMaskCodes6');
// Parametrage du prefix
// Setting up the prefix
$texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
$texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat minwidth175" name="maskvalue" value="'.$conf->global->TAKEPOS_REF_UNIVERSAL_MASK.'">', $tooltip, 1, 1).'</td>';
@ -92,7 +93,7 @@ class mod_takepos_ref_universal extends ModeleNumRefTakepos
}
/**
* Renvoi un exemple de numerotation
* Return an example of numbering
*
* @return string Example
*/
@ -125,7 +126,7 @@ class mod_takepos_ref_universal extends ModeleNumRefTakepos
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
// On defini critere recherche compteur
// We define search criteria counter
$mask = $conf->global->TAKEPOS_REF_UNIVERSAL_MASK;
if (!$mask) {

View File

@ -16,14 +16,14 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* or see https://www.gnu.org/
*/
/**
* \file htdocs/core/modules/takepos/modules_takepos.php
* \ingroup takepos
* \brief Fichier contenant la classe mere de numerotation des tickets de caisse
* \brief File containing the parent class for the numbering of cash register receipts
*/

View File

@ -71,7 +71,7 @@ if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf-
if (in_array($object->element, array('propal', 'commande', 'order', 'facture', 'facturerec', 'invoice', 'supplier_proposal', 'order_supplier', 'invoice_supplier', 'invoice_supplier_rec'))) {
$colspan++; // With this, there is a column move button
}
if (!empty($conf->asset->enabled) && $object->element == 'invoice_supplier') {
if (isModEnabled('asset') && $object->element == 'invoice_supplier') {
$colspan++;
}

View File

@ -73,7 +73,7 @@ if (in_array($object->element, array('propal', 'supplier_proposal', 'facture', '
if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) {
$colspan += 2;
}
if (!empty($conf->asset->enabled) && $object->element == 'invoice_supplier') {
if (isModEnabled('asset') && $object->element == 'invoice_supplier') {
$colspan++;
}

View File

@ -160,7 +160,7 @@ if ($outputalsopricetotalwithtax) {
print '<td class="right" style="width: 80px">'.$langs->trans('TotalTTCShort').'</td>';
}
if (!empty($conf->asset->enabled) && $object->element == 'invoice_supplier') {
if (isModEnabled('asset') && $object->element == 'invoice_supplier') {
print '<td class="linecolasset"></td>';
}

View File

@ -397,7 +397,7 @@ if ($this->statut == 0 && !empty($object_rights->creer) && $action != 'selectlin
}
}
if (!empty($conf->asset->enabled) && $object->element == 'invoice_supplier') {
if (isModEnabled('asset') && $object->element == 'invoice_supplier') {
print '<td class="linecolasset center">';
$coldisplay++;
if (!empty($product_static->accountancy_code_buy) ||

View File

@ -1,9 +1,9 @@
<?php
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2021 Greg Rastklan <greg.rastklan@atm-consulting.fr>
* Copyright (C) 2021 Jean-Pascal BOUDET <jean-pascal.boudet@atm-consulting.fr>
* Copyright (C) 2021 Grégory BLEMAND <gregory.blemand@atm-consulting.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2021 Greg Rastklan <greg.rastklan@atm-consulting.fr>
* Copyright (C) 2021 Jean-Pascal BOUDET <jean-pascal.boudet@atm-consulting.fr>
* Copyright (C) 2021 Grégory BLEMAND <gregory.blemand@atm-consulting.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
@ -18,7 +18,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* \file class/compare.php
* \file htdocs/hrm/compare.php
* \ingroup hrm
* \brief This file compares skills of user groups
*
@ -33,23 +33,29 @@
*
*/
// Load Dolibarr environment
require_once '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT . '/hrm/class/skill.class.php';
require_once DOL_DOCUMENT_ROOT . '/hrm/class/job.class.php';
require_once DOL_DOCUMENT_ROOT . '/hrm/class/evaluation.class.php';
require_once DOL_DOCUMENT_ROOT . '/hrm/class/position.class.php';
require_once DOL_DOCUMENT_ROOT . '/hrm/lib/hrm.lib.php';
$permissiontoread = $user->rights->hrm->evaluation->read || $user->rights->hrm->compare_advance->read;
$permissiontoadd = 0;
if (empty($conf->hrm->enabled)) accessforbidden();
if (!$permissiontoread || ($action === 'create' && !$permissiontoadd)) accessforbidden();
// Load translation files required by the page
$langs->load('hrm');
// Permissions
$permissiontoread = $user->rights->hrm->evaluation->read || $user->rights->hrm->compare_advance->read;
$permissiontoadd = 0;
if (empty($conf->hrm->enabled)) accessforbidden();
if (!$permissiontoread || ($action === 'create' && !$permissiontoadd)) accessforbidden();
/*
* View

View File

@ -26,6 +26,8 @@
* \brief Home page for HRM area.
*/
// Load Dolibarr environment
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
@ -34,6 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
if (!empty($conf->deplacement->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
}
@ -48,12 +51,15 @@ if (!empty($conf->holiday->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager = new HookManager($db);
$hookmanager->initHooks('hrmindex');
// Load translation files required by the page
$langs->loadLangs(array('users', 'holiday', 'trips', 'boxes'));
// Get Parameters
$socid = GETPOST("socid", "int");
// Protection if external user

View File

@ -20,9 +20,9 @@
*/
/**
* \file position.php
* \ingroup hrm
* \brief Page to create/edit/view position
* \file htdocs/hrm/position.php
* \ingroup hrm
* \brief Page to create/edit/view position
*/
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db
@ -88,10 +88,6 @@ require_once DOL_DOCUMENT_ROOT . '/hrm/class/job.class.php';
require_once DOL_DOCUMENT_ROOT . '/hrm/lib/hrm_position.lib.php';
require_once DOL_DOCUMENT_ROOT . '/hrm/lib/hrm_job.lib.php';
$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
$backtopage = GETPOST('backtopage', 'alpha');
$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
$fk_job = GETPOST('fk_job', 'int');
// Get parameters
$id = GETPOST('fk_job', 'int');
@ -105,12 +101,18 @@ $confirm = GETPOST('confirm', 'alpha');
$cancel = GETPOST('cancel', 'aZ09');
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'positioncard'; // To manage different context of search
$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
$backtopage = GETPOST('backtopage', 'alpha');
$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
$fk_job = GETPOST('fk_job', 'int');
// Initialize technical objects
$object = new Job($db);
$extrafields = new ExtraFields($db);
$diroutputmassaction = $conf->hrm->dir_output . '/temp/massgeneration/' . $user->id;
$hookmanager->initHooks(array('positiontab', 'globalcard')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
@ -130,6 +132,7 @@ foreach ($object->fields as $key => $val) {
// Load object
include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
// Permissions
$permissiontoread = $user->rights->hrm->all->read;
$permissiontoadd = $user->rights->hrm->all->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
$permissiontodelete = $user->rights->hrm->all->delete;

View File

@ -71,8 +71,8 @@ ALTER TABLE llx_adherent_type ADD COLUMN caneditamount integer DEFAULT 0 AFTER a
ALTER TABLE llx_holiday CHANGE COLUMN date_approve date_approval datetime;
UPDATE llx_holiday SET date_approval = date_valid WHEN statut = 3 AND date_approval IS NULL;
UPDATE llx_holiday SET fk_user_approve = fk_user_valid WHEN statut = 3 AND fk_user_approve IS NULL;
UPDATE llx_holiday SET date_approval = date_valid WHERE statut = 3 AND date_approval IS NULL;
UPDATE llx_holiday SET fk_user_approve = fk_user_valid WHERE statut = 3 AND fk_user_approve IS NULL;
ALTER TABLE llx_inventory ADD COLUMN categories_product VARCHAR(255) DEFAULT NULL AFTER fk_product;

View File

@ -2040,7 +2040,6 @@ class Project extends CommonObject
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
@ -2056,10 +2055,14 @@ class Project extends CommonObject
// For external user, no check is done on company because readability is managed by public status of project and assignement.
//$socid=$user->socid;
$projectsListId = null;
if (empty($user->rights->projet->all->lire)) {
$projectsListId = $this->getProjectsAuthorizedForUser($user, 0, 1);
}
$response = new WorkboardResponse();
$response->warning_delay = $conf->project->warning_delay / 60 / 60 / 24;
$response->label = $langs->trans("OpenedProjects");
$response->labelShort = $langs->trans("Opened");
$response->url = DOL_URL_ROOT.'/projet/list.php?search_project_user=-1&search_status=1&mainmenu=project';
$response->img = img_object('', "projectpub");
$response->nbtodo = 0;
$response->nbtodolate = 0;
$sql = "SELECT p.rowid, p.fk_statut as status, p.fk_opp_status, p.datee as datee";
$sql .= " FROM (".MAIN_DB_PREFIX."projet as p";
@ -2069,9 +2072,19 @@ class Project extends CommonObject
//if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid";
$sql .= " WHERE p.fk_statut = 1";
$sql .= " AND p.entity IN (".getEntity('project').')';
if (!empty($projectsListId)) {
$projectsListId = null;
if (!$user->rights->projet->all->lire) {
$response->url = DOL_URL_ROOT.'/projet/list.php?search_status=1&mainmenu=project';
$projectsListId = $this->getProjectsAuthorizedForUser($user, 0, 1);
if (empty($projectsListId)) {
return $response;
}
$sql .= " AND p.rowid IN (".$this->db->sanitize($projectsListId).")";
}
// No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser
//if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".((int) $socid).")";
// For external user, no check is done on company permission because readability is managed by public status of project and assignement.
@ -2082,16 +2095,6 @@ class Project extends CommonObject
if ($resql) {
$project_static = new Project($this->db);
$response = new WorkboardResponse();
$response->warning_delay = $conf->project->warning_delay / 60 / 60 / 24;
$response->label = $langs->trans("OpenedProjects");
$response->labelShort = $langs->trans("Opened");
if ($user->rights->projet->all->lire) {
$response->url = DOL_URL_ROOT.'/projet/list.php?search_status=1&mainmenu=project';
} else {
$response->url = DOL_URL_ROOT.'/projet/list.php?search_project_user=-1&search_status=1&mainmenu=project';
}
$response->img = img_object('', "projectpub");
// This assignment in condition is not a bug. It allows walking the results.
while ($obj = $this->db->fetch_object($resql)) {
@ -2107,12 +2110,11 @@ class Project extends CommonObject
}
return $response;
} else {
$this->error = $this->db->error();
return -1;
}
}
$this->error = $this->db->error();
return -1;
}
/**
* Function used to replace a thirdparty id with another one.

View File

@ -528,4 +528,22 @@ class ProjectStats extends Stats
// var_dump($res);print '<br>';
return $res;
}
/**
* Return average of entity by month
* @param int $year year number
* @return int value
*/
protected function getAverageByMonth($year)
{
$sql = "SELECT date_format(datef,'%m') as dm, AVG(f.".$this->field.")";
$sql .= " FROM ".$this->from;
$sql .= $this->join;
$sql .= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
$sql .= " AND ".$this->where;
$sql .= " GROUP BY dm";
$sql .= $this->db->order('dm', 'DESC');
return $this->_getAverageByMonth($year, $sql);
}
}