Skip to content
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
3 changes: 1 addition & 2 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

## 1.1
- NEW : Compat v23 - *18/12/2025* - 1.1.1
- NEW : Compat v22 - *23/07/2025* - 1.1.0

## 1.0
Expand All @@ -13,5 +14,3 @@
- FIX : REF on create notation - *07/04/2023* - 1.0.1

Initial version


91 changes: 45 additions & 46 deletions core/modules/modNotation.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,13 @@ public function __construct($db)
// Array to add new pages in new tabs
$this->tabs = array();
// ligne vers session tab
$this->tabs[] = array('data' => 'agefodd_session:+notation:Notation:notation@notation:$user->rights->notation->notationnote->read:/notation/notationnote_list.php?session=__ID__');
$this->tabs[] = array('data' => "agefodd_session:+notation:Notation:notation@notation:$user->hasRight('notation', 'notationnote', 'read'):/notation/notationnote_list.php?session=__ID__");
// ligne vers formation tab
$this->tabs[] = array('data' => 'agefodd_training:+notation:Notation:notation@notation:$user->rights->notation->notationnote->read:/notation/notationnote_list.php?formation=__ID__');
$this->tabs[] = array('data' => "agefodd_training:+notation:Notation:notation@notation:$user->hasRight('notation', 'notationnote', 'read'):/notation/notationnote_list.php?formation=__ID__");

// Example:
// $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@notation:$user->rights->notation->read:/notation/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1
// $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@notation:$user->rights->othermodule->read:/notation/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.
// $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@notation:$user->hasRight('notation', 'read'):/notation/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1
// $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@notation:$user->hasRight('othermodule', 'read'):/notation/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.
// $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname
//
// Where objecttype can be
Expand Down Expand Up @@ -278,7 +278,7 @@ public function __construct($db)
$this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->hasRight("notation", "notationnote", "read"))
$r++;
$this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used)
$this->rights[$r][1] = $langs->trans('CreateUpdateObj') ; // Permission label
$this->rights[$r][1] = $langs->trans('CreateUpdateObj'); // Permission label
$this->rights[$r][4] = 'notationnote';
$this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->hasRight("notation", "notationnote", "write"))
$r++;
Expand Down Expand Up @@ -311,47 +311,46 @@ public function __construct($db)
);*/


/* $this->menu[$r++]=array(
// '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'fk_menu'=>'fk_mainmenu=notation',
// This is a Left menu entry
'type'=>'left',
'titre'=>'List NotationNote',
'mainmenu'=>'notation',
'leftmenu'=>'notation_notationnote',
'url'=>'/notation/notationnote_list.php',
// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'langs'=>'notation@notation',
'position'=>1100+$r,
// Define condition to show or hide menu entry. Use '$conf->notation->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'enabled'=>'isModEnabled("notation")',
// Use 'perms'=>'$user->hasRight("notation", "level1", "level2")' if you want your menu with a permission rules
'perms'=>'1',
'target'=>'',
// 0=Menu for internal users, 1=external users, 2=both
'user'=>2,
);
$this->menu[$r++]=array(
// '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'fk_menu'=>'fk_mainmenu=notation,fk_leftmenu=notation_notationnote',
// This is a Left menu entry
'type'=>'left',
'titre'=>'New NotationNote',
'mainmenu'=>'notation',
'leftmenu'=>'notation_notationnote',
'url'=>'/notation/notationnote_card.php?action=create',
// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'langs'=>'notation@notation',
'position'=>1100+$r,
// Define condition to show or hide menu entry. Use '$conf->notation->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'enabled'=>'isModEnabled("notation")',
// Use 'perms'=>'$user->hasRight("notation", "level1", "level2")' if you want your menu with a permission rules
'perms'=>'1',
'target'=>'',
// 0=Menu for internal users, 1=external users, 2=both
'user'=>2
);*/

/* $this->menu[$r++]=array(
// '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'fk_menu'=>'fk_mainmenu=notation',
// This is a Left menu entry
'type'=>'left',
'titre'=>'List NotationNote',
'mainmenu'=>'notation',
'leftmenu'=>'notation_notationnote',
'url'=>'/notation/notationnote_list.php',
// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'langs'=>'notation@notation',
'position'=>1100+$r,
// Define condition to show or hide menu entry. Use '$conf->notation->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'enabled'=>'isModEnabled("notation")',
// Use 'perms'=>'$user->hasRight("notation", "level1", "level2")' if you want your menu with a permission rules
'perms'=>'1',
'target'=>'',
// 0=Menu for internal users, 1=external users, 2=both
'user'=>2,
);
$this->menu[$r++]=array(
// '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'fk_menu'=>'fk_mainmenu=notation,fk_leftmenu=notation_notationnote',
// This is a Left menu entry
'type'=>'left',
'titre'=>'New NotationNote',
'mainmenu'=>'notation',
'leftmenu'=>'notation_notationnote',
'url'=>'/notation/notationnote_card.php?action=create',
// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'langs'=>'notation@notation',
'position'=>1100+$r,
// Define condition to show or hide menu entry. Use '$conf->notation->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'enabled'=>'isModEnabled("notation")',
// Use 'perms'=>'$user->hasRight("notation", "level1", "level2")' if you want your menu with a permission rules
'perms'=>'1',
'target'=>'',
// 0=Menu for internal users, 1=external users, 2=both
'user'=>2
);*/
}

