Issues (188)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

generateBilling.php (2 issues)

Upgrade to new PHP Analysis Engine

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
dol_include_once('/compta/facture/class/facture.class.php');
24
dol_include_once('/adherents/class/adherent.class.php');
25
dol_include_once("/flightlog/lib/flightLog.lib.php");
26
dol_include_once("/flightlog/class/bbctypes.class.php");
27
dol_include_once("/product/class/product.class.php");
28
dol_include_once('/core/modules/facture/modules_facture.php');
29
dol_include_once('/flightlog/query/BillableFlightQuery.php');
30
dol_include_once('/flightlog/query/BillableFlightQueryHandler.php');
31
dol_include_once('/flightlog/command/CreatePilotYearBillCommand.php');
32
dol_include_once('/flightlog/command/CreatePilotYearBillCommandHandler.php');
33
34
35
global $db, $langs, $user, $conf;
36
37
// Load translation files required by the page
38
$langs->load("mymodule@mymodule");
39
$langs->load("trips");
40
$langs->load("bills");
41
42
// Get parameters
43
$id = GETPOST('id', 'int');
44
$action = GETPOST('action', 'alpha');
45
$year = GETPOST('year', 'int', 3);
46
47
//post parameters
48
$additionalBonus = GETPOST('additional_bonus', 'array', 2);
49
$pilotIds = GETPOST('pilot', 'array', 2);
50
$amouts = GETPOST('amout', 'array', 2);
51
$amoutDiscounts = GETPOST('amoutDiscount', 'array', 2);
52
$publicNote = GETPOST('public_note', 'alpha', 2);
53
$privateNote = GETPOST('private_note', 'alpha', 2);
54
$type = GETPOST("type", "int", 3);
55
$conditionReglement = GETPOST("cond_reglement_id", "int", 3);
56
$modeReglement = GETPOST("mode_reglement_id", "int", 3);
57
$bankAccount = GETPOST("fk_account", "int", 3);
58
$documentModel = GETPOST("model", "alpha", 3);
59
60
//variables
61
$currentYear = date('Y');
62
63
$t1 = new Bbctypes($db);
64
$t1->fetch(1);
65
$t2 = new Bbctypes($db);
66
$t2->fetch(2);
67
$t3 = new Bbctypes($db);
68
$t3->fetch(3);
69
$t4 = new Bbctypes($db);
70
$t4->fetch(4);
71
$t5 = new Bbctypes($db);
72
$t5->fetch(5);
73
$t6 = new Bbctypes($db);
74
$t6->fetch(6);
75
$t7 = new Bbctypes($db);
76
$t7->fetch(7);
77
$flightTypes = [
78
    '1' => $t1,
79
    '2' => $t2,
80
    '3' => $t3,
81
    '4' => $t4,
82
    '5' => $t5,
83
    '6' => $t6,
84
    '7' => $t7,
85
];
86
87
//Query
88
$flightYears = getFlightYears();
89
90
//pdf
91
$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails',
92
    'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
93
$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc',
94
    'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
95
$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref',
96
    'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
97
98
$object = new Facture($db);
99
100
//service
101
$tableQueryHandler = new BillableFlightQueryHandler($db, $conf->global);
102
$billHandler = new CreatePilotYearBillCommandHandler($db, $conf->global, $user, $langs, $flightTypes);
103
104
// Access control
105 View Code Duplication
if (!$conf->facture->enabled || !$user->rights->flightlog->vol->status || !$user->rights->flightlog->vol->financialGenerateDocuments) {
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.

Loading history...
106
    accessforbidden();
107
}
108
109
// Default action
110
if (empty($action)) {
111
    $action = EXPENSE_REPORT_GENERATOR_ACTION_SELECT;
112
}
113
114
llxHeader('', $langs->trans('Generate billing'), '');
115
print load_fiche_titre("Générer factures");
116
117
/*
118
 * ACTIONS
119
 *
120
 * Put here all code to do according to value of "action" parameter
121
 */
