Virtualei Posted October 1, 2012 Report Share Posted October 1, 2012 Hi, Has anyone ever produced something that sends an email to the pilot when their pirep has been accepted. I have looked in the forums and have found similar like email pireps data but have been unable to find what I am after. Maybe even an email to say Pirep accepted or if rejected and the reason ?? Looking forward to hearing from someone Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted October 1, 2012 Moderators Report Share Posted October 1, 2012 I have something that sends an email of the submitted PIREP to the pilot. Maybe you can change its code to send the email when PIREP is accepted. It's actually pretty easy to do. Here, try this but I haven't tested it: # 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']; Template::Set('pilotinfo', $pilotinfo); Template::Set('flight', $pirepdata); $sub = 'Flight Report for: '.$code.''.$flightnum; $message = Template::Get('email_pirep_accep.tpl', true); $pireps = self::getLastReports($pilotinfo->pilotid, 1); if($pireps->accepted == "1") { Util::SendEmail($email, $sub, $message); } Now you need to make a file named "email_pirep_accep.tpl" and write in there whatever you want to tell your pilots about their PIREP and you need to add this to your PIREPData.class.php inside the function filePIREP() around line 800. Mine is at line 842 Let me know if it works or not Salamaty Quote Link to comment Share on other sites More sharing options...
Virtualei Posted October 1, 2012 Author Report Share Posted October 1, 2012 Hi Parko mate, Ok here is my email_pirep_accep.tpl which I placed in my skins folder Dear <?php echo $firstname. ' ' .$lastname?>, Your pirep has been accepted. To view it, visit: <?php echo SITE_URL;?>/index.php/pireps/view/<?php echo $pirepid;?> Thanks! The <?php echo SITE_NAME;?> Team now I have added the code you supplied from line 800. but i dont think I have it in the right place * Update a specific PIREP * * @param int $pirepid ID of PIREP to update * @param array $pirepdata Dictionary array of fields to update * @param bool $recalc_finances Recalculate finances or not (fields must be passed!) * @return */ public static function updateFlightReport($pirepid, $pirepdata, $recalc_finances = true) { if (!is_array($pirepdata)) { return false; } if ($pirepdata['depicao'] == '' || $pirepdata['arricao'] == '') { return false; } $pirepinfo = self::getReportDetails($pirepid); if(isset($pirepdata['fuelused']) && isset($pirepdata['fuelunitcost'])) { $pirepdata['fuelprice'] = $pirepdata['fuelused'] * $pirepdata['fuelunitcost']; } if(isset($pirepdata['flighttime'])) { $flighttime_stamp = str_replace('.', ':', $pirepdata['flighttime']) . ':00'; $pirepdata['flighttime'] = str_replace(':', ',', $pirepdata['flighttime']); } # 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']; Template::Set('pilotinfo', $pilotinfo); Template::Set('flight', $pirepdata); $sub = 'Flight Report for: '.$code.''.$flightnum; $message = Template::Get('email_pirep_accep.tpl', true); $pireps = self::getLastReports($pilotinfo->pilotid, 1); if($pireps->accepted == "1") { Util::SendEmail($email, $sub, $message); } # Recalculate finances if these fields are set... if($recalc_finances === true) { $data = array( 'price' => $pirepdata['price'], 'load' => $pirepdata['load'], 'expenses' => $pirepdata['expenses'], 'fuelprice' => $pirepdata['fuelprice'], 'pilotpay' => $pirepdata['pilotpay'], 'flighttime' => $pirepdata['flighttime'], ); $gross = floatval($pirepdata['load']) * floatval($pirepdata['price']); $revenue = self::getPIREPRevenue($data, $pirepinfo->paytype); $pirepdata = array_merge($pirepdata, array( 'flighttime_stamp' => $flighttime_stamp, 'gross' => $gross, 'revenue' => $revenue, ) ); Am I in the correct file core/common/PIREPData.class.php Salamaty Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted October 1, 2012 Moderators Report Share Posted October 1, 2012 Yes, but you'll need to find the filePIREP() function and place it in there, right now you're in updatePIREP() function Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted October 1, 2012 Moderators Report Share Posted October 1, 2012 You also need to change what's in your .tpl to the following: Dear <?php echo $pilotinfo->firstname. ' ' .$pilotinfo->lastname?>, Your pirep has been accepted. To view it, visit: <?php echo SITE_URL;?>/index.php/pireps/view/<?php echo $pirepdata->pirepid;?> Thanks! The <?php echo SITE_NAME;?> Team Quote Link to comment Share on other sites More sharing options...
Virtualei Posted October 1, 2012 Author Report Share Posted October 1, 2012 I have emailed you Parko Quote Link to comment Share on other sites More sharing options...
Virtualei Posted October 1, 2012 Author Report Share Posted October 1, 2012 sorry no i havnt it came back again. I used your VA email address. Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted October 1, 2012 Moderators Report Share Posted October 1, 2012 info@bnfgallery.com Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted October 2, 2012 Moderators Report Share Posted October 2, 2012 Don't forget to change this: Dear <?php echo $pilotinfo->firstname. ' ' .$pilotinfo->lastname?>, Your pirep has been accepted. To view it, visit: <?php echo SITE_URL;?>/index.php/pireps/view/<?php echo $pirepdata->pirepid;?> Thanks! The <?php echo SITE_NAME;?> Team Quote Link to comment Share on other sites More sharing options...
Virtualei Posted October 2, 2012 Author Report Share Posted October 2, 2012 Have sent you a pm mate, the email is not sending Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted October 2, 2012 Moderators Report Share Posted October 2, 2012 Okay try this: # 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']; Template::Set('pilotinfo', $pilotinfo); Template::Set('flight', $pirepdata); $sub = 'Flight Report for: '.$code.''.$flightnum; $message = Template::Get('email_pirep_accep.tpl', true); if($pirepdata['accepted'] == "1") { Util::SendEmail($email, $sub, $message); } Quote Link to comment Share on other sites More sharing options...
Virtualei Posted October 2, 2012 Author Report Share Posted October 2, 2012 still not sending Parko Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted October 2, 2012 Moderators Report Share Posted October 2, 2012 Nothing at all or maybe an empty email? Quote Link to comment Share on other sites More sharing options...
Virtualei Posted October 2, 2012 Author Report Share Posted October 2, 2012 no email at all mate Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted October 2, 2012 Moderators Report Share Posted October 2, 2012 Okay i know why Wait a bit I'll let you know Quote Link to comment Share on other sites More sharing options...
Virtualei Posted October 2, 2012 Author Report Share Posted October 2, 2012 ok Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted October 2, 2012 Moderators Report Share Posted October 2, 2012 Okay, open admin/module/PIREPAdmin and paste the following in the approve_pirep_post() function at the very end. I think it should go through: # 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']; Template::Set('pilotinfo', $pilotinfo); Template::Set('flight', $pirepdata); $sub = 'Flight Report for: '.$code.''.$flightnum; $message = Template::Get('email_pirep_accep.tpl', true); Util::SendEmail($email, $sub, $message); Quote Link to comment Share on other sites More sharing options...
Virtualei Posted October 2, 2012 Author Report Share Posted October 2, 2012 I am getting this in my admin centre Notice: The template file "/home/airlingu/public_html//admin/templates/email_pirep_accep.tpl" doesn't exist in /home/airlingu/public_html/core/classes/TemplateSet.class.php on line 226 Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted October 2, 2012 Moderators Report Share Posted October 2, 2012 Okay then the tpl should go to admin/templates. Quote Link to comment Share on other sites More sharing options...
Virtualei Posted October 2, 2012 Author Report Share Posted October 2, 2012 Ok Parko got rid of the error but still no email mate Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted October 2, 2012 Moderators Report Share Posted October 2, 2012 Okay here is my last shot : # Send an email to the pilot who submitted that PIREP //PILOT INFO $pilotfirstname = Auth::$userinfo->firstname; $pilotlastname= Auth::$userinfo->lastname; $email = Auth::$userinfo->email; //PIREP INFO (This all goes into the email, we will need to add those into the TPL $code = $pirep_details->code; $flightnum = $pirep_details->flightnum; Template::Set('pilotinfo', Auth::$userinfo); Template::Set('flight', $pirep_details); $sub = 'Flight Report for: '.$code.''.$flightnum; $message = Template::Get('email_pirep_accep.tpl', true); Util::SendEmail($email, $sub, $message); Quote Link to comment Share on other sites More sharing options...
Virtualei Posted October 2, 2012 Author Report Share Posted October 2, 2012 Ok Parko I just got 4 emails through so I dont know which version worked. Gimme 5 mins mate Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted October 2, 2012 Moderators Report Share Posted October 2, 2012 okay. Quote Link to comment Share on other sites More sharing options...
Virtualei Posted October 2, 2012 Author Report Share Posted October 2, 2012 Ok mate I am getting 4 emails for each pirep. Feast or a famine lol Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted October 2, 2012 Moderators Report Share Posted October 2, 2012 lol, okay all the same? Quote Link to comment Share on other sites More sharing options...
Virtualei Posted October 2, 2012 Author Report Share Posted October 2, 2012 The link in the email to the report isnt going to the correct page. I can live with that. How do you think I should get it to one email. Should i remove the extra code in pirepdataclass.php Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted October 2, 2012 Moderators Report Share Posted October 2, 2012 of course! you only need the code in one place Quote Link to comment Share on other sites More sharing options...
Virtualei Posted October 2, 2012 Author Report Share Posted October 2, 2012 I have removed the code as we said and have left it in the admintemplates and modules but i am still getting 4 emails. I am going to leave it for tonight mate. Thanks for all your help. Maybe catch you tommorrow Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted October 2, 2012 Moderators Report Share Posted October 2, 2012 right on, good night then Quote Link to comment Share on other sites More sharing options...
Virtualei Posted October 3, 2012 Author Report Share Posted October 3, 2012 Hi Parko, I have had a look at this today with a fresh head. The last code sends out multiple emails[all the same email] even before the pirep has been accepted by admin. I tried moving the code from the Admin/modules to core/modules but the same thing happened. I tried adding if($pirepdata['accepted'] == "1") but then nothing was emailed. Are we at a loose end mate Alan Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.