ahughes3 Posted February 23, 2016 Report Share Posted February 23, 2016 (edited) Firstly, thank you to Vangelis for all the great work and support he gives to the community. I only wish I were half as capable! I have been using the community for a long time now and I am not often in the position to offer much back other than comments on posts. Hopefully, this will make up for it. Like many, I am using Vangelis' SimBrief addon, which creates a button that allows you to generate a SimBrief OFP. This worked great for a while on my airline site, but having used SimBrief itself, I wanted more control over the information used in my flight planning. I wanted something a little more like the Dispatch System used on SimBrief's website. I set about creating a form that I could use to specify some settings, before generating the OFP itself. After much playing around with ideas and combinations, I came up with something that works really well for me and creates a very accurate OFP. I wanted to share it on here and give a little something back. What this addon does. It provides a form that allows you to configure the following aspects of your flight plan: Aircraft type Weight unit preference (lbs or kgs) The departure and destination airports Contingency fuel amount Reserve fuel amount (time based) Detailed or simple Navlog ETOPS planning Stepclimb detail Runway analysis NOTAMS inclusion Flight Map detail Plan layout (LIDO, BAW etc) Route preference Any of these options can be switched on or off, or adjusted before clicking the "Generate OFP" button. You can also configure the form by deleting or hiding elements you don't want pilots to change or control. Readme from Github A form to allow options to be altered before generating the SimBrief OFP. NOTE: This addon is designed to work with the SimBrief Addon by Vangelis on PHPVMS Forums. You must have this installed for this functionality to work. http://forum.phpvms....ief-for-phpvms/ I am also using David Clark's version of PHPVMS where the templates are in .php format rather than .tpl. If you have an older version and your template files are .tpl, simply alter the file extension as required and the file should work. You must also have a SimBrief API key which is expained in Vangelis' module and you also need to register for a free SimBrief account for the form to work as it needs to make a connection to SimBrief itself. INSTALLATION Download the "schedules_briefing.php" file from here. It is optional if you want to download the "style.css" file. It gives you the custom styles I have used for my form and page. You may want to use your own sites styling for the form and tables. If you are using a custom skin for phpvms then you will need to place the "schedules_briefing.php" file in /lib/skins/(your skin name). If you are not using a custom skin, then you should place the file in /core/templates/. If you wish to use my styling, you can just copy and paste the styles from my "style.css" to your style file. For a custom skin this is likely to be /lib/skins/(your skin name)/css/style.css. For a vanilla phpvms install, your style file should be located in /lib/css/phpvms.css. If you want to use your own styling, then you need to change the following html tag references in the "schedules_briefing.php" file you downloaded. Change "classic-title5" to one of your own header styles The "call-action" is a Boostrap3 box. The styling of the box is controlled by "call-action-style1. <div class="call-action call-action-boxed call-action-style1 no-descripton clearfix"> This controls the general styling of the container and it's elements that house the tables. <div class="schedule-briefing"> This controls the specific table style. You can simply overwrite "briefing-table" with your own style classname. <table class="briefing-table"> The "dispinput" styles the input and select form elements on the page. <select class="dispinput" name="date" id="date"> <p>Once you've uploaded the schedule_briefing.php file, you need to also edit the following line at the bottom of the file. Replace the url from my form (highlighted bit below) . <button type="button" style="width:100%" class="btn btn-success btn-lg" onclick="simbriefsubmit('http://www.globalairalliance.com/index.php/SimBrief');" style="font-size:30px" value="Generate">Click to Generate OFP> with yours as shown below. <button type="button" style="width:100%" class="btn btn-success btn-lg" onclick="simbriefsubmit('http://Your website URL here/index.php/SimBrief');" style="font-size:30px" value="Generate">Click to Generate OFP</button> To add the "dynamically called fleet" from your database, you also need to download and install the "OperationsData.class.php file and copy it to your "core/common" directory. Rename your existing file to "OperationsData.class.phpOLD" so you have a backup, just incase anything breaks. That's it, you should be good to go. To test it, bid on a flight, go to "view my bids" and click on "pilot brief". You should now see your form. Adjust the settings as you need and press on the "Click to Generate OFP". You should now see your OFP complete with accurate timings and fuel predictions. Enjoy! Link to Github files Credits: Vangelis, Web541, Strider, Keith Edited December 8, 2016 by ahughes3 1 Quote Link to comment Share on other sites More sharing options...
TennShadow Posted February 24, 2016 Report Share Posted February 24, 2016 Nice job. I made a couple edits to the route planner section so that FlightAware and SkyVector include the ICAO's. <a href="http://flightaware.com/analysis/route.rvt?origin=<?php echo $schedule->depicao ; ?>&destination=<?php echo $schedule->arricao ; ?>" id="falink" target="_blank"> <a href="https://skyvector.com/?chart=304&zoom=6&fpl=<?php echo $schedule->depicao ; ?>%20%20<?php echo $schedule->arricao ; ?>" id="sklink" target="_blank"> I noticed that you hard coded dates in your form. Please correct me if I'm wrong but after March 22nd I'll have to go change all the dates? Quote Link to comment Share on other sites More sharing options...
ahughes3 Posted February 24, 2016 Author Report Share Posted February 24, 2016 Keith, thanks for the update. I'll see if I can include it in my Github files (assuming I can work out how!). Regarding the dates, I will have a look into that. Thanks Quote Link to comment Share on other sites More sharing options...
ahughes3 Posted February 24, 2016 Author Report Share Posted February 24, 2016 Ok so I know I'm going to regret this but I can't find a code that will return the date as "12 Mar" format. I have a calculation the returns both the day and month but as separate fields and I can't get the together. When I upload it only the first calculation appears. The code I'm using is below. <td><select class="dispinput" name="date" id="date"> <?php for($i= 1; $i <= 31; $i++) { ?><option value="<?php printf("%02d", $i); ?>"><?php printf("%02d", $i); ?><?php } ?> <?php for($i= 1; $i <= 12; $i++) { ?> <?php printf("%02d", $i); ?>"><?php printf("%02d", $i); ?></option><?php } ?> </select> </td> Quote Link to comment Share on other sites More sharing options...
TennShadow Posted February 24, 2016 Report Share Posted February 24, 2016 That falls outside of my realm of knowledge but there are a lot of smart developers on here that I'm sure will chime in and help on this. Quote Link to comment Share on other sites More sharing options...
ahughes3 Posted February 24, 2016 Author Report Share Posted February 24, 2016 Ok I now figure it is much easier to use the datepicker built into jquery to select the date. It now allows you to select the date but when I generate the OFP, it still shows the current date. I'm looking into what could be the problem but if anyone else has a notion, I'd be grateful for the help. Code I'm using is below. <td> <script> $(function() { $( "#datepicker" ).datepicker({dateFormat: "ddMy" }); }); </script> <input class="dispinput" name="date" size="7" type="text" id="datepicker"> </td> Amended file now on Github. Quote Link to comment Share on other sites More sharing options...
Members Vangelis Posted February 25, 2016 Members Report Share Posted February 25, 2016 I do not know if you want the solution or not yet But i will give you a tip <form id="sbapiform"> the location is wrong also you have 1 more mistake in your code as debugging software is a wonderful experience only if you are on drugs i want to remind you that time is splitted in Hours = 1-24 and minutes = 00-60 if you wish i can post the solution Quote Link to comment Share on other sites More sharing options...
ahughes3 Posted February 25, 2016 Author Report Share Posted February 25, 2016 Ha ha, darn you Vangelis!! lol. I was working on it this morning and Derek from SimBrief suggested I check the popup url window to see if the date parameter was being passed. It wasn't. So I went back to look at why in the schedules_briefing.php and bam I saw it. The "sbapiform" was in the wrong place. I moved it and the date now works perfectly. Then you go present me with another problem! Oh I love learning Give me a short mo to look at the time thing and if it stumps me completely, I'll take you up on that solution. Quote Link to comment Share on other sites More sharing options...
ahughes3 Posted February 25, 2016 Author Report Share Posted February 25, 2016 Got it! I'd used the mins hours bit for both the hours and mins. I have changed it and tested it. All seems to be good with it now. I will upload it again to Github. Any other errors please do feel free to keep them to yourself, ahem....I mean, let me know and I will try to sort. Thanks again guys for the support. Quote Link to comment Share on other sites More sharing options...
Members Vangelis Posted February 25, 2016 Members Report Share Posted February 25, 2016 1 tip i would replace the whole hard coded time code with this $r = range(1, 24); $selected = is_null($selected) ? date('h') : $selected; $select = "<select name=deph id=dephour>\n"; foreach ($r as $hour) { $select .= "<option value=\"$hour\""; $select .= ($hour==$selected) ? ' selected="selected"' : ''; $select .= ">$hour</option>\n"; } $select .= '</select>'; echo $select; echo":"; $rminutes = range(1, 60); $selected = is_null($selected) ? date('h') : $selected; $selectminutes = "<select name=depm id=dephour>\n"; foreach ($rminutes as $minutes) { $selectminutes .= "<option value=\"$minutes\""; $selectminutes .= ($hour==$selected) ? ' selected="selected"' : ''; $selectminutes .= ">$minutes</option>\n"; } $selectminutes .= '</select>'; echo $selectminutes; also you can get a dynamic fleet from the db if you want as i saw that you have it hard coded Quote Link to comment Share on other sites More sharing options...
ahughes3 Posted February 26, 2016 Author Report Share Posted February 26, 2016 1 tip i would replace the whole hard coded time code with this $r = range(1, 24); $selected = is_null($selected) ? date('h') : $selected; $select = "<select name=deph id=dephour>\n"; foreach ($r as $hour) { $select .= "<option value=\"$hour\""; $select .= ($hour==$selected) ? ' selected="selected"' : ''; $select .= ">$hour</option>\n"; } $select .= '</select>'; echo $select; echo":"; $rminutes = range(1, 60); $selected = is_null($selected) ? date('h') : $selected; $selectminutes = "<select name=depm id=dephour>\n"; foreach ($rminutes as $minutes) { $selectminutes .= "<option value=\"$minutes\""; $selectminutes .= ($hour==$selected) ? ' selected="selected"' : ''; $selectminutes .= ">$minutes</option>\n"; } $selectminutes .= '</select>'; echo $selectminutes; also you can get a dynamic fleet from the db if you want as i saw that you have it hard coded Brilliant as ever Vangelis. A question......how do I set it so the times display two digit format with the leading zero for times less than 10? Quote Link to comment Share on other sites More sharing options...
ahughes3 Posted March 10, 2016 Author Report Share Posted March 10, 2016 also you can get a dynamic fleet from the db if you want as i saw that you have it hard coded Umm yes please this would be a good addition. I'm already having issues with aircraft not appearing on the list Thank you. Quote Link to comment Share on other sites More sharing options...
TennShadow Posted March 27, 2016 Report Share Posted March 27, 2016 Has anymore updates been made to this template? Quote Link to comment Share on other sites More sharing options...
Strider Posted April 5, 2016 Report Share Posted April 5, 2016 <select class="dispinput" name="type"></option><?php $equipment = OperationsData::getAllAircraft(); if(!$equipment) $equipment = array(); foreach($equipment as $equip) { echo '<option value="'.$equip->name.'">'.$equip->name.'</option>'; } ?></select> the above code will get the aircraft from your DB. Quote Link to comment Share on other sites More sharing options...
web541 Posted April 5, 2016 Report Share Posted April 5, 2016 I could be wrong, but according to the github files, he has specified to use the ICAO as the value so it should be like this <select class="dispinput" name="type"> <?php $equipment = OperationsData::getAllAircraft(true); if(!$equipment) $equipment = array(); foreach($equipment as $equip) { echo '<option value="'.$equip->icao.'">'.$equip->name.'</option>'; } ?> </select> And I've also specified (true) to allow the query to attach only the aircraft that are enabled, of course you can remove that to search every aircraft like above --------------------------------- Again, not sure if this is the case, but you may find yourself with duplicates of many aircraft as it's pulling each aircraft from the database. Instead, what i recommend doing is using this in your form <select class="dispinput" name="type"> <?php $equipment = OperationsData::getAllAircraftSingle(true); if(!$equipment) $equipment = array(); foreach($equipment as $equip) { echo '<option value="'.$equip->icao.'">'.$equip->icao.' - '.$equip->name.'</option>'; } ?> </select> and in OperationsData.class.php in core/common place this anywhere in that file (under the getAllAircraft($onlyenabled == false) function for neatness) public static function getAllAircraftSingle($onlyenabled = false) { if ($onlyenabled == true) { $sql = "SELECT * FROM ".TABLE_PREFIX."aircraft a LEFT JOIN ".TABLE_PREFIX."ranks r ON r.rankid = a.minrank WHERE enabled = 1 GROUP BY(a.icao) ORDER BY a.icao ASC"; } else { $sql = "SELECT * FROM ".TABLE_PREFIX."aircraft a LEFT JOIN ".TABLE_PREFIX."ranks r ON r.rankid = a.minrank GROUP BY(a.icao) ORDER BY a.icao ASC"; } $all_aircraft = DB::get_results($sql); if(!$all_aircraft) { $all_aircraft = array(); } return $all_aircraft; } And that should work by giving you a different entry for each icao and specifying (true) will work as above as well but it will only show the icao if the whole fleet with that icao has been enabled Quote Link to comment Share on other sites More sharing options...
ahughes3 Posted April 28, 2016 Author Report Share Posted April 28, 2016 Hi all, Apologies, I've been crazy busy with work and family. Plus I've just had to rebuild my VA after my host destroyed it due to an incompetent error. Good thing for backups! Ok so I can see there have been some additional suggestions to help pull the fleet info dynamically. Thanks for your input Web541 & Strider. Apologies Vangelis I didn't respond to you sooner, I've been away quite a bit. I will incorporate the additions into my files and upload them to github. There was also another issue I remember seeing on it but I can't think of it right now so I might come back to this thread if I remember and can't sort it myself. Thanks guys Quote Link to comment Share on other sites More sharing options...
ahughes3 Posted December 8, 2016 Author Report Share Posted December 8, 2016 Ok so I have finally made the updates to my files and uploaded them to Github. Latest updates include: Improved the time code as per Vangelis' suggestion. Replaced the code for the fleet dropdown with Strider's dynamically called fleet, using Web541's amended version to avoid duplicate aircraft. Added the "OperationsData.class.php" file to Github with the code necessary to make the dynamic fleet call work properly. Updated the readme file to include installation of the "OperationsData.class.php" file. There is a readme which explains how to install the form and additional files needed to run things properly. I've tested the form and it works very nicely on my VA site. Thanks for your contribution guys! Quote Link to comment Share on other sites More sharing options...
ahughes3 Posted December 8, 2016 Author Report Share Posted December 8, 2016 Brilliant as ever Vangelis. A question......how do I set it so the times display two digit format with the leading zero for times less than 10? Vangelis, I would still like to sort this if possible. I've tried using the PHP letters for times with leading zeros but it makes no difference and just either breaks the form or ends up with a blank dropdown. If you can help, that would be great Quote Link to comment Share on other sites More sharing options...
web541 Posted December 8, 2016 Report Share Posted December 8, 2016 Vangelis, I would still like to sort this if possible. I've tried using the PHP letters for times with leading zeros but it makes no difference and just either breaks the form or ends up with a blank dropdown. If you can help, that would be great Confirm you mean when selecting the dep time? If so, go into your schedule_briefing.php file and find this foreach ($r as $hour) { and replace it with this foreach ($r as $hour) { if(strlen($hour) < 2) { $hour = str_pad($hour, 2, "0", STR_PAD_LEFT); } Quote Link to comment Share on other sites More sharing options...
Members Vangelis Posted December 8, 2016 Members Report Share Posted December 8, 2016 I agree with web sorry for not answering you previous question got lost somewhere <?php $r = range(1, 24); $selected = is_null($selected) ? date('H') : $selected; $select = "<select name=deph id=dephour>\n"; foreach ($r as $hour) { if(strlen($hour) < 2) { $hour = str_pad($hour, 2, "0", STR_PAD_LEFT); } $select .= "<option value=\"$hour\""; $select .= ($hour==$selected) ? ' selected="selected"' : ''; $select .= ">$hour</option>\n"; } $select .= '</select>'; echo $select; echo":"; $rminutes = range(1, 60); $selected = is_null($selected) ? date('i') : $selected; $selectminutes = "<select name=depm id=dephour>\n"; foreach ($rminutes as $minutes) { if(strlen($minutes) < 2) { $minutes = str_pad($minutes, 2, "0", STR_PAD_LEFT); } $selectminutes .= "<option value=\"$minutes\""; $selectminutes .= ($minutes==$selected) ? ' selected="selected"' : ''; $selectminutes .= ">$minutes</option>\n"; } $selectminutes .= '</select>'; echo $selectminutes; ?> 1 Quote Link to comment Share on other sites More sharing options...
Chriger Posted January 16, 2017 Report Share Posted January 16, 2017 (edited) Quick question, Do you know where the script pulls the Airline and Flight Number? Every time I click "Click to Generate" it puts a random flight number, that 1. Isn't in my aircraft database, or listed anyone on my site. So I'm not sure how to fix that. Example: Airline = LXA Flight Number = LXA57 on Brief Page. After clicking Generate, Flight Number = N320SB. Edit: So I figured out it's pulling the registration number of the aircraft from the SimBrief database. Is there any way to transmit our airline and flight number, in order for it to show up like that on generated pilot brief under flight number? Solution: Fixed by adding this code before the submit button. <input type="hidden" name="airline" value="<?php echo $schedule->code?>"> <input type="hidden" name="fltnum" value="<?php echo $schedule->flightnum?>"> <input type="hidden" name="reg" value="<?php echo $schedule->registration?>"> Edited January 17, 2017 by Chriger 1 Quote Link to comment Share on other sites More sharing options...
Omerr01 Posted March 18, 2017 Report Share Posted March 18, 2017 I have a problem when i clicking Click to Generate OFP nothing change.. Quote Link to comment Share on other sites More sharing options...
Members Vangelis Posted March 18, 2017 Members Report Share Posted March 18, 2017 Can you provide your website address ? Quote Link to comment Share on other sites More sharing options...
Omerr01 Posted March 18, 2017 Report Share Posted March 18, 2017 I have a problem when i clicking Click to Generate OFP nothing change.. 1 hour ago, Vangelis said: Can you provide your website address ? http://crew.elalvirtual.com Quote Link to comment Share on other sites More sharing options...
Members Vangelis Posted March 19, 2017 Members Report Share Posted March 19, 2017 You havent incluted simbrief.apiv1.js read again the instalation guide Quote Link to comment Share on other sites More sharing options...
Omerr01 Posted March 19, 2017 Report Share Posted March 19, 2017 15 hours ago, Vangelis said: You havent incluted simbrief.apiv1.js read again the instalation guide I have the this file inside /core/lib/js Quote Link to comment Share on other sites More sharing options...
Members Vangelis Posted March 21, 2017 Members Report Share Posted March 21, 2017 did you added it in your layout.php file ? Quote Link to comment Share on other sites More sharing options...
Omerr01 Posted March 21, 2017 Report Share Posted March 21, 2017 2 hours ago, Vangelis said: did you added it in your layout.php file ? Of course Quote Link to comment Share on other sites More sharing options...
Members Vangelis Posted March 26, 2017 Members Report Share Posted March 26, 2017 can you please send me a test username and password with pm so i can test it while i am logged in as i still dont find the simbrief reference in this link http://crew.elalvirtual.com/index.php/schedules/brief/2 Quote Link to comment Share on other sites More sharing options...
ncd200 Posted April 6, 2017 Report Share Posted April 6, 2017 Okay, Thank you for this file, But I have a problem with the aircraft registration. It recieves the registration from simbrief. any ideas how to fix this? Rick Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.