I'm very new in this site. Spend a lot of time for searching an answer for my target, but unsuccessfully. So, there it is (sorry for my english):
I'm quite new in php, but already created nice stuff. But now I'm interested in calendar with time slot reservation. I saw good exemple then I registered for my doctor. There i was able to choose a day from calendar and then select a free time range (e.g. from 12:00 to 12:30).
First idea for this is some calendar in PHP and table in MySQL. In MySQL table few rows with id, name and quantity. id - unique number of row, name - date and time slot, and quantity - (1 = free cell, 0 = unable). In PHP calendar after selecting a free time slot, in DB quantity goes from 1 to 0 and apear unavailable for other users.
But if where are a lots of "doctors"? How to make calendar, DB for thousands of them?
For the beggining maybie someone have some example how to make calendar with time reservation (e.g. 1 hour) in the easiest way? Or suggest something?
Related
I have created my first php system, it basically is a list of customers which the user can select and log work for which generates a PDF work record.
I want to extend it to generate an invoice every Thursday midnight and send it to the business, eg:
User 1 has worked:
Customer a - 1 hour
Customer c - 2 hours
Customer D - 4 hours
Total 7 hours at (Chargeable rate).
Now in my head it seems pretty straight forward but I want to sense check it with people it possible:
When the PDF is generated I need to store the information in a new table, User ID, Customer name, Hours worked, Time & date. Then each Thursday I need a script to run which will transfer the entries from the database (over the past X days - could I say from ID X which was the last ID to be ran in the previous pdf?) to a PDF, save the pdf to the server and email it to me.
A few questions:
Would It be beneficial to clear this data after X day so the DB doesn't get too big?
What is the best way to ensure that an entry doesn't get missed? I will most likely run the script every thursday at midnight, but I'm guessing theres room for error there if somebody submits an entry at the same time? (slim chance but possible)
I'll be using mPDF for the invoice generation which I already use.
I want to create a website with an scheduling calendar.
My first idea is to use some free calendar template or download some free scheduling calendar. Then in my scheduling form, when someone request for an schedule, I will get the date he/she input and save it into the database then show it to the scheduling calendar.
But someone told me that, in my database, I should create a calendar table.
Which is the best way around?
The first one with only one table for schedule on my database or the second one with two tables for schedule and calendar?
I hope you get my idea.
It could be first one. One of option is to keep data by day of year.
you can draw your own calendar by counting day of year
actual day of yaer - date('z') + 1; //+ 1 because it is an array it starts from 0
then you can get number of days in each month
cal_days_in_month
and loop it x 12 with
here will be day of month with css style so it looks like calendar field
your i++ will bee number of days in month of course.
Keep records in database by year and day of year. you can do so much things this way
For an art project I am trying to set up an order site.
The concept allows users to book a max. of two time slots with each artist. There are 12 slots per artist, but each slot with a specific definition (so each is unique). The slots are only available for a very limited time and hopefully booked fast. So there will be a lot of requests in a short period of time. I have to make sure each article/slot is only offered to a single user at a time and cannot be double booked.
My idea was, to check for the next unbooked slot(s) (status="free) and on that request update the status of the corresponding row in the table to status="locked". If the user proceeds to actually book the slot, the status is updated to "booked".
If a user clicks "cancel" I can release the article by updating the row to status="free".
However, it is not unlikely that users just abandon the site and I don't see a way to check for that. The slot would remain "locked". I was thinking, there might be a way to automatically reset the status e.g. 120 seconds after is was "locked" and show a countdown to the users. This could even enhance the excitement factor.
I don't think a cron job would work as I need the anchor to be the last update of the row and not a specific datetime.
I looked into MySQL events but understood that I cannot manipulate the data of the table it is attached to.
I would greatly appreciate any ideas.
Thanks,
Sam
In your db your status table add a datetime field.
When someone lock a slot you also save the current time using NOW()
When someone consult the slots you perform and update and free the inactive slots
Update slots
SET locked = false
WHERE `datetime`> NOW() - INTERVAL 15 MINUTE;
SELECT *
FROM slots
WHERE locked = false;
I am creating a system that requires a schedular for a particular task. Users may pick from times 24 hours a day, 7 days a week.
I came up with a few options for the database storage, but I don't think either one is the most efficient design, so I'm hoping for some possible alternatives that may be more efficient.
On the user side I created a grid of buttons with 2 loops to create the days, and the times, and I set each a unique value of $timeValue = "d".$j."-t".$i;
So d1-t0 will be Saturday at Midnight d3-t12= Tuesday at Noon, and so forth.
So, in the database I was first going to simply have a ID, day, time set up, but that would result in a possible 168 rows per event
Then I tried an ID, day, and time 0-23 (a column for each hour of the day) And I was simply going to have a boolean set up. 0 if not selected, 1 if it is.
This would result in 7 rows per event, but I think querying that data might be a pain.
I need to perform a few functions on this data. On each day, list the number of selected times into an array. But I don't believe having a select statement of SELECT * from schedule where time0, =1 or time1= 1 .... ect will work, nor will it produce the desired array. (times=(0,3,5,6,7...)
So, this isnt going to work well.
My overall system will need to also know every event that has each time selected for a mass posting.
"Select * from table where time = $time (0-23) and day= $day (1-7)
Do action with data...
So with this requirement, I'm going to assume that storing the times as an array within the database is likely not the most efficient way either.
So am I stuck with needing up to 168 rows of data per event, or is there a better way I am missing? Thanks
Update:
To give a little more clarity on what I need to accomplish:
Users will be creating event campaigns in which other users can bid on various time slots for something to happen. There will likely be 10-100 thousand of these campaigns at any one time and they are ongoing until the creator stops them. The campaign creators can define the time slots available for their campaign.
At the designated time each day the system will find every campaign that has an event scheduled and perform the event.
So the first requirement is to know which time slots are available for the campaign, and then I need the system to quickly identify campaigns that have an event on each hour and day and perform it automatically.
So, I've previously developed an employee scheduling system in php. It was VERY inefficient. When I created a new schedule, I generated a row in a table called 'schedules' and, for every employee affected by that schedule, I generated a row in a table called 'schedule_days' that gave there start and stop time for that specific date. Also, editing the schedules was a wreck too. On the editing page, I pulled every user from the database from the specific schedule and printed it out on the page. It was very logical, but it was very slow.
You can imagine how long it takes to load around 15 employees for a week long schedule. That would be 1 query for the schedule, 1 query for each user, and 7 queries for each day for every user.. If I have 15 users thats too many queries. So I'm simply asking, whats someone else's view on the best way to do this?
For rotation based schedules, you want to use an exclusion based system. If you know that employee x works in rotation y within date range z, then you can calculate the individual days for that employee on the fly. If they're off sick/on course/etc., add an exclusion to the employee for that day. This will make the database a lot smaller than tracking each day for each employee.
table employee {EmployeeID}
table employeeRotations {EmployeeRotationID, EmployeeID, RotationID, StartDate, EndDate}
table rotation {RotationID, NumberOfDays, StartDate}
table rotationDay {RotationDayID, RotationID, ScheduledDay, StartTime, EndTime}
table employeeExceptions {EmployeeExceptionID, ExceptionDate, ExceptionTypeID (or whatever you want here)}
From there, you can write a function that returns On/Off/Exception for any given date or any given week.
Sounds like you need to learn how to do a JOIN rather than doing many round trips to the server for each item.