Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

procedure opens a new form

johan
Posts: 399
Joined: Sun Feb 27, 2011 11:16 am
Location: Belgium
Been thanked: 3 times

procedure opens a new form

Unread post by johan »

Hi,

I've got a procedure that i run on a form. When I run the procedure (with a button runIt('verleng', nuGetFormId());) it opens a new form.

Code: Select all

$page =  $_SERVER['HTTP_REFERER'];
if('#verleng#' ==''){
  echo 'Je moet eerst een datum invullen. Tot wanneer wil je deze boeken verlengen?';
} else{

$c=("select  date_format(r.reg_from,'%d-%m-%Y') as reg_from, b.bib_titel from registratie r left join reservaties s on r.reg_id left join bibliotheek b on b.bib_id = s.res_artikel where s.res_reg_id = r.reg_id and res_artikel in (select res_artikel from reservaties where res_reg_id = '#runIt1#' and res_in is null) and STR_TO_DATE('#verleng#', '%d-%m-%Y') between reg_from and reg_to and reg_id != '#runIt1#'and reg_datum_in is null order by reg_from");

$z =nuRunQuery($c);

 $mess = '';
  
while($row= mysql_fetch_array($z))

{

$mess .= $row["bib_titel"];
$mess .= "\n";
  $mess .= "werd opnieuw gereserveerd op: ";
$mess .= $row["reg_from"];
   $mess .= "en kan niet verlengd worden. ";
  $mess .= "</BR>";

}

if(db_num_rows($z)<> 0) {
  
echo" 'Deze boeken: </BR>'$mess  ";
  
return false;
}else {
  
nuRunQuery("update registratie set reg_to = STR_TO_DATE('#verleng#', '%d-%m-%Y') where reg_id = '#runIt1#'");
echo" Deze boeken werden verlengd.  ";
  header('Location:'.$page);
  return true ;
}

}
Problem is that the new form contains the updated data. When user save and close the new form the data is updated to the database. But when user also saves the old form (with original data) he overwrites again with the old data.
How can I solve this? Is it possible to run the procedure in the same window?
Thanks for your help.
Johan
Post Reply