Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

ryxeo-glpi-git / plugins / anet_epacks / front / plugin_anet_epacks.view_recap_mensuel_rvd.php @ f481f9ee

Historique | Voir | Annoter | Télécharger (4,55 ko)

1
<?php
2

    
3
// Récap mensuel de tout serveur affecté à un revendeur ...
4

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

    
10
//Les dates en francais svp
11
setlocale(LC_TIME, "fr_FR");
12

    
13
checkRight("config","w");
14
//checkSeveralRightsOr(array("config" => "w", "profile" => "w"));
15

    
16
commonHeader("anet_epacks",$_SERVER['PHP_SELF'],"config","plugins");
17
print "<h1>Création du relevé mensuel</h1>";
18

    
19
$choix = "";
20
for($i = 2009; $i <= date("Y"); $i++) {
21
  for($j = 1; $j < 13; $j++) {
22
    $choix .= "<a href=\"" . $PHP_SELF . "?year=$i&month=$j\">$j/$i</a> :: ";
23
  }
24
 }
25

    
26
print "<p>Choix de la période : $choix</p>";
27

    
28
global $DB;
29

    
30
function rvd_get_details($id) {
31
  global $DB;
32
  //Les détails pour ce revendeur: tous les epacks avec la date d'activation, le code du epack et le nom du client
33
  $query2="SELECT e.*,g2.name as activation ,g3.name as client, g4.name as serveur  FROM glpi_plugin_anet_epacks AS e
34
LEFT JOIN glpi_entities AS g2 ON FK_activation=g2.ID
35
LEFT JOIN glpi_entities AS g3 ON FK_client=g3.ID
36
LEFT JOIN glpi_computers AS g4 ON FK_serveur=g4.ID
37
WHERE creation_date>'0000-00-00'
38
AND creation_date<'" . $_GET['year'] . "-" . $_GET['month'] . "-00'
39
AND FK_clientderyxeo='" . $id . "'
40
AND FK_contract>='0'
41
ORDER BY activation_date";
42
  $result2 = $DB->query($query2) or die($DB->error());
43

    
44
  //La liste des epacks clairement hors maintenance
45

    
46
  $txt = "<table width='100%' cellpadding='2'>\n";
47
  $txt .= "<tr class='tab_bg_3'>
48
  <td>Créat. / Activat.</td>
49
  <td>Activé</td>
50
  <td>Client</td>
51
  <td>ePack</td>
52
  <td>Maintenance</td>
53
</tr style=\"border-bottom: 1px solid black;\">\n";
54
  for($i = 0; $i < $DB->numrows($result2); $i++) {
55
    $data2=$DB->fetch_array($result2);
56
    $txt .= "<tr class='tab_bg_3'>\n";
57
    $txt .= "  <td style=\"text-align:left\" nowrap>Cré: " . strftime("%d/%m/%Y", strtotime($data2['creation_date'])) . "<br />Act: " . strftime("%d/%m/%Y", strtotime($data2['activation_date'])) . "</td>
58
  <td valign=\"top\">" . $data2['activation'] . "</td>
59
  <td valign=\"top\">" . $data2['client'] . " (" . $data2['serveur'] . ")</td>
60
  <td valign=\"top\" nowrap>" . $data2['code'] . "</td>
61
  <td nowrap></td>
62
</tr>\n";
63
    unset($data2);
64
  }
65
  $txt .= "<tr class='tab_bg_3'>
66
  <td colspan=\"6\"><br />Nombre total de packs: " . $i . "<br /></td>
67
</tr>\n";
68

    
69
  $txt .= "</table>";
70
  if($i == 0)
71
    unset($txt);
72
  return $txt;
73
}
74

    
75
//Le tableau global pour avoir la liste des revendeurs
76
//parentid=3 -> c'est l'entité "partenaires"
77
$query = "SELECT e.FK_clientderyxeo,g.name as clientderyxeo FROM glpi_plugin_anet_epacks AS e LEFT JOIN glpi_entities AS g ON FK_clientderyxeo=g.ID WHERE parentID='3' GROUP BY FK_clientderyxeo";
78
$result = $DB->query($query) or die($DB->error());
79

    
80
for($i = 0; $i < $DB->numrows($result); $i++) {
81

    
82
  $data=$DB->fetch_array($result);
83

    
84
  /*
85
   print "<table class='tab_cadre' width='100%' cellpadding='2'>\n";
86
   print "<tr class='tab_bg_3'>
87
   <td>Nom</td>
88
   <td>Détails</td>
89
   </tr>\n";
90
print "<tr class='tab_bg_3'>\n";
91
  print "  <td valign=\"top\">" . $data['clientderyxeo'] . " </td>
92
  <td valign=\"top\">" . rvd_get_details($data['FK_clientderyxeo']) . "</td>
93
</tr>\n";
94
  */
95
  $txt = rvd_get_details($data['FK_clientderyxeo']);
96
  if($txt != "") {
97
    print "<p style=\"page-break-after: always\">&nbsp;</p>\n";
98
    print "  <h2 style=\"text-align: left\"> Relevé mensuel (" . strftime("%B", strtotime($_GET['year'] . "/" . $_GET['month'] . "/01")) . " " . $_GET['year']  . ") pour " . $data['clientderyxeo'] . " </h2>";
99
    print $txt;
100
    unset($data);
101
  }
102
  /*
103
  print "</table>";
104
  */
105
 }
106

    
107
/*
108
print "<p style=\"page-break-after: always\">&nbsp;</p>\n";
109
print "  <h2 style=\"text-align: left\"> Synthèse du relevé mensuel de " . $_GET['month'] . "/" . $_GET['year']  . "</h2>";
110
print "<table>
111
<tr class='tab_bg_3'>
112
  <td colspan=\"3\"><br />Nombre total de revendeurs: " . $i . "<br /></td>
113
</tr>\n";
114
print "</table>";
115
*/
116

    
117
//Les packs attribués
118
//Permet de limiter un peu l'affichage, il faudra faire un système de recherche ou pagination à terme
119
if($_GET['year'])
120
  $condition = "AND YEAR(creation_date)='" . $_GET['year'] . "'";
121
if($_GET['month'])
122
  $condition = "AND MONTH(creation_date)='" . $_GET['month'] . "'";
123
$query="SELECT e.*,g.name as clientderyxeo ,g2.name as activation ,g3.name as client FROM glpi_plugin_anet_epacks AS e LEFT JOIN glpi_entities AS g ON FK_clientderyxeo=g.ID
124
LEFT JOIN glpi_entities AS g2 ON FK_activation=g2.ID
125
LEFT JOIN glpi_entities AS g3 ON FK_client=g3.ID
126
WHERE creation_date>'0000-00-00'
127
$condition
128
ORDER BY clientderyxeo,activation,creation_date
129
LIMIT 500;";
130
//print $query;
131

    
132

    
133
commonFooter();
134
?>
Redmine Appliance - Powered by TurnKey Linux