Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Generate a pdf file and send it by email Topic is solved

Questions related to nuBuilder Forte Reports and the Report Builder.
kev1n
nuBuilder Team
Posts: 4242
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 68 times
Been thanked: 422 times
Contact:

Re: Generate a pdf file and send it by email

Unread post by kev1n »

kev1n wrote: Fri Dec 30, 2022 12:33 pm Check out viewtopic.php?t=11008
Use the code from the topic above (last post) to send emails. It works fine for me and the file/attachment is correctly transferred.



Did you try the code from viewtopic.php?p=24368#p24368 ?

Code: Select all

$file = "#filename#";     
$filename = basename($file); 
etc...
yvesf
Posts: 305
Joined: Sun Mar 14, 2021 8:48 am
Location: Geneva
Has thanked: 83 times
Been thanked: 11 times

Re: Generate a pdf file and send it by email

Unread post by yvesf »

thank you, now it works... you need to use basename() function... Brilliant. Yves
yvesf
Posts: 305
Joined: Sun Mar 14, 2021 8:48 am
Location: Geneva
Has thanked: 83 times
Been thanked: 11 times

Re: Generate a pdf file and send it by email

Unread post by yvesf »

that's done, ouch, my fault partially. Many thanks for your continuous help.
nathan
Posts: 40
Joined: Tue Apr 19, 2022 9:18 pm
Been thanked: 3 times

Re: Generate a pdf file and send it by email

Unread post by nathan »

Hi,
Is there a way I could send a email for each of the records of a filtered browse screen ?
ex: sent an invoice to each person in the filtered browse

(Loop all the records in the filtered record set)

thanks
steven
Posts: 359
Joined: Mon Jun 15, 2009 10:03 am
Has thanked: 48 times
Been thanked: 47 times

Re: Generate a pdf file and send it by email

Unread post by steven »

Hi nathan,

This will loop through a list of email recipients.

Is that what you are asking?

Code: Select all

$to 		= ['person1@gmail.com', 'person2@gmail.com', 'person3@gmail.com'];	//-- recipients
$file 		= "#filename#";           						//-- get filename
$filename 	= basename($file);  							//-- file name only

if(file_exists($file)){

   for($i = 0 ; $i < count($to); ; $i++){ 
      nuSendEmail('from_email@gmail.com',$to[$i],'From Name','Test','Your Order',[$filename => $file],true); //-- Send E-Mail
   }

}else{
   nuDebug('Cannot send ' . $file);
}     

Steven
If you like nuBuilder, how about leaving a nice review on SourceForge?
nathan
Posts: 40
Joined: Tue Apr 19, 2022 9:18 pm
Been thanked: 3 times

Re: Generate a pdf file and send it by email

Unread post by nathan »

No not realy
What i wannt to do is have a filtered browse screen
here is my browse SQL
SELECT
tbl_facture.*,
tbl_membre.NC_membre,tbl_membre.CR_membre,
zzzzsys_user.sus_name

FROM
tbl_facture
join tbl_membre on tbl_facture.ID_mbfacture = tbl_membre.ID_membre
join zzzzsys_user on tbl_facture.ID_user = zzzzsys_user.sus_code

where
((AX_facture = '#nuBrowseTitle6_dropdown#' AND LOCATE('#', '#nuBrowseTitle6_dropdown#') <> 1 ) OR '#nuBrowseTitle6_dropdown#' = '' OR LOCATE('#', '#nuBrowseTitle6_dropdown#') = 1)
AND ((AE_facture = '#nuBrowseTitle2_dropdown#' AND LOCATE('#', '#nuBrowseTitle2_dropdown#') <> 1 ) OR '#nuBrowseTitle2_dropdown#' = '' OR LOCATE('#', '#nuBrowseTitle2_dropdown#') = 1)

this filters my results
I want to be able to generate a email for each entry than has not yet been sent.

EX: sending an invoice for each person.
I can do this one at a time but I whould like to do this all at once.

I don't know if i am clear on what i whant to do ???

Say you whant to sent all the invoices in the filtered sql (browse)
Goto first record generated by filtered sql
1:check to she if invoice has been sent (this is OK)
2:if it has not been sent +> run reportsave to generate pdf file
3: Send email to email address
4: goto the next recored
5: check to she if invoice has been sent
6:if it has not been sent +> run reportsave to generate pdf file
and so on looping through all records the the filtered browse sql returned
steven
Posts: 359
Joined: Mon Jun 15, 2009 10:03 am
Has thanked: 48 times
Been thanked: 47 times

Re: Generate a pdf file and send it by email

Unread post by steven »

nathan,

If you upload a zipped copy of your database we can take a look.

And if you add some screen shots so we know what you are talking about.


Steven
If you like nuBuilder, how about leaving a nice review on SourceForge?
nathan
Posts: 40
Joined: Tue Apr 19, 2022 9:18 pm
Been thanked: 3 times

Re: Generate a pdf file and send it by email

Unread post by nathan »

I am going to try to simplify what I want to achieve.
I manage a hunting club the requires members to pay a yearly fee
So each year I produce an invoice for each member …I would like to be able to send an email to each member with a pdf attachment of their invoice.
The report is ok I can send then individually so now I want to be able to send then all at once.
kev1n
nuBuilder Team
Posts: 4242
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 68 times
Been thanked: 422 times
Contact:

Re: Generate a pdf file and send it by email

Unread post by kev1n »

I would pass the `browse_sql` to a PHP procedure that iterates through all the records in a loop. For each record, it would call `nuRunReportSave()` and send an email.

A more elegant solution would probably be to handle everything entirely in PHP, without requiring each record to be visually opened. However, I'm not sure if that approach is feasible.
nathan
Posts: 40
Joined: Tue Apr 19, 2022 9:18 pm
Been thanked: 3 times

Re: Generate a pdf file and send it by email

Unread post by nathan »

kev1n wrote: Mon Dec 09, 2024 4:12 pm I would pass the `browse_sql` to a PHP procedure that iterates through all the records in a loop. For each record, it would call `nuRunReportSave()` and send an email.

A more elegant solution would probably be to handle everything entirely in PHP, without requiring each record to be visually opened. However, I'm not sure if that approach is feasible.
yes this is what i want but how to i do it,since `nuRunReportSave()` is JS and it seems to run after the PHP ???
Post Reply