phpvms icon indicating copy to clipboard operation
phpvms copied to clipboard

Manually Give a Pilot an Award

Open Da-Geek opened this issue 3 years ago • 4 comments

Describe the solution you'd like I would like to create some Awards, that I can give a pilot for completing pre-defined challenges.

Additional context I have a bunch "Tours" that are 3 or 5 Legs long, During a pre-defined date/time I want my pilots to be able to fly 1 or more of the legs, and for each leg they get an Award, if they complete all Legs of a Tour, they get a special Award.

Da-Geek avatar Oct 10 '20 16:10 Da-Geek

I think this might need to be another "Award Class", the Award Documentation URL is showing a 404 right now. Maybe using a Parameter for a new Award Class, I could enter the Pilot ID/Name to assign the award?

I would also be really interested in adding an $/£ Payment to the award, so when it is given to a pilot, it would add some $/£ to the Pilots wallet (maybe even add a cost to the Airline for the award, like a Pilot Payment)

Da-Geek avatar Oct 10 '20 16:10 Da-Geek

While looking at the code I ended up finding this following snippet from the '\app\Services\Finance\PirepFinanceService.php'

$this->financeSvc->debitFromJournal( $pirep->airline->journal, $pilot_pay, $pirep, $memo, 'Pilot Pay', 'pilot_pay' );

$this->financeSvc->creditToJournal( $pirep->user->journal, $pilot_pay, $pirep, $memo, 'Pilot Pay', 'pilot_pay' );

I think I can use something like this in an AwardClass to "Pay" a pilot some Money when an Award is given. I am not sure if I want to "Debit" the money from the Airline, or just "Magic" the money into existence, of course it would make more sense to Debit the amount from the Airline, but the Airline would need the funds to cover the cost of the Award.

I also need to work out if there is a method of adding multiple parameters to an AwardClass, so you could set a value to an Award, and if it is set, call the shared function to Debit/Credit the given amount to the Pilot. The quick/dirty way would be to do something similar to the way I accepted 2 values in the 'FlightRouteAwards.php' AwardClass, using the PHP Function explode() and just asking the user to enter a value like 'parm1:awardvalue' the parm1 will be used as the award parameter and then if the parm awardvalue != null, use it as a Pilot Payment.

Da-Geek avatar Oct 13 '20 21:10 Da-Geek

@nabeelio I just had a thought about this idea...

In the resources\views\admin\users\awards.blade.php file (Around line 16), That shows the awards, could we add a new

.... that then has a Dropdown List of the Awards (maybe from a special AwardClass=ManualAward) that when selected, would add the award to the user Directly?

I could create an Award Class that always returns false, so would never be issued by the PIREP route/function, and this new Dropdown would just add the Award to the DB as if it had been issued after the check() function??

What do you think?

Da-Geek avatar Oct 14 '20 20:10 Da-Geek

There's no need to hack it that way. It'll be the same template you're looking at, with just the list of available awards to add. Just a simple form POST from there. It won't need to run check()

nabeelio avatar Oct 14 '20 20:10 nabeelio