This topic is locked
[SOLVED]

 New Button in list view not working

4/7/2011 2:56:59 PM
PHPRunner General questions
D
dovercomputers author

Followed the instructions in the manual to the letter email selected users
When clicking on the button, in firefox nothing. In internet Explorer the button greys out when clicked, then nothing.
I even tried creating a new button and in the server tab just put in a alert with nothing else on either tab, but that failed as well.
I have spent 5 hours on this, it worked fine in 5.2 using the old hack, and if it wasn't for the new tabs in 5.3 which I have already used in this project, I would go back to 5.2.
Anyone have any ideas what is going wrong or experienced this in 5.3?
Thanks

Jim

D
dovercomputers author 4/7/2011

ok, well in client before tab, i put an alert and in the client after tab put an alert and they work fine. So its the php in the system tab thats not working.
This is my php
Table = quotes, primary key field = id, email field = clients_address1_email (joined from 'client' table)
Does this look right??

global $dal;

$dal_TableName = $dal->Table("quotes");

$email_list = "";

foreach(@$keys as $keyblock)

{

$arr=split("&",refine($keyblock["id"]));

if(count($arr)<1)

continue;

$arr2=array();

$arr2["id"]=urldecode(@$arr[0]);

$where = KeyWhere($arr2);

$rstmp = $dal_TableName->Query($where,"");

$datatmp=db_fetch_array($rstmp );

if ($datatmp["clients_address1_email"])

$email_list.=$datatmp["clients_address1_email"].",";

}

if ($email_list)

$email_list = substr($email_list,0,-1);

// send the email

$email=$email_list;

$subject="Sample subject";

$body = "Your email text here";

$arr = runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $body));

$result["txt"] = "Emails were sent.";

// if error happened print a message on the web page

if (!$arr["mailed"])

{

$errmsg = "Error happened:
";

$errmsg.= "File: " . $arr["errors"][0]["file"] . "
";

$errmsg.= "Line: " . $arr["errors"][0]["line"] . "
";

$errmsg.= "Description: " . $arr["errors"][0]["description"] . "
";

$result["txt"] = $errmsg;

}
D
dovercomputers author 4/7/2011

OK, I have narrowed it down to it doesn't appear to be pulling in the email address. If I hard code an email address in, it works.
The sql for the quotes table is

SELECT

quotes.id,

quotes.quoteNo,

quotes.client,

quotes.`date`,

quotes.paymentType,

quotes.totalFee,

quotes.ff_months,

quotes.ff_monthlyFee,

quotes.description,

quotes.convertToJob,

quotes.dateConverted,

quotes.b_hourly_rate,

clients.clients_address1_email

FROM quotes

INNER JOIN clients ON quotes.client = clients.clients_number


And if I view the results tab I can see the emaill address in the results.

D
dovercomputers author 4/7/2011

God I am stupid. The query is in the the "Server" tab, and that is only reading from the quotes table. Thats why it is not picking up email address.
So my question is now, how can I join the 'clients' table to get the email address. I tried creating view with the email address in, but that doesn't work.
Any ideas?

$dal_TableName = $dal->Table("quotes");

$email_list = "";
foreach(@$keys as $keyblock)
{
$arr=split("&",refine($keyblock["id"]));
if(count($arr)<1)
continue;
$arr2=array();
$arr2["id"]=urldecode(@$arr[0]);
$where = KeyWhere($arr2);
$rstmp = $dal_TableName->Query($where,"");
$datatmp=db_fetch_array($rstmp );
if ($datatmp["clients_address1_email"])
$email_list.=$datatmp["clients_address1_email"].",";
}
D
dovercomputers author 4/7/2011

Added a second query in the loop to get the email address from another table.
Not pretty but it worked.