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 @ b0bf16dc

Historique | Voir | Annoter | Télécharger (4,67 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 activation_date>'2009-01-01'
39
AND activation_date<'" . $_GET['year'] . "-" . ($_GET['month']-1) . "-20'
40
AND FK_clientderyxeo='" . $id . "'
41
AND FK_contract>='0'
42
ORDER BY activation_date";
43
  //print $query2;
44
  $result2 = $DB->query($query2) or die($DB->error());
45

    
46
  //La liste des epacks clairement hors maintenance
47

    
48
  $txt = "<table width='100%' cellpadding='2'>\n";
49
  $txt .= "<tr class='tab_bg_3'>
50
  <td>Créat. / Activat.</td>
51
  <td>Activé</td>
52
  <td>Client</td>
53
  <td>ePack</td>
54
  <td>Maintenance</td>
55
</tr style=\"border-bottom: 1px solid black;\">\n";
56
  for($i = 0; $i < $DB->numrows($result2); $i++) {
57
    $data2=$DB->fetch_array($result2);
58
    $txt .= "<tr class='tab_bg_3'>\n";
59
    $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
  <td nowrap>30,00€</td>
64
</tr>\n";
65
    unset($data2);
66
  }
67
  $txt .= "<tr class='tab_bg_3'>
68
  <td colspan=\"4\"><br />Nombre total de packs: " . $i . "<br /></td>
69
  <td> Total HT: " . ($i*30) . ",00€</td>
70
</tr>\n";
71

    
72
  $txt .= "</table>";
73
  if($i == 0)
74
    unset($txt);
75
  return $txt;
76
}
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
//print $query;
82
$result = $DB->query($query) or die($DB->error());
83

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

    
86
  $data=$DB->fetch_array($result);
87

    
88
  /*
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
</tr>\n";
98
  */
99
  $txt = rvd_get_details($data['FK_clientderyxeo']);
100
  if($txt != "") {
101
    print "<p style=\"page-break-after: always\">&nbsp;</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
 }
110

    
111
/*
112
print "<p style=\"page-break-after: always\">&nbsp;</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
  <td colspan=\"3\"><br />Nombre total de revendeurs: " . $i . "<br /></td>
117
</tr>\n";
118
print "</table>";
119
*/
120

    
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
?>
Redmine Appliance - Powered by TurnKey Linux