Jump to content

Pilot bonus[solved]


Virtualei

Recommended Posts

Hi ,

I have searched the forum but cant seem to find anything on this. I would like to be able to give abonus payment to pilots for their landing rate and if they complete a long haul flight online. Has anyone any idea how I would do this. Would a module have to be created or could I change a bit of coding somewhere.

Thanks in advance

Link to comment
Share on other sites

Hi Parko,

Thanks for the reply. I would like to pay a bonus if a pilots landing rate is below -50fpm . I would also like to give a bonus if a pilot completes a flight over 8 hours. Then maybe add a bonus earned section in the pilot profile section where it can be viewed.

Cheers mate :)

Link to comment
Share on other sites

  • Moderators

Sounds like a plan. First add a column to your phpvms_pilots in your DB as "bonus" the type must be "float" and set default to "0" then add this to your profile_main.tpl. It's not tested, so give it a try and let me know:

<?php
$pilot = PilotData::getPilotData(Auth::$userinfo->pilotdid);
$pirep = PIREPData::getLastReports($pilot,1);
$pilotbonus = "500";
if($pirep->landingrate < 50)
{
 $bonus = $pilotbonus + $pilot->totalpay ;
 $fields = array (
	 'bonus'	 => $bonus,
	 );
 PilotData::updateProfile($pilot, $fields);
}
?>
<li><strong>Total Bonus: </strong><?php echo FinanceData::FormatMoney($userinfo->bonus) ?></li>

Use the same code for the total hours like this:

if($pirep->flighttime > 8)
{
$bonus = $pilotbonus +$pilot->totalpay;
$fields = array(
					  'bonus'  =>$bonus,
				    )
PilotData::updateProfile($pilot, $fields);
}

Link to comment
Share on other sites

  • Moderators

Ok I got it working. First off forget the last post, so add a column into your phpvms_pilots in your DB as "bonus" the type must be "float" and set default az "0". Then open the following:

Admin/modules/PIREPadmin/PIREPAdmin.php go down to line 298 and find the function called : approve_pirep_post(). Now go to the end of it and add the following:

After this:

# Call the event
CodonEvent::Dispatch('pirep_accepted', 'PIREPAdmin', $pirep_details);

Add this:

# Give Bonus to good pilots
$pilotbonus = "500";
$userinfo = PilotData::getPilotData($pirep_details->pilotid);
if($pirep_details->landingrate < 50 OR $pirep_details->flighttime > 8)
{
 $totalpay = $pilotbonus + $userinfo->totalpay ;
 $bonus = $pilotbonus +$userinfo->bonus;
 $fields = array (
	 'totalpay' => $totalpay,
	 'bonus' => $bonus,
	 );
 PilotData::updateProfile($userinfo->pilotid, $fields);
}

then go to your profile_main.tpl and after this:

<li><strong>Total Money: </strong><?php echo FinanceData::FormatMoney($userinfo->totalpay) ?></li>

Add this:

<li><strong>Total Bonus: </strong><?php echo FinanceData::FormatMoney($userinfo->bonus) ?></li>

Then you should be home safe ;).

Cheers

  • Like 3
Link to comment
Share on other sites

  • Moderators

No worries man. I'm glad I could help. Also, how's the tour system working out for you? I'm actually working on a tour system pretty much from scratch, so just wanted to get some opinions. I really would appreciate it if you liked my last post.

Thanks

Link to comment
Share on other sites

  • 2 weeks later...

hi its not solved

i become a syntax error

Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in /www/htdocs/w00dac26/lausitzair/admin/modules/PIREPAdmin/PIREPAdmin.php on line 295

and on the line 295 is

$pilotbonus = "500";

i become this failure when i click on my admincenter

Link to comment
Share on other sites

  • Moderators

hi its not solved

i become a syntax error

Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in /www/htdocs/w00dac26/lausitzair/admin/modules/PIREPAdmin/PIREPAdmin.php on line 295

and on the line 295 is

$pilotbonus = "500";

i become this failure when i click on my admincenter

Look to see if you inserted the code correctly. Your error is mostly from missing a closing argument like "?>" or <?php .;)

Link to comment
Share on other sites

  • 4 years later...

i got this error if i click admincenter:

Parse error: syntax error, unexpected T_PROTECTED in /home/990/217990/public_html/admin/modules/PIREPAdmin/PIREPAdmin.php on line 328

in lin 328: protected function delete_pirep_post() {

 

i hope i correct my PIREPAdmin.php right

see here:

.......


    /**
     * Approve the PIREP, and then update
     * the pilot's data
     */
    protected function approve_pirep_post() {

        $pirepid = $this->post->id;

        if ($pirepid == '')
            return;

        $pirep_details = PIREPData::getReportDetails($pirepid);

        $this->set('pirep', $pirep_details);

        # See if it's already been accepted
        if (intval($pirep_details->accepted) == PIREP_ACCEPTED)
            return;

        # Update pilot stats

        PIREPData::ChangePIREPStatus($pirepid, PIREP_ACCEPTED); // 1 is accepted
        LogData::addLog(Auth::$userinfo->pilotid, 'Approved PIREP #' . $pirepid);

        # Call the event
        CodonEvent::Dispatch('pirep_accepted', 'PIREPAdmin', $pirep_details);

        # Give Bonus to good pilots
        $pilotbonus = "10";
        $userinfo = PilotData::getPilotData($pirep_details->pilotid);
        if($pirep_details->landingrate > -500 OR $pirep_details->flighttime > 3)

{
 $totalpay = $pilotbonus + $userinfo->totalpay ;
 $bonus = $pilotbonus +$userinfo->bonus;
 $fields = array (
         'totalpay' => $totalpay,
         'bonus' => $bonus,
         );
 PilotData::updateProfile($userinfo->pilotid, $fields);

    }

    /**
     * Delete a PIREP
     */

    protected function delete_pirep_post() {
        $pirepid = $this->post->id;
        if ($pirepid == '')
            return;

        # Call the event
        CodonEvent::Dispatch('pirep_deleted', 'PIREPAdmin', $pirepid);

        PIREPData::deleteFlightReport($pirepid);
        StatsData::UpdateTotalHours();
    }


......

 

Link to comment
Share on other sites

  • 3 years later...

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