Jump to content

Send an Email for Accepted PIREP


Curshad

Recommended Posts

Hi Guys,

So I did a lot of research and found this. To which it didn't really help but it sorta did. I use the auto accept PIREP Module, and I learned/noticed whenever a PIREP is rejected an email is sent out, this is the code I found in the PIREPACData Class file 

                    //If sendmail_to_pilot=1 send email to pilot that the pirep has been rejected 

                    if ($settings->sendmail_to_pilot == '1' && $pirepdetailsafter->accepted =='2')  
                    {  

                        $sub = "Your PIREP {$pirepdetails->pirepid}({$pirepdetails->depicao} - {$pirepdetails->arricao}) has been rejected ";
                        $message="Your PIREP {$pirepdetails->pirepid}({$pirepdetails->depicao} - {$pirepdetails->arricao}) has been rejected\n\n" 
                        ."If you wish to see the reason please visit the company Website \n";

                        $email = $userinfo->email;


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



                    }

this starts at around line 301, So what I did to try and create my own accepted pirep email was take this same code and tweak it abit according to the notes that are commented out in the code, and it looks like this:
 

                    //If sendmail_to_pilot=1 send email to pilot that the pirep has been accepted 

                    if ($settings->sendmail_to_pilot == '1' && $pirepdetailsafter->accepted =='1')  
                    {  

                        $sub = "Your PIREP has been approved!";
                        $message="Nice! Your PIREP {$pirepdetails->pirepid}({$pirepdetails->depicao} - {$pirepdetails->arricao}) has been approved\n\n";

                        $email = $userinfo->email;


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



                    }

                }

            } 
            else 
            {

            }
        }


    }    

at the end of that last bracket the data class file has ended. Could someone point out to me why this very code works, but is sending out 4 of the same email? I noticed in this forum the Original Poster, ran into the same issue while getting help with the code seen here at the very top he explains why it sends 4 of the same "your PIREP has been accepted" email which is great, but clearly his coding is a bit different from mine so follow his instructions or i should say taking his codes to fix my issue wont work, right? I'm going to try inserting this:

                        echo Util::SendEmail($email, $sub, $message);  
                        echo 'Accepted';
                    }
                        elseif($pirep->accepted == PIREP_REJECTED)
                    {
                        echo 'Rejected';
                    }
                        elseif($pirep->accepted == PIREP_PENDING)
                    {
                        echo 'Approval Pending';
                    }


and see if it works, But I'm not so sure it will, would anyone care to help me out here seems i am at a brick wall.

Edited by Curshad
Link to comment
Share on other sites

Update:

I'm going to try adding an else if like so:

                    if ($settings->sendmail_to_pilot == '1' && $pirepdetailsafter->accepted =='2')  
                    {  

                        $sub = "Your PIREP {$pirepdetails->pirepid}({$pirepdetails->depicao} - {$pirepdetails->arricao}) has been rejected ";
                        $message="Your flight from {$pirepdetails->depicao} to {$pirepdetails->arricao} has been rejected PIREP {$pirepdetails->pirepid}\n\n" 
                        ."If you wish to see the reason please visit the company Website \n";

                        $email = $userinfo->email;


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



                    }

                    //If sendmail_too_pilot=1 send email to pilot that the pirep has been accepted 

                    elseif ($settings->sendmail_to_pilot == '1' && $pirepdetailsafter->accepted =='1')  
                    {  

                        $sub = "Your PIREP has been approved!";
                        $message="Hey Nice! Your flight from <b> {$pirepdetails->depicao} </b> to <b> {$pirepdetails->arricao} </b> has been approved PIREP {$pirepdetails->pirepid}\n\n";

                        $email = $userinfo->email;


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

It should work. But knowing how coding works, it may not I'm going to test it

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