Calendar Price List

Source: Internet
Author: User
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 + +) {

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.