Révision e8a2f7fa
plugins/anet_epacks/front/plugin_anet_epacks.generate_odt_courrier_end_contract.form.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
// Génère le fichier ODT/PDF: courrier indiquant que la maintenance se termine cette année ... |
|
4 |
include "../ryxeo.php"; |
|
5 |
|
|
6 |
if(!defined('GLPI_ROOT')){ |
|
7 |
define('GLPI_ROOT', '../../..'); |
|
8 |
} |
|
9 |
include_once (GLPI_ROOT . "/inc/includes.php"); |
|
10 |
include_once("tools.php"); |
|
11 |
|
|
12 |
checkRight("config","w"); |
|
13 |
//checkSeveralRightsOr(array("config" => "w", "profile" => "w")); |
|
14 |
|
|
15 |
require_once('lib/odf.php'); |
|
16 |
//$odf->exportAsAttachedFile(); |
|
17 |
//$odf->printVars(); |
|
18 |
//print_r($odf); |
|
19 |
//$odf->saveToDisk('tmp/fichier.odt'); |
|
20 |
|
|
21 |
global $DB; |
|
22 |
|
|
23 |
//Si on demande a re-generer le fichier ODF on ne fait que ça |
|
24 |
//a faire |
|
25 |
if(isset($_GET['cid'])) { |
|
26 |
$fk_entitee = $_GET['clientid']; |
|
27 |
//On a demandé a re-générer le contrat |
|
28 |
//print "re - creation du contrat ... "; |
|
29 |
|
|
30 |
//Le nom du contrat |
|
31 |
$query = "SELECT name FROM glpi_contracts WHERE ID='" . $_GET['cid'] . "'"; |
|
32 |
$result = $DB->query($query); |
|
33 |
$data=$DB->fetch_array($result); |
|
34 |
$cname=$data[0]; |
|
35 |
|
|
36 |
//les epacks |
|
37 |
$query2 = "SELECT code FROM glpi_plugin_anet_epacks WHERE FK_contract='" . $_GET['cid'] . "'"; |
|
38 |
$result2 = $DB->query($query2); |
|
39 |
$epackstxt = ""; |
|
40 |
|
|
41 |
for($i = 0; $i < $DB->numrows($result2); $i++) { |
|
42 |
$data2 = $DB->fetch_array($result2); |
|
43 |
$epackstxt .= " " . $data2[0]; |
|
44 |
} |
|
45 |
|
|
46 |
//Le niveau du contrat de maintenance ... |
|
47 |
$niveau = "-" . $_GET['niveau']; |
|
48 |
|
|
49 |
$odf = new odf("courrier_fin_maintenance_cette_annee.odt"); |
|
50 |
setlocale(LC_TIME, "fr_FR"); |
|
51 |
error_reporting(E_ALL); |
|
52 |
$odf->setVars('date', strftime("%A %e %B %Y"), true, 'UTF-8'); |
|
53 |
|
|
54 |
$odf->setVars('datedebut', strftime("%A %e %B %Y"), true, 'UTF-8'); |
|
55 |
$odf->setVars('epacks', $epackstxt, true, 'UTF-8'); |
|
56 |
|
|
57 |
$query2="SELECT * FROM glpi_entities, glpi_entities_data WHERE glpi_entities.ID=FK_entities AND glpi_entities.ID='$fk_entitee';"; |
|
58 |
//print $query2; |
|
59 |
//$DB->query($query2) or die($DB->error()); |
|
60 |
$result2 = $DB->query($query2); |
|
61 |
$data2=$DB->fetch_array($result2); |
|
62 |
|
|
63 |
$odf->setVars('cname', $cname, true, 'UTF-8'); |
|
64 |
|
|
65 |
$odf->setVars('client', $data2['name'], true, 'UTF-8'); |
|
66 |
$odf->setVars('clienttype', "____________________", true, 'UTF-8'); |
|
67 |
$odf->setVars('clientcapital', "____________________", true, 'UTF-8'); |
|
68 |
$odf->setVars('clientrcs', "____________________", true, 'UTF-8'); |
|
69 |
$odf->setVars('clientsiret', "____________________", true, 'UTF-8'); |
|
70 |
$odf->setVars('clientadresse', $data2['address'], true, 'UTF-8'); |
|
71 |
$odf->setVars('clientcp', $data2['postcode']); |
|
72 |
$odf->setVars('clientville', $data2['town'], true, 'UTF-8'); |
|
73 |
$odf->setVars('clientcontact', "____________________", true, 'UTF-8'); |
|
74 |
|
|
75 |
//On créé un fichier local pour archive ... |
|
76 |
$fichier = "contrats/" . date("Y-m-d") . "-abuledu-maintenance-" . $cname . ".odt"; |
|
77 |
$odf->saveToDisk($fichier); |
|
78 |
pushfile($fichier); |
|
79 |
//On génère le fichier |
|
80 |
//$odf->exportAsAttachedFile(); |
|
81 |
//print $texte; |
|
82 |
|
|
83 |
|
|
84 |
} |
|
85 |
else { |
|
86 |
$fk_entitee = $_POST['clientid']; |
|
87 |
//On créé le contrat ... |
|
88 |
if(count($_POST['epack']) > 0) { |
|
89 |
$cname=strtoupper(anti_speciaux($_POST['clientname'])) . date("Ymd"); |
|
90 |
$cnum=date("Ymd"); |
|
91 |
//Verification que ce numero de contrat ne soit pas déjà pris ... |
|
92 |
$query="SELECT count(*) FROM glpi_contracts WHERE name='" . $cname . "'"; |
|
93 |
//$DB->query($query) or die($DB->error()); |
|
94 |
$result = $DB->query($query); |
|
95 |
$data=$DB->fetch_array($result); |
|
96 |
if($data[0] > 0) { |
|
97 |
print "<p>AAAAAAAAaaaaaaaaaatention, ce numéro de contrat $cname / $cnum est déjà utilisé !!! cette situation ne peut arriver que si vous créez plus d'un contrat par jour ... si c'est le cas voyez avec les développeurs ...</p>\n"; |
|
98 |
exit; |
|
99 |
} |
|
100 |
|
|
101 |
$query="INSERT INTO glpi_contracts(FK_entities,recursive,name,num,contract_type,begin_date,duration,notice,periodicity,facturation,notes,alert,renewal) |
|
102 |
VALUES(" . $_POST['clientid'] . ",'0','$cname','$cnum','6', NOW( ) ,'36','1','12','12','Créé par anet :: " . basename($_SERVER['SCRIPT_FILENAME']) . "','3','1' )"; |
|
103 |
$texte .= "<p> Création du contrat :: $query</p>\n"; |
|
104 |
|
|
105 |
$DB->query($query) or die($DB->error()); |
|
106 |
$contractid = $DB->insert_id(); |
|
107 |
|
|
108 |
$texte .= "<p>Pour y associer les ePacks suivants:</p> |
|
109 |
<ul>\n"; |
|
110 |
|
|
111 |
for($i = 0; $i < count($_POST['epack']); $i++) { |
|
112 |
$epack = trim($_POST['epack'][$i]); |
|
113 |
$epackstxt .= " $epack "; |
|
114 |
$query="UPDATE glpi_plugin_anet_epacks SET FK_contract='$contractid' WHERE code='$epack'"; |
|
115 |
$DB->query($query) or die($DB->error()); |
|
116 |
|
|
117 |
$texte .= "<li>$query</li>\n"; |
|
118 |
} |
|
119 |
$texte .= "</ul>"; |
|
120 |
|
|
121 |
} |
|
122 |
//Sinon c'est qu'on génère un contrat de partenaire global ENR2009 |
|
123 |
else { |
|
124 |
$cname=strtoupper(anti_speciaux(base64_decode($_GET['clientname']))) . "-ENR2009"; |
|
125 |
$cnum=date("Ymd"); |
|
126 |
//Verification que ce numero de contrat ne soit pas déjà pris ... |
|
127 |
$query="SELECT count(*) FROM glpi_contracts WHERE name='" . $cname . "'"; |
|
128 |
//$DB->query($query) or die($DB->error()); |
|
129 |
$result = $DB->query($query); |
|
130 |
$data=$DB->fetch_array($result); |
|
131 |
if($data[0] > 0) { |
|
132 |
print "<p>AAAAAAAAaaaaaaaaaatention, ce numéro de contrat $cname / $cnum est déjà utilisé !!! cette situation ne peut arriver que si vous créez plus d'un contrat par jour ... si c'est le cas voyez avec les développeurs ... <a href=\"plugin_anet_epacks.generate_odt_contrat_partenaire_enr2009.form.php\">Un petit retour à l'accueil</a> ?</p>\n"; |
|
133 |
exit; |
|
134 |
} |
|
135 |
|
|
136 |
$query="INSERT INTO glpi_contracts(FK_entities,recursive,name,num,contract_type,begin_date,duration,notice,periodicity,facturation,notes,alert,renewal) |
|
137 |
VALUES(" . $_GET['clientid'] . ",'0','$cname','$cnum','6', NOW( ) ,'36','1','12','12','Créé par anet :: " . basename($_SERVER['SCRIPT_FILENAME']) . "','3','1' )"; |
|
138 |
$texte .= "<p> Création du contrat partenaire :: $query</p>\n"; |
|
139 |
|
|
140 |
$DB->query($query) or die($DB->error()); |
|
141 |
$contractid = $DB->insert_id(); |
|
142 |
|
|
143 |
} |
|
144 |
|
|
145 |
print "<p>Désolé pour la mise en page et cette superbe page blanche ...</p>\n"; |
|
146 |
|
|
147 |
print "<p>Les packs sont maintenant associés au contrat, <a href=\"plugin_anet_epacks.view_maintenance.php?year=" . date("Y") . "\">cliquez ici pour choisir le type de contrat que vous voulez</a> pour ce client.</p>\n"; |
|
148 |
} |
|
149 |
?> |
plugins/anet_epacks/front/plugin_anet_epacks.index.php | ||
---|---|---|
47 | 47 |
<li><a href=\"plugin_anet_epacks.view_maintenance.php?year=" . date("Y") . "\">Liste des contrats auto-générés</a></li> |
48 | 48 |
<li><a href=\"plugin_anet_epacks.view_array_recap.php\">Tableau récapitulatif de mes serveurs</a> (page d'accueil du site normalement)</li> |
49 | 49 |
<li><a href=\"plugin_anet_epacks.view_recap_mensuel_rvd.php?year=" . date("Y") . "&month=" . date("m") . "\">Relevé mensuel pour facturer les revendeurs</a></li> |
50 |
<li><a href=\"plugin_anet_epacks.view_endcontract.php?year=" . date("Y") . "&month=12\">Création des courriers d'information de fin de contrat :</a> récupère la liste de tous les contrats qui se terminent dans le courant de l'année en cours et génère un fichier openoffice préremplis qu'il suffit d'envoyer.</li> |
|
50 | 51 |
</ul> |
51 | 52 |
|
52 | 53 |
<h2>Tâches pour l'administrateur</h2> |
plugins/anet_epacks/front/plugin_anet_epacks.verif_contract_epack.php | ||
---|---|---|
1 |
<?php |
|
2 |
/* |
|
3 |
* recherche les contrats qui ne sont pas raccrochés aux epacks |
|
4 |
* dans la table glpi_plugin_anet_epacks on a un FK_contract qui doit faire référence au bon contrat. |
|
5 |
* pour mettre à jour on cherche donc les FK_enduser dans glpi_plugin_anet_epacks WHERE FK_contract=0 |
|
6 |
* ensuite on cherche si ce FK_enduser existe dans glpi_contracts FK_entities |
|
7 |
* si c'est le cas on met à jour glpi_plugin_anet_epacks |
|
8 |
* |
|
9 |
*/ |
|
10 |
|
|
11 |
if(!defined('GLPI_ROOT')){ |
|
12 |
define('GLPI_ROOT', '../../..'); |
|
13 |
} |
|
14 |
include_once (GLPI_ROOT . "/inc/includes.php"); |
|
15 |
|
|
16 |
checkRight("config","w"); |
|
17 |
global $DB; |
|
18 |
|
|
19 |
commonHeader("anet_epacks",$_SERVER['PHP_SELF'],"config","plugins"); |
|
20 |
|
|
21 |
print "<h3>Recollage automatique des epacks <-> contrats</h3>\n"; |
|
22 |
|
|
23 |
print "<div style=\"text-align:left\">"; |
|
24 |
|
|
25 |
$query = "SELECT FK_enduser,code FROM glpi_plugin_anet_epacks WHERE FK_contract='0' AND FK_enduser>'0'"; |
|
26 |
$result = $DB->query($query); |
|
27 |
//print $query; |
|
28 |
while($data=$DB->fetch_array($result)) { |
|
29 |
$enduser=$data[0]; |
|
30 |
$code=$data[1]; |
|
31 |
|
|
32 |
$query1 = "SELECT * FROM glpi_entities WHERE ID='" . $enduser . "'"; |
|
33 |
$result1 = $DB->query($query1); |
|
34 |
$data1=$DB->fetch_array($result1); |
|
35 |
$clientfinal = $data1['completename']; |
|
36 |
|
|
37 |
|
|
38 |
$query2 = "SELECT * FROM glpi_contracts WHERE FK_entities='" . $enduser . "'"; |
|
39 |
$result2 = $DB->query($query2); |
|
40 |
$data2=$DB->fetch_array($result2); |
|
41 |
|
|
42 |
if(trim($data2['name'])) { |
|
43 |
$query3 = "UPDATE glpi_plugin_anet_epacks SET FK_contract='" . $data2['ID'] . "' WHERE FK_enduser='$enduser' AND FK_contract='0'"; |
|
44 |
print "<p>Recollement automatique pour $code -> $clientfinal -> nouvelle ref contrat: " . $data2['ID'] . "</p>"; |
|
45 |
$result3 = $DB->query($query3); |
|
46 |
$data3=$DB->fetch_array($result3); |
|
47 |
} |
|
48 |
else { |
|
49 |
print "<p><b>Vérification manuelle nécessaire</b> pour epack ref $code client final $clientfinal (ref $enduser) qui n'a aucune référence de contrat en recollement automatique (" . $data2['ID'] . ")</p>"; |
|
50 |
} |
|
51 |
} |
|
52 |
|
|
53 |
//$query = "UPDATE `glpi_users` SET FK_entities='1' WHERE `FK_entities` = 0 AND email NOT LIKE '%ryxeo.com'"; |
|
54 |
//$result = $DB->query($query); |
|
55 |
|
|
56 |
commonFooter(); |
|
57 |
?> |
plugins/anet_epacks/front/plugin_anet_epacks.view_endcontract.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
// Génère le fichier ODT/PDF pour le revendeur avec son numéro de pack à utiliser. Ce fichier doit contenir un certain nombre d'informations (url pour enregistrer son pack etc.) |
|
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 "<p>Liste : <a href=\"" . $PHP_SELF . "\">Tous</a> - <a href=\"" . $PHP_SELF . "?year=2008\">2008</a> - <a href=\"" . $PHP_SELF . "?year=2009\">2009</a> - <a href=\"" . $PHP_SELF . "?year=2010\">2010</a> - <a href=\"" . $PHP_SELF . "?year=2011\">2011</a>.</p>"; |
|
16 |
|
|
17 |
|
|
18 |
global $DB; |
|
19 |
|
|
20 |
if($_GET['year']) |
|
21 |
$condition = "AND `begin_date`+INTERVAL `duration` MONTH < '" . $_GET['year'] . "-12-31' AND `begin_date`+INTERVAL `duration` MONTH > '" . $_GET['year'] . "-01-01'"; |
|
22 |
|
|
23 |
//Les contrats attribués |
|
24 |
//Permet de limiter un peu l'affichage, il faudra faire un système de recherche ou pagination à terme |
|
25 |
$query = "SELECT c.*,`begin_date`+INTERVAL `duration` MONTH as endcontract FROM glpi_plugin_anet_epacks |
|
26 |
LEFT JOIN glpi_contracts AS c ON FK_contract=c.ID |
|
27 |
WHERE FK_contract > 0 $condition GROUP BY FK_contract"; |
|
28 |
//print $query; |
|
29 |
//$DB->query($query) or die($DB->error()); |
|
30 |
$result = $DB->query($query); |
|
31 |
|
|
32 |
print "<table class='tab_cadre' width='100%' cellpadding='2'>\n"; |
|
33 |
print "<tr class='tab_bg_3'> |
|
34 |
<td>Client</td> |
|
35 |
<td>Nom du contrat</td> |
|
36 |
<td>Numéro</td> |
|
37 |
<td>Coût</td> |
|
38 |
<td>Début / Fin</td> |
|
39 |
<td>Durée (mois)</td> |
|
40 |
<td>ePacks concernés</td> |
|
41 |
<td>Documents</td> |
|
42 |
</tr>\n"; |
|
43 |
|
|
44 |
for($i = 0; $i < $DB->numrows($result); $i++) { |
|
45 |
$data=$DB->fetch_array($result); |
|
46 |
|
|
47 |
$query2="SELECT g.name as clientderyxeo FROM glpi_plugin_anet_epacks AS e LEFT JOIN glpi_entities AS g ON FK_clientderyxeo=g.ID |
|
48 |
LEFT JOIN glpi_contracts AS c ON FK_contract=c.ID |
|
49 |
WHERE FK_contract= '" . $data['ID'] . "'"; |
|
50 |
//print $query2 . "<br />" . "<br />"; |
|
51 |
//$DB->query($query) or die($DB->error()); |
|
52 |
$epacks = ""; |
|
53 |
$result2 = $DB->query($query2); |
|
54 |
for($j = 0; $j < $DB->numrows($result2); $j++) { |
|
55 |
$data2=$DB->fetch_array($result2); |
|
56 |
$epacks .= $data2['code'] . "<br />"; |
|
57 |
} |
|
58 |
|
|
59 |
$query3="SELECT e.*,g.name as enduser FROM glpi_plugin_anet_epacks AS e LEFT JOIN glpi_entities AS g ON FK_enduser=g.ID |
|
60 |
LEFT JOIN glpi_contracts AS c ON FK_contract=c.ID |
|
61 |
WHERE FK_enduser= '" . $data['FK_entities'] . "' |
|
62 |
LIMIT 500;"; |
|
63 |
//print $query3 . "<br />" . "<br />"; |
|
64 |
$result3 = $DB->query($query3); |
|
65 |
$enduser = " "; |
|
66 |
for($j = 0; $j < $DB->numrows($result3); $j++) { |
|
67 |
if($j>0) |
|
68 |
$enduser .= " :: "; |
|
69 |
$data3=$DB->fetch_array($result3); |
|
70 |
$enduser .= stripslashes($data3['enduser']); |
|
71 |
} |
|
72 |
|
|
73 |
print "<tr class='tab_bg_3'>\n"; |
|
74 |
print " <td>" . $data2['clientderyxeo'] . " <br /> " . $enduser . "</td> |
|
75 |
<td>" . $data['name'] . "</td> |
|
76 |
<td>" . $data['num'] . "</td> |
|
77 |
<td>" . $data['cost'] . "</td> |
|
78 |
<td>" . $data['begin_date'] . " <br /> " . $data['endcontract'] . "</td> |
|
79 |
<td>" . $data['duration'] . "</td> |
|
80 |
<td>" . $epacks . "</td>\n"; |
|
81 |
print " <td> |
|
82 |
<a href=\"plugin_anet_epacks.generate_odt_courrier_end_contract.form.php?clientid=" . $data['FK_entities'] . "&cid=" . $data['ID'] . "&niveau=courrier_endcontract\">Courrier de fin de maintenance</a><br /> |
|
83 |
</td> |
|
84 |
</tr>\n"; |
|
85 |
} |
|
86 |
|
|
87 |
|
|
88 |
print "</table>"; |
|
89 |
|
|
90 |
commonFooter(); |
|
91 |
?> |
Formats disponibles : Unified diff