-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchangementStatus.php
175 lines (157 loc) · 4.26 KB
/
changementStatus.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?php
error_reporting(E_ALL);
require_once("class.authentification.php");
require_once('class.config.php');
require_once("class.demandeListe.php");
require_once("class.demande.php");
require_once("class.log.php");
require_once("class.validation.php");
$objAuth = authentification::instance();
#$objLog = log::instance();
#$objvalid= validation::instance();
if (getParam('logout') == '1')
{
session_destroy();
header("Location: auth.php");
exit();
}
if (!$objAuth->estIdentifie())
{
header("Location: auth.php");
exit();
}
$ids = array();
$ids = $_POST['id'];
$objDemande = new demande();
foreach ($ids as $id)
{
$changementStatus = false;
$objDemande->ouvrir($id);
$objDemande->setStatus(getParam('form_status'));
if (getParam('form_status') != $objDemande->getStatus())
{
$changementStatus = true;
}
if (!$objDemande->setStatus(getParam('form_status')))
{
$changementStatus = false;
}
if ($objDemande->sauvegarde())
{
$statutEnMot = printLecture('statusLong',$objDemande->getStatus());
$email = file_get_contents('emailStatut.txt');
$email = preg_replace("/@@PRENOM@@/",$objDemande->getPrenom(),$email);
$email = preg_replace("/@@NOM@@/",$objDemande->getNom(),$email);
$email = preg_replace("/@@ID@@/",$objDemande->getID(),$email);
$email = preg_replace("/@@STATUT@@/",$statutEnMot,$email);
$headers = 'From: Stationnement AEP <[email protected]>' . "\r\n" .
'X-Mailer: pHP/' . phpversion();
if (config::SendEmail) mail($objDemande->getEmail(),"Demande de stationnement (".$objDemande->getId().") : changement de statut",$email, $headers);
printn($id . " => Le statut est maintenant : ".printLecture('status',$objDemande->getStatus())."<br>");
}
else
{
printn($id . " => Erreur! Impossible de changer le statut!");
}
}
/*
$objDemande = new demande();
$objDemande->ouvrir(getParam('id'));
$objDemande->setStatus(DEMANDE_STATUS_IMPRIME);
if ($objDemande->sauvegarde())
{
printn("Le statut est maintenant : imprimé.<br><br>Vous pouvez fermer la fenetre.");
}
else
{
printn("Erreur! Impossible de changer le statut!");
}
*/
exit(0);
function getParam($param)
{
if (isset($_POST[$param]))
{
return $_POST[$param];
}
if (isset($_GET[$param]))
{
return $_GET[$param];
}
return null;
}
function printn ($txt) { print $txt."\n"; }
// Imprime le bon texte en fonction de la valeu et du type
function printLecture($type, $valeur)
{
if ($type == "groupe")
{
if ($valeur == DEMANDE_GROUPE_AEP)
{
return "AEP";
}
}
elseif ($type == "status")
{
if ($valeur == DEMANDE_STATUS_ATTENTE)
{
return "Attente";
}
if ($valeur == DEMANDE_STATUS_REFUSE)
{
return "Refus";
}
if ($valeur == DEMANDE_STATUS_ACCEPTE)
{
return "Accepté";
}
if ($valeur == DEMANDE_STATUS_PAYE)
{
return "Payé";
}
if ($valeur == DEMANDE_STATUS_PREUVEOK)
{
return "PreuvesOK";
}
if ($valeur == DEMANDE_STATUS_ANNULE)
{
return "Annulé";
}
if ($valeur == DEMANDE_STATUS_IMPRIME)
{
return "Imprimé";
}
}
elseif ($type == "statusLong")
{
if ($valeur == DEMANDE_STATUS_ATTENTE)
{
return "Demande reçue, en attente... Pièces justificatives NON-REÇUES";
}
if ($valeur == DEMANDE_STATUS_REFUSE)
{
return "Demande refusée";
}
if ($valeur == DEMANDE_STATUS_ACCEPTE)
{
return "Demande acceptée";
}
if ($valeur == DEMANDE_STATUS_PAYE)
{
return "Demande payée";
}
if ($valeur == DEMANDE_STATUS_PREUVEOK)
{
return "Demande reçue, en attente... Pièces justificatives REÇUES";
}
if ($valeur == DEMANDE_STATUS_ANNULE)
{
return "Demande annulée";
}
if ($valeur == DEMANDE_STATUS_IMPRIME)
{
return "Demande acceptée et transférée au SDI";
}
}
}
?>