function update_business_days() { $general = wc2_get_option('general'); $datetimestr = get_date_from_gmt(gmdate('Y-m-d H:i:s', time())); $dhour = (int) substr($datetimestr, 11, 2); $dminute = (int) substr($datetimestr, 14, 2); $dsecond = (int) substr($datetimestr, 17, 2); $dmonth = (int) substr($datetimestr, 5, 2); $dday = (int) substr($datetimestr, 8, 2); $dyear = (int) substr($datetimestr, 0, 4); $dtimestamp = mktime($dhour, $dminute, $dsecond, $dmonth, $dday, $dyear); $datenow = getdate($dtimestamp); //list($year, $mon, $mday) = wc2_get_beforemonth($datenow['year'], $datenow['mon'], $datenow['mday'], 1); list($year, $mon, $mday) = wc2_get_beforemonth($datenow['year'], $datenow['mon'], 1, 1); if (isset($general['business_days'][$year][$mon][1])) { unset($general['business_days'][$year][$mon]); } for ($i = 0; $i < 12; $i++) { //list($year, $mon, $mday) = wc2_get_aftermonth($datenow['year'], $datenow['mon'], $datenow['mday'], $i); list($year, $mon, $mday) = wc2_get_aftermonth($datenow['year'], $datenow['mon'], 1, $i); $last = wc2_get_lastday($year, $mon); for ($j = 1; $j <= $last; $j++) { if (!isset($general['business_days'][$year][$mon][$j])) { $general['business_days'][$year][$mon][$j] = 1; } } } wc2_update_option('general', $general); $_SESSION[WC2]['checked_business_days'] = ''; }
function setCalendarData() { $day = 1; // 当月開始日に設定 $firstw = wc2_get_week($this->_year, $this->_month, $day); // 当月開始日の曜日 $lastday = wc2_get_lastday($this->_year, $this->_month); // 当月最終日 $lastw = wc2_get_week($this->_year, $this->_month, $lastday); // 当月最終日の曜日 // 1週目 for ($d = 0; $d <= 6; $d++) { if ($firstw == $d) { $this->_date[0][$d] = sprintf("%04d-%02d-%02d", $this->_year, $this->_month, $day); $this->_datetext[0][$d] = $day; } elseif ($firstw < $d) { list($this->_year, $this->_month, $day) = wc2_get_nextday($this->_year, $this->_month, $day); $this->_date[0][$d] = sprintf("%04d-%02d-%02d", $this->_year, $this->_month, $day); $this->_datetext[0][$d] = $day; } else { $this->_date[0][$d] = ""; $this->_datetext[0][$d] = ""; } } // 2~4週目 for ($d = 0; $d <= 6; $d++) { list($this->_year, $this->_month, $day) = wc2_get_nextday($this->_year, $this->_month, $day); $this->_date[1][$d] = sprintf("%04d-%02d-%02d", $this->_year, $this->_month, $day); $this->_datetext[1][$d] = $day; } for ($d = 0; $d <= 6; $d++) { list($this->_year, $this->_month, $day) = wc2_get_nextday($this->_year, $this->_month, $day); $this->_date[2][$d] = sprintf("%04d-%02d-%02d", $this->_year, $this->_month, $day); $this->_datetext[2][$d] = $day; } for ($d = 0; $d <= 6; $d++) { list($this->_year, $this->_month, $day) = wc2_get_nextday($this->_year, $this->_month, $day); $this->_date[3][$d] = sprintf("%04d-%02d-%02d", $this->_year, $this->_month, $day); $this->_datetext[3][$d] = $day; } // 5週目 for ($d = 0; $d <= 6; $d++) { if ($lastday == $day) { break; } else { list($this->_year, $this->_month, $day) = wc2_get_nextday($this->_year, $this->_month, $day); $this->_date[4][$d] = sprintf("%04d-%02d-%02d", $this->_year, $this->_month, $day); $this->_datetext[4][$d] = $day; } } if (0 < $d && $d <= 6) { while ($d <= 6) { $this->_date[4][$d] = ""; $this->_datetext[4][$d] = ""; $d++; } } elseif ($d !== 0) { // 6週目 for ($d = 0; $d <= 6; $d++) { if ($lastday == $day) { break; } else { list($this->_year, $this->_month, $day) = wc2_get_nextday($this->_year, $this->_month, $day); $this->_date[5][$d] = sprintf("%04d-%02d-%02d", $this->_year, $this->_month, $day); $this->_datetext[5][$d] = $day; } } if ($d > 0) { while ($d <= 6) { $this->_date[5][$d] = ""; $this->_datetext[5][$d] = ""; $d++; } } } $this->_row = count($this->_date); }