Continuation of Help with asynchronous request script

Asked

Viewed 78 times

0

I solved with the help of Marcos Brinner, the problem with Detepicker according to previous post.

But he painted another doubt regarding asynchronous request, between the Detepicker (Calendar) and the Schedules.

I thought that following the reasoning of the other previous requests, could bring the hours of individual care of each professional, selecting the desired date and available in your calendar. But to no avail.

Relying on the help of friends to understand why, I’m posting a provisional address so that friends can see what is happening (or rather, what is not happening).

At the address friends can download the files used and also the images of the tables Calendar and Times.

From now on I thank you all for your attention to my problem.

  • Have you tested if the date is picking correctly from the datepicker? Try so var cod_Calendario = $('#datepicker').datepicker('getDate');

  • Hello Dobrychtop, I did what you suggested and now he is bringing me only ID 1 and 12, both with values "0" in the "cod_calendario" column. You can take a look there at the provisional address, because I left with your suggestion, thanks?

1 answer

1


Come on, first, as soon as the user selects a caledario, in addition to returning the format of it, you can put the ID of the calendar in a hidden field, to use it later for the search of the schedules.

To get the datepicker date from jQuery UI you need to do so

var data = $('#datepicker').datepicker('getDate');
data =  $.datepicker.formatDate('yy-mm-dd', data);

More information: https://api.jqueryui.com/datepicker/#method-getDate

This way you will take the date, and format it to ISO_8601(yy-mm-dd), which is the default write in the database.

Your database is not following the formal rules, I put in DRIVE one DER and an image of what it should look like, it’s not 100% in the rules, for example, the date writes right into the table agendar, it could be recorded and an external table and passed only the ID from it to the agendar.

More about formal rules: https://imasters.com.br/artigo/7020/banco-dados/modelling-de-dados-final-normalized/? trace=1519021197&source=single

When you record a query, you change the status from time to unavailable, and compare it in consultations, to bring only the available schedules, can leave 0 to available and 1 to unavailable, you choose.

In this case your query is like this, but you will need to change it if normalize the comic

"SELECT * FROM calendarios as c inner join horarios as h where c.cod_calendario = " . $_POST['cod_prof']. " and h.status = 0"; 

I hope this helps!

  • I inserted the line you suggested Dobrychtop, but without success. I updated the files with the change made, if you want to analyze, OK. I noticed that both in Specialties and in Professionals, I’m using Option with Value validated, could be because Datepicker is an Input and consequently without any Value valid???

  • The user will select a date, correct? Are you comparing this date selected by the user with any date in your database? In its nomenclature, what the cod_calendario alert(cod_calendario); to test if the date picks correctly.

  • What I would like, but I have no idea how to do or even research, would be to create a query schedule of the following form: the professional, after that the system shows me a calendar with the service days available to the selected professional. If all times relating to the day are scheduled, the day would become unavailable for selection in the calendar.

  • If any scheduling has already taken place for a given day, this scheduled time will no longer appear for selection, with only times available for that day. Have an idea of where I can research this?.

  • You are on the way, I could help more knowing the structure of your database, but seeing what you already have, only missing the last part, your calendar is already letting select only the days available, correct?

  • Now you already have the day that the user selected, just make a query in your schedule table, comparing the date that the user chose, and then bring the available times that selected day, you could have a "status" column of the time, to know if he is selected or not.

  • You can create a table to cross-reference the data, in it goes the ID of the professional and the ID of the time, for you to know which professional has scheduled what time.

  • I’m posting to download by provisional address the structure of the comic, thanks?

Show 4 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.