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