Skip to content

Commit

Permalink
Merge pull request #32 from delcroip/develop
Browse files Browse the repository at this point in the history
1.0.2
  • Loading branch information
delcroip authored Sep 12, 2021
2 parents 88c06a2 + 4ad0cea commit 1463fc5
Show file tree
Hide file tree
Showing 39 changed files with 1,341 additions and 1,202 deletions.
22 changes: 22 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [{
"name": "Listen for XDebug on Docker App",
"type": "php",
"request": "launch",
"port": 9000,
"pathMappings": {
"/var/www/html": "${workspaceFolder}"
},
"hostname": "localhost",
"xdebugSettings": {
"max_data": 65535,
"show_hidden": 1,
"max_children": 100,
"max_depth": 5
}
},]
}
25 changes: 21 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,32 @@ This module enable you to create and manage your Medical device

download the patch: https://patch-diff.githubusercontent.com/raw/glpi-project/glpi/pull/8280.patch

before 9.5.6 patches

administrative report: https://patch-diff.githubusercontent.com/raw/glpi-project/glpi/pull/9375.patch
other administrative report: https://patch-diff.githubusercontent.com/raw/glpi-project/glpi/pull/9377.patch
contract report: https://patch-diff.githubusercontent.com/raw/glpi-project/glpi/pull/9402.patch
default report: https://patch-diff.githubusercontent.com/raw/glpi-project/glpi/pull/9403.patch



then copy it on glpi/ folder

then apply it:

```
patch -p1 < 8280.patch
patch -p1 < 9375.patch
patch -p1 < 9377.patch
patch -p1 < 9402.patch
patch -p1 < 9403.patch
```

2. Configure project-GLPI:

*. Location, __Setup > Dropdowns > Common > Locaiton__


*. Users, __Administration > Users__

*. Groups __Administration > Groups__
Expand All @@ -40,9 +54,7 @@ This module enable you to create and manage your Medical device

*. __Health technologies management > Medical Devices Utilisations__ with the utilisation status you want to have (in use, ....)

*. __Health technologies management > Medical Accessories models__ Not used yet

*. __Health technologies management > Medical Accessories types__ Not used yet
*. __Health technologies management > Medical Accessories types__

5. Configure the Dropdowns in __Administration > Profiles > Select the profile__

Expand All @@ -58,7 +70,7 @@ This module enable you to create and manage your Medical device

8. Start adding medical consomable type and consomables (if any)

9. to use the custom report, the report module must be installed and the content of the "openmedis/reports" repository must be copied in the report module
9. to use the custom report, the report module must be installed and access must be givent to the openMedis specific reports (group options available if the report module have the PluginOpenmedisToggleCriteria class)

## Standard glpi information

Expand All @@ -83,6 +95,11 @@ This module enable you to create and manage your Medical device

https://app.lokalise.com/public/6803907760dcb8c3a08649.77618538/

Once the po files are updated, on Linux system you can execute in the plugin repository
```
../../vendor/bin/robo compile_locales
```



## development
Expand Down
179 changes: 179 additions & 0 deletions RoboFile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
<?php

use Symfony\Component\Finder\Finder;

