Skip to content

Commit

Permalink
add: class riskSign
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-eoxia committed Apr 15, 2021
1 parent c6f8e3f commit 9d757d7
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions class/riskanalysis/risksign.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,16 @@ class RiskSign extends CommonObject
'ref' => array('type' => 'varchar(128)', 'label' => 'Ref', 'enabled' => '1', 'position' => 10, 'notnull' => 1, 'visible' => 4, 'noteditable' => '1', 'default' => '(PROV)', 'index' => 1, 'searchall' => 1, 'showoncombobox' => '1', 'comment' => "Reference of object"),
'ref_ext' => array('type'=>'varchar(128)', 'label'=>'RefExt', 'enabled'=>'1', 'position'=>20, 'notnull'=>0, 'visible'=>0,),
'entity' => array('type' => 'integer', 'label' => 'Entity', 'enabled' => '1', 'position' => 30, 'notnull' => 1, 'visible' => -1,),
'date_creation' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => '1', 'position' => 40, 'notnull' => 1, 'visible' => -2,),
'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => '1', 'position' => 50, 'notnull' => 0, 'visible' => -2,),
'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => '1', 'position' => 60, 'notnull' => -1, 'visible' => -2,),
'date_creation' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => '1', 'position' => 40, 'notnull' => 1, 'visible' => 0,),
'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => '1', 'position' => 50, 'notnull' => 0, 'visible' => 0,),
'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => '1', 'position' => 60, 'notnull' => -1, 'visible' => 0,),
'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>0,),
'category' => array('type' => 'integer', 'label' => 'Category', 'enabled' => '1', 'position' => 80, 'notnull' => 0, 'visible' => -1,),
'photo' => array('type' => 'varchar(255)', 'label' => 'Photo', 'enabled' => '1', 'position' => 90, 'notnull' => 0, 'visible' => -1,),
'description' => array('type' => 'text', 'label' => 'Description', 'enabled' => '1', 'position' => 100, 'notnull' => 0, 'visible' => 3,),
'fk_user_creat' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserAuthor', 'enabled' => '1', 'position' => 110, 'notnull' => 1, 'visible' => -2, 'foreignkey' => 'user.rowid',),
'fk_user_modif' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserModif', 'enabled' => '1', 'position' => 120, 'notnull' => -1, 'visible' => -2,),
'fk_element' => array('type' => 'integer', 'label' => 'FK Element', 'enabled' => '1', 'position' => 130, 'notnull' => 0, 'visible' => -1,),

'category' => array('type' => 'integer', 'label' => 'RiskSignCategory', 'enabled' => '1', 'position' => 80, 'notnull' => 0, 'visible' => 1,),
'photo' => array('type' => 'varchar(255)', 'label' => 'Photo', 'enabled' => '1', 'position' => 90, 'notnull' => 0, 'visible' => 1,),
'description' => array('type' => 'text', 'label' => 'Description', 'enabled' => '1', 'position' => 100, 'notnull' => 0, 'visible' => 1,),
'fk_user_creat' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserAuthor', 'enabled' => '1', 'position' => 110, 'notnull' => 1, 'visible' => 0, 'foreignkey' => 'user.rowid',),
'fk_user_modif' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserModif', 'enabled' => '1', 'position' => 120, 'notnull' => -1, 'visible' => 0,),
'fk_element' => array('type' => 'integer', 'label' => 'FK Element', 'enabled' => '1', 'position' => 130, 'notnull' => 1, 'visible' => 0,),
);

public $rowid;
Expand Down Expand Up @@ -148,29 +147,29 @@ public function fetchFromParent($parent_id)
}

/**
* Get signalisation categories json in /digiriskdolibarr/js/json/
* Get risksign categories json in /digiriskdolibarr/js/json/
*
* @return array $risk_categories
* @return array $risksign_categories
*/
public function get_signalisation_categories()
public function get_risksign_categories()
{
$json_categories = file_get_contents(DOL_DOCUMENT_ROOT . '/custom/digiriskdolibarr/js/json/signalisationCategories.json');
$signalisation_categories = json_decode($json_categories, true);
$risksign_categories = json_decode($json_categories, true);

return $signalisation_categories;
return $risksign_categories;
}

/**
* Get signalisation category picto name
* Get risksign category picto name
*
* @return string $signalisation['thumbnail_name'] path to signalisation picto, -1 if don't exist
* @return string $risksign['thumbnail_name'] path to risksign picto, -1 if don't exist
*/
public function get_signalisation_category($signalisation, $param = 'name_thumbnail')
public function get_risksign_category($risksign, $param = 'name_thumbnail')
{
$signalisation_categories = $this->get_signalisation_categories();
$risksign_categories = $this->get_risksign_categories();

foreach ($signalisation_categories as $category) {
if ($category['position'] == $signalisation->category) {
foreach ($risksign_categories as $category) {
if ($category['position'] == $risksign->category) {
return $category[$param];
}
}
Expand Down

0 comments on commit 9d757d7

Please sign in to comment.