Page 1 of 1
Reservation add limit
Posted: Tue Aug 06, 2013 4:35 pm
by ZeR0C00L
i use phpmaker simple reservation form but i need help because i known I know the initial level of php.
I get a reservation for a variety of occasions but i need to limit. would like to bring a certain limit for the same day.
I want to make a reservation to be entered to allow 40 per day
ut I do not have any idea of how to do
i use this database sample
CREATE TABLE IF NOT EXISTS reservations
(
ID
int(11) NOT NULL AUTO_INCREMENT,
Arrival Date
date DEFAULT NULL,
Arrival Time
tinytext,
Name Surname
tinytext,
Room Number
tinytext,
Adult Guest
int(11) DEFAULT NULL,
Children Guest
int(11) DEFAULT NULL,
VIP Guest
tinytext,
Reservation Officer
tinytext,
Chicken
int(11) DEFAULT NULL,
Fish
int(11) DEFAULT NULL,
Antrikot
int(11) DEFAULT NULL,
Additional Requests & Notes
text,
ResponseDateTime
timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (ID
)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1009 ;
Additional Requests & Notes
text CHARACTER SET utf8 COLLATE utf8_bin,
ResponseDateTime
timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (ID
)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1009 ;
Re: Reservation add limit
Posted: Wed Aug 07, 2013 12:23 pm
by danielc
You can add a check in your reservation table Page_Load server event.
$count = ew_ExecuteScalar("SELECT COUNT(*) FROM yourtable WHERE ... "); // to count the record inserted for today.
If count is exceed your limit, perform your action.
Re: Reservation add limit
Posted: Wed Aug 07, 2013 2:34 pm
by ZeR0C00L
danielc wrote:
You can add a check in your reservation table Page_Load server event.
ew_ExecuteScalar("SELECT COUNT(*) FROM yourtable WHERE ... "); //
to count the record inserted for today.
If count is exceed your limit, perform your action.
ew_ExecuteScalar("SELECT COUNT(*) FROM Arrival Date ");
not working :(
Re: Reservation add limit
Posted: Thu Aug 08, 2013 11:09 am
by danielc
ZeR0C00L wrote:
ew_ExecuteScalar("SELECT COUNT(*) FROM Arrival Date ");
Your syntax is not correct.
ew_ExecuteScalar("SELECT COUNT(*) FROM reservations WHERE ... "); // assume your table is reservations and put your condition if it is Arrival Date after WHERE,
// to get current date use date('Y/m/d') if your date format is YYYY/mm/dd
Re: Reservation add limit
Posted: Fri Aug 09, 2013 3:10 am
by mobhar
Put the following complete code in your Page_Load:
$val = ew_ExecuteScalar("SELECT COUNT(*) FROM reservations
WHERE Arrival Date
= '".date("Y-m-d")."'");
if ($val > 4) {
$this->setFailureMessage("Sorry, the reservation has been closed for today!");
$this->Page_Terminate("reservationslist.php");
}
Just tried it here, and it works properly.
Re: Reservation add limit
Posted: Fri Aug 09, 2013 4:20 am
by ZeR0C00L
yes mate it is works :) but this is not control arrival date when is count 40 i cant make new reservation any other date because not opening reservationsadd.php "Sorry, the reservation has been closed for today!" but not today :)
Re: Reservation add limit
Posted: Sun Aug 11, 2013 5:52 pm
by mobhar
Change this:
if ($val > 4) {
become this:
if ($val > 40) {
Re: Reservation add limit
Posted: Sun Aug 11, 2013 9:06 pm
by ZeR0C00L
mate 4 or 40 it does not matter when this count 4 or 40 can not make new reservation any other date. i need control day by day. but this script make limit 40 reservation limit restrict all days
i need to do this
Sunday - 40 Reservation limit
Monday - 40 Reservation limit
Tuesday - 40 Reservation limit
Wednesday - 40 Reservation limit
Thursday - 40 Reservation limit
Friday - 40 Reservation limit
Saturday - 40 Reservation limit
Re: Reservation add limit
Posted: Sun Aug 11, 2013 11:48 pm
by mobhar
The SQL I gave you before has the functionality for calculating the count of reservation day to day.
"SELECT COUNT(*) FROM reservations
WHERE Arrival Date
= '".date("Y-m-d")."'"
See date("Y-m-d") inside the SQL. The date() function will be converted based on the day you accessed your web app. So, if for example, today is August 11, 2013, then the SQL above will be executed become:
"SELECT COUNT(*) FROM reservations
WHERE Arrival Date
= '2013-08-11'"
The same way also for the other date, such as August 12, 2013 (if you are accessing your web app on that day), then the SQL will be executed as:
"SELECT COUNT(*) FROM reservations
WHERE Arrival Date
= '2013-08-12'"
and so on.
Hopefully, the explanation above is clear enough now.