Jump to content

Email Pilot on submitting a pirep


mark1million

Recommended Posts

  • Moderators

I have had a search about and cant find what im looking for.

I want to extend the code a bit in the PIREPData.Class.php to also send a summary to the pilot upon sending in a pirep.

This is the send to admin email notification of a new pirep

           # Send an email to the admin that a PIREP was submitted
           $sub = "A PIREP has been submitted by {$pilotcode} ({$pirepdata['depicao']} - {$pirepdata['arricao']})";
           $message = "A PIREP has been submitted by {$pilotcode} "
               ."({$pilotinfo->firstname} {$pilotinfo->lastname})\n\n"
               ."{$pirepdata['code']}{$pirepdata['flightnum']}: {$pirepdata['depicao']} to {$pirepdata['arricao']}\n"
               ."Aircraft: {$pirepdata['aircraft']}\n" . "Flight Time: {$pirepdata['flighttime']}\n"
               ."Landing Rate: {$pirepdata['landingrate']}\n"."Filed using: {$pirepdata['source']}\n\n" 
               ."Comment: {$comment}\n\n"
               ."Click to approve this pirep (admin must be signed in):\n"
               .adminurl('/pirepadmin/approvepirep/'.$pirepid);

           $email = Config::Get('EMAIL_NEW_PIREP');
           if (empty($email)) {
               $email = ADMIN_EMAIL;
           }

           Util::SendEmail($email, $sub, $message);
       }

Clearly i would not want to send that approve link to the pilot so i can remove that no problem, would it just be a simple case of adding $pilotinfo->email to that Util?

Link to comment
Share on other sites

  • Moderators

           # Send an email to the pilot who submitted that PIREP
           $sub = "Your flight report - {$pirepdata['depicao']} - {$pirepdata['arricao']}";
           $message = "You have filed a PIREP ({$pirepdata['code']}{$pirepdata['flightnum']})"
               ."({$pilotinfo->firstname} {$pilotinfo->lastname})\n\n"
               ."{$pirepdata['code']}{$pirepdata['flightnum']}: {$pirepdata['depicao']} to {$pirepdata['arricao']}\n"
               ."Aircraft: {$pirepdata['aircraft']}\n" . "Flight Time: {$pirepdata['flighttime']}\n"
               ."Landing Rate: {$pirepdata['landingrate']}\n"."Filed using: {$pirepdata['source']}\n\n" 
               ."Comment: {$comment}\n\n";

               $email = $pilotinfo->email;

           Util::SendEmail($email, $sub, $message);
       }

Mark, this would be the code [NOT TESTED], give this a try and see what happens. Add after the line of code that you posted. first post.

Link to comment
Share on other sites

  • Moderators

           # Send an email to the pilot who submitted that PIREP
           $sub = "Your flight report - {$pirepdata['depicao']} - {$pirepdata['arricao']}";
           $message = "You have filed a PIREP ({$pirepdata['code']}{$pirepdata['flightnum']})"
               ."({$pilotinfo->firstname} {$pilotinfo->lastname})\n\n"
               ."{$pirepdata['code']}{$pirepdata['flightnum']}: {$pirepdata['depicao']} to {$pirepdata['arricao']}\n"
               ."Aircraft: {$pirepdata['aircraft']}\n" . "Flight Time: {$pirepdata['flighttime']}\n"
               ."Landing Rate: {$pirepdata['landingrate']}\n"."Filed using: {$pirepdata['source']}\n\n" 
               ."Comment: {$comment}\n\n";

               $email = $pilotinfo->email;

           Util::SendEmail($email, $sub, $message);
       }

Mark, this would be the code [NOT TESTED], give this a try and see what happens. Add after the line of code that you posted. first post.

Thanks Kyle. Just what I was looking for, I'm gonna test it now.

Link to comment
Share on other sites

  • Moderators

Okay, replace the code that you are using from me with this..

(NOT TESTED)

		//PILOT INFO
		$pilotfirstname = $pilotinfo->firstname;
		$pilotlastname= $pilotinfo->lastname;
		$email = $pilotinfo->email;
		//PIREP INFO (This all goes into the email, we will need to add those into the TPL)
		$code = $pirepdata['code'];
		$flightnum = $pirepdata['flightnum'];
		$depicao = $pirepdata['depicao'];
		$arricao = $pirepdata['arricao'];
		$aircraft = $pirepdata['aircraft'];
		$flighttime = $pirepdata['flighttime'];
		$landingrate = $pirepdata['landingrate'];
		$source = $pirepdata['source'];
		$comment = $comment;

		$sub = 'PIREP Report - '.$code.''.$flightnum;
		$message = Template::Get('email_pirep_info.tpl', true);
		Util::SendEmail($email, $sub, $message);

