Bonjour,

Il manque un onglet afin d'assigner un template de ticket à une
catégorie, ceci à partir du form de templates de ticket. J'ai donc codé
cet ajout qui permet de gagner du temps de gestion.

Je joins une capture d'écran du résultat.


Cordialement,
--
David DURIEUX
Tel : +33 (0)4.82.53.30.53
Mail : d.duri...@siprossii.com
Site Web : http://www.siprossii.com/

SIPROSSII
Les Lafôrets
69430 Beaujeu
FRANCE
Index: front/itilcategory.form.php
===================================================================
--- front/itilcategory.form.php	(revision 16403)
+++ front/itilcategory.form.php	(working copy)
@@ -37,5 +37,22 @@
 include (GLPI_ROOT . "/inc/includes.php");
 
 $dropdown = new ITILCategory();
+
+if (isset($_POST['add_demand'])) {
+   $dropdown->check($_POST['itilcategories_id_demand'], 'w');
+   $input = array();
+   $input['id'] = $_POST['itilcategories_id_demand'];
+   $input['tickettemplates_id_demand'] = $_POST['tickettemplates_id'];
+   $dropdown->update($input);
+   Html::back();
+} else if (isset($_POST['add_incident'])) {
+   $dropdown->check($_POST['itilcategories_id_incident'], 'w');
+   $input = array();
+   $input['id'] = $_POST['itilcategories_id_incident'];
+   $input['tickettemplates_id_incident'] = $_POST['tickettemplates_id'];
+   $dropdown->update($input);
+   Html::back();
+}
+
 include (GLPI_ROOT . "/front/dropdown.common.form.php");
 ?>
Index: inc/itilcategory.class.php
===================================================================
--- inc/itilcategory.class.php	(revision 16403)
+++ inc/itilcategory.class.php	(working copy)
@@ -212,7 +212,123 @@
    function cleanDBonPurge() {
       Rule::cleanForItemCriteria($this);
    }
+   
+   
+   function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
+      global $LANG;
 
+      if (Session::haveRight("entity_dropdown","r")) {
+         switch ($item->getType()) {
+            case 'TicketTemplate' :
+               $ong[1] = $this->getTypeName();
+               return $ong;
+         }
+      }
+      return '';
+   }
+   
+   
+   static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
+
+      self::showForTicketTemplate($item, $withtemplate);
+      return true;
+   }
+   
+   
+   static function showForTicketTemplate(TicketTemplate $tt, $withtemplate='') {
+      global $DB, $LANG, $CFG_GLPI;
+      
+      $itilcategory = new self();
+      $ID = $tt->fields['id'];
+
+      if (!$tt->getFromDB($ID) || !$tt->can($ID, "r")) {
+         return false;
+      }
+      $ttm     = new self();
+
+      $canedit = $tt->can($ID, "w");
+      $rand    = mt_rand();
+      echo "<form name='itilcategories_form$rand'
+                  id='itilcategories_form$rand' method='post' action='";
+      echo Toolbox::getItemTypeFormURL(__CLASS__)."'>";
+
+      echo "<div class='center'>";
+
+      $query = "SELECT `glpi_itilcategories`.*
+                FROM `glpi_itilcategories`
+                WHERE (`tickettemplates_id_incident` = '$ID')
+                     OR (`tickettemplates_id_demand` = '$ID')
+                ORDER BY `name`";
+
+      if ($result=$DB->query($query)) {
+         echo "<table class='tab_cadre_fixe'>";
+         echo "<tr><th colspan='4'>";
+         echo self::getTypeName($DB->numrows($result));
+         echo "</th></tr>";
+         $used_incident = array();
+         $used_demand = array();
+         if ($DB->numrows($result)) {
+            echo "<tr><th width='24'>&nbsp;</th>";
+            echo "<th>".$LANG['common'][16]."</th>";
+            echo "<th>".$LANG['job'][1]."</th>";
+            echo "<th>".$LANG['job'][2]."</th>";
+            echo "</tr>";
+
+            while ($data=$DB->fetch_assoc($result)) {
+               echo "<tr class='tab_bg_2'>";
+               if ($canedit) {
+                  echo "<td><input type='checkbox' name='item[".$data["id"]."]' value='1'></td>";
+               } else {
+                  echo "<td>&nbsp;</td>";
+               }
+               $itilcategory->getFromDB($data['id']);
+               echo "<td>".$itilcategory->getLink(1)."</td>";
+               if ($data['tickettemplates_id_incident'] == $ID) {
+                  echo "<td align='center'>
+                     <img src='".$CFG_GLPI["root_doc"]."/pics/ok.png' width='14' height='14'/></td>";
+                  $used_incident[] = $data["id"];
+               } else {
+                  echo "<td>&nbsp;</td>";
+               }
+               if ($data['tickettemplates_id_demand'] == $ID) {
+                  echo "<td align='center'>
+                     <img src='".$CFG_GLPI["root_doc"]."/pics/ok.png' width='14' height='14'/></td>";
+                  $used_demand[] = $data["id"];
+               } else {
+                  echo "<td>&nbsp;</td>";
+               }
+            }
+
+         } else {
+            echo "<tr><th colspan='4'>".$LANG['search'][15]."</th></tr>";
+         }
+
+         if ($canedit) {
+            echo "<tr class='tab_bg_2'><td class='center' colspan='2'>";
+            echo "<input type='hidden' name='tickettemplates_id' value='$ID'>";
+            echo "</td><td align='center'>";
+            dropdown::show("ITILCategory", array('name' => 'itilcategories_id_incident',
+                                                 'used' => $used_incident));
+            echo "&nbsp;<input type='submit' name='add_incident' value=\"".$LANG['buttons'][8].
+                         "\" class='submit'>";
+            echo "</td><td align='center'>";
+            dropdown::show("ITILCategory", array('name' => 'itilcategories_id_demand',
+                                                 'used' => $used_demand));
+            echo "&nbsp;<input type='submit' name='add_demand' value=\"".$LANG['buttons'][8].
+                         "\" class='submit'>";
+            echo "</td></tr>";
+         }
+         echo "</table></div>";
+
+//         if ($canedit) {
+//            Html::openArrowMassives("itilcategories_form$rand", true);
+//            Html::closeArrowMassives(array('delete' => $LANG['buttons'][6]));
+//         }
+         echo "</form>";
+
+      }
+   }
+
 }
 
 ?>
Index: inc/tickettemplate.class.php
===================================================================
--- inc/tickettemplate.class.php	(revision 16403)
+++ inc/tickettemplate.class.php	(working copy)
@@ -229,6 +229,7 @@
       $this->addStandardTab('TicketTemplatePredefinedField', $ong, $options);
       $this->addStandardTab('TicketTemplateHiddenField', $ong, $options);
       $this->addStandardTab('TicketTemplate', $ong, $options);
+      $this->addStandardTab('ITILCategory', $ong, $options);
       $this->addStandardTab('Log', $ong, $options);
 
       return $ong;

<<attachment: screenshot.png>>

_______________________________________________
Glpi-dev mailing list
Glpi-dev@gna.org
https://mail.gna.org/listinfo/glpi-dev

Reply via email to