ontarget
Active Member
Hi I am trying to set a condition for a validation I am using the "areuniquevalues" on a field element.
The user have a userid number that they use to make the claim
If a user has previously entered this ID to claim for travel expenses they cant claim for the same thing a second time - hence the comparison between the claim id and user id
Now the caveat!
If the user claimed once and the admin rejected the claim we wish to give them an opportunity to claim again therefore overriding the userid / claimid "areuniquevalues" validation.
in the condition field i have entered this php which says if the row doesnt have a value of "Rejected" then run the areuniquevalues validation - however it doesnt work! Not sure if my php is 100% correct or if i should be adding the if else statement.
The user have a userid number that they use to make the claim
If a user has previously entered this ID to claim for travel expenses they cant claim for the same thing a second time - hence the comparison between the claim id and user id
Now the caveat!
If the user claimed once and the admin rejected the claim we wish to give them an opportunity to claim again therefore overriding the userid / claimid "areuniquevalues" validation.
in the condition field i have entered this php which says if the row doesnt have a value of "Rejected" then run the areuniquevalues validation - however it doesnt work! Not sure if my php is 100% correct or if i should be adding the if else statement.
PHP:
$myDb = JFactory::getDbo();
$myQuery = $myDb->getQuery(true);
$myQuery
->select('calcapprove')
->from('aaa_participant_claim')
->where('tcn = ' . $myDb->quote('{aaa_participant_claim___tcn}'))
->and('uniqueclaim_id = ' . $myDb->quote('{aaa_participant_claim___uniqueclaim_id}'));
$myDb->setQuery($myQuery);
$rejected = $myDb->loadResult();
if ($rejected != 'Rejected') {
return true;
}
else {
return false;
}