PHPRunner and MS SQL Azure – Running a Stored Procedure behind a button – With Sweet Alert User Feedback

I have written previously about triggering stored procedures in MS SQL Azure through a PHP Runner generated web front end. This is a vanilla explanation which includes sweet alerts to indicate users updating them on the progress of longer running stored procedures. It also locks the front end preventing users from rushing procedures until the queries have had time to complete.

Firstly navigate to the table you wish to run the stored procedure from in this example it is table T032Email List Screen

Insert a Custom Button here I call it Transform

Next select the button and look to the right for the Edit Button Code button.

You will be presented with the Buttons properties window dialog with three tabs
1=Client Before
3=Client After

1) In the Client Before place the following code{
  title: 'Please wait... transforming selected records',
  allowOutsideClick: false,
  allowEscapeKey: false,
  showConfirmButton: false

2) On the Server trigger the stored procedure – swap out your stored procedure name.

DB::Exec("EXEC dbo.transformemail");

and on the 3) Client After notify the user once everything has been completed{
    icon: "success",
    allowOutsideClick: false,
    allowEscapeKey: false,
    title: "Records Transformed",
    showConfirmButton: false,
    timer: 2000
setTimeout("window.t032emailPage.reload({a:'reload'})", 2000);

PHPRunner – Using Sweet Alerts to give Users confirmation of Save

In PHPRunner as of version 10.51 the sweet alert javascript library is included in PHPRunner generated web applications.

How can we add code to a project to make bespoke adjustments?

Firstly navigate to the form you wish to add a special sweet alert to and insert a Custom Button.

Next navigate to the Events tab in PHPRunner and expand the table or view to which you added the additional button.

Behind the Javascipt OnLoad event add the following code

$('a[id^="saveButton"]').hide(); // Hide button "Save"

And on the Client Before Event of the new button add the following code{
icon: "success",
title: "Saved",
showConfirmButton: false,
timer: 1000
return false;

So what does the code do
Javascript OnLoad Event – Hides the real save button
On Click – Triggers the sweet alert success routine and once that is complete triggers the hidden savebutton code.

And more examples and inspiration

Sweet alert 2

And also if you find the Sweet Alert modal size too small add this to your page css:

.swal2-popup { font-size: 1.6rem !important; }

Most of this was from the following Xlinesoft User forum Thread