This topic is locked
[SOLVED]

 help with function please

11/26/2012 8:14:58 PM
PHPRunner General questions
S
stiven author

Hello,
I have a table with about 10 fields where the user has three options, "Done", "Pending", "N/A". If the user selects "Pending" in any field this list would be mark as incomplete, but if there is not "Pending" in any field I need to send an email, right now with the code I wrote, the email is sent either way, if there is "Pending" or not on any field,
I hope I made sense. Thanks for your help.


function check_pend ($values){
foreach($values as $k => $v)

{

if($values[$k] == "Pending"){

//echo $k . " keys <br/>";

return false;

}else if($values[$k] != "Pending"){

return true;

}

}

}
if(check_pend($values) == true){



$services = array();

foreach($values as $k => $v)

{

if($values[$k] == "N/A"){

$services[] = $k;

}

}



$msg = 'Please check, the following services WILL NOT be included in thise case: <br/>';



$count = count($services);

for ($i=0;$i<=$count;$i++){

$msg .= strtoupper($services[$i]) . "<br/>";

}
// ********** Send simple email ************

$email = "xxxxxxxxxxx";

$from = "Agape Check List<xxxxxxxxxxxx>";

$subject = "Double Check Task For: [". $values['deceased_name']."]";
echo $msg;

//$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'htmlbody' => $msg, 'from'=>$from);

}
C
cgphp 11/27/2012

Where do you put this code? Post a couple of screenshot of the list page to clarify your request.

S
stiven author 11/27/2012

this code goes after add events page,
I fix the function which was the one that was incorrect, here is the answer for anyone who might need it.


// Function

function check_pend($array)

{

foreach ($array AS $status)

{

if (strtolower($status) == 'pending')

{

return false;

}

}



return true;

}