mirror of
https://github.com/pluginsGLPI/example.git
synced 2025-05-04 18:08:42 +02:00
add massiveacitn stats
see #3272 git-svn-id: https://forge.glpi-project.org/svn/example/trunk@187 349b9182-4a13-0410-896f-e5e9767dd1b3
This commit is contained in:
parent
776bab4428
commit
96cccde844
17
hook.php
17
hook.php
@ -310,8 +310,13 @@ function plugin_example_MassiveActionsDisplay($options=array()) {
|
|||||||
|
|
||||||
|
|
||||||
// How to process specific actions ?
|
// How to process specific actions ?
|
||||||
|
// May return array of stats containing number of process: ok / ko / noright count to display stats
|
||||||
function plugin_example_MassiveActionsProcess($data) {
|
function plugin_example_MassiveActionsProcess($data) {
|
||||||
|
|
||||||
|
$ok = 0;
|
||||||
|
$ko = 0;
|
||||||
|
$noright = 0;
|
||||||
|
|
||||||
switch ($data['action']) {
|
switch ($data['action']) {
|
||||||
case 'plugin_example_DoIt' :
|
case 'plugin_example_DoIt' :
|
||||||
if ($data['itemtype'] == 'Computer') {
|
if ($data['itemtype'] == 'Computer') {
|
||||||
@ -322,6 +327,10 @@ function plugin_example_MassiveActionsProcess($data) {
|
|||||||
if ($val == 1) {
|
if ($val == 1) {
|
||||||
if ($comp->getFromDB($key)) {
|
if ($comp->getFromDB($key)) {
|
||||||
Session::addMessageAfterRedirect("- ".$comp->getField("name"));
|
Session::addMessageAfterRedirect("- ".$comp->getField("name"));
|
||||||
|
$ok++;
|
||||||
|
} else {
|
||||||
|
// Example of ko count
|
||||||
|
$ko++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -337,12 +346,20 @@ function plugin_example_MassiveActionsProcess($data) {
|
|||||||
if ($val == 1) {
|
if ($val == 1) {
|
||||||
if ($ex->getFromDB($key)) {
|
if ($ex->getFromDB($key)) {
|
||||||
Session::addMessageAfterRedirect("- ".$ex->getField("name"));
|
Session::addMessageAfterRedirect("- ".$ex->getField("name"));
|
||||||
|
$ok++;
|
||||||
|
} else {
|
||||||
|
// Example for noright / Maybe do it with can function is better
|
||||||
|
$noright++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
return array('ok' => $ok,
|
||||||
|
'ko' => $ko,
|
||||||
|
'noright' => $noright);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user