Sending Email

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
espo
Veteran Member
Posts: 98
Joined: 2013-03-01 12:55

Sending Email

Post by espo » 2014-05-19 09:23

Hello,

I wanted to know how to create a hook to send an email when an inserted field is equal to or less than a number.

example:

field STOCKS
when i enter a number that is 20 or lower than 20, the program sends an e-mail alert.

Can you help me to enter the code that allows this feature?
Thank you very much.

espo
Veteran Member
Posts: 98
Joined: 2013-03-01 12:55

Re: Sending Email

Post by espo » 2014-05-22 11:02

no one knows help me?

AhmedBR
AppGini Super Hero
AppGini Super Hero
Posts: 327
Joined: 2013-09-19 10:23

Re: Sending Email

Post by AhmedBR » 2014-05-24 12:21

You can do this with a simple IF

Something like
If( yourfield <= '80') { the code for sending email that you can get from the link below}

that is all.

http://bigprof.com/appgini/tips-and-tut ... ed-records
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper

espo
Veteran Member
Posts: 98
Joined: 2013-03-01 12:55

Re: Sending Email

Post by espo » 2014-05-27 12:01

Thank you very much.
I know that the answer it's simple, but i'm a novice in php and sometime to find a solution is difficult.

espo
Veteran Member
Posts: 98
Joined: 2013-03-01 12:55

Re: Sending Email

Post by espo » 2014-06-09 12:51

Hello to all.
Seeking clarification:

this is the code that I inserted into the hooks

Code: Select all

function giacenze_after_update($data, $memberInfo, &$args){

	// calculate total 
	$id=$data['id'];
        $Guasti = $data['Giacenza'] - $data['Disponibili'];
        sql("update giacenze set Guasti='$Guasti' where id='$id'", $eo);
	
	// to compose a message containing the submitted data,
	if ($data['Disponibili'] <= '20'){	

	@mail(
		// mail recipient
		"[email protected]",
		
		// subject
		"ATTENZIONE! Scorta Minima raggiunta per {$data['Apparato']}",
		
		
		// message
		"Ciao {$memberInfo['username']},\n\n".
		"Questo materiale ha raggiunto la scorta minima:\n\n".
		"{$data['Apparato']}\n".
		"Pezzi Disponibili: {$data['Disponibili']}\n\n".
		"Per visualizzare il materiale sul DataBase clicca il link seguente:\n".
		"http://appgini/table_view.php?SelectedID=$id",

		
		// sender address
		"From: [email protected]"
	);
	}
	
	//if ($data['Guasti'] >= '50'){
		
	

	@mail(
		// mail recipient
		"[email protected]",
		
		// subject
		"Eccessivo materiale GUASTO in magazzino per {$data['Apparato']}",
		
		
		// message
		"Ciao {$memberInfo['username']},\n\n".
		"C'è un eccesso di materiale guasto in magazzino:\n\n".
		"{$data['Apparato']}\n".
		"Materiale Guasto  {$data['Guasti']}.\n\n".
		"Per visualizzare il materiale sul DataBase clicca sul link:\n".
		"http://appgini/table_view.php?SelectedID=$id",

		
		// sender address
		"From: [email protected]"
	);
	}
		return TRUE;
	}
The problem I have when I send the email for the material FAIL {$data['Guasti']}, because in the field of the table shows the calculation, and in the email I have no result but a single number (such as 1, 8, etc ...).
How could I bring up the exact number of calculation in email?
I hope I have explained my problem!

How could I bring up the exact number of subtraction?
I hope I have explained my problem!

Can anyone help me?

User avatar
a.gneady
Site Admin
Posts: 1281
Joined: 2012-09-27 14:46
Contact:

Re: Sending Email

Post by a.gneady » 2014-06-15 16:58

Instead of

Code: Select all

$Guasti = $data['Giacenza'] - $data['Disponibili'];
try

Code: Select all

$data['Guasti'] = $data['Giacenza'] - $data['Disponibili'];
and use $data['Guasti'] rather than $Guasti in other parts of the code.
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

espo
Veteran Member
Posts: 98
Joined: 2013-03-01 12:55

Re: Sending Email

Post by espo » 2014-06-17 08:23

Hello,

I entered the code $data['Guasti'], but when I update, I see a blank page.
Something does not work ... :)

User avatar
a.gneady
Site Admin
Posts: 1281
Joined: 2012-09-27 14:46
Contact:

Re: Sending Email

Post by a.gneady » 2014-06-18 11:45

A blank page probably means some syntax error ... it should be logged into the server error_log file .. could you check what's in there?
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

espo
Veteran Member
Posts: 98
Joined: 2013-03-01 12:55

Re: Sending Email

Post by espo » 2014-06-20 06:48

Hallo,

in the error_log I haven't info or error.

When I change this code part

originial

Code: Select all

sql("update giacenze set Disponibili='$Disponibili' where id='$id'", $eo);
with

Code: Select all

sql("update giacenze set Disponibili='$data=['Disponibili']' where id='$id'", $eo);
or

Code: Select all

sql("update giacenze set Disponibili=$data=['Disponibili'] where id='$id'", $eo);
I have a blank page.

User avatar
a.gneady
Site Admin
Posts: 1281
Joined: 2012-09-27 14:46
Contact:

Re: Sending Email

Post by a.gneady » 2014-06-22 03:33

I guess it should be

Code: Select all

    sql("update giacenze set Disponibili='{$data['Disponibili']}' where id='$id'", $eo);
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

espo
Veteran Member
Posts: 98
Joined: 2013-03-01 12:55

Re: Sending Email

Post by espo » 2014-06-25 13:31

Thank you Ahmad,

I try and let you know!

espo
Veteran Member
Posts: 98
Joined: 2013-03-01 12:55

Re: Sending Email

Post by espo » 2014-06-25 13:44

The tested!

It does not work like that!

User avatar
toconnell
Veteran Member
Posts: 204
Joined: 2013-04-09 19:29
Location: Oklahoma City, OK
Contact:

Re: Sending Email

Post by toconnell » 2014-07-22 15:27

See this for my detailed explanation on how too.. my lesson.. lOL http://forums.appgini.com/phpbb/viewtopic.php?f=7&t=850
Tina O'Connell
Web Dev & Appgini FAN

magicalmutation
Posts: 11
Joined: 2013-08-07 17:15

Re: Sending Email

Post by magicalmutation » 2014-12-11 11:15

hi guys...

i have an email related issue..

I want to Email the attached file from a child / linked record.

so for instance i have an inquiry form about an item. i want to be able to email from the inquiry form the attached pdf related to that item that is in the items record. to be honest i would like to be able to attach multiple files like all files attached to that item as child records but lets keep it simple for now..

Glyn

Post Reply