122
123
if ($action == EXPENSE_REPORT_GENERATOR_ACTION_GENERATE) {
124
125
    if ($year < $currentYear) {
126
127
        if (empty($documentModel) || $conditionReglement == 0 || empty($conditionReglement) || $modeReglement == 0 || empty($modeReglement)) {
128
            dol_htmloutput_errors("Erreur de configuration !");
129
        } else {
130
            /**
131
             * @var Pilot $value
132
             */
133
            $flights = $tableQueryHandler->__invoke(new BillableFlightQuery(true, $year));
134
            foreach ($flights as $currentMissionUserId => $value) {
135
136
                $addBonus = (int) $additionalBonus[$currentMissionUserId];
137
                if ($addBonus < 0) {
138
                    dol_htmloutput_mesg("Facture ignorée " . $value->getName(), '', 'warning');
139
                    continue;
140
                }
141
142
                if (!$value->isBillable()) {
143
                    dol_htmloutput_mesg("Facture ignorée car à 0.00 €" . $value->getName(), '',
144
                        'warning');
145
                    continue;
146
                }
147
148
149
                $command = new CreatePilotYearBillCommand(
150
                    $value,
151
                    $type,
152
                    $privateNote,
153
                    $publicNote,
154
                    $documentModel,
155
                    $conditionReglement,
156
                    $modeReglement,
157
                    $bankAccount,
158
                    $year,
159
                    GETPOST("additional_message", 3),
160
                    $additionalBonus
161
                );
162
                $billHandler->__invoke($command);
163
164
            }
165
            dol_htmloutput_mesg("Facture créées");
166
167
168
        }
169
    } else {
170
        //Quarter not yet finished
171
        dol_htmloutput_errors("L'année n'est pas encore finie !");
172
    }
173
}
174
175
/*
176
 * VIEW
177
 *
178
 * Put here all code to build page
179
 */
180
181
182
$form = new Form($db);
183
184
$tabLinks = [];
185 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.

Loading history...
186
    $tabLinks[] = [
187
        DOL_URL_ROOT . "/flightlog/generateBilling.php?year=" . $currentFlightYear,
188
        $currentFlightYear,
189
        "tab_" . $currentFlightYear
190
    ];
191
}
192
193
if (!$t1->service || !$t2->service || !$t3->service || !$t4->service || !$t5->service || !$t6->service || !$t7->service) {
194
    dol_htmloutput_mesg("Un service n'a pas été configuré", '', 'warning');
195
}
196
dol_fiche_head($tabLinks, "tab_" . $year);
197
198
?>
199
    <div>
200
        <p>
201
            Pour ignorer une ligne, il faut mettre un montant négatif en points additionel.
202
        </p>
203
    </div>
204
    <form method="POST">
205
206
        <!-- action -->
207
        <input type="hidden" name="action" value="<?php echo EXPENSE_REPORT_GENERATOR_ACTION_GENERATE ?>">
208
209
        <?php
210
211
        //tableau par pilote
212
213
        print '<div class="tabBar">';
214
        print '<table class="border" width="100%">';
215
216
        print '<tr class="liste_titre">';
217
        print '<td colspan="2">Nom</td>';
218
        print '<td class="liste_titre" colspan="2">' . $langs->trans("Type 1 : Sponsor") . '</td>';
219
        print '<td class="liste_titre" colspan="2">' . $langs->trans("Type 2 : Baptême") . '</td>';
220
        print '<td class="liste_titre" colspan="2">' . $langs->trans("Organisateur_(T1/T2)") . '</td>';
221
        print '<td class="liste_titre" colspan="2">' . $langs->trans("Instructeur") . '</td>';
222
        print '<td class="liste_titre" colspan="2">' . $langs->trans("Total bonus") . '</td>';
223
        print '<td class="liste_titre" colspan="2">' . $langs->trans("Type 3 : Privé") . '</td>';
224
        print '<td class="liste_titre" colspan="2">' . $langs->trans("Type 4: Meeting") . '</td>';
225
        print '<td class="liste_titre" colspan="1">' . $langs->trans("Type 5: Chambley") . '</td>';
226
        print '<td class="liste_titre" colspan="2">' . $langs->trans("Type 6: instruction") . '</td>';
227
        print '<td class="liste_titre" colspan="2">' . $langs->trans("Type 7: vols < 50 ") . '</td>';
