ryxeo-glpi-git / plugins / anet_epacks / front / plugin_anet_epacks.view_recap_mensuel_rvd.php @ 769c7f66
Historique | Voir | Annoter | Télécharger (3,8 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 |
checkRight("config","w"); |
11 |
//checkSeveralRightsOr(array("config" => "w", "profile" => "w"));
|
12 |
|
13 |
commonHeader("anet_epacks",$_SERVER['PHP_SELF'],"config","plugins"); |
14 |
|
15 |
print "<h1>Relevé mensuel de " . $_GET['year'] . "-" . $_GET['month'] . "</h1>"; |
16 |
|
17 |
print "<p>Récapitulatif pour la période : <a href=\"" . $PHP_SELF . "\">Tous</a> - <a href=\"" . $PHP_SELF . "?year=2009&month=12\">Déc. 2009</a> - <a href=\"" . $PHP_SELF . "?year=2010&month=01\">Jan 2010</a> - <a href=\"" . $PHP_SELF . "?year=2010&month=02\">Fev 2010</a> - <a href=\"" . $PHP_SELF . "?year=2010&month=03\">Mars 2010</a>.</p>"; |
18 |
|
19 |
global $DB; |
20 |
|
21 |
function rvd_get_details($id) { |
22 |
global $DB; |
23 |
//Les détails pour ce revendeur: tous les epacks avec la date d'activation, le code du epack et le nom du client
|
24 |
$query2="SELECT e.*,g2.name as activation ,g3.name as client, g4.name as serveur FROM glpi_plugin_anet_epacks AS e |
25 |
LEFT JOIN glpi_entities AS g2 ON FK_activation=g2.ID
|
26 |
LEFT JOIN glpi_entities AS g3 ON FK_client=g3.ID
|
27 |
LEFT JOIN glpi_computers AS g4 ON FK_serveur=g4.ID
|
28 |
WHERE creation_date>'0000-00-00'
|
29 |
AND FK_clientderyxeo='" . $id . "' |
30 |
AND FK_contract>='0'
|
31 |
ORDER BY activation_date";
|
32 |
$result2 = $DB->query($query2) or die($DB->error()); |
33 |
|
34 |
//La liste des epacks clairement hors maintenance
|
35 |
|
36 |
$txt = "<table class='tab_cadre' width='100%' cellpadding='2'>\n"; |
37 |
$txt .= "<tr class='tab_bg_3'> |
38 |
<td>Création</td>
|
39 |
<td>Activation</td>
|
40 |
<td>Activé par</td>
|
41 |
<td>Client final</td>
|
42 |
<td>ePack</td>
|
43 |
</tr>\n";
|
44 |
for($i = 0; $i < $DB->numrows($result2); $i++) { |
45 |
$data2=$DB->fetch_array($result2); |
46 |
$txt .= "<tr class='tab_bg_3'>\n"; |
47 |
$txt .= " <td>" . $data2['creation_date'] . "</td> |
48 |
<td>" . $data2['activation_date'] . "</td> |
49 |
<td>" . $data2['activation'] . "</td> |
50 |
<td>" . $data2['client'] . " (" . $data2['serveur'] . ")</td> |
51 |
<td>" . $data2['code'] . "<br><br></td> |
52 |
</tr>\n";
|
53 |
unset($data2); |
54 |
} |
55 |
$txt .= "<tr class='tab_bg_3'> |
56 |
<td colspan=\"6\"><br />Nombre total de packs: " . $i . "<br /></td> |
57 |
</tr>\n";
|
58 |
|
59 |
$txt .= "</table>"; |
60 |
return $txt; |
61 |
} |
62 |
|
63 |
//Le tableau global pour avoir la liste des revendeurs
|
64 |
//parentid=3 -> c'est l'entité "partenaires"
|
65 |
$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"; |
66 |
$result = $DB->query($query) or die($DB->error()); |
67 |
|
68 |
print "<table class='tab_cadre' width='100%' cellpadding='2'>\n"; |
69 |
print "<tr class='tab_bg_3'> |
70 |
<td>Nom</td>
|
71 |
<td>Détails</td>
|
72 |
<td>Documents</td>
|
73 |
</tr>\n";
|
74 |
for($i = 0; $i < $DB->numrows($result); $i++) { |
75 |
$data=$DB->fetch_array($result); |
76 |
|
77 |
print "<tr class='tab_bg_3'>\n"; |
78 |
print " <td>" . $data['clientderyxeo'] . " </td> |
79 |
<td>" . rvd_get_details($data['FK_clientderyxeo']) . "</td> |
80 |
<td>" . $documents . "<br><br></td> |
81 |
</tr>\n";
|
82 |
unset($data); |
83 |
} |
84 |
print "<tr class='tab_bg_3'> |
85 |
<td colspan=\"3\"><br />Nombre total de revendeurs: " . $i . "<br /></td> |
86 |
</tr>\n";
|
87 |
print "</table>"; |
88 |
|
89 |
//Les packs attribués
|
90 |
//Permet de limiter un peu l'affichage, il faudra faire un système de recherche ou pagination à terme
|
91 |
if($_GET['year']) |
92 |
$condition = "AND YEAR(creation_date)='" . $_GET['year'] . "'"; |
93 |
if($_GET['month']) |
94 |
$condition = "AND MONTH(creation_date)='" . $_GET['month'] . "'"; |
95 |
$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 |
96 |
LEFT JOIN glpi_entities AS g2 ON FK_activation=g2.ID
|
97 |
LEFT JOIN glpi_entities AS g3 ON FK_client=g3.ID
|
98 |
WHERE creation_date>'0000-00-00'
|
99 |
$condition
|
100 |
ORDER BY clientderyxeo,activation,creation_date
|
101 |
LIMIT 500;";
|
102 |
//print $query;
|
103 |
|
104 |
|
105 |
commonFooter(); |
106 |
?>
|