This PHPMaker 2024 project will show you how to handle Record Locking in Edit and Delete Pages. When End-User is opening the Edit Page, then the record is locked immediately, so that another End-User cannot Edit or Delete it. This is very useful if you want to prevent many users Editing or Deleting the same record at the same time, in order to Avoid Conflicting and for the Data Integrity Reasons.

When the Edit Page is being displayed, there is a warning message (including the count down how long it will be locked) displayed at above and below the Edit Form. When the last 30 seconds comes, then system will display Modal dialog using SweetAlert to inform the form will be unlocked. If End-User clicks on the OK button at that Modal dialog, then system will update the last Date and Time the form is opened, and system will keep locking the Record.

To see it in action, then you may open two different browser and login by using this separated login for each browser as follows:

User 1, for example, uses Google Chrome browser:
- Username: Elvis
- Password: Sinaga

User 2:, for example, uses Mozilla Firefox browser
- Username: Masino
- Password: Sinaga

Then try to edit one of the Complaints or Customers record by one of those two users, let's say by User 1. After that, then try to Edit the same record by using User 2. You will see a message from system that informs the currenct Record is being locked by User 1 and cannot be displayed in Edit form.

The record will be unlocked by system if one of this two conditions is met:

  1. The record has already been saved by the End-User.
  2. The maximum locking time limit (1 minute) has been exceeded.

By using this project, then there are many things you will know and learn:

  1. How to use npm packages under menu Tools -> npm packages to implement Javascript count down logic.
  2. How to include Javascript file that came from npm packages, by using Page_Head server event.
  3. How to choose the best and the right Javascript Count Down Library, so that you don't spend much your time anymore
  4. How to handle Record Locking by using code in Client Side and Server Side for specific time limit.
  5. How to convert Count Down information from Seconds value to hh:mm (each in two digits) format.
  6. How to display the Count Down information by using Javascript code above and below the Edit Page.
  7. How to display the Count Down message by using SweetAlert that will be auto closed after the certain period of time.
  8. How to display the Count Down in browser title so that End-User will be able to see simply from the browser's tab.
  9. How to update the Date and Time in Database, either when the last time End-User opening the Edit Page or extend the locking session.
  10. How to check whether a Record is still being locked or not, for both conditions mentioned above.
  11. How to handle if End-User never saved the Record, then system should be able to check whether the maximum locking time limit has been exceeded or not.
  12. How to define the global variables in Server Side, so that it can be used in Client Side. In this example, we use a global variable to declare Locking Session Time for 1 (One) minute.
  13. How to define the new Language phrases that will be displayed in Client Side events.
  14. How to use Api_Action server event in order to create our own API that will be triggered from Client Side events.
  15. How to create a global Javascript function in Global Client Script section of your PHPMaker project.
  16. How to implement Record Locking for several tables based on that global Javascript function
  17. How to implement Auto-Fill for multiple fields which one of the fields uses Select control.
  18. How to change the control type from Select2 to Native Select control, so that Auto-Fill will work properly.
  19. How to reduce the width of Select control by using CSS code and define it from the project side.
  20. How to prevent deleting records, which is very useful for demo web applications.
  21. How to define default start page both for Anonymous and Logged-In Users.