Calendar price list? Problem: The price quantity information cannot be displayed only when it is corresponding to the date in the array (for example, the price and number of people are displayed only when the array contains 2013-10-12 and 2013-10-21, but the program displays the price quantity information from the start date in sequence, instead of displaying it in the corresponding date in the generated calendar). If you have any experts, please give us some advice. the more you change, the more chaotic the logic. Now the effect code is like the calendar price list?
Problem: The price quantity information cannot be displayed only when it is corresponding to the date in the array (for example, the price and number of people are displayed only when the array contains 2013-10-12 and 2013-10-21, but the program displays the price quantity information from the start date in sequence, instead of displaying it in the corresponding date in the generated calendar). If you have any experts, please give us some advice. the more you change, the more chaotic the logic.
Current effect
The code is as follows:
Class productDate {
Var $ product_id = '';
Var $ date = '';
Var $ original_date = '';
Var $ nextDate = '';
Var $ prices = '';
Var $ count = 42;
Var $ nowWeek;
Var $ nowMonth;
Var $ nextMonth;
Var $ startDate;
Var $ lastDate;
Function getNextMonth ($ tmp_date, $ step = 1 ){
// Cut year
$ Tmp_year = date ('Y', $ tmp_date );
// Cut Out Month
$ Tmp_mon = date ('M', $ tmp_date );
$ Tmp_nextmonth = mktime (0, 0, $ tmp_mon + $ step, 1, $ tmp_year );
// Obtain the next two months of the current month, starting from the next month of the latest date
Return $ tmp_nextmonth;
}
Function getPreMonth ($ tmp_date, $ step = 1 ){
// Cut year
$ Tmp_year = date ('Y', $ tmp_date );
// Cut Out Month
$ Tmp_mon = date ('M', $ tmp_date );
$ Tmp_premonth = mktime (0, 0, $ tmp_mon-$ step, 1, $ tmp_year );
// Obtain the previous month of the current month
Return $ tmp_premonth;
}
/**
* Initialization parameters
*
*/
Function _ init (){
$ This-> nowWeek = date ('W', $ this-> date );
$ This-> nowMonth = date ('M', $ this-> date );
$ This-> nextMonth = date ('M', $ this-> date + 86400 * $ this-> count );
$ This-> startDate = $ this-> date-86400 * $ this-> nowWeek; // get the start date
}
/**
* Getting html
*
*/
Function getHtml (){
$ Box = $ this-> getBox ();
While ($ this-> getNextMonth ($ this-> date, 2) <$ this-> lastDate ){
$ This-> date = $ this-> getNextMonth ($ this-> date );
$ This-> _ init ();
$ Box. = $ this-> getBox ();
}
Return <
Product_id} ">
{$ Box}
EOF;
}
/**
* Get calendar blocks
*
*/
Function getBox (){
$ Result =' ';
$ StartDate = $ this-> startDate;
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service