diff --git a/README.md b/README.md index d48d7c6..bf9ed34 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Services -GLPI ITIL Services project +GLPI Services project The goal of this plugin is to associate servers, devices, printers, ... to a specific service based on ITIL concepts. diff --git a/ajax/dropdownTypeServices.php b/ajax/dropdownTypeServices.php index ac0c27a..1d1ebff 100644 --- a/ajax/dropdownTypeServices.php +++ b/ajax/dropdownTypeServices.php @@ -27,13 +27,13 @@ -------------------------------------------------------------------------- */ -if (strpos($_SERVER['PHP_SELF'],"dropdownTypeServices.php")) { - include ('../../../inc/includes.php'); +if (strpos($_SERVER['PHP_SELF'], "dropdownTypeServices.php")) { + include('../../../inc/includes.php'); header("Content-Type: text/html; charset=UTF-8"); Html::header_nocache(); } -Session::checkLoginUser(); -//Session::checkCentralAccess(); +//Session::checkLoginUser(); +Session::checkCentralAccess(); // Make a select box if (isset($_POST["servicetype"])) { @@ -43,8 +43,8 @@ if (isset($_POST['used']) && is_array($_POST['used']) && (count($_POST['used']) > 0)) { $query = "SELECT `id` FROM `glpi_plugin_services_services` - WHERE `id` IN (".implode(',',$_POST['used']).") - AND `plugin_services_servicetypes_id` = '".$_POST["servicetype"]."'"; + WHERE `id` IN (" . implode(',', $_POST['used']) . ") + AND `plugin_services_servicetypes_id` = '" . $_POST["servicetype"] . "'"; foreach ($DB->request($query) AS $data) { $used[$data['id']] = $data['id']; @@ -52,12 +52,11 @@ } Dropdown::show('PluginServicesService', - array('name' => $_POST['myname'], + ['name' => $_POST['myname'], 'used' => $used, 'width' => '50%', 'entity' => $_POST['entity'], 'rand' => $_POST['rand'], - 'condition' => "glpi_plugin_services_services.plugin_services_servicetypes_id='".$_POST["servicetype"]."'")); + 'condition' => ["glpi_plugin_services_services.plugin_services_servicetypes_id"=>$_POST["servicetype"]]]); } -?> \ No newline at end of file diff --git a/front/service.form.php b/front/service.form.php index 238f930..9e4d484 100644 --- a/front/service.form.php +++ b/front/service.form.php @@ -41,6 +41,15 @@ if (isset($_POST["add"])) { $web->check(-1,CREATE,$_POST); + if (isset($_POST['plugin_services_services_id']) && $_POST['plugin_services_services_id'] != '0') { + // copy parent's value to child + $web->getFromDB($_POST['plugin_services_services_id']); + foreach ($web->fields as $key => $value) { + if ($key != 'id' && !isset($_POST[$key])) { + $_POST[$key] = $value; + } + } + } $newID= $web->add($_POST); if ($_SESSION['glpibackcreated']) { Html::redirect($web->getFormURL()."?id=".$newID); @@ -109,4 +118,4 @@ Html::footer(); } -?> \ No newline at end of file +?> diff --git a/front/service.php b/front/service.php index d4dec63..16e8ffd 100644 --- a/front/service.php +++ b/front/service.php @@ -2,40 +2,39 @@ /* * @version $Id: HEADER 15930 2011-10-30 15:47:55Z tsmr $ ------------------------------------------------------------------------- - Services plugin for GLPI - Copyright (C) 2003-2011 by the Services Development Team. + webapplications plugin for GLPI + Copyright (C) 2009-2016 by the services Development Team. - https://forge.indepnet.net/projects/services + https://github.com/InfotelGLPI/services ------------------------------------------------------------------------- LICENSE - - This file is part of Services. - Services is free software; you can redistribute it and/or modify + This file is part of services. + + services is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - Services is distributed in the hope that it will be useful, + services is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with Services. If not, see . + along with services. If not, see . -------------------------------------------------------------------------- */ -include ('../../../inc/includes.php'); +include('../../../inc/includes.php'); //check environment meta-plugin installation for change header $plugin = new Plugin(); if ($plugin->isActivated("environment")) { - Html::header(PluginServicesService::getTypeName(2) - ,'',"plugins","pluginenvironmentdisplay","services"); -}else { - Html::header(PluginServicesService::getTypeName(2), '', "plugins","pluginservicesmenu"); + Html::header(PluginServicesService::getTypeName(2), '', "assets", "pluginenvironmentdisplay", "services"); +} else { + Html::header(PluginServicesService::getTypeName(2), '', "plugins", "pluginservicesmenu"); } $web = new PluginServicesService(); @@ -45,9 +44,7 @@ Search::show("PluginServicesService"); } else { - + Html::displayRightError(); } Html::footer(); - -?> \ No newline at end of file diff --git a/front/servicedrsolutiontype.form.php b/front/servicedrsolutiontype.form.php new file mode 100644 index 0000000..fbc92a7 --- /dev/null +++ b/front/servicedrsolutiontype.form.php @@ -0,0 +1,35 @@ +. + -------------------------------------------------------------------------- + */ + +include ('../../../inc/includes.php'); + +$dropdown = new PluginServicesServiceDrSolutionType(); +include (GLPI_ROOT . "/front/dropdown.common.form.php"); + +?> \ No newline at end of file diff --git a/front/servicedrsolutiontype.php b/front/servicedrsolutiontype.php new file mode 100644 index 0000000..5273358 --- /dev/null +++ b/front/servicedrsolutiontype.php @@ -0,0 +1,35 @@ +. + -------------------------------------------------------------------------- + */ + +include ('../../../inc/includes.php'); + +$dropdown = new PluginServicesServiceDrSolutionType(); +include (GLPI_ROOT . "/front/dropdown.common.php"); + +?> \ No newline at end of file diff --git a/front/servicedrtesttype.form.php b/front/servicedrtesttype.form.php new file mode 100644 index 0000000..ec230e5 --- /dev/null +++ b/front/servicedrtesttype.form.php @@ -0,0 +1,35 @@ +. + -------------------------------------------------------------------------- + */ + +include ('../../../inc/includes.php'); + +$dropdown = new PluginServicesServiceDrTestType(); +include (GLPI_ROOT . "/front/dropdown.common.form.php"); + +?> \ No newline at end of file diff --git a/front/servicedrtesttype.php b/front/servicedrtesttype.php new file mode 100644 index 0000000..543c4bb --- /dev/null +++ b/front/servicedrtesttype.php @@ -0,0 +1,35 @@ +. + -------------------------------------------------------------------------- + */ + +include ('../../../inc/includes.php'); + +$dropdown = new PluginServicesServiceDrTestType(); +include (GLPI_ROOT . "/front/dropdown.common.php"); + +?> \ No newline at end of file diff --git a/front/serviceitowner.form.php b/front/serviceitowner.form.php new file mode 100644 index 0000000..e8bc351 --- /dev/null +++ b/front/serviceitowner.form.php @@ -0,0 +1,35 @@ +. + -------------------------------------------------------------------------- + */ + +include ('../../../inc/includes.php'); + +$dropdown = new PluginServicesServiceItowner(); +include (GLPI_ROOT . "/front/dropdown.common.form.php"); + +?> \ No newline at end of file diff --git a/front/serviceitowner.php b/front/serviceitowner.php new file mode 100644 index 0000000..2f0edcd --- /dev/null +++ b/front/serviceitowner.php @@ -0,0 +1,35 @@ +. + -------------------------------------------------------------------------- + */ + +include ('../../../inc/includes.php'); + +$dropdown = new PluginServicesServiceItowner(); +include (GLPI_ROOT . "/front/dropdown.common.php"); + +?> \ No newline at end of file diff --git a/hook.php b/hook.php index 6f83a27..9e6b303 100644 --- a/hook.php +++ b/hook.php @@ -4,24 +4,19 @@ ------------------------------------------------------------------------- Services plugin for GLPI Copyright (C) 2003-2011 by the Services Development Team. - https://forge.indepnet.net/projects/services ------------------------------------------------------------------------- - LICENSE This file is part of Services. - Services is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - Services is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License along with Services. If not, see . -------------------------------------------------------------------------- @@ -371,24 +366,20 @@ function plugin_services_MassiveActions($type) { if (in_array($type,PluginServicesService::getTypes(true))) { return array('PluginServicesService'.MassiveAction::CLASS_ACTION_SEPARATOR.'plugin_services_add_item' => - __('Associate a ITIL Service', 'ITIL Services')); + __('Associate a TC Service', 'TC Services')); } return array(); } /* function plugin_services_MassiveActionsDisplay($options=array()) { - $web = new PluginServicesService(); - if (in_array($options['itemtype'], PluginServicesService::getTypes(true))) { $web->dropdownWebApplications("plugin_services_services_id"); echo ""; } return ""; } - - function plugin_services_MassiveActionsProcess($data) { $web_item = new PluginServicesService_Item(); @@ -396,7 +387,6 @@ function plugin_services_MassiveActionsProcess($data) { $res = array('ok' => 0, 'ko' => 0, 'noright' => 0); - switch ($data['action']) { case "plugin_services_add_item": foreach ($data["item"] as $key => $val) { diff --git a/inc/menu.class.php b/inc/menu.class.php index f89c2f6..99847c1 100644 --- a/inc/menu.class.php +++ b/inc/menu.class.php @@ -1,65 +1,68 @@ . + along with services. If not, see . -------------------------------------------------------------------------- */ -// ---------------------------------------------------------------------- -// Original Author of file: -// Purpose of file: -// ---------------------------------------------------------------------- - - +/** + * Class PluginServicesMenu + */ class PluginServicesMenu extends CommonGLPI { static $rightname = 'plugin_services'; + /** + * @return translated + */ static function getMenuName() { - return _n('ITIL Service', 'ITIL Services', 2, 'services'); + return _n('TC Service', 'TC Services', 2, 'services'); } + /** + * @return array + */ static function getMenuContent() { - global $CFG_GLPI; - $menu = array(); - $menu['title'] = self::getMenuName(); - $menu['page'] = "/plugins/services/front/service.php"; - $menu['links']['search'] = PluginServicesService::getSearchURL(false); + $menu = []; + $menu['title'] = self::getMenuName(); + $menu['page'] = "/plugins/services/front/service.php"; + $menu['links']['search'] = PluginServicesService::getSearchURL(false); if (PluginServicesService::canCreate()) { - $menu['links']['add'] = PluginServicesService::getFormURL(false); + $menu['links']['add'] = PluginServicesService::getFormURL(false); } return $menu; } static function removeRightsFromSession() { - if (isset($_SESSION['glpimenu']['tools']['types']['PluginServicesMenu'])) { - unset($_SESSION['glpimenu']['tools']['types']['PluginServicesMenu']); + if (isset($_SESSION['glpimenu']['plugins']['types']['PluginServicesMenu'])) { + unset($_SESSION['glpimenu']['plugins']['types']['PluginServicesMenu']); } - if (isset($_SESSION['glpimenu']['tools']['content']['pluginservicesmenu'])) { - unset($_SESSION['glpimenu']['tools']['content']['pluginservicesmenu']); + if (isset($_SESSION['glpimenu']['plugins']['content']['pluginservicesmenu'])) { + unset($_SESSION['glpimenu']['plugins']['content']['pluginservicesmenu']); } } -} \ No newline at end of file +} diff --git a/inc/profile.class.php b/inc/profile.class.php index 619b0df..8b4dfdb 100644 --- a/inc/profile.class.php +++ b/inc/profile.class.php @@ -2,28 +2,28 @@ /* * @version $Id: HEADER 15930 2011-10-30 15:47:55Z tsmr $ ------------------------------------------------------------------------- - Services plugin for GLPI - Copyright (C) 2003-2011 by the Services Development Team. + webapplications plugin for GLPI + Copyright (C) 2009-2016 by the webapplications Development Team. - https://forge.indepnet.net/projects/services + https://github.com/InfotelGLPI/services ------------------------------------------------------------------------- LICENSE - - This file is part of Services. - Services is free software; you can redistribute it and/or modify + This file is part of services. + + services is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - Services is distributed in the hope that it will be useful, + services is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with Services. If not, see . + along with services. If not, see . -------------------------------------------------------------------------- */ @@ -31,55 +31,76 @@ die("Sorry. You can't access directly to this file"); } +/** + * Class PluginServicesProfile + */ class PluginServicesProfile extends Profile { static $rightname = "profile"; - function getTabNameForItem(CommonGLPI $item, $withtemplate=0) { + /** + * @param CommonGLPI $item + * @param int $withtemplate + * + * @return string|translated + */ + function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { - if ($item->getType()=='Profile') { - return PluginServicesService::getTypeName(2); + if ($item->getType() == 'Profile') { + return PluginServicesService::getTypeName(2); } return ''; } - static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) { - global $CFG_GLPI; + /** + * @param CommonGLPI $item + * @param int $tabnum + * @param int $withtemplate + * + * @return bool + */ + static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { - if ($item->getType()=='Profile') { - $ID = $item->getID(); + if ($item->getType() == 'Profile') { + $ID = $item->getID(); $prof = new self(); - self::addDefaultProfileInfos($ID, - array('plugin_services' => 0, - 'plugin_services_open_ticket' => 0)); + self::addDefaultProfileInfos($ID, + ['plugin_services' => 0, + 'plugin_services_open_ticket' => 0]); $prof->showForm($ID); } return true; } - + + /** + * @param $ID + */ static function createFirstAccess($ID) { //85 self::addDefaultProfileInfos($ID, - array('plugin_services' => 127, - 'plugin_services_open_ticket' => 1), true); + ['plugin_services' => 127, + 'plugin_services_open_ticket' => 1], true); } - - /** - * @param $profile - **/ + + /** + * @param $profiles_id + * @param $rights + * @param bool $drop_existing + * + * @internal param $profile + */ static function addDefaultProfileInfos($profiles_id, $rights, $drop_existing = false) { - global $DB; - + $dbu = new DbUtils(); $profileRight = new ProfileRight(); foreach ($rights as $right => $value) { - if (countElementsInTable('glpi_profilerights', - "`profiles_id`='$profiles_id' AND `name`='$right'") && $drop_existing) { - $profileRight->deleteByCriteria(array('profiles_id' => $profiles_id, 'name' => $right)); + if ($dbu->countElementsInTable('glpi_profilerights', + ["profiles_id" => $profiles_id, "name" => $right]) && $drop_existing) { + $profileRight->deleteByCriteria(['profiles_id' => $profiles_id, 'name' => $right]); } - if (!countElementsInTable('glpi_profilerights', - "`profiles_id`='$profiles_id' AND `name`='$right'")) { + if (!$dbu->countElementsInTable('glpi_profilerights', + ["profiles_id" => $profiles_id, "name" => $right])) { $myright['profiles_id'] = $profiles_id; $myright['name'] = $right; $myright['rights'] = $value; @@ -95,76 +116,87 @@ static function addDefaultProfileInfos($profiles_id, $rights, $drop_existing = f /** * Show profile form * - * @param $items_id integer id of the profile - * @param $target value url of target + * @param int $profiles_id + * @param bool $openform + * @param bool $closeform * * @return nothing - **/ - function showForm($profiles_id=0, $openform=TRUE, $closeform=TRUE) { + * @internal param int $items_id id of the profile + * @internal param value $target url of target + */ + function showForm($profiles_id = 0, $openform = true, $closeform = true) { echo "
"; - if (($canedit = Session::haveRightsOr(self::$rightname, array(CREATE, UPDATE, PURGE))) + if (($canedit = Session::haveRightsOr(self::$rightname, [CREATE, UPDATE, PURGE])) && $openform) { $profile = new Profile(); - echo "
"; + echo ""; } $profile = new Profile(); $profile->getFromDB($profiles_id); if ($profile->getField('interface') == 'central') { $rights = $this->getAllRights(); - $profile->displayRightsChoiceMatrix($rights, array('canedit' => $canedit, - 'default_class' => 'tab_bg_2', - 'title' => __('General'))); + $profile->displayRightsChoiceMatrix($rights, ['canedit' => $canedit, + 'default_class' => 'tab_bg_2', + 'title' => __('General')]); } echo ""; - echo "\n"; + echo "\n"; - $effective_rights = ProfileRight::getProfileRights($profiles_id, array('plugin_services_open_ticket')); + $effective_rights = ProfileRight::getProfileRights($profiles_id, ['plugin_services_open_ticket']); echo ""; - echo ""; + echo ""; echo "\n"; echo "
".__('Helpdesk')."
" . __('Helpdesk') . "
".__('Associable items to a ticket')."" . __('Associable items to a ticket') . ""; - Html::showCheckbox(array('name' => '_plugin_services_open_ticket', - 'checked' => $effective_rights['plugin_services_open_ticket'])); + Html::showCheckbox(['name' => '_plugin_services_open_ticket', + 'checked' => $effective_rights['plugin_services_open_ticket']]); echo "
"; - + if ($canedit && $closeform) { echo "
"; - echo Html::hidden('id', array('value' => $profiles_id)); - echo Html::submit(_sx('button', 'Save'), array('name' => 'update')); + echo Html::hidden('id', ['value' => $profiles_id]); + echo Html::submit(_sx('button', 'Save'), ['name' => 'update']); echo "
\n"; Html::closeForm(); } echo "
"; } + /** + * @param bool $all + * + * @return array + */ static function getAllRights($all = false) { - $rights = array( - array('itemtype' => 'PluginServicesService', - 'label' => _n('ITIL Service', 'ITIL Services', 2, 'services'), - 'field' => 'plugin_services' - ), - ); + $rights = [ + ['itemtype' => 'PluginServicesService', + 'label' => _n('Web application', 'Web applications', 2, 'services'), + 'field' => 'plugin_services' + ], + ]; if ($all) { - $rights[] = array('itemtype' => 'PluginServicesService', - 'label' => __('Associable items to a ticket'), - 'field' => 'plugin_services_open_ticket'); + $rights[] = ['itemtype' => 'PluginServicesService', + 'label' => __('Associable items to a ticket'), + 'field' => 'plugin_services_open_ticket']; } - + return $rights; } /** * Init profiles * - **/ - + * @param $old_right + * + * @return int + */ + static function translateARight($old_right) { switch ($old_right) { - case '': + case '': return 0; case 'r' : return READ; @@ -173,58 +205,72 @@ static function translateARight($old_right) { case '0': case '1': return $old_right; - + default : return 0; } } - + /** - * @since 0.85 - * Migration rights from old system to the new one for one profile - * @param $profiles_id the profile ID - */ + * @since 0.85 + * Migration rights from old system to the new one for one profile + * + * @param $profiles_id the profile ID + * + * @return bool + */ static function migrateOneProfile($profiles_id) { global $DB; //Cannot launch migration if there's nothing to migrate... - if (!TableExists('glpi_plugin_services_profiles')) { - return true; + if (!$DB->tableExists('glpi_plugin_services_profiles')) { + return true; } - - foreach ($DB->request('glpi_plugin_services_profiles', + + foreach ($DB->request('glpi_plugin_services_profiles', "`profiles_id`='$profiles_id'") as $profile_data) { - $matching = array('services' => 'plugin_services', - 'open_ticket' => 'plugin_services_open_ticket'); + $matching = ['services' => 'plugin_services', + 'open_ticket' => 'plugin_services_open_ticket']; $current_rights = ProfileRight::getProfileRights($profiles_id, array_values($matching)); foreach ($matching as $old => $new) { if (!isset($current_rights[$old])) { $query = "UPDATE `glpi_profilerights` - SET `rights`='".self::translateARight($profile_data[$old])."' + SET `rights`='" . self::translateARight($profile_data[$old]) . "' WHERE `name`='$new' AND `profiles_id`='$profiles_id'"; $DB->query($query); } } } } - + /** - * Initialize profiles, and migrate it necessary - */ + * Initialize profiles, and migrate it necessary + */ static function initProfile() { global $DB; $profile = new self(); - + $dbu = new DbUtils(); //Add new rights in glpi_profilerights table foreach ($profile->getAllRights(true) as $data) { - if (countElementsInTable("glpi_profilerights", - "`name` = '".$data['field']."'") == 0) { - ProfileRight::addProfileRights(array($data['field'])); + if ($dbu->countElementsInTable("glpi_profilerights", + ["name" => $data['field']]) == 0) { + ProfileRight::addProfileRights([$data['field']]); } } - + + //Migration old rights in new ones + foreach ($DB->request("SELECT `id` FROM `glpi_profiles`") as $prof) { + self::migrateOneProfile($prof['id']); + } + foreach ($DB->request("SELECT * + FROM `glpi_profilerights` + WHERE `profiles_id`='" . $_SESSION['glpiactiveprofile']['id'] . "' + AND `name` LIKE '%plugin_services%'") as $prof) { + $_SESSION['glpiactiveprofile'][$prof['name']] = $prof['rights']; + } } + static function removeRightsFromSession() { foreach (self::getAllRights(true) as $right) { if (isset($_SESSION['glpiactiveprofile'][$right['field']])) { @@ -233,5 +279,3 @@ static function removeRightsFromSession() { } } } - -?> \ No newline at end of file diff --git a/inc/service.class.php b/inc/service.class.php index ec5975b..9817173 100644 --- a/inc/service.class.php +++ b/inc/service.class.php @@ -31,30 +31,49 @@ die("Sorry. You can't access directly to this file"); } +/** + * Class PluginServicesService + */ class PluginServicesService extends CommonDBTM { - public $dohistory=true; - static $rightname = "plugin_services"; - protected $usenotepad = true; - - static $types = array('Computer', 'Monitor', 'NetworkEquipment', 'Peripheral', 'Phone', - 'Printer', 'Software', 'Entity'); + public $dohistory = true; + static $rightname = "plugin_services"; + protected $usenotepad = true; + + static $types = ['Computer', 'Monitor', 'NetworkEquipment', 'Peripheral', 'Phone', + 'Printer', 'Software', 'Entity', 'SoftwareLicense', 'PluginServicesService','Certificate']; + static $tags = '[SERVICE_URL]'; + + /** + * @param int $nb + * + * @return translated + */ + static function getTypeName($nb = 0) { - static function getTypeName($nb=0) { + return _n('TC Service', 'TC Services', $nb, 'services'); + } - return _n('ITIL Service', 'ITIL Services', $nb, 'services'); - } //clean if services are deleted + /** + * + */ function cleanDBonPurge() { $temp = new PluginServicesService_Item(); - $temp->deleteByCriteria(array('plugin_services_services_id' => $this->fields['id'])); + $temp->deleteByCriteria(['plugin_services_services_id' => $this->fields['id']]); } - function getTabNameForItem(CommonGLPI $item, $withtemplate=0) { + /** + * @param CommonGLPI $item + * @param int $withtemplate + * + * @return array|string|translated + */ + function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { - if ($item->getType()=='Supplier') { + if ($item->getType() == 'Supplier') { if ($_SESSION['glpishow_count_on_tabs']) { return self::createTabEntry(self::getTypeName(2), self::countForItem($item)); } @@ -64,22 +83,35 @@ function getTabNameForItem(CommonGLPI $item, $withtemplate=0) { } - static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) { - global $CFG_GLPI; + /** + * @param CommonGLPI $item + * @param int $tabnum + * @param int $withtemplate + * + * @return bool + */ + static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { - if ($item->getType()=='Supplier') { + if ($item->getType() == 'Supplier') { PluginServicesService_Item::showForSupplier($item); } return true; } + + /** + * @param CommonDBTM $item + * + * @return int + */ static function countForItem(CommonDBTM $item) { - - return countElementsInTable('glpi_plugin_services_services', - "`suppliers_id` = '".$item->getID()."'"); + $dbu = new DbUtils(); + return $dbu->countElementsInTable('glpi_plugin_services_services', + ["suppliers_id" => $item->getID()]); } + - function getSearchOptions() { +/* function getSearchOptions() { global $LANG; $tab = array(); @@ -152,7 +184,7 @@ function getSearchOptions() { // Dashboard URL $tab[45]['table'] = $this->getTable(); - $tab[45]['field'] = 'address'; + $tab[45]['field'] = 'Address'; $tab[45]['name'] = __('Dashboard URL'); $tab[45]['datatype'] = 'weblink'; @@ -226,20 +258,28 @@ function getSearchOptions() { $tab[100]['field'] = 'name'; $tab[100]['name'] = __('Supplier'); $tab[100]['datatype'] = 'itemlink'; + + // IT owner + $tab[101]['table'] = 'glpi_users'; + $tab[101]['field'] = 'name'; + $tab[101]['linkfield'] = 'users_id_itowner'; + $tab[101]['name'] = __('Product Owner'); + $tab[101]['datatype'] = 'dropdown'; + $tab[101]['right'] = 'interface'; // Technicial owner - $tab[105]['table'] = 'glpi_users'; - $tab[105]['field'] = 'name'; - $tab[105]['linkfield'] = 'users_id_tech'; - $tab[105]['name'] = __('Technicial owner'); - $tab[105]['datatype'] = 'dropdown'; - $tab[105]['right'] = 'interface'; + $tab[102]['table'] = 'glpi_users'; + $tab[102]['field'] = 'name'; + $tab[102]['linkfield'] = 'users_id_tech'; + $tab[102]['name'] = __('Technicial Owner'); + $tab[102]['datatype'] = 'dropdown'; + $tab[102]['right'] = 'interface'; //technical groups $tab[110]['table'] = 'glpi_groups'; $tab[110]['field'] = 'name'; $tab[110]['linkfield'] = 'groups_id_tech'; - $tab[110]['name'] = __('Technical owner group'); + $tab[110]['name'] = __('Technical Owner Group'); $tab[110]['condition'] = '`is_assign`'; $tab[110]['datatype'] = 'dropdown'; @@ -247,7 +287,7 @@ function getSearchOptions() { $tab[115]['table'] = 'glpi_users'; $tab[115]['field'] = 'name'; $tab[115]['linkfield'] = 'users_id_sectech'; - $tab[115]['name'] = __('Secondary Technicial owner'); + $tab[115]['name'] = __('Secondary Technicial Twner'); $tab[115]['datatype'] = 'dropdown'; $tab[115]['right'] = 'interface'; @@ -257,12 +297,31 @@ function getSearchOptions() { $tab[120]['name'] = PluginServicesServiceSupport::getTypeName(1); $tab[120]['datatype'] = 'dropdown'; + + // DR Test Type + $tab[121]['table'] = 'glpi_plugin_services_servicedrtesttypes'; + $tab[121]['field'] = 'name'; + $tab[121]['name'] = PluginServicesServiceDrTestType::getTypeName(1); + $tab[121]['datatype'] = 'dropdown'; + + // DR Solution Type + $tab[122]['table'] = 'glpi_plugin_services_servicedrsolutiontypes'; + $tab[122]['field'] = 'name'; + $tab[122]['name'] = PluginServicesServiceDrSolutionType::getTypeName(1); + $tab[122]['datatype'] = 'dropdown'; + // Tiers $tab[125]['table'] = 'glpi_plugin_services_servicetiers'; $tab[125]['field'] = 'name'; $tab[125]['name'] = PluginServicesServiceTier::getTypeName(1); $tab[125]['datatype'] = 'dropdown'; + // Is Corp DBA Managed + $tab[128]['table'] = $this->getTable(); + $tab[128]['field'] = 'Is_Corp_DBA_Managed'; + $tab[128]['name'] = __('Is Corp DBA Managed'); + $tab[128]['datatype'] = 'bool'; + // Is helpdesk visible $tab[129]['table'] = $this->getTable(); $tab[129]['field'] = 'is_helpdesk_visible'; @@ -294,19 +353,387 @@ function getSearchOptions() { $tab[150]['name'] = __('Child entities'); $tab[150]['datatype'] = 'bool'; return $tab; - } + } */ + + function rawSearchOptions() { + + $tab = []; + + $tab[] = [ + 'id' => 'common', + 'name' => self::getTypeName(2) + ]; + // Name + $tab[] = [ + 'id' => '1', + 'table' => $this->getTable(), + 'field' => 'name', + 'name' => __('Product Name'), + 'datatype' => 'itemlink', + 'itemlink_type' => $this->getType() + ]; + + $tab[] = [ + 'id' => '5', + 'table' => 'glpi_users', + 'field' => 'name', + 'linkfield' => 'users_id_app', + 'name' => __('Application Specialist'), + 'datatype' => 'dropdown', + 'right' => 'interface' + ]; + + $tab[] = [ + 'id' => '10', + 'table' => 'glpi_users', + 'field' => 'name', + 'linkfield' => 'users_id_secapp', + 'name' => __('Secondary Application Specialist'), + 'datatype' => 'dropdown', + 'right' => 'interface' + ]; + + /* $tab = array_merge($tab, Location::rawSearchOptionsToAdd()); */ + + $tab[] = [ + 'id' => '15', + 'table' => 'glpi_plugin_services_services_items', + 'field' => 'items_id', + 'nosearch' => true, + 'massiveaction' => false, + 'name' => _n('Associated item', 'Associated items', 2), + 'forcegroupby' => true, + 'joinparams' => ['jointype' => 'child'] + ]; + + $tab[] = [ + 'id' => '20', + 'table' => 'glpi_users', + 'field' => 'name', + 'linkfield' => 'users_id_bus', + 'name' => __('Business owner'), + 'datatype' => 'dropdown', + 'right' => 'interface' + ]; + + $tab[] = [ + 'id' => '25', + 'table' => 'glpi_plugin_services_servicebuspriorities', + 'field' => 'name', + 'name' => PluginServicesServicebuspriority::getTypeName(1), + 'datatype' => 'dropdown' + ]; + + // Business risks + $tab[] = [ + 'id' => '30', + 'table' => 'glpi_plugin_services_servicebusrisks', + 'field' => 'name', + 'name' => PluginServicesServiceBusRisk::getTypeName(1), + 'datatype' => 'dropdown' + ]; + + // Categories + $tab[] = [ + 'id' => '35', + 'table' => 'glpi_itilcategories', + 'field' => 'completename', + 'name' => __('Category'), + 'datatype' => 'dropdown' + ]; + + // Comments + $tab[] = [ + 'id' => '40', + 'table' => $this->getTable(), + 'field' => 'comment', + 'name' => __('Comments'), + 'datatype' => 'text' + ]; + + // Dashboard URL + $tab[] = [ + 'id' => '45', + 'table' => $this->getTable(), + 'field' => 'Address', + 'name' => __('Dashboard URL'), + 'datatype' => 'weblink' + ]; + + // Distribution list + $tab[] = [ + 'id' => '50', + 'table' => $this->getTable(), + 'field' => 'dist_list', + 'name' => __('Distribution List'), + ]; + + // Last DR + $tab[] = [ + 'id' => '55', + 'table' => $this->getTable(), + 'field' => 'date_last_dr', + 'massiveaction' => false, + 'name' => __('Last disaster recovery tested'), + 'datatype' => 'date' + ]; + + // Next DR + $tab[] = [ + 'id' => '60', + 'table' => $this->getTable(), + 'field' => 'date_next_dr', + 'massiveaction' => false, + 'name' => __('Next disaster recovery planning'), + 'datatype' => 'date' + ]; + + // Editor + $tab[] = [ + 'id' => '65', + 'table' => 'glpi_manufacturers', + 'field' => 'name', + 'name' => __('Editor'), + 'datatype' => 'dropdown' + ]; + + // Is DR + $tab[] = [ + 'id' => '70', + 'table' => $this->getTable(), + 'field' => 'is_disaster_recovery', + 'name' => __('Is Disaster Recovery'), + 'datatype' => 'bool' + ]; + + // Is DR documented + $tab[] = [ + 'id' => '75', + 'table' => $this->getTable(), + 'field' => 'is_disaster_recovery_documented', + 'name' => __('Is DR documented'), + 'datatype' => 'bool' + ]; + // DR doc URL + $tab[] = [ + 'id' => '76', + 'table' => $this->getTable(), + 'field' => 'dr_docs_url', + 'name' => __('DR Documentation URL'), + 'datatype' => 'weblink' + ]; + + // Entity complete name + $tab[] = [ + 'id' => '80', + 'table' => 'glpi_entities', + 'field' => 'completename', + 'name' => __('Entity'), + 'datatype' => 'dropdown' + ]; + + // RPO + $tab[] = [ + 'id' => '85', + 'table' => 'glpi_plugin_services_servicerpos', + 'field' => 'name', + 'name' => PluginServicesServiceRpo::getTypeName(1), + 'datatype' => 'dropdown' + ]; + + // RTO + $tab[] = [ + 'id' => '90', + 'table' => 'glpi_plugin_services_servicertos', + 'field' => 'name', + 'name' => PluginServicesServiceRto::getTypeName(1), + 'datatype' => 'dropdown' + ]; + + + // Sharepoint URL + $tab[] = [ + 'id' => '95', + 'table' => $this->getTable(), + 'field' => 'backoffice', + 'name' => __('Sharepoint URL'), + 'datatype' => 'weblink' + ]; + + // Supplier + $tab[] = [ + 'id' => '100', + 'table' => 'glpi_suppliers', + 'field' => 'name', + 'name' => __('Supplier'), + 'datatype' => 'itemlink' + ]; + + // IT owner + $tab[] = [ + 'id' => '101', + 'table' => 'glpi_users', + 'field' => 'name', + 'linkfield' => 'users_id_itowner', + 'name' => __('Product Owner'), + 'datatype' => 'dropdown', + 'right' => 'interface' + ]; + + // Technicial owner + $tab[] = [ + 'id' => '102', + 'table' => 'glpi_users', + 'linkfield' => 'users_id_tech', + 'field' => 'name', + 'name' => __('Technicial Owner'), + 'datatype' => 'dropdown', + 'right' => 'interface' + ]; + //technical groups + $tab[] = [ + 'id' => '110', + 'table' => 'glpi_groups', + 'field' => 'name', + 'linkfield' => 'groups_id_tech', + 'name' => __('Technical Owner Group'), + 'datatype' => 'dropdown', + 'condition' => '`is_assign`' + ]; + + // Secondary Technicial owner + $tab[] = [ + 'id' => '115', + 'table' => 'glpi_users', + 'field' => 'name', + 'linkfield' => 'users_id_sectech', + 'name' => __('Secondary Technicial Owner'), + 'datatype' => 'dropdown', + 'right' => 'interface' + ]; + + // Service status + # $tab[] = [ + # 'id' => '118', + # 'table' => 'glpi_plugin_services_servicestatus', + # 'field' => 'name', + # 'name' => PluginServicesServiceStatus::getTypeName(1), + # 'datatype' => 'dropdown' + # ]; + + // Service support time + $tab[] = [ + 'id' => '120', + 'table' => 'glpi_plugin_services_servicesupports', + 'field' => 'name', + 'name' => PluginServicesServiceSupport::getTypeName(1), + 'datatype' => 'dropdown' + ]; + + // DR Test Type + $tab[] = [ + 'id' => '121', + 'table' => 'glpi_plugin_services_servicedrtesttypes', + 'field' => 'name', + 'name' => PluginServicesServiceDrTestType::getTypeName(1), + 'datatype' => 'dropdown' + ]; + + // DR Solution Type + $tab[] = [ + 'id' => '122', + 'table' => 'glpi_plugin_services_servicedrsolutiontypes', + 'field' => 'name', + 'name' => PluginServicesServiceDrSolutionType::getTypeName(1), + 'datatype' => 'dropdown' + ]; + + // Tiers + $tab[] = [ + 'id' => '125', + 'table' => 'glpi_plugin_services_servicetiers', + 'field' => 'name', + 'name' => PluginServicesServiceTier::getTypeName(1), + 'datatype' => 'dropdown' + ]; + + // Is CORP DBA Managed + $tab[] = [ + 'id' => '128', + 'table' => $this->getTable(), + 'field' => 'is_corp_dba_managed', + 'name' => __('Is CORP DBA Managed'), + 'datatype' => 'bool' + ]; + + // Is helpdesk visible + $tab[] = [ + 'id' => '129', + 'table' => $this->getTable(), + 'field' => 'is_helpdesk_visible', + 'name' => __('Associable to a ticket'), + 'datatype' => 'bool' + ]; + + // TCO + $tab[] = [ + 'id' => '130', + 'table' => 'glpi_plugin_services_servicetypes', + 'field' => 'name', + 'name' => PluginServicesServiceType::getTypeName(1), + 'datatype' => 'dropdown' + ]; + + // ID + $tab[] = [ + 'id' => '135', + 'table' => $this->getTable(), + 'field' => 'id', + 'name' => __('ID'), + 'datatype' => 'number' + ]; + + //Last update + $tab[] = [ + 'id' => '145', + 'table' => $this->getTable(), + 'field' => 'date_mod', + 'massiveaction' => false, + 'name' => __('Last update'), + 'datatype' => 'date' + ]; + + // is_recursive + $tab[] = [ + 'id' => '150', + 'table' => $this->getTable(), + 'field' => 'is_recursive', + 'name' => __('Child entities'), + 'datatype' => 'bool' + ]; + + return $tab; + } //define header form - function defineTabs($options=array()) { + /** + * @param array $options + * + * @return array + */ + function defineTabs($options = []) { - $ong = array(); + $ong = []; $this->addDefaultFormTab($ong); $this->addStandardTab('PluginServicesService_Item', $ong, $options); $this->addStandardTab('Ticket', $ong, $options); + $this->addStandardTab('KnowbaseItem_Item', $ong, $options); $this->addStandardTab('Item_Problem', $ong, $options); - $this->addStandardTab('Contract_Item', $ong, $options); + $this->addStandardTab('Change_Item', $ong, $options); $this->addStandardTab('Document_Item', $ong, $options); + $this->addStandardTab('Contract_Item', $ong, $options); + $this->addStandardTab('Address', $ong, $options); $this->addStandardTab('Notepad', $ong, $options); $this->addStandardTab('Log', $ong, $options); return $ong; @@ -341,29 +768,35 @@ function prepareInputForUpdate($input) { * Return the SQL command to retrieve linked object * * @return a SQL command which return a set of (itemtype, items_id) - **/ - function getSelectLinkedItem () { + **/ + function getSelectLinkedItem() { return "SELECT `itemtype`, `items_id` FROM `glpi_plugin_services_services_items` - WHERE `plugin_services_services_id`='" . $this->fields['id']."'"; + WHERE `plugin_services_services_id`='" . $this->fields['id'] . "'"; } - function showForm($ID, $options=array()) { - global $CFG_GLPI; + function showForm($ID, $options = []) { $this->initForm($ID, $options); $this->showFormHeader($options); echo ""; //name of services - echo "".__('Product Name').""; + echo "".__('Service Name').""; echo ""; Html::autocompletionTextField($this,"name"); echo ""; - //time of services + //Service Status + #echo "".PluginServicesServiceStatus::getTypeName(1).""; + #echo ""; + #Dropdown::show('PluginServicesServiceStatus', + # array('value' => $this->fields["plugin_services_servicestatus_id"])); + #echo ""; + + //Service Support Level echo "".PluginServicesServiceSupport::getTypeName(1).""; echo ""; Dropdown::show('PluginServicesServiceSupport', @@ -407,9 +840,9 @@ function showForm($ID, $options=array()) { echo ""; //url of services - echo "".__('Application URL').""; + echo "".__('Service URL').""; echo ""; - Html::autocompletionTextField($this, "address", array('size' => "65")); + Html::autocompletionTextField($this, "Address", array('size' => "65")); echo ""; //manufacturer of services @@ -423,12 +856,20 @@ function showForm($ID, $options=array()) { echo ""; //backoffice of services - echo "".__('Backoffice URL', 'services').""; + echo "".__('Service Admin URL', 'services').""; echo ""; Html::autocompletionTextField($this, "backoffice", array('size' => "65")); echo ""; - - //is_helpdesk_visible + + //is_corp_dba_managed + echo "" . __('Is CORP DBA Managed') . ""; + Dropdown::showYesNo('is_corp_dba_managed', $this->fields['is_corp_dba_managed']); + echo ""; + + // ---- End of 2 ----- + echo ""; + + //is_helpdesk_visible echo "" . __('Associable to a ticket') . ""; Dropdown::showYesNo('is_helpdesk_visible', $this->fields['is_helpdesk_visible']); echo ""; @@ -451,16 +892,29 @@ function showForm($ID, $options=array()) { echo "".__('Owner information', 'Services').""; echo ""; - //application specialist - echo "".__('Application specialist').""; + echo ""; + //IT Owner + echo "".__('Service Owner').""; + User::dropdown(array('name' => "users_id_itowner", + 'value' => $this->fields["users_id_itowner"], + 'entity' => $this->fields["entities_id"], + 'right' => 'interface')); + echo ""; + echo ""; + + // ---- End of 2 ----- + + //Service specialist + echo ""; + echo "".__('Service Specialist').""; User::dropdown(array('name' => "users_id_app", 'value' => $this->fields["users_id_app"], 'entity' => $this->fields["entities_id"], 'right' => 'interface')); echo ""; - //Technical owner - echo "".__('Technical owner').""; + //Technical Specialist + echo "".__('Technical Specialist').""; User::dropdown(array('name' => "users_id_tech", 'value' => $this->fields["users_id_tech"], 'entity' => $this->fields["entities_id"], @@ -470,16 +924,16 @@ function showForm($ID, $options=array()) { // ---- End of 2 ----- echo ""; - //secondary application specialist - echo "".__('Secondary Application specialist').""; + //Backup service specialist + echo "".__('Backup Service Specialist').""; User::dropdown(array('name' => "users_id_secapp", 'value' => $this->fields["users_id_secapp"], 'entity' => $this->fields["entities_id"], 'right' => 'interface')); echo ""; - //secondary Technical owner - echo "".__('Secondary Technical owner').""; + //secondary Technical Specialist + echo "".__('Backup Technical Specialist').""; User::dropdown(array('name' => "users_id_sectech", 'value' => $this->fields["users_id_sectech"], 'entity' => $this->fields["entities_id"], @@ -490,15 +944,15 @@ function showForm($ID, $options=array()) { echo ""; //tech groups - echo "".__('Technical group owner').""; + echo "".__('Technical Group').""; Dropdown::show('Group', array('name' => "groups_id_tech", 'value' => $this->fields["groups_id_tech"], 'entity' => $this->fields["entities_id"], - 'condition' => '`is_assign`')); + 'condition' => ['is_assign' => 1])); echo ""; //Bus user - echo "".__('Business owner').""; + echo "".__('Management Owner').""; User::dropdown(array('name' => "users_id_bus", 'value' => $this->fields["users_id_bus"], 'entity' => $this->fields["entities_id"], @@ -509,16 +963,13 @@ function showForm($ID, $options=array()) { // ---- End of 2 ----- echo ""; - - - - // ---------------------------------- Section DRP --------------------------------------- + // ---------------------------------- Section Business information --------------------------------------- echo "
"; echo ""; echo ""; - echo ""; + echo ""; echo ""; - + //Business Risk echo ""; echo ""; - // ---- End of 2 ----- + // ---- End of 2 ----- echo ""; //Business Priority @@ -551,6 +1002,15 @@ function showForm($ID, $options=array()) { echo ""; // ---- End of 2 ----- + + + // ---------------------------------- Section DRP --------------------------------------- + echo "
"; + echo "
".__('Disaster Recovery information', 'Services')."".__('Business information priorities', 'Services')."
".PluginServicesServiceBusRisk::getTypeName(1).""; @@ -533,7 +984,7 @@ function showForm($ID, $options=array()) { array('value' => $this->fields["plugin_services_servicertos_id"])); echo "
"; + echo ""; + echo ""; + echo ""; + echo ""; //Is Disaster Recovery @@ -569,7 +1029,7 @@ function showForm($ID, $options=array()) { //DR Documentation URL echo ""; echo ""; //Tier Level @@ -584,25 +1044,42 @@ function showForm($ID, $options=array()) { echo ""; echo ""; echo ""; echo ""; echo ""; // ---- End of 2 ----- echo ""; + //DR Test Type + echo ""; + echo ""; + + //DR Solution Type + echo ""; + echo ""; + + // ---- End of 2 ----- + + echo ""; $this->showFormButtons($options); - + return true; } - /** + /** * Make a select box for link services * * Parameters which could be used in options array : @@ -614,14 +1091,13 @@ function showForm($ID, $options=array()) { * @param $options array of possible options * * @return nothing (print out an HTML select box) - **/ - static function dropdownService($options=array()) { + **/ + static function dropdownService($options = []) { global $DB, $CFG_GLPI; - $p['name'] = 'plugin_services_services_id'; $p['entity'] = ''; - $p['used'] = array(); + $p['used'] = []; $p['display'] = true; if (is_array($options) && count($options)) { @@ -629,16 +1105,16 @@ static function dropdownService($options=array()) { $p[$key] = $val; } } - - $where = " WHERE `glpi_plugin_services_services`.`is_deleted` = '0' ". - getEntitiesRestrictRequest("AND", "glpi_plugin_services_services", '', $p['entity'], true); + $dbu = new DbUtils(); + $where = " WHERE `glpi_plugin_services_services`.`is_deleted` = '0' " . + $dbu->getEntitiesRestrictRequest("AND", "glpi_plugin_services_services", '', $p['entity'], true); $p['used'] = array_filter($p['used']); if (count($p['used'])) { - $where .= " AND `id` NOT IN (0, ".implode(",",$p['used']).")"; + $where .= " AND `id` NOT IN (0, " . implode(",", $p['used']) . ")"; } - $query = "SELECT * + $query = "SELECT * FROM `glpi_plugin_services_servicetypes` WHERE `id` IN (SELECT DISTINCT `plugin_services_servicetypes_id` FROM `glpi_plugin_services_services` @@ -646,32 +1122,32 @@ static function dropdownService($options=array()) { ORDER BY `name`"; $result = $DB->query($query); - $values = array(0 => Dropdown::EMPTY_VALUE); + $values = [0 => Dropdown::EMPTY_VALUE]; - while ($data = $DB->fetch_assoc($result)) { + while ($data = $DB->fetchassoc($result)) { $values[$data['id']] = $data['name']; } - $rand = mt_rand(); - $out = Dropdown::showFromArray('_servicetype', $values, array('width' => '30%', - 'rand' => $rand, - 'display' => false)); + $rand = mt_rand(); + $out = Dropdown::showFromArray('_servicetype', $values, ['width' => '30%', + 'rand' => $rand, + 'display' => false]); $field_id = Html::cleanId("dropdown__servicetype$rand"); - $params = array('servicetype' => '__VALUE__', - 'entity' => $p['entity'], - 'rand' => $rand, - 'myname' => $p['name'], - 'used' => $p['used']); + $params = ['servicetype' => '__VALUE__', + 'entity' => $p['entity'], + 'rand' => $rand, + 'myname' => $p['name'], + 'used' => $p['used']]; - $out .= Ajax::updateItemOnSelectEvent($field_id,"show_".$p['name'].$rand, - $CFG_GLPI["root_doc"]."/plugins/services/ajax/dropdownTypeServices.php", + $out .= Ajax::updateItemOnSelectEvent($field_id, "show_" . $p['name'] . $rand, + $CFG_GLPI["root_doc"] . "/plugins/services/ajax/dropdownTypeServices.php", $params, false); - $out .= ""; + $out .= ""; $out .= "\n"; $params['servicetype'] = 0; - $out .= Ajax::updateItem("show_".$p['name'].$rand, - $CFG_GLPI["root_doc"]. "/plugins/services/ajax/dropdownTypeServices.php", + $out .= Ajax::updateItem("show_" . $p['name'] . $rand, + $CFG_GLPI["root_doc"] . "/plugins/services/ajax/dropdownTypeServices.php", $params, false); if ($p['display']) { echo $out; @@ -681,6 +1157,13 @@ static function dropdownService($options=array()) { } + /** + * For other plugins, add a type to the linkable types + * + * @since version 1.3.0 + * + * @param $type string class name + **/ static function registerType($type) { if (!in_array($type, self::$types)) { self::$types[] = $type; @@ -694,8 +1177,8 @@ static function registerType($type) { * @param $all boolean, all type, or only allowed ones * * @return array of types - **/ - static function getTypes($all=false) { + **/ + static function getTypes($all = false) { if ($all) { return self::$types; @@ -722,20 +1205,23 @@ static function getTypes($all=false) { * @since version 0.85 * * @see CommonDBTM::getSpecificMassiveActions() - **/ - function getSpecificMassiveActions($checkitem=NULL) { + * + * @param null $checkitem + * + * @return an + */ + function getSpecificMassiveActions($checkitem = null) { $isadmin = static::canUpdate(); $actions = parent::getSpecificMassiveActions($checkitem); - if ($_SESSION['glpiactiveprofile']['interface'] == 'central') { + if (Session::getCurrentInterface() == 'central') { if ($isadmin) { - $actions['PluginServicesService'.MassiveAction::CLASS_ACTION_SEPARATOR.'install'] = _x('button', 'Associate'); - $actions['PluginServicesService'.MassiveAction::CLASS_ACTION_SEPARATOR.'uninstall'] = _x('button', 'Dissociate'); + $actions['PluginServicesService' . MassiveAction::CLASS_ACTION_SEPARATOR . 'install'] = _x('button', 'Associate'); + $actions['PluginServicesService' . MassiveAction::CLASS_ACTION_SEPARATOR . 'uninstall'] = _x('button', 'Dissociate'); if (Session::haveRight('transfer', READ) - && Session::isMultiEntitiesMode() - ) { - $actions['PluginServicesService'.MassiveAction::CLASS_ACTION_SEPARATOR.'transfer'] = __('Transfer'); + && Session::isMultiEntitiesMode()) { + $actions['PluginServicesService' . MassiveAction::CLASS_ACTION_SEPARATOR . 'transfer'] = __('Transfer'); } } } @@ -747,34 +1233,46 @@ function getSpecificMassiveActions($checkitem=NULL) { * @since version 0.85 * * @see CommonDBTM::showMassiveActionsSubForm() - **/ + * + * @param MassiveAction $ma + * + * @return bool|false + */ static function showMassiveActionsSubForm(MassiveAction $ma) { switch ($ma->getAction()) { case 'plugin_services_add_item': - self::dropdownService(array()); - echo " ". - Html::submit(_x('button','Post'), array('name' => 'massiveaction')); + self::dropdownService([]); + echo " " . + Html::submit(_x('button', 'Post'), ['name' => 'massiveaction']); return true; break; case "install" : - Dropdown::showAllItems("item_item", 0, 0, -1, self::getTypes(true), - false, false, 'typeitem'); - echo Html::submit(_x('button','Post'), array('name' => 'massiveaction')); + Dropdown::showSelectItemFromItemtypes(['items_id_name' => 'item_item', + 'itemtype_name' => 'typeitem', + 'itemtypes' => self::getTypes(true), + 'checkright' + => true, + ]); + echo Html::submit(_x('button', 'Post'), ['name' => 'massiveaction']); return true; break; case "uninstall" : - Dropdown::showAllItems("item_item", 0, 0, -1, self::getTypes(true), - false, false, 'typeitem'); - echo Html::submit(_x('button','Post'), array('name' => 'massiveaction')); + Dropdown::showSelectItemFromItemtypes(['items_id_name' => 'item_item', + 'itemtype_name' => 'typeitem', + 'itemtypes' => self::getTypes(true), + 'checkright' + => true, + ]); + echo Html::submit(_x('button', 'Post'), ['name' => 'massiveaction']); return true; break; case "transfer" : Dropdown::show('Entity'); - echo Html::submit(_x('button','Post'), array('name' => 'massiveaction')); + echo Html::submit(_x('button', 'Post'), ['name' => 'massiveaction']); return true; break; - } + } return parent::showMassiveActionsSubForm($ma); } @@ -783,21 +1281,26 @@ static function showMassiveActionsSubForm(MassiveAction $ma) { * @since version 0.85 * * @see CommonDBTM::processMassiveActionsForOneItemtype() - **/ + * + * @param MassiveAction $ma + * @param CommonDBTM $item + * @param array $ids + * + * @return nothing|void + */ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) { - global $DB; - + $web_item = new PluginServicesService_Item(); - + switch ($ma->getAction()) { case "plugin_services_add_item": $input = $ma->getInput(); foreach ($ids as $id) { - $input = array('plugin_services_services_id' => $input['plugin_services_services_id'], - 'items_id' => $id, - 'itemtype' => $item->getType()); - if ($web_item->can(-1,UPDATE,$input)) { + $input = ['plugin_services_services_id' => $input['plugin_services_services_id'], + 'items_id' => $id, + 'itemtype' => $item->getType()]; + if ($web_item->can(-1, UPDATE, $input)) { if ($web_item->add($input)) { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK); } else { @@ -812,17 +1315,17 @@ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBT case "transfer" : $input = $ma->getInput(); if ($item->getType() == 'PluginServicesService') { - foreach ($ids as $key) { + foreach ($ids as $key) { $item->getFromDB($key); $type = PluginServicesServiceType::transfer($item->fields["plugin_services_servicetypes_id"], $input['entities_id']); if ($type > 0) { - $values["id"] = $key; + $values["id"] = $key; $values["plugin_services_servicetypes_id"] = $type; $item->update($values); } unset($values); - $values["id"] = $key; + $values["id"] = $key; $values["entities_id"] = $input['entities_id']; if ($item->update($values)) { @@ -838,9 +1341,9 @@ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBT $input = $ma->getInput(); foreach ($ids as $key) { if ($item->can($key, UPDATE)) { - $values = array('plugin_services_services_id' => $key, - 'items_id' => $input["item_item"], - 'itemtype' => $input['typeitem']); + $values = ['plugin_services_services_id' => $key, + 'items_id' => $input["item_item"], + 'itemtype' => $input['typeitem']]; if ($web_item->add($values)) { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK); } else { @@ -852,21 +1355,35 @@ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBT } } return; - + case 'uninstall': $input = $ma->getInput(); foreach ($ids as $key) { - if ($val == 1) { - if ($web_item->deleteItemByServicesAndItem($key,$input['item_item'],$input['typeitem'])) { - $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK); - } else { - $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO); - } + if ($web_item->deleteItemByServicesAndItem($key, $input['item_item'], $input['typeitem'])) { + $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK); + } else { + $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO); } } return; } parent::processMassiveActionsForOneItemtype($ma, $item, $ids); } + + /** + * @param string $link + * @param CommonDBTM $item + * + * @return array + */ + static function generateLinkContents($link, CommonDBTM $item) { + + if (strstr($link, "[SERVICE_URL]")) { + $link = str_replace("[SERVICE_URL]", $item->fields['link'], $link); + return [$link]; + } + + return parent::generateLinkContents($link, $item); + } } -?> \ No newline at end of file +?> diff --git a/inc/service_item.class.php b/inc/service_item.class.php index 4139c8c..ac53a95 100644 --- a/inc/service_item.class.php +++ b/inc/service_item.class.php @@ -1,29 +1,29 @@ . + along with services. If not, see . -------------------------------------------------------------------------- */ @@ -31,19 +31,25 @@ die("Sorry. You can't access directly to this file"); } +/** + * Class PluginServicesService_Item + */ class PluginServicesService_Item extends CommonDBRelation { // From CommonDBRelation - static public $itemtype_1 = 'PluginServicesService'; - static public $items_id_1 = 'plugin_services_services_id'; - static public $take_entity_1 = false ; - - static public $itemtype_2 = 'itemtype'; - static public $items_id_2 = 'items_id'; - static public $take_entity_2 = true ; - + static public $itemtype_1 = 'PluginServicesService'; + static public $items_id_1 = 'plugin_services_services_id'; + static public $take_entity_1 = false; + + static public $itemtype_2 = 'itemtype'; + static public $items_id_2 = 'items_id'; + static public $take_entity_2 = true; + static $rightname = "plugin_services"; - + + /** + * @param CommonDBTM $item + */ static function cleanForItem(CommonDBTM $item) { $temp = new self(); @@ -52,16 +58,22 @@ static function cleanForItem(CommonDBTM $item) { 'items_id' => $item->getField('id')) ); } - - function getTabNameForItem(CommonGLPI $item, $withtemplate=0) { + + /** + * @param CommonGLPI $item + * @param int $withtemplate + * + * @return array|string|translated + */ + function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { if (!$withtemplate) { - if ($item->getType()=='PluginServicesService' + if ($item->getType() == 'PluginServicesService' && count(PluginServicesService::getTypes(false))) { if ($_SESSION['glpishow_count_on_tabs']) { - return self::createTabEntry(_n('Associated item','Associated items',2), self::countForService($item)); + return self::createTabEntry(_n('Associated item', 'Associated items', 2), self::countForService($item)); } - return _n('Associated item','Associated items',2); + return _n('Associated item', 'Associated items', 2); } else if (in_array($item->getType(), PluginServicesService::getTypes(true)) && Session::haveRight("plugin_services", READ)) { @@ -75,45 +87,69 @@ function getTabNameForItem(CommonGLPI $item, $withtemplate=0) { } - static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) { - - if ($item->getType()=='PluginServicesService') { - + /** + * @param CommonGLPI $item + * @param int $tabnum + * @param int $withtemplate + * + * @return bool + */ + static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { + + if ($item->getType() == 'PluginServicesService') { + self::showForService($item); } else if (in_array($item->getType(), PluginServicesService::getTypes(true))) { - + self::showForItem($item); } return true; } - - static function countForService(PluginServicesService $item) { - $types = implode("','", $item->getTypes()); - if (empty($types)) { + /** + * @param PluginServicesService $item + * + * @return int + */ + static function countForService(PluginServicesService $item) { + $dbu = new DbUtils(); + $types = $item->getTypes(); + if (count($types) == 0) { return 0; } - return countElementsInTable('glpi_plugin_services_services_items', - "`itemtype` IN ('$types') - AND `plugin_services_services_id` = '".$item->getID()."'"); + return $dbu->countElementsInTable('glpi_plugin_services_services_items', + ["itemtype" => $types, + "plugin_services_services_id" => $item->getID()]); } + /** + * @param CommonDBTM $item + * + * @return int + */ static function countForItem(CommonDBTM $item) { - - return countElementsInTable('glpi_plugin_services_services_items', - "`itemtype`='".$item->getType()."' - AND `items_id` = '".$item->getID()."'"); + $dbu = new DbUtils(); + return $dbu->countElementsInTable('glpi_plugin_services_services_items', + ["itemtype" => $item->getType(), + "items_id" => $item->getID()]); } - function getFromDBbyServicesAndItem($plugin_services_services_id, - $items_id,$itemtype) { + /** + * @param $plugin_services_services_id + * @param $items_id + * @param $itemtype + * + * @return bool + */ + function getFromDBbyWebApplicationsAndItem($plugin_services_services_id, + $items_id, $itemtype) { global $DB; $query = "SELECT * - FROM `".$this->getTable()."` + FROM `" . $this->getTable() . "` WHERE `plugin_services_services_id` = '" . $plugin_services_services_id . "' AND `itemtype` = '" . $itemtype . "' @@ -131,36 +167,45 @@ function getFromDBbyServicesAndItem($plugin_services_services_id, return false; } + /** + * @param $values + */ function addItem($values) { - $this->add(array('plugin_services_services_id' - =>$values["plugin_services_services_id"], - 'items_id'=>$values["items_id"], - 'itemtype'=>$values["itemtype"])); - + $this->add(['plugin_services_services_id' + => $values["plugin_services_services_id"], + 'items_id' => $values["items_id"], + 'itemtype' => $values["itemtype"]]); + } - - function deleteItemByServicesAndItem($plugin_services_services_id, - $items_id, $itemtype) { + /** + * @param $plugin_services_services_id + * @param $items_id + * @param $itemtype + */ + function deleteItemByServicesAndItem($plugin_services_services_id, + $items_id, $itemtype) { if ($this->getFromDBbyServicesAndItem($plugin_services_services_id, - $items_id,$itemtype)) { - $this->delete(array('id' => $this->fields["id"])); + $items_id, $itemtype)) { + $this->delete(['id' => $this->fields["id"]]); } } - + /** * Show items links to a service * * @since version 0.84 * - * @param $PluginServicesService PluginServicesService object + * @param PluginServicesService $service * - * @return nothing (HTML display) - **/ + * @return nothing + * @internal param PluginServicesService $PluginServicesService object + * + */ static function showForService(PluginServicesService $service) { global $DB, $CFG_GLPI; @@ -178,21 +223,32 @@ static function showForService(PluginServicesService $service) { $result = $DB->query($query); $number = $DB->numrows($result); $rand = mt_rand(); + $dbu = new DbUtils(); if ($canedit) { echo "
"; echo ""; + action='" . Toolbox::getItemTypeFormURL("PluginServicesService") . "'>"; echo "
".__('Disaster Recovery information', 'Services')."
".__('DR Documentation URL', 'services').""; - Html::autocompletionTextField($this, "dr_docs_url", array('size' => "65")); + Html::autocompletionTextField($this, "DR_docs_url", array('size' => "65")); echo "
".__('Last disaster recovery tested').""; - Html::showDateFormItem("date_last_dr",$this->fields["date_last_dr"],true,true); + Html::showDateField("date_last_dr",['value' => $this->fields["date_last_dr"],'maybeempty' => true]); echo "".__('Next disaster recovery planning').""; - Html::showDateFormItem("date_next_dr",$this->fields["date_next_dr"],true,true); + Html::showDateField("date_next_dr",['value' => $this->fields["date_next_dr"],'maybeempty' => true]); echo "
".PluginServicesServiceDrTestType::getTypeName(1).""; + Dropdown::show('PluginServicesServiceDrTestType', + array('value' => $this->fields["plugin_services_servicedrtesttypes_id"])); + echo "".PluginServicesServiceDrSolutionType::getTypeName(1).""; + Dropdown::show('PluginServicesServiceDrSolutionType', + array('value' => $this->fields["plugin_services_servicedrsolutiontypes_id"])); + echo "
"; - echo ""; + echo ""; echo ""; echo "
".__('Add an item')."
" . __('Add an item') . "
"; - Dropdown::showAllItems("items_id", 0, 0, - ($service->fields['is_recursive']?-1:$service->fields['entities_id']), - PluginServicesService::getTypes(), false, true); + Dropdown::showSelectItemFromItemtypes(['items_id_name' => 'items_id', + + + + 'itemtypes' => PluginServicesService::getTypes(true), + 'entity_restrict' + => ($service->fields['is_recursive'] + ? $dbu->getSonsOf('glpi_entities', + $service->fields['entities_id']) + : $service->fields['entities_id']), + 'checkright' + => true, + ]); echo ""; - echo ""; + echo ""; echo ""; echo "
"; @@ -202,27 +258,27 @@ static function showForService(PluginServicesService $service) { echo "
"; if ($canedit && $number) { - Html::openMassiveActionsForm('mass'.__CLASS__.$rand); - $massiveactionparams = array(); + Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); + $massiveactionparams = []; Html::showMassiveActions($massiveactionparams); } echo ""; - echo ""; + echo ""; if ($canedit && $number) { - echo ""; + echo ""; } - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; echo ""; - for ($i=0 ; $i < $number ; $i++) { - $itemtype=$DB->result($result, $i, "itemtype"); - if (!($item = getItemForItemtype($itemtype))) { + for ($i = 0; $i < $number; $i++) { + $itemtype = $DB->result($result, $i, "itemtype"); + if (!($item = $dbu->getItemForItemtype($itemtype))) { continue; } @@ -232,21 +288,21 @@ static function showForService(PluginServicesService $service) { $column = "id"; } - $itemtable = getTableForItemType($itemtype); + $itemtable = $dbu->getTableForItemType($itemtype); $query = "SELECT `$itemtable`.*, `glpi_plugin_services_services_items`.`id` AS IDD, "; if ($itemtype == 'KnowbaseItem') { $query .= "-1 AS entity FROM `glpi_plugin_services_services_items`, `$itemtable` - ".KnowbaseItem::addVisibilityJoins()." + " . KnowbaseItem::addVisibilityJoins() . " WHERE `$itemtable`.`id` = `glpi_plugin_services_services_items`.`items_id` AND "; } else { $query .= "`glpi_entities`.`id` AS entity FROM `glpi_plugin_services_services_items`, `$itemtable` "; - - if ($itemtype !='Entity') { + + if ($itemtype != 'Entity') { $query .= "LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `$itemtable`.`entities_id`) "; } @@ -256,9 +312,9 @@ static function showForService(PluginServicesService $service) { $query .= "`glpi_plugin_services_services_items`.`itemtype` = '$itemtype' AND `glpi_plugin_services_services_items`.`plugin_services_services_id` = '$instID' "; - if ($itemtype =='KnowbaseItem') { + if ($itemtype == 'KnowbaseItem') { if (Session::getLoginUserID()) { - $where = "AND ".KnowbaseItem::addVisibilityRestrict(); + $where = "AND " . KnowbaseItem::addVisibilityRestrict(); } else { // Anonymous access if (Session::isMultiEntitiesMode()) { @@ -267,8 +323,8 @@ static function showForService(PluginServicesService $service) { } } } else { - $query .= getEntitiesRestrictRequest(" AND ", $itemtable, '', '', - $item->maybeRecursive()); + $query .= $dbu->getEntitiesRestrictRequest(" AND ", $itemtable, '', '', + $item->maybeRecursive()); } if ($item->maybeTemplate()) { @@ -288,7 +344,7 @@ static function showForService(PluginServicesService $service) { if ($result_linked = $DB->query($query)) { if ($DB->numrows($result_linked)) { - while ($data = $DB->fetch_assoc($result_linked)) { + while ($data = $DB->fetchassoc($result_linked)) { if ($itemtype == 'Ticket') { $data["name"] = sprintf(__('%1$s: %2$s'), __('Ticket'), $data["id"]); @@ -306,7 +362,7 @@ static function showForService(PluginServicesService $service) { } $link = Toolbox::getItemTypeFormURL($itemtype); - $name = "".$linkname.""; + $name = "" . $linkname . ""; echo ""; @@ -315,17 +371,17 @@ static function showForService(PluginServicesService $service) { Html::showMassiveActionCheckBox(__CLASS__, $data["IDD"]); echo ""; } - echo ""; - echo ""; - echo ""; + echo ""; + echo ""; - echo ""; - echo ""; + echo ""; + echo ""; echo ""; } } @@ -334,24 +390,26 @@ static function showForService(PluginServicesService $service) { } echo "
".Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand)."" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "".__('Type')."".__('Name')."".__('Entity')."".__('Serial number')."".__('Inventory number')."" . __('Type') . "" . __('Name') . "" . __('Entity') . "" . __('Serial number') . "" . __('Inventory number') . "
".$item->getTypeName(1)."".$name."".Dropdown::getDropdownName("glpi_entities", - $data['entity']); + echo "" . $item->getTypeName(1) . "" . $name . "" . Dropdown::getDropdownName("glpi_entities", + $data['entity']); echo "". - (isset($data["serial"])? "".$data["serial"]."" :"-")."". - (isset($data["otherserial"])? "".$data["otherserial"]."" :"-")."" . + (isset($data["serial"]) ? "" . $data["serial"] . "" : "-") . "" . + (isset($data["otherserial"]) ? "" . $data["otherserial"] . "" : "-") . "
"; if ($canedit && $number) { - $paramsma['ontop'] =false; + $paramsma['ontop'] = false; Html::showMassiveActions($paramsma); Html::closeForm(); } echo "
"; } - + /** - * Show services associated to an item - * - * @since version 0.84 - * - * @param $item CommonDBTM object for which associated services must be displayed - * @param $withtemplate (default '') - **/ - static function showForItem(CommonDBTM $item, $withtemplate='') { - global $DB, $CFG_GLPI; + * Show services associated to an item + * + * @since version 0.84 + * + * @param $item CommonDBTM object for which associated services must be displayed + * @param $withtemplate (default '') + * + * @return bool + */ + static function showForItem(CommonDBTM $item, $withtemplate = '') { + global $DB; $ID = $item->getField('id'); @@ -362,7 +420,7 @@ static function showForItem(CommonDBTM $item, $withtemplate='') { return false; } - if (!$item->can($item->fields['id'],READ)) { + if (!$item->can($item->fields['id'], READ)) { return false; } @@ -370,9 +428,10 @@ static function showForItem(CommonDBTM $item, $withtemplate='') { $withtemplate = 0; } - $canedit = $item->canadditem('PluginServicesService'); - $rand = mt_rand(); - $is_recursive = $item->isRecursive(); + $canedit = $item->canAddItem('PluginServicesService'); + $rand = mt_rand(); + $is_recursive = $item->isRecursive(); + $dbu = new DbUtils(); $query = "SELECT `glpi_plugin_services_services_items`.`id` AS assocID, `glpi_entities`.`id` AS entity, @@ -383,9 +442,9 @@ static function showForItem(CommonDBTM $item, $withtemplate='') { ON (`glpi_plugin_services_services_items`.`plugin_services_services_id`=`glpi_plugin_services_services`.`id`) LEFT JOIN `glpi_entities` ON (`glpi_plugin_services_services`.`entities_id`=`glpi_entities`.`id`) WHERE `glpi_plugin_services_services_items`.`items_id` = '$ID' - AND `glpi_plugin_services_services_items`.`itemtype` = '".$item->getType()."' "; + AND `glpi_plugin_services_services_items`.`itemtype` = '" . $item->getType() . "' "; - $query .= getEntitiesRestrictRequest(" AND","glpi_plugin_services_services",'','',true); + $query .= $dbu->getEntitiesRestrictRequest(" AND", "glpi_plugin_services_services", '', '', true); $query .= " ORDER BY `assocName`"; @@ -393,13 +452,13 @@ static function showForItem(CommonDBTM $item, $withtemplate='') { $number = $DB->numrows($result); $i = 0; - $webs = array(); - $web = new PluginServicesService(); - $used = array(); + $webs = []; + $web = new PluginServicesService(); + $used = []; if ($numrows = $DB->numrows($result)) { - while ($data = $DB->fetch_assoc($result)) { + while ($data = $DB->fetchassoc($result)) { $webs[$data['assocID']] = $data; - $used[$data['id']] = $data['id']; + $used[$data['id']] = $data['id']; } } @@ -410,48 +469,47 @@ static function showForItem(CommonDBTM $item, $withtemplate='') { if ($item->isEntityAssign()) { /// Case of personal items : entity = -1 : create on active entity (Reminder case)) - if ($item->getEntityID() >=0 ) { + if ($item->getEntityID() >= 0) { $entity = $item->getEntityID(); } if ($item->isRecursive()) { - $entities = getSonsOf('glpi_entities',$entity); + $entities = $dbu->getSonsOf('glpi_entities', $entity); } else { $entities = $entity; } } - $limit = getEntitiesRestrictRequest(" AND ","glpi_plugin_services_services",'',$entities,true); - $q = "SELECT COUNT(*) + $limit = $dbu->getEntitiesRestrictRequest(" AND ", "glpi_plugin_services_services", '', $entities, true); + $q = "SELECT COUNT(*) FROM `glpi_plugin_services_services` WHERE `is_deleted` = '0' $limit"; $result = $DB->query($q); - $nb = $DB->result($result,0,0); + $nb = $DB->result($result, 0, 0); echo "
"; - - + if (Session::haveRight("plugin_services", READ) && ($nb > count($used))) { echo ""; + action='" . Toolbox::getItemTypeFormURL('PluginServicesService') . "'>"; echo ""; echo ""; echo ""; echo ""; echo "
"; echo ""; echo ""; - echo ""; + echo ""; echo ""; if ($item->getType() == 'Ticket') { echo ""; } - PluginServicesService::dropdownService(array('entity' => $entities , - 'used' => $used)); + PluginServicesService::dropdownService(['entity' => $entities, + 'used' => $used]); echo ""; - echo ""; + echo ""; echo "
"; @@ -463,53 +521,50 @@ static function showForItem(CommonDBTM $item, $withtemplate='') { echo "
"; if ($canedit && $number && ($withtemplate < 2)) { - Html::openMassiveActionsForm('mass'.__CLASS__.$rand); - $massiveactionparams = array('num_displayed' => $number); + Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); + $massiveactionparams = ['num_displayed' => $number]; Html::showMassiveActions($massiveactionparams); } echo ""; echo ""; if ($canedit && $number && ($withtemplate < 2)) { - echo ""; + echo ""; } - echo ""; + echo ""; if (Session::isMultiEntitiesMode()) { - echo ""; - } - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; + echo ""; + } + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; echo ""; - $used = array(); + $used = []; if ($number) { Session::initNavigateListItems('PluginServicesService', - //TRANS : %1$s is the itemtype name, - // %2$s is the name of the item (used for headings of a list) + //TRANS : %1$s is the itemtype name, + // %2$s is the name of the item (used for headings of a list) sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName())); - - foreach ($webs as $data) { - $webID = $data["id"]; - $link = NOT_AVAILABLE; + foreach ($webs as $data) { + $webID = $data["id"]; + $link = NOT_AVAILABLE; if ($web->getFromDB($webID)) { - $link = $web->getLink(); + $link = $web->getLink(); } Session::addToNavigateListItems('PluginServicesService', $webID); - + $used[$webID] = $webID; - $assocID = $data["assocID"]; - echo ""; + echo ""; if ($canedit && ($withtemplate < 2)) { echo ""; if (Session::isMultiEntitiesMode()) { - echo ""; } - echo ""; - echo ""; - $link = Toolbox::substr($data["address"],0,30)."..."; - echo ""; + $link = Toolbox::substr($data["address"], 0, 30) . "..."; + echo ""; /* echo ""; */ - echo ""; - echo ""; - echo ""; +/* echo ""; */ + echo ""; echo ""; $i++; } } - echo "
".Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand)."" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "".__('Name')."" . __('Name') . "".__('Entity')."".PluginServicesServiceType::getTypeName(1)."".PluginServicesServiceSupport::getTypeName(1)."".__('URL')."".__('Server')."".__('Language')."".__('Distribution List')."".__('Comments')."" . __('Entity') . "" . PluginServicesServiceType::getTypeName(1) . "" . __('URL') . "" . __('Server') . "" . __('Language') . "" . __('Version') . "" . __('Comments') . "
"; Html::showMassiveActionCheckBox(__CLASS__, $data["assocID"]); @@ -517,35 +572,31 @@ static function showForItem(CommonDBTM $item, $withtemplate='') { } echo "$link".Dropdown::getDropdownName("glpi_entities", $data['entities_id']). + echo "" . Dropdown::getDropdownName("glpi_entities", $data['entities_id']) . "".Dropdown::getDropdownName("glpi_plugin_services_servicetypes", - $data["plugin_services_servicetypes_id"]). - "".Dropdown::getDropdownName("glpi_plugin_services_servicesupports", - $data["plugin_services_servicesupports_id"]). + echo "" . Dropdown::getDropdownName("glpi_plugin_services_servicetypes", + $data["plugin_services_servicetypes_id"]) . "". - "". - "".$link."" . + "" . + "" . $link . "".Dropdown::getDropdownName("glpi_plugin_services_serviceservertypes", $data["plugin_services_serviceservertypes_id"]). "".Dropdown::getDropdownName("glpi_plugin_services_servicetiers", - $data["plugin_services_servicetiers_id"]). + echo "" . Dropdown::getDropdownName("glpi_plugin_services_servicetechnics", + $data["plugin_services_servicetechnics_id"]) . "".$data["dist_list"]."".$data["comment"]."" . $data["version"] . "" . $data["comment"] . "
"; if ($canedit && $number && ($withtemplate < 2)) { $massiveactionparams['ontop'] = false; @@ -554,27 +605,29 @@ static function showForItem(CommonDBTM $item, $withtemplate='') { } echo "
"; } - + /** * @since version 0.84 - **/ + **/ function getForbiddenStandardMassiveAction() { $forbidden = parent::getForbiddenStandardMassiveAction(); $forbidden[] = 'update'; return $forbidden; } - - /** + + /** * Show services associated to an item * * @since version 0.84 * * @param $item Supplier object for which associated services must be displayed - * @param $withtemplate (default '') - **/ - static function showForSupplier(Supplier $item, $withtemplate='') { - global $DB, $CFG_GLPI; + * @param $withtemplate (default '') + * + * @return bool + */ + static function showForSupplier(Supplier $item, $withtemplate = '') { + global $DB; $ID = $item->getField('id'); @@ -589,12 +642,7 @@ static function showForSupplier(Supplier $item, $withtemplate='') { return false; } - if (empty($withtemplate)) { - $withtemplate = 0; - } - - $rand = mt_rand(); - $is_recursive = $item->isRecursive(); + $dbu = new DbUtils(); $query = "SELECT `glpi_entities`.`id` AS entity, `glpi_plugin_services_services`.`id` AS assocID, @@ -604,7 +652,7 @@ static function showForSupplier(Supplier $item, $withtemplate='') { LEFT JOIN `glpi_entities` ON (`glpi_plugin_services_services`.`entities_id`=`glpi_entities`.`id`) WHERE `glpi_plugin_services_services`.`suppliers_id` = '$ID' "; - $query .= getEntitiesRestrictRequest(" AND","glpi_plugin_services_services",'','',true); + $query .= $dbu->getEntitiesRestrictRequest(" AND", "glpi_plugin_services_services", '', '', true); $query .= " ORDER BY `assocName`"; @@ -612,7 +660,7 @@ static function showForSupplier(Supplier $item, $withtemplate='') { $number = $DB->numrows($result); $i = 0; - $webs = array(); + $webs = []; if ($numrows = $DB->numrows($result)) { while ($data = $DB->fetch_assoc($result)) { $webs[$data['assocID']] = $data; @@ -623,97 +671,94 @@ static function showForSupplier(Supplier $item, $withtemplate='') { echo ""; echo ""; - echo ""; - if (Session::isMultiEntitiesMode()) - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; + echo ""; + if (Session::isMultiEntitiesMode()) { + echo ""; + } + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; echo ""; - $used = array(); if ($number) { Session::initNavigateListItems('PluginServicesService', - //TRANS : %1$s is the itemtype name, - // %2$s is the name of the item (used for headings of a list) + //TRANS : %1$s is the itemtype name, + // %2$s is the name of the item (used for headings of a list) sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName())); $web = new PluginServicesService(); - - foreach ($webs as $data) { - $webID = $data["id"]; - $link = NOT_AVAILABLE; - + + foreach ($webs as $data) { + $webID = $data["id"]; + $link = NOT_AVAILABLE; + if ($web->getFromDB($webID)) { - $link = $web->getLink(); + $link = $web->getLink(); } Session::addToNavigateListItems('PluginServicesService', $webID); - - $assocID = $data["assocID"]; - echo ""; + echo ""; echo ""; if (Session::isMultiEntitiesMode()) { - echo ""; } - echo ""; - - echo ""; - $link = Toolbox::substr($data["address"],0,30)."..."; - echo ""; + $link = Toolbox::substr($data["address"], 0, 30) . "..."; + echo ""; -/* echo ""; */ - echo ""; - echo ""; - echo ""; - echo ""; + echo ""; + echo ""; + echo ""; echo ""; $i++; } } - echo "
".__('Name')."".__('Entity')."".PluginServicesServiceType::getTypeName(1)."".PluginServicesServiceSupport::getTypeName(1)."".__('URL')."".__('Server')."".__('Language')."".__('Version')."".__('Comments')."" . __('Name') . "" . __('Entity') . "" . PluginServicesServiceType::getTypeName(1) . "" . __('URL') . "" . __('Server') . "" . __('Language') . "" . __('Version') . "" . __('Comments') . "
$link".Dropdown::getDropdownName("glpi_entities", $data['entities_id']). + echo "" . Dropdown::getDropdownName("glpi_entities", $data['entities_id']) . "".Dropdown::getDropdownName("glpi_plugin_services_servicetypes", - $data["plugin_services_servicetypes_id"]). - "".Dropdown::getDropdownName("glpi_plugin_services_servicesupports", - $data["plugin_services_servicesupports_id"]). + echo "" . Dropdown::getDropdownName("glpi_plugin_services_servicetypes", + $data["plugin_services_servicetypes_id"]) . "". - "". - "".$link."" . + "" . + "" . $link . "".Dropdown::getDropdownName("glpi_plugin_services_serviceservertypes", - $data["plugin_services_serviceservertypes_id"]). - "".Dropdown::getDropdownName("glpi_plugin_services_servicetiers", - $data["plugin_services_servicetiers_id"]). + echo "" . Dropdown::getDropdownName("glpi_plugin_services_serviceservertypes", + $data["plugin_services_serviceservertypes_id"]) . "".Html::convdate($data["date_query"])."".$data["Distribution List"]."".$data["comment"]."" . Dropdown::getDropdownName("glpi_plugin_services_servicetechnics", + $data["plugin_services_servicetechnics_id"]) . + "" . $data["version"] . "" . $data["comment"] . "
"; echo "
"; } + /** + * @param PluginPdfSimplePDF $pdf + * @param PluginServicesService $item + * + * @return bool + */ static function ItemsPdf(PluginPdfSimplePDF $pdf, PluginServicesService $item) { - global $DB,$CFG_GLPI; + global $DB; $ID = $item->getField('id'); - + if (!$item->can($ID, READ)) { return false; } - + if (!Session::haveRight("plugin_services", READ)) { return false; } $pdf->setColumnsSize(100); - $pdf->displayTitle(''._n('Associated item','Associated items',2).''); + $pdf->displayTitle('' . _n('Associated item', 'Associated items', 2) . ''); - $query = "SELECT DISTINCT `itemtype` + $query = "SELECT DISTINCT `itemtype` FROM `glpi_plugin_services_services_items` WHERE `plugin_services_services_id` = '$ID' ORDER BY `itemtype`"; @@ -721,89 +766,95 @@ static function ItemsPdf(PluginPdfSimplePDF $pdf, PluginServicesService $item) { $number = $DB->numrows($result); if (Session::isMultiEntitiesMode()) { - $pdf->setColumnsSize(12,27,25,18,18); - - $pdf->displayTitle( ''.__('Type'), - __('Name'), - __('Entity'), - __('Serial number'), - __('Inventory number').''); + $pdf->setColumnsSize(12, 27, 25, 18, 18); + + $pdf->displayTitle('' . __('Type'), + __('Name'), + __('Entity'), + __('Serial number'), + __('Inventory number') . ''); } else { - $pdf->setColumnsSize(25,31,22,22); - $pdf->displayTitle(''.__('Type'), - __('Name'), - __('Serial number'), - __('Inventory number').''); + $pdf->setColumnsSize(25, 31, 22, 22); + $pdf->displayTitle('' . __('Type'), + __('Name'), + __('Serial number'), + __('Inventory number') . ''); } if (!$number) { $pdf->displayLine(__('No item found')); } else { - for ($i=0 ; $i < $number ; $i++) { - $type=$DB->result($result, $i, "itemtype"); + for ($i = 0; $i < $number; $i++) { + $type = $DB->result($result, $i, "itemtype"); if (!class_exists($type)) { continue; } if ($item->canView()) { - $column="name"; - $table = getTableForItemType($type); - $items = new $type(); - - $query = "SELECT `".$table."`.*, `glpi_entities`.`id` AS entity " - ." FROM `glpi_plugin_services_services_items`, `".$table - ."` LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `".$table."`.`entities_id`) " - ." WHERE `".$table."`.`id` = `glpi_plugin_services_services_items`.`items_id` + $dbu = new DbUtils(); + $column = "name"; + $table = $dbu->getTableForItemType($type); + $items = new $type(); + + $query = "SELECT `" . $table . "`.*, `glpi_entities`.`id` AS entity " + . " FROM `glpi_plugin_services_services_items`, `" . $table + . "` LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `" . $table . "`.`entities_id`) " + . " WHERE `" . $table . "`.`id` = `glpi_plugin_services_services_items`.`items_id` AND `glpi_plugin_services_services_items`.`itemtype` = '$type' AND `glpi_plugin_services_services_items`.`plugin_services_services_id` = '$ID' "; - if ($type!='User') - $query.= getEntitiesRestrictRequest(" AND ",$table,'','',$items->maybeRecursive()); + if ($type != 'User') { + $query .= $dbu->getEntitiesRestrictRequest(" AND ", $table, '', '', $items->maybeRecursive()); + } if ($items->maybeTemplate()) { - $query.=" AND `".$table."`.`is_template` = '0'"; + $query .= " AND `" . $table . "`.`is_template` = '0'"; } - $query.=" ORDER BY `glpi_entities`.`completename`, `".$table."`.`$column`"; - - if ($result_linked=$DB->query($query)) + $query .= " ORDER BY `glpi_entities`.`completename`, `" . $table . "`.`$column`"; + + if ($result_linked = $DB->query($query)) { if ($DB->numrows($result_linked)) { - - while ($data=$DB->fetch_assoc($result_linked)) { + + while ($data = $DB->fetch_assoc($result_linked)) { if (!$items->getFromDB($data["id"])) { continue; } - $items_id_display=""; - - if ($_SESSION["glpiis_ids_visible"]||empty($data["name"])) $items_id_display= " (".$data["id"].")"; - if ($type=='User') - $name=Html::clean(getUserName($data["id"])).$items_id_display; - else - $name=$data["name"].$items_id_display; - - if ($type!='User') { - $entity=Html::clean(Dropdown::getDropdownName("glpi_entities",$data['entity'])); - } else { - $entity="-"; - } - + $items_id_display = ""; + + if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) { + $items_id_display = " (" . $data["id"] . ")"; + } + if ($type == 'User') { + $name = Html::clean($dbu->getUserName($data["id"])) . $items_id_display; + } else { + $name = $data["name"] . $items_id_display; + } + + if ($type != 'User') { + $entity = Html::clean(Dropdown::getDropdownName("glpi_entities", $data['entity'])); + } else { + $entity = "-"; + } + if (Session::isMultiEntitiesMode()) { - $pdf->setColumnsSize(12,27,25,18,18); + $pdf->setColumnsSize(12, 27, 25, 18, 18); $pdf->displayLine( - $items->getTypeName(), - $name, - $entity, - (isset($data["serial"])? "".$data["serial"]."" :"-"), - (isset($data["otherserial"])? "".$data["otherserial"]."" :"-") - ); + $items->getTypeName(), + $name, + $entity, + (isset($data["serial"]) ? "" . $data["serial"] . "" : "-"), + (isset($data["otherserial"]) ? "" . $data["otherserial"] . "" : "-") + ); } else { - $pdf->setColumnsSize(25,31,22,22); + $pdf->setColumnsSize(25, 31, 22, 22); $pdf->displayTitle( - $items->getTypeName(), - $name, - (isset($data["serial"])? "".$data["serial"]."" :"-"), - (isset($data["otherserial"])? "".$data["otherserial"]."" :"-") - ); + $items->getTypeName(), + $name, + (isset($data["serial"]) ? "" . $data["serial"] . "" : "-"), + (isset($data["otherserial"]) ? "" . $data["otherserial"] . "" : "-") + ); } } // Each device } // numrows device + } } // type right } // each type } // numrows type @@ -816,27 +867,27 @@ static function ItemsPdf(PluginPdfSimplePDF $pdf, PluginServicesService $item) { * @param $pdf * @param $item * - **/ - static function PdfFromItems(PluginPdfSimplePDF $pdf, CommonGLPI $item){ - global $DB,$CFG_GLPI; + **/ + static function PdfFromItems(PluginPdfSimplePDF $pdf, CommonGLPI $item) { + global $DB; $pdf->setColumnsSize(100); - $pdf->displayTitle(''._n('Associated service','Associated services',2, 'services').''); + $pdf->displayTitle('' . _n('Associated web application', 'Associated web applications', 2, 'services') . ''); + + $ID = $item->getField('id'); + $itemtype = get_class($item); + $dbu = new DbUtils(); - $ID = $item->getField('id'); - $itemtype = get_Class($item); - $canread = $item->can($ID, READ); - $canedit = $item->can($ID, UPDATE); $web = new PluginServicesService(); $query = "SELECT `glpi_plugin_services_services`.* " - ." FROM `glpi_plugin_services_services_items`,`glpi_plugin_services_services` " - ." LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `glpi_plugin_services_services`.`entities_id`) " - ." WHERE `glpi_plugin_services_services_items`.`items_id` = '".$ID."' - AND `glpi_plugin_services_services_items`.`itemtype` = '".$itemtype."' + . " FROM `glpi_plugin_services_services_items`,`glpi_plugin_services_services` " + . " LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `glpi_plugin_services_services`.`entities_id`) " + . " WHERE `glpi_plugin_services_services_items`.`items_id` = '" . $ID . "' + AND `glpi_plugin_services_services_items`.`itemtype` = '" . $itemtype . "' AND `glpi_plugin_services_services_items`.`plugin_services_services_id` = `glpi_plugin_services_services`.`id` " - . getEntitiesRestrictRequest(" AND ","glpi_plugin_services_services",'','',$web->maybeRecursive()); - + . $dbu->getEntitiesRestrictRequest(" AND ", "glpi_plugin_services_services", '', '', $web->maybeRecursive()); + $result = $DB->query($query); $number = $DB->numrows($result); @@ -844,53 +895,54 @@ static function PdfFromItems(PluginPdfSimplePDF $pdf, CommonGLPI $item){ $pdf->displayLine(__('No item found')); } else { if (Session::isMultiEntitiesMode()) { - $pdf->setColumnsSize(25,25,15,15,20); - $pdf->displayTitle(''.__('Name'), - __('Entity'), - __('Technician in charge of the hardware'), - __('Group in charge of the hardware'), - PluginServicesServiceType::getTypeName(1).''); + $pdf->setColumnsSize(25, 25, 15, 15, 20); + $pdf->displayTitle('' . __('Name'), + __('Entity'), + __('Technician in charge of the hardware'), + __('Group in charge of the hardware'), + PluginServicesServiceType::getTypeName(1) . ''); } else { - $pdf->setColumnsSize(30,30,20,20); - $pdf->displayTitle(''.__('Name'), - __('Technician in charge of the hardware'), - __('Group in charge of the hardware'), - PluginServicesServiceType::getTypeName(1).''); + $pdf->setColumnsSize(30, 30, 20, 20); + $pdf->displayTitle('' . __('Name'), + __('Technician in charge of the hardware'), + __('Group in charge of the hardware'), + PluginServicesServiceType::getTypeName(1) . ''); } - while ($data=$DB->fetch_array($result)) { - $servicesID = $data["id"]; + while ($data = $DB->fetch_array($result)) { if (Session::isMultiEntitiesMode()) { - $pdf->setColumnsSize(25,25,15,15,20); - $pdf->displayLine($data["name"], - Html::clean(Dropdown::getDropdownName("glpi_entities", - $data['entities_id'])), - Html::clean(getUsername("glpi_users", $data["users_id_tech"])), - Html::clean(Dropdown::getDropdownName("glpi_groups", - $data["groups_id_tech"])), - Html::clean(Dropdown::getDropdownName("glpi_plugin_services_servicesupports", - $data["plugin_services_servicesupports_id"])), - Html::clean(Dropdown::getDropdownName("glpi_plugin_services_servicetypes", - $data["plugin_services_servicetypes_id"]))); + $pdf->setColumnsSize(25, 25, 15, 15, 20); + $pdf->displayLine($data["name"], + Html::clean(Dropdown::getDropdownName("glpi_entities", + $data['entities_id'])), + Html::clean($dbu->getUserName("glpi_users", $data["users_id_tech"])), + Html::clean(Dropdown::getDropdownName("glpi_groups", + $data["groups_id_tech"])), + Html::clean(Dropdown::getDropdownName("glpi_plugin_services_servicetypes", + $data["plugin_services_servicetypes_id"]))); } else { - $pdf->setColumnsSize(50,25,25); + $pdf->setColumnsSize(50, 25, 25); $pdf->displayLine( - $data["name"], - Html::clean(getUsername("glpi_users", $data["users_id_tech"])), - Html::clean(Dropdown::getDropdownName("glpi_groups", - $data["groups_id_tech"])), - Html::clean(Dropdown::getDropdownName("glpi_plugin_services_servicesupports", - $data["plugin_services_servicesupports_id"])), - Html::clean(Dropdown::getDropdownName("glpi_plugin_services_servicetypes", - $data["plugin_services_servicetypes_id"]))); + $data["name"], + Html::clean($dbu->getUserName("glpi_users", $data["users_id_tech"])), + Html::clean(Dropdown::getDropdownName("glpi_groups", $data["groups_id_tech"])), + Html::clean(Dropdown::getDropdownName("glpi_plugin_services_servicetypes", + $data["plugin_services_servicetypes_id"]))); } } } } -/* static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGLPI $item, $tab) { + /** + * @param PluginPdfSimplePDF $pdf + * @param CommonGLPI $item + * @param $tab + * + * @return bool + */ + static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGLPI $item, $tab) { - if ($item->getType()=='PluginServicesService') { + if ($item->getType() == 'PluginServicesService') { self::ItemsPdf($pdf, $item); } else if (in_array($item->getType(), PluginServicesService::getTypes(true))) { self::PdfFromItems($pdf, $item); @@ -898,7 +950,6 @@ static function PdfFromItems(PluginPdfSimplePDF $pdf, CommonGLPI $item){ return false; } return true; - } */ + } } -?> \ No newline at end of file diff --git a/inc/service_item.class.phpold b/inc/service_item.class.phpold new file mode 100644 index 0000000..5c9441a --- /dev/null +++ b/inc/service_item.class.phpold @@ -0,0 +1,909 @@ +. + -------------------------------------------------------------------------- + */ + +if (!defined('GLPI_ROOT')) { + die("Sorry. You can't access directly to this file"); +} + +class PluginServicesService_Item extends CommonDBRelation { + + // From CommonDBRelation + static public $itemtype_1 = 'PluginServicesService'; + static public $items_id_1 = 'plugin_services_services_id'; + static public $take_entity_1 = false ; + + static public $itemtype_2 = 'itemtype'; + static public $items_id_2 = 'items_id'; + static public $take_entity_2 = true ; + + static $rightname = "plugin_services"; + + static function cleanForItem(CommonDBTM $item) { + + $temp = new self(); + $temp->deleteByCriteria( + array('itemtype' => $item->getType(), + 'items_id' => $item->getField('id')) + ); + } + + function getTabNameForItem(CommonGLPI $item, $withtemplate=0) { + + if (!$withtemplate) { + if ($item->getType()=='PluginServicesService' + && count(PluginServicesService::getTypes(false))) { + if ($_SESSION['glpishow_count_on_tabs']) { + return self::createTabEntry(_n('Associated item','Associated items',2), self::countForService($item)); + } + return _n('Associated item','Associated items',2); + + } else if (in_array($item->getType(), PluginServicesService::getTypes(true)) + && Session::haveRight("plugin_services", READ)) { + if ($_SESSION['glpishow_count_on_tabs']) { + return self::createTabEntry(PluginServicesService::getTypeName(2), self::countForItem($item)); + } + return PluginServicesService::getTypeName(2); + } + } + return ''; + } + + + static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) { + + if ($item->getType()=='PluginServicesService') { + + self::showForService($item); + + } else if (in_array($item->getType(), PluginServicesService::getTypes(true))) { + + self::showForItem($item); + + } + return true; + } + + static function countForService(PluginServicesService $item) { + + $types = implode("','", $item->getTypes()); + if (empty($types)) { + return 0; + } + return countElementsInTable('glpi_plugin_services_services_items', + "`itemtype` IN ('$types') + AND `plugin_services_services_id` = '".$item->getID()."'"); + } + + + static function countForItem(CommonDBTM $item) { + + return countElementsInTable('glpi_plugin_services_services_items', + "`itemtype`='".$item->getType()."' + AND `items_id` = '".$item->getID()."'"); + } + + function getFromDBbyServicesAndItem($plugin_services_services_id, + $items_id,$itemtype) { + global $DB; + + $query = "SELECT * + FROM `".$this->getTable()."` + WHERE `plugin_services_services_id` + = '" . $plugin_services_services_id . "' + AND `itemtype` = '" . $itemtype . "' + AND `items_id` = '" . $items_id . "'"; + + if ($result = $DB->query($query)) { + if ($DB->numrows($result) != 1) { + return false; + } + $this->fields = $DB->fetch_assoc($result); + if (is_array($this->fields) && count($this->fields)) { + return true; + } + } + return false; + } + + function addItem($values) { + + $this->add(array('plugin_services_services_id' + =>$values["plugin_services_services_id"], + 'items_id'=>$values["items_id"], + 'itemtype'=>$values["itemtype"])); + + } + + + + function deleteItemByServicesAndItem($plugin_services_services_id, + $items_id, $itemtype) { + + if ($this->getFromDBbyServicesAndItem($plugin_services_services_id, + $items_id,$itemtype)) { + $this->delete(array('id' => $this->fields["id"])); + } + } + + + /** + * Show items links to a service + * + * @since version 0.84 + * + * @param $PluginServicesService PluginServicesService object + * + * @return nothing (HTML display) + **/ + static function showForService(PluginServicesService $service) { + global $DB, $CFG_GLPI; + + $instID = $service->fields['id']; + if (!$service->can($instID, READ)) { + return false; + } + $canedit = $service->can($instID, UPDATE); + + $query = "SELECT DISTINCT `itemtype` + FROM `glpi_plugin_services_services_items` + WHERE `plugin_services_services_id` = '$instID' + ORDER BY `itemtype` "; + + $result = $DB->query($query); + $number = $DB->numrows($result); + $rand = mt_rand(); + + if ($canedit) { + echo "
"; + echo ""; + + echo ""; + echo ""; + + echo ""; + echo "
".__('Add an item')."
"; + /*Dropdown::showAllItems("items_id", 0, 0, + ($service->fields['is_recursive']?-1:$service->fields['entities_id']), + PluginServicesService::getTypes(), false, true); + ($service->fields['is_recursive']?-1:$service->fields['entities_id']),*/ + Dropdown::showSelectItemFromItemtypes(['itemtypes' => PluginServicesService::getTypes(), + 'entity_restrict'=> ($service->fields['is_recursive']?-1:$service->fields['entities_id']), + 'checkright' => true]); + + echo ""; + echo ""; + echo ""; + echo "
"; + Html::closeForm(); + echo "
"; + } + + echo "
"; + if ($canedit && $number) { + Html::openMassiveActionsForm('mass'.__CLASS__.$rand); + $massiveactionparams = array(); + Html::showMassiveActions($massiveactionparams); + } + echo ""; + echo ""; + + if ($canedit && $number) { + echo ""; + } + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + for ($i=0 ; $i < $number ; $i++) { + $itemtype=$DB->result($result, $i, "itemtype"); + if (!($item = getItemForItemtype($itemtype))) { + continue; + } + + if ($item->canView()) { + $column = "name"; + if ($itemtype == 'Ticket') { + $column = "id"; + } + + $itemtable = getTableForItemType($itemtype); + $query = "SELECT `$itemtable`.*, + `glpi_plugin_services_services_items`.`id` AS IDD, "; + + if ($itemtype == 'KnowbaseItem') { + $query .= "-1 AS entity + FROM `glpi_plugin_services_services_items`, `$itemtable` + ".KnowbaseItem::addVisibilityJoins()." + WHERE `$itemtable`.`id` = `glpi_plugin_services_services_items`.`items_id` + AND "; + } else { + $query .= "`glpi_entities`.`id` AS entity + FROM `glpi_plugin_services_services_items`, `$itemtable` "; + + if ($itemtype !='Entity') { + $query .= "LEFT JOIN `glpi_entities` + ON (`glpi_entities`.`id` = `$itemtable`.`entities_id`) "; + } + $query .= "WHERE `$itemtable`.`id` = `glpi_plugin_services_services_items`.`items_id` + AND "; + } + $query .= "`glpi_plugin_services_services_items`.`itemtype` = '$itemtype' + AND `glpi_plugin_services_services_items`.`plugin_services_services_id` = '$instID' "; + + if ($itemtype =='KnowbaseItem') { + if (Session::getLoginUserID()) { + $where = "AND ".KnowbaseItem::addVisibilityRestrict(); + } else { + // Anonymous access + if (Session::isMultiEntitiesMode()) { + $where = " AND (`glpi_entities_knowbaseitems`.`entities_id` = '0' + AND `glpi_entities_knowbaseitems`.`is_recursive` = '1')"; + } + } + } else { + $query .= getEntitiesRestrictRequest(" AND ", $itemtable, '', '', + $item->maybeRecursive()); + } + + if ($item->maybeTemplate()) { + $query .= " AND `$itemtable`.`is_template` = '0'"; + } + + if ($itemtype == 'KnowbaseItem') { + $query .= " ORDER BY `$itemtable`.`$column`"; + } else { + $query .= " ORDER BY `glpi_entities`.`completename`, `$itemtable`.`$column`"; + } + + if ($itemtype == 'SoftwareLicense') { + $soft = new Software(); + } + + if ($result_linked = $DB->query($query)) { + if ($DB->numrows($result_linked)) { + + while ($data = $DB->fetch_assoc($result_linked)) { + + if ($itemtype == 'Ticket') { + $data["name"] = sprintf(__('%1$s: %2$s'), __('Ticket'), $data["id"]); + } + + if ($itemtype == 'SoftwareLicense') { + $soft->getFromDB($data['softwares_id']); + $data["name"] = sprintf(__('%1$s - %2$s'), $data["name"], + $soft->fields['name']); + } + $linkname = $data["name"]; + if ($_SESSION["glpiis_ids_visible"] + || empty($data["name"])) { + $linkname = sprintf(__('%1$s (%2$s)'), $linkname, $data["id"]); + } + + $link = Toolbox::getItemTypeFormURL($itemtype); + $name = "".$linkname.""; + + echo ""; + + if ($canedit) { + echo ""; + } + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + } + } + } + } + echo "
".Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand)."".__('Type')."".__('Name')."".__('Entity')."".__('Serial number')."".__('Inventory number')."
"; + Html::showMassiveActionCheckBox(__CLASS__, $data["IDD"]); + echo "".$item->getTypeName(1)."".$name."".Dropdown::getDropdownName("glpi_entities", + $data['entity']); + echo "". + (isset($data["serial"])? "".$data["serial"]."" :"-")."". + (isset($data["otherserial"])? "".$data["otherserial"]."" :"-")."
"; + if ($canedit && $number) { + $paramsma['ontop'] =false; + Html::showMassiveActions($paramsma); + Html::closeForm(); + } + echo "
"; + + } + + /** + * Show services associated to an item + * + * @since version 0.84 + * + * @param $item CommonDBTM object for which associated services must be displayed + * @param $withtemplate (default '') + **/ + static function showForItem(CommonDBTM $item, $withtemplate='') { + global $DB, $CFG_GLPI; + + $ID = $item->getField('id'); + + if ($item->isNewID($ID)) { + return false; + } + if (!Session::haveRight("plugin_services", READ)) { + return false; + } + + if (!$item->can($item->fields['id'],READ)) { + return false; + } + + if (empty($withtemplate)) { + $withtemplate = 0; + } + + $canedit = $item->canadditem('PluginServicesService'); + $rand = mt_rand(); + $is_recursive = $item->isRecursive(); + + $query = "SELECT `glpi_plugin_services_services_items`.`id` AS assocID, + `glpi_entities`.`id` AS entity, + `glpi_plugin_services_services`.`name` AS assocName, + `glpi_plugin_services_services`.* + FROM `glpi_plugin_services_services_items` + LEFT JOIN `glpi_plugin_services_services` + ON (`glpi_plugin_services_services_items`.`plugin_services_services_id`=`glpi_plugin_services_services`.`id`) + LEFT JOIN `glpi_entities` ON (`glpi_plugin_services_services`.`entities_id`=`glpi_entities`.`id`) + WHERE `glpi_plugin_services_services_items`.`items_id` = '$ID' + AND `glpi_plugin_services_services_items`.`itemtype` = '".$item->getType()."' "; + + $query .= getEntitiesRestrictRequest(" AND","glpi_plugin_services_services",'','',true); + + $query .= " ORDER BY `assocName`"; + + $result = $DB->query($query); + $number = $DB->numrows($result); + $i = 0; + + $webs = array(); + $web = new PluginServicesService(); + $used = array(); + if ($numrows = $DB->numrows($result)) { + while ($data = $DB->fetch_assoc($result)) { + $webs[$data['assocID']] = $data; + $used[$data['id']] = $data['id']; + } + } + + if ($canedit && $withtemplate < 2) { + // Restrict entity for knowbase + $entities = ""; + $entity = $_SESSION["glpiactive_entity"]; + + if ($item->isEntityAssign()) { + /// Case of personal items : entity = -1 : create on active entity (Reminder case)) + if ($item->getEntityID() >=0 ) { + $entity = $item->getEntityID(); + } + + if ($item->isRecursive()) { + $entities = getSonsOf('glpi_entities',$entity); + } else { + $entities = $entity; + } + } + $limit = getEntitiesRestrictRequest(" AND ","glpi_plugin_services_services",'',$entities,true); + $q = "SELECT COUNT(*) + FROM `glpi_plugin_services_services` + WHERE `is_deleted` = '0' + $limit"; + + $result = $DB->query($q); + $nb = $DB->result($result,0,0); + + echo "
"; + + + if (Session::haveRight("plugin_services", READ) + && ($nb > count($used))) { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "
"; + echo ""; + echo ""; + echo ""; + echo ""; + if ($item->getType() == 'Ticket') { + echo ""; + } + + PluginServicesService::dropdownService(array('entity' => $entities , + 'used' => $used)); + echo ""; + echo ""; + echo "
"; + Html::closeForm(); + } + + echo "
"; + } + + echo "
"; + if ($canedit && $number && ($withtemplate < 2)) { + Html::openMassiveActionsForm('mass'.__CLASS__.$rand); + $massiveactionparams = array('num_displayed' => $number); + Html::showMassiveActions($massiveactionparams); + } + echo ""; + + echo ""; + if ($canedit && $number && ($withtemplate < 2)) { + echo ""; + } + echo ""; + if (Session::isMultiEntitiesMode()) { + echo ""; + } + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + $used = array(); + + if ($number) { + + Session::initNavigateListItems('PluginServicesService', + //TRANS : %1$s is the itemtype name, + // %2$s is the name of the item (used for headings of a list) + sprintf(__('%1$s = %2$s'), + $item->getTypeName(1), $item->getName())); + + + foreach ($webs as $data) { + $webID = $data["id"]; + $link = NOT_AVAILABLE; + + if ($web->getFromDB($webID)) { + $link = $web->getLink(); + } + + Session::addToNavigateListItems('PluginServicesService', $webID); + + $used[$webID] = $webID; + $assocID = $data["assocID"]; + + echo ""; + if ($canedit && ($withtemplate < 2)) { + echo ""; + } + echo ""; + if (Session::isMultiEntitiesMode()) { + echo ""; + } + echo ""; + echo ""; + + $link = Toolbox::substr($data["address"],0,30)."..."; + echo ""; + +/* echo ""; */ + echo ""; + echo ""; + echo ""; + echo ""; + $i++; + } + } + + + echo "
".Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand)."".__('Name')."".__('Entity')."".PluginServicesServiceType::getTypeName(1)."".PluginServicesServiceSupport::getTypeName(1)."".__('URL')."".__('Server')."".__('Language')."".__('Distribution List')."".__('Comments')."
"; + Html::showMassiveActionCheckBox(__CLASS__, $data["assocID"]); + echo "$link".Dropdown::getDropdownName("glpi_entities", $data['entities_id']). + "".Dropdown::getDropdownName("glpi_plugin_services_servicetypes", + $data["plugin_services_servicetypes_id"]). + "".Dropdown::getDropdownName("glpi_plugin_services_servicesupports", + $data["plugin_services_servicesupports_id"]). + "". + "". + "".$link."".Dropdown::getDropdownName("glpi_plugin_services_serviceservertypes", + $data["plugin_services_serviceservertypes_id"]). + "".Dropdown::getDropdownName("glpi_plugin_services_servicetiers", + $data["plugin_services_servicetiers_id"]). + "".$data["dist_list"]."".$data["comment"]."
"; + if ($canedit && $number && ($withtemplate < 2)) { + $massiveactionparams['ontop'] = false; + Html::showMassiveActions($massiveactionparams); + Html::closeForm(); + } + echo "
"; + } + + /** + * @since version 0.84 + **/ + function getForbiddenStandardMassiveAction() { + + $forbidden = parent::getForbiddenStandardMassiveAction(); + $forbidden[] = 'update'; + return $forbidden; + } + + /** + * Show services associated to an item + * + * @since version 0.84 + * + * @param $item Supplier object for which associated services must be displayed + * @param $withtemplate (default '') + **/ + static function showForSupplier(Supplier $item, $withtemplate='') { + global $DB, $CFG_GLPI; + + $ID = $item->getField('id'); + + if ($item->isNewID($ID)) { + return false; + } + if (!Session::haveRight("plugin_services", READ)) { + return false; + } + + if (!$item->can($item->fields['id'], READ)) { + return false; + } + + if (empty($withtemplate)) { + $withtemplate = 0; + } + + $rand = mt_rand(); + $is_recursive = $item->isRecursive(); + + $query = "SELECT `glpi_entities`.`id` AS entity, + `glpi_plugin_services_services`.`id` AS assocID, + `glpi_plugin_services_services`.`name` AS assocName, + `glpi_plugin_services_services`.* + FROM `glpi_plugin_services_services` + LEFT JOIN `glpi_entities` ON (`glpi_plugin_services_services`.`entities_id`=`glpi_entities`.`id`) + WHERE `glpi_plugin_services_services`.`suppliers_id` = '$ID' "; + + $query .= getEntitiesRestrictRequest(" AND","glpi_plugin_services_services",'','',true); + + $query .= " ORDER BY `assocName`"; + + $result = $DB->query($query); + $number = $DB->numrows($result); + $i = 0; + + $webs = array(); + if ($numrows = $DB->numrows($result)) { + while ($data = $DB->fetch_assoc($result)) { + $webs[$data['assocID']] = $data; + } + } + + echo "
"; + echo ""; + + echo ""; + echo ""; + if (Session::isMultiEntitiesMode()) + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + $used = array(); + + if ($number) { + + Session::initNavigateListItems('PluginServicesService', + //TRANS : %1$s is the itemtype name, + // %2$s is the name of the item (used for headings of a list) + sprintf(__('%1$s = %2$s'), + $item->getTypeName(1), $item->getName())); + + $web = new PluginServicesService(); + + foreach ($webs as $data) { + $webID = $data["id"]; + $link = NOT_AVAILABLE; + + if ($web->getFromDB($webID)) { + $link = $web->getLink(); + } + + Session::addToNavigateListItems('PluginServicesService', $webID); + + $assocID = $data["assocID"]; + + echo ""; + echo ""; + if (Session::isMultiEntitiesMode()) { + echo ""; + } + echo ""; + + echo ""; + + $link = Toolbox::substr($data["address"],0,30)."..."; + echo ""; + +/* echo ""; */ + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + $i++; + } + } + + + echo "
".__('Name')."".__('Entity')."".PluginServicesServiceType::getTypeName(1)."".PluginServicesServiceSupport::getTypeName(1)."".__('URL')."".__('Server')."".__('Language')."".__('Version')."".__('Comments')."
$link".Dropdown::getDropdownName("glpi_entities", $data['entities_id']). + "".Dropdown::getDropdownName("glpi_plugin_services_servicetypes", + $data["plugin_services_servicetypes_id"]). + "".Dropdown::getDropdownName("glpi_plugin_services_servicesupports", + $data["plugin_services_servicesupports_id"]). + "". + "". + "".$link."".Dropdown::getDropdownName("glpi_plugin_services_serviceservertypes", + $data["plugin_services_serviceservertypes_id"]). + "".Dropdown::getDropdownName("glpi_plugin_services_servicetiers", + $data["plugin_services_servicetiers_id"]). + "".Html::convdate($data["date_query"])."".$data["Distribution List"]."".$data["comment"]."
"; + echo "
"; + } + + + static function ItemsPdf(PluginPdfSimplePDF $pdf, PluginServicesService $item) { + global $DB,$CFG_GLPI; + + $ID = $item->getField('id'); + + if (!$item->can($ID, READ)) { + return false; + } + + if (!Session::haveRight("plugin_services", READ)) { + return false; + } + + $pdf->setColumnsSize(100); + $pdf->displayTitle(''._n('Associated item','Associated items',2).''); + + $query = "SELECT DISTINCT `itemtype` + FROM `glpi_plugin_services_services_items` + WHERE `plugin_services_services_id` = '$ID' + ORDER BY `itemtype`"; + $result = $DB->query($query); + $number = $DB->numrows($result); + + if (Session::isMultiEntitiesMode()) { + $pdf->setColumnsSize(12,27,25,18,18); + + $pdf->displayTitle( ''.__('Type'), + __('Name'), + __('Entity'), + __('Serial number'), + __('Inventory number').''); + } else { + $pdf->setColumnsSize(25,31,22,22); + $pdf->displayTitle(''.__('Type'), + __('Name'), + __('Serial number'), + __('Inventory number').''); + } + + if (!$number) { + $pdf->displayLine(__('No item found')); + } else { + for ($i=0 ; $i < $number ; $i++) { + $type=$DB->result($result, $i, "itemtype"); + if (!class_exists($type)) { + continue; + } + if ($item->canView()) { + $column="name"; + $table = getTableForItemType($type); + $items = new $type(); + + $query = "SELECT `".$table."`.*, `glpi_entities`.`id` AS entity " + ." FROM `glpi_plugin_services_services_items`, `".$table + ."` LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `".$table."`.`entities_id`) " + ." WHERE `".$table."`.`id` = `glpi_plugin_services_services_items`.`items_id` + AND `glpi_plugin_services_services_items`.`itemtype` = '$type' + AND `glpi_plugin_services_services_items`.`plugin_services_services_id` = '$ID' "; + if ($type!='User') + $query.= getEntitiesRestrictRequest(" AND ",$table,'','',$items->maybeRecursive()); + + if ($items->maybeTemplate()) { + $query.=" AND `".$table."`.`is_template` = '0'"; + } + $query.=" ORDER BY `glpi_entities`.`completename`, `".$table."`.`$column`"; + + if ($result_linked=$DB->query($query)) + if ($DB->numrows($result_linked)) { + + while ($data=$DB->fetch_assoc($result_linked)) { + if (!$items->getFromDB($data["id"])) { + continue; + } + $items_id_display=""; + + if ($_SESSION["glpiis_ids_visible"]||empty($data["name"])) $items_id_display= " (".$data["id"].")"; + if ($type=='User') + $name=Html::clean(getUserName($data["id"])).$items_id_display; + else + $name=$data["name"].$items_id_display; + + if ($type!='User') { + $entity=Html::clean(Dropdown::getDropdownName("glpi_entities",$data['entity'])); + } else { + $entity="-"; + } + + if (Session::isMultiEntitiesMode()) { + $pdf->setColumnsSize(12,27,25,18,18); + $pdf->displayLine( + $items->getTypeName(), + $name, + $entity, + (isset($data["serial"])? "".$data["serial"]."" :"-"), + (isset($data["otherserial"])? "".$data["otherserial"]."" :"-") + ); + } else { + $pdf->setColumnsSize(25,31,22,22); + $pdf->displayTitle( + $items->getTypeName(), + $name, + (isset($data["serial"])? "".$data["serial"]."" :"-"), + (isset($data["otherserial"])? "".$data["otherserial"]."" :"-") + ); + } + } // Each device + } // numrows device + } // type right + } // each type + } // numrows type + } + + + /** + * show for PDF the services associated with a device + * + * @param $pdf + * @param $item + * + **/ + static function PdfFromItems(PluginPdfSimplePDF $pdf, CommonGLPI $item){ + global $DB,$CFG_GLPI; + + $pdf->setColumnsSize(100); + $pdf->displayTitle(''._n('Associated service','Associated services',2, 'services').''); + + $ID = $item->getField('id'); + $itemtype = get_Class($item); + $canread = $item->can($ID, READ); + $canedit = $item->can($ID, UPDATE); + $web = new PluginServicesService(); + + $query = "SELECT `glpi_plugin_services_services`.* " + ." FROM `glpi_plugin_services_services_items`,`glpi_plugin_services_services` " + ." LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `glpi_plugin_services_services`.`entities_id`) " + ." WHERE `glpi_plugin_services_services_items`.`items_id` = '".$ID."' + AND `glpi_plugin_services_services_items`.`itemtype` = '".$itemtype."' + AND `glpi_plugin_services_services_items`.`plugin_services_services_id` = `glpi_plugin_services_services`.`id` " + . getEntitiesRestrictRequest(" AND ","glpi_plugin_services_services",'','',$web->maybeRecursive()); + + $result = $DB->query($query); + $number = $DB->numrows($result); + + if (!$number) { + $pdf->displayLine(__('No item found')); + } else { + if (Session::isMultiEntitiesMode()) { + $pdf->setColumnsSize(25,25,15,15,20); + $pdf->displayTitle(''.__('Name'), + __('Entity'), + __('Technician in charge of the hardware'), + __('Group in charge of the hardware'), + PluginServicesServiceType::getTypeName(1).''); + } else { + $pdf->setColumnsSize(30,30,20,20); + $pdf->displayTitle(''.__('Name'), + __('Technician in charge of the hardware'), + __('Group in charge of the hardware'), + PluginServicesServiceType::getTypeName(1).''); + } + while ($data=$DB->fetch_array($result)) { + $servicesID = $data["id"]; + + if (Session::isMultiEntitiesMode()) { + $pdf->setColumnsSize(25,25,15,15,20); + $pdf->displayLine($data["name"], + Html::clean(Dropdown::getDropdownName("glpi_entities", + $data['entities_id'])), + Html::clean(getUsername("glpi_users", $data["users_id_tech"])), + Html::clean(Dropdown::getDropdownName("glpi_groups", + $data["groups_id_tech"])), + Html::clean(Dropdown::getDropdownName("glpi_plugin_services_servicesupports", + $data["plugin_services_servicesupports_id"])), + Html::clean(Dropdown::getDropdownName("glpi_plugin_services_servicetypes", + $data["plugin_services_servicetypes_id"]))); + } else { + $pdf->setColumnsSize(50,25,25); + $pdf->displayLine( + $data["name"], + Html::clean(getUsername("glpi_users", $data["users_id_tech"])), + Html::clean(Dropdown::getDropdownName("glpi_groups", + $data["groups_id_tech"])), + Html::clean(Dropdown::getDropdownName("glpi_plugin_services_servicesupports", + $data["plugin_services_servicesupports_id"])), + Html::clean(Dropdown::getDropdownName("glpi_plugin_services_servicetypes", + $data["plugin_services_servicetypes_id"]))); + } + } + } + } + +/* static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGLPI $item, $tab) { + + if ($item->getType()=='PluginServicesService') { + self::ItemsPdf($pdf, $item); + } else if (in_array($item->getType(), PluginServicesService::getTypes(true))) { + self::PdfFromItems($pdf, $item); + } else { + return false; + } + return true; + } */ + +} +?> diff --git a/inc/servicedrsolutiontype.class.php b/inc/servicedrsolutiontype.class.php new file mode 100644 index 0000000..515c7c5 --- /dev/null +++ b/inc/servicedrsolutiontype.class.php @@ -0,0 +1,44 @@ +. + -------------------------------------------------------------------------- + */ + +if (!defined('GLPI_ROOT')) { + die("Sorry. You can't access directly to this file"); +} + +class PluginServicesServiceDrSolutionType extends CommonDropdown { + + static $rightname = "plugin_services"; + var $can_be_translated = true; + + static function getTypeName($nb=0) { + + return _n('DR Solution Types', 'DR Solution Type', $nb, 'DR Solution Type'); + } +} +?> \ No newline at end of file diff --git a/inc/servicedrtesttype.class.php b/inc/servicedrtesttype.class.php new file mode 100644 index 0000000..f779c36 --- /dev/null +++ b/inc/servicedrtesttype.class.php @@ -0,0 +1,44 @@ +. + -------------------------------------------------------------------------- + */ + +if (!defined('GLPI_ROOT')) { + die("Sorry. You can't access directly to this file"); +} + +class PluginServicesServiceDrTestType extends CommonDropdown { + + static $rightname = "plugin_services"; + var $can_be_translated = true; + + static function getTypeName($nb=0) { + + return _n('DR Testtype', 'DR Testtypes', $nb, 'DR TestType'); + } +} +?> \ No newline at end of file diff --git a/inc/serviceitowner.class.php b/inc/serviceitowner.class.php new file mode 100644 index 0000000..0b827a2 --- /dev/null +++ b/inc/serviceitowner.class.php @@ -0,0 +1,74 @@ +. + -------------------------------------------------------------------------- + */ + +if (!defined('GLPI_ROOT')) { + die("Sorry. You can't access directly to this file"); +} + +// Class for a Dropdown +class PluginServicesServiceitowner extends CommonDropdown { + + static $rightname = "plugin_services"; + var $can_be_translated = true; + + static function getTypeName($nb=0) { + + return _n('Product Owners','Product Owner',$nb, 'Product Owner'); + } + + static function transfer($ID, $entity) { + global $DB; + + if ($ID>0) { + // Not already transfer + // Search init item + $query = "SELECT * FROM `glpi_plugin_services_services` + WHERE `id` = '$ID'"; + + if ($result=$DB->query($query)) { + if ($DB->numrows($result)) { + $data = $DB->fetch_assoc($result); + $data = Toolbox::addslashes_deep($data); + $input['users_id_itowner'] = $data['users_id_itowner']; + $input['entities_id'] = $entity; + $temp = new self(); + $newID = $temp->getID($input); + + if ($newID<0) { + $newID = $temp->import($input); + } + + return $newID; + } + } + } + return 0; + } +} +?> \ No newline at end of file diff --git a/inc/servicesupport.class.php b/inc/servicesupport.class.php index 241b16b..35d75dd 100644 --- a/inc/servicesupport.class.php +++ b/inc/servicesupport.class.php @@ -39,7 +39,7 @@ class PluginServicesServiceSupport extends CommonDropdown { static function getTypeName($nb=0) { - return _n('Support Period','Support Periods',$nb, 'Support Periods'); + return _n('Service Support Level','Services Support Level',$nb, 'Services Support Level'); } static function transfer($ID, $entity) { diff --git a/locales/en_GB.mo b/locales/en_GB.mo new file mode 100644 index 0000000..c587bf2 Binary files /dev/null and b/locales/en_GB.mo differ diff --git a/locales/en_GB.po b/locales/en_GB.po new file mode 100644 index 0000000..4063966 --- /dev/null +++ b/locales/en_GB.po @@ -0,0 +1,57 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR Services Development Team +# This file is distributed under the same license as the PACKAGE package. +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: GLPI Project - services plugin\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-02-19 15:53+0100\n" +"PO-Revision-Date: 2013-11-20 09:39+0000\n" +"Last-Translator: Xavier CAILLAUD \n" +"Language-Team: English (United Kingdom) (http://www.transifex.com/projects/p/GLPI_services/language/en_GB/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: en_GB\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: hook.php:356 inc/service_item.class.php:413 +msgid "Associate a web application" +msgstr "Associate a TC application" + +#: setup.php:131 inc/service.class.php:43 +msgid "Web application" +msgid_plural "Web applications" +msgstr[0] "TC application" +msgstr[1] "TC applications" + +#: setup.php:145 +msgid "This plugin requires GLPI >= 0.84" +msgstr "This plugin requires GLPI >= 0.84" + +#: inc/profile.class.php:37 inc/profile.class.php:133 +msgid "Rights management" +msgstr "Rights management" + +#: inc/service.class.php:154 inc/service.class.php:331 +msgid "Backoffice URL" +msgstr "Sharepoint URL" + +#: inc/service.class.php:167 inc/service.class.php:310 +#: inc/service.class.php:455 +msgid "Editor" +msgstr "Editor" + +#: inc/service_item.class.php:763 +msgid "Associated web application" +msgid_plural "Associated web applications" +msgstr[0] "Associated TC application" +msgstr[1] "Associated TC applications" + +#: inc/servicetype.class.php:39 +msgid "Category" +msgid_plural "Categories" +msgstr[0] "Category" +msgstr[1] "Categories" diff --git a/locales/fr_FR.mo b/locales/fr_FR.mo new file mode 100644 index 0000000..b81cccc Binary files /dev/null and b/locales/fr_FR.mo differ diff --git a/locales/fr_FR.po b/locales/fr_FR.po new file mode 100644 index 0000000..0d3d31e --- /dev/null +++ b/locales/fr_FR.po @@ -0,0 +1,65 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR Services Development Team +# This file is distributed under the same license as the PACKAGE package. +# +# Translators: +# Xavier CAILLAUD , 2012 +# Xavier CAILLAUD , 2013 +msgid "" +msgstr "" +"Project-Id-Version: GLPI Project - services plugin\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-02-19 15:53+0100\n" +"PO-Revision-Date: 2013-11-20 09:39+0000\n" +"Last-Translator: Xavier CAILLAUD \n" +"Language-Team: French (France) (http://www.transifex.com/projects/p/GLPI_services/language/fr_FR/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: fr_FR\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#: hook.php:356 inc/service_item.class.php:413 +msgid "Associate a web application" +msgstr "Associer une application TC" + +#: setup.php:131 inc/service.class.php:43 +msgid "Web application" +msgid_plural "Web applications" +msgstr[0] "Application TC" +msgstr[1] "Applications TC" + +#: setup.php:145 +msgid "This plugin requires GLPI >= 0.84" +msgstr " Ce plugin nécessite GLPI >= 0.84" + +#: inc/profile.class.php:37 inc/profile.class.php:133 +msgid "Rights management" +msgstr "Gestion des droits" + +#: inc/service.class.php:154 inc/service.class.php:331 +msgid "Backoffice URL" +msgstr "URL Sharepoint" + +#: inc/service.class.php:167 inc/service.class.php:310 +#: inc/service.class.php:455 +msgid "Editor" +msgstr "Manufacturier " + +#: inc/service_item.class.php:763 +msgid "Associated web application" +msgid_plural "Associated web applications" +msgstr[0] "Application TC associée" +msgstr[1] "Applications TC associées" + +#: inc/servicetechnic.class.php:38 +msgid "Language of treatment" +msgid_plural "Languages of treatment" +msgstr[0] "Site Principal" +msgstr[1] "Sites Principal" + +#: inc/servicetype.class.php:39 +msgid "Category" +msgid_plural "Categories" +msgstr[0] "Catégorie" +msgstr[1] "Catégories" diff --git a/locales/glpi.pot b/locales/glpi.pot index fc68dc3..d0b9059 100644 --- a/locales/glpi.pot +++ b/locales/glpi.pot @@ -19,13 +19,13 @@ msgstr "" "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" #: hook.php:403 inc/service_item.class.php:454 -msgid "Associate an ITIL Service" +msgid "Associate an TC Service" msgstr "" #: setup.php:99 inc/menu.class.php:35 inc/profile.class.php:146 #: inc/service.class.php:45 -msgid "ITIL Service" -msgid_plural "ITIL Services" +msgid "TC Service" +msgid_plural "TC Services" msgstr[0] "" msgstr[1] "" @@ -43,8 +43,8 @@ msgid "Editor" msgstr "" #: inc/service_item.class.php:814 -msgid "Associated ITIL Service" -msgid_plural "Associated ITIL Services" +msgid "Associated TC Service" +msgid_plural "Associated TC Services" msgstr[0] "" msgstr[1] "" diff --git a/services.xml b/services.xml index a950f58..cfa8674 100644 --- a/services.xml +++ b/services.xml @@ -1,49 +1,49 @@ - - - ITIL Services - service - stable - https://raw.githubusercontent.com/bacus99/Services/master/screenshots/services.png - - - - - - /plugins/services` directory - * Navigate to the Configuration > Plugins page, - * Install and activate the plugin. - -]]> - - - https://github.com/bacus99/Services - https://github.com/bacus99/Services/releases - https://github.com/bacus99/Services/issues - https://github.com/bacus99/Services/wiki - - Christian Bernard, based on WebServices plugin - - - - 1.3.1 - 9.2.4 - - - - en_GB - - - - - ITIL - Services - PHP - Disaster recovery informations - Owners - - - + + + TC Services + service + stable + https://raw.githubusercontent.com/bacus99/Services/screeshots/services.png + + + + + + /plugins/services` directory + * Navigate to the Configuration > Plugins page, + * Install and activate the plugin. + +]]> + + + https://github.com/bacus99/Services + https://github.com/bacus99/Services/releases + https://github.com/bacus99/Services/issues + https://github.com/bacus99/Services/wiki + + Christian Bernard, Transcontinental + + + + 1.3.1 + 9.5.5 + + + + en_GB + + + + + TC + Services + PHP + Disaster recovery informations + Owners + + + diff --git a/setup.php b/setup.php index 3f2936d..f404f51 100644 --- a/setup.php +++ b/setup.php @@ -3,24 +3,18 @@ ------------------------------------------------------------------------- GLPI - Gestionnaire Libre de Parc Informatique Copyright (C) 2003-2011 by the INDEPNET Development Team. - http://indepnet.net/ http://glpi-project.org ------------------------------------------------------------------------- - LICENSE - This file is part of GLPI. - GLPI is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - GLPI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License along with GLPI. If not, see . -------------------------------------------------------------------------- @@ -150,4 +144,4 @@ function plugin_services_check_config() { return false; } -?> +?> \ No newline at end of file diff --git a/sql/empty-1.0.0.sql b/sql/empty-1.0.0.sql index 5497823..cd245af 100644 --- a/sql/empty-1.0.0.sql +++ b/sql/empty-1.0.0.sql @@ -1,120 +1,189 @@ --- Table structure for table `glpi_plugin_services_servicetypes` +DROP TABLE IF EXISTS `glpi_plugin_services_servicebuspriorities`; +-- +-- Table structure for table `glpi_plugin_services_servicebuspriorities` -- -CREATE TABLE IF NOT EXISTS `glpi_plugin_services_servicetypes` ( +CREATE TABLE IF NOT EXISTS `glpi_plugin_services_servicebuspriorities` ( `id` int(11) NOT NULL, - `entities_id` int(11) NOT NULL DEFAULT '0', `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `comment` text COLLATE utf8_unicode_ci -) ENGINE=MyISAM AUTO_INCREMENT=141 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; --- Indexes for table `glpi_plugin_services_servicetypes` -- -ALTER TABLE `glpi_plugin_services_servicetypes` - ADD PRIMARY KEY (`id`), - ADD KEY `name` (`name`), - ADD KEY `entities_id` (`entities_id`); +-- Dumping data for table `glpi_plugin_services_servicebuspriorities` +-- + +INSERT INTO `glpi_plugin_services_servicebuspriorities` (`id`, `name`, `comment`) VALUES +(2, 'P1', ''), +(3, 'P2', ''), +(4, 'P3', ''), +(5, 'P4', NULL), +(1, 'P0', NULL); -- --- AUTO_INCREMENT for dumped tables +-- Indexes for dumped tables -- -- --- AUTO_INCREMENT for table `glpi_plugin_services_servicetypes` +-- Indexes for table `glpi_plugin_services_servicebuspriorities` -- -ALTER TABLE `glpi_plugin_services_servicetypes` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=141; +ALTER TABLE `glpi_plugin_services_servicebuspriorities` + ADD PRIMARY KEY (`id`), + ADD KEY `name` (`name`); +-- +-- AUTO_INCREMENT for dumped tables +-- -- --- Table structure for table `glpi_plugin_services_servicetiers` +-- AUTO_INCREMENT for table `glpi_plugin_services_servicebuspriorities` -- +ALTER TABLE `glpi_plugin_services_servicebuspriorities` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=6; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -CREATE TABLE IF NOT EXISTS `glpi_plugin_services_servicetiers` ( +DROP TABLE IF EXISTS `glpi_plugin_services_servicebusrisks`; +-- Table structure for table `glpi_plugin_services_servicebusrisks` +-- + +CREATE TABLE IF NOT EXISTS `glpi_plugin_services_servicebusrisks` ( `id` int(11) NOT NULL, `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `comment` text COLLATE utf8_unicode_ci -) ENGINE=MyISAM AUTO_INCREMENT=8 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -INSERT INTO `glpi_plugin_services_servicetiers` (`id`, `name`, `comment`) VALUES -(1, 'Tier 0', ''), -(2, 'Tier 1', ''), -(3, 'Tier 2', ''), -(4, 'Tier 3', NULL); +-- +-- Dumping data for table `glpi_plugin_services_servicebusrisks` +-- + +INSERT INTO `glpi_plugin_services_servicebusrisks` (`id`, `name`, `comment`) VALUES +(1, 'Low', ''), +(2, 'Medium', ''), +(3, 'High', ''); -- --- Indexes for table `glpi_plugin_services_servicetiers` +-- Indexes for dumped tables -- -ALTER TABLE `glpi_plugin_services_servicetiers` + +-- +-- Indexes for table `glpi_plugin_services_servicebusrisks` +-- +ALTER TABLE `glpi_plugin_services_servicebusrisks` ADD PRIMARY KEY (`id`), ADD KEY `name` (`name`); - --- AUTO_INCREMENT for table `glpi_plugin_services_servicetiers` + +-- +-- AUTO_INCREMENT for dumped tables -- -ALTER TABLE `glpi_plugin_services_servicetiers` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=8; +-- +-- AUTO_INCREMENT for table `glpi_plugin_services_servicebusrisks` +-- +ALTER TABLE `glpi_plugin_services_servicebusrisks` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=4; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; --- Table structure for table `glpi_plugin_services_services_items` +-- Table structure for table `glpi_plugin_services_servicerpos` -- - -CREATE TABLE IF NOT EXISTS `glpi_plugin_services_services_items` ( +DROP TABLE IF EXISTS `glpi_plugin_services_servicerpos`; +CREATE TABLE IF NOT EXISTS `glpi_plugin_services_servicerpos` ( `id` int(11) NOT NULL, - `plugin_services_services_id` int(11) NOT NULL DEFAULT '0' COMMENT 'RELATION to glpi_plugin_services_services (id)', - `items_id` int(11) NOT NULL DEFAULT '0' COMMENT 'RELATION to various tables, according to itemtype (id)', - `itemtype` varchar(100) COLLATE utf8_unicode_ci NOT NULL COMMENT 'see .class.php file' -) ENGINE=MyISAM AUTO_INCREMENT=7955 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + `comment` text COLLATE utf8_unicode_ci +) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; --- Indexes for table `glpi_plugin_services_services_items` -- -ALTER TABLE `glpi_plugin_services_services_items` - ADD PRIMARY KEY (`id`), - ADD UNIQUE KEY `unicity` (`plugin_services_services_id`,`items_id`,`itemtype`), - ADD KEY `FK_device` (`items_id`,`itemtype`), - ADD KEY `item` (`itemtype`,`items_id`); +-- Dumping data for table `glpi_plugin_services_servicerpos` +-- + +INSERT INTO `glpi_plugin_services_servicerpos` (`id`, `name`, `comment`) VALUES +(5, '48h', ''), +(4, '> 48h', ''), +(6, 'ND', ''), +(7, '4h', ''), +(8, '8h', ''), +(9, '24h', ''), +(10, '2h', ''); - -- AUTO_INCREMENT for table `glpi_plugin_services_services_items` -- -ALTER TABLE `glpi_plugin_services_services_items`; +-- Indexes for dumped tables +-- +-- +-- Indexes for table `glpi_plugin_services_servicerpos` +-- +ALTER TABLE `glpi_plugin_services_servicerpos` + ADD PRIMARY KEY (`id`), + ADD KEY `name` (`name`); --- Table structure for table `glpi_plugin_services_servicesupports` +-- +-- AUTO_INCREMENT for dumped tables -- -CREATE TABLE IF NOT EXISTS `glpi_plugin_services_servicesupports` ( +-- +-- AUTO_INCREMENT for table `glpi_plugin_services_servicerpos` +-- +ALTER TABLE `glpi_plugin_services_servicerpos` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=11; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; + + +-- Table structure for table `glpi_plugin_services_servicertos` +-- +DROP TABLE IF EXISTS `glpi_plugin_services_servicertos`; +CREATE TABLE IF NOT EXISTS `glpi_plugin_services_servicertos` ( `id` int(11) NOT NULL, - `entities_id` int(11) NOT NULL DEFAULT '0', `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `comment` text COLLATE utf8_unicode_ci -) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- --- Dumping data for table `glpi_plugin_services_servicesupports` +-- Dumping data for table `glpi_plugin_services_servicertos` -- -INSERT INTO `glpi_plugin_services_servicesupports` (`id`, `entities_id`, `name`, `comment`) VALUES -(1, 0, '24/7', NULL), -(2, 0, '8x5', ''); +INSERT INTO `glpi_plugin_services_servicertos` (`id`, `name`, `comment`) VALUES +(5, '48h', ''), +(4, '> 48h', ''), +(6, 'ND', ''), +(7, '4h', ''), +(8, '8h', ''), +(9, '24h', ''), +(10, '2h', ''); --- Indexes for table `glpi_plugin_services_servicesupports` -- -ALTER TABLE `glpi_plugin_services_servicesupports` - ADD PRIMARY KEY (`id`), - ADD KEY `name` (`name`), - ADD KEY `entities_id` (`entities_id`); - --- AUTO_INCREMENT for table `glpi_plugin_services_servicesupports` +-- Indexes for dumped tables -- -ALTER TABLE `glpi_plugin_services_servicesupports` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=3; +-- +-- Indexes for table `glpi_plugin_services_servicertos` +-- +ALTER TABLE `glpi_plugin_services_servicertos` + ADD PRIMARY KEY (`id`), + ADD KEY `name` (`name`); + +-- +-- AUTO_INCREMENT for dumped tables +-- +-- +-- AUTO_INCREMENT for table `glpi_plugin_services_servicertos` +-- +ALTER TABLE `glpi_plugin_services_servicertos` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=11; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; - -- Table structure for table `glpi_plugin_services_services` -- - +DROP TABLE IF EXISTS `glpi_plugin_services_services`; CREATE TABLE IF NOT EXISTS `glpi_plugin_services_services` ( `id` int(11) NOT NULL, `entities_id` int(11) NOT NULL DEFAULT '0', @@ -149,8 +218,16 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_services_services` ( `is_disaster_recovery` int(5) NOT NULL DEFAULT '0', `is_disaster_recovery_documented` int(5) NOT NULL, `dr_docs_url` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL -) ENGINE=MyISAM AUTO_INCREMENT=482 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=MyISAM AUTO_INCREMENT=465 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + +-- +-- Dumping data for table `glpi_plugin_services_services` +-- +-- +-- Indexes for dumped tables +-- +-- -- Indexes for table `glpi_plugin_services_services` -- ALTER TABLE `glpi_plugin_services_services` @@ -169,145 +246,232 @@ ALTER TABLE `glpi_plugin_services_services` ADD KEY `is_helpdesk_visible` (`is_helpdesk_visible`), ADD KEY `is_deleted` (`is_deleted`); - -- +-- +-- AUTO_INCREMENT for dumped tables +-- + +-- -- AUTO_INCREMENT for table `glpi_plugin_services_services` -- ALTER TABLE `glpi_plugin_services_services` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=482; - + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=465; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; - --- Table structure for table `glpi_plugin_services_servicertos` +-- Table structure for table `glpi_plugin_services_servicesupports` -- - -CREATE TABLE IF NOT EXISTS `glpi_plugin_services_servicertos` ( +DROP TABLE IF EXISTS `glpi_plugin_services_servicesupports`; +CREATE TABLE IF NOT EXISTS `glpi_plugin_services_servicesupports` ( `id` int(11) NOT NULL, + `entities_id` int(11) NOT NULL DEFAULT '0', `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `comment` text COLLATE utf8_unicode_ci -) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- --- Dumping data for table `glpi_plugin_services_servicertos` +-- Dumping data for table `glpi_plugin_services_servicesupports` -- -INSERT INTO `glpi_plugin_services_servicertos` (`id`, `name`, `comment`) VALUES -(5, '48h', ''), -(4, '> 48h', ''), -(6, 'ND', ''), -(7, '4h', ''), -(8, '8h', ''), -(9, '24h', ''), -(10, '2h', ''); +INSERT INTO `glpi_plugin_services_servicesupports` (`id`, `entities_id`, `name`, `comment`) VALUES +(1, 0, '24/7', NULL), +(2, 0, '8x5', ''); +-- +-- Indexes for dumped tables +-- --- Indexes for table `glpi_plugin_services_servicertos` -- -ALTER TABLE `glpi_plugin_services_servicertos` +-- Indexes for table `glpi_plugin_services_servicesupports` +-- +ALTER TABLE `glpi_plugin_services_servicesupports` ADD PRIMARY KEY (`id`), - ADD KEY `name` (`name`); - + ADD KEY `name` (`name`), + ADD KEY `entities_id` (`entities_id`); + -- --- AUTO_INCREMENT for table `glpi_plugin_services_servicertos` +-- AUTO_INCREMENT for dumped tables -- -ALTER TABLE `glpi_plugin_services_servicertos` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=11; +-- +-- AUTO_INCREMENT for table `glpi_plugin_services_servicesupports` +-- +ALTER TABLE `glpi_plugin_services_servicesupports` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=3; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; + +-- Table structure for table `glpi_plugin_services_services_items` +-- +DROP TABLE IF EXISTS `glpi_plugin_services_services_items`; +CREATE TABLE IF NOT EXISTS `glpi_plugin_services_services_items` ( + `id` int(11) NOT NULL, + `plugin_services_services_id` int(11) NOT NULL DEFAULT '0' COMMENT 'RELATION to glpi_plugin_services_services (id)', + `items_id` int(11) NOT NULL DEFAULT '0' COMMENT 'RELATION to various tables, according to itemtype (id)', + `itemtype` varchar(100) COLLATE utf8_unicode_ci NOT NULL COMMENT 'see .class.php file' +) ENGINE=MyISAM AUTO_INCREMENT=6651 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; - --- Table structure for table `glpi_plugin_services_servicerpos` +-- +-- Dumping data for table `glpi_plugin_services_services_items` -- -CREATE TABLE IF NOT EXISTS `glpi_plugin_services_servicerpos` ( +-- +-- Indexes for dumped tables +-- + +-- +-- Indexes for table `glpi_plugin_services_services_items` +-- +ALTER TABLE `glpi_plugin_services_services_items` + ADD PRIMARY KEY (`id`), + ADD UNIQUE KEY `unicity` (`plugin_services_services_id`,`items_id`,`itemtype`), + ADD KEY `FK_device` (`items_id`,`itemtype`), + ADD KEY `item` (`itemtype`,`items_id`); + +-- +-- AUTO_INCREMENT for dumped tables +-- + +-- +-- AUTO_INCREMENT for table `glpi_plugin_services_services_items` +-- +ALTER TABLE `glpi_plugin_services_services_items` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=6651; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; + +-- Table structure for table `glpi_plugin_services_servicetechnics` +-- +DROP TABLE IF EXISTS `glpi_plugin_services_servicetechnics`; +CREATE TABLE IF NOT EXISTS `glpi_plugin_services_servicetechnics` ( `id` int(11) NOT NULL, `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `comment` text COLLATE utf8_unicode_ci -) ENGINE=MyISAM AUTO_INCREMENT=12 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- --- Dumping data for table `glpi_plugin_services_servicerpos` +-- Dumping data for table `glpi_plugin_services_servicetechnics` -- -INSERT INTO `glpi_plugin_services_servicerpos` (`id`, `name`, `comment`) VALUES -(5, '48h', ''), -(4, '> 48h', ''), -(6, 'ND', ''), -(7, '4h', ''), -(8, '8h', ''), -(9, '24h', ''), -(10, '2h', ''), -(11, '15 Min', ''); +INSERT INTO `glpi_plugin_services_servicetechnics` (`id`, `name`, `comment`) VALUES +(1, 'Tier 0', ''), +(2, 'Tier 1', ''), +(3, 'Tier 2', ''), +(4, 'Tier 3', NULL); --- Indexes for table `glpi_plugin_services_servicerpos` -- -ALTER TABLE `glpi_plugin_services_servicerpos` +-- Indexes for dumped tables +-- + +-- +-- Indexes for table `glpi_plugin_services_servicetechnics` +-- +ALTER TABLE `glpi_plugin_services_servicetechnics` ADD PRIMARY KEY (`id`), ADD KEY `name` (`name`); - -- --- AUTO_INCREMENT for table `glpi_plugin_services_servicerpos` -- -ALTER TABLE `glpi_plugin_services_servicerpos` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=12; - +-- AUTO_INCREMENT for dumped tables +-- --- Table structure for table `glpi_plugin_services_servicebusrisks` -- +-- AUTO_INCREMENT for table `glpi_plugin_services_servicetechnics` +-- +ALTER TABLE `glpi_plugin_services_servicetechnics` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=5; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -CREATE TABLE IF NOT EXISTS `glpi_plugin_services_servicebusrisks` ( +-- Table structure for table `glpi_plugin_services_servicetiers` +-- +DROP TABLE IF EXISTS `glpi_plugin_services_servicetiers`; +CREATE TABLE IF NOT EXISTS `glpi_plugin_services_servicetiers` ( `id` int(11) NOT NULL, `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `comment` text COLLATE utf8_unicode_ci -) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=MyISAM AUTO_INCREMENT=8 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- --- Dumping data for table `glpi_plugin_services_servicebusrisks` +-- Dumping data for table `glpi_plugin_services_servicetiers` -- -INSERT INTO `glpi_plugin_services_servicebusrisks` (`id`, `name`, `comment`) VALUES -(1, 'Low', ''), -(2, 'Medium', ''), -(3, 'High', ''); +INSERT INTO `glpi_plugin_services_servicetiers` (`id`, `name`, `comment`) VALUES +(1, 'Tier 0', ''), +(2, 'Tier 1', ''), +(3, 'Tier 2', ''), +(4, 'Tier 3', NULL); --- Indexes for table `glpi_plugin_services_servicebusrisks` -- -ALTER TABLE `glpi_plugin_services_servicebusrisks` +-- Indexes for dumped tables +-- + +-- +-- Indexes for table `glpi_plugin_services_servicetiers` +-- +ALTER TABLE `glpi_plugin_services_servicetiers` ADD PRIMARY KEY (`id`), ADD KEY `name` (`name`); -- --- AUTO_INCREMENT for table `glpi_plugin_services_servicebusrisks` +-- AUTO_INCREMENT for dumped tables -- -ALTER TABLE `glpi_plugin_services_servicebusrisks` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=4; - --- Table structure for table `glpi_plugin_services_servicebuspriorities` -- +-- AUTO_INCREMENT for table `glpi_plugin_services_servicetiers` +-- +ALTER TABLE `glpi_plugin_services_servicetiers` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=8; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -CREATE TABLE IF NOT EXISTS `glpi_plugin_services_servicebuspriorities` ( + +-- Table structure for table `glpi_plugin_services_servicetypes` +-- +DROP TABLE IF EXISTS `glpi_plugin_services_servicetypes`; +CREATE TABLE IF NOT EXISTS `glpi_plugin_services_servicetypes` ( `id` int(11) NOT NULL, + `entities_id` int(11) NOT NULL DEFAULT '0', `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `comment` text COLLATE utf8_unicode_ci -) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=MyISAM AUTO_INCREMENT=120 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- --- Dumping data for table `glpi_plugin_services_servicebuspriorities` +-- Dumping data for table `glpi_plugin_services_servicetypes` -- -INSERT INTO `glpi_plugin_services_servicebuspriorities` (`id`, `name`, `comment`) VALUES -(2, 'P1', ''), -(3, 'P2', ''), -(4, 'P3', ''), -(5, 'P4', NULL), -(1, 'P0', NULL); +-- +-- Indexes for dumped tables +-- --- Indexes for table `glpi_plugin_services_servicebuspriorities` -- -ALTER TABLE `glpi_plugin_services_servicebuspriorities` +-- Indexes for table `glpi_plugin_services_servicetypes` +-- +ALTER TABLE `glpi_plugin_services_servicetypes` ADD PRIMARY KEY (`id`), - ADD KEY `name` (`name`); + ADD KEY `name` (`name`), + ADD KEY `entities_id` (`entities_id`); + -- --- AUTO_INCREMENT for table `glpi_plugin_services_servicebuspriorities` +-- AUTO_INCREMENT for dumped tables -- -ALTER TABLE `glpi_plugin_services_servicebuspriorities` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=6; + +-- +-- AUTO_INCREMENT for table `glpi_plugin_services_servicetypes` +-- +ALTER TABLE `glpi_plugin_services_servicetypes` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=120; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; + + + +INSERT INTO `glpi_displaypreferences` VALUES (NULL,'PluginServicesService','2','2','0'); +INSERT INTO `glpi_displaypreferences` VALUES (NULL,'PluginServicesService','3','4','0'); +INSERT INTO `glpi_displaypreferences` VALUES (NULL,'PluginServicesService','6','5','0'); +INSERT INTO `glpi_displaypreferences` VALUES (NULL,'PluginServicesService','7','6','0'); +INSERT INTO `glpi_displaypreferences` VALUES (NULL,'PluginServicesService','8','7','0'); \ No newline at end of file