/**
Expand Down
38 changes: 17 additions & 21 deletions notationnote_card.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@
$session = GETPOST('session', 'int');
$fk_session = GETPOST('fk_session', 'int');
$formation = GETPOST('formation', 'int');
$note = GETPOST('note','int');
$note = GETPOST('note', 'int');
$fk_trainee = GETPOST('fk_trainee', 'int');
$status=GETPOST('status','int');
$status=GETPOST('status', 'int');


// Initialize technical objects
Expand Down Expand Up @@ -140,7 +140,7 @@
if ($enablepermissioncheck) {
$permissiontoread = $user->hasRight("notation", "notationnote", "read");
$permissiontoadd = $user->hasRight("notation", "notationnote", "write"); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
$permissiontodelete = $user->rights->notation->notationnote->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
$permissiontodelete = $user->hasRight('notation', 'notationnote', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
$permissionnote = $user->hasRight("notation", "notationnote", "write"); // Used by the include of actions_setnotes.inc.php
$permissiondellink = $user->hasRight("notation", "notationnote", "write"); // Used by the include of actions_dellink.inc.php
} else {
Expand Down Expand Up @@ -183,17 +183,14 @@
}

// Error handler
if (($action == 'add' || $action == 'update') && empty($cancel)){


if (($action == 'add' || $action == 'update') && empty($cancel)) {
if (empty($object->ref) && $action == "add") $object->ref = $object->getNextNumRef();
$error=0;

if (empty(GETPOST('note')) || GETPOST('note') < floatval(getDolGlobalString('MIN_NOTATION', '0')) || GETPOST('note') > floatval(getDolGlobalString('MAX_NOTATION', '0')) ){
if (empty(GETPOST('note')) || GETPOST('note') < floatval(getDolGlobalString('MIN_NOTATION', '0')) || GETPOST('note') > floatval(getDolGlobalString('MAX_NOTATION', '0')) ) {
setEventMessages($langs->trans('ErrorType', $langs->transnoentitiesnoconv($object->fields['note']['label'])), null, 'errors');
$error++;
}

}


Expand Down Expand Up @@ -252,9 +249,9 @@
$help_url = '';
llxHeader('', $title, $help_url);

if (!empty($formation)){
if (!empty($formation)) {
$addparams = "&formation=".$formation;
}else{
} else {
$addparams = "&session=".$session;
}

Expand All @@ -270,10 +267,10 @@
$res = $agf->fetch($session);
$agf->fetch_societe_per_session($session);

$ref = $agf->getNomUrl(1,"",0,'ref');
$ref = $agf->getNomUrl(1, "", 0, 'ref');


// Display consult
// Display consult
$head = session_prepare_head($agf);

dol_fiche_head($head, 'notation', $langs->trans('AgfSessionDetail'), -1, 'generic');
Expand Down Expand Up @@ -325,7 +322,6 @@

// Part to edit record
if (($id || $ref) && $action == 'edit') {

print load_fiche_titre($langs->trans("NotationNote"), '', 'object_'.$object->picto);

print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
Expand Down Expand Up @@ -431,20 +427,20 @@

// Object card
// ------------------------------------------------------------
if ($formation){
$linkback = '<a href="'.dol_buildpath('/notation/notationnote_list.php', 1).'?formation='.$formation . (!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
}else{
$linkback = '<a href="'.dol_buildpath('/notation/notationnote_list.php', 1).'?restore_lastsearch_values=1'. '&session='. $session . (!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
if ($formation) {
$linkback = '<a href="'. dol_buildpath('/notation/notationnote_list.php', 1).'?formation='.$formation . (!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
} else {
$linkback = '<a href="'. dol_buildpath('/notation/notationnote_list.php', 1).'?restore_lastsearch_values=1&session='. $session . (!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
}

$morehtmlref = '<div class="refidno">';

$morehtmlref .= '</div>';

$addparams = "";
if (!empty($formation)){
if (!empty($formation)) {
$addparams = "&formation=".$formation;
}else{
} else {
$addparams = "&session=".$session;
}

Expand Down Expand Up @@ -545,9 +541,9 @@
}

$addParams = "";
if (!empty($formation)){
if (!empty($formation)) {
$addParams = "&formation=".$formation;
}else {
} else {
$addParams = "&session=".$session;
}

Expand Down
31 changes: 23 additions & 8 deletions scripts/testCreate.php
Original file line number Diff line number Diff line change
@@ -1,33 +1,48 @@
<?php
/* Copyright (C) 2025 ATM Consulting
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* 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 <https://www.gnu.org/licenses/>.
*/
// Load Dolibarr environment
$res = 0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
$res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
$res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
}
// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
$i--; $j--;
$i--; $j--;
}
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
$res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
$res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
}
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
$res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
$res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
}
// Try main.inc.php using relative path
if (!$res && file_exists("../main.inc.php")) {
$res = @include "../main.inc.php";
$res = @include "../main.inc.php";
}
if (!$res && file_exists("../../main.inc.php")) {
$res = @include "../../main.inc.php";
$res = @include "../../main.inc.php";
}
if (!$res && file_exists("../../../main.inc.php")) {
$res = @include "../../../main.inc.php";
$res = @include "../../../main.inc.php";
}
if (!$res) {
die("Include of main fails");
die("Include of main fails");
}

require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
Expand Down