Projet

Général

Profil

Révision 20a15d94

Voir les différences:

plugins/anet_epacks/front/plugin_anet_epacks.search.php
1
<?php
2

  
3
  /* Permet de faire une recherche rapide pour ryxeo-erp ... */
4

  
5
if(!defined('GLPI_ROOT')){
6
  define('GLPI_ROOT', '../../..');
7
 }
8
include_once (GLPI_ROOT . "/inc/includes.php");
9

  
10
commonHeader("AbulEdu.NET -- Recherche rapide -- Accueil RyXéo",$_SERVER['PHP_SELF'],"config","plugins");
11

  
12
$glpiid = $_SESSION['glpiID'];
13

  
14
global $DB;
15

  
16
$query = "SELECT glpi_profiles.name AS name,glpi_users_profiles.FK_entities as FK_entities FROM glpi_profiles,glpi_users_profiles,glpi_users WHERE glpi_users_profiles.FK_users='" . $glpiid . "' AND glpi_users_profiles.FK_profiles=glpi_profiles.ID GROUP BY FK_entities";
17

  
18
$result = $DB->query($query);
19
if($result) {
20
  while($data=$DB->fetch_array($result)) {
21
    $entityid = $data['FK_entities'];
22
    if($data['name'] == "super-admin") {
23
      //print $query;
24
      $entityid = $data['FK_entities'];
25
      $recherche = addslashes($_GET['search']);
26

  
27
      //Recherche (1) dans les codes epacks
28
      $query2 = "SELECT e.*, e.FK_enduser as entityid, g3.name as client, g4.name as serveur
29
FROM glpi_plugin_anet_epacks AS e
30
LEFT JOIN glpi_entities AS g3 ON (e.FK_client=g3.ID OR e.FK_enduser=g3.ID)
31
LEFT JOIN glpi_computers AS g4 ON e.FK_serveur=g4.ID
32
LEFT JOIN glpi_contracts AS g6 ON e.FK_contract=g6.ID
33
LEFT JOIN glpi_entities AS g7 ON e.FK_clientderyxeo=g7.ID
34
WHERE e.code LIKE '%$recherche%'
35
GROUP BY e.FK_serveur";
36
      $result2 = $DB->query($query2);
37
      if($result2) {
38
	$data2=$DB->fetch_array($result2);
39
	if($data2) {
40
	  //On saute directement c'est que c'est le bon
41
	  $txt .= "<a href=\"../../manageentity/index.php?active_entity=" . $data2['entityid'] . "\">" . $data2['client'] . ": " . $data2['serveur'] . "</a><br />\n";
42
	}
43
      }
44
      //print "$query2<br />";
45

  
46
      //Recherche dans les noms des entites
47
      $query3 = "SELECT e.*, e.FK_enduser as entityid, g3.name as client, g4.name as serveur
48
FROM glpi_plugin_anet_epacks AS e
49
LEFT JOIN glpi_entities AS g3 ON (e.FK_client=g3.ID OR e.FK_enduser=g3.ID)
50
LEFT JOIN glpi_computers AS g4 ON e.FK_serveur=g4.ID
51
LEFT JOIN glpi_contracts AS g6 ON e.FK_contract=g6.ID
52
LEFT JOIN glpi_entities AS g7 ON e.FK_clientderyxeo=g7.ID
53
WHERE g3.name LIKE '%$recherche%'
54
GROUP BY e.FK_serveur";
55
      $result3 = $DB->query($query3);
56
      if($result3) {
57
	$data3=$DB->fetch_array($result3);
58
	if($data3) {
59
	  //On saute directement c'est que c'est le bon
60
	  $txt .= "<a href=\"../../manageentity/index.php?active_entity=" . $data3['entityid'] . "\">" . $data3['client'] . ": " . $data3['serveur'] . "</a> <br />\n";
61
	}
62
      }
63
      //print $query2;
64
    }
65
  }
66

  
67
  print "<h1>Résultat de la recherche</h1>";
68
  print $txt;
69
 }  
70

  
71
commonFooter();
72

  
73
?>

Formats disponibles : Unified diff

Redmine Appliance - Powered by TurnKey Linux