Jump to content

SimBrief form to tailor OFP result


Recommended Posts

  • Administrators
Posted

I'm having an issue with the minutes box. The hours displays correctly, but the minutes box displays the number 01, regardless of the actual minute time. Both dropdown boxes display the range as listed below.

<?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 .= ($hour==$selected) ? ' selected="selected"' : '';
                                 $selectminutes .= ">$minutes</option>\n";
                         }
                         $selectminutes .= '</select>';
                         echo $selectminutes;
                         ?>

While not 100% sure, I don't think the current minute is being pulled. I did do some research and this line looks correct.

$selected = is_null($selected) ? date('i') : $selected;

Yes, I know the ranges should be hours (0, 23) and minutes (0, 59). But am using the default code to try to remedy my issue.

Any help is greatly appreciated.

TIA!

  • 1 month later...
  • Administrators
Posted

The saga continues...... With the following code, the hours still display correctly, but the minutes box also now displays the hour.

<td>
					<?php date_default_timezone_set('UTC');
					
					$r = range(0, 23); // range of hours
  
                        $selected = is_null($selected) ? date('H') : $selected; //current hour
						 
                        $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 "&nbsp;";
						
                    $rminutes = range(0, 59); //range of minutes

                        $selected = is_null($selected) ? date('i') : $selected; //current minute
						 
                        $selectminutes = "<select name=depm id=depmin>\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;
                        ?>
                    </td>

If I move the entire minutes section to above the hour section, minutes displays in the first box and in the second box. Seems - in either case (hour section first or minutes section first) - that the later section will only display what's in the first section. The time send to simBrief is as listed in the hour and minutes boxes.

Anyone have any ideas? The generation of the simBrief package works great, it's just this time issue.

Also, once it's working correctly, I'd like to increment the returned minutes time by 30 (add 30 minutes).

  • Moderators
Posted
On 05/09/2017 at 5:13 AM, ProAvia said:

The saga continues...... With the following code, the hours still display correctly, but the minutes box also now displays the hour.


<td>
					<?php date_default_timezone_set('UTC');
					
					$r = range(0, 23); // range of hours
  
                        $selected = is_null($selected) ? date('H') : $selected; //current hour
						 
                        $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 "&nbsp;";
						
                    $rminutes = range(0, 59); //range of minutes

                        $selected = is_null($selected) ? date('i') : $selected; //current minute
						 
                        $selectminutes = "<select name=depm id=depmin>\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;
                        ?>
                    </td>

If I move the entire minutes section to above the hour section, minutes displays in the first box and in the second box. Seems - in either case (hour section first or minutes section first) - that the later section will only display what's in the first section. The time send to simBrief is as listed in the hour and minutes boxes.

Anyone have any ideas? The generation of the simBrief package works great, it's just this time issue.

Also, once it's working correctly, I'd like to increment the returned minutes time by 30 (add 30 minutes).

Hey,

 

I looked at your site and can see that you now have this working correctly.  How did you do it?

Regards,

  • Administrators
Posted (edited)

I was waiting a few days to test it out before posting back here.

Change

$selected = is_null($selected) ? date('H') : $selected; //current hour

to

$selected = date('H'); //current hour

and change

$selected = is_null($selected) ? date('i') : $selected; //current minute

to

$selected = date('i'); //current minute

I also moved the echo statements to the end of the code area. Here's the entire section of the schedule_briefing.php file.....

