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

Historique | Voir | Annoter | Télécharger (4,64 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'] . "-00'
40
AND FK_clientderyxeo='" . $id . "'
41
AND FK_contract>='0'
42
ORDER BY activation_date";
43
  $result2 = $DB->query($query2) or die($DB->error());
44

    
45
  //La liste des epacks clairement hors maintenance
46

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

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

    
77
//Le tableau global pour avoir la liste des revendeurs
78
//parentid=3 -> c'est l'entité "partenaires"
79
$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";
80
$result = $DB->query($query) or die($DB->error());
81

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

    
84
  $data=$DB->fetch_array($result);
85

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

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

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

    
134

    
135
commonFooter();
136
?>
Redmine Appliance - Powered by TurnKey Linux