conditional outcome after saving a record
Posted: Mon Nov 05, 2007 4:25 pm
Depending on a value entered in a form, I want the app to go to different places upon a user clicking 'Save'. Usually I have no problem with this. However, in this instance, it doesn't quite work.
Basically, when status is not 'WORKED' this should loop back to create a another version of the same form, with the same relation. However, it kicks me out to the list of related records already entered.
???
- Code: Select all
function afterInsert(&$record){
$app =& Dataface_application::getInstance();
$auth =& Dataface_AuthenticationTool::getInstance();
$user =& $auth->getLoggedInUser();
$lc = $record->val('location_code'); // same as dataframe$val
//print $lc;
$date = $record->strval('date');
$status = $record->val('status');
$query = & $app->getQuery();
$eid = trim($query['eid'],"=");
if ( strpbrk($lc,"X") ) $msg = "El codigo de casa usado en el registro no se encuentra en la base. Se ha indicado que la ficha debe ser revisada.";
//print $date;
if ( $user ) {
if ( $status == "WORKED" ) {
header("Location: index.php?-table=House_survey&-action=new_related_record&location_code=$lc&date=$date&-relationship=caracteristicas&--msg=$msg");
exit;
} else {
//This isn't working! Doesn't make sense. The app goes to house_survey list view, not the new related record form.
header("Location: index.php?-table=Entomology&-action=new_related_record&eid=$eid&-relationship=encuesta");
}
}
}
Basically, when status is not 'WORKED' this should loop back to create a another version of the same form, with the same relation. However, it kicks me out to the list of related records already entered.
???