本文整理汇总了PHP中getDaysInMonth函数的典型用法代码示例。如果您正苦于以下问题:PHP getDaysInMonth函数的具体用法?PHP getDaysInMonth怎么用?PHP getDaysInMonth使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getDaysInMonth函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cal
function cal($month, $year)
{
global $weekstarts, $display_day;
$display_day="1111111";
if (!isset($weekstarts)) $weekstarts = 0;
$s = "";
$daysInMonth = getDaysInMonth($month, $year);
$date = mktime(12, 0, 0, $month, 1, $year);
$first = (strftime("%w",$date) + 7 - $weekstarts) % 7;
$monthName = utf8_strftime("%B",$date);
$s .= "<table class=\"calendar2\" border=\"1\" cellspacing=\"3\">\n";
$s .= "<tr>\n";
$s .= "<td class=\"calendarHeader2\" colspan=\"7\">$monthName $year</td>\n";
$s .= "</tr>\n";
$d = 1 - $first;
$is_ligne1 = 'y';
while ($d <= $daysInMonth)
{
$s .= "<tr>\n";
for ($i = 0; $i < 7; $i++)
{
$basetime = mktime(12,0,0,6,11+$weekstarts,2000);
$show = $basetime + ($i * 24 * 60 * 60);
$nameday = utf8_strftime('%A',$show);
$temp = mktime(0,0,0,$month,$d,$year);
if ($i==0) $s .= "<td class=\"calendar2\" style=\"vertical-align:bottom;\"><b>S".numero_semaine($temp)."</b></td>\n";
$s .= "<td class=\"calendar2\" align=\"center\" valign=\"top\">";
if ($is_ligne1 == 'y') $s .= '<b>'.ucfirst(substr($nameday,0,1)).'</b><br />';
if ($d > 0 && $d <= $daysInMonth)
{
$s .= $d;
$day = grr_sql_query1("SELECT day FROM ".TABLE_PREFIX."_calendrier_jours_cycle WHERE day='$temp'");
$s .= "<br /><input type=\"checkbox\" name=\"$temp\" value=\"$nameday\" ";
if (!($day < 0)) $s .= "checked=\"checked\" ";
$s .= " />";
} else {
$s .= " ";
}
$s .= "</td>\n";
$d++;
}
$s .= "</tr>\n";
$is_ligne1 = 'n';
}
$s .= "</table>\n";
return $s;
}
示例2: slctDate
function slctDate()
{
db_connect();
#check what we have permission to
$get_perm = "SELECT payroll_groups FROM users WHERE username = '{$_SESSION['USER_NAME']}' LIMIT 1";
$run_perm = db_exec($get_perm) or errDie("Unable to get payroll groups permission information.");
if (pg_numrows($run_perm) > 0) {
$parr = pg_fetch_array($run_perm);
if (strlen($parr['payroll_groups']) > 0) {
$pay_grps = explode(",", $parr['payroll_groups']);
if (is_array($pay_grps)) {
$egsearch = " AND (emp_group = '" . implode("' OR emp_group = '", $pay_grps) . "')";
}
} else {
$egsearch = "AND false";
}
}
$sql = "SELECT enum,empnum, sname, fnames FROM employees WHERE div = '" . USER_DIV . "' {$egsearch} ORDER BY sname";
$empRslt = db_exec($sql) or errDie("Unable to select employees from database.");
if (pg_numrows($empRslt) < 1) {
// return "No employees found in database.<p>"
// .mkQuickLinks();
}
$employees = array("0" => "All");
while ($d = pg_fetch_array($empRslt)) {
$employees[$d["empnum"]] = "{$d['sname']}, {$d['fnames']} ({$d['enum']})";
}
$fields = array("empnum" => 0, "from_year" => DATE_YEAR, "from_month" => DATE_MONTH, "from_day" => 1, "to_year" => DATE_YEAR, "to_month" => DATE_MONTH, "to_day" => getDaysInMonth(DATE_MONTH, DATE_YEAR));
foreach ($fields as $fname => $dflt) {
if (!isset(${$fname})) {
${$fname} = $dflt;
}
}
$OUT = "\n\t\t<h3>Select date range to view</h3>\n\t\t<form action='" . SELF . "' method='POST'>\n\t\t<table " . TMPL_tblDflts . ">\n\t\t\t<input type='hidden' name='key' value='slip'>\n\t\t\t<tr>\n\t\t\t\t<th>Employee</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td align='center'>" . extlib_cpsel("empnum", $employees, $empnum) . "</td>\n\t\t\t</tr>\n\t\t\t<tr><th colspan='2'>Date Range</th></tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td align='center' colspan='2'>\n\t\t\t\t\t" . mkDateSelect("from", $from_year, $from_month, $from_day) . "\n\t\t\t\t\t TO \n\t\t\t\t\t" . mkDateSelect("to", $to_year, $to_month, $to_day) . "\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td colspan='2' align='right'><input type='submit' value='View »'></td>\n\t\t\t</tr>\n\t\t</table>\n\t\t</form>" . mkQuickLinks();
return $OUT;
}
示例3: afterLastDayInMonth
function afterLastDayInMonth($curYear, $year, $month, $day)
{
$days_in_month = getDaysInMonth($month);
for ($i = $days_in_month; $i > $days_in_month - 8; $i--) {
if (date("D", mktime(0, 0, 0, $month, $i)) == $day) {
$last_day = $i;
break;
}
}
$curDay = gmdate("d");
$curMonth = gmdate("m");
$curHour = gmdate("H");
$cur_stamp = mktime($curHour, 0, 0, $curMonth, $curDay, $curYear);
$last_day_stamp = mktime(1, 0, 0, $month, $last_day, $year);
if ($cur_stamp >= $last_day_stamp) {
return true;
}
return false;
}
示例4: foreach
$catFirstChildren = $oCat->getFirstChildren($cat_id);
foreach ($catFirstChildren as $value) {
$tabCat["{$value}"] = $oCat->getAllChildren($value);
}
// initialisation du tabeau pour le total de chaque année
foreach ($catFirstChildren as $value) {
$name = $oCat->getName($value);
$cat_fils_annee["{$name}"] = 0;
// total pour l'année
}
// Boucle sur les mois
$cat_fils_mois_max = 0;
for ($i = 1; $i <= 12; $i++) {
// Initialisation
$date_debut = mktime(0, 0, 0, "{$i}", '01', '2008');
$day = getDaysInMonth($i, 2008);
$date_fin = mktime(0, 0, 0, "{$i}", "{$day}", '2008');
foreach ($catFirstChildren as $value) {
$name = $oCat->getName($value);
$cat_fils_mois["{$name}"][$i] = 0;
}
$cat_annee[$i] = 0;
$query = "SELECT * FROM transactions WHERE\r\n date >= {$date_debut} AND\r\n date <= {$date_fin}";
$result = $mysql->query($query);
while ($line = mysql_fetch_assoc($result)) {
extract($line);
if ($valeur > 0) {
continue;
}
$valeur *= -1;
foreach ($catFirstChildren as $value) {
示例5: generateMonthView_small
function generateMonthView_small($month, $year, $view_diary)
{
global $_GET;
$OUTPUT = "\r\n\t\t<table width=190 cellspacing=0>\r\n\t\t\t<tr>\r\n\t\t\t\t<td height=20 align=center " . TMPL_calSmallMonthTitleStyle . "\r\n\t\t\t\t\t\tonClick='document.location.href=\"" . SELF . "?key=month&month={$month}&year={$year}\"'>\r\n\t\t\t\t\t<b>" . getMonthText($month) . " {$year}</b>\r\n\t\t\t\t</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<td align=center " . TMPL_calSmallMonthBodyStyle . ">";
// generate the titles of the weekdays
$OUTPUT .= "\r\n\t\t\t<table width='184' cellspacing=0>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td width=23> </td>\r\n\t\t\t\t\t<td width=23 align=center><b>M</b></td>\r\n\t\t\t\t\t<td width=23 align=center><b>T</b></td>\r\n\t\t\t\t\t<td width=23 align=center><b>W</b></td>\r\n\t\t\t\t\t<td width=23 align=center><b>T</b></td>\r\n\t\t\t\t\t<td width=23 align=center><b>F</b></td>\r\n\t\t\t\t\t<td width=23 align=center bgcolor=" . TMPL_calFillSaturday . "><b>S</b></td>\r\n\t\t\t\t\t<td width=23 align=center bgcolor=" . TMPL_calFillSunday . "><b>S</b></td>\r\n\t\t\t\t</tr>";
// get the weekday number of the first of this month
$first_wd = getWeekdayNum(1, $month, $year);
// the following code will generate the first entries on the calendar, which is for the previous month (if any)
// month and year of previous month
if ($month == 1) {
$tmp_month = 12;
$tmp_year = $year - 1;
} else {
$tmp_month = $month - 1;
$tmp_year = $year;
}
// date of last monday in previous month (where the entries will start)
if ($first_wd > 1) {
$tmp_day = getDaysInMonth($tmp_month, $tmp_year) - ($first_wd - 2);
} else {
$tmp_day = 1;
$tmp_month = $month;
$tmp_year = $year;
}
// create a view variables
$selected_month = $_GET["month"];
// create the previous month's entries
$c_weeknum = getWeekNumber($tmp_day, $tmp_month, $tmp_year);
$selected_weeknum = getWeekNumber($_GET["mday"], $_GET["month"], $_GET["year"]);
// if today's week number = the current generated week's number, hightlight the row, as so with the selected week,
if ($c_weeknum == getTodayWeekNumber() && $tmp_year == date("Y") && $month == date("m") || getTodayWeekNumber() == 0 && $month == date("m") && $year == date("Y")) {
// today's week
$OUTPUT .= "<tr bgcolor='" . TMPL_calSmallMonthCurrentWeek . "'>";
$ROW_COLORED = 1;
} else {
if ($month == $_GET["month"] && $c_weeknum == $selected_weeknum && $month == $_GET["month"] || $c_weeknum == 52 && $selected_weeknum == 0) {
// selected week, the last check is for the first week in jan
$OUTPUT .= "<tr bgcolor='" . TMPL_calSmallMonthSelectedWeek . "'>";
$ROW_COLORED = 1;
} else {
// other dates
$OUTPUT .= "<tr>";
$ROW_COLORED = 0;
}
}
if ($first_wd != 1) {
// only if there is a day in this week of previous month, print the week number
$OUTPUT .= "<td width=23 " . TMPL_calSmallMonthWeekNumberStyle . " align=center>{$c_weeknum}</td>";
}
for ($c_wd = 1; $c_wd < $first_wd; $c_wd++, $tmp_day++) {
// fill differently for saturday and sunday (only when row wasn't already highlighted)
if ($c_wd == 6 && !$ROW_COLORED) {
$dayfill = "bgcolor=" . TMPL_calFillSaturday;
} else {
if ($c_wd == 7) {
$dayfill = "bgcolor=" . TMPL_calFillSunday;
} else {
$dayfill = "";
}
}
$OUTPUT .= "<td {$dayfill} width=23 align=center>\r\n\t\t\t\t\t\t\t<a id='calSmallMonthOMLink' href='" . SELF . "?mday={$tmp_day}&month={$tmp_month}&year={$tmp_year}'>{$tmp_day}</a>\r\n\t\t\t\t\t\t</td>";
}
// start creating this month's entries
$cm_days = getDaysInMonth($month, $year);
for ($c_day = 1; $c_day <= $cm_days; $c_day++) {
$c_weeknum = getWeekNumber($c_day, $month, $year);
if ($c_wd == 1) {
// start a new row (it's MONDAY!!!!!)
// if today's week number = the current generated week's number, hightlight the row, as so with the selected week
if ($c_weeknum == getTodayWeekNumber() && $year == date("Y") && $month == date("m")) {
// today's week
$OUTPUT .= "<tr bgcolor='" . TMPL_calSmallMonthCurrentWeek . "'>";
$ROW_COLORED = 1;
} else {
if ($month == $_GET["month"] && $c_weeknum == $selected_weeknum) {
// selected week
$OUTPUT .= "<tr bgcolor='" . TMPL_calSmallMonthSelectedWeek . "'>";
$ROW_COLORED = 1;
} else {
// other dates
$OUTPUT .= "<tr>";
$ROW_COLORED = 0;
}
}
// attach the week number
$OUTPUT .= "<td align=center width=23 " . TMPL_calSmallMonthWeekNumberStyle . ">{$c_weeknum}</td>";
}
// change the fill color if it it 2day's date we are printing, or the selected date
if ($c_day == $_GET["mday"] && $month == $_GET["month"] && $year == $_GET["year"]) {
// selected date
$dayfill = "bgcolor=" . TMPL_calSmallMonthSelectedDay;
$a_id = "calSmallMonthCMLinkSelected";
} else {
if (date("d") == $c_day && date("m") == $month && date("Y") == $year) {
// 2day's date
$dayfill = "bgcolor=" . TMPL_calSmallMonthCurrentDay;
$a_id = "calSmallMonthCMLinkToday";
} else {
// other dates
//.........这里部分代码省略.........
示例6: generateMonthView_large
function generateMonthView_large($month, $year, $view_diary)
{
global $_GET;
$valid_date = mktime(0, 0, 0, $month, 1, $year);
$month = date("m", $valid_date);
$year = date("Y", $valid_date);
$select_month = "<select name=month>";
for ($i = 1; $i <= 12; $i++) {
if ($month == $i) {
$sel = "selected";
} else {
$sel = "";
}
$select_month .= "<option {$sel} value='{$i}'>" . getMonthText($i) . "</option>";
}
$select_month .= "</select>";
$select_year = "<select name=year>";
for ($i = 1971; $i <= 2028; $i++) {
if ($year == $i) {
$sel = "selected";
} else {
$sel = "";
}
$select_year .= "<option {$sel} value={$i}>{$i}</option>";
}
$select_year .= "</select>";
$OUTPUT = "\r\n\t<table width=600 cellspacing=0>\r\n\t<tr>\r\n\t\t<td align=center style='font-size: 14px; color: #ffffff; font-weight: bold;' colspan=3>\r\n\t\t\t<form method=post action='" . SELF . "'>\r\n\t\t\t<input type=hidden name=key value='month'>\r\n\t\t\tGoto: {$select_month} {$select_year} <input type=submit value='Go'>\r\n\t\t\t</form>\r\n\t\t</td>\r\n\t</tr>\r\n\t<tr><td> </td></tr>\r\n <tr>\r\n \t<td colspan=3 " . TMPL_calTimeStyle2 . ">\r\n \t<table width=100%><tr>\r\n \t<td width=30% align=center valign=middle>\r\n \t\t<a href='" . SELF . "?key=month&month=" . ($month - 1) . "&year={$year}&view_diary={$view_diary}'>\r\n \t\t\t<img src='left_day.gif' border=0>\r\n\t\t\t</a>\r\n\t\t</td>\r\n\t\t<td width=40% valign=middle align=center " . TMPL_calTimeStyleHeader . ">\r\n\t\t\t<b>" . getMonthText($month) . " {$year}</b>\r\n\t\t</td>\r\n\t\t<td width=30% align=center valign=middle>\r\n\t\t\t<a href='" . SELF . "?key=month&month=" . ($month + 1) . "&year={$year}&view_diary={$view_diary}'>\r\n\t\t\t\t<img src='right_day.gif' border=0>\r\n\t\t\t</a>\r\n\t\t</td>\r\n\t\t</tr></table>\r\n\t\t</td>\r\n\t</tr>\r\n\t<tr>\r\n\t\t<td align=center " . TMPL_calLargeMonthBodyStyle . " colspan=3>\r\n\t\t<table width='600' cellspacing=0>\r\n\t\t<tr>\r\n\t\t\t<td width=75 height=60> </td>\r\n\t\t\t<td width=75 height=60 align=center><h1>M</h1></td>\r\n\t\t\t<td width=75 height=60 align=center><h1>T</h1></td>\r\n\t\t\t<td width=75 height=60 align=center><h1>W</h1></td>\r\n\t\t\t<td width=75 height=60 align=center><h1>T</h1></td>\r\n\t\t\t<td width=75 height=60 align=center><h1>F</h1></td>\r\n\t\t\t<td width=75 height=60 align=center bgcolor=" . TMPL_calFillSaturday . "><h1>S</h1></td>\r\n\t\t\t<td width=75 height=60 align=center bgcolor=" . TMPL_calFillSunday . "><h1>S</h1></td>\r\n\t\t</tr>";
// get the weekday number of the first of this month
$first_wd = getWeekdayNum(1, $month, $year);
// the following code will generate the first entries on the calendar, which is for the previous month (if any)
// and year of previous month
if ($month == 1) {
$tmp_month = 12;
$tmp_year = $year - 1;
} else {
$tmp_month = $month - 1;
$tmp_year = $year;
}
// date of last monday in previous month (where the entries will start)
if ($first_wd > 1) {
$tmp_day = getDaysInMonth($tmp_month, $tmp_year) - ($first_wd - 2);
} else {
$tmp_day = 1;
$tmp_month = $month;
$tmp_year = $year;
}
// create a view variables
$selected_month = $_GET["month"];
// create the previous month's entries
$c_weeknum = getWeekNumber($tmp_day, $tmp_month, $tmp_year);
$selected_weeknum = getWeekNumber($_GET["mday"], $_GET["month"], $_GET["year"]);
$OUTPUT .= "<tr>";
if ($first_wd != 1) {
// only if there is a day in this week of previous month, print the week number
$OUTPUT .= "<td width=75 height=60 " . TMPL_calLargeMonthWeekNumberStyle . " align=center>{$c_weeknum}</td>";
}
for ($c_wd = 1; $c_wd < $first_wd; $c_wd++, $tmp_day++) {
// fill differently for saturday and sunday (only when row wasn't already highlighted)
if ($c_wd == 6) {
$dayfill = "bgcolor=" . TMPL_calFillSaturday;
} else {
if ($c_wd == 7) {
$dayfill = "bgcolor=" . TMPL_calFillSunday;
} else {
$dayfill = "";
}
}
$OUTPUT .= "<td {$dayfill} width=75 style='border-bottom: 1px solid #000000;' height=60 align=center>\r\n\t\t\t\t<a id='calSmallMonthOMLink' href='" . SELF . "?mday={$tmp_day}&month={$tmp_month}&year={$tmp_year}'>{$tmp_day}</a>\r\n\t\t\t</td>";
}
// start creating this month's entries
$cm_days = getDaysInMonth($month, $year);
for ($c_day = 1; $c_day <= $cm_days; $c_day++) {
$c_weeknum = getWeekNumber($c_day, $month, $year);
if ($c_wd == 1) {
// start a new row (it's MONDAY!!!!!)
$OUTPUT .= "<tr>";
// attach the week number
$OUTPUT .= "<td align=center width=75 height=60 " . TMPL_calLargeMonthWeekNumberStyle . ">{$c_weeknum}</td>";
}
// change the fill color if it is 2day's date we are printing, or the selected date
if (date("d") == $c_day && date("m") == $month && date("Y") == $year) {
// 2day's date
$dayfill = "bgcolor=" . TMPL_calLargeMonthSelectedDay;
$a_id = "calSmallMonthCMLinkToday";
} else {
// other dates
// fill differently for saturday and sunday (only when the row has not already been colored)
if ($c_weeknum == getTodayWeekNumber() && $year == date("Y") && $month == date("m")) {
$dayfill = "bgcolor='" . TMPL_calLargeMonthCurrentWeek . "'";
} else {
if ($c_wd == 6) {
$dayfill = "bgcolor=" . TMPL_calFillSaturday;
} else {
if ($c_wd == 7) {
$dayfill = "bgcolor=" . TMPL_calFillSunday;
} else {
$dayfill = "";
}
}
}
//.........这里部分代码省略.........
示例7: cal3
function cal3($month, $year)
{
global $weekstarts;
if (!isset($weekstarts)) {
$weekstarts = 0;
}
$s = "";
$daysInMonth = getDaysInMonth($month, $year);
$date = mktime(12, 0, 0, $month, 1, $year);
$first = (strftime("%w", $date) + 7 - $weekstarts) % 7;
$monthName = utf8_strftime("%B", $date);
$s .= "<table class=\"calendar2\" border=\"1\" cellspacing=\"2\">\n";
$s .= "<tr>\n";
$s .= "<td class=\"calendarHeader2\" colspan=\"8\">{$monthName} {$year}</td>\n";
$s .= "</tr>\n";
$d = 1 - $first;
$is_ligne1 = 'y';
while ($d <= $daysInMonth) {
$s .= "<tr>\n";
for ($i = 0; $i < 7; $i++) {
$basetime = mktime(12, 0, 0, 6, 11 + $weekstarts, 2000);
$show = $basetime + $i * 24 * 60 * 60;
$nameday = utf8_strftime('%A', $show);
$temp = mktime(0, 0, 0, $month, $d, $year);
if ($i == 0) {
$s .= "<td class=\"calendar2\" style=\"vertical-align:bottom;\"><b>S" . getWeekNumber($temp) . "</b></td>\n";
}
if ($d > 0 && $d <= $daysInMonth) {
$temp = mktime(0, 0, 0, $month, $d, $year);
$day = grr_sql_query1("SELECT day FROM " . TABLE_PREFIX . "_calendrier_jours_cycle WHERE day='{$temp}'");
$jour = grr_sql_query1("SELECT Jours FROM " . TABLE_PREFIX . "_calendrier_jours_cycle WHERE DAY='{$temp}'");
if (intval($jour) > 0) {
$alt = get_vocab('jour_cycle') . " " . $jour;
$jour = ucfirst(substr(get_vocab("rep_type_6"), 0, 1)) . $jour;
} else {
$alt = get_vocab('jour_cycle') . ' ' . $jour;
if (strlen($jour) > 5) {
$jour = substr($jour, 0, 3) . "..";
}
}
if (!isset($_GET["pview"])) {
if ($day < 0) {
$s .= "<td class=\"calendar2\" valign=\"top\" style=\"background-color:#FF8585\">";
} else {
$s .= "<td class=\"calendar2\" valign=\"top\" style=\"background-color:#C0FF82\">";
}
} else {
$s .= "<td style=\"text-align:center;\" valign=\"top\">";
}
if ($is_ligne1 == 'y') {
$s .= '<b>' . ucfirst(substr($nameday, 0, 1)) . '</b><br />';
}
$s .= "<b>" . $d . "</b>";
// Pour aller checher la date ainsi que son Jour cycle
$s .= "<br />";
if (isset($_GET["pview"])) {
if ($day < 0) {
$s .= "<img src=\"../img_grr/stop.png\" class=\"image\" width=\"16\" height=\"16\" alt=\"no\"/>";
} else {
$s .= "<span class=\"jour-cycle\">" . $jour . "</span>";
}
} else {
if ($day < 0) {
$s .= "<a href=\"admin_calend_jour_cycle.php?page_calend=3&date=" . $temp . "\"><img src=\"../img_grr/stop.png\" class=\"image\" alt=\"(aucun)\" width=\"16\" height=\"16\" /></a>";
} else {
$s .= "<a class=\"jour-cycle\" href=\"admin_calend_jour_cycle.php?page_calend=3&date=" . $temp . "\" title=\"" . $alt . "\" >" . $jour . "</a>";
}
}
} else {
if (!isset($_GET["pview"])) {
$s .= "<td class=\"calendar2\" valign=\"top\">";
} else {
$s .= "<td style=\"text-align:center;\" valign=\"top\">";
}
if ($is_ligne1 == 'y') {
$s .= '<b>' . ucfirst(substr($nameday, 0, 1)) . '</b><br />';
}
$s .= " ";
}
$s .= "</td>\n";
$d++;
}
$s .= "</tr>\n";
$is_ligne1 = 'n';
}
$s .= "</table>\n";
return $s;
}
示例8: getHTML
function getHTML()
{
global $weekstarts, $vocab, $type_month_all, $display_day, $nb_display_day;
// Calcul de la date courante
$date_today = mktime(12, 0, 0, $this->month, $this->day, $this->year);
// Calcul du numéro de semaine courante
$week_today = numero_semaine($date_today);
if (!isset($weekstarts)) $weekstarts = 0;
$s = "";
$daysInMonth = getDaysInMonth($this->month, $this->year);
// Calcul de la date au 1er du mois de la date courante
$date = mktime(12, 0, 0, $this->month, 1, $this->year);
$first = (strftime("%w",$date) + 7 - $weekstarts) % 7;
$monthName = utf8_strftime("%B",$date);
$prevMonth = $this->getCalendarLink($this->month - 1 > 0 ? $this->month - 1 : 12, $this->month - 1 > 0 ? $this->year : $this->year - 1);
$nextMonth = $this->getCalendarLink($this->month + 1 <= 12 ? $this->month + 1 : 1, $this->month + 1 <= 12 ? $this->year : $this->year + 1);
$s .= "<table border = \"0\" class=\"calendar\">\n";
$s .= "<tr><td></td>\n";
if (($this->h) and (($this->dmy=='month') or ($this->dmy=='month_all') or ($this->dmy=='month_all2') )) $bg_lign = "week"; else $bg_lign = 'calendarHeader';
$s .= "<td align=\"center\" valign=\"top\" class=\"$bg_lign\" colspan=\"".$nb_display_day."\">";
#Permet de récupérer le numéro de la 1ere semaine affichée par le mini calendrier.
// $week = number_format(strftime("%W",$date),0);
$week = numero_semaine($date);
$weekd = $week;
// on ajoute un lien vers le mois précédent
if ($this->mois_precedent == 1) {
$tmp = mktime(0, 0, 0, ($this->month)-1, 1, $this->year);
$lastmonth = date("m",$tmp);
$lastyear= date("Y",$tmp);
if (($this->dmy!='day') and ($this->dmy!='week_all') and ($this->dmy!='month_all') and ($this->dmy!='month_all2'))
$s .= "<a title=\"".grr_htmlSpecialChars(get_vocab("see_month_for_this_room"))."\" href=\"month.php?year=$lastyear&month=$lastmonth&day=1&area=$this->area&room=$this->room\"><<</a> ";
else
$s .= "<a title=\"".grr_htmlSpecialChars(get_vocab("see_all_the_rooms_for_the_month"))."\" href=\"".$type_month_all.".php?year=$lastyear&month=$lastmonth&day=1&area=$this->area\"><<</a> ";
}
if (($this->dmy!='day') and ($this->dmy!='week_all') and ($this->dmy!='month_all') and ($this->dmy!='month_all2'))
$s .= "<a title=\"".grr_htmlSpecialChars(get_vocab("see_month_for_this_room"))."\" href=\"month.php?year=$this->year&month=$this->month&day=1&area=$this->area&room=$this->room\">$monthName $this->year</a>";
else
$s .= "<a title=\"".grr_htmlSpecialChars(get_vocab("see_all_the_rooms_for_the_month"))."\" href=\"".$type_month_all.".php?year=$this->year&month=$this->month&day=1&area=$this->area\">$monthName $this->year</a>";
// on ajoute un lien vers le mois suivant
if ($this->mois_suivant == 1) {
$tmp = mktime(0, 0, 0, ($this->month)+1, 1, $this->year);
$nextmonth = date("m",$tmp);
$nextyear= date("Y",$tmp);
if (($this->dmy!='day') and ($this->dmy!='week_all') and ($this->dmy!='month_all') and ($this->dmy!='month_all2'))
$s .= " <a title=\"".grr_htmlSpecialChars(get_vocab("see_month_for_this_room"))."\" href=\"month.php?year=$nextyear&month=$nextmonth&day=1&area=$this->area&room=$this->room\">>></a>";
else
$s .= " <a title=\"".grr_htmlSpecialChars(get_vocab("see_all_the_rooms_for_the_month"))."\" href=\"".$type_month_all.".php?year=$nextyear&month=$nextmonth&day=1&area=$this->area\">>></a>";
}
$s .= "</td>\n";
$s .= "</tr>\n";
$s .= "<tr><td></td>\n";
$s .= getFirstDays();
$s .= "</tr>\n";
$d = 1 - $first;
$temp = 1;
while ($d <= $daysInMonth)
{
// if (($date_today <= $date) and ($this->h) and (($this->dmy=='week_all') or ($this->dmy=='week') )) $bg_lign = " class=\"week\""; else $bg_lign = '';
if (($week_today == $week) and ($this->h) and (($this->dmy=='week_all') or ($this->dmy=='week') )) $bg_lign = " class=\"week\""; else $bg_lign = '';
$s .= "<tr ".$bg_lign."><td class=\"calendarcol1\" align=\"right\" valign=\"top\">";
#Affichage du numéro de la semaine en cours à droite du calendrier et génère un lien sur la semaine voulue.
if (($this->dmy!='day') and ($this->dmy!='week_all') and ($this->dmy!='month_all') and ($this->dmy!='month_all2'))
$s .="<a title=\"".grr_htmlSpecialChars(get_vocab("see_week_for_this_room"))."\" href=\"week.php?year=$this->year&month=$this->month&day=$temp&area=$this->area&room=$this->room\">s".sprintf("%02d",$week)."</a>";
else
$s .="<a title=\"".grr_htmlSpecialChars(get_vocab("see_week_for_this_area"))."\" href=\"week_all.php?year=$this->year&month=$this->month&day=$temp&area=$this->area\">s".sprintf("%02d",$week)."</a>";
$temp=$temp+7;
while ((!checkdate($this->month, $temp, $this->year)) and ($temp > 0)) $temp--;
#Nouveau affichage, affiche le numéro de la semaine dans l'année.Incrémentation de ce numéro à chaque nouvelle semaine.
$date = mktime(12, 0, 0, $this->month, $temp, $this->year);
$week = numero_semaine($date);
$s .= "</td>\n";
for ($i = 0; $i < 7; $i++)
{
$j = ($i + 7 + $weekstarts) % 7;
if ($display_day[$j] == "1") {// début condition "on n'affiche pas tous les jours de la semaine"
if (($this->dmy == 'day') and ($d == $this->day) and ($this->h))
$s .= "<td class=\"week\" align=\"right\" valign=\"top\">";
else
$s .= "<td class=\"calendar\" align=\"right\" valign=\"top\">";
if ($d > 0 && $d <= $daysInMonth)
{
$link = $this->getDateLink($d, $this->month, $this->year);
if ($link == "")
$s .= $d;
#Permet de colorer la date affichée sur la page
elseif (($d == $this->day) and ($this->h))
$s .= $link."><span class=\"cal_current_day\">$d</span></a>";
else
$s .= $link.">$d</a>";
}
else
$s .= " ";
$s .= "</td>\n";
}// fin condition "on n'affiche pas tous les jours de la semaine"
$d++;
}
//.........这里部分代码省略.........
示例9: cal
function cal($month, $year)
{
global $weekstarts;
if (!isset($weekstarts)) {
$weekstarts = 0;
}
$s = "";
$daysInMonth = getDaysInMonth($month, $year);
$date = mktime(12, 0, 0, $month, 1, $year);
$first = (strftime("%w", $date) + 7 - $weekstarts) % 7;
$monthName = ucfirst(utf8_strftime("%B", $date));
$s .= '<table class="table calendar2">' . PHP_EOL;
$s .= '<tr>' . PHP_EOL;
$s .= '<td class="calendarHeader2" colspan="8">' . $monthName . ' ' . $year . '</td>' . PHP_EOL;
$s .= '</tr>' . PHP_EOL;
$d = 1 - $first;
$is_ligne1 = 'y';
while ($d <= $daysInMonth) {
$s .= '<tr>' . PHP_EOL;
for ($i = 0; $i < 7; $i++) {
$basetime = mktime(12, 0, 0, 6, 11 + $weekstarts, 2000);
$show = $basetime + $i * 24 * 60 * 60;
$nameday = utf8_strftime('%A', $show);
$temp = mktime(0, 0, 0, $month, $d, $year);
if ($i == 0) {
$s .= '<td class="calendar2" style="vertical-align:bottom;"><b>S' . getWeekNumber($temp) . '</b></td>' . PHP_EOL;
}
$s .= '<td class="calendar2" align="center" valign="top">' . PHP_EOL;
if ($is_ligne1 == 'y') {
$s .= '<b>' . ucfirst(substr($nameday, 0, 1)) . '</b><br />';
}
if ($d > 0 && $d <= $daysInMonth) {
$s .= $d;
$day = grr_sql_query1("SELECT day FROM " . TABLE_PREFIX . "_calendar WHERE day='{$temp}'");
$s .= '<br><input type="checkbox" name="' . $temp . '" value="' . $nameday . '" ';
if (!($day < 0)) {
$s .= 'checked="checked" ';
}
$s .= '/>';
} else {
$s .= " ";
}
$s .= '</td>' . PHP_EOL;
$d++;
}
$s .= '</tr>' . PHP_EOL;
$is_ligne1 = 'n';
}
$s .= '</table>' . PHP_EOL;
return $s;
}
示例10: generateMonthView_small_mail
function generateMonthView_small_mail($view_diary)
{
global $_GET;
extract($_GET);
$pyear = extractYear(mkdatet($year - 1, $month, 1));
$pmonth = extractMonth(mkdatet($year, $month - 1, 1));
$nyear = extractYear(mkdatet($year + 1, $month, 1));
$nmonth = extractMonth(mkdatet($year, $month + 1, 1));
$OUTPUT = "\n\t\t<table width=190 cellspacing=0>\n\t\t\t<tr>\n\t\t\t\t<td height=20 align=center " . TMPL_calSmallMonthTitleStyle . ">\n\t\t\t\t\t<a href='" . SELF . "?month={$month}&year={$pyear}'><img border='0' src='left_year.gif'></a>\n\t\t\t\t\t<a href='" . SELF . "?month={$pmonth}&year={$year}'><img border='0' src='left_month.gif'></a>\n\t\t\t\t\t<b><a class='month_text' href='javascript:ajaxLink(\"iframe.php\", \"script=diary-index.php&key=month&month={$month}&year={$year}\");'>" . getMonthName($month) . " {$year}</a></b>\n\t\t\t\t\t<a href='" . SELF . "?month={$nmonth}&year={$year}'><img border='0' src='right_month.gif'></a>\n\t\t\t\t\t<a href='" . SELF . "?month={$month}&year={$nyear}'><img border='0' src='right_year.gif'></a>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td align=center " . TMPL_calSmallMonthBodyStyle . " colspan='5'>";
// generate the titles of the weekdays
$OUTPUT .= "\n\t\t\t<table width='184' cellspacing=0>\n\t\t\t\t<tr>\n\t\t\t\t\t<td width=23> </td>\n\t\t\t\t\t<td width=23 align=center><b>M</b></td>\n\t\t\t\t\t<td width=23 align=center><b>T</b></td>\n\t\t\t\t\t<td width=23 align=center><b>W</b></td>\n\t\t\t\t\t<td width=23 align=center><b>T</b></td>\n\t\t\t\t\t<td width=23 align=center><b>F</b></td>\n\t\t\t\t\t<td width=23 align=center bgcolor=" . TMPL_calFillSaturday . "><b>S</b></td>\n\t\t\t\t\t<td width=23 align=center bgcolor=" . TMPL_calFillSunday . "><b>S</b></td>\n\t\t\t\t</tr>";
// get the weekday number of the first of this month
$first_wd = getWeekdayNum(1, $month, $year);
// the following code will generate the first entries on the calendar, which is for the previous month (if any)
// month and year of previous month
if ($month == 1) {
$tmp_month = 12;
$tmp_year = $year - 1;
} else {
$tmp_month = $month - 1;
$tmp_year = $year;
}
// date of last monday in previous month (where the entries will start)
if ($first_wd > 1) {
$tmp_day = getDaysInMonth($tmp_month, $tmp_year) - ($first_wd - 2);
} else {
$tmp_day = 1;
$tmp_month = $month;
$tmp_year = $year;
}
// create a view variables
$selected_month = $smonth;
// create the previous month's entries
$c_weeknum = getWeekNumber($tmp_day, $tmp_month, $tmp_year);
$selected_weeknum = getWeekNumber($sday, $smonth, $syear);
// if today's week number = the current generated week's number, hightlight the row, as so with the selected week,
if ($c_weeknum == getTodayWeekNumber() && $tmp_year == date("Y") && $month == date("m") || getTodayWeekNumber() == 0 && $month == date("m") && $year == date("Y")) {
// today's week
$OUTPUT .= "<tr bgcolor='" . TMPL_calSmallMonthCurrentWeek . "'>";
$ROW_COLORED = 1;
} else {
if ($month == $smonth && $c_weeknum == $selected_weeknum || $c_weeknum == 52 && $selected_weeknum == 0) {
// selected week, the last check is for the first week in jan
$OUTPUT .= "<tr bgcolor='" . TMPL_calSmallMonthSelectedWeek . "'>";
$ROW_COLORED = 1;
} else {
// other dates
$OUTPUT .= "<tr>";
$ROW_COLORED = 0;
}
}
if ($first_wd != 1) {
// only if there is a day in this week of previous month, print the week number
$OUTPUT .= "<td width=23 " . TMPL_calSmallMonthWeekNumberStyle . " align=center>{$c_weeknum}</td>";
}
for ($c_wd = 1; $c_wd < $first_wd; $c_wd++, $tmp_day++) {
// fill differently for saturday and sunday (only when row wasn't already highlighted)
if ($c_wd == 6 && !$ROW_COLORED) {
$dayfill = "bgcolor=" . TMPL_calFillSaturday;
} else {
if ($c_wd == 7) {
$dayfill = "bgcolor=" . TMPL_calFillSunday;
} else {
$dayfill = "";
}
}
// ** 2006-05-08 **
// $OUTPUT.="<td $dayfill width=23 align=center>
// <a id='calSmallMonthOMLink' href='#' onClick='parent.rightframe.document.location.href=\"diary-index.php?mday=$tmp_day&month=$tmp_month&year=$tmp_year\"'>$tmp_day</a>
// </td>";
$OUTPUT .= "<td {$dayfill} width='23' align='center'>\n\t\t\t<a id='calSmallMonthOMLink' href='javascript:ajaxLink(\"iframe.php\", \"script=diary-index.php&mday={$tmp_day}&month={$tmp_month}&year={$tmp_year}\");'>{$tmp_day}</a></td>";
}
// start creating this month's entries
$cm_days = getDaysInMonth($month, $year);
for ($c_day = 1; $c_day <= $cm_days; $c_day++) {
$c_weeknum = getWeekNumber($c_day, $month, $year);
if ($c_wd == 1) {
// start a new row (it's MONDAY!!!!!)
// if today's week number = the current generated week's number, hightlight the row, as so with the selected week
if ($c_weeknum == getTodayWeekNumber() && $year == date("Y") && $month == date("m")) {
// today's week
$OUTPUT .= "<tr bgcolor='" . TMPL_calSmallMonthCurrentWeek . "'>";
$ROW_COLORED = 1;
} else {
if ($month == $smonth && $c_weeknum == $selected_weeknum) {
// selected week
$OUTPUT .= "<tr bgcolor='" . TMPL_calSmallMonthSelectedWeek . "'>";
$ROW_COLORED = 1;
} else {
// other dates
$OUTPUT .= "<tr>";
$ROW_COLORED = 0;
}
}
// attach the week number
$OUTPUT .= "<td align=center width=23 " . TMPL_calSmallMonthWeekNumberStyle . ">{$c_weeknum}</td>";
}
// change the fill color if it it 2day's date we are printing, or the selected date
if ($c_day == $sday && $month == $smonth && $year == $syear) {
// selected date
//.........这里部分代码省略.........
示例11: getHoliday
/**
* 祝日テーブルを作成
* @param int $year 西暦年(計算開始年)
* @return string 祝日の名称/FALSE=祝日ではない
*/
function getHoliday($year)
{
static $youbi = array('日', '月', '火', '水', '木', '金', '土', '日');
if ($year == FALSE) {
return '';
}
$holidays = array();
$flag = FALSE;
//Google Calendar APIを使って祝日を取得
for ($yyyy = $year; $yyyy < $year + 3; $yyyy++) {
$n = getHoliday_by_Google($yyyy, $holidays);
if ($n > 0) {
$flag = TRUE;
}
if (!$flag) {
break;
}
}
if ($flag) {
$msg = "<table border=\"1\">\n";
for ($yyyy = $year; $yyyy < $year + 3; $yyyy++) {
$cnt = 1;
$msg .= sprintf("<tr><td colspan=\"3\">%04d年</td></tr>\n", $yyyy);
for ($month = 1; $month <= 12; $month++) {
$day_of_month = getDaysInMonth($yyyy, $month);
for ($day = 1; $day <= $day_of_month; $day++) {
$key = sprintf("%04d-%02d-%02d", $year, $month, $day);
$name = isset($holidays[$key]) ? $holidays[$key] : FALSE;
$ww = getWeekNumber($yyyy, $month, $day);
if ($name != FALSE) {
$msg .= sprintf("<tr><td>%02d</td><td>%02d月%02d日(%s)</td><td>%s</td></tr>\n", $cnt, $month, $day, $youbi[$ww], $name);
$cnt++;
}
}
}
}
$msg .= "</table>\n";
} else {
$msg = 'error > Google Calendar APIから祝日を取得できません.';
}
return $msg;
}
示例12: display
function display($_POST)
{
extract($_POST);
global $PRDMON;
#determine the date range based on period selection
if (isset($year_to_process)) {
switch ($year_to_process) {
case "active":
$fdate_year = getYearOfFinPrd(1);
$fdate_month = $PRDMON[1];
$fdate_day = "1";
$tdate_year = getYearOfFinPrd(12);
$tdate_month = $PRDMON[12];
$tdate_day = date("d", mktime(0, 0, 0, $PRDMON[12] + 1, 0, $tdate_year));
break;
case "previous":
$fdate_year = getYearOfFinPrd(1) - 1;
$fdate_month = $PRDMON[1];
$fdate_day = "1";
$tdate_year = getYearOfFinPrd(12) - 1;
$tdate_month = $PRDMON[12];
$tdate_day = date("d", mktime(0, 0, 0, $PRDMON[12] + 1, 0, $tdate_year));
break;
default:
$fdate_year = getYearOfFinPrd(1);
$fdate_month = "03";
$fdate_day = "01";
$tdate_year = getYearOfFinPrd(12);
$tdate_month = "02";
$tdate_day = date("d", mktime(0, 0, 0, 3, 0, $tdate_year));
}
}
// -----------------------------------------------------------------------
// Sanity checks
// -----------------------------------------------------------------------
require_lib("validate");
$v = new validate();
// Does this employee number actually exist
db_conn("cubit");
$sql = "SELECT * FROM employees WHERE empnum='" . (int) $empnum . "' AND div='" . USER_DIV . "'";
$empinf_rslt = db_exec($sql) or errDie("Unable to retrieve employee number from Cubit.");
if (pg_num_rows($empinf_rslt) == 0) {
$v->addError(0, "Employee number not found in Cubit.");
}
$v->isOk($fdate_month, "num", 1, 2, "Invalid from date (month)");
$v->isOk($fdate_year, "num", 4, 4, "Invalid from date (year)");
$v->isOk($tdate_month, "num", 1, 2, "Invalid to date (month)");
$v->isOk($tdate_year, "num", 4, 4, "Invalid to date (year)");
if ($fdate_month > 12) {
$v->addError(0, "Invalid from date (month)");
}
if ($fdate_year < 1970 || $fdate_year > 2050) {
$v->addError(0, "Invalid from date (year)");
}
if ($tdate_month > 12) {
$v->addError(0, "Invalid to date (month)");
}
if ($tdate_year < 1970 || $tdate_year > 2050) {
$v->addError(0, "Invalid to date (year)");
}
if ($fdate_day > getDaysInMonth((int) $fdate_month, $fdate_year)) {
$v->addError(0, "Invalid from date (day)");
}
if ($tdate_day > getDaysInMonth((int) $tdate_month, $tdate_year)) {
$v->addError(0, "Invalid to date (day)");
}
$from_time = mktime(0, 0, 0, $fdate_day, $fdate_month, $fdate_year);
$to_time = mktime(0, 0, 0, $tdate_day, $tdate_month, $tdate_year);
if ($from_time > $to_time) {
$v->addError(0, "Invalid date range specified.");
}
if (isset($income_code)) {
foreach ($income_code as $id => $value) {
$v->isOk($income_code[$id], "numeric", 1, 4, "Invalid income code.");
$v->isOk($income_description[$id], "string", 1, 80, "Invalid income description.");
$v->isOk($income_rfind[$id], "string", 1, 30, "Invalid RF IND.");
$v->isOk($income_amount[$id], "float", 1, 9, "Invalid income amount.");
}
}
// Return the errors, if any
if ($v->isError()) {
$confirm = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$confirm .= "<li class='err'>{$e['msg']}</li>";
}
return slct($confirm);
}
$from_date = "{$fdate_year}-{$fdate_month}-{$fdate_day}";
$to_date = "{$tdate_year}-{$tdate_month}-{$tdate_day}";
$gross_taxable_annual_payments = 0.0;
$gross_non_taxable_income = 0.0;
$gross_retirement_funding_income = 0.0;
$gross_non_retirement_funding_income = 0.0;
$gross_remuneration = 0.0;
db_conn("cubit");
$sql = "SELECT * FROM compinfo";
$compinfo_rslt = db_exec($sql) or errDie("Unable to retrieve company information from Cubit.");
$compinfo = pg_fetch_array($compinfo_rslt);
db_conn("cubit");
//.........这里部分代码省略.........
示例13: dateSelection
/**
* returns html for a date selection
*
* the form fields to update must have in id in the form of
* ${idpfx}_day, ${idpfx}_month, ${idpfx}_year in the order day, month, year
* respectively.
*
* @ignore
* @param string idpfx prefix for form fields to update
* @return string html
*/
function dateSelection($idpfx)
{
global $GWPP;
/* all the different date parts with default values -> false */
$date_fields = array("day", "month", "year", "sday", "smonth", "syear");
foreach ($date_fields as $k) {
if (!isset($_REQUEST[$k])) {
${$k} = false;
} else {
${$k} = $_REQUEST[$k];
}
}
/* why check only date === false but set all of them to date()
values? what if they have values you gonna overwrite?
because I dont want bugs like day isset, month not, year isset
causing some weird month to be shown */
if ($day === false) {
$day = date("d");
$month = date("m");
$year = date("Y");
}
if ($sday === false) {
$sday = $day;
$smonth = $month;
$syear = $year;
}
/* forcibly fix the date */
explodeDate(date("Y-m-d", mktime(0, 0, 0, $smonth, $sday, $syear)), $syear, $smonth, $sday);
/* previous year */
$pyear = extractYear(mkdatet($year - 1, $month, 1));
/* previous month */
$pmonth = extractMonth(mkdatet($year, $month - 1, 1));
$pmyear = extractYear(mkdatet($year, $month - 1, 1));
/* next month */
$nmonth = extractMonth(mkdatet($year, $month + 1, 1));
$nmyear = extractYear(mkdatet($year, $month + 1, 1));
/* next year */
$nyear = extractYear(mkdatet($year + 1, $month, 1));
/* month/year selections */
$dateselmove = "dateSelMoveBySelect(\"{$idpfx}\", \"{$day}\", \"{$sday}\", \"{$smonth}\", \"{$syear}\", \"{$GWPP}\");";
$move_month = mksel_month("datesel_move_month", $month, "onchange='{$dateselmove}'", true);
$move_year = mksel_year("datesel_move_year", $year, "onchange='{$dateselmove}'");
$title_style = "onMouseUp='moveXLayer(false);' onMouseDown='moveXLayer(true);'";
$OUTPUT = "\n\t<div id='datesel_container' style='background: #fdeb89; border: 1px dashed black;' >\n\t<div id='datesel_loading' style='position: absolute; visibility: hidden;'>\n\t\t<p style='margin-left: 25px; margin-top: 60px;'>\n\t\t\t<strong>Loading. Please Wait...</strong>\n\t\t</p>\n\t</div>\n\t<div id='datesel_calender'>\n\t<table>\n\t<tr>\n\t\t<td nowrap='t' align='left'>\n\t\t\t{$move_month} {$move_year}\n\t\t\t<!--<input type='button' onclick='{$dateselmove}' value='Go'/>-->\n\t\t</td>\n\t\t<td align='right' nowrap='t' onMouseUp='moveXLayer(false);' onMouseDown='moveXLayer(true);'>\n\t\t\t<b><a id='xpopup_cls' href='javascript: XPopupHideAct()'>[X] </a></b>\n\t\t</td>\n\t</tr>\n\t<tr><td colspan='2'>\n\n\t<table width='190' cellspacing='0'>\n\t<tr>\n\t\t<td {$title_style} " . TMPL_calSmallMonthTitleStyleLeft . ">\n\t\t\t<a href='javascript: dateSelMove(\"{$idpfx}\", \"{$day}\", \"{$month}\", \"{$pyear}\", \"{$sday}\", \"{$smonth}\", \"{$syear}\", \"{$GWPP}\");'><img border='0' src='{$GWPP}/left_year.gif' /></a>\n\t\t\t<a href='javascript: dateSelMove(\"{$idpfx}\", \"{$day}\", \"{$pmonth}\", \"{$pmyear}\", \"{$sday}\", \"{$smonth}\", \"{$syear}\", \"{$GWPP}\");'><img border='0' src='{$GWPP}/left_month.gif' /></a>\n\t\t</td>\n\t\t<td {$title_style} " . TMPL_calSmallMonthTitleStyleCenter . ">\n\t\t\t" . getMonthName($month) . " {$year}\n\t\t</td>\n\t\t<td {$title_style} " . TMPL_calSmallMonthTitleStyleRight . ">\n\t\t\t<a href='javascript: dateSelMove(\"{$idpfx}\", \"{$day}\", \"{$nmonth}\", \"{$nmyear}\", \"{$sday}\", \"{$smonth}\", \"{$syear}\", \"{$GWPP}\");'><img border='0' src='{$GWPP}/right_month.gif' /></a>\n\t\t\t<a href='javascript: dateSelMove(\"{$idpfx}\", \"{$day}\", \"{$month}\", \"{$nyear}\", \"{$sday}\", \"{$smonth}\", \"{$syear}\", \"{$GWPP}\");'><img border='0' src='{$GWPP}/right_year.gif' /></a>\n\t\t</td>\n\t</tr>\n\t<tr>\n\t\t<td align='center' " . TMPL_calSmallMonthBodyStyle . " colspan='5'>";
// generate the titles of the weekdays
$OUTPUT .= "\n\t\t<table width='184' cellspacing='0'>\n\t\t\t<tr>\n\t\t\t\t<td width='23'> </td>\n\t\t\t\t<td width='23' align='center'><b>M</b></td>\n\t\t\t\t<td width='23' align='center'><b>T</b></td>\n\t\t\t\t<td width='23' align='center'><b>W</b></td>\n\t\t\t\t<td width='23' align='center'><b>T</b></td>\n\t\t\t\t<td width='23' align='center'><b>F</b></td>\n\t\t\t\t<td width='23' align='center' bgcolor=" . TMPL_calFillSaturday . "><b>S</b></td>\n\t\t\t\t<td width='23' align='center' bgcolor=" . TMPL_calFillSunday . "><b>S</b></td>\n\t\t\t</tr>";
// get the weekday number of the first of this month
$first_wd = getWeekdayNum(1, $month, $year);
// the following code will generate the first entries on the calendar, which is for the previous month (if any)
// month and year of previous month
if ($month == 1) {
$tmp_month = 12;
$tmp_year = $year - 1;
} else {
$tmp_month = $month - 1;
$tmp_year = $year;
}
// date of last monday in previous month (where the entries will start)
if ($first_wd > 1) {
$tmp_day = getDaysInMonth($tmp_month, $tmp_year) - ($first_wd - 2);
} else {
$tmp_day = 1;
$tmp_month = $month;
$tmp_year = $year;
}
// create a view variables
$selected_month = $smonth;
// create the previous month's entries
$c_weeknum = getWeekNumber($tmp_day, $tmp_month, $tmp_year);
$selected_weeknum = getWeekNumber($sday, $smonth, $syear);
// if today's week number = the current generated week's number, hightlight the row, as so with the selected week,
if ($c_weeknum == getTodayWeekNumber() && $tmp_year == date("Y") && $month == date("m") || getTodayWeekNumber() == 0 && $month == date("m") && $year == date("Y")) {
// today's week
$OUTPUT .= "<tr bgcolor='" . TMPL_calSmallMonthCurrentWeek . "'>";
$ROW_COLORED = 1;
} else {
if ($year == $syear && $month == $smonth && $c_weeknum == $selected_weeknum || $c_weeknum == 52 && $selected_weeknum == 0) {
// selected week, the last check is for the first week in jan
$OUTPUT .= "<tr bgcolor='" . TMPL_calSmallMonthSelectedWeek . "'>";
$ROW_COLORED = 1;
} else {
// other dates
$OUTPUT .= "<tr>";
$ROW_COLORED = 0;
}
}
if ($first_wd != 1) {
// only if there is a day in this week of previous month, print the week number
$OUTPUT .= "<td width='23' " . TMPL_calSmallMonthWeekNumberStyle . " align='center'>{$c_weeknum}</td>";
//.........这里部分代码省略.........
示例14: slct
function slct($errors = "")
{
global $_POST;
extract($_POST);
$fields["fdate_year"] = date("Y") - 1;
$fields["fdate_month"] = "03";
$fields["fdate_day"] = "01";
$fields["tdate_year"] = date("Y");
$fields["tdate_month"] = "02";
$fields["tdate_day"] = getDaysInMonth($fields["tdate_month"], $fields["tdate_year"]);
$fields["irp5_number"] = "";
$fields["directive_number"] = "";
$fields["over_deduction"] = "";
$fields["pay_periods"] = "";
$fields["pay_periods_worked"] = "";
foreach ($fields as $var_name => $value) {
if (!isset(${$var_name})) {
${$var_name} = $value;
}
}
require "irp5-codes.php";
// Income sources dropdown
$nincome_codes_sel = "<select name='nincome_code' style='width: 180px'>\n\t\t<option value='0'>Please select</option>";
foreach ($income_codes as $category => $value) {
foreach ($value as $code => $description) {
$nincome_codes_sel .= "<option value='{$code}'>{$code} - {$description}</option>";
}
}
$nincome_codes_sel .= "</select>";
$income_sources_out = "<tr class='bg-odd'>\n\t\t<td>{$nincome_codes_sel}</td>\n\t\t<td align=center><input type=text name=nincome_description size=100%></td>\n\t\t<td align=center>\n\t\t\t<select name=nincome_rfind>\n\t\t\t\t<option value='N'>No</option>\n\t\t\t\t<option value='Y'>Yes</option>\n\t\t\t</select>\n\t\t</td>\n\t\t<td align=center><input type=text name=nincome_amount size=10%></td>\n\t\t<td> </td>\n\t</tr>";
// Retrieve the saved income sources from Cubit
db_conn("cubit");
$sql = "SELECT * FROM emp_income_sources WHERE empnum='{$empnum}' ORDER BY id DESC";
$rslt = db_exec($sql) or errDie("Unable to retrieve income sources from Cubit.");
// Should we add the update button
if (pg_num_rows($rslt) < 20) {
$update_out = "<input type=submit value='Update'>";
} else {
$update_out = "";
}
$i = 0;
while ($income_data = pg_fetch_array($rslt)) {
// Income sources dropdown
$income_codes_sel = "<select name='income_code[{$income_data['id']}]' style='width: 180px'>\n\t\t\t<option value='0'>Please select</option>";
foreach ($income_codes as $category => $value) {
foreach ($value as $code => $description) {
if ($code == $income_data["code"]) {
$selected = "selected";
} else {
$selected = "";
}
$income_codes_sel .= "<option value='{$code}' {$selected}>{$code} - {$description}</option>";
}
}
$income_codes_sel .= "</select>";
// RF IND dropdown
$rf_ind_vals = array("N" => "No", "Y" => "Yes");
$rf_ind_sel = "<select name='income_rfind[{$income_data['id']}]'";
foreach ($rf_ind_vals as $key => $value) {
if ($key == $income_data["rf_ind"]) {
$selected = "selected";
} else {
$selected = "";
}
$rf_ind_sel .= "<option value='{$key}' {$selected}>{$value}</option>";
}
$rf_ind_sel .= "</select>";
$income_sources_out .= "<tr class='" . bg_class() . "'>\n\t\t\t<td width=20%>{$income_codes_sel}</td>\n\t\t\t<td align=center><input type=text name='income_description[{$income_data['id']}]' size=100% value='{$income_data['description']}'></td>\n\t\t\t<td align=center>{$rf_ind_sel}</td>\n\t\t\t<td align=center><input type=text name='income_amount[{$income_data['id']}]' size=10% value='{$income_data['amount']}'></td>\n\t\t\t<td><input type=checkbox name=income_rem[{$income_data['id']}] size=10%></td>\n\t\t</tr>";
}
// Retrieve employee details
db_conn("cubit");
$sql = "SELECT * FROM employees WHERE empnum='{$empnum}'";
$rslt = db_exec($sql) or errDie("Unable to retrieve employee information from Cubit.");
$empinfo = pg_fetch_array($rslt);
$OUTPUT = "<center>\n\t<h3>IRP 5 Output for {$empinfo['fnames']} {$empinfo['sname']}</h3>\n\t<form method=post action='" . SELF . "'>\n\t<input type=hidden name=key value='update'>\n\t<input type=hidden name=empnum value='{$empnum}'>\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\n\t\t<tr>\n\t\t\t<th colspan=5>Date Range</th>\n\t\t</tr>\n\t\t<tr class='bg-odd'>\n\t\t\t<td><b>From</b></td>\n\t\t\t<td>" . mkDateSelect("fdate", $fdate_year, $fdate_month, $fdate_day) . "</td>\n\t\t\t<td><b>To</b></td>\n\t\t\t<td>" . mkDateSelect("tdate", $tdate_year, $tdate_month, $tdate_day) . "</td>\n\t\t</tr>\n\t</table>\n\t<p>\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\n\t\t<tr>\n\t\t\t<th colspan=2>Values</th>\n\t\t</tr>\n\t\t<tr class='bg-odd'>\n\t\t\t<td>IRP 5 Number</td>\n\t\t\t<td><input type=text name='irp5_number' value='{$irp5_number}'></td>\n\t\t</tr>\n\t\t<tr class='bg-even'>\n\t\t\t<td>Directive Number</td>\n\t\t\t<td><input type=text name='directive_number' value='{$directive_number}'></td>\n\t\t</tr>\n\t\t<tr class='bg-odd'>\n\t\t\t<td>Voluntary over-deduction</td>\n\t\t\t<td><input type=text name='over_deduction' value='{$over_deduction}'></td>\n\t\t</tr>\n\t</table>\n\t<p>\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width=100%>\n\t\t<tr>\n\t\t\t<td colspan=5>{$errors}</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<th colspan=5>Income Sources</th>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<th align=left width=10%>Code</th>\n\t\t\t<th align=left width=70%>Description</th>\n\t\t\t<th align=left width=10%>RF IND</th>\n\t\t\t<th align=left width=10%>Amount</th>\n\t\t\t<th> </th>\n\t\t</tr>\n\t\t{$income_sources_out}\n\t</table>\n\t<p>\n\t{$update_out}\n\t<input type=submit name=display value='Done »'>\n\t</form>\n\t</center>";
return $OUTPUT;
}
示例15: slctDate
function slctDate()
{
db_connect();
#check what we have permission to
$get_perm = "SELECT payroll_groups FROM users WHERE username = '{$_SESSION['USER_NAME']}' LIMIT 1";
$run_perm = db_exec($get_perm) or errDie("Unable to get payroll groups permission information.");
if (pg_numrows($run_perm) > 0) {
$parr = pg_fetch_array($run_perm);
if (strlen($parr['payroll_groups']) > 0) {
$pay_grps = explode(",", $parr['payroll_groups']);
if (is_array($pay_grps)) {
$egsearch = " AND (emp_group = '" . implode("' OR emp_group = '", $pay_grps) . "')";
}
} else {
$egsearch = "AND false";
}
}
$sql = "SELECT enum,empnum, sname, fnames FROM employees WHERE div = '" . USER_DIV . "' {$egsearch} ORDER BY sname";
$empRslt = db_exec($sql) or errDie("Unable to select employees from database.");
if (pg_numrows($empRslt) < 1) {
// return "No employees found in database.<p>"
// .mkQuickLinks();
}
$employees = array("0" => "All");
while ($d = pg_fetch_array($empRslt)) {
$employees[$d["empnum"]] = "{$d['sname']}, {$d['fnames']} ({$d['enum']})";
}
$fields = array("empnum" => 0, "from_year" => DATE_YEAR, "from_month" => DATE_MONTH, "from_day" => 1, "to_year" => DATE_YEAR, "to_month" => DATE_MONTH, "to_day" => getDaysInMonth(DATE_MONTH, DATE_YEAR));
foreach ($fields as $fname => $dflt) {
if (!isset(${$fname})) {
${$fname} = $dflt;
}
}
$get_egroups = "SELECT * FROM emp_groups ORDER BY emp_group";
$run_egroups = db_exec($get_egroups) or errDie("Unable to get employee group information.");
if (pg_numrows($run_egroups) < 1) {
$emp_group_drop = "<input type='hidden' name='emp_group[]' value='0'>No Employee Groups Found.";
} else {
$emp_group_drop = "<select name='emp_group[]' multiple size='5'>";
$emp_group_drop .= "<option value='0'>All</option>";
while ($garr = pg_fetch_array($run_egroups)) {
$emp_group_drop .= "<option value='{$garr['id']}'>{$garr['emp_group']}</option>";
}
$emp_group_drop .= "</select>";
}
db_connect();
$get_years = "SELECT distinct (cyear) FROM salpaid ORDER BY cyear";
$run_years = db_exec($get_years) or errDie("Unable to get salary processed years.");
if (pg_numrows($run_years) < 1) {
$sal_year_drop = "<input type='hidden' name='salyear' value='" . EMP_YEAR . "'>No Previously Processed Salaries Found.";
} else {
$sal_year_drop = "<select name='salyear'>";
while ($sarr = pg_fetch_array($run_years)) {
if ($sarr['cyear'] == EMP_YEAR) {
$sal_year_drop .= "<option value='{$sarr['cyear']}' selected>{$sarr['cyear']}</option>";
} else {
$sal_year_drop .= "<option value='{$sarr['cyear']}'>{$sarr['cyear']}</option>";
}
}
$sal_year_drop .= "</select>";
}
$OUT = "\n\t\t<h3>Select date range to view</h3>\n\t\t<form action='" . SELF . "' method='POST'>\n\t\t<table " . TMPL_tblDflts . ">\n\t\t\t<input type='hidden' name='key' value='slip'>\n\t\t\t<tr>\n\t\t\t\t<th>Employee</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td align='center'>" . extlib_cpsel("empnum", $employees, $empnum) . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<th>Employee Group</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td align='center'>{$emp_group_drop}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<th colspan='2'>Date Range</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td align='center' colspan='2'>\n\t\t\t\t\t" . mkDateSelect("from", $from_year, $from_month, $from_day) . "\n\t\t\t\t\t TO \n\t\t\t\t\t" . mkDateSelect("to", $to_year, $to_month, $to_day) . "\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<th>Select Salary Financial Year</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td align='center'>{$sal_year_drop}</td>\n\t\t\t</tr>\n\t\t <tr>\n\t\t \t<td colspan='2' align='right'><input type='submit' value='View »'></td>\n\t\t </tr>\n\t </table>\n\t </form>" . mkQuickLinks();
return $OUT;
}