ryxeo-glpi-git / plugins / anet_epacks / front / plugin_anet_epacks.view_recap_mensuel_rvd.php @ 08132581
Historique | Voir | Annoter | Télécharger (4,59 ko)
1 | b67d8923 | Eric Seigne | <?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 | f481f9ee | Eric Seigne | //Les dates en francais svp
|
11 | setlocale(LC_TIME, "fr_FR"); |
||
12 | |||
13 | b67d8923 | Eric Seigne | checkRight("config","w"); |
14 | //checkSeveralRightsOr(array("config" => "w", "profile" => "w"));
|
||
15 | |||
16 | commonHeader("anet_epacks",$_SERVER['PHP_SELF'],"config","plugins"); |
||
17 | f481f9ee | Eric Seigne | print "<h1>Création du relevé mensuel</h1>"; |
18 | b67d8923 | Eric Seigne | |
19 | f481f9ee | Eric Seigne | $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 | b67d8923 | Eric Seigne | |
26 | f481f9ee | Eric Seigne | print "<p>Choix de la période : $choix</p>"; |
27 | b67d8923 | Eric Seigne | |
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 | 08132581 | Eric Seigne | AND activation_date>'2009-01-01'
|
39 | AND activation_date<'" . $_GET['year'] . "-" . $_GET['month'] . "-00' |
||
40 | b67d8923 | Eric Seigne | AND FK_clientderyxeo='" . $id . "' |
41 | 769c7f66 | Eric Seigne | AND FK_contract>='0'
|
42 | b67d8923 | Eric Seigne | ORDER BY activation_date";
|
43 | $result2 = $DB->query($query2) or die($DB->error()); |
||
44 | |||
45 | 769c7f66 | Eric Seigne | //La liste des epacks clairement hors maintenance
|
46 | |||
47 | f481f9ee | Eric Seigne | $txt = "<table width='100%' cellpadding='2'>\n"; |
48 | b67d8923 | Eric Seigne | $txt .= "<tr class='tab_bg_3'> |
49 | f481f9ee | Eric Seigne | <td>Créat. / Activat.</td>
|
50 | <td>Activé</td>
|
||
51 | <td>Client</td>
|
||
52 | b67d8923 | Eric Seigne | <td>ePack</td>
|
53 | f481f9ee | Eric Seigne | <td>Maintenance</td>
|
54 | </tr style=\"border-bottom: 1px solid black;\">\n";
|
||
55 | b67d8923 | Eric Seigne | for($i = 0; $i < $DB->numrows($result2); $i++) { |
56 | $data2=$DB->fetch_array($result2); |
||
57 | $txt .= "<tr class='tab_bg_3'>\n"; |
||
58 | f481f9ee | Eric Seigne | $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> |
59 | <td valign=\"top\">" . $data2['activation'] . "</td> |
||
60 | <td valign=\"top\">" . $data2['client'] . " (" . $data2['serveur'] . ")</td> |
||
61 | <td valign=\"top\" nowrap>" . $data2['code'] . "</td> |
||
62 | <td nowrap></td>
|
||
63 | b67d8923 | Eric Seigne | </tr>\n";
|
64 | unset($data2); |
||
65 | } |
||
66 | $txt .= "<tr class='tab_bg_3'> |
||
67 | <td colspan=\"6\"><br />Nombre total de packs: " . $i . "<br /></td> |
||
68 | </tr>\n";
|
||
69 | |||
70 | $txt .= "</table>"; |
||
71 | f481f9ee | Eric Seigne | if($i == 0) |
72 | unset($txt); |
||
73 | return $txt; |
||
74 | b67d8923 | Eric Seigne | } |
75 | |||
76 | //Le tableau global pour avoir la liste des revendeurs
|
||
77 | //parentid=3 -> c'est l'entité "partenaires"
|
||
78 | $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"; |
||
79 | $result = $DB->query($query) or die($DB->error()); |
||
80 | |||
81 | for($i = 0; $i < $DB->numrows($result); $i++) { |
||
82 | f481f9ee | Eric Seigne | |
83 | b67d8923 | Eric Seigne | $data=$DB->fetch_array($result); |
84 | |||
85 | f481f9ee | Eric Seigne | /*
|
86 | print "<table class='tab_cadre' width='100%' cellpadding='2'>\n";
|
||
87 | print "<tr class='tab_bg_3'>
|
||
88 | <td>Nom</td>
|
||
89 | <td>Détails</td>
|
||
90 | </tr>\n";
|
||
91 | print "<tr class='tab_bg_3'>\n";
|
||
92 | print " <td valign=\"top\">" . $data['clientderyxeo'] . " </td>
|
||
93 | <td valign=\"top\">" . rvd_get_details($data['FK_clientderyxeo']) . "</td>
|
||
94 | b67d8923 | Eric Seigne | </tr>\n";
|
95 | f481f9ee | Eric Seigne | */
|
96 | $txt = rvd_get_details($data['FK_clientderyxeo']); |
||
97 | if($txt != "") { |
||
98 | print "<p style=\"page-break-after: always\"> </p>\n"; |
||
99 | print " <h2 style=\"text-align: left\"> Relevé mensuel (" . strftime("%B", strtotime($_GET['year'] . "/" . $_GET['month'] . "/01")) . " " . $_GET['year'] . ") pour " . $data['clientderyxeo'] . " </h2>"; |
||
100 | print $txt; |
||
101 | unset($data); |
||
102 | } |
||
103 | /*
|
||
104 | print "</table>";
|
||
105 | */
|
||
106 | b67d8923 | Eric Seigne | } |
107 | f481f9ee | Eric Seigne | |
108 | /*
|
||
109 | print "<p style=\"page-break-after: always\"> </p>\n";
|
||
110 | print " <h2 style=\"text-align: left\"> Synthèse du relevé mensuel de " . $_GET['month'] . "/" . $_GET['year'] . "</h2>";
|
||
111 | print "<table>
|
||
112 | <tr class='tab_bg_3'>
|
||
113 | b67d8923 | Eric Seigne | <td colspan=\"3\"><br />Nombre total de revendeurs: " . $i . "<br /></td>
|
114 | </tr>\n";
|
||
115 | print "</table>";
|
||
116 | f481f9ee | Eric Seigne | */
|
117 | b67d8923 | Eric Seigne | |
118 | //Les packs attribués
|
||
119 | //Permet de limiter un peu l'affichage, il faudra faire un système de recherche ou pagination à terme
|
||
120 | if($_GET['year']) |
||
121 | $condition = "AND YEAR(creation_date)='" . $_GET['year'] . "'"; |
||
122 | if($_GET['month']) |
||
123 | $condition = "AND MONTH(creation_date)='" . $_GET['month'] . "'"; |
||
124 | $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 |
||
125 | LEFT JOIN glpi_entities AS g2 ON FK_activation=g2.ID
|
||
126 | LEFT JOIN glpi_entities AS g3 ON FK_client=g3.ID
|
||
127 | WHERE creation_date>'0000-00-00'
|
||
128 | $condition
|
||
129 | ORDER BY clientderyxeo,activation,creation_date
|
||
130 | LIMIT 500;";
|
||
131 | //print $query;
|
||
132 | |||
133 | |||
134 | commonFooter(); |
||
135 | ?> |