Jump to content

Recommended Posts

Posted (edited)
14 hours ago, camilovelandia04 said:

Hi there,

Greetings! , I would like to know how to create a rule in our system in order to auto approve a pireps when the score is equal or grater than 75%, and if not just be in standby like if not auto approve.... 

appreciate your help! thanks 

 

What about setting it to auto accept (acars pireps) at rank settings and then rejecting only reports with a score lower than 75 ? It will be much practical and easier.

 

Yesterday I shared an example and simple pirep evaluation listener (which can be improved and integrated to your own module for v7 easily), you can check it at phpVMS Discord. Or you can check below for a much simple example for your needs.

 

<?php

namespace Modules\YOUR_MODULE_FOLDER_HERE\Listeners;

use App\Events\PirepFiled;
use App\Models\Enums\PirepSource;
use App\Models\Enums\PirepState;

class Pirep_AutoReject
{
    public function handle(PirepFiled $event)
    {
        $pirep = $event->pirep;

        if ($pirep->fuel_used->internal() < 5) {
            // Fuel Burn is less than 5 Pounds -> REJECT
            $pirep_state = PirepState::REJECTED;
        }

        if ($pirep->flight_time < 10) {
            // Flight Time is less than 10 Minutes -> REJECT
            $pirep_state = PirepState::REJECTED;
        }

        if ($pirep->source == PirepSource::ACARS && $pirep->score < 75) {
            // Score is less than 75 -> REJECT
            $pirep_state = PirepState::REJECTED;
        }
      
        // Check if this pireps need to be REJECTED, write the state back to model and save
        // Do not try to ACCEPT the pirep here as it should be handled by v7 itself, 
        // Just set it to auto accept at rank settings and only REJECT here if you need to ;) 
        // Save your time
        if (isset($pirep_state)) {
            $pirep->state = $pirep_state;
            $pirep->save();
        }
    }
}

 

Good luck

 

Important Note: For this to work, you need to have a custom module and it needs to be listening phpVMS v7 events. Some phpvms v7 development + laravel + php knowledge is needed, this is not something to copy and paste.

 

Edited by DisposableHero
  • Like 1

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