These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | // Load Dolibarr environment |
||
4 | if (false === (@include '../main.inc.php')) { // From htdocs directory |
||
5 | require '../../documents/custom/main.inc.php'; // From "custom" directory |
||
6 | } |
||
7 | |||
8 | global $db, $langs, $user; |
||
9 | |||
10 | dol_include_once('/flightLog/class/bbcvols.class.php'); |
||
11 | dol_include_once('/flightLog/class/bbctypes.class.php'); |
||
12 | dol_include_once("/flightLog/lib/flightLog.lib.php"); |
||
13 | |||
14 | // Load translation files required by the page |
||
15 | $langs->load("mymodule@mymodule"); |
||
16 | |||
17 | |||
18 | if (!$user->rights->flightLog->vol->add) { |
||
19 | accessforbidden(); |
||
20 | } |
||
21 | |||
22 | |||
23 | /* * ***************************************************************** |
||
24 | * ACTIONS |
||
25 | * |
||
26 | * Put here all code to do according to value of "action" parameter |
||
27 | * ****************************************************************** */ |
||
28 | $msg = ''; |
||
29 | if ($_GET["action"] == 'add' || $_POST["action"] == 'add') { |
||
30 | if (!$_POST["cancel"]) { |
||
31 | $dated = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); |
||
32 | |||
33 | $vol = new Bbcvols($db); |
||
34 | |||
35 | $vol->date = $dated; |
||
36 | $vol->lieuD = $_POST['lieuD']; |
||
37 | $vol->lieuA = $_POST['lieuA']; |
||
38 | $vol->heureD = $_POST['heureD']; |
||
39 | $vol->heureA = $_POST['heureA']; |
||
40 | $vol->BBC_ballons_idBBC_ballons = $_POST['ballon']; |
||
41 | $vol->nbrPax = $_POST['nbrPax']; |
||
42 | $vol->remarque = $_POST['comm']; |
||
43 | $vol->incidents = $_POST['inci']; |
||
44 | $vol->fk_type = $_POST['type']; |
||
45 | $vol->fk_pilot = $_POST['pilot']; |
||
46 | $vol->fk_organisateur = $_POST['orga']; |
||
47 | $vol->kilometers = $_POST['kilometers']; |
||
48 | $vol->cost = $_POST['cost']; |
||
49 | $vol->fk_receiver = $_POST['fk_receiver']; |
||
50 | $vol->justif_kilometers = $_POST['justif_kilometers']; |
||
51 | |||
52 | //verification des heures |
||
53 | $patern = '#[0-9]{4}#'; |
||
54 | $error = 0; |
||
55 | View Code Duplication | if (preg_match($patern, $vol->heureD) == 0 || strlen($vol->heureD) != 4) { |
|
0 ignored issues
–
show
|
|||
56 | $msg = '<div class="error">L\'heure depart n\'est pas correcte</div>'; |
||
57 | $error++; |
||
58 | } else { |
||
59 | $vol->heureD = $vol->heureD . '00'; |
||
60 | } |
||
61 | View Code Duplication | if (preg_match($patern, $vol->heureA) == 0 || strlen($vol->heureA) != 4) { |
|
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. ![]() |
|||
62 | $msg = '<div class="error">L\'heure d\'arrivee n\'est pas correcte</div>'; |
||
63 | $error++; |
||
64 | } else { |
||
65 | $vol->heureA = $vol->heureA . '00'; |
||
66 | } |
||
67 | |||
68 | if ($error == 0 && ($vol->heureA - $vol->heureD) <= 0) { |
||
69 | $msg = '<div class="error">L\'heure de depart est plus grande que l\'heure d\'arrivee</div>'; |
||
70 | $error++; |
||
71 | } |
||
72 | |||
73 | // verification du nombre de pax |
||
74 | if ($vol->nbrPax < 0) { |
||
75 | $msg = '<div class="error">Erreur le nombre de passager est �gale � 0 ou est un nombre n�gatif.</div>'; |
||
76 | $error++; |
||
77 | } |
||
78 | if ($error == 0) { |
||
79 | $result = $vol->create($user); |
||
80 | if ($result > 0) { |
||
81 | //creation OK |
||
82 | $msg = '<div class="ok">L\'ajout du vol du : ' . $_POST["reday"] . '/' . $_POST["remonth"] . '/' . $_POST["reyear"] . ' s\'est correctement effectue ! </div>'; |
||
83 | Header("Location: fiche.php?vol=" . $result); |
||
84 | } else { |
||
85 | // Creation KO |
||
86 | $msg = '<div class="error">Erreur lors de l\'ajout du vol : ' . $vol->error . '! </div>'; |
||
87 | $error++; |
||
88 | } |
||
89 | } |
||
90 | } |
||
91 | } |
||
92 | |||
93 | |||
94 | |||
95 | |||
96 | |||
97 | /* * ************************************************* |
||
98 | * PAGE |
||
99 | * |
||
100 | * Put here all code to build page |
||
101 | * ************************************************** */ |
||
102 | |||
103 | llxHeader('', 'Carnet de vol', ''); |
||
104 | |||
105 | $html = new Form($db); |
||
106 | $datec = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); |
||
107 | if ($msg) { |
||
108 | print $msg; |
||
109 | } |
||
110 | |||
111 | // Put here content of your page |
||
112 | print "<form name='add' action=\"addFlight.php\" method=\"post\">\n"; |
||
113 | print '<input type="hidden" name="action" value="add"/>'; |
||
114 | print '<table class="border" width="100%">'; |
||
115 | //date du vol |
||
116 | print "<tr>"; |
||
117 | print '<td class="fieldrequired"> Date du vol</td><td>'; |
||
118 | print $html->select_date($datec ? $datec : -1, '', '', '', '', 'add', 1, 1); |
||
119 | print '</td></tr>'; |
||
120 | //type du vol |
||
121 | print "<tr>"; |
||
122 | print '<td class="fieldrequired"> Type du vol</td><td>'; |
||
123 | print select_flight_type($_POST['type']); |
||
124 | print '</td></tr>'; |
||
125 | //Pilote |
||
126 | print "<tr>"; |
||
127 | print '<td class="fieldrequired"> Pilote </td><td>'; |
||
128 | print $html->select_dolusers($_POST["pilot"] ? $_POST["pilot"] : $_GET["pilot"], 'pilot', $user->id); |
||
129 | //print '<td class="fieldrequired"> Pilote <input type="hidden" name="pilot" value="'.$user->id.'"/></td><td>'; |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
60% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
130 | print '</td></tr>'; |
||
131 | //organisateur |
||
132 | print "<tr>"; |
||
133 | print '<td class="fieldrequired"> Organisateur </td><td>'; |
||
134 | print $html->select_dolusers($_POST["orga"] ? $_POST["orga"] : $_GET["orga"], 'orga', 1); |
||
135 | print '</td></tr>'; |
||
136 | //Ballon |
||
137 | print "<tr>"; |
||
138 | print '<td width="25%" class="fieldrequired">Ballon</td><td>'; |
||
139 | print select_balloons($_POST['ballon'], 'ballon', $showempty = 0, $showimmat = 0, $showDeclasse = 0); |
||
140 | print '</td></tr>'; |
||
141 | //lieu d�part |
||
142 | print "<tr>"; |
||
143 | print '<td width="25%" class="fieldrequired">Lieu de départ </td><td>'; |
||
144 | print '<input type="text" name="lieuD" class="flat" value="' . $_POST['lieuD'] . '"/>'; |
||
145 | print '</td></tr>'; |
||
146 | //lieu arriv�e |
||
147 | print "<tr>"; |
||
148 | print '<td width="25%" class="fieldrequired">Lieu d\'arrivée </td><td>'; |
||
149 | print '<input type="text" name="lieuA" class="flat" value="' . $_POST['lieuA'] . '"/>'; |
||
150 | print '</td></tr>'; |
||
151 | //heure d�part |
||
152 | print "<tr>"; |
||
153 | print '<td width="25%" class="fieldrequired">Heure de départ <br/>(format autorise XXXX)</td><td>'; |
||
154 | print '<input type="text" name="heureD" class="flat" value="' . $_POST['heureD'] . '"/>'; |
||
155 | print '</td></tr>'; |
||
156 | //heure arriv�e |
||
157 | print "<tr>"; |
||
158 | print '<td width="25%" class="fieldrequired">Heure d\'arrivée <br/>(format autorise XXXX)</td><td>'; |
||
159 | print '<input type="text" name="heureA" class="flat" value="' . $_POST['heureA'] . '"/>'; |
||
160 | print '</td></tr>'; |
||
161 | //Numbe rof kilometrs done for the flight |
||
162 | print "<tr>"; |
||
163 | print '<td width="25%" class="fieldrequired">Nombre de kilometres effectués pour le vol</td><td>'; |
||
164 | print '<input type="number" name="kilometers" class="flat" value="' . $_POST['kilometers'] . '"/>'; |
||
165 | print '</td></tr>'; |
||
166 | |||
167 | //Justif KIlometers |
||
168 | print "<tr>"; |
||
169 | print '<td width="25%" class="fieldrequired">Justificatif des KM</td><td>'; |
||
170 | print '<textarea rows="2" cols="60" class="flat" name="justif_kilometers" >' . $_POST['justif_kilometers'] . '</textarea> '; |
||
171 | print '</td></tr>'; |
||
172 | //NBR pax |
||
173 | print "<tr>"; |
||
174 | print '<td width="25%" class="fieldrequired">Nombre de passagers</td><td>'; |
||
175 | print '<input type="number" name="nbrPax" class="flat" value="' . $_POST['nbrPax'] . '"/>'; |
||
176 | print '</td></tr>'; |
||
177 | //Flight cost |
||
178 | print "<tr>"; |
||
179 | print '<td width="25%" class="fieldrequired">Montant perçu</td><td>'; |
||
180 | print '<input type="text" name="cost" class="flat" value="' . $_POST['cost'] . '"/>'; |
||
181 | print "€"; |
||
182 | print '</td></tr>'; |
||
183 | //Money receiver |
||
184 | print "<tr>"; |
||
185 | print '<td width="25%" class="fieldrequired">Qui a perçu l\'argent</td><td>'; |
||
186 | print $html->select_dolusers($_POST["fk_receiver"] ? $_POST["fk_receiver"] : $_GET["fk_receiver"], 'fk_receiver', 1); |
||
187 | print '</td></tr>'; |
||
188 | //commentaires |
||
189 | print "<tr>"; |
||
190 | print '<td class="fieldrequired"> Commentaire </td><td>'; |
||
191 | print '<textarea rows="2" cols="60" class="flat" name="comm" placeholder="RAS">' . $_POST['comm'] . '</textarea> '; |
||
192 | print '</td></tr>'; |
||
193 | //incidents |
||
194 | print "<tr>"; |
||
195 | print '<td class="fieldrequired"> incidents </td><td>'; |
||
196 | print '<textarea rows="2" cols="60" class="flat" name="inci" placeholder="RAS">' . $_POST['inci'] . '</textarea> '; |
||
197 | print '</td></tr>'; |
||
198 | |||
199 | print '</table>'; |
||
200 | |||
201 | print '<br><center><input class="button" type="submit" value="' . $langs->trans("Save") . '"> '; |
||
202 | print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '"></center'; |
||
203 | |||
204 | print '</form>'; |
||
205 | |||
206 | /* * ************************************************* |
||
207 | * LINKED OBJECT BLOCK |
||
208 | * |
||
209 | * Put here code to view linked object |
||
210 | * ************************************************** */ |
||
211 | //$somethingshown=$myobject->showLinkedObjectBlock(); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
40% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
212 | // End of page |
||
213 | $db->close(); |
||
214 | llxFooter('$Date: 2011/07/31 22:21:57 $ - $Revision: 1.19 $'); |
||
215 | ?> |
||
0 ignored issues
–
show
It is not recommended to use PHP's closing tag
?> in files other than templates.
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore. A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever. ![]() |
|||
216 |
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.