<td>
					<?php date_default_timezone_set('UTC');
					
					{$r = range(0, 23); // range of hours
  
                        $selected = date('H'); //current hour
						//$selected = is_null($selected) ? date('H') : $selected; //current hour
						 
                        $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>';}
					
					{$rminutes = range(0, 59); //range of minutes

						$selected = date('i'); //current minute
						//$selected = is_null($selected) ? date('i') : $selected; //current minute
						 
                        $selectminutes = "<select name=depm id=depmin>\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 $select;
					
					echo "&nbsp;";
					
					echo $selectminutes;
                    ?>    
                    </td>

I don't know why it works or if it will cause other issues down the line. The time is now correct and the simBrief OFP uses this time in its report.

Hoping someone can explain what the sections I deleted/changed are supposed to do.

Edited by ProAvia
  • 2 weeks later...
Posted (edited)

@ahughes3 @Vangelis @web541

What do I have to download from Vangelis' SimBrief? Can you do a small text tutorial? Because it has modules, templates, js, schedule_brienfing, and I do not know if it has to put everything ... I also do not know what to edit and also the template is in .tpl mine is .php

And what do you have to add i the layout.php file? I saw that vangelis had spoken on the front page
Edited by CarlosEduardo2409
Posted (edited)
52 minutes ago, web541 said:

Você precisará primeiro enviar um e-mail para o Simbrief para obter sua chave da API, mas o resto é bastante simples. Sim, você precisará do módulo Simbrief para que isso funcione.

Consulte estas instruções claras para fazê-lo funcionar  https://github.com/vangelisb/Simbrief/tree/master/phpvms

 

I followed the steps all right but this one giving error. But I still do not have the API I've requested, is that why this is giving this error? And where is this layout.tpl and core_htmlhead.tpl? Mine is .php

I'm using your crew center skin. @web541

Error: http://prntscr.com/go3o9d / http://prntscr.com/go3of3

I'm sorry if I wrote wrong, because I'm Brazilian. I'm using google translator
Edited by CarlosEduardo2409
Posted
On 22/09/2017 at 3:51 AM, Vangelis said:

did you read the https://github.com/vangelisb/Simbrief/blob/master/phpvms/ReadMe.txt  ? it has clearly instructions how to do it, if you still dont understand then you will have to find someone with basic file upload and editing knowledge

 

I read, I did everything as written, but it is still not working and when I click on generate the flight plan nothing happened, but I already have the api and put it in the right place, also uninstalled and installed everything again several leaks. One of the main mistakes is this (Warning: simplexml_load_file(): http://www.simbrief.com/ofp/flightplans/xml/:1: parser error : Document is empty in /storage/ssd2/921/2877921/public_html/core/modules/SimBrief/SimBrief.php on line 12) and the button that does not work. Pls help-me @Vangelis

  • 1 month later...
Posted
8 minutes ago, ProAvia said:

Did you install the following module first?

Did you get an API key from simBrief and enter it in the correct place?

 

i have the tailored OFP and also i have emailed for a API key where do i place the API key 

  • Administrators
Posted
2 minutes ago, Michael2015 said:

 

i have the tailored OFP and also i have emailed for a API key where do i place the API key 

You will need to install the module I linked to above. The instructions state where to enter the API key.

  • Administrators
Posted

The link in my post - just a few posts above this one - works fine. It takes you to Github, where you can download the module.

If you're using phpVMS 5.5.2, you may have to adapt the module from .tpl to .php .... but that's pretty easy.

Posted
21 minutes ago, ProAvia said:

The link in my post - just a few posts above this one - works fine. It takes you to Github, where you can download the module.

If you're using phpVMS 5.5.2, you may have to adapt the module from .tpl to .php .... but that's pretty easy.

 

 

easy your talking to a basic coder who is in the procress ar you on discord 

  • 1 month later...
Posted (edited)

hi guys can you please assist, i have installed everything properly as per the instructions given in Read me file and it was working fine but i changed the template to work with my website skin it is giving this error nothing happens when click Generate OFP.

Uncaught TypeError: Cannot read property 'value' of undefined
    at do_simbriefsubmit (simbrief.apiv1.js:116)
    at simbriefsubmit (simbrief.apiv1.js:86)
    at HTMLButtonElement.onclick (5273:918)
do_simbriefsubmit @ simbrief.apiv1.js:116
simbriefsubmit @ simbrief.apiv1.js:86
onclick @ 5273:918

 

Regards

Irfaan Khan

Edited by IrfaanKhan
  • 2 years later...
Posted

I'm sorry if this has been discussed previously but I read all the posts and don't think there's an answer to my question.

 

We have the script up and working as it should but my question is as follow:

 

Is there a way to have only the aircraft called by the Bid already selected in the Brief window?

 

For instance if the Bid is AAL200 scheduled with an Airbus A320, I would like to already have the A320 pre-selected instead of the pull down menu with 300 other aircraft.

 

Appreciate it if anyone has any input in regard. Thanks for the great work!

 

Will

  • 3 weeks later...
  • 5 months later...
Posted
On 4/5/2016 at 4:20 PM, web541 said:

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

Don't know why, but looks like this modification will only show me an empty dropdown menu. If I revert the code back to original one, it will work, but instead shows me all my fleets.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...