228
        print '<td class="liste_titre" colspan="1">' . $langs->trans("Facture") . '</td>';
229
        print '<td class="liste_titre" colspan="1">' . $langs->trans("A payer") . '</td>';
230
        print '<tr>';
231
232
        print '<tr class="liste_titre">';
233
        print '<td colspan="2" class="liste_titre"></td>';
234
235
        print '<td class="liste_titre"> # </td>';
236
        print '<td class="liste_titre"> Pts </td>';
237
238
        print '<td class="liste_titre"> # </td>';
239
        print '<td class="liste_titre"> Pts </td>';
240
241
        print '<td class="liste_titre"> # </td>';
242
        print '<td class="liste_titre"> Pts </td>';
243
244
        print '<td class="liste_titre"> # </td>';
245
        print '<td class="liste_titre"> Pts </td>';
246
247
        print '<td class="liste_titre"> Bonus gagnés </td>';
248
        print '<td class="liste_titre"> Bonus additional (ROI) </td>';
249
250
        print '<td class="liste_titre"> # </td>';
251
        print '<td class="liste_titre"> € </td>';
252
253
        print '<td class="liste_titre"> # </td>';
254
        print '<td class="liste_titre"> € </td>';
255
256
        print '<td class="liste_titre"> # </td>';
257
258
        print '<td class="liste_titre"> # </td>';
259
        print '<td class="liste_titre"> € </td>';
260
261
        print '<td class="liste_titre"> #</td>';
262
        print '<td class="liste_titre"> €</td>';
263
264
        print '<td class="liste_titre"> € </td>';
265
        print '<td class="liste_titre"> Balance (A payer) €</td>';
266
267
        print'</tr>';
268
269
        $total = 0;
270
        /**
271
         * @var int   $key
272
         * @var Pilot $pilot
273
         */
274
        foreach ($tableQueryHandler->__invoke(new BillableFlightQuery(true, $year)) as $key => $pilot) {
275
            $total += $pilot->getTotalBill()->getValue();
276
277
            print '<tr class="pair">';
278
            print '<td>' . $key;
279
            print sprintf('<input type="hidden" name="pilot[%s]" value="%s" />', $pilot->getId(), $pilot->getId());
280
            print '</td>';
281
282
            print '<td>' . $pilot->getName() . '</td>';
283
284
            print '<td>' . $pilot->getCountForType('1')->getCount() . '</td>';
285
            print '<td>' . $pilot->getCountForType('1')->getCost()->getValue() . '</td>';
286
287
            print '<td>' . $pilot->getCountForType('2')->getCount() . '</td>';
288
            print '<td>' . $pilot->getCountForType('2')->getCost()->getValue() . '</td>';
289
290
            print '<td>' . $pilot->getCountForType('orga')->getCount() . '</td>';
291
            print '<td>' . $pilot->getCountForType('orga')->getCost()->getValue() . '</td>';
292
293
            print '<td>' . $pilot->getCountForType('orga_T6')->getCount() . '</td>';
294
            print '<td>' . $pilot->getCountForType('orga_T6')->getCost()->getValue() . '</td>';
295
296
            print '<td><b>' . $pilot->getFlightBonus()->getValue() . '</b></td>';
297
            print '<td>' . sprintf('<input type="number" value="0" name="additional_bonus[%s]"/>',
298
                    $pilot->getId()) . '</b></td>';
299
300
            print '<td>' . $pilot->getCountForType('3')->getCount() . '</td>';
301
            print '<td>' . price($pilot->getCountForType('3')->getCost()->getValue()) . '€</td>';
302
303
            print '<td>' . $pilot->getCountForType('4')->getCount() . '</td>';
304
            print '<td>' . price($pilot->getCountForType('4')->getCost()->getValue()) . '€</td>';
305
306
            print '<td>' . $pilot->getCountForType('5')->getCount() . '</td>';
307
308
            print '<td>' . $pilot->getCountForType('6')->getCount() . '</td>';
309
            print '<td>' . price($pilot->getCountForType('6')->getCost()->getValue()) . '€</td>';
310
311
            print '<td>' . $pilot->getCountForType('7')->getCount() . '</td>';
312
            print '<td>' . price($pilot->getCountForType('7')->getCost()->getValue()) . '€</td>';
313
314
            print '<td>';
315
            print sprintf('<input type="hidden" value="%d" name="amout[%d]"/>', $pilot->getFlightsCost()->getValue(),
316
                $pilot->getId());
317
            print price($pilot->getFlightsCost()->getValue());
318
            print '€ </td>';
319
320
            print '<td><b>';
321
            print sprintf('<input type="hidden" value="%d" name="amoutDiscount[%d]"/>',
322
                $pilot->getTotalBill()->getValue(), $pilot->getId());
323
            print price($pilot->getTotalBill()->getValue());
324
            print '€</b></td>';
325
            print '</tr>';
326
327
        }
