From 642915ed004925ad757dcc0fc5440dfe17e09cb7 Mon Sep 17 00:00:00 2001 From: bacus99 Date: Thu, 23 Feb 2017 06:59:38 -0500 Subject: [PATCH] V 1.0.1 sql install correct - Correct install sql path - Correct hook support error --- hook.php | 87 +++++++++++++++++++++++++++++++----- inc/service.class.php | 4 +- inc/service_item.class.php | 4 +- inc/servicesupport.class.php | 4 +- services.xml | 2 +- setup.php | 2 +- 6 files changed, 85 insertions(+), 18 deletions(-) diff --git a/hook.php b/hook.php index a525cee..e6404b3 100644 --- a/hook.php +++ b/hook.php @@ -35,7 +35,7 @@ function plugin_services_install() { $update = false; if (TableExists("glpi_plugin_services_services")){ - $DB->runFile(GLPI_ROOT ."/plugins/services/sql/empty-2.0.0.sql"); + $DB->runFile(GLPI_ROOT ."/plugins/services/sql/empty-1.0.0.sql"); } /* else { @@ -128,7 +128,7 @@ function plugin_services_uninstall() { $tables = array("glpi_plugin_services_services", "glpi_plugin_services_servicetypes", "glpi_plugin_services_servicesupports", - //"glpi_plugin_services_serviceservertypes", + "glpi_plugin_services_serviceservertypes", "glpi_plugin_services_servicetiers", "glpi_plugin_services_services_items"); @@ -166,7 +166,7 @@ function plugin_services_uninstall() { } -// Define dropdown relations +/* // Define dropdown relations function plugin_services_getDatabaseRelations() { $plugin = new Plugin(); @@ -178,9 +178,9 @@ function plugin_services_getDatabaseRelations() { "glpi_plugin_services_servicesupports" => array("glpi_plugin_services_services" => "plugin_services_servicesupports_id"), -/* "glpi_plugin_services_serviceservertypes" + "glpi_plugin_services_serviceservertypes" => array("glpi_plugin_services_services" - =>"plugin_services_serviceservertypes_id"), */ + =>"plugin_services_serviceservertypes_id"), "glpi_plugin_services_servicetiers" => array("glpi_plugin_services_services" =>"plugin_services_servicetiers_id"), @@ -203,8 +203,41 @@ function plugin_services_getDatabaseRelations() { "glpi_plugin_services_servicesupports" => "entities_id")); } return array(); -} +} */ +// Define dropdown relations +function plugin_services_getDatabaseRelations() { + $plugin = new Plugin(); + + if ($plugin->isActivated("services")) { + return array("glpi_plugin_services_servicetypes" + => array("glpi_plugin_services_services" + => "plugin_services_servicetypes_id"), + "glpi_plugin_services_serviceservertypes" + => array("glpi_plugin_services_services" + =>"plugin_services_serviceservertypes_id"), + "glpi_plugin_services_servicetechnics" + => array("glpi_plugin_services_services" + =>"plugin_services_servicetechnics_id"), + "glpi_users" + => array("glpi_plugin_services_services" => "users_id_tech"), + "glpi_groups" + => array("glpi_plugin_services_services" => "groups_id_tech"), + "glpi_suppliers" + => array("glpi_plugin_services_services" => "suppliers_id"), + "glpi_manufacturers" + => array("glpi_plugin_services_services" => "manufacturers_id"), + "glpi_locations" + => array("glpi_plugin_services_services" => "locations_id"), + "glpi_plugin_services_services" + => array("glpi_plugin_services_services_items" + => "plugin_services_services_id"), + "glpi_entities" + => array("glpi_plugin_services_services" => "entities_id", + "glpi_plugin_services_servicetypes" => "entities_id")); + } + return array(); +} // Define Dropdown tables to be manage in GLPI : function plugin_services_getDropdown() { @@ -240,6 +273,40 @@ function plugin_services_getAddSearchOptions($itemtype) { $sopt = array(); + if (in_array($itemtype, PluginServicesService::getTypes(true))) { + + if (Session::haveRight("plugin_services", READ)) { + $sopt[1310]['table'] = 'glpi_plugin_services_services'; + $sopt[1310]['field'] = 'name'; + $sopt[1310]['name'] = PluginServicesService::getTypeName(2)." - ". + __('Name'); + $sopt[1310]['forcegroupby'] = true; + $sopt[1310]['datatype'] = 'itemlink'; + $sopt[1310]['massiveaction'] = false; + $sopt[1310]['itemlink_type'] = 'PluginServicesService'; + $sopt[1310]['joinparams'] = array('beforejoin' + => array('table' => 'glpi_plugin_services_services_items', + 'joinparams' => array('jointype' => 'itemtype_item'))); + + $sopt[1311]['table'] = 'glpi_plugin_services_servicetypes'; + $sopt[1311]['field'] = 'name'; + $sopt[1311]['name'] = PluginServicesService::getTypeName(2)." - ". + PluginServicesServiceType::getTypeName(1); + $sopt[1311]['forcegroupby'] = true; + $sopt[1311]['datatype'] = 'dropdown'; + $sopt[1311]['massiveaction'] = false; + $sopt[1311]['joinparams'] = array('beforejoin' => array( + array('table' => 'glpi_plugin_services_services', + 'joinparams' => $sopt[1310]['joinparams']))); + } + } + + return $sopt; +} +/* function plugin_services_getAddSearchOptions($itemtype) { + + $sopt = array(); + if (in_array($itemtype, PluginServicesService::getTypes(true))) { if (Session::haveRight("plugin_services", READ)) { @@ -264,7 +331,7 @@ function plugin_services_getAddSearchOptions($itemtype) { array('table' => 'glpi_plugin_services_services', 'joinparams' => $sopt[1310]['joinparams']))); - $sopt[1312]['table'] = 'glpi_plugin_services_servicesupport'; +/* $sopt[1312]['table'] = 'glpi_plugin_services_servicesupports'; $sopt[1312]['field'] = 'name'; $sopt[1312]['name'] = PluginServicesService::getTypeName(2)." - ". PluginServicesServiceSupport::getTypeName(1); $sopt[1312]['forcegroupby'] = true; @@ -272,12 +339,12 @@ function plugin_services_getAddSearchOptions($itemtype) { $sopt[1312]['massiveaction'] = false; $sopt[1312]['joinparams'] = array('beforejoin' => array( array('table' => 'glpi_plugin_services_services', - 'joinparams' => $sopt[1310]['joinparams']))); - } + 'joinparams' => $sopt[1310]['joinparams']))); */ +/* } } return $sopt; -} +} */ //display custom fields in the search function plugin_services_giveItem($type, $ID, $data, $num) { diff --git a/inc/service.class.php b/inc/service.class.php index db9bee9..09dfe3b 100644 --- a/inc/service.class.php +++ b/inc/service.class.php @@ -251,7 +251,7 @@ function getSearchOptions() { $tab[115]['datatype'] = 'dropdown'; $tab[115]['right'] = 'interface'; - // Service Support time + // Service support time $tab[120]['table'] = 'glpi_plugin_services_servicesupports'; $tab[120]['field'] = 'name'; $tab[120]['name'] = PluginServicesServiceSupport::getTypeName(1); @@ -363,7 +363,7 @@ function showForm($ID, $options=array()) { Html::autocompletionTextField($this,"name"); echo ""; - //support of services + //time of services echo "".PluginServicesServiceSupport::getTypeName(1).""; echo ""; Dropdown::show('PluginServicesServiceSupport', diff --git a/inc/service_item.class.php b/inc/service_item.class.php index 25f8666..0a8efa1 100644 --- a/inc/service_item.class.php +++ b/inc/service_item.class.php @@ -888,7 +888,7 @@ static function PdfFromItems(PluginPdfSimplePDF $pdf, CommonGLPI $item){ } } - static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGLPI $item, $tab) { +/* static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGLPI $item, $tab) { if ($item->getType()=='PluginServicesService') { self::ItemsPdf($pdf, $item); @@ -898,7 +898,7 @@ static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGLPI $ite return false; } return true; - } + } */ } ?> \ No newline at end of file diff --git a/inc/servicesupport.class.php b/inc/servicesupport.class.php index 2b3d9ee..241b16b 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, 'services'); + return _n('Support Period','Support Periods',$nb, 'Support Periods'); } static function transfer($ID, $entity) { @@ -49,7 +49,7 @@ static function transfer($ID, $entity) { // Not already transfer // Search init item $query = "SELECT * - FROM `glpi_plugin_services_servicesupport` + FROM `glpi_plugin_services_servicesupports` WHERE `id` = '$ID'"; if ($result=$DB->query($query)) { diff --git a/services.xml b/services.xml index 1b5add7..bbce3ea 100644 --- a/services.xml +++ b/services.xml @@ -28,7 +28,7 @@ This plugin allow adding informations to services based on ITIL concepts (DR, Ow - 1.0.0 + 1.0.1 0.85 0.90 9.1 diff --git a/setup.php b/setup.php index bb89d86..3279816 100644 --- a/setup.php +++ b/setup.php @@ -66,7 +66,7 @@ function plugin_init_services() { function plugin_version_services() { return array('name' => _n('ITIL Service' , 'ITIL Services' ,2, 'services'), - 'version' => '1.0.0', + 'version' => '1.0.1', 'license' => 'GPLv2+', 'author' => "Christian Bernard, based on WebApplications plugin", 'minGlpiVersion' => '9.1');