Jump to content

Imanol

Members
  • Posts

    97
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by Imanol

  1. On 12/22/2023 at 12:56 PM, DisposableHero said:

    @foreach($awards->whereIn('id', [1,2,3,4]) as $award)

     

    You need to know the id numbers of the awards you wish to group for this to work. more info at https://laravel.com/docs/10.x/collections#method-wherein you can use other available methods too.

     

    But there is a logical flaw in the code above, Auth always gives you the logged in user. So for example if you place this code to profile index page and then visit my profile, you will see your own awards ;) 

     

    Hope this helps, good luck

     

    I appreciate it. Happy Holidays!

    • Thanks 1
  2. On 12/2/2023 at 4:16 AM, DisposableHero said:

    I think this can be done in blade... If you know the codes of awards for hours/pirep counts, then you can alter the foreach loop to show only them at top section (or left section) then the rest at bottom etc. (according to your placing wishes)

     

     

     

    Hi @DisposableHero! I modified the original code to show awards into a Bootstrap grid. I need two of this rows, one for hours/pireps awards and the other one for awards in general, but I don't know how to edit the foreach. Thanks.

     

    {{-- Show the user's award if they have any --}}
                    @if (Auth::user()->awards)
                    <div class="row">
                      <div class="col-sm-12">
                        @foreach(Auth::user()->awards->chunk(3) as $awards)
                        <div class="row">
                          @foreach($awards as $award)
                          <div class="col-md-4">
                            <div class="header header-primary text-center">
                              @if ($award->image_url)
                              <div class="photo-container">
                                <img class="img-fluid" src="{{ $award->image_url }}" alt="{{ $award->description }}">
                              </div>
                              @endif
                            </div>
                          </div>
                          @endforeach
                        </div>
                        <div class="clearfix" style="height: 20px;"></div>
                        @endforeach

     

  3. On 11/16/2023 at 4:52 PM, DisposableHero said:

     

    Understood... 

     

    The problem is simple, those pages do not have a controller providing you data to use. This is why {{ $user->name }} fails but {{ Auth::user()->name }} works. To be able to use for example $flight, $user or $aircraft you need it to be prepared in the backend (controller) and passed to the view (that page you are visiting), otherwise you will get errors and those pages are not designed to provide you those details.

     

    Same applies to translations and helpers (@lang is a helper), try using {{ __('common.profile') }} instead of @lang('common.profile'), it may work.

     

    https://laravel.com/docs/10.x/localization#retrieving-translation-strings

     

    Good luck

     

    Hi @DisposableHero,

     

    I have done some tests but {{ __('common.profile') }} is not working either. However, I solved this creating a module per section. Thanks for your help!

    • Like 1
  4. Hello,

     

    I built my own skin using Bootstrap but I'm having some issues using the PHP and language tags.

     

    I want the user's name to appear in the navbar header when they log in. I placed the tag {{ $user->name }} but it only works in templates that already come default with PHPVMS 7, for example with home, dashboard, etc. When I open one of the custom pages I have a 500 error.

     

    On the other hand, language tags also don't work when I insert them into a custom page. For example: @lang('common.profile'), does not appear rendered as "Perfil" ("Profile" in Spanish) but instead appears directly as "@lang('common.profile')".

     

    Thanks in advance.

  5. Hello!

     

    I'm setting up phpVMS 7 for my virtual airline and I'm also editting some templates. I need the flight search results to show the days which each flight is operated. Is there any piece of code to do so? Thanks in advance.

  6. 3 hours ago, magicflyer said:

    The problem isn't in that file.It's the jQuery - You must be loading in a conflicting library that also uses the $ symbol to call jQuery (I'm guessing this is a new theme that is using bootstrap?). You're probably loading two versions of jQuery on the same page.
    This might help: https://api.jquery.com/jQuery.noConflict/

    You can also try loading the new bootstrap jQuery before every other script in the file core_htmlhead.tpl

    I deleted the no conflict script it had and now the map works perfectely. Thank you!

  7. Hi. I am having problems with the ACARS map, it does not show any flights, not even in the lists. On the home page of my site we have a table that shows flights in curos and works correctly. I don't know what the problem with the map might be. I leave the code of the php file and template. Thank you!

     

    ACARS.php

     

    <?php
    /**
     * phpVMS - Virtual Airline Administration Software
     * Copyright (c) 2008 Nabeel Shahzad
     * For more information, visit www.phpvms.net
     *	Forums: http://www.phpvms.net/forum
     *	Documentation: http://www.phpvms.net/docs
     *
     * phpVMS is licenced under the following license:
     *   Creative Commons Attribution Non-commercial Share Alike (by-nc-sa)
     *   View license.txt in the root, or visit http://creativecommons.org/licenses/by-nc-sa/3.0/
     *
     * @author Nabeel Shahzad
     * @copyright Copyright (c) 2008, Nabeel Shahzad
     * @link http://www.phpvms.net
     * @license http://creativecommons.org/licenses/by-nc-sa/3.0/
     */
    
    class ACARS extends CodonModule
    {
    	public $title = 'ACARS';
    	public $acarsflights;
    
    	public function index()
    	{
    		$this->viewmap();
    	}
    
    	public function viewmap()
    	{
    		$this->title = 'ACARS Map';
    		$this->set('acarsdata', ACARSData::GetACARSData());
    		$this->render('acarsmap.tpl');
    	}
    
    	/**
    	 *  We didn't list a function for each ACARS client,
    	 *	so call this, which will include the acars peice in
    	 */
    	public function __call($name, $args)
    	{
    		$acars_action = $args[0];
    
    		// clean the name...
    		$name = preg_replace("/[^a-z0-9-]/", "", strtolower($name));
    		if(dirname(__FILE__).DS.$name.'.php')
    		{
    			include_once dirname(__FILE__).DS.$name.'.php';
    			return;
    		}
    	}
    
    	public function data()
    	{
    		$flights = ACARSData::GetACARSData();
    
    		if(!$flights)
    			$flights = array();
    
    		$this->acarsflights = array();
    		foreach($flights as $flight)
    		{
    			if($flight->route == '')
    			{
    				$flight->route_details = array();
    			}
    			else
    			{
    				$flight->route_details = NavData::parseRoute($flight->route);
    			}
    
    			$c = (array) $flight; // Convert the object to an array
    
    			$c['pilotid'] = PilotData::GetPilotCode($c['code'], $c['pilotid']);
    
    			// Normalize the data
    			if($c['timeremaining'] == '')
    			{
    				$c['timeremaining'] ==  '-';
    			}
    
    			if(trim($c['phasedetail']) == '')
    			{
    				$c['phasedetail'] = 'Enroute';
    			}
    
    			/* If no heading was passed via ACARS app then calculate it
    				This should probably move to inside the ACARSData function, so then
    				 the heading is always there for no matter what the calcuation is
    				*/
    			if($flight->heading == '')
    			{
    				/* Calculate an angle based on current coords and the
    					destination coordinates */
    
    				$flight->heading = intval(atan2(($flight->lat - $flight->arrlat), ($flight->lng - $flight->arrlng)) * 180 / 3.14);
    				//$flight->heading *= intval(180/3.14159);
    
    				if(($flight->lng - $flight->arrlng) < 0)
    				{
    					$flight->heading += 180;
    				}
    
    				if($flight->heading < 0)
    				{
    					$flight->heading += 360;
    				}
    			}
    
    			// Little one-off fixes to normalize data
    			$c['distremaining'] = $c['distremain'];
    			$c['pilotname'] = $c['firstname'] . ' ' . $c['lastname'];
    
    			unset($c['messagelog']);
                $c['flightcode'] = substr($c['flightnum'], 0, 3);
    			$this->acarsflights[] = $c;
    
    			continue;
    		}
    
    		CodonEvent::Dispatch('refresh_acars', 'ACARS');
    
    		echo json_encode($this->acarsflights);
    	}
    
    	public function routeinfo()
    	{
    		if($this->get->depicao == '' || $this->get->arricao == '')
    			return;
    
    		$depinfo = OperationsData::GetAirportInfo($this->get->depicao);
    		if(!$depinfo)
    		{
    			$depinfo = OperationsData::RetrieveAirportInfo($this->get->depicao);
    		}
    
    		$arrinfo = OperationsData::GetAirportInfo($this->get->arricao);
    		if(!$arrinfo)
    		{
    			$arrinfo = OperationsData::RetrieveAirportInfo($this->get->arricao);
    		}
    
    		// Convert to json format
    		$c = array();
    		$c['depapt'] = (array) $depinfo;
    		$c['arrapt'] = (array) $arrinfo;
    
    		echo json_encode($c);
    	}
    
    	public function fsacarsconfig()
    	{
    		$this->write_config('fsacars_config.tpl', Auth::$userinfo->code.'.ini');
    	}
    
    	public function fspaxconfig()
    	{
    		$this->write_config('fspax_config.tpl', Auth::$userinfo->code.'_config.cfg');
    	}
    
    	public function xacarsconfig()
    	{
    		$this->write_config('xacars_config.tpl', 'xacars.ini');
    	}
    
    	/**
    	 * Write out a config file to the user, give the template name and
    	 *	the filename to save the template as to the user
    	 *
    	 * @param mixed $template_name Template to use for config (fspax_config.tpl)
    	 * @param mixed $save_as File to save as (xacars.ini)
    	 * @return mixed Nothing, sends the file to the user
    	 *
    	 */
    	public function write_config($template_name, $save_as)
    	{
    		if(!Auth::LoggedIn())
    		{
    			echo 'You are not logged in!';
    			return;
    		}
    
    		$this->set('pilotcode', PilotData::GetPilotCode(Auth::$userinfo->code, Auth::$userinfo->pilotid));
    		$this->set('userinfo', Auth::$userinfo);
    
    		$acars_config = Template::GetTemplate($template_name, true);
    		$acars_config = str_replace("\n", "\r\n", $acars_config);
    
    		Util::downloadFile($acars_config, $save_as);
    	}
    }

     

    acarsmap.tpl

    
    <head><meta http-equiv="Content-Type" content="text/html; charset=gb18030">
    <style>
    .map-responsive iframe{
        left:0;
        top:0;
        height:100%;
        width:100%;
        position:absolute;
    }
    .table > thead > tr > th,
    .table > tbody > tr > th,
    .table > tfoot > tr > th,
    .table > thead > tr > td,
    .table > tbody > tr > td,
    .table > tfoot > tr > td {
      vertical-align: middle;
    }
    
    </style>
    </head>
                                                                    <?php 
    /**
     * These are some options for the ACARS map, you can change here
     * 
     * By default, the zoom level and center are ignored, and the map 
     * will try to fit the all the flights in. If you want to manually set
     * the zoom level and center, set "autozoom" to false.
     * 
     * You can use these MapTypeId's:
     * http://code.google.com/apis/maps/documentation/v3/reference.html#MapTypeId
     * 
     * Change the "TERRAIN" to the "Constant" listed there - they are case-sensitive
     * 
     * Also, how to style the acars pilot list table. You can use these style selectors:
     * 
     * table.acarsmap { }
     * table.acarsmap thead { }
     * table.acarsmap tbody { }
     * table.acarsmap tbody tr.even { }
     * table.acarsmap tbody tr.odd { } 
     */
    ?>
    <div class="mapcenter" align="center">
    	<div class="map-responsive" id="acarsmap" style="width:90%; height: 500px"></div>
    </div>
    <p>&nbsp;</p>
    <?php
    /* See below for details and columns you can use in this table */
    ?>
    <div class="table-responsive">
    <table border = "0" width="75%" class="table table-hover SegoeUI Text" align="center">
    <thead>
    	<tr>
    		<td><strong>Operado por</strong></td>
    		<td><strong>Piloto</strong></td>
    		<td><strong>N煤mero de vuelo</strong></td>
    		<td><strong>Salida</strong></td>
    		<td><strong>Destino</strong></td>
    		<td><strong>Estado</strong></td>
    		<td><strong>Dist./E. R. T.</strong></td>
            <td><strong>Avi贸n</strong></td>
            <td><strong>On-line</strong></td>
    	</tr>
    </thead>
    <tbody id="pilotlist"></tbody>
    </table>
    </div>
    <script src="<?php echo SITE_URL?>/lib/js/base_map.js"></script>
    <script src="<?php echo SITE_URL?>/lib/js/acarsmap.js"></script>
    <?php
    /* This is the template which is used in the table above, for each row. 
    	Be careful modifying it. You can simply add/remove columns, combine 
    	columns too. Keep each "section" (<%=...%>) intact
    	
    	Variables you can use (what they are is pretty obvious)
    	
    	Variable:							Notes:
    	<%=flight.pilotid%>
    	<%=flight.firstname%>
    	<%=flight.lastname%>
    	<%=flight.pilotname%>				First and last combined
    	<%=flight.flightnum%>
    	<%=flight.depapt%>					Gives the airport name
    	<%=flight.depicao%>
    	<%=flight.arrapt%>					Gives the airport name
    	<%=flight.arricao%>
    	<%=flight.phasedetail%>
    	<%=flight.heading%>
    	<%=flight.alt%>
    	<%=flight.gs%>
    	<%=flight.disremaining%>
    	<%=flight.timeremaning%>
    	<%=flight.aircraft%>				Gives the registration
    	<%=flight.aircraftname%>			Gives the full name
    	<%=flight.client%>					FSACARS/Xacars/FSFK, etc
    	<%=flight.trclass%>					"even" or "odd"
    	
    	You can also use logic in the templating, if you so choose:
    	http://ejohn.org/blog/javascript-micro-templating/
    */
    ?>
    <script type="text/html" id="acars_map_row">
    <tr class="<%=flight.trclass%>">
    <td><img src="https://www.skyjetvirtual.com/imagenes/logos/small/<%=flight.flightcode%>.png"></td>
    <td><a href="<?php echo url('/profile/view');?>/<%=flight.pilotid%>"><%=flight.pilotid%> - <%=flight.pilotname%></a></td>
    <td class="auto-style2001"><%=flight.flightnum%></td>
    <td class="auto-style2001"><%=flight.depicao%></td>
    <td class="auto-style2001"><%=flight.arricao%></td>
    <td class="auto-style2001"><%=flight.phasedetail%></td>
    <td class="auto-style2001"><%=flight.distremaining%> <?php echo Config::Get('UNITS');?> / <%=flight.timeremaining%></td>
    <td class="auto-style2001"><%=flight.aircraftname%></td>
    <td class="auto-style2001"><%=flight.online%></td>
    </tr>
    </script>
    
    <?php
    /*	This is the template for the little map bubble which pops up when you click on a flight
    	Same principle as above, keep the <%=...%> tags intact. The same variables are available
    	to use here as are available above.
    */
    ?>
    <script type="text/html" id="acars_map_bubble">
    <span style="font-size: 10px; text-align:left; width: 100%" align="left">
    <a href="<?php echo url('/profile/view');?>/<%=flight.pilotid%>"><%=flight.pilotid%> - <%=flight.pilotname%></a><br />
    <strong>Flight <%=flight.flightnum%></strong> (<%=flight.depicao%> to <%=flight.arricao%>)<br />
    <strong>Status: </strong><%=flight.phasedetail%><br />
    <strong>Dist/Time Remain: </strong><%=flight.distremaining%> <?php echo Config::Get('UNITS');?> / <%=flight.timeremaining%><br />
    </span>
    </script>
    
    <?php
    /*	This is a small template for information about a navpoint popup 
    	
    	Variables available:
    	
    	<%=nav.title%>
    	<%=nav.name%>
    	<%=nav.freq%>
    	<%=nav.lat%>
    	<%=nav.lng%>
    	<%=nav.type%>	2=NDB 3=VOR 4=DME 5=FIX 6=TRACK
     */
    ?>
    <script type="text/html" id="navpoint_bubble">
    <span style="font-size: 10px; text-align:left; width: 100%" align="left">
    <strong>Name: </strong><%=nav.title%> (<%=nav.name%>)<br />
    <strong>Type: </strong>
    <?php	/* Show the type of point */ ?>
    <% if(nav.type == 2) { %> NDB <% } %>
    <% if(nav.type == 3) { %> VOR <% } %>
    <% if(nav.type == 4) { %> DME <% } %>
    <% if(nav.type == 5) { %> FIX <% } %>
    <% if(nav.type == 6) { %> TRACK <% } %>
    <br />
    <?php	/* Only show frequency if it's not a 0*/ ?>
    <% if(nav.freq != 0) { %>
    <strong>Frequency: </strong><%=nav.freq%>
    <% } %>
    </span>
    </script>
    <script type="text/javascript">
    <?php 
    /* These are the settings for the Google map. You can see the
    	Google API reference if you want to add more options.
    	
    	There's two options I've added:
    	
    	autozoom: This will automatically center in on/zoom 
    	  so all your current flights are visible. If false,
    	  then the zoom and center you specify will be used instead
    	  
    	refreshTime: Time, in seconds * 1000 to refresh the map.
    	  The default is 10000 (10 seconds)
    */
    ?>
    const opts = {
    	render_elem: 'acarsmap',
    	provider: '<?php echo Config::Get("MAP_TYPE"); ?>',
    	autozoom: true,
    	zoom: <?php echo Config::Get('MAP_ZOOM_LEVEL'); ?>,
        center: L.latLng("<?php echo Config::Get('MAP_CENTER_LAT'); ?>", "<?php echo Config::Get('MAP_CENTER_LNG'); ?>"),
        refreshTime: 10000
    };
    renderAcarsMap(opts);
    </script>       
                                

     

  8. Hi all,

    I would like to know if there is a possibility that several senders send mass emails to pilots. My idea is that in the option "Email all pilots" there is a drop-down list in which each administrator chooses his name to appear as sender. I saw that in the file "Util.class.php" there is the possibility to edit this, I would like a sender from the list to be used instead of the default email address.

     

    Thank you!

  9. Hi everyone,

    Since last week my virtual airline can not receive flights reports because the PIREPS function stopped working by surprise (manually or through smartCARS).

    I tried reinstalling the PIREPS module, the classes files and the whole site using the last version of phpVMS available but it does not work either.

    I contacted my hosting provider and after some tests they told me it could be a problem compatibility with MariaDB. Last Wednesday they updated their servers, including MariaDB, since then I have this issue.

     

    Here you have more details:

    SQL: 10.2.8-MariaDB
    phpMyAdmin: 4.7
    Apache: 2.4.27 + LSAPI
    PHP 7.0.22

    Could be this a problem with MariaDB?

×
×
  • Create New...