Defining work days and work time

I’m working on development of SMS parking software, and I’m stuck at one point for a month… I need to implement periods of payment (or work time, of a work day, if you will). Here’s the problem:

For an example, traffic wardens work from Monday to Saturday. From Monday to Friday, the work times are from 07:00 to 21:00, and on Saturday, the work time is from 07:00 to 14:00. The project request was, that the customer can pay parking by SMS unlimited, which I did, but didn’t implement this logic. I started with making a table for this periods of payment, it consists of: dayofweek (INT, for use with mysql function DAYOFWEEK, to tell me which day in week is the current date), work_start and work_stop (DATETIME, for defining starting and ending the work day), but I’m unsure if I should use DATETIME, beacuse of the date, or should I use only TIME.

The idea is this:

If you send an SMS, at 20:50, Monday, it should be valid until 07:50, Tuesday (it’s payed by the hour). Extending the time of payment, regarding the work time in week. Currently, it works with extending time by the hour without this rule. Really would use some help, or some ideas, I’m stuck with this for quite some time…

8

I believe it would be much easier to have a table that stores for every hour (assuming that is your resolution) whether parking is billed (=1) or free (=0). Then iterate over the time your customer paid for by subtracting the value until his credit is used up to determine the last admissible period.

I would even suggest using two tables: the first one for the regular weekly schedule, and the second one for holidays. That way, you can easily keep track of holidays and adapt it quickly (e.g. for special events that offer free parking, etc), while being able to manage a default pattern very conveniently as well. You would need to multiply both values (a binary AND statement), then proceed as above.

You need your program code logic to implement paid time periods. If you allow for payment on one day to carry over to the next, you really want to have two records of “paid time.”

(After all, what happens when someone pays on Friday Dec 29th, and doesn’t pick up their car until Tuesday Jan 2nd, after two weekends and a holiday in a separate year? And the car park wants to know their revenue by month, quarter, and year?)

When you serialize the information to a database, you’ll want two tables anyway. “SMS payments” and “parking time”, which allows for future payments for other things (i.e., SMS to pay the higher rate for a ticket) as well as legal parking for other reasons (employee/resident guests, promotional coupons, etc.)

Alternately, if the parking garage has a slick system for tracking what times cars enter and leave, you can just record the events, extract a bill, and compare it to the record of payments, be they by SMS or not. One “SMS payment” would give a credit for 60 minutes (or 3600 seconds, depending on your resolution), and if the car has recorded time without payments they get the second, higher, rate for not paying on time.

The easiest way to take the payment periods (working hours) into account is to turn the things around and store the periods during which parking is free.

Then you can adjust the valid_from and valid_to timestamps using an algorithm like this:

if (active_payment)
    valid_from = active_payment.valid_to
else
    valid_from = now
if (valid_from in free_parking_period)
    valid_from = free_parking_period.end
valid_to = valid_from + 1 hour
if (valid_to in free_parking_period)
    valid_to = free_parking_period.end + (valid_to - free_parking_period.start)

For storing the free parking periods, I would just go with the simplest solution of two DATETIME columns with the start and end of each period. If there is free parking on Sundays and public holidays, this will amount to approximately 300 entries for a year.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật