Author Topic: Editing VAM to allow multiple sub-VAs in one VAM-installation  (Read 588 times)

VA Pilot

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • EUROJET
Hi,
I have tried test systems of VAOS, FSWIRE, phpvms V2 and V7. While I really like the GUI of FSWIRE, I don´t have control over the data as it´s an online service. With phpvms (the old one looks terrible xD), I do like the more advanced settings regarding sub-airlines, route options (Cargo, Pax, Charter etc.), and Pilot-fleettype-route restrictions.
However, as I don´t want to risk having to overwrite my database when updating (seems to be the case with phpvms v7), I will stick to VAM.
But how to bring the features mentioned above to VAM?
(Warning! Following is a work in progress project!)

This post is just an idea and not the final code.
As there is no GUI to create another VA inside VAM, I duplicted the va_parameters in MySQL and changed the va_name. With va_parameters.va_parameters_id there is an easy way to differenciate several VAs.
Next, I added a operator_id and operator (Varchar) column to fleets with operator_id = va_parameters_id.
in fleet_public.php I added
Code: [Select]
f.operator as operator to the SQl query in line 18 and
Code: [Select]
echo  '<td>' . $row["operator"] . '</a></td><td>'; in line 74 as the first column of the table.

In order to edit/view/add an operator to a fleet, we have to change several files in vamcore/app/view.
add this in vamcore/app/view/fleets/add.ctp and edit.ctp:
Code: [Select]
echo $this->Form->input('operator');add in view.ctp:
Code: [Select]
<tr>
<td><?php echo __('Operator'); ?></td>
<td><?php echo h($fleet['Fleet']['operator']); ?></td>
</tr>
in index.ctp, I added
Code: [Select]
<td><?php echo h($fleet['Fleet']['operator']); ?>&nbsp;</td> in line 30.
These changes only display the values. In order to be able to edit them, we have to edit /vamcore/app/controller/FleetsController.php

As you can see, I am currently not calling operators but fleettypes as I don´t know how to change $this->Fleet->Fleettype->find('list'); to output a list of operators. Please help me! Solved. See below.
[/glow][/b]
« Last Edit: August 07, 2018, 09:43:44 AM by VA Pilot »
CEO and admin of https://eurojetva.eu :)

VA Pilot

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • EUROJET
Re: Editing VAM to allow multiple sub-VAs in one VAM-installation
« Reply #1 on: July 24, 2018, 10:22:42 AM »
I have figured out a workaround on how to have several VAs and assign a plane to a va. I will post again once I have adapted all the other files.
CEO and admin of https://eurojetva.eu :)

CharlieBravo

  • Newbie
  • *
  • Posts: 46
    • View Profile
Re: Editing VAM to allow multiple sub-VAs in one VAM-installation
« Reply #2 on: July 24, 2018, 01:32:55 PM »
Awesome!

VA Pilot

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • EUROJET
Re: Editing VAM to allow multiple sub-VAs in one VAM-installation
« Reply #3 on: July 30, 2018, 03:10:14 PM »
Short update:

I am now able to have several VAs in one databse (one main VA and several sub-VAs), each with their own fleet and routes.
These values can all be edited in the admin-panel. NOTE: my goal is not to have completely independent VAs in one VAM installation.
Moreover, public route table can be searched for operator, route booking now only allows booking of routes operated by anairline which has an aircraft at the departure locstion and for which the pilot meets the minimum rank requirement which is assigned to each route.

Issues to fix (those in brackets are irrelevant for my use case):
  • (Mails sent using the VA parameters of the VA added last -> needs seperation for each VA)
  • (pilots automatically member of each sub-VA as they use the same gvauser table ->needs -//-)
  • Visually differntiate VAs on live map, hub page etc.
  • Figure out VAMcars tracking and assign flight to VA; creating seperate VA-specific sections in global finacial report
  • All the issues I haven´t found yet ;)

Oh, btw, if someone can help me with integrating the Simbrief API - any help is highly appreciated :)

Regards
Tim
« Last Edit: July 30, 2018, 03:12:49 PM by VA Pilot »
CEO and admin of https://eurojetva.eu :)

VA Pilot

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • EUROJET
Re: Editing VAM to allow multiple sub-VAs in one VAM-installation
« Reply #4 on: August 05, 2018, 11:37:00 PM »
I have been busy painting liveries and therefore had to take a break from further modifications.
This will be the first part of a series of posts outlining the changes I made.
Lets start with modifications to the database:
I added the columns operator_id(int) and operator(Varchar) to fleets and routes. To the table routes, I also added the columns rank and rank_id as stated in the first post. These are required to save the minimum rank for each route.

In vamcore/app/Model, add
Code: [Select]
**
 * belongsTo associations
 *
 * @var array
 */
 
public $belongsTo = array(
// other belongsto
'Operator' => array(
'className' => 'Operator',
'foreignKey' => 'operator_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
to Fleets.php

and
Code: [Select]
       'Operator' => array(
'className' => 'Operator',
'foreignKey' => 'operator_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Rank' => array(
'className' => 'Rank',
'foreignKey' => 'rank_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
to the $belongsto relation in Route.php
Also, add the Operator.php attached to this post in the next post.

Next, edit the matching files in vamcore/app/Controller.
FleetsController.php should contain:
Code: [Select]
/**
 * add method
 *
 * @return void
 */
public function add() {

$fleettypes = $this->Fleet->Fleettype->find('list');
$this->set(compact('fleettypes'));

//add function for operator!
$operators = $this->Fleet->Operator->find('list');
$this->set(compact('operators'));

$hubs = $this->Fleet->Hub->find('list');
$this->set(compact('hubs'));

if ($this->request->is('post')) {
include ('../../../vam/db_login.php');
$fleettype_id=$this->data['Fleet']['fleettype_id'];
$registry=$this->data['Fleet']['registry'];
$operator=$this->data['Fleet']['operator'];
$name=$this->data['Fleet']['name'];
$type='';
$aircraftvalue=0;
$db = new mysqli($db_host , $db_username , $db_password , $db_database);
$db->set_charset("utf8");
if ($db->connect_errno > 0) {
die('Unable to connect to database [' . $db->connect_error . ']');
}
$sql = "select * from fleettypes where fleettype_id=$fleettype_id";
if (!$result = $db->query($sql))
{
die('There was an error running the query  [' . $db->error . ']');
}
while ($row = $result->fetch_assoc())
{
$aircraftvalue = -1 * $row['unit_price'];
$type = $row['plane_icao'];
}


$description = $type. ' ' . $registry . ' ' . $name;
$sql = "insert into va_finances (finance_date,amount,description,report_type) values (now(),$aircraftvalue,'$description','New Aircraft')";
if (!$result = $db->query($sql))
{
die('There was an error running the query  [' . $db->error . ']');
}

$this->Fleet->create();
if ($this->Fleet->save($this->request->data)) {

$db = new mysqli($db_host , $db_username , $db_password , $db_database);
$db->set_charset("utf8");
if ($db->connect_errno > 0) {
die('Unable to connect to database [' . $db->connect_error . ']');
}
$sql = "UPDATE fleets F, va_parameters P SET F.operator = P.va_name, F.operator_id = F.operator WHERE F.operator = P.va_parameters_id;";
if (!$result = $db->query($sql))
{
die('There was an error running the query  [' . $db->error . ']');
}

$this->Session->setFlash(__('The fleet has been saved'));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The fleet could not be saved. Please, try again.'));
}
}
}
As you can see I had to use a workaround (SQL query to correct database) as the dropdown menu $operators = $this->Fleet->Operator->find('list'); displays strings but actually returns int values. So instead of the String you end up getting the VA_id as seen as the id in the table va_parameters. The SQl statement puts the int to the correct column and adds the String. I know this is not elegant and my former teacher would probably yell at me for this but at least it works ;)
The same solution is used for the edit method:
Code: [Select]
/**
 * edit method
 *
 * @throws NotFoundException
 * @param string $id
 * @return void
 */
public function edit($id = null) {
$fleettypes = $this->Fleet->Fleettype->find('list');
$this->set(compact('fleettypes'));

$operators = $this->Fleet->Operator->find('list');
$this->set(compact('operators'));
$hubs = $this->Fleet->Hub->find('list');
$this->set(compact('hubs'));

$this->Fleet->id = $id;
if (!$this->Fleet->exists()) {
throw new NotFoundException(__('Invalid fleet'));
}
if ($this->request->is('post') || $this->request->is('put')) {
if ($this->Fleet->save($this->request->data)) {
include ('../../../vam/db_login.php');
$db = new mysqli($db_host , $db_username , $db_password , $db_database);
$db->set_charset("utf8");
if ($db->connect_errno > 0) {
die('Unable to connect to database [' . $db->connect_error . ']');
}
$sql = "UPDATE fleets F, va_parameters P SET F.operator = P.va_name, F.operator_id = F.operator WHERE F.operator = P.va_parameters_id;";
if (!$result = $db->query($sql))
{
die('There was an error running the query  [' . $db->error . ']');
}

$this->Session->setFlash(__('The fleet has been saved'));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The fleet could not be saved. Please, try again.'));
}
} else {
$this->request->data = $this->Fleet->read(null, $id);
}
}
This procedure now has to be repeated for RoutesController.php:
Code: [Select]
/**
 * add method
 *
 * @return void
 */
public function add() {
$hubs = $this->Route->Hub->find('list');
$this->set(compact('hubs'));

$operators = $this->Route->Operator->find('list');
$this->set(compact('operators'));

$ranks = $this->Route->Rank->find('list');
$this->set(compact('ranks'));
if ($this->request->is('post')) {
$operator=$this->data['Route']['operator'];
$rank=$this->data['Route']['rank'];
$this->Route->create();
if ($this->Route->save($this->request->data)) {
// custom sql query to correct table: move operator_id from operator to operator_id and get operator + do the same with (required minimum) rank
include ('../../../vam/db_login.php');
$db = new mysqli($db_host , $db_username , $db_password , $db_database);
$db->set_charset("utf8");
if ($db->connect_errno > 0) {
die('Unable to connect to database [' . $db->connect_error . ']');
}
$sql = "UPDATE routes R, va_parameters P, ranks SET R.operator = P.va_name, R.operator_id = R.operator, R.rank = ranks.rank, R.rank_id = R.rank WHERE R.operator = P.va_parameters_id AND R.rank = ranks.rank_id;";
if (!$result = $db->query($sql))
{
die('There was an error running the query  [' . $db->error . ']');
}
//end of custom query
$this->Session->setFlash(__('The Route has been saved'));
$this->redirect(array('action' => 'index'));
// VAM $this->flash(__('Route saved.'), array('action' => 'index'));
} else {
}
}
$fleettypes = $this->Route->Fleettype->find('list');
$this->set(compact('fleettypes'));
}

/**
 * edit method
 *
 * @throws NotFoundException
 * @param string $id
 * @return void
 */
 


public function edit($id = null) {
$hubs = $this->Route->Hub->find('list');
$this->set(compact('hubs'));

$operators = $this->Route->Operator->find('list');
$this->set(compact('operators'));
$ranks = $this->Route->Rank->find('list');
$this->set(compact('ranks'));

if (!$this->Route->exists($id)) {
throw new NotFoundException(__('Invalid route'));
}
if ($this->request->is('post') || $this->request->is('put')) {
if ($this->Route->save($this->request->data)) {
// custom sql query to correct table: move operator_id from operator to operator_id and get operator
include ('../../../vam/db_login.php');
$db = new mysqli($db_host , $db_username , $db_password , $db_database);
$db->set_charset("utf8");
if ($db->connect_errno > 0) {
die('Unable to connect to database [' . $db->connect_error . ']');
}
$sql = "UPDATE routes R, va_parameters P, ranks SET R.operator = P.va_name, R.operator_id = R.operator, R.rank = ranks.rank, R.rank_id = R.rank WHERE R.operator = P.va_parameters_id AND R.rank = ranks.rank_id;";
if (!$result = $db->query($sql))
{
die('There was an error running the query  [' . $db->error . ']');
}
//end of custom query
$this->Session->setFlash(__('The Route has been saved'));
$this->redirect(array('action' => 'index'));
} else {
}
} else {
$options = array('conditions' => array('Route.' . $this->Route->primaryKey => $id));
$this->request->data = $this->Route->find('first', $options);
}
$fleettypes = $this->Route->Fleettype->find('list');
$this->set(compact('fleettypes'));
}
Further information will be posted soon.
« Last Edit: August 07, 2018, 09:40:53 AM by VA Pilot »
CEO and admin of https://eurojetva.eu :)

VA Pilot

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • EUROJET
Re: Editing VAM to allow multiple sub-VAs in one VAM-installation
« Reply #5 on: August 06, 2018, 09:40:34 PM »
vamcore/app/Model/Operator.php should look like this:
Code: [Select]
<?php
App
::uses('AppModel''Model');
/**
 * Operator Model
 *
 * @property Fleettype $Fleettype
 */
class Operator extends AppModel {

/**
 * Use table
 *
 * @var mixed False or table name
 */
public $useTable 'va_parameters';

/**
 * Primary key field
 *
 * @var string
 */
public $primaryKey 'va_parameters_id';

/**
 * Display field
 *
 * @var string
 */
public $displayField 'va_name';


//The Associations below have been created with all possible keys, those that are not needed can be removed

/**
 * belongsTo associations
 *
 * @var array
 */
public $hasMany = array(
'Fleet' => array(
'className' => 'Fleet',
'foreignKey' => 'operator_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
'Route' => array(
'className' => 'Route',
'joinTable' => 'fleettypes_routes',
'foreignKey' => 'fleet_id',
'associationForeignKey' => 'fleet_id'
)
);
}
« Last Edit: August 06, 2018, 09:50:00 PM by VA Pilot »
CEO and admin of https://eurojetva.eu :)

VA Pilot

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • EUROJET
Re: Editing VAM to allow multiple sub-VAs in one VAM-installation
« Reply #6 on: August 06, 2018, 09:59:18 PM »
Next step is to modify the Admin Panel GUI in order to change the values without having to visit the database :P
Go to vamcore/app/View and open the Fleets folder.
view.ctp contains the table you see on the panel. You can swap columns by changeing the rows in this file.
Code: [Select]
?php

    if ($_SESSION["access_fleet_manager"] ==1)
    {
?>
<div class="fleets view">

<div class="col-md-12">
    <div class="panel panel-primary">
        <div class="panel-heading">
              <h3 class="panel-title"><?php  echo __('Fleet'); ?></h3>
        </div>
        <div class="panel-body">
            <table class="table table-striped">
              <tr>
              <td><?php echo __('Fleet Type'); ?></td>
              <td><?php echo $this->Html->link($fleet['Fleettype']['plane_icao'], array('controller' => 'fleettypes''action' => 'view'$fleet['Fleettype']['fleettype_id'])); ?></td>
              </tr>
              <tr>
              <td><?php echo __('Registry'); ?></td>
              <td><?php echo h($fleet['Fleet']['registry']); ?></td>
              </tr>
<tr>
              <td><?php echo __('Operator'); ?></td>
              <td><?php echo h($fleet['Fleet']['operator']); ?></td>
              </tr>
              <tr>
              <td><?php echo __('Location'); ?></td>
              <td><?php echo h($fleet['Fleet']['location']); ?></td>
              </tr>
              <tr>
              <td><?php echo __('Hours'); ?></td>
              <td><?php echo h($fleet['Fleet']['hours']); ?></td>
              </tr>
              <tr>
              <td><?php echo __('Status'); ?></td>
              <td><?php echo h($fleet['Fleet']['status']).' %'?></td>
              </tr>
              <tr>
              <td><?php echo __('Booked'); ?></td>
              <?php $booked='No'; if ($fleet['Fleet']['booked']==1$booked='Yes'  ?>
              <td><?php echo $booked?></td>
              </tr>
              <tr>
              <td><?php echo __('Name'); ?></td>
              <td><?php echo h($fleet['Fleet']['name']); ?></td>
              </tr>
              <tr>
              <td><?php echo __('Hub'); ?></td>
              <td><?php echo $this->Html->link($fleet['Hub']['hub'], array('controller' => 'hubs''action' => 'view'$fleet['Hub']['hub_id'])); ?></td>
              </tr>
              <tr>
              <td><?php echo __('Hangar'); ?></td>
              <?php $hangar='No'; if ($fleet['Fleet']['hangar']==1$hangar='Yes'  ?>
              <td><?php echo $hangar?></td>
              </tr>
              <tr>
              <td><?php echo __('Hangardate'); ?></td>
              <td><?php echo h($fleet['Fleet']['hangardate']); ?></td>
              </tr>
           
              </table>
        </div>
    </div>
</div>

<div class="actions">
<h3><?php echo __('Actions'); ?></h3>
<ul class="list-inline">
<li><?php echo $this->Html->link(__('Edit Fleet'), array('action' => 'edit'$fleet['Fleet']['fleet_id']),array('class' => 'btn btn-md btn-primary')); ?> </li>
<li><?php echo $this->Html->link(__('List Fleets'), array('action' => 'index'),array('class' => 'btn btn-md btn-primary')); ?> </li>
<li><?php echo $this->Html->link(__('List Fleet Type'), array('controller' => 'fleettypes''action' => 'index'),array('class' => 'btn btn-md btn-primary')); ?> </li>
<li><?php echo $this->Html->link(__('New Fleet Type'), array('controller' => 'fleettypes''action' => 'add'),array('class' => 'btn btn-md btn-success')); ?> </li>
<li><?php echo $this->Html->link(__('New Fleet'), array('action' => 'add'),array('class' => 'btn btn-md btn-success')); ?> </li>
<li><?php echo $this->Form->postLink(__('Delete Fleet'), array('action' => 'delete'$fleet['Fleet']['fleet_id']), array('class' => 'btn btn-md btn-danger'), __('Are you sure you want to delete # %s?'$fleet['Fleet']['registry'])); ?> </li>
</ul>
</div>
<?php
    
}
    else
    {
        echo 
'<div class="alert alert-danger"> You do not have access to Fleet manager module</div>';
    }
?>

index.ctp:
Code: [Select]
<?php

    
if ($_SESSION["access_fleet_manager"] ==1)
    {
?>

<div class="fleets index">
<h2><?php echo __('Fleet'); ?></h2>
<table class="table table-striped">
<tr>

<th><?php echo $this->Paginator->sort('plane_icao'); ?></th>
<th><?php echo $this->Paginator->sort('registry'); ?></th>
<th><?php echo $this->Paginator->sort('operator'); ?></th>
<th><?php echo $this->Paginator->sort('location'); ?></th>
<th><?php echo $this->Paginator->sort('hours'); ?></th>
<th><?php echo $this->Paginator->sort('status'); ?></th>
<th><?php echo $this->Paginator->sort('booked'); ?></th>
<th><?php echo $this->Paginator->sort('name'); ?></th>
<th><?php echo $this->Paginator->sort('hub'); ?></th>
<th><?php echo $this->Paginator->sort('hangar'); ?></th>
<th class="actions"><?php echo __('Actions'); ?></th>
</tr>
<?php foreach ($fleets as $fleet): ?>
<tr>

<td>
<?php echo $this->Html->link($fleet['Fleettype']['plane_icao'], array('controller' => 'fleettypes''action' => 'view'$fleet['Fleettype']['fleettype_id'])); ?>
</td>
<td><?php echo h($fleet['Fleet']['registry']); ?>&nbsp;</td>
<td><?php echo h($fleet['Fleet']['operator']); ?>&nbsp;</td>
<td><?php echo h($fleet['Fleet']['location']); ?>&nbsp;</td>
<td><?php echo h($fleet['Fleet']['hours']); ?>&nbsp;</td>
<td><?php echo h($fleet['Fleet']['status']); ?>&nbsp;%</td>
<?php $booked='No'; if ($fleet['Fleet']['booked']==1$booked='Yes'  ?>
<td><?php echo $booked?></td>
<td><?php echo h($fleet['Fleet']['name']); ?>&nbsp;</td>
<td>
<?php echo $this->Html->link($fleet['Hub']['hub'], array('controller' => 'hubs''action' => 'view'$fleet['Hub']['hub_id'])); ?>
</td>



<?php $hangar='No'; if ($fleet['Fleet']['hangar']==1$hangar='Yes'  ?>
<td><?php echo $hangar?></td>

<td class="actions">

<?php echo $this->Html->link($this->Html->image('view.png', array('width' => '32''height' => '32')) . '' __(''),
                       array(
'action' => 'view'$fleet['Fleet']['fleet_id']),
                       array(
'escape' => false));?>

            <?php echo $this->Html->link($this->Html->image('edit.png', array('width' => '32''height' => '32')) . '' __(''),
                       array(
'action' => 'edit'$fleet['Fleet']['fleet_id']),
                       array(
'escape' => false));?>

<?php echo $this->Form->postLink(__('Delete'), array('action' => 'delete'$fleet['Fleet']['fleet_id']), array('class' => 'btn btn-md btn-danger'), __('Are you sure you want to delete # %s?'$fleet['Fleet']['registry'])); ?>
</td>
</tr>
<?php endforeach; ?>
</table>
<p>
<?php
echo 
$this->Paginator->counter(array(
'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}')
));
?>
</p>
<div class="paging">
<ul class="pagination">
<?php
  echo $this->Paginator->prev('&laquo;', array('tag' => 'li''escape' => false), '<a href="#">&laquo;</a>', array('class' => 'prev disabled''tag' => 'li''escape' => false));
  echo $this->Paginator->numbers(array('separator' => '''tag' => 'li''currentLink' => true'currentClass' => 'active''currentTag' => 'a'));
  echo $this->Paginator->next('&raquo;', array('tag' => 'li''escape' => false), '<a href="#">&raquo;</a>', array('class' => 'prev disabled''tag' => 'li''escape' => false));
?>

</ul>
</div>
</div>
<div class="actions">
<h3><?php echo __('Actions'); ?></h3>
<ul class="list-inline">
<li><?php echo $this->Html->link(__('List Fleet Type'), array('controller' => 'fleettypes''action' => 'index'),array('class' => 'btn btn-md btn-primary')); ?> </li>
<li><?php echo $this->Html->link(__('New Fleet'), array('action' => 'add'),array('class' => 'btn btn-md btn-success')); ?></li>
<li><?php echo $this->Html->link(__('New Fleet Type'), array('controller' => 'fleettypes''action' => 'add'),array('class' => 'btn btn-md btn-success')); ?> </li>
</ul>
</div>
<?php
    
}
    else
    {
        echo 
'<div class="alert alert-danger"> You do not have access to Fleet manager module</div>';
    }
?>

edit.ctp:
Code: [Select]
<?php

    
if ($_SESSION["access_fleet_manager"] ==1)
    {
?>

<div class="fleets form">
<?php echo $this->Form->create('Fleet'); ?>
<fieldset>
<legend><?php echo __('Edit Fleet'); ?></legend>
<?php

echo $this->Form->input('fleettype_id');
echo $this->Form->input('registry');
echo $this->Form->input('operator');
echo $this->Form->input('location');
echo $this->Form->input('hours');
echo $this->Form->input('status');
echo $this->Form->input('name');
echo $this->Form->input('hub_id');
$yes_no = array('1' => 'Yes''0' => 'No');
echo $this->Form->input(
    'hangar',
    array('options' => $yes_no'default' => '0'));
echo $this->Form->input(
    'booked',
    array('options' => $yes_no'default' => '0'));


?>

</fieldset>
<?php echo $this->Form->end(__('Submit')); ?>
</div>
<div class="actions">
<h3><?php echo __('Actions'); ?></h3>
<ul class="list-inline">
<li><?php echo $this->Html->link(__('List Fleets'), array('action' => 'index'),array('class' => 'btn btn-md btn-primary')); ?></li>
<li><?php echo $this->Html->link(__('List Fleet Type'), array('controller' => 'fleettypes''action' => 'index'),array('class' => 'btn btn-md btn-primary')); ?> </li>
<li><?php echo $this->Html->link(__('New Fleet'), array('controller' => 'fleets''action' => 'add'),array('class' => 'btn btn-md btn-success')); ?> </li>
<li><?php echo $this->Html->link(__('New Fleet Type'), array('controller' => 'fleettypes''action' => 'add'),array('class' => 'btn btn-md btn-success')); ?> </li>
<li><?php echo $this->Form->postLink(__('Delete'), array('action' => 'delete'$this->Form->value('Fleet.fleet_id')), array('class' => 'btn btn-md btn-danger'), __('Are you sure you want to delete # %s?'$this->Form->value('Fleet.registry'))); ?></li>
</ul>
</div>
<?php
    
}
    else
    {
        echo 
'<div class="alert alert-danger"> You do not have access to Fleet manager module</div>';
    }
?>

and add.ctp:
Code: [Select]
<?php

    
if ($_SESSION["access_fleet_manager"] ==1)
    {
?>

<div class="fleets form">
<?php echo $this->Form->create('Fleet'); ?>
<fieldset>
<legend><?php echo __('Add Fleet'); ?></legend>
<?php
//$form->input('category_id');
echo $this->Form->input('fleettype_id');
echo $this->Form->input('registry');
echo $this->Form->input('operator');
echo $this->Form->input('location');
echo $this->Form->input('hours');
echo $this->Form->input('status');
echo $this->Form->input('name');
echo $this->Form->input('hub_id');
?>

</fieldset>
<?php echo $this->Form->end(__('Submit')); ?>
</div>
<div class="actions">
<h3><?php echo __('Actions'); ?></h3>
<ul class="list-inline">

<li><?php echo $this->Html->link(__('List Fleets'), array('action' => 'index'),array('class' => 'btn btn-md btn-primary')); ?></li>
<li><?php echo $this->Html->link(__('List Fleet Type'), array('controller' => 'fleettypes''action' => 'index'),array('class' => 'btn btn-md btn-primary')); ?> </li>
<li><?php echo $this->Html->link(__('New Fleet Type'), array('controller' => 'fleettypes''action' => 'add'),array('class' => 'btn btn-md btn-success')); ?> </li>
</ul>
</div>
<?php
    
}
    else
    {
        echo 
'<div class="alert alert-danger"> You do not have access to Fleet manager module</div>';
    }
?>

« Last Edit: August 06, 2018, 10:03:41 PM by VA Pilot »
CEO and admin of https://eurojetva.eu :)

VA Pilot

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • EUROJET
Re: Editing VAM to allow multiple sub-VAs in one VAM-installation
« Reply #7 on: August 06, 2018, 10:08:59 PM »
similar changes, same directory, Routes folder:
view.ctp:
Code: [Select]
<?php

    
if ($_SESSION["access_route_manager"] ==1)
    {
?>

<div class="routes view">
<div class="col-md-12">
    <div class="panel panel-primary">
        <div class="panel-heading">
              <h3 class="panel-title"><?php  echo __('Route'); ?></h3>
        </div>
        <div class="panel-body">
            <table class="table table-striped">
<tr>
              <td><?php echo __('Operator'); ?></td>
              <td><?php echo h($route['Route']['operator']); ?></td>
              </tr>
              <tr>
              <td><?php echo __('Flight'); ?></td>
              <td><?php echo h($route['Route']['flight']); ?></td>
              </tr>
              <tr>
              <td><?php echo __('Departure'); ?></td>
              <td><?php echo h($route['Route']['departure']); ?></td>
              </tr>
              <tr>
              <td><?php echo __('Arrival'); ?></td>
              <td><?php echo h($route['Route']['arrival']); ?></td>
              </tr>
              <tr>
              <td><?php echo __('Alternative'); ?></td>
              <td><?php echo h($route['Route']['alternative']); ?></td>
              </tr>
              <tr>
              <td><?php echo __('ETD'); ?></td>
              <td><?php echo h($route['Route']['etd']); ?></td>
              </tr>
              <tr>
              <td><?php echo __('ETA'); ?></td>
              <td><?php echo h($route['Route']['eta']); ?></td>
              </tr>
              <tr>
              <td><?php echo __('PAX Price'); ?></td>
              <td><?php echo h($route['Route']['pax_price']); ?></td>
              </tr>
              <tr>
              <td><?php echo __('Cargo Price'); ?></td>
              <td><?php echo h($route['Route']['cargo_price']); ?></td>
              </tr>
              <tr>
              <td><?php echo __('Route'); ?></td>
              <td><?php echo h($route['Route']['flproute']); ?></td>
              </tr>
              <tr>
              <td><?php echo __('Flight Level'); ?></td>
              <td><?php echo h($route['Route']['flight_level']); ?></td>
              </tr>
              <tr>
              <td><?php echo __('Comments'); ?></td>
              <td><?php echo h($route['Route']['comments']); ?></td>
              </tr>
            <tr>
                <td><?php echo __('Duration'); ?></td>
                <td><?php echo h($route['Route']['duration']); ?></td>
                </tr>
              <tr>
              <td><?php echo __('Hub'); ?></td>
              <td><?php echo $this->Html->link($route['Hub']['hub'], array('controller' => 'hubs''action' => 'view'$route['Hub']['hub_id'])); ?></td>
              </tr>
<tr>
              <td><?php echo __('Required Rank'); ?></td>
              <td><?php echo h($route['Route']['rank']); ?></td>
              </tr>
              </table>
        </div>
    </div>
</div>

<div class="actions">
<h3><?php echo __('Actions'); ?></h3>
<ul class="list-inline">
<li><?php echo $this->Html->link(__('Edit Route'), array('action' => 'edit'$route['Route']['route_id']),array('class' => 'btn btn-md btn-primary')); ?> </li>
<li><?php echo $this->Html->link(__('List Routes'), array('action' => 'index'),array('class' => 'btn btn-md btn-primary')); ?> </li>
<li><?php echo $this->Html->link(__('List Fleet Type'), array('controller' => 'fleettypes''action' => 'index'),array('class' => 'btn btn-md btn-primary')); ?> </li>
<li><?php echo $this->Html->link(__('New Route'), array('action' => 'add'),array('class' => 'btn btn-md btn-success')); ?> </li>
<li><?php echo $this->Html->link(__('New Fleet Type'), array('controller' => 'fleettypes''action' => 'add'),array('class' => 'btn btn-md btn-success')); ?> </li>
<li><?php echo $this->Form->postLink(__('Delete Route'), array('action' => 'delete'$route['Route']['route_id']),array('class' => 'btn btn-md btn-danger'), __('Are you sure you want to delete # %s?'$route['Route']['flight'])); ?> </li>
</ul>
</div>
<div class="related">
<h3><?php echo __('Related Fleet Types'); ?></h3>
<?php if (!empty($route['Fleettype'])): ?>
<table class="table table-striped">
<tr>
<th><?php echo __('Plane Icao'); ?></th>
<th><?php echo __('Plane Description'); ?></th>
<th class="actions"><?php echo __('Actions'); ?></th>
</tr>
<?php
$i 0;
foreach ($route['Fleettype'] as $fleettype): ?>

<tr>
<td><?php echo $fleettype['plane_icao']; ?></td>
<td><?php echo $fleettype['plane_description']; ?></td>
<td class="actions">
<?php echo $this->Html->image("view.png", array(
    'url' => array('controller' => 'fleettypes''action' => 'view'$fleettype['fleettype_id'])));?>

<?php echo $this->Html->image("edit.png", array(
    'url' => array('controller' => 'fleettypes''action' => 'edit'$fleettype['fleettype_id'])));?>

<?php echo $this->Form->postLink(__('Delete'), array('controller' => 'fleettypes''action' => 'delete'$fleettype['fleettype_id']), array('class' => 'btn btn-md btn-danger'), __('Are you sure you want to delete # %s?'$fleettype['fleettype_id'])); ?>
</td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>

<div class="actions">
<ul class="list-inline">
<li><?php echo $this->Html->link(__('New Fleet Type'), array('controller' => 'fleettypes''action' => 'add'),array('class' => 'btn btn-md btn-success')); ?> </li>
</ul>
</div>
</div>
<?php
    
}
    else
    {
        echo 
'<div class="alert alert-danger"> You do not have access to Route manager module</div>';
    }
?>

index.ctp:
Code: [Select]
<?php

    
if ($_SESSION["access_route_manager"] ==1)
    {
?>

<div class="routes index">
<h2><?php echo __('Routes'); ?></h2>
<table class="table table-striped">
<tr>
<th><?php echo $this->Paginator->sort('operator'); ?></th>
<th><?php echo $this->Paginator->sort('flight'); ?></th>
<th><?php echo $this->Paginator->sort('departure'); ?></th>
<th><?php echo $this->Paginator->sort('arrival'); ?></th>
<th><?php echo $this->Paginator->sort('alternative'); ?></th>
<th><?php echo $this->Paginator->sort('etd'); ?></th>
<th><?php echo $this->Paginator->sort('eta'); ?></th>
<th><?php echo $this->Paginator->sort('pax_price'); ?></th>
<th><?php echo $this->Paginator->sort('cargo_price'); ?></th>
<th><?php echo $this->Paginator->sort('duration'); ?></th>
<th><?php echo $this->Paginator->sort('hub_id'); ?></th>
<th><?php echo $this->Paginator->sort('rank'); ?></th>
<th class="actions"><?php echo __('Actions'); ?></th>
</tr>
<?php foreach ($routes as $route): ?>
<tr>
<td><?php echo h($route['Route']['operator']); ?>&nbsp;</td>
<td><?php echo h($route['Route']['flight']); ?>&nbsp;</td>
<td><?php echo h($route['Route']['departure']); ?>&nbsp;</td>
<td><?php echo h($route['Route']['arrival']); ?>&nbsp;</td>
<td><?php echo h($route['Route']['alternative']); ?>&nbsp;</td>
<td><?php echo h($route['Route']['etd']); ?>&nbsp;</td>
<td><?php echo h($route['Route']['eta']); ?>&nbsp;</td>
<td><?php echo h($route['Route']['pax_price']); ?>&nbsp;</td>
<td><?php echo h($route['Route']['cargo_price']); ?>&nbsp;</td>
<td><?php echo h($route['Route']['duration']); ?>&nbsp;</td>
<td>
        <?php echo $this->Html->link($route['Hub']['hub'], array('controller' => 'hubs''action' => 'view'$route['Hub']['hub_id'])); ?>
        </td>
<td><?php echo h($route['Route']['rank']); ?>&nbsp;</td>
<td class="actions">
<?php echo $this->Html->image("view.png", array(
    'url' => array('controller' => 'routes''action' => 'view'$route['Route']['route_id'])));?>

<?php echo $this->Html->image("edit.png", array(
    'url' => array('controller' => 'routes''action' => 'edit'$route['Route']['route_id'])));?>

<?php echo $this->Form->postLink(__('Delete'), array('action' => 'delete'$route['Route']['route_id']), array('class' => 'btn btn-md btn-danger'), __('Are you sure you want to delete # %s?'$route['Route']['flight'])); ?>
</td>
</tr>
<?php endforeach; ?>
</table>
<p>
<?php
echo 
$this->Paginator->counter(array(
'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}')
));
?>
</p>
<div class="paging">
<ul class="pagination">
<?php
  echo $this->Paginator->prev('&laquo;', array('tag' => 'li''escape' => false), '<a href="#">&laquo;</a>', array('class' => 'prev disabled''tag' => 'li''escape' => false));
  echo $this->Paginator->numbers(array('separator' => '''tag' => 'li''currentLink' => true'currentClass' => 'active''currentTag' => 'a'));
  echo $this->Paginator->next('&raquo;', array('tag' => 'li''escape' => false), '<a href="#">&raquo;</a>', array('class' => 'prev disabled''tag' => 'li''escape' => false));
?>

</ul>
</div>
</div>
<div class="actions">
<h3><?php echo __('Actions'); ?></h3>
<ul class="list-inline">
<li><?php echo $this->Html->link(__('List Fleet Route'), array('controller' => 'fleettypesRoutes''action' => 'index'),array('class' => 'btn btn-md btn-primary')); ?> </li>
<li><?php echo $this->Html->link(__('List Fleet Type'), array('controller' => 'fleettypes''action' => 'index'),array('class' => 'btn btn-md btn-primary')); ?> </li>
<li><?php echo $this->Html->link(__('New Route'), array('action' => 'add'),array('class' => 'btn btn-md btn-success')); ?></li>
<li><?php echo $this->Html->link(__('New Fleet Type'), array('controller' => 'fleettypes''action' => 'add'),array('class' => 'btn btn-md btn-success')); ?> </li>

</ul>
</div>
<?php
    
}
    else
    {
        echo 
'<div class="alert alert-danger"> You do not have access to Route manager module</div>';
    }
?>

add.ctp:
Code: [Select]
<?php

    
if ($_SESSION["access_route_manager"] ==1)
    {
?>

<div class="routes form">
<?php echo $this->Form->create('Route'); ?>
<fieldset>
<legend><?php echo __('Add Route'); ?></legend>
<?php
echo $this->Form->input('operator');
echo $this->Form->input('rank');
echo $this->Form->input('flight');
echo $this->Form->input('departure');
echo $this->Form->input('arrival');
echo $this->Form->input('alternative');
echo $this->Form->input('etd',['label' => 'ETD']);
echo $this->Form->input('eta',['label' => 'ETA']);
echo $this->Form->input('pax_price');
echo $this->Form->input('cargo_price');
echo $this->Form->input('flproute',['label' => 'FP Route']);
echo $this->Form->input('flight_level');
echo $this->Form->input('comments');
echo $this->Form->input('duration');
echo $this->Form->input('hub_id');
echo $this->Form->input('Fleettype',['label' => 'Aircraft type assignation']);
?>

</fieldset>
<?php echo $this->Form->end(__('Submit')); ?>
</div>
<div class="actions">
<h3><?php echo __('Actions'); ?></h3>
<ul class="list-inline">

<li><?php echo $this->Html->link(__('List Routes'), array('action' => 'index'),array('class' => 'btn btn-md btn-primary')); ?></li>
<li><?php echo $this->Html->link(__('List Fleet Type'), array('controller' => 'fleettypes''action' => 'index'),array('class' => 'btn btn-md btn-primary')); ?> </li>
<li><?php echo $this->Html->link(__('New Fleet Type'), array('controller' => 'fleettypes''action' => 'add'),array('class' => 'btn btn-md btn-success')); ?> </li>
</ul>
</div>
<?php
    
}
    else
    {
        echo 
'<div class="alert alert-danger"> You do not have access to Route manager module</div>';
    }
?>
and edit.ctp:
Code: [Select]
<?php

    
if ($_SESSION["access_route_manager"] ==1)
    {
?>

<div class="routes form">
<?php echo $this->Form->create('Route'); ?>
<fieldset>
<legend><?php echo __('Edit Route'); ?></legend>
<?php
echo $this->Form->input('route_id');
echo $this->Form->input('operator');
echo $this->Form->input('rank');
echo $this->Form->input('flight');
echo $this->Form->input('departure');
echo $this->Form->input('arrival');
echo $this->Form->input('alternative');
echo $this->Form->input('etd',['label' => 'ETD']);
echo $this->Form->input('eta',['label' => 'ETA']);
echo $this->Form->input('pax_price');
echo $this->Form->input('cargo_price');
echo $this->Form->input('flproute',['label' => 'FP Route']);
echo $this->Form->input('flight_level');
echo $this->Form->input('comments');
echo $this->Form->input('duration');
echo $this->Form->input('hub_id');
echo $this->Form->input('Fleettype',['label' => 'Aircraft type assignation']);
?>

</fieldset>
<?php echo $this->Form->end(__('Submit')); ?>
</div>
<div class="actions">
<h3><?php echo __('Actions'); ?></h3>
<ul class="list-inline">

<li><?php echo $this->Html->link(__('List Routes'), array('action' => 'index'),array('class' => 'btn btn-md btn-primary')); ?></li>
<li><?php echo $this->Html->link(__('List Fleet Type'), array('controller' => 'fleettypes''action' => 'index'),array('class' => 'btn btn-md btn-primary')); ?> </li>
<li><?php echo $this->Html->link(__('New Fleet Type'), array('controller' => 'fleettypes''action' => 'add'),array('class' => 'btn btn-md btn-success')); ?> </li>
<li><?php echo $this->Form->postLink(__('Delete'), array('action' => 'delete'$this->Form->value('Route.route_id')),array('class' => 'btn btn-md btn-danger'), __('Are you sure you want to delete # %s?'$this->Form->value('Route.flight'))); ?></li>
</ul>
</div>
<?php
    
}
    else
    {
        echo 
'<div class="alert alert-danger"> You do not have access to Route manager module</div>';
    }
?>


With the changes made so far, you should be able to select an operator and rank via a drop-down menu and the values/strings should be displayed in the tables.
CEO and admin of https://eurojetva.eu :)

dohavik

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: Editing VAM to allow multiple sub-VAs in one VAM-installation
« Reply #8 on: August 29, 2018, 03:27:30 PM »
It looks very promising :) I am going to try it out in a test airline.

VA Pilot

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • EUROJET
Re: Editing VAM to allow multiple sub-VAs in one VAM-installation
« Reply #9 on: September 12, 2018, 12:40:27 PM »
Sorry for not posting in a while. I recently moved and will start cleaning up this topic very soon ;)
CEO and admin of https://eurojetva.eu :)

GRUPOGOLv

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Editing VAM to allow multiple sub-VAs in one VAM-installation
« Reply #10 on: January 26, 2019, 07:37:50 PM »
Tentei fazer, mas não deu certo!

sjohnny777

  • Jr. Member
  • **
  • Posts: 90
  • Choose life!
    • View Profile
    • Virtual LH
Re: Editing VAM to allow multiple sub-VAs in one VAM-installation
« Reply #11 on: January 29, 2019, 02:19:40 PM »
Hello guys,

You know I run Lufthansa's group (https://virtuallh.com/vam/index.php?lang=en), and we operate 6 different airlines, all I did was to add everyroutes and then, created a way to show up each airline on the tables. That's how I did the latest flights table and also the route selection stage 1 shows which company are operating the route.

Regards
Johnny
Pax president at https://virtuallh.com