Skip to content

Commit

Permalink
Merge branch 'develop' into fix_risksign
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-eoxia authored Oct 20, 2023
2 parents 83a89e0 + 81fb5c9 commit ea9512b
Show file tree
Hide file tree
Showing 49 changed files with 835 additions and 152 deletions.
15 changes: 10 additions & 5 deletions class/actions_digiriskdolibarr.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public function printCommonFooter($parameters)
require_once __DIR__ . '/digiriskelement.class.php';
$digiriskelement = new DigiriskElement($db);
$digiriskelement->fetch($object->array_options['options_digiriskdolibarr_ticket_service']);
$selectDictionnary = $digiriskelement->getNomUrl(1, 'blank', 1);
$selectDictionnary = $digiriskelement->getNomUrl(1, 'blank', 0, '', -1, 1);
?>
<script>
jQuery('.ticket_extras_digiriskdolibarr_ticket_service').html('')
Expand Down Expand Up @@ -271,7 +271,7 @@ public function printCommonFooter($parameters)
<?php
if (!empty($risk_id) && $risk_id > 0) { ?>
<script>
jQuery('.project_task_extras_fk_risk').html(<?php echo json_encode($risk->getNomUrl(1, 'blank')) ?>);
jQuery('.project_task_extras_fk_risk').html(<?php echo json_encode($risk->getNomUrl(1, 'nolink')) ?>);
</script>
<?php }
if (!empty($preventionplan_id) && $preventionplan_id > 0) { ?>
Expand Down Expand Up @@ -316,7 +316,7 @@ public function printCommonFooter($parameters)
if ($parameters['currentcontext'] == 'projecttaskscard') {
if (!empty($risk_id) && $risk_id > 0) { ?>
<script>
jQuery('.div-table-responsive').find('tr[id="row-' + <?php echo $tasksingle->id; ?> +'"]').find('td[data-key="projet_task.fk_risk"]').html(<?php echo json_encode($risk->getNomUrl(1, 'blank')) ?>);
jQuery('.div-table-responsive').find('tr[id="row-' + <?php echo $tasksingle->id; ?> +'"]').find('td[data-key="projet_task.fk_risk"]').html(<?php echo json_encode($risk->getNomUrl(1, 'nolink')) ?>);
</script>
<?php }
if (!empty($preventionplan_id) && $preventionplan_id > 0) { ?>
Expand All @@ -343,7 +343,7 @@ public function printCommonFooter($parameters)
if ($parameters['currentcontext'] == 'tasklist') {
if (!empty($risk_id) && $risk_id > 0) { ?>
<script>
jQuery('.div-table-responsive').find('tr[data-rowid="' + <?php echo $tasksingle->id; ?> +'"]').find('td[data-key="projet_task.fk_risk"]').html(<?php echo json_encode($risk->getNomUrl(1, 'blank')) ?>);
jQuery('.div-table-responsive').find('tr[data-rowid="' + <?php echo $tasksingle->id; ?> +'"]').find('td[data-key="projet_task.fk_risk"]').html(<?php echo json_encode($risk->getNomUrl(1, 'nolink')) ?>);
</script>
<?php }
if (!empty($preventionplan_id) && $preventionplan_id > 0) { ?>
Expand Down Expand Up @@ -840,7 +840,8 @@ public function saturneBannerTab(array $parameters, object $object): int
case 'digiriskelementdocument' :
case 'digiriskelementagenda' :
case 'digiriskstandardagenda' :
$object->fk_project = $conf->global->DIGIRISKDOLIBARR_DU_PROJECT;
$moreParams['moreHtml'] = 'none';
$object->fk_project = $conf->global->DIGIRISKDOLIBARR_DU_PROJECT;
break;
case 'accidentdocument' :
case 'accidentagenda' :
Expand Down Expand Up @@ -925,6 +926,10 @@ public function SaturneAdminDocumentData(array $parameters): int
'documentType' => 'firepermitdocument',
'picto' => 'fontawesome_fa-fire-alt_fas_#d35968'
],
'AccidentInvestigationDocument' => [
'documentType' => 'accidentinvestigationdocument',
'picto' => 'fontawesome_fa-search_fas_#d35968'
],
'Ticket' => [
'documentType' => 'ticketdocument',
'picto' => 'ticket'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
/* Copyright (C) 2022-2023 EVARISK <technique@evarisk.com>
*
* 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/>.
*/

/**
* \file class/digiriskdolibarrdocuments/accidentinvestigationdocument.class.php
* \ingroup digiriskdolibarr
* \brief This file is a class file for AccidentInvestigationDocument
*/

// Load DigiriskDolibarr libraries
require_once __DIR__ . '/../digiriskdocuments.class.php';

/**
* Class for AccidentInvestigationDocument
*/
class AccidentInvestigationDocument extends DigiriskDocuments
{
/**
* @var string Module name
*/
public $module = 'digiriskdolibarr';

/**
* @var string Element type of object
*/
public $element = 'accidentinvestigationdocument';

/**
* Constructor
*
* @param DoliDb $db Database handler
*/
public function __construct(DoliDB $db)
{
parent::__construct($db, $this->module, $this->element);
}
}
3 changes: 2 additions & 1 deletion class/digiriskelement.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ public function selectDigiriskElementList($selected = '', $htmlname = 'fk_elemen
if (dol_strlen($filter['customsql'])) {
$filter['customsql'] .= ' AND t.rowid != ' . ($this->id ?? 0);
}
$objectList = saturne_fetch_all_object_type('digiriskelement', '', '', $limit, 0, $filter);

$objectList = saturne_fetch_all_object_type('digiriskelement', '', '', $limit, 0, $filter, 'AND', false, $multientitymanaged);
$digiriskElementsData = [];
if (is_array($objectList) && !empty($objectList)) {
foreach ($objectList as $digiriskElement) {
Expand Down
58 changes: 21 additions & 37 deletions class/riskanalysis/riskassessment.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ class RiskAssessment extends SaturneObject
*/
public int $isextrafieldmanaged = 1;

/**
* @var string Name of icon for riskassessment. Must be a 'fa-xxx' fontawesome code (or 'fa-xxx_fa_color_size') or 'riskassessment@digiriskdolibarr' if picto is file 'img/object_riskassessment.png'
*/
public string $picto = 'fontawesome_fa-chart-line_fas_#d35968';

public const STATUS_DELETED = -1;
public const STATUS_DRAFT = 0;
public const STATUS_VALIDATED = 1;
Expand Down Expand Up @@ -167,43 +172,22 @@ public function fetchFromParent($parent_id, $active = 0, $desc = '')
return $this->fetchAll($desc, 'rowid', 0, 0, $filter, 'AND', 1);
}


/**
* Update risk assessment status into database
*
* @param User $user User that modifies
* @param $risk_id
* @return int <0 if KO, >0 if OK
* @throws Exception
*/
public function updateEvaluationStatus(User $user, $risk_id)
{
dol_syslog(__METHOD__, LOG_DEBUG);
$sql = 'SELECT ';
$sql .= $this->getFieldList();
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN (' . getEntity($this->table_element) . ')';
else $sql .= ' WHERE 1 = 1';
$sql .= ' AND fk_risk = ' . $risk_id;
$sql .= ' ORDER BY t.rowid DESC';
$sql .= ' LIMIT 1';

$resql = $this->db->query($sql);

if ($resql) {
$evaluation = new RiskAssessment($this->db);
$obj = $this->db->fetch_object($resql);
$this->db->free($resql);
$evaluation->fetch($obj->rowid);
$evaluation->status = 1;
return $evaluation->update($user);
} else {
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);

return -1;
}
}
/**
* Update risk assessment status into database
*
* @param User $user User that modifies
* @param int $riskID Risk id
* @throws Exception
*/
public function updatePreviousRiskAssessmentStatus(User $user, int $riskID)
{
$riskAssessments = $this->fetchAll('DESC', 'rowid', 1, 0, ['customsql' => 'fk_risk = ' . $riskID . ' AND status = 0']);
if (is_array($riskAssessments) && !empty($riskAssessments)) {
foreach ($riskAssessments as $riskAssessment) {
$riskAssessment->setValueFrom('status', 1, '', '', 'int', '', $user);
}
}
}

/**
* Return scale level for risk assessment
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/* Copyright (C) 2021-2023 EVARISK <technique@evarisk.com>
*
* 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/>.
* or see https://www.gnu.org/
*/

/**
* \file core/modules/digiriskdolibarr/digiriskdolibarrdocuments/accidentinvestigationdocument/mod_accidentinvestigationdocument_siarnaq.php
* \ingroup digiriskdolibarr
* \brief File that contains the numbering module rules siarnaq
*/

// Load Saturne libraries
require_once __DIR__ . '/../../../../../../saturne/core/modules/saturne/modules_saturne.php';

/**
* Class of file that contains the numbering module rules siarnaq
*/
class mod_accidentinvestigationdocument_siarnaq extends CustomModeleNumRefSaturne
{
/**
* @var string Model name
*/
public string $name = 'Siarnaq';

public function __construct()
{
global $conf;

$refMod = $conf->global->DIGIRISKDOLIBARR_ACCIDENTINVESTIGATIONDOCUMENT_SIARNAQ_ADDON;
if (dol_strlen($refMod)) {
$refModSplitted = preg_split('/\{/', $refMod);
if (is_array($refModSplitted) && !empty($refModSplitted)) {
$suffix = preg_replace('/}/', '', $refModSplitted[1]);
$this->prefix = $refModSplitted[0];
$this->suffix = $suffix;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/* Copyright (C) 2021-2023 EVARISK <technique@evarisk.com>
*
* 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/>.
* or see https://www.gnu.org/
*/

/**
* \file core/modules/digiriskdolibarr/digiriskdolibarrdocuments/firepermitdocument/mod_firepermitdocument_greip.php
* \ingroup digiriskdolibarr
* \brief File that contains the numbering module rules greip
*/

// Load Saturne libraries
require_once __DIR__ . '/../../../../../../saturne/core/modules/saturne/modules_saturne.php';

/**
* Class of file that contains the numbering module rules greip
*/
class mod_firepermitdocument_greip extends CustomModeleNumRefSaturne
{
/**
* @var string Model name
*/
public string $name = 'Greip';

public function __construct()
{
global $conf;

$refMod = $conf->global->digiriskdolibarr_FIREPERMITDOCUMENT_GREIP_addon;
if (dol_strlen($refMod)) {
$refModSplitted = preg_split('/\{/', $refMod);
if (is_array($refModSplitted) && !empty($refModSplitted)) {
$suffix = preg_replace('/}/', '', $refModSplitted[1]);
$this->prefix = $refModSplitted[0];
$this->suffix = $suffix;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/* Copyright (C) 2021-2023 EVARISK <technique@evarisk.com>
*
* 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/>.
* or see https://www.gnu.org/
*/

/**
* \file core/modules/digiriskdolibarr/digiriskdolibarrdocuments/groupmentdocument/mod_groupmentdocument_mundilfari.php
* \ingroup digiriskdolibarr
* \brief File that contains the numbering module rules mundilfari
*/

// Load Saturne libraries
require_once __DIR__ . '/../../../../../../saturne/core/modules/saturne/modules_saturne.php';

/**
* Class of file that contains the numbering module rules mundilfari
*/
class mod_groupmentdocument_mundilfari extends CustomModeleNumRefSaturne
{
/**
* @var string Model name
*/
public string $name = 'Mundilfari';

public function __construct()
{
global $conf;

$refMod = $conf->global->DIGIRISKDOLIBARR_GROUPMENTDOCUMENT_MUNDILFARI_ADDON;
if (dol_strlen($refMod)) {
$refModSplitted = preg_split('/\{/', $refMod);
if (is_array($refModSplitted) && !empty($refModSplitted)) {
$suffix = preg_replace('/}/', '', $refModSplitted[1]);
$this->prefix = $refModSplitted[0];
$this->suffix = $suffix;
}
}
}
}
Loading

0 comments on commit ea9512b

Please sign in to comment.