These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * \file mypage.php |
||
| 4 | * \ingroup mymodule |
||
| 5 | * \brief Example PHP page. |
||
| 6 | * |
||
| 7 | * read flights |
||
| 8 | */ |
||
| 9 | |||
| 10 | // Load Dolibarr environment |
||
| 11 | if (false === (@include '../main.inc.php')) { // From htdocs directory |
||
| 12 | require '../../documents/custom/main.inc.php'; // From "custom" directory |
||
| 13 | } |
||
| 14 | |||
| 15 | global $db, $langs, $user, $conf; |
||
| 16 | |||
| 17 | dol_include_once('/core/class/dolgraph.class.php'); |
||
| 18 | dol_include_once('/flightLog/class/bbcvols.class.php'); |
||
| 19 | dol_include_once('/flightLog/class/bbctypes.class.php'); |
||
| 20 | dol_include_once('/flightLog/class/GraphicalData.php'); |
||
| 21 | dol_include_once('/flightLog/class/GraphicalType.php'); |
||
| 22 | dol_include_once('/flightLog/class/GraphicalValue.php'); |
||
| 23 | dol_include_once('/flightLog/class/GraphicalValueType.php'); |
||
| 24 | dol_include_once('/flightLog/class/YearGraphicalData.php'); |
||
| 25 | |||
| 26 | dol_include_once("/flightLog/lib/flightLog.lib.php"); |
||
| 27 | |||
| 28 | $langs->load("mymodule@flightLog"); |
||
| 29 | |||
| 30 | // Get parameters |
||
| 31 | //TODO get all parameters from here |
||
| 32 | $id = GETPOST('id', 'int'); |
||
| 33 | $action = GETPOST('action', 'alpha'); |
||
| 34 | $myparam = GETPOST('myparam', 'alpha'); |
||
| 35 | |||
| 36 | $unitPriceMission = $conf->global->BBC_FLIGHT_LOG_UNIT_PRICE_MISSION; |
||
| 37 | |||
| 38 | //variables |
||
| 39 | $WIDTH = DolGraph::getDefaultGraphSizeForStats('width', 768); |
||
| 40 | $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); |
||
| 41 | |||
| 42 | $year = strftime("%Y", dol_now()); |
||
| 43 | $dir = $conf->expensereport->dir_temp; |
||
| 44 | |||
| 45 | $filenamenb = $dir . "/test2-" . $year . ".png"; |
||
| 46 | $fileurlnb = DOL_URL_ROOT . '/viewimage.php?modulepart=flightLog&file=' . $fileurlnb; |
||
| 47 | |||
| 48 | $graphByTypeAndYear = new DolGraph(); |
||
| 49 | $mesg = $graphByTypeAndYear->isGraphKo(); |
||
| 50 | if (!$mesg) { |
||
| 51 | $data = getGraphByTypeAndYearData(); |
||
| 52 | |||
| 53 | $graphByTypeAndYear->SetData($data->export()); |
||
| 54 | $graphByTypeAndYear->SetPrecisionY(0); |
||
| 55 | |||
| 56 | $legend = []; |
||
| 57 | $graphByTypeAndYear->type = []; |
||
| 58 | foreach (fetchBbcFlightTypes() as $flightType) { |
||
| 59 | |||
| 60 | if (!in_array($flightType->numero, [1, 2, 3, 6])) { |
||
| 61 | continue; |
||
| 62 | } |
||
| 63 | |||
| 64 | $legend[] = $flightType->nom; |
||
| 65 | $graphByTypeAndYear->type[] = "lines"; |
||
| 66 | } |
||
| 67 | $graphByTypeAndYear->SetLegend($legend); |
||
| 68 | $graphByTypeAndYear->SetMaxValue($graphByTypeAndYear->GetCeilMaxValue()); |
||
| 69 | $graphByTypeAndYear->SetWidth($WIDTH + 100); |
||
| 70 | $graphByTypeAndYear->SetHeight($HEIGHT); |
||
| 71 | $graphByTypeAndYear->SetYLabel($langs->trans("YEAR")); |
||
| 72 | $graphByTypeAndYear->SetShading(3); |
||
| 73 | $graphByTypeAndYear->SetHorizTickIncrement(1); |
||
| 74 | $graphByTypeAndYear->SetPrecisionY(0); |
||
| 75 | |||
| 76 | $graphByTypeAndYear->SetTitle($langs->trans("Par type et par année")); |
||
| 77 | |||
| 78 | $graphByTypeAndYear->draw($filenamenb, $fileurlnb); |
||
| 79 | } |
||
| 80 | |||
| 81 | // Default action |
||
| 82 | if (empty($action) && empty($id) && empty($ref)) { |
||
| 83 | $action = 'create'; |
||
| 84 | } |
||
| 85 | |||
| 86 | // Load object if id or ref is provided as parameter |
||
| 87 | $object = new Bbcvols($db); |
||
| 88 | View Code Duplication | if (($id > 0 || !empty($ref)) && $action != 'add') { |
|
| 89 | $result = $object->fetch($id, $ref); |
||
| 90 | if ($result < 0) { |
||
| 91 | dol_print_error($db); |
||
| 92 | } |
||
| 93 | } |
||
| 94 | |||
| 95 | /* |
||
| 96 | * ACTIONS |
||
| 97 | * |
||
| 98 | * Put here all code to do according to value of "action" parameter |
||
| 99 | */ |
||
| 100 | |||
| 101 | /* |
||
| 102 | * VIEW |
||
| 103 | * |
||
| 104 | * Put here all code to build page |
||
| 105 | */ |
||
| 106 | |||
| 107 | llxHeader('', $langs->trans('Read flights'), ''); |
||
| 108 | |||
| 109 | $form = new Form($db); |
||
| 110 | |||
| 111 | // Put here content of your page |
||
| 112 | $data = array(); // array(array('abs1',valA1,valB1), array('abs2',valA2,valB2), ...) |
||
|
0 ignored issues
–
show
|
|||
| 113 | $tmp = array(); |
||
| 114 | $legend = array(); |
||
| 115 | |||
| 116 | //tableau par pilote |
||
| 117 | $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"; |
||
| 118 | $sql .= " FROM llx_bbc_vols, llx_user AS USR,llx_bbc_types AS TT "; |
||
| 119 | $sql .= " WHERE `fk_pilot`= USR.rowid AND fk_type = TT.idType AND YEAR(llx_bbc_vols.date) = " . (GETPOST("year") ? "'" . GETPOST("year") . "'" : 'YEAR(NOW())'); |
||
| 120 | $sql .= " GROUP BY fk_pilot,`fk_type`"; |
||
| 121 | |||
| 122 | $resql = $db->query($sql); |
||
| 123 | |||
| 124 | $sqlYear = "SELECT DISTINCT(YEAR(llx_bbc_vols.date)) as annee FROM llx_bbc_vols "; |
||
| 125 | $resql_years = $db->query($sqlYear); |
||
| 126 | |||
| 127 | $pilotNumberFlight = array(); |
||
| 128 | if ($resql) { |
||
| 129 | |||
| 130 | $num = $db->num_rows($resql_years); |
||
| 131 | $i = 0; |
||
| 132 | if ($num) { |
||
| 133 | print '<div class="tabs">'; |
||
| 134 | print '<a class="tabTitle"><img src="../theme/eldy/img/object_user.png" border="0" alt="" title=""> Recap / utilisateur </a>'; //title |
||
| 135 | |||
| 136 | while ($i < $num) { |
||
| 137 | $obj = $db->fetch_object($resql_years); //vol |
||
| 138 | if ($obj->annee) { |
||
| 139 | print '<a class="tab" id="' . (GETPOST("year") == $obj->annee || (!GETPOST("year") && $obj->annee == date("Y")) ? 'active' : '') . '" " href="readFlights.php?year=' . $obj->annee . '">' . $obj->annee . '</a>'; |
||
| 140 | } |
||
| 141 | $i++; |
||
| 142 | } |
||
| 143 | print '</div>'; |
||
| 144 | } |
||
| 145 | |||
| 146 | |||
| 147 | print '<div class="tabBar">'; |
||
| 148 | print '<table class="border" width="100%">'; |
||
| 149 | |||
| 150 | print '<tr class="liste_titre">'; |
||
| 151 | print '<td colspan="2">Nom</td>'; |
||
| 152 | print '<td class="liste_titre" colspan="2">' . $langs->trans("Type 1 : Sponsor") . '</td>'; |
||
| 153 | print '<td class="liste_titre" colspan="2">' . $langs->trans("Type 2 : Baptême") . '</td>'; |
||
| 154 | print '<td class="liste_titre" colspan="2">' . $langs->trans("Organisateur (T1/T2)") . '</td>'; |
||
| 155 | print '<td class="liste_titre" >' . $langs->trans("Total bonus") . '</td>'; |
||
| 156 | print '<td class="liste_titre" colspan="2">' . $langs->trans("Type 3 : Privé") . '</td>'; |
||
| 157 | print '<td class="liste_titre" colspan="2">' . $langs->trans("Type 4: Meeting") . '</td>'; |
||
| 158 | print '<td class="liste_titre" colspan="1">' . $langs->trans("Type 5: Chambley") . '</td>'; |
||
| 159 | print '<td class="liste_titre" colspan="2">' . $langs->trans("Type 6: instruction") . '</td>'; |
||
| 160 | print '<td class="liste_titre" colspan="2">' . $langs->trans("Type 7: vols < 50 ") . '</td>'; |
||
| 161 | print '<td class="liste_titre" colspan="1">' . $langs->trans("Facture") . '</td>'; |
||
| 162 | print '<td class="liste_titre" colspan="1">' . $langs->trans("A payer") . '</td>'; |
||
| 163 | print '<tr>'; |
||
| 164 | |||
| 165 | print '<tr class="liste_titre">'; |
||
| 166 | print '<td colspan="2" class="liste_titre"></td>'; |
||
| 167 | |||
| 168 | print '<td class="liste_titre"> # </td>'; |
||
| 169 | print '<td class="liste_titre"> Pts </td>'; |
||
| 170 | |||
| 171 | print '<td class="liste_titre"> # </td>'; |
||
| 172 | print '<td class="liste_titre"> Pts </td>'; |
||
| 173 | |||
| 174 | print '<td class="liste_titre"> # </td>'; |
||
| 175 | print '<td class="liste_titre"> Pts </td>'; |
||
| 176 | |||
| 177 | print '<td class="liste_titre"> Bonus gagnés </td>'; |
||
| 178 | |||
| 179 | print '<td class="liste_titre"> # </td>'; |
||
| 180 | print '<td class="liste_titre"> € </td>'; |
||
| 181 | |||
| 182 | print '<td class="liste_titre"> # </td>'; |
||
| 183 | print '<td class="liste_titre"> € </td>'; |
||
| 184 | |||
| 185 | print '<td class="liste_titre"> # </td>'; |
||
| 186 | |||
| 187 | print '<td class="liste_titre"> # </td>'; |
||
| 188 | print '<td class="liste_titre"> € </td>'; |
||
| 189 | |||
| 190 | print '<td class="liste_titre"> #</td>'; |
||
| 191 | print '<td class="liste_titre"> €</td>'; |
||
| 192 | |||
| 193 | print '<td class="liste_titre"> € </td>'; |
||
| 194 | print '<td class="liste_titre"> Balance (A payer) €</td>'; |
||
| 195 | |||
| 196 | print'</tr>'; |
||
| 197 | $table = sqlToArray($db, $sql, true, (GETPOST("year") ?: date("Y"))); |
||
| 198 | foreach ($table as $key => $value) { |
||
| 199 | |||
| 200 | if (!$user->rights->flightLog->vol->detail && $user->id != $value["id"]) { |
||
| 201 | continue; |
||
| 202 | } |
||
| 203 | |||
| 204 | $totalBonus = $value['1']['count'] * 50 + $value['2']['count'] * 50 + $value['orga']['count'] * 25; |
||
| 205 | $totalFacture = $value['3']['count'] * 150 + $value['4']['count'] * 100 + $value['6']['count'] * 50 + $value['7']['count'] * 75; |
||
| 206 | $facturable = $totalFacture - $totalBonus; |
||
| 207 | |||
| 208 | $pilotNumberFlight[$value['id']] = array( |
||
| 209 | "1" => $value['1']['count'], |
||
| 210 | "2" => $value['2']['count'], |
||
| 211 | "3" => $value['3']['count'], |
||
| 212 | "4" => $value['4']['count'], |
||
| 213 | "5" => $value['5']['count'], |
||
| 214 | "6" => $value['6']['count'], |
||
| 215 | "7" => $value['7']['count'], |
||
| 216 | ); |
||
| 217 | |||
| 218 | print '<tr>'; |
||
| 219 | print '<td>' . $key . '</td>'; |
||
| 220 | print '<td>' . $value['name'] . '</td>'; |
||
| 221 | |||
| 222 | print '<td>' . $value['1']['count'] . '</td>'; |
||
| 223 | print '<td>' . $value['1']['count'] * 50 . '</td>'; |
||
| 224 | |||
| 225 | print '<td>' . $value['2']['count'] . '</td>'; |
||
| 226 | print '<td>' . $value['2']['count'] * 50 . '</td>'; |
||
| 227 | |||
| 228 | print '<td>' . $value['orga']['count'] . '</td>'; |
||
| 229 | print '<td>' . $value['orga']['count'] * 25 . '</td>'; |
||
| 230 | |||
| 231 | print '<td><b>' . ($totalBonus) . '</b></td>'; |
||
| 232 | |||
| 233 | print '<td>' . $value['3']['count'] . '</td>'; |
||
| 234 | print '<td>' . price($value['3']['count'] * 150) . '€</td>'; |
||
| 235 | |||
| 236 | print '<td>' . $value['4']['count'] . '</td>'; |
||
| 237 | print '<td>' . price($value['4']['count'] * 100) . '€</td>'; |
||
| 238 | |||
| 239 | print '<td>' . $value['5']['count'] . '</td>'; |
||
| 240 | |||
| 241 | print '<td>' . $value['6']['count'] . '</td>'; |
||
| 242 | print '<td>' . price($value['6']['count'] * 50) . '€</td>'; |
||
| 243 | |||
| 244 | print '<td>' . $value['7']['count'] . '</td>'; |
||
| 245 | print '<td>' . price($value['7']['count'] * 75) . '€</td>'; |
||
| 246 | |||
| 247 | print '<td>' . price($totalFacture) . '€ </td>'; |
||
| 248 | print '<td><b>' . price(($facturable < 0 ? 0 : $facturable)) . '€</b></td>'; |
||
| 249 | print '</tr>'; |
||
| 250 | } |
||
| 251 | print'</table>'; |
||
| 252 | |||
| 253 | |||
| 254 | print '<br/>'; |
||
| 255 | print '<h3>' . $langs->trans("Remboursement aux pilotes") . '</h3>'; |
||
| 256 | |||
| 257 | //table km |
||
| 258 | $tauxRemb = isset($conf->global->BBC_FLIGHT_LOG_TAUX_REMB_KM) ? $conf->global->BBC_FLIGHT_LOG_TAUX_REMB_KM : 0; |
||
| 259 | $year = GETPOST("year", 'int'); |
||
| 260 | |||
| 261 | $kmByQuartil = bbcKilometersByQuartil($year); |
||
| 262 | |||
| 263 | printBbcKilometersByQuartil($kmByQuartil, $tauxRemb, $unitPriceMission); |
||
| 264 | |||
| 265 | print '</div>'; |
||
| 266 | |||
| 267 | |||
| 268 | } |
||
| 269 | print '<br/>'; |
||
| 270 | |||
| 271 | print '<div class="tabsAction">'; |
||
| 272 | |||
| 273 | |||
| 274 | if (false && $conf->expensereport->enabled && $user->rights->flightLog->vol->financial) { |
||
| 275 | print '<a class="butAction" href="generateExpenseNote.php?year=' . (GETPOST("year", |
||
| 276 | 'int') ?: date("Y")) . '">Générer notes de frais</a>'; |
||
| 277 | } |
||
| 278 | |||
| 279 | print '</div>'; |
||
| 280 | |||
| 281 | |||
| 282 | ?> |
||
| 283 | |||
| 284 | |||
| 285 | <div class="fichecenter"> |
||
| 286 | <?php print $graphByTypeAndYear->show(); ?> |
||
| 287 | </div> |
||
| 288 | |||
| 289 | <?php |
||
| 290 | llxFooter(); |
||
| 291 |
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.