AND Create a tpl file called email_pirep_info.tpl and place in your core/templates. The forums won't let me upload tpl files.

And copy this code and paste into email_pirep_info.tpl...

<p>Dear <?php echo $pilotfirstname .' '. $pilotlastname; ?>,

 </p>
<p>Here is your submitted flight report enclosed for your review.</p>
<p><b>Flight Number:</b><?php echo $code.''.$flightnum;?> </p>
<p><b>Departure:</b><?php echo $depicao;?> </p>
<p><b>Arrival:</b><?php echo $arricao;?> </p>
<p><b>Aircraft:</b><?php echo $aircraft;?> </p>
<p><b>Flight Time:</b><?php echo $flighttime;?> </p>
<p><b>Landing Rate:</b><?php echo $landingrate;?> </p>
<p><b>Filed By:</b><?php echo $source;?> </p>
<p><b>Comments:</b><?php echo $comment;?> </p>

And that should work for you. Please test it cause there's no one flying yet and to test it at my VA, lol.

I know the code is not so great, but that's a start, lol.

Cheers!

Link to comment
Share on other sites

  • Moderators

Okay, replace the code that you are using from me with this..

(NOT TESTED)

		//PILOT INFO
		$pilotfirstname = $pilotinfo->firstname;
		$pilotlastname= $pilotinfo->lastname;
		$email = $pilotinfo->email;
		//PIREP INFO (This all goes into the email, we will need to add those into the TPL)
		$code = $pirepdata['code'];
		$flightnum = $pirepdata['flightnum'];
		$depicao = $pirepdata['depicao'];
		$arricao = $pirepdata['arricao'];
		$aircraft = $pirepdata['aircraft'];
		$flighttime = $pirepdata['flighttime'];
		$landingrate = $pirepdata['landingrate'];
		$source = $pirepdata['source'];
		$comment = $comment;

		$sub = 'PIREP Report - '.$code.''.$flightnum;
		$message = Template::Get('email_pirep_info.tpl', true);
		Util::SendEmail($email, $sub, $message);

AND Create a tpl file called email_pirep_info.tpl and place in your core/templates. The forums won't let me upload tpl files.

And copy this code and paste into email_pirep_info.tpl...

<p>Dear <?php echo $pilotfirstname .' '. $pilotlastname; ?>,

 </p>
<p>Here is your submitted flight report enclosed for your review.</p>
<p><b>Flight Number:</b><?php echo $code.''.$flightnum;?> </p>
<p><b>Departure:</b><?php echo $depicao;?> </p>
<p><b>Arrival:</b><?php echo $arricao;?> </p>
<p><b>Aircraft:</b><?php echo $aircraft;?> </p>
<p><b>Flight Time:</b><?php echo $flighttime;?> </p>
<p><b>Landing Rate:</b><?php echo $landingrate;?> </p>
<p><b>Filed By:</b><?php echo $source;?> </p>
<p><b>Comments:</b><?php echo $comment;?> </p>

And that should work for you. Please test it cause there's no one flying yet and to test it at my VA, lol.

I know the code is not so great, but that's a start, lol.

Cheers!

Thanks a lot man. You've done too much I'll give it shot.wink.gif

Link to comment
Share on other sites

  • Moderators

Sorry, I made a silly mistake.

Try this and put in the php file.

		//PILOT INFO
		$pilotfirstname = $pilotinfo->firstname;
		$pilotlastname= $pilotinfo->lastname;
		$email = $pilotinfo->email;
		//PIREP INFO (This all goes into the email, we will need to add those into the TPL)
		$code = $pirepdata->code;
		$flightnum = $pirepdata->flightnum;
		$depicao = $pirepdata->depicao;
		$arricao = $pirepdata->arricao;
		$aircraft = $pirepdata->aircraft;
		$flighttime = $pirepdata->flighttime;
		$landingrate = $pirepdata->landingrate;
		$source = $pirepdata->source;
		$comment = $comment;

		$email = $pilotinfo->email;
		$sub = 'PIREP Report - '.$code.''.$flightnum;
		$message = Template::Get('email_pirep_info.tpl', true);
		Util::SendEmail($email, $sub, $message);

Link to comment
Share on other sites

  • Moderators

Sorry, I made a silly mistake.

