Hi,
I'm having a small issue with the subject of this topic.
In a list page I added a button to start the duplication of the selected records.
What happens is that the 1st selected element of the list get duplicated, but then the execution of the code stops, the page of course doesn't get updated and all the elements are still selected.
I wasn't able to identify the problem, becasue I'm not very familiar with PHP code or javascript and I'd like to know if there is a way of tracing what happens when the CustomQuery gets executed at this control.
If I replace CustomQuery($sql); with $result["txt"] = $result["txt"] . $sql; the process passes from the Server to the Client After event without ane issue.
So it seems the the first occurence of CustomQuery gets executed (the DB gets updated with the duplicated record) and then no more.
At the end of the post is the Button's properties code.
As plus I'd like to show the process to the user.
I didn't look much into it, but any suggestion will greatly appreciated.
Thank you
Roberto.
--------
Event: Client Before
if (!confirm("Are you sure you want to Re-Issue the selected records?")) {
ctrl.setEnabled();
return;
}
Event: Server
global $dal;
for ($i=0; $i<count($keys); $i++) {
$str = "
CREATE TEMPORARY TABLE tmp01 SELECT * FROM cert_clbrs WHERE Cert_ID = '".$keys[$i]["Cert_ID"]."';
UPDATE tmp01 SET Cert_ID = NULL, Cert_No = CONCAT(Cert_No,'/REISSUE'), Cert_Date = NULL;
INSERT INTO cert_clbrs SELECT * FROM tmp01;
DROP TABLE tmp01;
";
$query = explode(";", $str);
foreach ($query as $index => $sql) {
CustomQuery($sql);
//$result["txt"] = $result["txt"] . $sql;
};
};
$result["txt"] = "Certs were Re-Issued.";
Event: ClientAfter
var message = result["txt"];
alert(message);
location.href = "cert_clbrs_list.php";