These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * When a user generates the expense report for all pilots |
||
4 | */ |
||
5 | define("EXPENSE_REPORT_GENERATOR_ACTION_GENERATE", "generate"); |
||
6 | |||
7 | /** |
||
8 | * When a user has to select year and quartil |
||
9 | */ |
||
10 | define("EXPENSE_REPORT_GENERATOR_ACTION_SELECT", "select"); |
||
11 | |||
12 | /** |
||
13 | * \file generateExpenseNote.php |
||
14 | * \ingroup flightlog |
||
15 | * \brief Generate expense notes for a quartil |
||
16 | * |
||
17 | */ |
||
18 | |||
19 | // Load Dolibarr environment |
||
20 | if (false === (@include '../main.inc.php')) { // From htdocs directory |
||
21 | require '../../documents/custom/main.inc.php'; // From "custom" directory |
||
22 | } |
||
23 | |||
24 | dol_include_once('/compta/facture/class/facture.class.php'); |
||
25 | dol_include_once('/adherents/class/adherent.class.php'); |
||
26 | dol_include_once("/flightlog/lib/flightLog.lib.php"); |
||
27 | dol_include_once("/flightlog/class/bbctypes.class.php"); |
||
28 | dol_include_once("/product/class/product.class.php"); |
||
29 | dol_include_once('/core/modules/facture/modules_facture.php'); |
||
30 | |||
31 | global $db, $langs, $user, $conf; |
||
32 | |||
33 | // Load translation files required by the page |
||
34 | $langs->load("mymodule@mymodule"); |
||
35 | $langs->load("trips"); |
||
36 | $langs->load("bills"); |
||
37 | |||
38 | // Get parameters |
||
39 | $id = GETPOST('id', 'int'); |
||
40 | $action = GETPOST('action', 'alpha'); |
||
41 | $year = GETPOST('year', 'int', 3); |
||
42 | |||
43 | //post parameters |
||
44 | $additionalBonus = GETPOST('additional_bonus', 'array', 2); |
||
45 | $pilotIds = GETPOST('pilot', 'array', 2); |
||
46 | $amouts = GETPOST('amout', 'array', 2); |
||
47 | $amoutDiscounts = GETPOST('amoutDiscount', 'array', 2); |
||
48 | $publicNote = GETPOST('public_note', 'alpha', 2); |
||
49 | $privateNote = GETPOST('private_note', 'alpha', 2); |
||
50 | $type = GETPOST("type", "int", 3); |
||
51 | $conditionReglement = GETPOST("cond_reglement_id", "int", 3); |
||
52 | $modeReglement = GETPOST("mode_reglement_id", "int", 3); |
||
53 | $bankAccount = GETPOST("fk_account", "int", 3); |
||
54 | $documentModel = GETPOST("model", "alpha", 3); |
||
55 | |||
56 | //variables |
||
57 | $currentYear = date('Y'); |
||
58 | |||
59 | $t1 = new Bbctypes($db); |
||
60 | $t1->fetch(1); |
||
61 | $t2 = new Bbctypes($db); |
||
62 | $t2->fetch(2); |
||
63 | $t3 = new Bbctypes($db); |
||
64 | $t3->fetch(3); |
||
65 | $t4 = new Bbctypes($db); |
||
66 | $t4->fetch(4); |
||
67 | $t5 = new Bbctypes($db); |
||
68 | $t5->fetch(5); |
||
69 | $t6 = new Bbctypes($db); |
||
70 | $t6->fetch(6); |
||
71 | $t7 = new Bbctypes($db); |
||
72 | $t7->fetch(7); |
||
73 | |||
74 | //Query |
||
75 | $sql = "SELECT USR.lastname AS nom , USR.firstname AS prenom ,COUNT(`idBBC_vols`) AS nbr,fk_pilot as pilot, TT.numero as type,SEC_TO_TIME(SUM(TIME_TO_SEC(TIMEDIFF(heureA,heureD)))) AS time"; |
||
76 | $sql .= " FROM llx_bbc_vols, llx_user AS USR,llx_bbc_types AS TT "; |
||
77 | $sql .= " WHERE `fk_pilot`= USR.rowid AND fk_type = TT.idType AND YEAR(llx_bbc_vols.date) = " . $year; |
||
78 | $sql .= " GROUP BY fk_pilot,`fk_type`"; |
||
79 | |||
80 | $flightYears = getFlightYears(); |
||
81 | |||
82 | |||
83 | $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', |
||
84 | 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); |
||
85 | $hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', |
||
86 | 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); |
||
87 | $hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', |
||
88 | 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); |
||
89 | |||
90 | $object = new Facture($db); |
||
91 | $vatrate = "0.000"; |
||
92 | |||
93 | // Access control |
||
94 | View Code Duplication | if (!$conf->facture->enabled || !$user->rights->flightlog->vol->status || !$user->rights->flightlog->vol->financialGenerateDocuments) { |
|
0 ignored issues
–
show
|
|||
95 | accessforbidden(); |
||
96 | } |
||
97 | |||
98 | // Default action |
||
99 | if (empty($action)) { |
||
100 | $action = EXPENSE_REPORT_GENERATOR_ACTION_SELECT; |
||
101 | } |
||
102 | |||
103 | llxHeader('', $langs->trans('Generate billing'), ''); |
||
104 | print load_fiche_titre("Générer factures"); |
||
105 | |||
106 | /* |
||
107 | * ACTIONS |
||
108 | * |
||
109 | * Put here all code to do according to value of "action" parameter |
||
110 | */ |
||
111 | |||
112 | if ($action == EXPENSE_REPORT_GENERATOR_ACTION_GENERATE) { |
||
113 | |||
114 | if ($year < $currentYear) { |
||
115 | |||
116 | if (empty($documentModel) || $conditionReglement == 0 || empty($conditionReglement) || $modeReglement == 0 || empty($modeReglement)) { |
||
117 | dol_htmloutput_errors("Erreur de configuration !"); |
||
118 | } else { |
||
119 | $table = sqlToArray($db, $sql, true, $year); |
||
120 | $startYearTimestamp = (new \DateTime())->setDate($year, 1, 1)->getTimestamp(); |
||
121 | $endYearTimestamp = (new \DateTime())->setDate($year, 12, 31)->getTimestamp(); |
||
122 | |||
123 | foreach ($table as $currentMissionUserId => $value) { |
||
124 | |||
125 | $expenseNoteUser = new User($db); |
||
126 | $expenseNoteUser->fetch($currentMissionUserId); |
||
127 | |||
128 | $adherent = new Adherent($db); |
||
129 | $adherent->fetch($expenseNoteUser->fk_member); |
||
130 | |||
131 | $addBonus = (int)$additionalBonus[$currentMissionUserId]; |
||
132 | if ($addBonus < 0) { |
||
133 | dol_htmloutput_mesg("Facture ignorée " . $adherent->getFullName($langs), '', 'warning'); |
||
134 | continue; |
||
135 | } |
||
136 | |||
137 | $totalFlights = $value['1']['count'] + $value['2']['count'] + $value['orga']['count'] + $value['3']['count'] + $value['4']['count'] + $value['6']['count'] + $value['7']['count']; |
||
138 | $totalBonus = $value['1']['count'] * $t1->service->price_ttc + $value['2']['count'] * $t2->service->price_ttc + $value['orga']['count'] * 25 + $addBonus; |
||
139 | |||
140 | $totalFacture = $value['3']['count'] * $t3->service->price_ttc + $value['4']['count'] * $t4->service->price_ttc + $value['6']['count'] * $t6->service->price_ttc + $value['7']['count'] * $t7->service->price_ttc; |
||
141 | |||
142 | $facturable = ($totalFacture - $totalBonus < 0 ? 0 : $totalFacture - $totalBonus); |
||
143 | |||
144 | if ($facturable == 0) { |
||
145 | continue; |
||
146 | } |
||
147 | |||
148 | $object = new Facture($db); |
||
149 | $object->fetch_thirdparty(); |
||
150 | |||
151 | $object->socid = $adherent->fk_soc; |
||
152 | $object->type = $type; |
||
153 | $object->number = "provisoire"; |
||
154 | $object->date = (new DateTime())->getTimestamp(); |
||
155 | $object->date_pointoftax = ""; |
||
156 | $object->note_public = $publicNote; |
||
157 | $object->note_private = $privateNote; |
||
158 | $object->ref_client = ""; |
||
159 | $object->ref_int = ""; |
||
160 | $object->modelpdf = $documentModel; |
||
161 | $object->cond_reglement_id = $conditionReglement; |
||
162 | $object->mode_reglement_id = $modeReglement; |
||
163 | $object->fk_account = $bankAccount; |
||
164 | |||
165 | $id = $object->create($user); |
||
166 | |||
167 | $soc = new Societe($db); |
||
168 | $soc->fetch($adherent->fk_soc); |
||
169 | |||
170 | if ($id <= 0) { |
||
171 | setEventMessages($object->error, $object->errors, 'errors'); |
||
172 | } |
||
173 | |||
174 | $localtax1_tx = get_localtax(0, 1, $object->thirdparty); |
||
175 | $localtax2_tx = get_localtax(0, 2, $object->thirdparty); |
||
176 | |||
177 | //T3 |
||
178 | $pu_ht = price2num($t3->service->price, 'MU'); |
||
179 | $pu_ttc = price2num($t3->service->price_ttc, 'MU'); |
||
180 | $pu_ht_devise = price2num($t3->service->price, 'MU'); |
||
181 | $qty = $value['3']['count']; |
||
182 | |||
183 | $result = $object->addline( |
||
184 | $t3->service->description, |
||
185 | $pu_ht, |
||
186 | $qty, |
||
187 | 0, |
||
188 | $localtax1_tx, |
||
189 | $localtax2_tx, |
||
190 | $t3->service->id, |
||
191 | 0, |
||
192 | $startYearTimestamp, |
||
193 | $endYearTimestamp, |
||
194 | 0, |
||
195 | 0, |
||
196 | '', |
||
197 | 'TTC', |
||
198 | $pu_ttc, |
||
199 | 1, |
||
200 | -1, |
||
201 | 0, |
||
202 | '', |
||
203 | 0, |
||
204 | 0, |
||
205 | '', |
||
206 | '', |
||
207 | $t3->service->label, |
||
208 | [], |
||
209 | 100, |
||
210 | '', |
||
211 | 0, |
||
212 | 0 |
||
213 | ); |
||
214 | |||
215 | //T4 |
||
216 | $pu_ht = price2num($t4->service->price, 'MU'); |
||
217 | $pu_ttc = price2num($t4->service->price_ttc, 'MU'); |
||
218 | $pu_ht_devise = price2num($t4->service->price, 'MU'); |
||
219 | $qty = $value['4']['count']; |
||
220 | |||
221 | $result = $object->addline( |
||
222 | $t4->service->description, |
||
223 | $pu_ht, |
||
224 | $qty, |
||
225 | 0, |
||
226 | $localtax1_tx, |
||
227 | $localtax2_tx, |
||
228 | $t4->service->id, |
||
229 | 0, |
||
230 | $startYearTimestamp, |
||
231 | $endYearTimestamp, |
||
232 | 0, |
||
233 | 0, |
||
234 | '', |
||
235 | 'HT', |
||
236 | $pu_ttc, |
||
237 | 1, |
||
238 | -1, |
||
239 | 0, |
||
240 | '', |
||
241 | 0, |
||
242 | 0, |
||
243 | '', |
||
244 | '', |
||
245 | $t4->service->label, |
||
246 | [], |
||
247 | 100, |
||
248 | '', |
||
249 | 0, |
||
250 | 0 |
||
251 | ); |
||
252 | |||
253 | //T6 |
||
254 | $pu_ht = price2num($t6->service->price, 'MU'); |
||
255 | $pu_ttc = price2num($t6->service->price, 'MU'); |
||
256 | $pu_ht_devise = price2num($t6->service->price, 'MU'); |
||
257 | $qty = $value['6']['count']; |
||
258 | |||
259 | $result = $object->addline( |
||
260 | $t6->service->description, |
||
261 | $pu_ht, |
||
262 | $qty, |
||
263 | 0, |
||
264 | $localtax1_tx, |
||
265 | $localtax2_tx, |
||
266 | $t6->service->id, |
||
267 | 0, |
||
268 | $startYearTimestamp, |
||
269 | $endYearTimestamp, |
||
270 | 0, |
||
271 | 0, |
||
272 | '', |
||
273 | 'HT', |
||
274 | $pu_ttc, |
||
275 | 1, |
||
276 | -1, |
||
277 | 0, |
||
278 | '', |
||
279 | 0, |
||
280 | 0, |
||
281 | '', |
||
282 | '', |
||
283 | $t6->service->label, |
||
284 | [], |
||
285 | 100, |
||
286 | '', |
||
287 | 0, |
||
288 | 0 |
||
289 | ); |
||
290 | |||
291 | //T7 |
||
292 | $pu_ht = price2num($t7->service->price, 'MU'); |
||
293 | $pu_ttc = price2num($t7->service->price_ttc, 'MU'); |
||
294 | $pu_ht_devise = price2num($t7->service->price, 'MU'); |
||
295 | $qty = $value['7']['count']; |
||
296 | |||
297 | $result = $object->addline( |
||
298 | $t7->service->description, |
||
299 | $pu_ht, |
||
300 | $qty, |
||
301 | 0, |
||
302 | $localtax1_tx, |
||
303 | $localtax2_tx, |
||
304 | $t7->service->id, |
||
305 | 0, |
||
306 | $startYearTimestamp, |
||
307 | $endYearTimestamp, |
||
308 | 0, |
||
309 | 0, |
||
310 | '', |
||
311 | 'HT', |
||
312 | $pu_ttc, |
||
313 | 1, |
||
314 | -1, |
||
315 | 0, |
||
316 | '', |
||
317 | 0, |
||
318 | 0, |
||
319 | '', |
||
320 | '', |
||
321 | $t7->service->label, |
||
322 | [], |
||
323 | 100, |
||
324 | '', |
||
325 | 0, |
||
326 | 0 |
||
327 | ); |
||
328 | |||
329 | //### DISCOUNTS |
||
330 | |||
331 | //T1 |
||
332 | $pu_ht = price2num(50 * $value['1']['count'], 'MU'); |
||
333 | $desc = $year . " - " . $t1->service->label . " - (" . $value['1']['count'] . " * 50)"; |
||
334 | |||
335 | $discountid = $soc->set_remise_except($pu_ht, $user, $desc, 0); |
||
336 | $object->insert_discount($discountid); |
||
337 | |||
338 | //T2 |
||
339 | $pu_ht = price2num(50 * $value['2']['count'], 'MU'); |
||
340 | $desc = $year . " - " . $t2->service->label . " - (" . $value['2']['count'] . " * 50)"; |
||
341 | |||
342 | $discountid = $soc->set_remise_except($pu_ht, $user, $desc, 0); |
||
343 | $object->insert_discount($discountid); |
||
344 | |||
345 | //Orga |
||
346 | $pu_ht = price2num(25 * $value['orga']['count'], 'MU'); |
||
347 | $desc = $year . " - Vols dont vous êtes organisateur - (" . $value['orga']['count'] . " * 25)"; |
||
348 | |||
349 | $discountid = $soc->set_remise_except($pu_ht, $user, $desc, 0); |
||
350 | $object->insert_discount($discountid); |
||
351 | |||
352 | //Additional bonus |
||
353 | if ((int)$addBonus > 0) { |
||
354 | |||
355 | $pu_ht = price2num($addBonus, 'MU'); |
||
356 | |||
357 | $desc = sprintf("%s - %s", $year, GETPOST("additional_message", 3)); |
||
358 | |||
359 | $discountid = $soc->set_remise_except($pu_ht, $user, $desc, 0); |
||
360 | $object->insert_discount($discountid); |
||
361 | } |
||
362 | |||
363 | $ret = $object->fetch($id); |
||
364 | $result = $object->generateDocument($documentModel, $langs, $hidedetails, $hidedesc, $hideref); |
||
365 | |||
366 | // Validate |
||
367 | $object->fetch($id); |
||
368 | $object->validate($user); |
||
369 | |||
370 | // Generate document |
||
371 | $object->fetch($id); |
||
372 | $result = $object->generateDocument($documentModel, $langs, $hidedetails, $hidedesc, $hideref); |
||
373 | |||
374 | } |
||
375 | |||
376 | if ($result > 0) { |
||
377 | dol_htmloutput_mesg("Facture créées"); |
||
378 | } else { |
||
379 | dol_htmloutput_errors("Note de frais non créée"); |
||
380 | } |
||
381 | } |
||
382 | |||
383 | } else { |
||
384 | //Quarter not yet finished |
||
385 | dol_htmloutput_errors("L'année n'est pas encore finie !"); |
||
386 | } |
||
387 | } |
||
388 | |||
389 | /* |
||
390 | * VIEW |
||
391 | * |
||
392 | * Put here all code to build page |
||
393 | */ |
||
394 | |||
395 | |||
396 | $form = new Form($db); |
||
397 | |||
398 | $tabLinks = []; |
||
399 | View Code Duplication | foreach ($flightYears as $currentFlightYear) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
400 | $tabLinks[] = [ |
||
401 | DOL_URL_ROOT . "/flightlog/generateBilling.php?year=" . $currentFlightYear, |
||
402 | $currentFlightYear, |
||
403 | "tab_" . $currentFlightYear |
||
404 | ]; |
||
405 | } |
||
406 | |||
407 | if (!$t1->service || !$t2->service || !$t3->service || !$t4->service || !$t5->service || !$t6->service || !$t7->service) { |
||
408 | dol_htmloutput_mesg("Un service n'a pas été configuré", '', 'warning'); |
||
409 | } |
||
410 | dol_fiche_head($tabLinks, "tab_" . $year); |
||
411 | |||
412 | ?> |
||
413 | <form method="POST"> |
||
414 | |||
415 | <!-- action --> |
||
416 | <input type="hidden" name="action" value="<?= EXPENSE_REPORT_GENERATOR_ACTION_GENERATE ?>"> |
||
417 | |||
418 | <?php |
||
419 | |||
420 | //tableau par pilote |
||
421 | |||
422 | $resql = $db->query($sql); |
||
423 | $pilotNumberFlight = array(); |
||
424 | if ($resql): |
||
425 | |||
426 | print '<div class="tabBar">'; |
||
427 | print '<table class="border" width="100%">'; |
||
428 | |||
429 | print '<tr class="liste_titre">'; |
||
430 | print '<td colspan="2">Nom</td>'; |
||
431 | print '<td class="liste_titre" colspan="2">' . $langs->trans("Type 1 : Sponsor") . '</td>'; |
||
432 | print '<td class="liste_titre" colspan="2">' . $langs->trans("Type 2 : Baptême") . '</td>'; |
||
433 | print '<td class="liste_titre" colspan="2">' . $langs->trans("Organisateur (T1/T2)") . '</td>'; |
||
434 | print '<td class="liste_titre" colspan="2">' . $langs->trans("Total bonus") . '</td>'; |
||
435 | print '<td class="liste_titre" colspan="2">' . $langs->trans("Type 3 : Privé") . '</td>'; |
||
436 | print '<td class="liste_titre" colspan="2">' . $langs->trans("Type 4: Meeting") . '</td>'; |
||
437 | print '<td class="liste_titre" colspan="1">' . $langs->trans("Type 5: Chambley") . '</td>'; |
||
438 | print '<td class="liste_titre" colspan="2">' . $langs->trans("Type 6: instruction") . '</td>'; |
||
439 | print '<td class="liste_titre" colspan="2">' . $langs->trans("Type 7: vols < 50 ") . '</td>'; |
||
440 | print '<td class="liste_titre" colspan="1">' . $langs->trans("Facture") . '</td>'; |
||
441 | print '<td class="liste_titre" colspan="1">' . $langs->trans("A payer") . '</td>'; |
||
442 | print '<tr>'; |
||
443 | |||
444 | print '<tr class="liste_titre">'; |
||
445 | print '<td colspan="2" class="liste_titre"></td>'; |
||
446 | |||
447 | print '<td class="liste_titre"> # </td>'; |
||
448 | print '<td class="liste_titre"> Pts </td>'; |
||
449 | |||
450 | print '<td class="liste_titre"> # </td>'; |
||
451 | print '<td class="liste_titre"> Pts </td>'; |
||
452 | |||
453 | print '<td class="liste_titre"> # </td>'; |
||
454 | print '<td class="liste_titre"> Pts </td>'; |
||
455 | |||
456 | print '<td class="liste_titre"> Bonus gagnés </td>'; |
||
457 | print '<td class="liste_titre"> Bonus additional (ROI) </td>'; |
||
458 | |||
459 | print '<td class="liste_titre"> # </td>'; |
||
460 | print '<td class="liste_titre"> € </td>'; |
||
461 | |||
462 | print '<td class="liste_titre"> # </td>'; |
||
463 | print '<td class="liste_titre"> € </td>'; |
||
464 | |||
465 | print '<td class="liste_titre"> # </td>'; |
||
466 | |||
467 | print '<td class="liste_titre"> # </td>'; |
||
468 | print '<td class="liste_titre"> € </td>'; |
||
469 | |||
470 | print '<td class="liste_titre"> #</td>'; |
||
471 | print '<td class="liste_titre"> €</td>'; |
||
472 | |||
473 | print '<td class="liste_titre"> € </td>'; |
||
474 | print '<td class="liste_titre"> Balance (A payer) €</td>'; |
||
475 | |||
476 | print'</tr>'; |
||
477 | $table = sqlToArray($db, $sql, true, $year); |
||
478 | $total = 0; |
||
479 | foreach ($table as $key => $value) { |
||
480 | |||
481 | $totalBonus = $value['1']['count'] * 50 + $value['2']['count'] * 50 + $value['orga']['count'] * 25; |
||
482 | $totalFacture = $value['3']['count'] * 150 + $value['4']['count'] * 100 + $value['6']['count'] * 50 + $value['7']['count'] * 75; |
||
483 | $facturable = ($totalFacture - $totalBonus < 0 ? 0 : $totalFacture - $totalBonus); |
||
484 | $total += $facturable; |
||
485 | |||
486 | $pilotNumberFlight[$value['id']] = array( |
||
487 | "1" => $value['1']['count'], |
||
488 | "2" => $value['2']['count'], |
||
489 | "3" => $value['3']['count'], |
||
490 | "4" => $value['4']['count'], |
||
491 | "5" => $value['5']['count'], |
||
492 | "6" => $value['6']['count'], |
||
493 | "7" => $value['7']['count'], |
||
494 | ); |
||
495 | |||
496 | print '<tr>'; |
||
497 | print '<td>' . $key; |
||
498 | print sprintf('<input type="hidden" name="pilot[%s]" value="%s" />', $key, $key); |
||
499 | print '</td>'; |
||
500 | print '<td>' . $value['name'] . '</td>'; |
||
501 | |||
502 | print '<td>' . $value['1']['count'] . '</td>'; |
||
503 | print '<td>' . $value['1']['count'] * 50 . '</td>'; |
||
504 | |||
505 | print '<td>' . $value['2']['count'] . '</td>'; |
||
506 | print '<td>' . $value['2']['count'] * 50 . '</td>'; |
||
507 | |||
508 | print '<td>' . $value['orga']['count'] . '</td>'; |
||
509 | print '<td>' . $value['orga']['count'] * 25 . '</td>'; |
||
510 | |||
511 | print '<td><b>' . ($totalBonus) . '</b></td>'; |
||
512 | print '<td>' . sprintf('<input type="number" value="0" name="additional_bonus[%s]"/>', |
||
513 | $key) . '</b></td>'; |
||
514 | |||
515 | print '<td>' . $value['3']['count'] . '</td>'; |
||
516 | print '<td>' . price($value['3']['count'] * 150) . '€</td>'; |
||
517 | |||
518 | print '<td>' . $value['4']['count'] . '</td>'; |
||
519 | print '<td>' . price($value['4']['count'] * 100) . '€</td>'; |
||
520 | |||
521 | print '<td>' . $value['5']['count'] . '</td>'; |
||
522 | |||
523 | print '<td>' . $value['6']['count'] . '</td>'; |
||
524 | print '<td>' . price($value['6']['count'] * 50) . '€</td>'; |
||
525 | |||
526 | print '<td>' . $value['7']['count'] . '</td>'; |
||
527 | print '<td>' . price($value['7']['count'] * 75) . '€</td>'; |
||
528 | |||
529 | print '<td>'; |
||
530 | print sprintf('<input type="hidden" value="%d" name="amout[%d]"/>', $totalFacture, $key); |
||
531 | print price($totalFacture); |
||
532 | print '€ </td>'; |
||
533 | |||
534 | |||
535 | print '<td>'; |
||
536 | print sprintf('<input type="hidden" value="%d" name="amoutDiscount[%d]"/>', $facturable, $key); |
||
537 | print price($facturable); |
||
538 | print '€ </td>'; |
||
539 | |||
540 | print '</tr>'; |
||
541 | |||
542 | } |
||
543 | |||
544 | |||
545 | ?> |
||
546 | |||
547 | <tr> |
||
548 | <td colspan='19'></td> |
||
549 | <td>Total à reçevoir</td> |
||
550 | <td><?= price($total) ?>€</td> |
||
551 | </tr> |
||
552 | |||
553 | </table> |
||
554 | |||
555 | <?php endif; ?> |
||
556 | |||
557 | |||
558 | <!-- Additional Point message --> |
||
559 | <label>Message de réduction pour points supplémentaire (Commun à toutes les factures)</label><br/> |
||
560 | <textarea name="additional_message" wrap="soft" class="quatrevingtpercent" rows="2"> |
||
561 | Points additionel (cf.annexe du ROI) |
||
562 | </textarea> |
||
563 | <br/> |
||
564 | <br/> |
||
565 | |||
566 | <!-- Billing type --> |
||
567 | <label><?= $langs->trans("Type de facture"); ?></label><br/> |
||
568 | <input type="radio" id="radio_standard" name="type" value="0" checked="checked"/> |
||
569 | <?= $form->textwithpicto($langs->trans("InvoiceStandardAsk"), $langs->transnoentities("InvoiceStandardDesc"), 1, |
||
570 | 'help', '', 0, 3) ?> |
||
571 | <br/> |
||
572 | <br/> |
||
573 | |||
574 | <!-- Payment mode --> |
||
575 | <label><?= $langs->trans("Mode de payement"); ?></label><br/> |
||
576 | <?php $form->select_types_paiements(0, 'mode_reglement_id', 'CRDT'); ?> |
||
577 | <br/> |
||
578 | <br/> |
||
579 | |||
580 | <!-- Payment condition --> |
||
581 | <label><?= $langs->trans("Condition de payement"); ?></label><br/> |
||
582 | <?php $form->select_conditions_paiements(0, 'cond_reglement_id'); ?> |
||
583 | <br/> |
||
584 | <br/> |
||
585 | |||
586 | <!-- bank account --> |
||
587 | <label><?= $langs->trans("Compte en banque"); ?></label><br/> |
||
588 | <?php $form->select_comptes(0, 'fk_account', 0, '', 1); ?> |
||
589 | <br/> |
||
590 | <br/> |
||
591 | |||
592 | <!-- Public note --> |
||
593 | <label><?= $langs->trans("Note publique (commune à toutes les factures)"); ?></label><br/> |
||
594 | <textarea name="public_note" wrap="soft" class="quatrevingtpercent" rows="2"> |
||
595 | Les vols sont facturés comme le stipule l'annexe du ROI. |
||
596 | </textarea> |
||
597 | <br/> |
||
598 | <br/> |
||
599 | |||
600 | <!-- Private note --> |
||
601 | <label><?= $langs->trans("Note privée (commune à toutes les factures)"); ?></label><br/> |
||
602 | <textarea name="private_note" wrap="soft" class="quatrevingtpercent" rows="2"> |
||
603 | Aux points de vols, s'ajoutent une indemnité pour les membres du CA/CD de 300 points. |
||
604 | </textarea> |
||
605 | <br/> |
||
606 | |||
607 | <!-- model document --> |
||
608 | <label><?= $langs->trans("Model de document "); ?></label><br/> |
||
609 | <?php $liste = ModelePDFFactures::liste_modeles($db); ?> |
||
610 | <?= $form->selectarray('model', $liste, $conf->global->FACTURE_ADDON_PDF); ?> |
||
611 | <br/> |
||
612 | <br/> |
||
613 | |||
614 | <?php if ($year >= $currentYear || !$t1->service || !$t2->service || !$t3->service || !$t4->service || !$t5->service || !$t6->service || !$t7->service) : ?> |
||
615 | <a class="butActionRefused" href="#">Générer</a> |
||
616 | <?php else: ?> |
||
617 | <button class="butAction" type="submit">Générer</button> |
||
618 | <?php endif; ?> |
||
619 | |||
620 | </form> |
||
621 | |||
622 | <?php |
||
623 | llxFooter(); |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.