*
* 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
@@ -22,12 +22,12 @@
* \brief File of class to manage Meeting numbering rules standard
*/
-require_once __DIR__ . '/modules_meeting.php';
+require_once __DIR__ . '/modules_session.php';
/**
* Class to manage customer order numbering rules standard
*/
-class mod_meeting_standard extends ModeleNumRefMeeting
+class mod_meeting_standard extends ModeleNumRefSession
{
/**
* Dolibarr version of the loaded meeting
@@ -45,7 +45,7 @@ class mod_meeting_standard extends ModeleNumRefMeeting
/**
* @var string name
*/
- public $name = 'Test';
+ public $name = 'Meeting';
/**
* Return description of numbering module
@@ -65,7 +65,7 @@ public function info()
*/
public function getExample()
{
- return $this->prefix."1";
+ return $this->prefix."2208-0001";
}
/**
@@ -82,7 +82,7 @@ public function canBeActivated($object) {
$posindice = strlen($this->prefix) + 6;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
- $sql .= " FROM ".MAIN_DB_PREFIX."dolimeet_meeting";
+ $sql .= " FROM ".MAIN_DB_PREFIX."dolimeet_session";
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."_______-%'";
if ($object->ismultientitymanaged == 1) {
$sql .= " AND entity = ".$conf->entity;
@@ -116,10 +116,10 @@ public function getNextValue($object) {
global $db, $conf;
// first we get the max value
- $posindice = strlen($this->prefix) + 1;
+ $posindice = strlen($this->prefix) + 6;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
- $sql .= " FROM ".MAIN_DB_PREFIX."dolimeet_meeting";
- $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."%'";
+ $sql .= " FROM ".MAIN_DB_PREFIX."dolimeet_session";
+ $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
if ($object->ismultientitymanaged == 1) {
$sql .= " AND entity = ".$conf->entity;
}
@@ -137,10 +137,17 @@ public function getNextValue($object) {
return -1;
}
- if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
- else $num = sprintf("%s", $max + 1);
+ $date = empty($object->date_creation) ?dol_now() : $object->date_creation;
+
+ $yymm = strftime("%y%m", $date);
+
+ if ($max >= (pow(10, 4) - 1)) {
+ $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
+ } else {
+ $num = sprintf("%04s", $max + 1);
+ }
- dol_syslog("mod_meeting_standard::getNextValue return ".$this->prefix.$num);
- return $this->prefix.$num;
+ dol_syslog("mod_meeting_standard::getNextValue return ".$this->prefix.$yymm."-".$num);
+ return $this->prefix.$yymm."-".$num;
}
}
diff --git a/core/modules/dolimeet/mod_trainingsession_standard.php b/core/modules/dolimeet/mod_trainingsession_standard.php
new file mode 100644
index 0000000..59068df
--- /dev/null
+++ b/core/modules/dolimeet/mod_trainingsession_standard.php
@@ -0,0 +1,153 @@
+
+ *
+ * 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 .
+ */
+
+
+/**
+ * \file htdocs/core/modules/dolimeet/mod_trainingsession_standard.php
+ * \ingroup dolimeet
+ * \brief File of class to manage Meeting numbering rules standard
+ */
+
+require_once __DIR__ . '/modules_session.php';
+
+/**
+ * Class to manage customer order numbering rules standard
+ */
+class mod_trainingsession_standard extends ModeleNumRefSession
+{
+ /**
+ * Dolibarr version of the loaded trainingsession
+ * @var string
+ */
+ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
+
+ public $prefix = 'TS';
+
+ /**
+ * @var string Error code (or message)
+ */
+ public $error = '';
+
+ /**
+ * @var string name
+ */
+ public $name = 'TrainingSession';
+
+ /**
+ * Return description of numbering module
+ *
+ * @return string Text with description
+ */
+ public function info()
+ {
+ global $langs;
+ return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
+ }
+
+ /**
+ * Return an example of numbering
+ *
+ * @return string Example
+ */
+ public function getExample()
+ {
+ return $this->prefix."2208-0001";
+ }
+
+ /**
+ * Checks if the numbers already in the database do not
+ * cause conflicts that would prevent this numbering working.
+ *
+ * @param Object $object Object we need next value for
+ * @return boolean false if conflict, true if ok
+ */
+ public function canBeActivated($object) {
+ global $conf, $langs, $db;
+
+ $coyymm = ''; $max = '';
+
+ $posindice = strlen($this->prefix) + 6;
+ $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
+ $sql .= " FROM ".MAIN_DB_PREFIX."dolimeet_session";
+ $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."_______-%'";
+ if ($object->ismultientitymanaged == 1) {
+ $sql .= " AND entity = ".$conf->entity;
+ } elseif ($object->ismultientitymanaged == 2) {
+ // TODO
+ }
+
+ $resql = $db->query($sql);
+ if ($resql) {
+ $row = $db->fetch_row($resql);
+ if ($row) {
+ $coyymm = substr($row[0], 0, 6); $max = $row[0];
+ }
+ }
+ if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) {
+ $langs->load("errors");
+ $this->error = $langs->trans('ErrorNumRefModel', $max);
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Return next free value
+ *
+ * @param Object $object Object we need next value for
+ * @return string Value if KO, <0 if KO
+ */
+ public function getNextValue($object) {
+ global $db, $conf;
+
+ // first we get the max value
+ $posindice = strlen($this->prefix) + 6;
+ $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
+ $sql .= " FROM ".MAIN_DB_PREFIX."dolimeet_session";
+ $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
+ if ($object->ismultientitymanaged == 1) {
+ $sql .= " AND entity = ".$conf->entity;
+ }
+
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $obj = $db->fetch_object($resql);
+ if ($obj) $max = intval($obj->max);
+ else $max = 0;
+ }
+ else
+ {
+ dol_syslog("mod_trainingsession_standard::getNextValue", LOG_DEBUG);
+ return -1;
+ }
+
+ $date = empty($object->date_creation) ?dol_now() : $object->date_creation;
+
+ $yymm = strftime("%y%m", $date);
+
+ if ($max >= (pow(10, 4) - 1)) {
+ $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
+ } else {
+ $num = sprintf("%04s", $max + 1);
+ }
+
+ dol_syslog("mod_trainingsession_standard::getNextValue return ".$this->prefix.$yymm."-".$num);
+ return $this->prefix.$yymm."-".$num;
+ }
+}
diff --git a/core/modules/dolimeet/modules_meeting.php b/core/modules/dolimeet/modules_session.php
similarity index 87%
rename from core/modules/dolimeet/modules_meeting.php
rename to core/modules/dolimeet/modules_session.php
index af435e9..9561ed8 100644
--- a/core/modules/dolimeet/modules_meeting.php
+++ b/core/modules/dolimeet/modules_session.php
@@ -23,17 +23,18 @@
*/
/**
- * \file htdocs/core/modules/doliletter/modules_meeting.php
- * \ingroup doliletter
- * \brief File that contains parent class for meeting document models and parent class for meeting numbering models
+ * \file htdocs/core/modules/dolimeet/modules_session.php
+ * \ingroup dolimeet
+ * \brief File that contains parent class for session document models and parent class for session numbering models
*/
require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
+require_once DOL_DOCUMENT_ROOT.'/custom/dolimeet/lib/dolimeet_function.lib.php';
/**
* Parent class for documents models
*/
-abstract class ModelePDFMeeting extends CommonDocGenerator
+abstract class ModelePDFSession extends CommonDocGenerator
{
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@@ -44,16 +45,15 @@ abstract class ModelePDFMeeting extends CommonDocGenerator
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
- public static function liste_modeles($db, $maxfilenamelength = 0)
+ public static function liste_modeles($db, $maxfilenamelength = 0, $type)
{
// phpcs:enable
global $conf;
- $type = 'meeting';
$list = array();
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
- $list = getListOfModels($db, $type, $maxfilenamelength);
+ $list = getListOfModelsDolimeet($db, $type, $maxfilenamelength);
return $list;
}
@@ -64,7 +64,7 @@ public static function liste_modeles($db, $maxfilenamelength = 0)
/**
* Parent class to manage numbering of Meeting
*/
-abstract class ModeleNumRefMeeting
+abstract class ModeleNumRefSession
{
/**
* @var string Error code (or message)
@@ -89,7 +89,7 @@ public function isEnabled()
public function info()
{
global $langs;
- $langs->load("doliletter@doliletter");
+ $langs->load("dolimeet@dolimeet");
return $langs->trans("NoDescription");
}
@@ -101,7 +101,7 @@ public function info()
public function getExample()
{
global $langs;
- $langs->load("doliletter@doliletter");
+ $langs->load("dolimeet@dolimeet");
return $langs->trans("NoExample");
}
diff --git a/core/modules/modDoliMeet.class.php b/core/modules/modDoliMeet.class.php
index fc61f75..eb7369f 100644
--- a/core/modules/modDoliMeet.class.php
+++ b/core/modules/modDoliMeet.class.php
@@ -53,10 +53,10 @@ public function __construct($db)
$this->editor_url = 'https://www.evarisk.com';
$this->version = '1.0.0';
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
- $this->picto = 'generic';
+ $this->picto = 'dolimeet@dolimeet';
$this->module_parts = array(
// Set this to 1 if module has its own trigger directory (core/triggers)
- 'triggers' => 0,
+ 'triggers' => 1,
// Set this to 1 if module has its own login method file (core/login)
'login' => 0,
// Set this to 1 if module has its own substitution function file (core/substitutions)
@@ -83,11 +83,11 @@ public function __construct($db)
),
// Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context to 'all'
'hooks' => array(
- // 'data' => array(
- // 'hookcontext1',
- // 'hookcontext2',
- // ),
- // 'entity' => '0',
+ 'category',
+ 'categoryindex',
+ 'projectOverview',
+ 'printOverviewDetail',
+ 'admincompany'
),
// Set this to 1 if features of module are opened to external users
'moduleforexternal' => 0,
@@ -104,7 +104,7 @@ public function __construct($db)
// A condition to hide module
$this->hidden = false;
// List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...)
- $this->depends = array();
+ $this->depends = array('modCategorie', 'modContrat', 'modProjet', 'modFckeditor', 'modAgenda');
$this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...)
$this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...)
@@ -128,6 +128,18 @@ public function __construct($db)
// );
$this->const = array(
1 => array('DOLIMEET_MEETING_ADDON','chaine', 'mod_meeting_standard','', $conf->entity),
+ 2 => array('DOLIMEET_MEETING_MENU_ENABLED','integer', 1,'', $conf->entity),
+
+ 3 => array('DOLIMEET_TRAININGSESSION_ADDON','chaine', 'mod_trainingsession_standard','', $conf->entity),
+ 4 => array('DOLIMEET_TRAININGSESSION_MENU_ENABLED','integer', 1,'', $conf->entity),
+
+ 5 => array('DOLIMEET_AUDIT_ADDON','chaine', 'mod_audit_standard','', $conf->entity),
+ 6 => array('DOLIMEET_AUDIT_MENU_ENABLED','integer', 1,'', $conf->entity),
+
+ 7 => array('DOLIMEET_ATTENDANCESHEET_ADDON_ODT_PATH', 'chaine', 'DOL_DOCUMENT_ROOT/custom/dolimeet/documents/doctemplates/attendancesheet/', '', 0, 'current'),
+ 8 => array('DOLIMEET_COMPLETIONCERTIFICATE_ADDON_ODT_PATH', 'chaine', 'DOL_DOCUMENT_ROOT/custom/dolimeet/documents/doctemplates/completioncertificate/', '', 0, 'current'),
+
+ 9 => array('MAIN_INFO_SOCIETE_TRAINING_ORGANIZATION_NUMBER', 'chaine', '', '', 0, 'current')
);
// Some keys to add into the overwriting translation tables
@@ -142,11 +154,58 @@ public function __construct($db)
}
// Array to add new pages in new tabs
+ $langs->load("dolimeet@dolimeet");
+ $pictopath = dol_buildpath('/custom/dolimeet/img/dolimeet32px.png', 1);
+ $picto = img_picto('', $pictopath, '', 1, 0, 0, '', 'pictoDolimeet');
+
$this->tabs = array();
+ $this->tabs[] = array('data' => 'thirdparty:+sessionList:'.$picto.$langs->trans('DoliMeet').':dolimeet@dolimeet:1:/custom/dolimeet/view/session/session_list.php?fromtype=thirdparty&fromid=__ID__'); // To add a new tab identified by code tabname1
+ $this->tabs[] = array('data' => 'user:+sessionList:'.$picto.$langs->trans('DoliMeet').':dolimeet@dolimeet:1:/custom/dolimeet/view/session/session_list.php?fromtype=user&fromid=__ID__'); // To add a new tab identified by code tabname1
+ $this->tabs[] = array('data' => 'contact:+sessionList:'.$picto.$langs->trans('DoliMeet').':dolimeet@dolimeet:1:/custom/dolimeet/view/session/session_list.php?fromtype=socpeople&fromid=__ID__'); // To add a new tab identified by code tabname1
+ $this->tabs[] = array('data' => 'project:+sessionList:'.$picto.$langs->trans('DoliMeet').':dolimeet@dolimeet:1:/custom/dolimeet/view/session/session_list.php?fromtype=project&fromid=__ID__'); // To add a new tab identified by code tabname1
+ $this->tabs[] = array('data' => 'contract:+sessionList:'.$picto.$langs->trans('DoliMeet').':dolimeet@dolimeet:1:/custom/dolimeet/view/session/session_list.php?fromtype=contrat&fromid=__ID__'); // To add a new tab identified by code tabname1
+ $this->tabs[] = array('data' => 'contract:+openinghours:'.$picto.$langs->trans('OpeningHours').':dolimeet@dolimeet:1:/custom/dolimeet/view/openinghours_card.php?element_type=contrat&id=__ID__'); // To add a new tab identified by code tabname1
// Dictionaries
- $this->dictionaries = array();
-
+ $this->dictionaries = array(
+ 'langs' => 'dolimeet@dolimeet',
+ // List of tables we want to see into dictonnary editor
+ 'tabname' => array(
+ MAIN_DB_PREFIX . "c_trainingsession_type"
+ ),
+ // Label of tables
+ 'tablib' => array(
+ "TrainingSession"
+ ),
+ // Request to select fields
+ 'tabsql' => array(
+ 'SELECT f.rowid as rowid, f.ref, f.label, f.description, f.active FROM ' . MAIN_DB_PREFIX . 'c_trainingsession_type as f'
+ ),
+ // Sort order
+ 'tabsqlsort' => array(
+ "label ASC"
+ ),
+ // List of fields (result of select to show dictionary)
+ 'tabfield' => array(
+ "ref,label,description"
+ ),
+ // List of fields (list of fields to edit a record)
+ 'tabfieldvalue' => array(
+ "ref,label,description"
+ ),
+ // List of fields (list of fields for insert)
+ 'tabfieldinsert' => array(
+ "ref,label,description"
+ ),
+ // Name of columns with primary key (try to always name it 'rowid')
+ 'tabrowid' => array(
+ "rowid"
+ ),
+ // Condition to show each dictionary
+ 'tabcond' => array(
+ $conf->dolimeet->enabled,
+ )
+ );
// Boxes/Widgets
$this->boxes = array(
);
@@ -161,21 +220,65 @@ public function __construct($db)
// Add here entries to declare new permissions
/* BEGIN MODULEBUILDER PERMISSIONS */
$this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used)
- $this->rights[$r][1] = 'Read objects of DoliMeet'; // Permission label
+ $this->rights[$r][1] = $langs->transnoentities('ReadDoliMeetSession'); // Permission label
+ $this->rights[$r][4] = 'session';
+ $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->dolimeet->session->read)
+ $r++;
+ $this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used)
+ $this->rights[$r][1] = $langs->transnoentities('WriteDoliMeetSession'); // Permission label
+ $this->rights[$r][4] = 'session';
+ $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->dolimeet->session->write)
+ $r++;
+ $this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used)
+ $this->rights[$r][1] = $langs->transnoentities('DeleteDoliMeetSession'); // Permission label
+ $this->rights[$r][4] = 'session';
+ $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->dolimeet->session->delete)
+ $r++;
+ $this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used)
+ $this->rights[$r][1] = $langs->transnoentities('ReadDoliMeetMeeting'); // Permission label
$this->rights[$r][4] = 'meeting';
$this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->dolimeet->meeting->read)
$r++;
$this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used)
- $this->rights[$r][1] = 'Create/Update objects of DoliMeet'; // Permission label
+ $this->rights[$r][1] = $langs->transnoentities('WriteDoliMeetMeeting'); // Permission label
$this->rights[$r][4] = 'meeting';
$this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->dolimeet->meeting->write)
$r++;
$this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used)
- $this->rights[$r][1] = 'Delete objects of DoliMeet'; // Permission label
+ $this->rights[$r][1] = $langs->transnoentities('DeleteDoliMeetMeeting'); // Permission label
$this->rights[$r][4] = 'meeting';
$this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->dolimeet->meeting->delete)
$r++;
- /* END MODULEBUILDER PERMISSIONS */
+ $this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used)
+ $this->rights[$r][1] = $langs->transnoentities('ReadDoliMeetTrainingSession'); // Permission label
+ $this->rights[$r][4] = 'trainingsession';
+ $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->dolimeet->trainingsession->read)
+ $r++;
+ $this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used)
+ $this->rights[$r][1] = $langs->transnoentities('WriteDoliMeetTrainingSession'); // Permission label
+ $this->rights[$r][4] = 'trainingsession';
+ $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->dolimeet->trainingsession->write)
+ $r++;
+ $this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used)
+ $this->rights[$r][1] = $langs->transnoentities('DeleteDoliMeetTrainingSession'); // Permission label
+ $this->rights[$r][4] = 'trainingsession';
+ $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->dolimeet->meeting->delete)
+ $r++;
+ $this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used)
+ $this->rights[$r][1] = $langs->transnoentities('ReadDoliMeetAudit'); // Permission label
+ $this->rights[$r][4] = 'audit';
+ $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->dolimeet->audit->read)
+ $r++;
+ $this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used)
+ $this->rights[$r][1] = $langs->transnoentities('WriteDoliMeetAudit'); // Permission label
+ $this->rights[$r][4] = 'audit';
+ $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->dolimeet->audit->write)
+ $r++;
+ $this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used)
+ $this->rights[$r][1] = $langs->transnoentities('DeleteDoliMeetAudit'); // Permission label
+ $this->rights[$r][4] = 'audit';
+ $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->dolimeet->meeting->delete)
+ $r++; /* END MODULEBUILDER PERMISSIONS */
// Main menu entries to add
$this->menu = array();
@@ -203,10 +306,10 @@ public function __construct($db)
'titre'=>' '. $langs->trans('MeetingList'),
'mainmenu'=>'dolimeet',
'leftmenu'=>'meeting_list',
- 'url'=>'/dolimeet/meeting_list.php',
+ 'url'=>'/dolimeet/view/meeting/meeting_list.php',
'langs'=>'dolimeet@dolimeet', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>1100+$r,
- 'enabled'=>'$conf->dolimeet->enabled', // Define condition to show or hide menu entry. Use '$conf->dolimeet->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
+ 'enabled'=>'$conf->dolimeet->enabled && $conf->global->DOLIMEET_MEETING_MENU_ENABLED', // Define condition to show or hide menu entry. Use '$conf->dolimeet->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'perms'=>'1', // Use 'perms'=>'$user->rights->dolimeet->level1->level2' if you want your menu with a permission rules
'target'=>'',
'user'=>0, // 0=Menu for internal users, 1=external users, 2=both
@@ -214,17 +317,130 @@ public function __construct($db)
$this->menu[$r++]=array(
'fk_menu'=>'fk_mainmenu=dolimeet,fk_leftmenu=meeting_list', // '' 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
'type'=>'left', // This is a Left menu entry
- 'titre'=> ' ' . $langs->trans('MeetingCreate'),
+ 'titre'=> ' ' . $langs->trans('MeetingCreate'),
'mainmenu'=>'dolimeet',
'leftmenu'=>'meeting_card',
- 'url'=>'/dolimeet/meeting_card.php?action=create',
+ 'url'=>'/dolimeet/view/meeting/meeting_card.php?action=create',
'langs'=>'dolimeet@dolimeet', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>1100+$r,
- 'enabled'=>'$conf->dolimeet->enabled', // Define condition to show or hide menu entry. Use '$conf->doliletter->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
+ 'enabled'=>'$conf->dolimeet->enabled && $conf->global->DOLIMEET_MEETING_MENU_ENABLED', // Define condition to show or hide menu entry. Use '$conf->dolimeet->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'perms'=>'1', // Use 'perms'=>'$user->rights->dolimeet->level1->level2' if you want your menu with a permission rules
'target'=>'',
'user'=>0, // 0=Menu for internal users, 1=external users, 2=both
);
+ $this->menu[$r++] = array(
+ 'fk_menu' => 'fk_mainmenu=dolimeet,fk_leftmenu=meeting_list',
+ 'type' => 'left',
+ 'titre' => ' ' . $langs->trans('Categories'),
+ 'mainmenu' => 'dolimeet',
+ 'leftmenu' => 'dolimeet_meeting',
+ 'url' => '/categories/index.php?type=meeting',
+ 'langs' => 'ticket',
+ 'position' => 1100 + $r,
+ 'enabled' => '$conf->dolimeet->enabled && $conf->categorie->enabled && $conf->global->DOLIMEET_MEETING_MENU_ENABLED',
+ 'perms' => '1',
+ 'target' => '',
+ 'user' => 0,
+ );
+ $this->menu[$r++]=array(
+ 'fk_menu'=>'fk_mainmenu=dolimeet', // '' 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
+ 'type'=>'left', // This is a Left menu entry
+ 'titre'=>' '. $langs->trans('TrainingSessionList'),
+ 'mainmenu'=>'dolimeet',
+ 'leftmenu'=>'trainingsession_list',
+ 'url'=>'/dolimeet/view/trainingsession/trainingsession_list.php',
+ 'langs'=>'dolimeet@dolimeet', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
+ 'position'=>1100+$r,
+ 'enabled'=>'$conf->dolimeet->enabled && $conf->global->DOLIMEET_TRAININGSESSION_MENU_ENABLED', // Define condition to show or hide menu entry. Use '$conf->dolimeet->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
+ 'perms'=>'1', // Use 'perms'=>'$user->rights->dolimeet->level1->level2' if you want your menu with a permission rules
+ 'target'=>'',
+ 'user'=>0, // 0=Menu for internal users, 1=external users, 2=both
+ );
+ $this->menu[$r++]=array(
+ 'fk_menu'=>'fk_mainmenu=dolimeet,fk_leftmenu=trainingsession_list', // '' 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
+ 'type'=>'left', // This is a Left menu entry
+ 'titre'=> ' ' . $langs->trans('TrainingSessionCreate'),
+ 'mainmenu'=>'dolimeet',
+ 'leftmenu'=>'trainingsession_card',
+ 'url'=>'/dolimeet/view/trainingsession/trainingsession_card.php?action=create',
+ 'langs'=>'dolimeet@dolimeet', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
+ 'position'=>1100+$r,
+ 'enabled'=>'$conf->dolimeet->enabled && $conf->global->DOLIMEET_TRAININGSESSION_MENU_ENABLED', // Define condition to show or hide menu entry. Use '$conf->dolimeet->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
+ 'perms'=>'1', // Use 'perms'=>'$user->rights->dolimeet->level1->level2' if you want your menu with a permission rules
+ 'target'=>'',
+ 'user'=>0, // 0=Menu for internal users, 1=external users, 2=both
+ );
+ $this->menu[$r++] = array(
+ 'fk_menu' => 'fk_mainmenu=dolimeet,fk_leftmenu=trainingsession_list',
+ 'type' => 'left',
+ 'titre' => ' ' . $langs->trans('Categories'),
+ 'mainmenu' => 'dolimeet',
+ 'leftmenu' => 'dolimeet_trainingsession',
+ 'url' => '/categories/index.php?type=trainingsession',
+ 'langs' => 'ticket',
+ 'position' => 1100 + $r,
+ 'enabled' => '$conf->dolimeet->enabled && $conf->categorie->enabled && $conf->global->DOLIMEET_TRAININGSESSION_MENU_ENABLED',
+ 'perms' => '1',
+ 'target' => '',
+ 'user' => 0,
+ );
+ $this->menu[$r++]=array(
+ 'fk_menu'=>'fk_mainmenu=dolimeet', // '' 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
+ 'type'=>'left', // This is a Left menu entry
+ 'titre'=>' '. $langs->trans('AuditList'),
+ 'mainmenu'=>'dolimeet',
+ 'leftmenu'=>'audit_list',
+ 'url'=>'/dolimeet/view/audit/audit_list.php',
+ 'langs'=>'dolimeet@dolimeet', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
+ 'position'=>1100+$r,
+ 'enabled'=>'$conf->dolimeet->enabled && $conf->global->DOLIMEET_AUDIT_MENU_ENABLED', // Define condition to show or hide menu entry. Use '$conf->dolimeet->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
+ 'perms'=>'1', // Use 'perms'=>'$user->rights->dolimeet->level1->level2' if you want your menu with a permission rules
+ 'target'=>'',
+ 'user'=>0, // 0=Menu for internal users, 1=external users, 2=both
+ );
+ $this->menu[$r++]=array(
+ 'fk_menu'=>'fk_mainmenu=dolimeet,fk_leftmenu=audit_list', // '' 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
+ 'type'=>'left', // This is a Left menu entry
+ 'titre'=> ' ' . $langs->trans('AuditCreate'),
+ 'mainmenu'=>'dolimeet',
+ 'leftmenu'=>'audit_card',
+ 'url'=>'/dolimeet/view/audit/audit_card.php?action=create',
+ 'langs'=>'dolimeet@dolimeet', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
+ 'position'=>1100+$r,
+ 'enabled'=>'$conf->dolimeet->enabled && $conf->global->DOLIMEET_AUDIT_MENU_ENABLED', // Define condition to show or hide menu entry. Use '$conf->dolimeet->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
+ 'perms'=>'1', // Use 'perms'=>'$user->rights->dolimeet->level1->level2' if you want your menu with a permission rules
+ 'target'=>'',
+ 'user'=>0, // 0=Menu for internal users, 1=external users, 2=both
+ );
+ $this->menu[$r++] = array(
+ 'fk_menu' => 'fk_mainmenu=dolimeet,fk_leftmenu=audit_list',
+ 'type' => 'left',
+ 'titre' => ' ' . $langs->trans('Categories'),
+ 'mainmenu' => 'dolimeet',
+ 'leftmenu' => 'dolimeet_audit',
+ 'url' => '/categories/index.php?type=audit',
+ 'langs' => 'ticket',
+ 'position' => 1100 + $r,
+ 'enabled' => '$conf->dolimeet->enabled && $conf->categorie->enabled && $conf->global->DOLIMEET_AUDIT_MENU_ENABLED',
+ 'perms' => '1',
+ 'target' => '',
+ 'user' => 0,
+ );
+ $this->menu[$r++] = array(
+ 'fk_menu' => 'fk_mainmenu=dolimeet', // '' 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
+ 'type' => 'left', // This is a Left menu entry
+ 'titre' => $langs->trans('ModuleConfiguration'),
+ 'prefix' => ' ',
+ 'mainmenu' => 'dolimeet',
+ 'leftmenu' => 'dolimeetconfig',
+ 'url' => '/dolimeet/admin/setup.php',
+ 'langs' => 'dolimeet@dolimeet', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
+ 'position' => 48520 + $r,
+ 'enabled' => '$conf->dolimeet->enabled', // Define condition to show or hide menu entry. Use '$conf->dolimeet->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
+ 'perms' => '1', // Use 'perms'=>'$user->rights->dolimeet->level1->level2' if you want your menu with a permission rules
+ 'target' => '',
+ 'user' => 0, // 0=Menu for internal users, 1=external users, 2=both
+ );
/* END MODULEBUILDER TOPMENU */
/* BEGIN MODULEBUILDER LEFTMENU MYOBJECT
$this->menu[$r++]=array(
@@ -336,19 +552,44 @@ public function init($options = '')
global $conf, $langs;
//$result = $this->_load_tables('/install/mysql/tables/', 'dolimeet');
- $result = $this->_load_tables('/dolimeet/sql/');
+ $sql = array();
+ // Load sql sub folders
+ $sqlFolder = scandir(__DIR__ . '/../../sql');
+ foreach ($sqlFolder as $subFolder) {
+ if ( ! preg_match('/\./', $subFolder)) {
+ $this->_load_tables('/dolimeet/sql/' . $subFolder . '/');
+ }
+ }
+
+ $this->_load_tables('/dolimeet/sql/');
if ($result < 0) {
return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
}
+ delDocumentModel('attendancesheet_odt', 'trainingsession');
+ delDocumentModel('completioncertificate_odt', 'trainingsession');
+
+ addDocumentModel('attendancesheet_odt', 'trainingsession', 'ODT templates', 'DOLIMEET_ATTENDANCESHEET_ADDON_ODT_PATH');
+ addDocumentModel('completioncertificate_odt', 'trainingsession', 'ODT templates', 'DOLIMEET_COMPLETIONCERTIFICATE_ADDON_ODT_PATH');
+
// Create extrafields during init
- //include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
- //$extrafields = new ExtraFields($this->db);
- //$result1=$extrafields->addExtraField('dolimeet_myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'dolimeet@dolimeet', '$conf->dolimeet->enabled');
- //$result2=$extrafields->addExtraField('dolimeet_myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'dolimeet@dolimeet', '$conf->dolimeet->enabled');
- //$result3=$extrafields->addExtraField('dolimeet_myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'dolimeet@dolimeet', '$conf->dolimeet->enabled');
- //$result4=$extrafields->addExtraField('dolimeet_myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'dolimeet@dolimeet', '$conf->dolimeet->enabled');
- //$result5=$extrafields->addExtraField('dolimeet_myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'dolimeet@dolimeet', '$conf->dolimeet->enabled');
+ include_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
+ $extra_fields = new ExtraFields($this->db);
+
+ $extra_fields->update('label', $langs->transnoentities("Label"), 'varchar', '', 'contrat', 0, 0, 1040, '', '', '', 1);
+ $extra_fields->addExtraField('label', $langs->transnoentities("Label"), 'varchar', 1040, '', 'contrat', 0, 0, '', '', '', '', 1);
+
+ $extra_fields->update('trainingsession_start', $langs->transnoentities("TrainingSessionStart"), 'datetime', '', 'contrat', 0, 0, 1800, '', '', '', 1);
+ $extra_fields->addExtraField('trainingsession_start', $langs->transnoentities("TrainingSessionStart"), 'datetime', 1040, '', 'contrat', 0, 0, '', '', '', '', 1);
+
+ $extra_fields->update('trainingsession_end', $langs->transnoentities("TrainingSessionEnd"), 'datetime', '', 'contrat', 0, 0, 1810, '', '', '', 1);
+ $extra_fields->addExtraField('trainingsession_end', $langs->transnoentities("TrainingSessionEnd"), 'datetime', 1040, '', 'contrat', 0, 0, '', '', '', '', 1);
+
+ $extra_fields->update('trainingsession_type', $langs->transnoentities("TrainingSessionType"), 'sellist', '', 'contrat', 0, 0, 1830, 'a:1:{s:7:"options";a:1:{s:34:"c_trainingsession_type:label:rowid";N;}}', '', '', 1);
+ $extra_fields->addExtraField('trainingsession_type', $langs->transnoentities("TrainingSessionType"), 'sellist', 1830, '', 'contrat', 0, 0, '', 'a:1:{s:7:"options";a:1:{s:34:"c_trainingsession_type:label:rowid";N;}}', '', '', 1);
+
+ $extra_fields->update('trainingsession_location', $langs->transnoentities("TrainingSessionLocation"), 'varchar', '', 'contrat', 0, 0, 1850, '', '', '', 1);
+ $extra_fields->addExtraField('trainingsession_location', $langs->transnoentities("TrainingSessionLocation"), 'varchar', 1850, '', 'contrat', 0, 0, '', '', '', '', 1);
// Permissions
$this->remove($options);
diff --git a/core/tpl/session/dolimeet_session_agenda.tpl.php b/core/tpl/session/dolimeet_session_agenda.tpl.php
new file mode 100644
index 0000000..5d95b3f
--- /dev/null
+++ b/core/tpl/session/dolimeet_session_agenda.tpl.php
@@ -0,0 +1,166 @@
+dolimeet->dir_output.'/temp/massgeneration/'.$user->id;
+$hookmanager->initHooks(array($object->element.'agenda', 'globalcard')); // Note that conf->hooks_modules contains array
+// Fetch optionals attributes and labels
+$extrafields->fetch_name_optionals_label($object->table_element);
+
+// Load object
+include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
+if ($id > 0 || !empty($ref)) {
+$upload_dir = $conf->dolimeet->multidir_output[$object->entity]."/".$object->id;
+}
+
+$object_type = $object->element;
+$permissiontoread = $user->rights->dolimeet->$object_type->read;
+$permissiontoadd = $user->rights->dolimeet->$object_type->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
+$permissiontodelete = $user->rights->dolimeet->$object_type->delete || ($permissiontoadd && isset($object->status));
+$permissionnote = $user->rights->dolimeet->$object_type->write; // Used by the include of actions_setnotes.inc.php
+$upload_dir = $conf->dolimeet->multidir_output[$conf->entity];
+
+// Security check (enable the most restrictive one)
+if ($user->socid > 0) accessforbidden();
+if ($user->socid > 0) $socid = $user->socid;
+if (empty($conf->dolimeet->enabled)) accessforbidden();
+if (!$permissiontoread) accessforbidden();
+
+/*
+* Actions
+*/
+
+$parameters = array('id'=>$id);
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) {
+setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+}
+
+if (empty($reshook)) {
+// Cancel
+if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
+header("Location: ".$backtopage);
+exit;
+}
+
+// Purge search criteria
+if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
+$actioncode = '';
+$search_agenda_label = '';
+}
+}
+
+
+
+/*
+* View
+*/
+
+$form = new Form($db);
+
+if ($object->id > 0) {
+ $title = $langs->trans("Agenda" . ucfirst($object->element));
+ //if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title;
+ $help_url = 'EN:Module_Agenda_En';
+ llxHeader('', $title, $help_url);
+
+ if (!empty($conf->notification->enabled)) {
+ $langs->load("mails");
+ }
+ $prepareHead = $object->element . 'PrepareHead';
+ $head = $prepareHead($object);
+
+ print dol_get_fiche_head($head, 'agenda', $langs->trans('Agenda'), -1, $object->picto);
+
+ // Object card
+ // ------------------------------------------------------------
+ $linkback = ''.$langs->trans("BackToList").'';
+
+ // Project
+ $project->fetch($object->fk_project);
+ $morehtmlref = '- ' . $object->label;
+ $morehtmlref .= '';
+ $morehtmlref .= $langs->trans('Project') . ' : ' . $project->getNomUrl(1);
+ $morehtmlref .= '';
+ $morehtmlref .= '
';
+ $morehtmlref .= '
';
+
+ if ($object->element == 'trainingsession') {
+ $contract->fetch($object->fk_contrat);
+ $morehtmlref .= '';
+ $morehtmlref .= $langs->trans('Contract') . ' : ' . $contract->getNomUrl(1);
+ $morehtmlref .= '';
+ $morehtmlref .= '
';
+ $morehtmlref .= '
';
+ }
+
+
+ dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
+
+ print '';
+ print '
';
+
+ $object->info($object->id);
+ dol_print_object_info($object, 1);
+
+ print '
';
+
+ print dol_get_fiche_end();
+
+ // Actions buttons
+
+ $objthirdparty = $object;
+ $objcon = new stdClass();
+
+ $out = '&origin='.urlencode($object->element.'@'.$object->module).'&originid='.urlencode($object->id);
+ $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id;
+ $out .= '&backtopage='.urlencode($urlbacktopage);
+ $permok = $user->rights->agenda->myactions->create;
+ if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) {
+ //$out.='trans("AddAnAction"),'filenew');
+ //$out.="";
+ }
+
+
+ print '';
+
+ if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
+ $param = '&id='.$object->id.'&socid='.$socid;
+ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
+ $param .= '&contextpage='.urlencode($contextpage);
+ }
+ if ($limit > 0 && $limit != $conf->liste_limit) {
+ $param .= '&limit='.urlencode($limit);
+ }
+
+ // List of all actions
+ $filters = array();
+ $filters['search_agenda_label'] = $search_agenda_label;
+
+ // TODO Replace this with same code than into list.php
+ show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module);
+ }
+}
+
+// End of page
+llxFooter();
+$db->close();
diff --git a/core/tpl/session/dolimeet_session_attendants.tpl.php b/core/tpl/session/dolimeet_session_attendants.tpl.php
new file mode 100644
index 0000000..ac136ce
--- /dev/null
+++ b/core/tpl/session/dolimeet_session_attendants.tpl.php
@@ -0,0 +1,544 @@
+fetch($id);
+
+$hookmanager->initHooks(array($object->element.'signature', 'globalcard')); // Note that conf->hooks_modules contains array
+
+//Security check
+$object_type = $object->element;
+$permissiontoread = $user->rights->dolimeet->$object_type->read;
+$permissiontoadd = $user->rights->dolimeet->$object_type->write;
+$permissiontodelete = $user->rights->dolimeet->$object_type->delete;
+
+if ( ! $permissiontoread) accessforbidden();
+
+/*
+/*
+ * Actions
+ */
+
+$parameters = array();
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+
+if (empty($backtopage) || ($cancel && empty($id))) {
+ if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
+ $backtopage = dol_buildpath('/dolimeet/view/'. $object->element .'/' . $object->element .'_attendants.php', 1) . '?id=' . ($object->id > 0 ? $object->id : '__ID__');
+ }
+}
+
+// Action to add internal attendant
+if ($action == 'addSocietyAttendant') {
+ $error = 0;
+ $object->fetch($id);
+ $attendant_id = GETPOST('user_attendant');
+
+ if ( ! $error) {
+ $role = strtoupper(GETPOST('attendantRole'));
+ $result = $signatory->setSignatory($object->id, $object->element, 'user', array($attendant_id), strtoupper($object->element).'_' . $role, $role == 'SESSION_TRAINER' ? 0 : 1);
+ if ($result > 0) {
+ $usertmp = $user;
+ $usertmp->fetch($attendant_id);
+ setEventMessages($langs->trans('AddAttendantMessage') . ' ' . $usertmp->firstname . ' ' . $usertmp->lastname, array());
+ // Creation attendant OK
+ $urltogo = str_replace('__ID__', $result, $backtopage);
+ $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $id, $urltogo); // New method to autoselect project after a New on another form object creation
+ header("Location: " . $urltogo);
+ exit;
+ } else {
+ // Creation attendant KO
+ if ( ! empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
+ else setEventMessages($object->error, null, 'errors');
+ }
+ }
+}
+
+// Action to add external attendant
+if ($action == 'addExternalAttendant') {
+ $error = 0;
+ $object->fetch($id);
+ $extintervenant_id = GETPOST('external_attendant');
+
+ if ( ! $error) {
+ $result = $signatory->setSignatory($object->id, $object->element, 'socpeople', array($extintervenant_id), strtoupper($object->element).'_EXTERNAL_ATTENDANT', 1);
+ if ($result > 0) {
+ $contact->fetch($extintervenant_id);
+ setEventMessages($langs->trans('AddAttendantMessage') . ' ' . $contact->firstname . ' ' . $contact->lastname, array());
+ // Creation attendant OK
+ $urltogo = str_replace('__ID__', $result, $backtopage);
+ $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $id, $urltogo); // New method to autoselect project after a New on another form object creation
+ header("Location: " . $urltogo);
+ exit;
+ } else {
+ // Creation attendant KO
+ if ( ! empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
+ else setEventMessages($object->error, null, 'errors');
+ }
+ }
+}
+
+// Action to add record
+if ($action == 'addSignature') {
+ $signatoryID = GETPOST('signatoryID');
+ $data = json_decode(file_get_contents('php://input'), true);
+
+ $signatory->fetch($signatoryID);
+ $signatory->signature = $data['signature'];
+ $signatory->signature_date = dol_now('tzuser');
+
+ if ( ! $error) {
+ $result = $signatory->update($user, false);
+
+ if ($result > 0) {
+ // Creation signature OK
+ $signatory->setSigned($user, 0);
+ setEventMessages($langs->trans('SignatureEvent') . ' ' . $contact->firstname . ' ' . $contact->lastname, array());
+ $urltogo = str_replace('__ID__', $result, $backtopage);
+ $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $id, $urltogo); // New method to autoselect project after a New on another form object creation
+ header("Location: " . $urltogo);
+ exit;
+ } else {
+ // Creation signature KO
+ if ( ! empty($signatory->errors)) setEventMessages(null, $signatory->errors, 'errors');
+ else setEventMessages($signatory->error, null, 'errors');
+ }
+ }
+}
+
+// Action to set status STATUS_ABSENT
+if ($action == 'setAbsent') {
+ $signatoryID = GETPOST('signatoryID');
+
+ $signatory->fetch($signatoryID);
+
+ if ( ! $error) {
+ $result = $signatory->setAbsent($user, 0);
+ if ($result > 0) {
+ // set absent OK
+ setEventMessages($langs->trans('Attendant') . ' ' . $signatory->firstname . ' ' . $signatory->lastname . ' ' . $langs->trans('SetAbsentAttendant'), array());
+ $urltogo = str_replace('__ID__', $result, $backtopage);
+ $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $id, $urltogo); // New method to autoselect project after a New on another form object creation
+ header("Location: " . $urltogo);
+ exit;
+ } else {
+ // set absent KO
+ if ( ! empty($signatory->errors)) setEventMessages(null, $signatory->errors, 'errors');
+ else setEventMessages($signatory->error, null, 'errors');
+ }
+ }
+}
+
+// Action to send Email
+if ($action == 'send') {
+ $signatoryID = GETPOST('signatoryID');
+ $signatory->fetch($signatoryID);
+
+ if ( ! $error) {
+ $langs->load('mails');
+
+ if (!dol_strlen($signatory->email)) {
+ if ($signatory->element_type == 'user') {
+ $usertmp = $user;
+ $usertmp->fetch($signatory->element_id);
+ if (dol_strlen($usertmp->email)) {
+ $signatory->email = $usertmp->email;
+ $signatory->update($user, true);
+ }
+ } else if ($signatory->element_type == 'socpeople') {
+ $contact->fetch($signatory->element_id);
+ if (dol_strlen($contact->email)) {
+ $signatory->email = $contact->email;
+ $signatory->update($user, true);
+ }
+ }
+ }
+
+ $sendto = $signatory->email;
+
+ if (dol_strlen($sendto) && ( ! empty($conf->global->MAIN_MAIL_EMAIL_FROM))) {
+ require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
+
+ $from = $conf->global->MAIN_MAIL_EMAIL_FROM;
+ $url = dol_buildpath('/custom/dolimeet/public/signature/add_signature.php?track_id=' . $signatory->signature_url . '&type=' . $object->element, 3);
+
+ $message = $langs->trans('SignatureEmailMessage') . ' ' . $url;
+ $subject = $langs->trans('SignatureEmailSubject') . ' ' . $object->ref;
+
+ // Create form object
+ // Send mail (substitutionarray must be done just before this)
+ $mailfile = new CMailFile($subject, $sendto, $from, $message, array(), array(), array(), "", "", 0, -1, '', '', '', '', 'mail');
+
+ if ($mailfile->error) {
+ setEventMessages($mailfile->error, $mailfile->errors, 'errors');
+ } else {
+ if ( ! empty($conf->global->MAIN_MAIL_SMTPS_ID)) {
+ $result = $mailfile->sendfile();
+ if ($result) {
+ $signatory->last_email_sent_date = dol_now('tzuser');
+ $signatory->update($user, true);
+ $signatory->setPending($user, false);
+ setEventMessages($langs->trans('SendEmailAt') . ' ' . $signatory->email, array());
+ // This avoid sending mail twice if going out and then back to page
+ header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id);
+ exit;
+ } else {
+ $langs->load("other");
+ $mesg = '';
+ if ($mailfile->error) {
+ $mesg .= $langs->transnoentities('ErrorFailedToSendMail', dol_escape_htmltag($from), dol_escape_htmltag($sendto));
+ $mesg .= '
' . $mailfile->error;
+ } else {
+ $mesg .= $langs->transnoentities('ErrorFailedToSendMail', dol_escape_htmltag($from), dol_escape_htmltag($sendto));
+ }
+ $mesg .= '
';
+ setEventMessages($mesg, null, 'warnings');
+ }
+ } else {
+ setEventMessages($langs->trans('ErrorSetupEmail'), '', 'errors');
+ }
+ }
+ } else {
+ $langs->load("errors");
+ setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("MailTo")), null, 'warnings');
+ dol_syslog('Try to send email with no recipient defined', LOG_WARNING);
+ }
+ } else {
+ // Mail sent KO
+ if ( ! empty($signatory->errors)) setEventMessages(null, $signatory->errors, 'errors');
+ else setEventMessages($signatory->error, null, 'errors');
+ }
+}
+
+// Action to delete attendant
+if ($action == 'deleteAttendant') {
+ $signatoryToDeleteID = GETPOST('signatoryID');
+ $signatory->fetch($signatoryToDeleteID);
+
+ if ( ! $error) {
+ $result = $signatory->setDeleted($user, 0);
+ if ($result > 0) {
+ setEventMessages($langs->trans('DeleteAttendantMessage') . ' ' . $signatory->firstname . ' ' . $signatory->lastname, array());
+ // Deletion attendant OK
+ $urltogo = str_replace('__ID__', $result, $backtopage);
+ $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $id, $urltogo); // New method to autoselect project after a New on another form object creation
+ header("Location: " . $urltogo);
+ exit;
+ } else {
+ // Deletion attendant KO
+ if ( ! empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
+ else setEventMessages($object->error, null, 'errors');
+ }
+ } else {
+ $action = 'create';
+ }
+}
+
+/*
+ * View
+ */
+
+$formcompany = new FormCompany($db);
+$title = $langs->trans(ucfirst($object->element)."Attendants");
+$help_url = '';
+$morejs = array("/dolimeet/js/signature-pad.min.js", "/dolimeet/js/dolimeet.js.php");
+$morecss = array("/dolimeet/css/dolimeet.css");
+
+llxHeader('', $title, $help_url, '', '', '', $morejs, $morecss);
+
+if ( ! empty($object->id)) $res = $object->fetch_optionals();
+
+// Object card
+// ------------------------------------------------------------
+
+$prepareHead = $object->element . 'PrepareHead';
+$head = $prepareHead($object);
+print dol_get_fiche_head($head, 'attendants', $langs->trans(ucfirst($object->element)), -1, $object->picto);
+
+$width = 80; $cssclass = 'photoref';
+dol_strlen($object->label) ? $morehtmlref = '' . ' - ' . $object->label . '' : '';
+$morehtmlref .= '';
+
+// Project
+$project->fetch($object->fk_project);
+$morehtmlref = '- ' . $object->label;
+$morehtmlref .= '
';
+$morehtmlref .= $langs->trans('Project') . ' : ' . $project->getNomUrl(1);
+$morehtmlref .= '';
+$morehtmlref .= '
';
+$morehtmlref .= '
';
+
+if ($object->element == 'trainingsession') {
+ $contract->fetch($object->fk_contrat);
+ $morehtmlref .= '
';
+ $morehtmlref .= $langs->trans('Contract') . ' : ' . $contract->getNomUrl(1);
+ $morehtmlref .= '';
+ $morehtmlref .= '
';
+ $morehtmlref .= '
';
+}
+
+//$morehtmlleft = '
'.digirisk_show_photos('dolimeet', $conf->dolimeet->multidir_output[$entity].'/'.$object->element_type, 'small', 5, 0, 0, 0, $width,0, 0, 0, 0, $object->element_type, $object).'
';
+
+dol_banner_tab($object, 'ref', '', 0, 'ref', 'ref', $morehtmlref, '', 0, $morehtmlleft);
+
+print dol_get_fiche_end(); ?>
+
+status == 1 ) : ?>
+
+
+trans('DisclaimerSignatureTitle') ?>
+trans(ucfirst($object->element)."MustBeValidatedToSign") ?>
+
+element ?>element ?>trans("GoToValidate") ?>
+
+
+
+
+
+trans('AddSignatureSuccess') ?>
+trans("AddSignatureSuccessText") . GETPOST('signature_id')?>
+
+checkSignatoriesSignatures($object->id, $object->element)) {
+// print '
' . $langs->trans("GoToLock") . '';
+// }
+// ?>
+
+
+fetchSignatory(strtoupper($object->element).'_SOCIETY_ATTENDANT', $object->id, $object->element);
+ $society_trainer = $signatory->fetchSignatory(strtoupper($object->element).'_SESSION_TRAINER', $object->id, $object->element);
+
+ $society_intervenants = array_merge($society_intervenants, $society_trainer);
+
+ print load_fiche_titre($langs->trans("Attendants"), '', '');
+
+ print '
';
+
+ print '';
+ print '' . $langs->trans("Name") . ' | ';
+ print '' . $langs->trans("Role") . ' | ';
+ print '' . $langs->trans("SignatureLink") . ' | ';
+ print '' . $langs->trans("SendMailDate") . ' | ';
+ print '' . $langs->trans("SignatureDate") . ' | ';
+ print '' . $langs->trans("Status") . ' | ';
+ print '' . $langs->trans("ActionsSignature") . ' | ';
+ print '' . $langs->trans("Signature") . ' | ';
+ print '
';
+
+ $already_added_users = array();
+ $j = 1;
+ if (is_array($society_intervenants) && ! empty($society_intervenants) && $society_intervenants > 0) {
+ foreach ($society_intervenants as $element) {
+ $usertmp = $user;
+ $usertmp->fetch($element->element_id);
+ print '';
+ print $usertmp->getNomUrl(1);
+ print ' | ';
+ print $langs->trans($element->role);
+ print ' | ';
+// if ($object->status == 2) {
+ $signatureUrl = dol_buildpath('/custom/dolimeet/public/signature/add_signature.php?track_id=' . $element->signature_url . '&type=' . $object->element, 3);
+ print '';
+// } else {
+// print '-';
+// }
+
+ print ' | ';
+ print dol_print_date($element->last_email_sent_date, 'dayhour');
+ print ' | ';
+ print dol_print_date($element->signature_date, 'dayhour');
+ print ' | ';
+ print $element->getLibStatut(5);
+ print ' | ';
+ print '';
+ if ($permissiontoadd) {
+ require __DIR__ . "/../signature/dolimeet_signature_action_view.tpl.php";
+ }
+ print ' | ';
+ if ($element->signature != $langs->transnoentities("FileGenerated") && $permissiontoadd) {
+ print '';
+ require __DIR__ . "/../signature/dolimeet_signature_view.tpl.php";
+ print ' | ';
+ }
+ print '
';
+ $already_added_users[$element->element_id] = $element->element_id;
+ $j++;
+ }
+ } else {
+ print '';
+ print $langs->trans('NoSocietyAttendants');
+ print ' |
';
+ }
+
+ if ($permissiontoadd) {
+ print '
' . "\n";
+ print '';
+ }
+
+ //External Society Intervenants -- Intervenants Société extérieure
+ $thirdparty->fetch($object->fk_soc);
+ $ext_society_intervenants = $signatory->fetchSignatory(strtoupper($object->element).'_EXTERNAL_ATTENDANT', $object->id, $object->element);
+
+ print load_fiche_titre($langs->trans("ExternalAttendants"), '', '');
+
+ print '
';
+
+ print '';
+ print '' . $langs->trans("Thirdparty") . ' | ';
+ print '' . $langs->trans("ContactLinked") . ' | ';
+ print '' . $langs->trans("Role") . ' | ';
+ print '' . $langs->trans("SignatureLink") . ' | ';
+ print '' . $langs->trans("SendMailDate") . ' | ';
+ print '' . $langs->trans("SignatureDate") . ' | ';
+ print '' . $langs->trans("Status") . ' | ';
+ print '' . $langs->trans("ActionsSignature") . ' | ';
+ print '' . $langs->trans("Signature") . ' | ';
+ print '
';
+
+ $already_selected_intervenants = array();
+ $j = 1;
+ if (is_array($ext_society_intervenants) && ! empty($ext_society_intervenants) && $ext_society_intervenants > 0) {
+ foreach ($ext_society_intervenants as $element) {
+ $contact->fetch($element->element_id);
+ print '';
+ $thirdparty->fetch($contact->fk_soc);
+ print $thirdparty->getNomUrl(1);
+ print ' | ';
+ print $contact->getNomUrl(1);
+ print ' | ';
+ print $langs->trans("ExtSocietyIntervenant");
+ print ' | ';
+// if ($object->status == 2) {
+ $signatureUrl = dol_buildpath('/custom/dolimeet/public/signature/add_signature.php?track_id=' . $element->signature_url . '&type=' . $object->element, 3);
+ print '';
+// } else {
+// print '-';
+// }
+
+ print ' | ';
+ print dol_print_date($element->last_email_sent_date, 'dayhour');
+ print ' | ';
+ print dol_print_date($element->signature_date, 'dayhour');
+ print ' | ';
+ print $element->getLibStatut(5);
+ print ' | ';
+ print '';
+ if ($permissiontoadd) {
+ require __DIR__ . "/../signature/dolimeet_signature_action_view.tpl.php";
+ }
+ print ' | ';
+ if ($element->signature != $langs->transnoentities("FileGenerated") && $permissiontoadd) {
+ print '';
+ require __DIR__ . "/../signature/dolimeet_signature_view.tpl.php";
+ print ' | ';
+ }
+ print '
';
+ $already_selected_intervenants[$element->element_id] = $element->element_id;
+ $j++;
+ }
+ } else {
+ print '';
+ print $langs->trans('NoExternalAttendants');
+ print ' |
';
+ }
+
+ if ($permissiontoadd) {
+ print '
' . "\n";
+ print '';
+ print '
';
+
+ }
+}
+
+// End of page
+llxFooter();
+$db->close();
diff --git a/meeting_card.php b/core/tpl/session/dolimeet_session_card.tpl.php
similarity index 66%
rename from meeting_card.php
rename to core/tpl/session/dolimeet_session_card.tpl.php
index f522c2d..13fcc41 100644
--- a/meeting_card.php
+++ b/core/tpl/session/dolimeet_session_card.tpl.php
@@ -1,81 +1,14 @@
- *
- * 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 .
- */
-
-/**
- * \file meeting_card.php
- * \ingroup meeting
- * \brief Page to create/edit/view meeting
- */
-// 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";
-// 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--; }
-if (!$res && $i > 0 && file_exists(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";
-// Try main.inc.php using relative path
-if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
-if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
-if (!$res) die("Include of main fails");
-
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
-require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
-require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
-require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
-require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
-require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
-
-require_once './class/meeting.class.php';
-require_once './core/modules/dolimeet/mod_meeting_standard.php';
-require_once './lib/dolimeet_meeting.lib.php';
-require_once './lib/dolimeet.lib.php';
-require_once './lib/dolimeet_function.lib.php';
-
-global $db, $conf, $langs, $user, $hookmanager;
-
-// Load translation files required by the page
-$langs->loadLangs(array("dolimeet@dolimeet", "other"));
-
-// Get parameters
-$id = GETPOST('id', 'int');
-$action = GETPOST('action', 'aZ09');
-$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
-$confirm = GETPOST('confirm', 'alpha');
-$cancel = GETPOST('cancel', 'aZ09');
-$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'riskcard'; // To manage different context of search
-$backtopage = GETPOST('backtopage', 'alpha');
-
-// Initialize technical objects
-$object = new Meeting($db);
$contact = new Contact($db);
$project = new Project($db);
-$refMeetingMod = new $conf->global->DOLIMEET_MEETING_ADDON();
+$mod = 'DOLIMEET_'. strtoupper($object->element) .'_ADDON';
+$refMod = new $conf->global->$mod();
$extrafields = new ExtraFields($db);
$usertmp = new User($db);
$ecmfile = new EcmFiles($db);
$thirdparty = new Societe($db);
+$signatory = new DolimeetSignature($db);
$object->fetch($id);
if ($object->fk_contact > 0) {
@@ -83,7 +16,7 @@
$linked_contact->fetch($object->fk_contact);
}
-$hookmanager->initHooks(array('lettercard', 'globalcard')); // Note that conf->hooks_modules contains array
+$hookmanager->initHooks(array($object->element . 'card', 'globalcard')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element);
@@ -102,15 +35,15 @@
if (empty($action) && empty($id) && empty($ref)) {
$action = 'view';
}
-$upload_dir = $conf->dolimeet->multidir_output[$conf->entity ?: $conf->entity]."/meeting/".get_exdir(0, 0, 0, 1, $object);
+$upload_dir = $conf->dolimeet->multidir_output[$conf->entity ?: $conf->entity]. "/" . $object->element . "/" .get_exdir(0, 0, 0, 1, $object);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
-$permissiontoread = $user->rights->dolimeet->meeting->read;
-$permissiontoadd = $user->rights->dolimeet->meeting->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
-$permissiontodelete = $user->rights->dolimeet->meeting->delete || ($permissiontoadd && isset($object->status));
-$permissionnote = $user->rights->dolimeet->meeting->write; // Used by the include of actions_setnotes.inc.php
-$permissiondellink = $user->rights->meeting->letter->write; // Used by the include of actions_dellink.inc.php
+$object_type = $object->element;
+$permissiontoread = $user->rights->dolimeet->$object_type->read;
+$permissiontoadd = $user->rights->dolimeet->$object_type->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
+$permissiontodelete = $user->rights->dolimeet->$object_type->delete || ($permissiontoadd && isset($object->status));
+$permissionnote = $user->rights->dolimeet->$object_type->write; // Used by the include of actions_setnotes.inc.php
$upload_dir = $conf->dolimeet->multidir_output[$conf->entity];
$thirdparty->fetch($object->fk_soc);
@@ -120,7 +53,6 @@
if (empty($conf->dolimeet->enabled)) accessforbidden();
if (!$permissiontoread) accessforbidden();
-
/*
* Actions
*/
@@ -163,19 +95,18 @@
$error = 0;
- $backurlforlist = dol_buildpath('/dolimeet/meeting_list.php', 1);
+ $backurlforlist = dol_buildpath('/dolimeet/view/'. $object->element .'/'. $object->element .'_list.php', 1);
if (empty($backtopage) || ($cancel && empty($id))) {
if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
$backtopage = $backurlforlist;
} else {
- $backtopage = dol_buildpath('/dolimeet/meeting_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
+ $backtopage = dol_buildpath('/dolimeet/view/'. $object->element .'/'. $object->element .'_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
}
}
}
-
// Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
//include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
@@ -186,22 +117,35 @@
$note_private = GETPOST('note_private');
$note_public = GETPOST('note_public');
$label = GETPOST('label');
- $project_id = GETPOST('fk_project');
+ $society_id = GETPOST('fk_soc');
+ $project_id = GETPOST('projectid');
+ $contrat_id = GETPOST('fk_contrat');
+ $durationh = GETPOST('durationh') ?:0;
+ $durationm = GETPOST('durationm') ?: 0;
+
+ $duration_minutes = $durationh * 60 + $durationm;
+
+ $date_start = dol_mktime(GETPOST('date_starthour', 'int'), GETPOST('date_startmin', 'int'), 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int'));
+ $date_end = dol_mktime(GETPOST('date_endhour', 'int'), GETPOST('date_endmin', 'int'), 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int'));
// Initialize object
$now = dol_now();
- $object->ref = $refMeetingMod->getNextValue($object);
+ $object->ref = $refMod->getNextValue($object);
$object->ref_ext = 'dolimeet_' . $object->ref;
$object->date_creation = $object->db->idate($now);
+ $object->date_start = $date_start;
+ $object->date_end = $date_end;
$object->tms = $now;
$object->import_key = "";
$object->note_private = $note_private;
$object->note_public = $note_public;
$object->label = $label;
+ $object->type = $object->element;
+ $object->duration = $duration_minutes;
$object->fk_soc = $society_id;
- $object->fk_contact = $contact_id;
$object->fk_project = $project_id;
+ $object->fk_contrat = $contrat_id;
$object->content = $content;
$object->entity = $conf->entity ?: 1;
@@ -217,14 +161,17 @@
if (!$error) {
$result = $object->create($user, false);
if ($result > 0) {
- // Creation meeting OK
- $urltogo = str_replace('__ID__', $result, $backtopage);
- $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $id, $urltogo); // New method to autoselect project after a New on another form object creation
- header("Location: " . $urltogo);
+ // Creation OK
+ // Category association
+ $categories = GETPOST('categories', 'array');
+ $object->setCategories($categories);
+ $urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist;
+ $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation
+ header("Location: ".$urltogo);
exit;
}
else {
- // Creation meeting KO
+ // Creation KO
if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
else setEventMessages($object->error, null, 'errors');
}
@@ -238,24 +185,33 @@
$society_id = GETPOST('fk_soc');
$content = GETPOST('content', 'restricthtml');
$label = GETPOST('label');
- $contact_id = GETPOST('fk_contact');
+ $contrat_id = GETPOST('fk_contrat');
$project_id = GETPOST('fk_project');
+ $date_start = dol_mktime(GETPOST('date_starthour', 'int'), GETPOST('date_startmin', 'int'), 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int'));
+ $date_end = dol_mktime(GETPOST('date_endhour', 'int'), GETPOST('date_endmin', 'int'), 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int'));
+ $durationh = GETPOST('durationh') ?:0;
+ $durationm = GETPOST('durationm') ?: 0;
+
+ $duration_minutes = $durationh * 60 + $durationm;
$object->label = $label;
$object->fk_soc = $society_id;
$object->content = $content;
- $object->fk_contact = $contact_id;
+ $object->fk_contrat = $contrat_id;
$object->fk_project = $project_id;
+ $object->date_start = $date_start;
+ $object->date_end = $date_end;
+ $object->duration = $duration_minutes;
$object->fk_user_creat = $user->id ? $user->id : 1;
if (!$error) {
$result = $object->update($user, false);
if ($result > 0) {
- $signatory->deleteSignatoriesSignatures($object->id, 0);
- $object->setStatusCommon($user, 0);
- $urltogo = str_replace('__ID__', $result, $backtopage);
- $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $id, $urltogo); // New method to autoselect project after a New on another form object creation
- header("Location: " . $urltogo);
+ $categories = GETPOST('categories', 'array');
+ $object->setCategories($categories);
+ $urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist;
+ $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation
+ header("Location: ".$urltogo);
exit;
}
else
@@ -271,7 +227,7 @@
if ($action == 'confirm_delete' && GETPOST("confirm") == "yes")
{
$object->setStatusCommon($user, -1);
- $urltogo = DOL_URL_ROOT . '/custom/dolimeet/meeting_list.php';
+ $urltogo = DOL_URL_ROOT . '/custom/dolimeet/view/'. $object->element .'/'. $object->element .'_list.php';
header("Location: " . $urltogo);
exit;
}
@@ -286,108 +242,71 @@
//include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
// Action to build doc
-// include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
-
if ($action == 'builddoc' && $permissiontoadd) {
- if (is_numeric(GETPOST('model', 'alpha'))) {
- $error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Model"));
- } else {
- // Reload to get all modified line records and be ready for hooks
- $ret = $object->fetch($id);
- $ret = $object->fetch_thirdparty();
- /*if (empty($object->id) || ! $object->id > 0)
- {
- dol_print_error('Object must have been loaded by a fetch');
- exit;
- }*/
-
- // Save last template used to generate document
- if (GETPOST('model', 'alpha')) {
- $object->setDocModel($user, GETPOST('model', 'alpha'));
- }
+ $outputlangs = $langs;
+ $newlang = '';
- // Special case to force bank account
- //if (property_exists($object, 'fk_bank'))
- //{
- if (GETPOST('fk_bank', 'int')) {
- // this field may come from an external module
- $object->fk_bank = GETPOST('fk_bank', 'int');
- } elseif (!empty($object->fk_account)) {
- $object->fk_bank = $object->fk_account;
- }
- //}
-
- $outputlangs = $langs;
- $newlang = '';
-
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
- $newlang = GETPOST('lang_id', 'aZ09');
- }
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->thirdparty->default_lang)) {
- $newlang = $object->thirdparty->default_lang; // for proposal, order, invoice, ...
- }
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->default_lang)) {
- $newlang = $object->default_lang; // for thirdparty
- }
- if (!empty($newlang)) {
- $outputlangs = new Translate("", $conf);
- $outputlangs->setDefaultLang($newlang);
- }
-
- // To be sure vars is defined
- if (empty($hidedetails)) {
- $hidedetails = 0;
- }
- if (empty($hidedesc)) {
- $hidedesc = 0;
- }
- if (empty($hideref)) {
- $hideref = 0;
- }
- if (empty($moreparams)) {
- $moreparams = null;
- }
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
+ if ( ! empty($newlang)) {
+ $outputlangs = new Translate("", $conf);
+ $outputlangs->setDefaultLang($newlang);
+ }
- $result = $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
- if ($result <= 0) {
- setEventMessages($object->error, $object->errors, 'errors');
- $action = '';
- } else {
- if ($conf->global->DOLIMEET_SHOW_DOCUMENTS_ON_PUBLIC_INTERFACE) {
- $filedir = $conf->dolimeet->dir_output.'/'.$object->element.'/'.$object->ref;
- $filelist = dol_dir_list($filedir, 'files');
- if (!empty($filelist)) {
- foreach ($filelist as $file) {
- if (!preg_match('/specimen/', $file['name'])) {
- $fileurl = $file['fullname'];
- $filename = $file['name'];
- }
+ // To be sure vars is defined
+ if (empty($hidedetails)) $hidedetails = 0;
+ if (empty($hidedesc)) $hidedesc = 0;
+ if (empty($hideref)) $hideref = 0;
+ if (empty($moreparams)) $moreparams = null;
+
+ $model = GETPOST('model', 'alpha');
+
+ $moreparams['object'] = $object;
+ $moreparams['user'] = $user;
+
+ if (preg_match('/completioncertificate/',GETPOST('model'))) {
+ $signatoriesList = $signatory->fetchSignatories($object->id, $object->type);
+ if (!empty($signatoriesList)) {
+ foreach($signatoriesList as $objectSignatory) {
+ if ($objectSignatory->role != 'TRAININGSESSION_SESSION_TRAINER') {
+ $moreparams['attendant'] = $objectSignatory;
+ $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
+ if ($result <= 0) {
+ setEventMessages($object->error, $object->errors, 'errors');
+ $action = '';
}
}
-
- $ecmfile->fetch(0, '', 'dolimeet/meeting/'.$object->ref.'/'.$filename, '', '', 'dolimeet_meeting', $id);
- require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
- $ecmfile->share = getRandomPassword(true);
- $ecmfile->update($user);
}
- if (empty($donotredirect)) { // This is set when include is done by bulk action "Bill Orders"
- setEventMessages($langs->trans("FileGenerated"), null);
-
+ if (empty($donotredirect)) {
+ setEventMessages($langs->trans("FileGenerated") . ' - ' . $object->last_main_doc, null);
$urltoredirect = $_SERVER['REQUEST_URI'];
$urltoredirect = preg_replace('/#builddoc$/', '', $urltoredirect);
$urltoredirect = preg_replace('/action=builddoc&?/', '', $urltoredirect); // To avoid infinite loop
-
- header('Location: '.$urltoredirect.'#builddoc');
+ header('Location: ' . $urltoredirect . '#builddoc');
exit;
}
}
}
+
+ $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
+ if ($result <= 0) {
+ setEventMessages($object->error, $object->errors, 'errors');
+ $action = '';
+ } else {
+ if (empty($donotredirect)) {
+ setEventMessages($langs->trans("FileGenerated") . ' - ' . $object->last_main_doc, null);
+ $urltoredirect = $_SERVER['REQUEST_URI'];
+ $urltoredirect = preg_replace('/#builddoc$/', '', $urltoredirect);
+ $urltoredirect = preg_replace('/action=builddoc&?/', '', $urltoredirect); // To avoid infinite loop
+ header('Location: ' . $urltoredirect . '#builddoc');
+ exit;
+ }
+ }
}
// Actions to send emails
- $triggersendname = 'DOLIMEET_MEETING_SENTBYMAIL';
- $autocopy = 'MAIN_MAIL_AUTOCOPY_MEETING_TO';
- $trackid = 'meeting'.$object->id;
+ $triggersendname = 'DOLIMEET_'. strtoupper($object->element) .'_SENTBYMAIL';
+ $autocopy = 'MAIN_MAIL_AUTOCOPY_'. strtoupper($object->element) .'_TO';
+ $trackid = $object->element.$object->id;
/*
* Send mail
@@ -754,11 +673,9 @@
// Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes') {
- if ($object->status > 0) {
- $object->status = 0;
- }
- $object->ref = $refMeetingMod->getNextValue($object);
- $result = $object->create($user);
+ $options = array();
+ $object->ref = $refMod->getNextValue($object);
+ $result = $object->createFromClone($user, $object->id, $options);
if ($result > 0) {
header("Location: " . $_SERVER["PHP_SELF"] . '?id=' . $result);
@@ -769,7 +686,7 @@
/*
* View
- *
+ *FZ
* Put here all code to build page
*/
@@ -778,9 +695,9 @@
$formfile = new FormFile($db);
$formproject = new FormProjets($db);
-$title = $langs->trans("Meeting");
-$title_create = $langs->trans("NewMeeting");
-$title_edit = $langs->trans("ModifyMeeting");
+$title = $langs->trans("Card" . ucfirst($object->element));
+$title_create = $langs->trans("New" . ucfirst($object->element));
+$title_edit = $langs->trans("Modify" . ucfirst($object->element));
$help_url = '';
$morejs = array("/dolimeet/js/signature-pad.min.js", "/dolimeet/js/dolimeet.js.php");
$morecss = array("/dolimeet/css/dolimeet.css");
@@ -811,14 +728,17 @@
unset($object->fields['content']);
unset($object->fields['note_public']);
unset($object->fields['note_private']);
+ unset($object->fields['date_start']);
+ unset($object->fields['date_end']);
unset($object->fields['fk_soc']);
- unset($object->fields['fk_contact']);
+ unset($object->fields['fk_contrat']);
unset($object->fields['fk_project']);
+ unset($object->fields['duration']);
//Ref -- Ref
print ''.$langs->trans("Ref").' | ';
- print '';
- print $refMeetingMod->getNextValue($object);
+ print '';
+ print $refMod->getNextValue($object);
print ' |
';
// Common attributes
@@ -826,16 +746,60 @@
//Project -- Projet
print ' | ';
- $numprojet = $formproject->select_projects(GETPOST('fk_soc') ?: -1, GETPOST('fk_project'), 'fk_project', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, 'minwidth300');
+ $numprojet = $formproject->select_projects(GETPOST('fk_soc') ?: -1, GETPOST('projectid'), 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, 'minwidth300');
print ' ';
print ' |
';
+ //Contract -- Contrat
+ if ($object->element == 'trainingsession') {
+ print ' | ';
+ $numcontrat = $formcontract->select_contract(GETPOST('fk_soc') ?: -1, GETPOST('fk_contrat'), 'fk_contrat', 0, 1, 1);
+ print ' ';
+ print ' |
';
+
+ //Duration - Durée
+ print ' | ';
+ print '';
+ print $langs->trans('Hour(s)');
+ print '';
+ print $langs->trans('Minute(s)');
+ print ' |
';
+ }
+
+ //Date start - Date de début
+ print ' | ';
+ print $form->selectDate(dol_now('tzuser'), 'date_start', 1, 1, 0, '', 1,1);
+ print ' |
';
+
+ //Date end - Date de début
+ print ' | ';
+ print $form->selectDate(dol_now('tzuser'), 'date_end', 1, 1, 0, '', 1, 1);
+ print ' |
';
+
+
+// //Society -- Société
+// print ''.$langs->trans("Society").' | ';
+// $events = array();
+// $events[1] = array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php?showempty=1', 1), 'htmlname' => 'fk_contact', 'params' => array('add-customer-contact' => 'disabled'));
+// print $form->select_company(GETPOST('fromtype') == 'thirdparty' ? GETPOST('fromid') : GETPOST('fk_soc'), 'fk_soc', '', 'SelectThirdParty', 1, 0, $events, 0, 'minwidth300');
+// print ' ';
+// print ' |
';
+
//Content -- Contenu
print ' | ';
$doleditor = new DolEditor('content', GETPOST('content'), '', 250, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_3, '90%');
$doleditor->Create();
print ' |
';
+ // Categories
+ if (!empty($conf->categorie->enabled)) {
+ print ''.$langs->trans("Categories").' | ';
+ $cate_arbo = $form->select_all_categories($object->element, '', 'parent', 64, 0, 1);
+ print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, GETPOST('categories', 'array'), '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
+ print " |
";
+ }
+
+
// //PublicNote -- Note publique
// print ' | ';
// $doleditor = new DolEditor('note_public', GETPOST('note_public'), '', 90, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_3, '90%');
@@ -867,7 +831,7 @@
// Part to edit record
if (($id || $ref) && $action == 'edit' ||$action == 'confirm_setInProgress') {
- print load_fiche_titre($langs->trans("EditMeeting"), '', 'object_'.$object->picto);
+ print load_fiche_titre($langs->trans("Edit".ucfirst($object->element)), '', 'object_'.$object->picto);
print ' |
';
- //Society -- Société
- print ''.$langs->trans("Society").' | ';
- $events = array();
- $events[1] = array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php?showempty=1', 1), 'htmlname' => 'contact', 'params' => array('add-customer-contact' => 'disabled'));
- print $form->select_company($object->fk_soc, 'fk_soc', '', 'SelectThirdParty', 1, 0, $events, 0, 'minwidth300');
- print ' ';
+ //Project -- Projet
+ print ' |
| ';
+ $numprojet = $formproject->select_projects(GETPOST('fk_soc') ?: -1, $object->fk_project, 'fk_project', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, 'minwidth300');
+ print ' ';
print ' |
';
- //Contact -- Contact
- print ''.$langs->trans("Contact").' | ';
- print $form->selectcontacts(GETPOST('fk_soc', 'int'), $object->fk_contact, 'fk_contact', 1, '', '', 0, 'quatrevingtpercent', false, 0, array(), false, '', 'fk_contact');
+ //Contract -- Contrat
+ if ($object->element == 'trainingsession') {
+ print ' |
| ';
+ $numcontrat = $formcontract->select_contract(GETPOST('fk_soc') ?: -1, $object->fk_contrat, 'fk_contrat', 0, 1, 1);
+ print ' ';
+ print ' |
';
+
+ //Duration - Durée
+ print ' | ';
+ $duration_hours = floor($object->duration / 60);
+ $duration_minutes = ($object->duration % 60);
+ print '';
+ print '';
+ print ' |
';
+ }
+
+ //Date start - Date de début
+ print ' | ';
+ print $form->selectDate($object->date_start, 'date_start', 1, 1, 0, '', 1,1);
print ' |
';
- //Contact -- Contact
- print ' | ';
- $numprojet = $formproject->select_projects(0, $object->fk_project, 'fk_project', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, 'minwidth300');
- print ' ';
+ //Date end - Date de début
+ print ' |
| ';
+ print $form->selectDate($object->date_end, 'date_end', 1, 1, 0, '', 1, 1);
print ' |
';
+// //Society -- Société
+// print ''.$langs->trans("Society").' | ';
+// $events = array();
+// $events[1] = array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php?showempty=1', 1), 'htmlname' => 'contact', 'params' => array('add-customer-contact' => 'disabled'));
+// print $form->select_company($object->fk_soc, 'fk_soc', '', 'SelectThirdParty', 1, 0, $events, 0, 'minwidth300');
+// print ' ';
+// print ' |
';
+
//Content -- Contenu
print ' | ';
$doleditor = new DolEditor('content', $object->content, '', 90, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_3, '90%');
$doleditor->Create();
print ' |
';
+ // Tags-Categories
+ if ($conf->categorie->enabled) {
+ print ''.$langs->trans("Categories").' | ';
+ $cate_arbo = $form->select_all_categories($object->element, '', 'parent', 64, 0, 1);
+ $c = new Categorie($db);
+ $cats = $c->containing($object->id, 'session');
+ $arrayselected = array();
+ if (is_array($cats)) {
+ foreach ($cats as $cat) {
+ $arrayselected[] = $cat->id;
+ }
+ }
+ print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
+ print " |
";
+ }
+
print '