Calendar Price list?
Problem: The price number information can not correspond to the array of the date to display (such as the array has 2013-10-12 and 2013-10-21 only price and number, but the program will be displayed in turn from the start date, not in the generated calendar within the corresponding date), there are experts please point out, The more you change the logic, the more confusing.
Now the 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 Create ($product _id, $date, $prices) {
$this->product_id = $product _id;
$this->original_date = $this->date = strtotime ($date);
$this->prices = $prices;
$this->_init ();
$DATESTMP = Array_keys ($this->prices);
$this->lastdate = Array_pop ($DATESTMP);
}
/**
* Next one months
*
*/
function Createnext () {
$this->nextdate = $date; Next month, awaiting treatment
$this->create ($this->nextdate);
}
function Getnextmonth ($tmp _date, $step = 1) {
Cut out year
$tmp _year= Date (' Y ', $tmp _date);
Cut out Month
$tmp _mon =date (' m ', $tmp _date);
$tmp _nextmonth=mktime (0,0,0, $tmp _mon + $step, 1, $tmp _year);
Get the start of the next month for the next 2 months of the current month, the latest date
return $tmp _nextmonth;
}
function Getpremonth ($tmp _date, $step = 1) {
Cut out year
$tmp _year= Date (' Y ', $tmp _date);
Cut out Month
$tmp _mon =date (' m ', $tmp _date);
$tmp _premonth=mktime (0,0,0, $tmp _mon-$step, 1, $tmp _year);
Get the last one months 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 start date
}
/**
* Get 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;
for ($i = 0; $i < $this->count; $i + +) {
-