Skip to content

Commit

Permalink
Merge pull request Evarisk#4037 from evarisk-francois/add_right_defen…
Browse files Browse the repository at this point in the history
…ders_info

Evarisk#4028 [Core] add: update right defenders information
  • Loading branch information
nicolas-eoxia authored Jul 13, 2024
2 parents 451d095 + 5bad4f8 commit 6ec532f
Showing 1 changed file with 47 additions and 43 deletions.
90 changes: 47 additions & 43 deletions core/modules/modDigiriskDolibarr.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2158,49 +2158,53 @@ public function init($options = '')
dolibarr_set_const($this->db, 'DIGIRISKDOLIBARR_CONTACTS_SET', 1, 'integer', 0, '', $conf->entity);
}

if ( $conf->global->DIGIRISKDOLIBARR_THIRDPARTY_UPDATED == 0 ) {
require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
require_once __DIR__ . '/../../class/digiriskresources.class.php';

$societe = new Societe($this->db);
$resources = new DigiriskResources($this->db);
$labour_inspectorID = $resources->fetchDigiriskResource('LabourInspectorSociety');
$societe->fetch($labour_inspectorID);
$societe->name = $langs->trans('LabourInspectorName') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM;
$societe->update(0, $user);

$policeID = $resources->fetchDigiriskResource('Police');
$societe->fetch($policeID);
$societe->name = $langs->trans('Police') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM;
$societe->update(0, $user);

$samuID = $resources->fetchDigiriskResource('SAMU');
$societe->fetch($samuID);
$societe->name = $langs->trans('SAMU') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM;
$societe->update(0, $user);

$pompiersID = $resources->fetchDigiriskResource('Pompiers');
$societe->fetch($pompiersID);
$societe->name = $langs->trans('Pompiers') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM;
$societe->update(0, $user);

$emergencyID = $resources->fetchDigiriskResource('AllEmergencies');
$societe->fetch($emergencyID);
$societe->name = $langs->trans('AllEmergencies') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM;
$societe->update(0, $user);

$rights_defenderID = $resources->fetchDigiriskResource('RightsDefender');
$societe->fetch($rights_defenderID);
$societe->name = $langs->transnoentities('RightsDefender') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM;
$societe->update(0, $user);

$poison_control_centerID = $resources->fetchDigiriskResource('PoisonControlCenter');
$societe->fetch($poison_control_centerID);
$societe->name = $langs->trans('PoisonControlCenter') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM;
$societe->update(0, $user);

dolibarr_set_const($this->db, 'DIGIRISKDOLIBARR_THIRDPARTY_UPDATED', 1, 'integer', 0, '', $conf->entity);
}
if (getDolGlobalInt('DIGIRISKDOLIBARR_THIRDPARTY_UPDATED') == 0) {
$labourInspectorID = $resources->fetchDigiriskResource('LabourInspectorSociety');
$societe->fetch($labourInspectorID);
$societe->name = $langs->trans('LabourInspectorName') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM;
$societe->update(0, $user);

$policeID = $resources->fetchDigiriskResource('Police');
$societe->fetch($policeID);
$societe->name = $langs->trans('Police') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM;
$societe->update(0, $user);

$samuID = $resources->fetchDigiriskResource('SAMU');
$societe->fetch($samuID);
$societe->name = $langs->trans('SAMU') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM;
$societe->update(0, $user);

$pompiersID = $resources->fetchDigiriskResource('Pompiers');
$societe->fetch($pompiersID);
$societe->name = $langs->trans('Pompiers') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM;
$societe->update(0, $user);

$emergencyID = $resources->fetchDigiriskResource('AllEmergencies');
$societe->fetch($emergencyID);
$societe->name = $langs->trans('AllEmergencies') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM;
$societe->update(0, $user);

$rightsDefenderID = $resources->fetchDigiriskResource('RightsDefender');
$societe->fetch($rightsDefenderID);
$societe->name = $langs->transnoentities('RightsDefender') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM;
$societe->update(0, $user);

$poisonControlCenterID = $resources->fetchDigiriskResource('PoisonControlCenter');
$societe->fetch($poisonControlCenterID);
$societe->name = $langs->trans('PoisonControlCenter') . ' - ' . $conf->global->MAIN_INFO_SOCIETE_NOM;
$societe->update(0, $user);

dolibarr_set_const($this->db, 'DIGIRISKDOLIBARR_THIRDPARTY_UPDATED', 1, 'integer', 0, '', $conf->entity);
}
if (getDolGlobalInt('DIGIRISKDOLIBARR_THIRDPARTY_UPDATED') == 1) {
$rightsDefenderID = $resources->fetchDigiriskResource('RightsDefender');
$societe->fetch($rightsDefenderID);
$societe->phone = '09 69 39 00 00';
$societe->url = 'https://www.defenseurdesdroits.fr/';
$societe->update(0, $user);

dolibarr_set_const($this->db, 'DIGIRISKDOLIBARR_THIRDPARTY_UPDATED', 2, 'integer', 0, '', $conf->entity);
}

// Create extrafields during init
include_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
Expand Down

0 comments on commit 6ec532f

Please sign in to comment.