-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfacturation.php
More file actions
executable file
·244 lines (227 loc) · 11.7 KB
/
facturation.php
File metadata and controls
executable file
·244 lines (227 loc) · 11.7 KB
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
<?php
require_once("assets/Label.php");
require_once("assets/Sap.php");
require_once("assets/Lock.php");
require_once("includes/State.php");
require_once("session.inc");
/**
* Page to manage a plateform facturation
*/
if(!isset($_GET["plateforme"])) {
$_SESSION['alert-danger'] = "Manque un numéro de plateforme !";
header('Location: index.php');
exit;
}
$plateforme = $_GET['plateforme'];
checkPlateforme("facturation", $plateforme);
// Check if first facturation, if one is running, which one is the last one
$dir = DATA.$plateforme;
$first = true;
$current = State::currentState($dir);
$state = new State($dir);
if(file_exists($dir)) {
$first = false;
if(empty($current)) {
if(empty($state->getLast())) {
$first = true;
}
}
}
$name = DATA_GEST['facturation'][$plateforme];
/**
* Customized button to upload prepa
*
* @param string $title button title
* @param string $id upload input id
* @param string $disabled if button is disabled, when a process is running
* @return string
*/
function uploader(string $title, string $id, string $disabled): string
{
$html = '<input id="'.$id.'" type="file" name="'.$id.'" '.$disabled.' class="zip-file lockable" accept=".zip">';
$html .= '<label class="btn but-line" for="'.$id.'">';
$html .= $title;
$html .= '</label>';
return $html;
}
include("includes/lock.inc");
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<?php include("includes/header.inc");?>
</head>
<body>
<div class="container-fluid">
<div id="head">
<div id="div-logo">
<a href="index.php"><img src="icons/epfl-logo.png" alt="Logo EPFL" id="logo"/></a>
</div>
<div id="div-path">
<p><a href="index.php">Accueil</a> > Facturation <?= $name ?></p>
<p><a href="logout.php">Logout</a></p>
</div>
</div>
<div class="title <?php if(TEST_MODE) echo "test";?>">
<h1 class="text-center p-1"><?= $name ?></h1>
</div>
<form action="controller/uploadPrepa.php" method="post" id="form-fact" enctype="multipart/form-data" >
<div class="text-center">
<p>Facturation en cours : <?php echo (!empty($current)) ? $current : "aucune"; ?></p>
<p>Dernière facturation : <?php echo (!empty($state->getLast())) ? $state->getLast() : "aucune"; ?></p>
<input type="hidden" name="plate" id="plate" value="<?= $plateforme ?>" />
<input type="hidden" name="type" id="type" value="SAP">
<div class="row" id="buttons">
<div class="col-sm">
<?php
if(!$first) { ?>
<div><button type="button" id="open-historique" class="btn but-line">Ouvrir l'historique</button></div>
<?php
if(empty($current)) {
echo uploader("Facturation Pro Forma : ".$state->getNextMonth()."/".$state->getNextYear(), "PROFORMA", $disabled);
}
if(IS_SUPER && TEST_MODE == "TEST") {
?>
<div><button type="button" id="destroy" '.$disabled.' class="btn but-red lockable">Réinitialisation des tests : tout supprimer</button>
</div>
<?php }
}
if(IS_SUPER && TEST_MODE == "TEST") {
//echo uploader("Charger des archives", "ARCHIVE", $disabled);
$choices = [];
if($first) {
$title = "Charger une période";
}
else {
$title = "Réinitialiser et charger une période";
}
$prod = str_replace("data", "../prod/data", DATA.$plateforme);
foreach(globReverse($prod) as $dirYear) {
$year = basename($dirYear);
foreach(globReverse($dirYear) as $dirMonth) {
$month = basename($dirMonth);
$choices[$year.$month] = [$year, $month];
}
}?>
<div><button type="button" id="init-period" '.$disabled.' data-choices="<?php echo htmlentities(json_encode($choices),ENT_QUOTES); ?>" class="btn but-red lockable"><?= $title ?></button>
</div>
<div id="first"></div>
<div id="last">
</div>
<div id="reinit">
</div>
<?php }
?>
</div>
<div class="col-sm">
<?php
if($first) {
if(DATA_GEST['tarifs'] && array_key_exists($plateforme, DATA_GEST['tarifs'])) {
echo uploader("Préparer 1ère facturation", "FIRST", $disabled);
}
}
else {
if(empty($current)) {
echo uploader("Refaire factures : ".$state->getLastMonth()."/".$state->getLastYear(), "REDO", $disabled);
echo uploader("Facturation nouveau mois : ".$state->getNextMonth()."/".$state->getNextYear(), "MONTH", $disabled);
}
}
?>
</div>
</div>
<div class="row hidden" id="historique-div">
<div><button type="button" id="close-historique" class="btn but-line">Fermer l'historique</button></div>
</div>
</div>
<?php include("includes/message.inc");
if(!empty($lockProcess)) {
$other = "";
if($lockedPlate != $plateforme) {
$other = " pour une autre plateforme";
}
echo'<div class="text-center" >'.$lockedProcessus.' est en cours'.$other.'. Veuillez patientez et rafraîchir la page...</div>';
}
if(!empty($lockUser)) {
echo'<div class="text-center">'.$dlTxt.'</div>';
}
?>
<div id="display"></div>
</form>
<div id="plate-content">
<?php
if(file_exists($dir)) {
?>
<table class="table table-boxed">
<?php
// Listing of all year/month/version/run for th plateform
foreach(globReverse($dir) as $dirYear) {
$year = basename($dirYear);
foreach(globReverse($dirYear) as $dirMonth) {
$month = basename($dirMonth);
$dirVersions = globReverse($dirMonth);
if(count($dirVersions) > 0) {
echo '<tr>';
echo '<td rowspan="'.count($dirVersions).'">';
if (file_exists($dirMonth."/archive.csv")) { ?>
<svg class="icon" aria-hidden="true">
<use xlink:href="#star"></use>
</svg>
<?php }
echo $month.' '.$year;
if (file_exists($dirMonth."/".Lock::FILES['month'])) { ?>
<svg class="icon" aria-hidden="true">
<use xlink:href="#lock"></use>
</svg>
<?php }
echo '</td>';
$line = 0;
foreach($dirVersions as $dirVersion) {
$version = basename($dirVersion);
if($line > 0){
echo '<tr>';
}
echo '<td>'.$version;
if (file_exists($dirVersion."/".Lock::FILES['version'])) { ?>
<svg class="icon" aria-hidden="true">
<use xlink:href="#lock"></use>
</svg>
<?php }
echo '</td><td>';
foreach(globReverse($dirVersion) as $dirRun) {
$run = basename($dirRun);
if($run != $lockedRun || $lockedProcessus != "Une préfacturation") {
$value = 'year='.$year.'&month='.$month.'&version='.$version.'&run='.$run;
$label = Label::load($dirRun);
if(empty($label)) {
$label = $run;
}
$sap = new Sap($dirRun);
$lockRun = Lock::load($dirRun, "run");
echo ' <button type="button" value="'.$value.'" class="open-run btn '.Sap::color($sap->status(), is_null($lockRun) ? "" : $lockRun).'"> '.$label;
if (!is_null($lockRun)) { ?>
<svg class="icon" aria-hidden="true">
<use xlink:href="#lock"></use>
</svg>
<?php }
echo '</button>';
}
}
echo '</td>';
if($line > 0){
echo '</tr>';
}
$line++;
}
echo '</tr>';
}
}
}
?></table><?php
}
?>
</div>
</div>
<?php include("includes/footer.inc");?>
<script src="js/facturation.js"></script>
</body>
</html>