Try this and put in the php file.

		//PILOT INFO
		$pilotfirstname = $pilotinfo->firstname;
		$pilotlastname= $pilotinfo->lastname;
		$email = $pilotinfo->email;
		//PIREP INFO (This all goes into the email, we will need to add those into the TPL)
		$code = $pirepdata->code;
		$flightnum = $pirepdata->flightnum;
		$depicao = $pirepdata->depicao;
		$arricao = $pirepdata->arricao;
		$aircraft = $pirepdata->aircraft;
		$flighttime = $pirepdata->flighttime;
		$landingrate = $pirepdata->landingrate;
		$source = $pirepdata->source;
		$comment = $comment;

		$email = $pilotinfo->email;
		$sub = 'PIREP Report - '.$code.''.$flightnum;
		$message = Template::Get('email_pirep_info.tpl', true);
		Util::SendEmail($email, $sub, $message);

Okay! I think we're missing something here. The Template::set(...) ?!

Link to comment
Share on other sites

  • Moderators

# Send an email to the pilot who submitted that PIREP
      	//PILOT INFO
                   	$pilotfirstname = $pilotinfo->firstname;
                   	$pilotlastname= $pilotinfo->lastname;
                   	$email = $pilotinfo->email;
                   	//PIREP INFO (This all goes into the email, we will need to add those into the TPL)
                   	$code = $pirepdata['code'];
                   	$flightnum = $pirepdata['flightnum'];
                   	$depicao = $pirepdata['depicao'];
                   	$arricao = $pirepdata['arricao'];
                   	$aircraft = $pirepdata['aircraft'];
                   	$flighttime = $pirepdata['flighttime'];
                   	$landingrate = $pirepdata['landingrate'];
                   	$source = $pirepdata['source'];
                   	$comment = $comment;

					Template::Set('pilotfirstname', $pilotfirstname);
                   	Template::Set('pilotlastname', $pilotlastname);
					Template::Set('code', $code);
					Template::Set('flightnum', $flightnum);
					Template::Set('depicao', $depicao);
					Template::Set('arricao', $arricao);
					Template::Set('aircraft', $aircraft);
					Template::Set('flighttime', $flighttime);
					Template::Set('landingrate', $landingrate);
					Template::Set('source', $source);
					Template::Set('comment', $comment);

                   	$sub = 'PIREP Report - '.$code.''.$flightnum;
                   	$message = Template::Get('email_pirep_info.tpl', true);
                   	Util::SendEmail($email, $sub, $message);

Okay. Change the code in PIREPData.class.php to the one above. It's tested and working. wink.gif

Link to comment
Share on other sites

Guest lorathon

You need to set the data into the template and then get the template. Then use the data inside of the template.

SET DATA

Template::Set('pilotinfo', $pilotinfo));
Template::Set('flight', $pirepdata);

GET TEMPLATE

$message = Template::Get('email_pirep_info.tpl', true);

USE DATA (inside of template)

Hello <?php echo $pilotinfo->firstname.' '.$pilot->lastname?>, 
</br>
Your PIREP for Flight#<?php echo $flight['code'].$flight['flightnum']?>....... 

SEND EMAIL

Util::SendEmail($email, $sub, $message);

NOT TESTED but should work.

Link to comment
Share on other sites

  • Moderators

You need to set the data into the template and then get the template. Then use the data inside of the template.

SET DATA

Template::Set('pilotinfo', $pilotinfo));
Template::Set('flight', $pirepdata);

GET TEMPLATE

$message = Template::Get('email_pirep_info.tpl', true);

USE DATA (inside of template)

Hello <?php echo $pilotinfo->firstname.' '.$pilot->lastname?>, 
</br>
Your PIREP for Flight#<?php echo $flight['code'].$flight['flightnum']?>....... 

SEND EMAIL

Util::SendEmail($email, $sub, $message);

NOT TESTED but should work.

Yes it;s working. But how can I get it to show aircraft name instead of aircraft ID?

Link to comment
Share on other sites

Here is what I got when a flight was submitted.

Flight Number:DL133

Departure:KATL

Arrival:KMIA

Aircraft:63

Flight Time:1.30

Landing Rate:0

Filed By:manual

Comments:This is a test flight submission.

I would also like to know how to show the aircraft name, and also how to show the Flight Log.

Link to comment
Share on other sites

  • Moderators

Okay! Here is what I designed for the .tpl. BTW I'm using FSPAX as my PIREP, so if you guys ever wanted to switch to FSPAX pirep system, let me know and I can give you the required files. We also have the FSPAX pilot pointing system at our airline which I can share as well. wink.gif

repo.png

Link to comment
Share on other sites

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