/**
* This is project's console commands configuration for Robo task runner.
*
* @see http://robo.li/
*/
class RoboFile extends \Robo\Tasks {

protected $name = "openmedis";
protected $issues = "https://github.com/delcroip/glpi_plugin_openmedis";
protected $locale_keywords = "t_openmedis";

protected function getLocaleFiles() {
$finder = new Finder();
$finder
->files()
->name('*.po')
->in('locales');

$files = [];
foreach ($finder as $file) {
$files[] = str_replace('\\', '/', $file->getRelativePathname());
}

return $files;
}

public function compile_locales() {
$files = $this->getLocaleFiles();

foreach ($files as $file) {
$lang = basename($file, ".po");

$this->taskExec('msgfmt')->args([
"locales/$lang.po",
"-o",
"locales/$lang.mo",
])->run();
}
}

public function update_locales() {
$finder = new Finder();
$finder
->files()
->name('*.php')
->in(__DIR__)
->exclude([
'vendor'
])
->sortByName();

if (!$finder->hasResults()) {
return false;
}

$args = [];

foreach ($finder as $file) {
$args[] = str_replace('\\', '/', $file->getRelativePathname());
}

$args[] = '-D';
$args[] = '.';
$args[] = '-o';
$args[] = "locales/{$this->name}.pot";
$args[] = '-L';
$args[] = 'PHP';
$args[] = '--add-comments=TRANS';
$args[] = '--from-code=UTF-8';
$args[] = '--force-po';
$args[] = "--keyword={$this->locale_keywords}";
$args[] = "--package-name={$this->name}";

if ($this->issues) {
$args[] = "--msgid-bugs-address={$this->issues}";
}

try {
$content = file_get_contents('setup.php');
$name = 'PLUGIN_' . strtoupper($this->name) . '_VERSION';
preg_match("/'$name',\s*'([\w\.]+)'/", $content, $matches);
$args[] = '--package-version=' . $matches[1];
} catch (\Exception $ex) {
echo $ex->getMessage();
}

putenv("LANG=C");

$this->taskExec('xgettext')->args($args)->run();

$this->taskReplaceInFile("locales/{$this->name}.pot")
->from('CHARSET')
->to('UTF-8')
->run();

$this->taskExec('msginit')->args([
'--no-translator',
'-i',
"locales/{$this->name}.pot",
'-l',
'en_GB.UTF8',
'-o',
'locales/en_GB.po',
])->run();

$files = $this->getLocaleFiles();

foreach ($files as $file) {
$lang = basename($file, ".po");

if ($lang === "en_GB") {
continue;
}

$this->taskExec('msgmerge')->args([
"--update",
"locales/$lang.po",
"locales/{$this->name}.pot",
"--lang=$lang",
"--backup=off",
])->run();
}

$this->compile_locales();
}

public function build() {
$this->_remove(["$this->name.zip", "$this->name.tgz"]);

$this->compile_locales();

$tmpPath = $this->_tmpDir();

$exclude = glob(__DIR__ . '/.*');
$exclude[] = 'plugin.xml';
$exclude[] = 'screenshots';
$exclude[] = 'tools';
$exclude[] = 'vendor';
$exclude[] = "$this->name.zip";
$exclude[] = "$this->name.tgz";

$this->taskCopyDir([__DIR__ => $tmpPath])
->exclude($exclude)
->run();

$composer_file = "$tmpPath/composer.json";
if (file_exists($composer_file)) {
$hasDep = false;
try {
$data = json_decode(file_get_contents($composer_file), true);
$hasDep = isset($data['require']) && count($data['require']) > 0;
} catch (\Exception $ex) {
$hasDep = true;
}

if ($hasDep) {
$this->taskComposerInstall()
->workingDir($tmpPath)
->noDev()
->run();
}
}

$this->_remove("$tmpPath/composer.lock");

// Pack
$this->taskPack("$this->name.zip")
->addDir($this->name, $tmpPath)
->run();

$this->taskPack("$this->name.tgz")
->addDir($this->name, $tmpPath)
->run();
}
}
13 changes: 13 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# openmedis plugin change log

## 1.0.2:
- MD category used for accessory too
- Report MD per utilization

## < 1.0.1
- list of Medical Device
- category of MD (similar to Type of other GLPI asset)
- model of MD
- MD accessory
- model of MD
- Medical consulmables
74 changes: 74 additions & 0 deletions dev_lesson_learned.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# GPLI plugin Development lesson learned

Glpi rely a lot on the database schema a naming, therefore tables or class name that are compliant will generate bugs or will limits the acces to glpi functions

Table should have this form: glpi_plugin_[pluginname (all lower and without _)]_[elementname (all lower)]
The class should have this form Plugin[Pluginname(only first letter in CAP)][ElementName (singular form, start with CAP, may have CAP in it)]

## Asset

### Schema fields
when creating an asset there is fields that must be created
ticket_tco
is_deleted
name
id
...

if you want to have devices per entity
is_recursive
entity_id


### other schema

<AssetClass>Type is a std class expected by some reports, alias works when the class have a differnet name


## component

add the "component/ itemDevice" types you want while registering the function

eg. pluginopenmedisitemdevicemedicalaccessory_types

and "$this->addStandardTab('Item_Devices', $ong, $options);" in defineTabs function

## consumable

you may use the std consomable or create your own class then, in both cases you will have to add the left menu

$this->addStandardTab('PluginOpenmedisMedicalConsumable', $ong, $options);



## reservation

use "reservation_types" to activate the reservation

and "$this->addStandardTab('Reservation', $ong, $options);" in defineTabs function

Do NOT add the "planning_types", this type is reserved to planning class

## class function

getIcon(): Define the icon used in UI (awsome font)
getTypeName: return the string to be displayed for the asset type
getTypes($all = false): Get the allowed component type (to be confirmed)
getType(): return the type of the asset
registerType($type): For other plugins, add a type to the linkable types
getLinkedItems: get linked compenent, all components are in "glpi_computers_items" but the itemtype specify to which asset () use get Type
rawSearchOptions(): used for the list search in the asset pages
getSpecificMassiveActions($checkitem = null): specifiy massive actions
showForm($ID, $options = []): template for the UI
prepareInputForAdd() unction called before the creation of an item, can be usefule when cloning
post_addItem() function called after the creation of an item, can be usefule when cloning
defineTabs($options = []): define the tab to be showed (to be used coherently with _types registered)
redirectToList(): link for the asset list page

## financial information

in order to activate "infocom_types" on asset, the fields "ticket_tco" must be part of the database table

then just add "infocom_types" when regestering your class in setup.php

and "$this->addStandardTab('Infocom', $ong, $options);" in defineTabs function
35 changes: 0 additions & 35 deletions front/medicalaccessorycategory.form.php

This file was deleted.

Loading

0 comments on commit 1463fc5

Please sign in to comment.