I'm trying to make some code to run after save.
Code: Select all
if('#clone#' == '1' or '#recordID#' == '-1'){ //-- this is a new record
nuRunQuery("INSERT INTO fac_counter (tc_text) VALUES ('1')");
$s = "UPDATE facturatie SET fac_ogm2 = '" . mysql_insert_id() . "' ";
$s .= "WHERE fac_id = '#newID#'";
nuRunQuery($s);
$c = nuRunQuery("select mod(concat(fac_ogm1, fac_ogm2, fac_ogm3),97) from facturatie where fac_id = '#newID#'");
If ($c =='0'){
nuRunQuery("update facturatie set fac_ogm4 = '97' where fac_id = '#newID#'");
}else{
nuRunQuery("update facturatie set fac_ogm4 = (select mod(concat(fac_ogm1, fac_ogm2,'00'),97))where fac_id = '#newID#'");
}
$t = nuRunQuery("select fac_ogm4 from facturatie where fac_id = '#newID#'");
if ($t <'10') {
nuRunQuery("update facturatie set fac_nummer = concat('+++',fac_ogm1,'/', fac_ogm2,'/',fac_ogm3,'0',fac_ogm4,'+++') where fac_id = '#newID#'");
} else {
nuRunQuery("update facturatie set fac_nummer = concat('+++',fac_ogm1,'/', fac_ogm2,'/',fac_ogm3,fac_ogm4,'+++') where fac_id = '#newID#'");
}
}
Problem is that if I echo $c (or something else) i get #resourceID# 38 and not the integer I'm expecting. So the if won't work. I think / hope the rest of my sql / code is ok.
Other problem is that the 2 last figures is a code generated by mod(),97). This have to be 2 digits. When te result is < 10 I need 01, 02, .... Now I've tried to solve it with if.... but is there a better sollution.
Thanks a lot.
Johan