Skip to content

Commit

Permalink
[Mod] add: picto default GP0
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-eoxia committed Dec 8, 2021
1 parent 2c5c6df commit 7b7f987
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion core/modules/modDigiriskDolibarr.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ public function __construct($db)
101 => array('DIGIRISKDOLIBARR_GROUPMENT_ADDON','chaine', 'mod_groupment_standard' ,'', $conf->entity),
102 => array('DIGIRISKDOLIBARR_DIGIRISKELEMENT_TRASH','integer', 0 ,'', $conf->entity),
103 => array('DIGIRISKDOLIBARR_SHOW_HIDDEN_DIGIRISKELEMENT','integer', 0 ,'', $conf->entity),
104 => array('DIGIRISKDOLIBARR_DIGIRISKELEMENT_TRASH_UPDATED','integer', 0 ,'', $conf->entity),

// CONST WORKUNIT
110 => array('MAIN_AGENDA_ACTIONAUTO_WORKUNIT_CREATE','chaine',1,'', $conf->entity),
Expand Down Expand Up @@ -938,7 +939,6 @@ public function init($options = '')
if ( $conf->global->DIGIRISKDOLIBARR_DIGIRISKELEMENT_TRASH == 0 ) {
require_once __DIR__ . '/../../class/digiriskelement/groupment.class.php';


$trashRef = 'GP0';
$digiriskelement = new Groupment($this->db);
$digiriskelement->ref = $trashRef;
Expand All @@ -948,9 +948,46 @@ public function init($options = '')
$digiriskelement->description = $langs->trans('TrashGroupment');
$digiriskelement->status = 0;

$dirforimage = DOL_DOCUMENT_ROOT . '/custom/digiriskdolibarr/img/defaultImgGP0/';
$original_file = 'trash-alt-solid.png';
$src_file = $conf->digiriskdolibarr->multidir_output[$conf->entity] . '/groupment/GP0/';

if (!is_dir($dirforimage)) {
dol_mkdir($dirforimage);
}

dol_copy($dirforimage.$original_file, $src_file.$original_file, 0, 0);

$digiriskelement->photo = $original_file;

$trash_id = $digiriskelement->create($user);

dolibarr_set_const($this->db, 'DIGIRISKDOLIBARR_DIGIRISKELEMENT_TRASH', $trash_id, 'integer', 0, '', $conf->entity);
dolibarr_set_const($this->db, 'DIGIRISKDOLIBARR_DIGIRISKELEMENT_TRASH_UPDATED', 1, 'integer', 0, '', $conf->entity);
}

if ( $conf->global->DIGIRISKDOLIBARR_DIGIRISKELEMENT_TRASH_UPDATED == 0 ) {
require_once __DIR__ . '/../../class/digiriskelement/groupment.class.php';

$digiriskelement = new Groupment($this->db);
$digiriskelement->fetch($conf->global->DIGIRISKDOLIBARR_DIGIRISKELEMENT_TRASH);

$dirforimage = DOL_DOCUMENT_ROOT . '/custom/digiriskdolibarr/img/defaultImgGP0/';
$original_file = 'trash-alt-solid.png';
$src_file = $conf->digiriskdolibarr->multidir_output[$conf->entity] . '/groupment/GP0/';

if (!is_dir($dirforimage)) {
dol_mkdir($dirforimage);
}

dol_copy($dirforimage.$original_file, $src_file.$original_file, 0, 0);

$digiriskelement->photo = $original_file;
$result = $digiriskelement->update($user);

if ($result > 0) {
dolibarr_set_const($this->db, 'DIGIRISKDOLIBARR_DIGIRISKELEMENT_TRASH_UPDATED', 1, 'integer', 0, '', $conf->entity);
}
}

if ( $conf->global->DIGIRISKDOLIBARR_ACTIVE_STANDARD == 0 ) {
Expand Down
Binary file added img/defaultImgGP0/trash-alt-solid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7b7f987

Please sign in to comment.