328
329
330
        ?>
331
332
        <tr>
333
            <td colspan='19'></td>
334
            <td>Total à reçevoir</td>
335
            <td><?= price($total) ?>€</td>
336
        </tr>
337
338
        </table>
339
340
341
        <!-- Additional Point message -->
342
        <label>Message de réduction pour points supplémentaire (Commun à toutes les factures)</label><br/>
343
        <textarea name="additional_message" wrap="soft" class="quatrevingtpercent" rows="2">
344
            Points additionel (cf.annexe du ROI)
345
        </textarea>
346
        <br/>
347
        <br/>
348
349
        <!-- Billing type -->
350
        <label><?= $langs->trans("Type de facture"); ?></label><br/>
351
        <input type="radio" id="radio_standard" name="type" value="0" checked="checked"/>
352
        <?= $form->textwithpicto($langs->trans("InvoiceStandardAsk"), $langs->transnoentities("InvoiceStandardDesc"), 1,
353
            'help', '', 0, 3) ?>
354
        <br/>
355
        <br/>
356
357
        <!-- Payment mode -->
358
        <label><?= $langs->trans("Mode de payement"); ?></label><br/>
359
        <?php $form->select_types_paiements(0, 'mode_reglement_id', 'CRDT'); ?>
360
        <br/>
361
        <br/>
362
363
        <!-- Payment condition -->
364
        <label><?= $langs->trans("Condition de payement"); ?></label><br/>
365
        <?php $form->select_conditions_paiements(0, 'cond_reglement_id'); ?>
366
        <br/>
367
        <br/>
368
369
        <!-- bank account -->
370
        <label><?= $langs->trans("Compte en banque"); ?></label><br/>
371
        <?php $form->select_comptes(0, 'fk_account', 0, '', 1); ?>
372
        <br/>
373
        <br/>
374
375
        <!-- Public note -->
376
        <label><?= $langs->trans("Note publique (commune à toutes les factures)"); ?></label><br/>
377
        <textarea name="public_note" wrap="soft" class="quatrevingtpercent" rows="2">
378
            Les vols sont facturés comme le stipule l'annexe du ROI.
379
        </textarea>
380
        <br/>
381
        <br/>
382
383
        <!-- Private note -->
384
        <label><?= $langs->trans("Note privée (commune à toutes les factures)"); ?></label><br/>
385
        <textarea name="private_note" wrap="soft" class="quatrevingtpercent" rows="2">
386
            Aux points de vols, s'ajoutent une indemnité pour les membres du CA/CD de 300 points.
387
        </textarea>
388
        <br/>
389
390
        <!-- model document -->
391
        <label><?= $langs->trans("Model de document "); ?></label><br/>
392
        <?php $liste = ModelePDFFactures::liste_modeles($db); ?>
393
        <?= $form->selectarray('model', $liste, $conf->global->FACTURE_ADDON_PDF); ?>
394
        <br/>
395
        <br/>
396
397
        <?php if ($year >= $currentYear || !$t1->service || !$t2->service || !$t3->service || !$t4->service || !$t5->service || !$t6->service || !$t7->service) : ?>
398
            <a class="butActionRefused" href="#">Générer</a>
399
        <?php else: ?>
400
            <button class="butAction" type="submit">Générer</button>
401
        <?php endif; ?>
402
403
    </form>
404
405
<?php
406
llxFooter();