Aim
Hide, Disable or Enable buttons based on the data retrieved from the Database
SQL - Database Table (SchoolData)
+-----+--------+------------+------------+----------------+-----------+
| ID | Class | Teacher | YearMonth | Description | Status |
+-----+--------+------------+------------+----------------+-----------+
| 1 | Alpha | Sara | 2017/01 | Good & Clean | Pending |
+-----+--------+------------+------------+----------------+-----------+
| 2 | Beta | John | 2016/11 | Big & Clean | Official |
+-----+--------+------------+------------+----------------+-----------+
Webpage
+---------------------------------------------------------------+
| |
| |>Select Class<| |>Select Teacher<| |>Select Year/Month<| |
| |
| (Search) |
| |
| |
|>>>>>>>>>>>>>>>>>>>>>>>>>>INPUT<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<|
| |
| {Class} {Teacher} {Description} |
| |
| |
| (RE-SUBMIT) (Draft) (Submit) |
| |
+---------------------------------------------------------------+
-
Legend
Drop down List - |><|
Button - ()
Text Input - {}
Webpage Description
RE-SUBMIT button is only available for the Admin
If the staff searches | Alpha | Sara | 2017/01 | for the âClassâ, âTeacherâ, and âYear/Monthâ respectively, since the data already exist and is saved as Pending, the staff will be able to input data again and choose to either click Draft or Submit.
If the staff clicks Draft, the Status of that data will be saved as âPendingâ but if the staff clicks Submit, the Status of that data will be saved as âOfficialâ. Once the Status of a set of Data is saved as âOfficialâ, the Submit button will be disabled even though the staff Searches for the data again.
For example if the staff searches | Beta | John | 2016/11 |, the staff will only be able to view the data and the DISABLED buttons. The staff will not be able to submit the new data. The reason for this is because if status of the data is âOfficialâ, it means that it has been finalized and will require the Admin to re-enable the âSubmitâ button again
Only the Admin will be able to re-enable the Submit button by clicking on the âRE-SUBMITâ button. The Admin will have to search for the data that was submitted as âOfficialâ to only be able to click on the âRE-SUBMITâ button. When the Admin clicks on the âRE-SUBMITâ button the status of the of the searched Data will once again be changed to âPendingâ in order to allow the staff to re-submit input.
Logic
This is just the logic of the desired solution. This isnât the actual codes that I was implementing. It is just used to give a clearer picture of the Web Description.
(StatusQuery)
SELECT status
FROM SchoolData sd
WHERE SelectedClass = sd.Class
AND SelectedTeacher = sd.Teacher
AND SelectedYearMonth = sd.YearMonth
if((StatusQuery) == "Official"){
set.(btn.Submit).disabled
set.(btn.Draft).disabled
set.(btn.ReSubmit).enabled
}else if((StatusQuery) == "Draft"){
set.(btn.Submit).enabled
set.(btn.Draft).enabled
set.(btn.ReSubmit).disabled
}
Additional Notes
Iâm very new to PHP and JQuery, like few days new and I had to take over from a previous developer. This link Disable submit button unless original form data has changed is quite similar but its solution will enable the Submit button once input is changed.
Whereas I only want the Admin to re-enable the Submit button through the RE-SUBMIT button. And if the RE-SUBMIT button has been clicked for the selected data, it will change the Status of the data to âDraftâ in order to allow the Staff to once again submit new data. Not only that but my intentions are to disable the Submit button once the data for the Selected Class, Teacher, and Year/Month has been submitted.
Meaning that, if I were to enter Data for ID 1 as shown in the Database but I click on the âSubmitâ button instead of the âDraftâ button. The data saved will have the status âOfficialâ. Once the status of the data is âOfficialâ no one can ever submit data for that again.