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; |
||
| 16 | |||
| 17 | dol_include_once('/flightLog/class/bbcvols.class.php'); |
||
| 18 | dol_include_once("/flightBalloon/bbc_ballons.class.php"); |
||
| 19 | dol_include_once('/flightLog/class/bbctypes.class.php'); |
||
| 20 | dol_include_once("/flightLog/lib/flightLog.lib.php"); |
||
| 21 | |||
| 22 | // Load translation files required by the page |
||
| 23 | $langs->load("mymodule@mymodule"); |
||
| 24 | |||
| 25 | // Get parameters |
||
| 26 | $myparam = isset($_GET["myparam"])?$_GET["myparam"]:''; |
||
| 27 | |||
| 28 | // Protection if the user can't acces to the module |
||
| 29 | if (!$user->rights->flightLog->vol->access) |
||
| 30 | { |
||
| 31 | accessforbidden(); |
||
| 32 | } |
||
| 33 | |||
| 34 | |||
| 35 | |||
| 36 | /******************************************************************* |
||
| 37 | * ACTIONS |
||
| 38 | * |
||
| 39 | * Put here all code to do according to value of "action" parameter |
||
| 40 | ********************************************************************/ |
||
| 41 | |||
| 42 | //l'utilisateur a le droit de selectionner le ballon qu'il veut |
||
| 43 | if (($user->rights->flightLog->vol->detail)) |
||
| 44 | { |
||
| 45 | if(isset($_GET["ballon"])){ |
||
| 46 | $idBallon = $_GET['ballon']; |
||
| 47 | }else{ |
||
| 48 | $idBallon =1; |
||
| 49 | } |
||
| 50 | |||
| 51 | }else{ |
||
| 52 | |||
| 53 | //l'utilisateur n'a pas le choix du ballon |
||
| 54 | //il est titulaire d'un ballon |
||
| 55 | $query = 'SELECT * FROM llx_bbc_ballons'; |
||
| 56 | $query.= ' WHERE `fk_responsable` = '.$user->id; |
||
| 57 | $resql = $db->query($query); |
||
| 58 | View Code Duplication | if($resql){ |
|
| 59 | $num = $db->num_rows($resql); |
||
| 60 | $i = 0; |
||
| 61 | if($num){ |
||
| 62 | print'</tr>'; |
||
| 63 | while($i <$num){ |
||
| 64 | $obj = $db->fetch_object($resql); //vol |
||
| 65 | if($obj){ |
||
| 66 | $idBallon = ($obj->rowid); |
||
| 67 | } |
||
| 68 | } |
||
| 69 | }else{ |
||
| 70 | //il n'est pas titulaire d'un ballon |
||
| 71 | accessforbidden("Vous n'êtes pas titulaire du ballon"); |
||
| 72 | } |
||
| 73 | } |
||
| 74 | } |
||
| 75 | if($idBallon != -1){ |
||
| 76 | |||
| 77 | //balloon with ID |
||
| 78 | $ballon = New Bbc_ballons($db); |
||
| 79 | |||
| 80 | if($ballon->fetch($idBallon)==-1){ |
||
| 81 | print "ERROR".$idBallon."<br/>"; |
||
| 82 | } |
||
| 83 | //titulaire with ballon ID |
||
| 84 | $titulaire = new User($db); |
||
| 85 | $titulaire->fetch($ballon->fk_responsable); |
||
| 86 | //flight with balloon ID |
||
| 87 | $query = 'SELECT *, TIMEDIFF(heureA,heureD) AS time FROM llx_bbc_vols'; |
||
| 88 | $query.= ' WHERE `BBC_ballons_idBBC_ballons` = '.$ballon->id; |
||
| 89 | $query.= ' AND `incidents` NOT LIKE \'RAS\''; |
||
| 90 | $query.= ' AND `incidents` NOT LIKE \'\''; |
||
| 91 | $query.= ' ORDER BY date'; |
||
| 92 | $resql = $db->query($query); |
||
| 93 | } |
||
| 94 | |||
| 95 | |||
| 96 | |||
| 97 | /*************************************************** |
||
| 98 | * PAGE |
||
| 99 | * |
||
| 100 | * Put here all code to build page |
||
| 101 | ****************************************************/ |
||
| 102 | |||
| 103 | llxHeader('','Carnet de vol',''); |
||
| 104 | if($msg && $idBallon != -1){ |
||
| 105 | print $msg; |
||
| 106 | }else{ |
||
| 107 | $form=new Form($db); |
||
| 108 | |||
| 109 | print '<!-- debut cartouche rapport --> |
||
| 110 | <div class="tabs"> |
||
| 111 | <a class="tab" href="readFlightsBalloon.php?ballon='.$idBallon.'">Carnet de vol</a> |
||
| 112 | <a id="active" class="tab" href="readBalloonInc.php?ballon='.$idBallon.'">Incidents</a> |
||
| 113 | </div>'; |
||
| 114 | print '<div class="tabBar">'; |
||
| 115 | print "<form name='readBalloon' action=\"readFlightsBalloon.php\" method=\"get\">\n"; |
||
| 116 | print '<input type="hidden" name="mode" value="SELECT">'; |
||
| 117 | print '<table width="100%" class="border">'; |
||
| 118 | print '<tr><td>Ballon</td><td colspan="3">'; |
||
| 119 | if($user->rights->flightLog->vol->detail){ |
||
| 120 | select_balloons($idBallon); |
||
| 121 | }else{ |
||
| 122 | print $ballon->immat; |
||
| 123 | } |
||
| 124 | |||
| 125 | print'</td></tr>'; |
||
| 126 | //titulaire |
||
| 127 | print '<tr>'; |
||
| 128 | print '<td>Titulaire</td>'; |
||
| 129 | print '<td>'.$titulaire->getLoginUrl(1).'</td>'; |
||
| 130 | print '</tr>'; |
||
| 131 | //Vol initial |
||
| 132 | print '<tr>'; |
||
| 133 | print '<td>Bapteme</td>'; |
||
| 134 | print '<td>'.dol_print_date($ballon->date, 'dayrfc').'</td>'; |
||
| 135 | print '</tr>'; |
||
| 136 | $num = 0; |
||
| 137 | View Code Duplication | if($resql){ |
|
| 138 | //fetch pilot |
||
| 139 | |||
| 140 | $num = $db->num_rows($resql); |
||
| 141 | //>Nombre d'incidences |
||
| 142 | print '<tr>'; |
||
| 143 | print '<td>Nombre d\'incidences</.td>'; |
||
| 144 | print '<td>' . $num . '</.td>'; |
||
| 145 | print '</tr>'; |
||
| 146 | } |
||
| 147 | print '<tr><td colspan="4" align="center"><input type="submit" class="button" name="submit" value="Rafraichir"></td></tr></table>'; |
||
| 148 | print '</form></div>'; |
||
| 149 | |||
| 150 | |||
| 151 | print '<table class="border" width="100%">'; |
||
| 152 | $i = 0; |
||
| 153 | if($num){ |
||
| 154 | print '<tr class="liste_titre">'; |
||
| 155 | print '<td class="liste_titre"> identifiant </td>'; |
||
| 156 | print '<td class="liste_titre"> Date </td>'; |
||
| 157 | print '<td class="liste_titre"> Ballon </td>'; |
||
| 158 | print '<td class="liste_titre"> Pilote </td>'; |
||
| 159 | print '<td class="liste_titre"> Lieu depart </td>'; |
||
| 160 | print '<td class="liste_titre"> Lieu arrivee </td>'; |
||
| 161 | print '<td class="liste_titre"> Heure depart</td>'; |
||
| 162 | print '<td class="liste_titre"> Heure Arrivee </td>'; |
||
| 163 | print '<td class="liste_titre"> Duree (min) </td>'; |
||
| 164 | print '<td class="liste_titre"> Nbr Pax </td>'; |
||
| 165 | print '<td class="liste_titre"> Rem </td>'; |
||
| 166 | print '<td class="liste_titre"> Incidents </td>'; |
||
| 167 | if($user->rights->flightLog->vol->status){ |
||
| 168 | print '<td class="liste_titre"> Statut </td>'; |
||
| 169 | } |
||
| 170 | print'</tr>'; |
||
| 171 | while($i <$num){ |
||
| 172 | $obj = $db->fetch_object($resql); //vol |
||
| 173 | print '<tr>'; |
||
| 174 | if($obj){ |
||
| 175 | $pilot = New User($db); //pilot |
||
| 176 | $pilot->fetch($obj->fk_pilot); |
||
| 177 | print '<td><a href="fiche.php?vol='.$obj->idBBC_vols.'">'.$obj->idBBC_vols.'</a></td>'; |
||
| 178 | print '<td>'.$obj->date.'</td>'; |
||
| 179 | print '<td>'.$ballon->immat.'</td>'; |
||
| 180 | print '<td>'.$pilot->getNomUrl().'</a></td>'; |
||
| 181 | print '<td>'.$obj->lieuD.'</td>'; |
||
| 182 | print '<td>'.$obj->lieuA.'</td>'; |
||
| 183 | print '<td>'.$obj->heureD.'</td>'; |
||
| 184 | print '<td>'.$obj->heureA.'</td>'; |
||
| 185 | print '<td>'.$obj->time.'</td>'; |
||
| 186 | print '<td>'.$obj->nbrPax.'</td>'; |
||
| 187 | print '<td>'.$obj->remarque.'</td>'; |
||
| 188 | print '<td>'.$obj->incidents.'</td>'; |
||
| 189 | if($user->rights->flightLog->vol->status){ |
||
| 190 | $vol = new Bbcvols($db); |
||
| 191 | $vol->fetch($obj->idBBC_vols); |
||
| 192 | print '<td>' . $vol->getStatus().'</td>'; |
||
| 193 | } |
||
| 194 | } |
||
| 195 | print'</tr>'; |
||
| 196 | $i++; |
||
| 197 | } |
||
| 198 | } |
||
| 199 | print'</table>'; |
||
| 200 | |||
| 201 | } |
||
| 202 | /*************************************************** |
||
| 203 | * LINKED OBJECT BLOCK |
||
| 204 | * |
||
| 205 | * Put here code to view linked object |
||
| 206 | ****************************************************/ |
||
| 207 | //$somethingshown=$myobject->showLinkedObjectBlock(); |
||
| 208 | |||
| 209 | // End of page |
||
| 210 | $db->close(); |
||
| 211 | llxFooter('$Date: 2011/07/31 22:21:57 $ - $Revision: 1.19 $'); |
||
| 212 | ?> |
||
|
0 ignored issues
–
show
|
|||
| 213 |
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.