mirror of
https://gitea.psi.ch/ELOG/elog.git
synced 2026-09-14 20:33:48 +00:00
Started working on calendar
SVN revision: 726
This commit is contained in:
parent
5acab922ca
commit
5c820d2d1c
170
src/elogd.c
170
src/elogd.c
@ -6,6 +6,9 @@
|
|||||||
Contents: Web server program for Electronic Logbook ELOG
|
Contents: Web server program for Electronic Logbook ELOG
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.219 2004/01/29 21:20:02 midas
|
||||||
|
Started working on calendar
|
||||||
|
|
||||||
Revision 1.218 2004/01/29 09:53:27 midas
|
Revision 1.218 2004/01/29 09:53:27 midas
|
||||||
Use \r\n in save_admin_config()
|
Use \r\n in save_admin_config()
|
||||||
|
|
||||||
@ -6808,6 +6811,15 @@ void show_find_form(LOGBOOK * lbs)
|
|||||||
rsprintf(" %s: <input type=\"text\" size=5 maxlength=5 name=\"y1\">",
|
rsprintf(" %s: <input type=\"text\" size=5 maxlength=5 name=\"y1\">",
|
||||||
loc("Year"));
|
loc("Year"));
|
||||||
|
|
||||||
|
rsprintf("\n<script language=\"javascript\" type=\"text/javascript\">\n");
|
||||||
|
rsprintf("if (navigator.javaEnabled()) {\n");
|
||||||
|
rsprintf(" document.write(\" \");\n");
|
||||||
|
rsprintf
|
||||||
|
(" document.write(\"<input type=button value=\\\"%s\\\" onClick=window.open(\\\"cal.html\\\",\\\"\\\",\\\"width=300,height=220,dependent=yes,menubar=no,scrollbars=no,location=no\\\");>\");\n",
|
||||||
|
loc("Calendar"));
|
||||||
|
rsprintf("} \n");
|
||||||
|
rsprintf("</script>\n");
|
||||||
|
|
||||||
rsprintf(" / %s: ", loc("Show last"));
|
rsprintf(" / %s: ", loc("Show last"));
|
||||||
|
|
||||||
rsprintf("<select name=last>\n");
|
rsprintf("<select name=last>\n");
|
||||||
@ -6838,6 +6850,16 @@ void show_find_form(LOGBOOK * lbs)
|
|||||||
|
|
||||||
rsprintf(" %s: <input type=\"text\" size=5 maxlength=5 name=\"y2\">",
|
rsprintf(" %s: <input type=\"text\" size=5 maxlength=5 name=\"y2\">",
|
||||||
loc("Year"));
|
loc("Year"));
|
||||||
|
|
||||||
|
rsprintf("\n<script language=\"javascript\" type=\"text/javascript\">\n");
|
||||||
|
rsprintf("if (navigator.javaEnabled()) {\n");
|
||||||
|
rsprintf(" document.write(\" \");\n");
|
||||||
|
rsprintf
|
||||||
|
(" document.write(\"<input type=button value=\\\"%s\\\" onClick=window.open(\\\"cal.html\\\",\\\"\\\",\\\"width=300,height=220,dependent=yes,menubar=no,scrollbars=no,location=no\\\");>\");\n",
|
||||||
|
loc("Calendar"));
|
||||||
|
rsprintf("} \n");
|
||||||
|
rsprintf("</script>\n");
|
||||||
|
|
||||||
rsprintf("</td></tr>\n");
|
rsprintf("</td></tr>\n");
|
||||||
|
|
||||||
for (i = 0; i < lbs->n_attr; i++) {
|
for (i = 0; i < lbs->n_attr; i++) {
|
||||||
@ -9235,9 +9257,11 @@ void synchronize_logbook(LOGBOOK * lbs, BOOL bcron)
|
|||||||
} else if (!bcron) {
|
} else if (!bcron) {
|
||||||
|
|
||||||
if (getcfg_topgroup())
|
if (getcfg_topgroup())
|
||||||
rsprintf("<a href=\"../%s/%d\">ID%d:</a>\t", lbs->name_enc, message_id, message_id);
|
rsprintf("<a href=\"../%s/%d\">ID%d:</a>\t", lbs->name_enc,
|
||||||
|
message_id, message_id);
|
||||||
else
|
else
|
||||||
rsprintf("<a href=\"%s/%d\">ID%d:</a>\t", lbs->name_enc, message_id, message_id);
|
rsprintf("<a href=\"%s/%d\">ID%d:</a>\t", lbs->name_enc, message_id,
|
||||||
|
message_id);
|
||||||
|
|
||||||
rsprintf("%s\n", loc("Remote entry received"));
|
rsprintf("%s\n", loc("Remote entry received"));
|
||||||
}
|
}
|
||||||
@ -9395,9 +9419,11 @@ void synchronize_logbook(LOGBOOK * lbs, BOOL bcron)
|
|||||||
} else if (!bcron) {
|
} else if (!bcron) {
|
||||||
|
|
||||||
if (getcfg_topgroup())
|
if (getcfg_topgroup())
|
||||||
rsprintf("<a href=\"../%s/%d\">ID%d:</a>\t", lbs->name_enc, message_id, message_id);
|
rsprintf("<a href=\"../%s/%d\">ID%d:</a>\t", lbs->name_enc,
|
||||||
|
message_id, message_id);
|
||||||
else
|
else
|
||||||
rsprintf("<a href=\"%s/%d\">ID%d:</a>\t", lbs->name_enc, message_id, message_id);
|
rsprintf("<a href=\"%s/%d\">ID%d:</a>\t", lbs->name_enc,
|
||||||
|
message_id, message_id);
|
||||||
|
|
||||||
rsprintf("%s\n", loc("Remote entry received"));
|
rsprintf("%s\n", loc("Remote entry received"));
|
||||||
}
|
}
|
||||||
@ -11268,7 +11294,8 @@ void show_elog_list(LOGBOOK * lbs, INT past_n, INT last_n, INT page_n)
|
|||||||
else if (page_n == -1)
|
else if (page_n == -1)
|
||||||
sprintf(str + strlen(str), loc("all entries"));
|
sprintf(str + strlen(str), loc("all entries"));
|
||||||
else if (page_n)
|
else if (page_n)
|
||||||
sprintf(str + strlen(str), loc("Page %d of %d"), page_n, (n_msg - 1) / n_page + 1);
|
sprintf(str + strlen(str), loc("Page %d of %d"), page_n,
|
||||||
|
(n_msg - 1) / n_page + 1);
|
||||||
if (strlen(str) == 2)
|
if (strlen(str) == 2)
|
||||||
str[0] = 0;
|
str[0] = 0;
|
||||||
|
|
||||||
@ -11324,14 +11351,14 @@ void show_elog_list(LOGBOOK * lbs, INT past_n, INT last_n, INT page_n)
|
|||||||
if (equal_ustring(menu_item[i], "Last x")) {
|
if (equal_ustring(menu_item[i], "Last x")) {
|
||||||
if (past_n) {
|
if (past_n) {
|
||||||
sprintf(str, loc("Last %d days"), past_n * 2);
|
sprintf(str, loc("Last %d days"), past_n * 2);
|
||||||
rsprintf(" <a href=\"past%d?mode=%s\">%s</a> |\n", past_n * 2,
|
rsprintf(" <a href=\"past%d?mode=%s\">%s</a> |\n",
|
||||||
mode, str);
|
past_n * 2, mode, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (last_n) {
|
if (last_n) {
|
||||||
sprintf(str, loc("Last %d entries"), last_n * 2);
|
sprintf(str, loc("Last %d entries"), last_n * 2);
|
||||||
rsprintf(" <a href=\"last%d?mode=%s\">%s</a> |\n", last_n * 2,
|
rsprintf(" <a href=\"last%d?mode=%s\">%s</a> |\n",
|
||||||
mode, str);
|
last_n * 2, mode, str);
|
||||||
}
|
}
|
||||||
} else if (equal_ustring(menu_item[i], "Select")) {
|
} else if (equal_ustring(menu_item[i], "Select")) {
|
||||||
strcpy(str, getparam("cmdline"));
|
strcpy(str, getparam("cmdline"));
|
||||||
@ -11340,7 +11367,8 @@ void show_elog_list(LOGBOOK * lbs, INT past_n, INT last_n, INT page_n)
|
|||||||
if (strstr(str, "select=1")) {
|
if (strstr(str, "select=1")) {
|
||||||
*strstr(str, "select=1") = 0;
|
*strstr(str, "select=1") = 0;
|
||||||
if (strlen(str) > 1
|
if (strlen(str) > 1
|
||||||
&& (str[strlen(str) - 1] == '&' || str[strlen(str) - 1] == '?'))
|
&& (str[strlen(str) - 1] == '&'
|
||||||
|
|| str[strlen(str) - 1] == '?'))
|
||||||
str[strlen(str) - 1] = 0;
|
str[strlen(str) - 1] = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -11407,7 +11435,8 @@ void show_elog_list(LOGBOOK * lbs, INT past_n, INT last_n, INT page_n)
|
|||||||
|
|
||||||
/*---- display filters ----*/
|
/*---- display filters ----*/
|
||||||
|
|
||||||
disp_filter = *getparam("m1") || *getparam("y1") || *getparam("d1") || *getparam("m2")
|
disp_filter = *getparam("m1") || *getparam("y1") || *getparam("d1")
|
||||||
|
|| *getparam("m2")
|
||||||
|| *getparam("y2") || *getparam("d2")
|
|| *getparam("y2") || *getparam("d2")
|
||||||
|| *getparam("subtext");
|
|| *getparam("subtext");
|
||||||
|
|
||||||
@ -11698,7 +11727,8 @@ void show_elog_list(LOGBOOK * lbs, INT past_n, INT last_n, INT page_n)
|
|||||||
index, mode, expand, 0, printable, n_line,
|
index, mode, expand, 0, printable, n_line,
|
||||||
show_attachments, date, in_reply_to, reply_to,
|
show_attachments, date, in_reply_to, reply_to,
|
||||||
n_attr_disp, disp_attr, attrib, lbs->n_attr, text,
|
n_attr_disp, disp_attr, attrib, lbs->n_attr, text,
|
||||||
attachment, encoding, atoi(getparam("select")), &n_display, locked_by);
|
attachment, encoding, atoi(getparam("select")), &n_display,
|
||||||
|
locked_by);
|
||||||
|
|
||||||
if (threaded) {
|
if (threaded) {
|
||||||
if (reply_to[0] && expand > 0) {
|
if (reply_to[0] && expand > 0) {
|
||||||
@ -14035,6 +14065,116 @@ int do_self_register(LOGBOOK * lbs, char *command)
|
|||||||
|
|
||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
void show_calendar(LOGBOOK * lbs)
|
||||||
|
{
|
||||||
|
int i, j, cur_mon, cur_day, cur_year, today_day, today_mon, today_year;
|
||||||
|
time_t now, stime;
|
||||||
|
struct tm *ts;
|
||||||
|
char str[256];
|
||||||
|
|
||||||
|
time(&now);
|
||||||
|
ts = localtime(&now);
|
||||||
|
today_mon = ts->tm_mon + 1;
|
||||||
|
today_day = ts->tm_mday;
|
||||||
|
today_year = ts->tm_year + 1900;
|
||||||
|
|
||||||
|
if (isparam("m") && isparam("y")) {
|
||||||
|
cur_mon = atoi(getparam("m"));
|
||||||
|
cur_year = atoi(getparam("y"));
|
||||||
|
cur_day = -1;
|
||||||
|
ts->tm_mday = 1;
|
||||||
|
ts->tm_mon = cur_mon - 1;
|
||||||
|
ts->tm_year = cur_year - 1900;
|
||||||
|
mktime(ts);
|
||||||
|
} else {
|
||||||
|
cur_mon = ts->tm_mon + 1;
|
||||||
|
cur_day = ts->tm_mday;
|
||||||
|
cur_year = ts->tm_year + 1900;
|
||||||
|
}
|
||||||
|
|
||||||
|
show_html_header(lbs, TRUE, loc("Calendar"));
|
||||||
|
rsprintf("<body>\n");
|
||||||
|
rsprintf
|
||||||
|
("<table border=1 width=294 height=214><tr><td colspan=7 class=\"caltitle\">\n");
|
||||||
|
|
||||||
|
/* link to previous month */
|
||||||
|
if (cur_mon > 1)
|
||||||
|
rsprintf("<a href=\"?m=%d&y=%d\"><</a>", cur_mon - 1, cur_year);
|
||||||
|
else
|
||||||
|
rsprintf("<a href=\"?m=%d&y=%d\"><</a>", 12, cur_year - 1);
|
||||||
|
|
||||||
|
/* current month */
|
||||||
|
strftime(str, sizeof(str), "%B", ts);
|
||||||
|
rsprintf(" %s ", str);
|
||||||
|
|
||||||
|
/* link to next month */
|
||||||
|
if (cur_mon == 12)
|
||||||
|
rsprintf("<a href=\"?m=%d&y=%d\">></a>", 1, cur_year + 1);
|
||||||
|
else
|
||||||
|
rsprintf("<a href=\"?m=%d&y=%d\">></a>", cur_mon + 1, cur_year);
|
||||||
|
|
||||||
|
/* link to previous year */
|
||||||
|
rsprintf(" ");
|
||||||
|
rsprintf("<a href=\"?m=%d&y=%d\"><</a>", cur_mon, cur_year - 1);
|
||||||
|
|
||||||
|
/* current year */
|
||||||
|
rsprintf(" %d ", cur_year);
|
||||||
|
|
||||||
|
/* link to next year */
|
||||||
|
rsprintf("<a href=\"?m=%d&y=%d\">></a>", cur_mon, cur_year + 1);
|
||||||
|
|
||||||
|
/* go to first day of month */
|
||||||
|
ts->tm_mday = 1;
|
||||||
|
stime = mktime(ts);
|
||||||
|
|
||||||
|
/* go to last sunday */
|
||||||
|
stime = stime - 3600 * 24 * ts->tm_wday;
|
||||||
|
|
||||||
|
rsprintf("<tr>\n");
|
||||||
|
for (i = 0; i < 7; i++) {
|
||||||
|
ts = localtime(&stime);
|
||||||
|
strftime(str, sizeof(str), "%a", ts);
|
||||||
|
rsprintf("<td class=\"calhead\">%s</td>\n", str);
|
||||||
|
stime += 3600 * 24;
|
||||||
|
}
|
||||||
|
rsprintf("</tr>\n");
|
||||||
|
stime -= 3600 * 24 * 7;
|
||||||
|
ts = localtime(&stime);
|
||||||
|
|
||||||
|
/* onClick='window.close(); opener.document.form1.y1 = 2004;'; */
|
||||||
|
|
||||||
|
for (i = 0; i < 6; i++) {
|
||||||
|
rsprintf("<tr>\n");
|
||||||
|
|
||||||
|
for (j = 0; j < 7; j++) {
|
||||||
|
if (ts->tm_mon + 1 == cur_mon)
|
||||||
|
sprintf(str, "%d", ts->tm_mday);
|
||||||
|
else
|
||||||
|
strcpy(str, " ");
|
||||||
|
|
||||||
|
if (ts->tm_mday == today_day && ts->tm_mon + 1 == today_mon
|
||||||
|
&& ts->tm_year + 1900 == today_year)
|
||||||
|
rsprintf("<td class=\"calcurday\">%s</td>\n", str);
|
||||||
|
else {
|
||||||
|
if (j == 0)
|
||||||
|
rsprintf("<td class=\"calhday\">%s</td>\n", str);
|
||||||
|
else
|
||||||
|
rsprintf("<td class=\"calday\">%s</td>\n", str);
|
||||||
|
}
|
||||||
|
stime += 3600 * 24;
|
||||||
|
ts = localtime(&stime);
|
||||||
|
}
|
||||||
|
|
||||||
|
rsprintf("</tr>\n");
|
||||||
|
if (ts->tm_mon + 1 != cur_mon)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
rsprintf("</body></html>\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------*/
|
||||||
|
|
||||||
void interprete(char *lbook, char *path)
|
void interprete(char *lbook, char *path)
|
||||||
/********************************************************************\
|
/********************************************************************\
|
||||||
|
|
||||||
@ -14823,6 +14963,12 @@ void interprete(char *lbook, char *path)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* check for calender */
|
||||||
|
if (equal_ustring(dec_path, "cal.html")) {
|
||||||
|
show_calendar(lbs);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* show page listing or display single entry */
|
/* show page listing or display single entry */
|
||||||
if (dec_path[0] == 0)
|
if (dec_path[0] == 0)
|
||||||
show_elog_list(lbs, 0, 0, 1);
|
show_elog_list(lbs, 0, 0, 1);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user