Skip to content

Commit

Permalink
Merge pull request #39 from delcroip/develop
Browse files Browse the repository at this point in the history
version 1.1.0
  • Loading branch information
delcroip authored Feb 13, 2022
2 parents 1463fc5 + 533eb8e commit effe4df
Show file tree
Hide file tree
Showing 65 changed files with 8,314 additions and 7,408 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,21 @@ This module enable you to create and manage your Medical device

before GLPI 10, a patch need to be applied to make the medical accessories working (without this patch GLPI plugins cannot add component type)

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

ajax to filter medical device categories based on parent: https://patch-diff.githubusercontent.com/raw/glpi-project/glpi/pull/9429.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





Expand All @@ -27,6 +34,8 @@ This module enable you to create and manage your Medical device

```
patch -p1 < 8280.patch
patch -p1 < 9429.patch

patch -p1 < 9375.patch
patch -p1 < 9377.patch
patch -p1 < 9402.patch
Expand Down
31 changes: 31 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: "3.2"

services:
#Mysql Container
mysql:
image: mysql:5.7.23
container_name: mysql
hostname: mysql
volumes:
- gpli-mysql:/var/lib/mysql
env_file:
- ./mysql.env
restart: always

#GLPI Container
glpi:
image: diouxx/glpi
container_name : glpi
hostname: glpi
ports:
- "80:80"
volumes:
- G:/dev/docker-glpi/glpi:/var/www/html/glpi
- G:/dev/glpi_open_medis:/var/www/html/glpi/plugins/openmedis
environment:
- TIMEZONE=Europe/Brussels
- VERSION_GLPI=9.5.6
restart: always

volumes:
gpli-mysql:
8 changes: 4 additions & 4 deletions front/medicalconsumable.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
}
Event::log($_POST["plugin_openmedis_medicalconsumableitems_id"], "plugin_openmedis_medicalconsumableitems", 4, "inventory",
//TRANS: %s is the user login
sprintf(__('%s adds medical consumables'), $_SESSION["glpiname"]));
sprintf(__('%s adds medical consumables', 'openmedis'), $_SESSION["glpiname"]));
Html::back();

} else if (isset($_POST["purge"])) {
Expand All @@ -56,7 +56,7 @@
if ($cart->delete($_POST, 1)) {
Event::log($_POST["plugin_openmedis_medicalconsumableitems_id"], "plugin_openmedis_medicalconsumableitems", 4, "inventory",
//TRANS: %s is the user login
sprintf(__('%s purges a medical consumable'), $_SESSION["glpiname"]));
sprintf(__('%s purges a medical consumable', 'openmedis'), $_SESSION["glpiname"]));
}
Html::back();

Expand All @@ -67,7 +67,7 @@
if ($cart->install($_POST["plugin_openmedis_medicaldevices_id"], $_POST["plugin_openmedis_medicalconsumableitems_id"])) {
Event::log($_POST["plugin_openmedis_medicaldevices_id"], "plugin_openmedis_medicaldevices", 5, "inventory",
//TRANS: %s is the user login
sprintf(__('%s installs a medical consumable'), $_SESSION["glpiname"]));
sprintf(__('%s installs a medical consumable', 'openmedis'), $_SESSION["glpiname"]));
}
}
}
Expand All @@ -79,7 +79,7 @@
if ($cart->update($_POST)) {
Event::log($_POST["plugin_openmedis_medicaldevices_id"], "plugin_openmedis_medicaldevices", 4, "inventory",
//TRANS: %s is the user login
sprintf(__('%s updates a medical consumable'), $_SESSION["glpiname"]));
sprintf(__('%s updates a medical consumable', 'openmedis'), $_SESSION["glpiname"]));
}
Html::back();

Expand Down
12 changes: 4 additions & 8 deletions inc/devicemedicalaccessory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,15 @@ function getAdditionalFields() {
],
[
'name' => 'plugin_openmedis_medicaldevicecategories_id',
'label' => PluginOpenmedisMedicalDeviceCategory::getFieldLabel(0),
'label' => PluginOpenmedisMedicalDeviceCategory::getFieldLabel(1),
'type' => 'dropdownValue'
],
[
'name' => 'part_number',
'label' => __('Part Number'),
'type' => 'text'
],
[
'name' => 'picture',
'label' => __('Picture'),
'type' => 'picture'
]

]
);
}
Expand All @@ -87,7 +83,7 @@ function rawSearchOptions() {
'id' => '12',
'table' => 'glpi_plugin_openmedis_medicalaccessorycategories',
'field' => 'name',
'name' => PluginOpenmedisMedicalDeviceCategory::getFieldLabel(0),
'name' => PluginOpenmedisMedicalDeviceCategory::getFieldLabel(1),
'datatype' => 'dropdown'
];

Expand All @@ -114,7 +110,7 @@ static function getHTMLTableHeader($itemtype, HTMLTableBase $base,

Manufacturer::getHTMLTableHeader(__CLASS__, $base, $super, $father, $options);
$base->addHeader('medicalaccessory_type', __('Type'), $super, $father);
$base->addHeader('medicaldevice_category', PluginOpenmedisMedicalDeviceCategory::getFieldLabel(0), $super, $father);
$base->addHeader('medicaldevice_category', PluginOpenmedisMedicalDeviceCategory::getFieldLabel(1), $super, $father);
$base->addHeader('part_number', sprintf('%1$s', __('Part Number')), $super, $father);
}

Expand Down
13 changes: 7 additions & 6 deletions inc/medicalconsumable.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,15 @@ static function getNameField() {

function prepareInputForAdd($input) {

$item = static::getItemFromArray(static::$itemtype, static::$items_id, $input);
if ($item === false) {
return false;

$item = new PluginOpenmedisMedicalConsumableItem();
if ($item->getFromDB($input["plugin_openmedis_medicalconsumableitems_id"])) {
return ["plugin_openmedis_medicalconsumableitems_id" => $item->fields["id"],
"entities_id" => $item->getEntityID(),
"date_in" => date("Y-m-d")];
}
return [];

return ["plugin_openmedis_medicalconsumableitems_id" => $item->fields["id"],
"entities_id" => $item->getEntityID(),
"date_in" => date("Y-m-d")];
}


Expand Down
129 changes: 106 additions & 23 deletions inc/medicaldevice.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
**/
class PluginOpenmedisMedicalDevice extends CommonDBTM {
use Glpi\Features\DCBreadcrumb;

// From CommonDBTM
public $dohistory = true;
// used to filter the categories
Expand Down Expand Up @@ -199,8 +199,8 @@ function showForm($ID, $options = []) {
//do not display called elements per default; they'll be displayed or returned here
$params['display'] = false;
echo "<tr class='tab_bg_1'>";
echo "<td>".__("Parent")."</br>\n";
echo PluginOpenmedisMedicalDeviceCategory::getFieldLabel(0)."</td>\n";
echo "<td>".PluginOpenmedisMedicalDeviceCategory::getFieldLabel(0, 0)."</br>\n";
echo PluginOpenmedisMedicalDeviceCategory::getFieldLabel(0, 1)."</td>\n";
echo "<td>";
//$this->category = is_null($_POST['category'] ? $_POST['category'] : '');
$rand = mt_rand();
Expand All @@ -216,6 +216,8 @@ function showForm($ID, $options = []) {
'permit_select_parent' => true,
'displaywith' => ['code','label'],
'parentfieldid' => $parent_field_id ]);


echo "</td>";


Expand All @@ -234,7 +236,7 @@ function showForm($ID, $options = []) {
$tplmark = $this->getAutofillMark('name', $options);

//TRANS: %1$s is a string, %2$s a second one without spaces between them : to change for RTL
echo "<td>".sprintf(__('%1$s%2$s'), __('Name'), $tplmark);
echo "<td>".sprintf(__('%1$s%2$s'), __('Name', 'openmedis'), $tplmark);
echo "</td>";
echo "<td>";
//$this->fields['withtemplate'] = 2 ;
Expand Down Expand Up @@ -317,7 +319,7 @@ function showForm($ID, $options = []) {
'entity' => $this->fields["entities_id"],
'right' => 'all']);
echo "</td>\n";
echo "<td>".PluginOpenmedisUtilization::getFieldLabel(0)."</td>\n";
echo "<td>".PluginOpenmedisUtilization::getFieldLabel(1)."</td>\n";
echo "<td>";

PluginOpenmedisUtilization::dropdown(['value' => $this->fields["plugin_openmedis_utilizations_id"]]);
Expand Down Expand Up @@ -346,6 +348,18 @@ function showForm($ID, $options = []) {
echo "</td>\n";
echo "</tr>\n";

echo "<tr class='tab_bg_1'>";
$tplmark = $this->getAutofillMark('barcode', $options);
echo "<td>".sprintf(__('%1$s%2$s'), __('Barcode','openmedis'), $tplmark).
"</td>\n";
echo "<td>";
$objectName = autoName($this->fields["barcode"], "barcode",
(isset($options['withtemplate']) && ($options['withtemplate'] == 2)),
$this->getType(), $this->fields["entities_id"]);
Html::autocompletionTextField($this, "barcode", ['value' => $objectName]);
echo "</td></tr>\n";


// Display auto inventory informations
if (!empty($ID)
&& $this->fields["is_dynamic"]) {
Expand All @@ -354,6 +368,37 @@ function showForm($ID, $options = []) {
echo "</td></tr>";
}

/* model images*/

if($this->fields["plugin_openmedis_medicaldevicemodels_id"] > 0){
//error_reporting(E_ALL);
$models = new PluginOpenmedisMedicalDeviceModel();
$models->getFromDB($this->fields["plugin_openmedis_medicaldevicemodels_id"]);
echo "<tr class='tab_bg_1'><td colspan='4'>";
if (isset($models->fields['picture_front'])){
echo Html::image(Toolbox::getPictureUrl($models->fields['picture_front']), [
'alt' =>"Model front picture",
'style' => 'width: 45%;',
]);
}

//echo $models->getSpecificValueToDisplay('picture_front');
//echo "</td><td>";

if (isset($models->fields['picture_rear'])){
echo Html::image(Toolbox::getPictureUrl($models->fields['picture_rear']), [
'alt' =>"Model rear picture",
'style' => 'width: 45%;',
]);
}

//echo $models->getSpecificValueToDisplay('picture_rear');
echo "</td></tr>";
}




$this->showFormButtons($options);

return true;
Expand Down Expand Up @@ -407,12 +452,15 @@ function getSpecificMassiveActions($checkitem = null) {
}


function rawSearchOptions() {
function rawSearchOptionsToAdd(){
$tab = [];

$tab[] = [
'id' => 'common',
'name' => __('Characteristics')
'id' => '4',
'table' => 'glpi_plugin_openmedis_medicaldevicecategories',
'field' => 'name',
'name' => PluginOpenmedisMedicalDeviceCategory::getFieldLabel(1),
'datatype' => 'dropdown'
];

$tab[] = [
Expand All @@ -426,22 +474,11 @@ function rawSearchOptions() {
];

$tab[] = [
'id' => '2',
'id' => '5',
'table' => $this->getTable(),
'field' => 'id',
'name' => __('ID'),
'massiveaction' => false,
'datatype' => 'number'
];

$tab = array_merge($tab, Location::rawSearchOptionsToAdd());

$tab[] = [
'id' => '4',
'table' => 'glpi_plugin_openmedis_medicaldevicecategories',
'field' => 'name',
'name' => PluginOpenmedisMedicalDeviceCategory::getFieldLabel(0),
'datatype' => 'dropdown'
'field' => 'barcode',
'name' => __('Barcode','openmedis'),
'datatype' => 'string',
];

$tab[] = [
Expand All @@ -452,6 +489,35 @@ function rawSearchOptions() {
'datatype' => 'dropdown'
];

return $tab;

}

function rawSearchOptions() {
$tab = [];



$tab[] = [
'id' => 'common',
'name' => __('Characteristics')
];



$tab[] = [
'id' => '2',
'table' => $this->getTable(),
'field' => 'id',
'name' => __('ID'),
'massiveaction' => false,
'datatype' => 'number'
];
$tab = array_merge($tab, $this->rawSearchOptionsToAdd());
$tab = array_merge($tab, Location::rawSearchOptionsToAdd());



$tab[] = [
'id' => '31',
'table' => 'glpi_states',
Expand Down Expand Up @@ -660,4 +726,21 @@ static function registerType($type) {
static function getIcon() {
return "fas fa-laptop-medical";
}

function pre_updateInDB() {

if ( isset($this->fields['plugin_openmedis_medicaldevicecategories_id'])){
// set parent
$cat = new PluginOpenmedisMedicalDeviceCategory();
$cat->getFromDB($this->fields['plugin_openmedis_medicaldevicecategories_id']);
while (isset($cat->fields['plugin_openmedis_medicaldevicecategories_id'])
&& $cat->fields['level']>1) {
$cat->getFromDB($cat->fields['plugin_openmedis_medicaldevicecategories_id']);
}
$this->fields['plugin_openmedis_medicaldevicecategories_parent_id'] =
$cat->fields['id'];
}

parent::pre_updateInDB();
}
}
Loading

0 comments on commit effe4df

Please sign in to comment.