good afternoon
How to make a custom button with confirmation?
Warning: "Do you want Download the Releases?"
if ok -> Execute SQL
if not -> Not Execute SQL
When I run both if I click ok or cancel the sql runs
If possible I would also like to know, how to give an alert if the button is clicked but have no record selected.
"There are no records selected"
My Code:
------------------------
Client Before
------------------------
ctrl.setEnabled();
if(!confirm("Deseja Baixar os Lançamentos Selecionados?"))
return false;
------------------------
Server
------------------------
global $dal;
while ( $data = $button->getNextSelectedRecord() ) {
$sql = "UPDATE LANCAMENTOS
SET STATUS = 1, USUARIOULTIMAALTERACAO = '".$_SESSION["UserID"]."'
WHERE IDLAN IN (SELECT IDLAN FROM view_lancamentos
WHERE STATUS = 0
AND DTVENCIMENTO <= CURDATE()
AND IDEMPRESTIMO = '".$data["COD_EMPRESTIMO"]."');";
CustomQuery($sql);
}
$result["txt"] = "Lançamentos Baixados Com Sucesso!";
------------------------
Client After
------------------------
alert(result['txt']);
location.reload();