Jump to content
ahughes3

SimBrief form to tailor OFP result

Recommended Posts

ProAvia    12

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!

Share this post


Link to post
Share on other sites
ProAvia    12

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).

Share this post


Link to post
Share on other sites
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,

Share this post


Link to post
Share on other sites
ProAvia    12

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

Share this post


Link to post
Share on other sites

@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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×