mirror of
https://github.com/acanas/swad-core.git
synced 2024-06-15 21:24:07 +02:00
Version 14.53
This commit is contained in:
parent
343244dc9c
commit
cc995feacf
2
Makefile
2
Makefile
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
OBJS = swad_account.o swad_action.o swad_announcement.o swad_assignment.o swad_attendance.o \
|
OBJS = swad_account.o swad_action.o swad_announcement.o swad_assignment.o swad_attendance.o \
|
||||||
swad_banner.o \
|
swad_banner.o \
|
||||||
swad_centre.o swad_chat.o swad_config.o swad_connected.o swad_country.o swad_course.o swad_cryptography.o \
|
swad_calendar.o swad_centre.o swad_chat.o swad_config.o swad_connected.o swad_country.o swad_course.o swad_cryptography.o \
|
||||||
swad_database.o swad_date.o swad_degree.o swad_department.o \
|
swad_database.o swad_date.o swad_degree.o swad_department.o \
|
||||||
swad_enrollment.o swad_exam.o \
|
swad_enrollment.o swad_exam.o \
|
||||||
swad_file.o swad_file_browser.o swad_forum.o \
|
swad_file.o swad_file_browser.o swad_forum.o \
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "swad_action.h"
|
#include "swad_action.h"
|
||||||
#include "swad_announcement.h"
|
#include "swad_announcement.h"
|
||||||
#include "swad_banner.h"
|
#include "swad_banner.h"
|
||||||
|
#include "swad_calendar.h"
|
||||||
#include "swad_config.h"
|
#include "swad_config.h"
|
||||||
#include "swad_country.h"
|
#include "swad_country.h"
|
||||||
#include "swad_course.h"
|
#include "swad_course.h"
|
||||||
|
@ -1638,7 +1639,7 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
|
||||||
/* ActAdmAsgWrkUsr */{ 792, 2,TabAss,ActAdmAsgWrkUsr ,0x008,0x000,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Brw_ShowFileBrowserOrWorks ,"editfolderuser" },
|
/* ActAdmAsgWrkUsr */{ 792, 2,TabAss,ActAdmAsgWrkUsr ,0x008,0x000,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Brw_ShowFileBrowserOrWorks ,"editfolderuser" },
|
||||||
/* ActReqAsgWrkCrs */{ 899, 3,TabAss,ActReqAsgWrkCrs ,0x110,0x100,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Brw_AskEditWorksCrs ,"folderusers" },
|
/* ActReqAsgWrkCrs */{ 899, 3,TabAss,ActReqAsgWrkCrs ,0x110,0x100,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Brw_AskEditWorksCrs ,"folderusers" },
|
||||||
/* ActReqTst */{ 103, 4,TabAss,ActReqTst ,0x118,0x100,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Tst_ShowFormAskTst ,"test" },
|
/* ActReqTst */{ 103, 4,TabAss,ActReqTst ,0x118,0x100,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Tst_ShowFormAskTst ,"test" },
|
||||||
/* ActSeeCal */{ 16, 5,TabAss,ActSeeCal ,0x1FF,0x1FF,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Dat_DrawCalendar ,"date" },
|
/* ActSeeCal */{ 16, 5,TabAss,ActSeeCal ,0x1FF,0x1FF,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Cal_DrawCalendar ,"date" },
|
||||||
/* ActSeeExaAnn */{ 85, 6,TabAss,ActSeeExaAnn ,0x1FF,0x1FF,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Exa_ListExamAnnouncementsSee ,"announce" },
|
/* ActSeeExaAnn */{ 85, 6,TabAss,ActSeeExaAnn ,0x1FF,0x1FF,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Exa_ListExamAnnouncementsSee ,"announce" },
|
||||||
/* ActSeeAdmMrk */{ 17, 7,TabAss,ActSeeAdmMrk ,0x118,0x100,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Brw_ShowFileBrowserOrWorks ,"grades" },
|
/* ActSeeAdmMrk */{ 17, 7,TabAss,ActSeeAdmMrk ,0x118,0x100,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Brw_ShowFileBrowserOrWorks ,"grades" },
|
||||||
/* ActSeeRecCrs */{ 299, 8,TabAss,ActSeeRecCrs ,0x108,0x100,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Rec_ShowFormMyCrsRecord ,"editcard" },
|
/* ActSeeRecCrs */{ 299, 8,TabAss,ActSeeRecCrs ,0x108,0x100,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Rec_ShowFormMyCrsRecord ,"editcard" },
|
||||||
|
@ -1769,7 +1770,7 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
|
||||||
/* ActSeeUsrTstExa */{1081,-1,TabAss,ActReqTst ,0x110,0x100,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Tst_ShowUsrsTestResults ,NULL},
|
/* ActSeeUsrTstExa */{1081,-1,TabAss,ActReqTst ,0x110,0x100,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Tst_ShowUsrsTestResults ,NULL},
|
||||||
/* ActSeeOneTstExaOth*/{1082,-1,TabAss,ActReqTst ,0x110,0x100,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Tst_ShowOneTestExam ,NULL},
|
/* ActSeeOneTstExaOth*/{1082,-1,TabAss,ActReqTst ,0x110,0x100,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Tst_ShowOneTestExam ,NULL},
|
||||||
|
|
||||||
/* ActPrnCal */{ 71,-1,TabAss,ActSeeCal ,0x1FF,0x1FF,0x000,Act_CONTENT_NORM,Act_NEW_WINDOW ,NULL ,Dat_DrawCalendar ,NULL},
|
/* ActPrnCal */{ 71,-1,TabAss,ActSeeCal ,0x1FF,0x1FF,0x000,Act_CONTENT_NORM,Act_NEW_WINDOW ,NULL ,Cal_DrawCalendar ,NULL},
|
||||||
|
|
||||||
/* ActEdiExaAnn */{ 91,-1,TabAss,ActSeeExaAnn ,0x110,0x100,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Exa_PutFrmEditAExamAnnouncement,NULL},
|
/* ActEdiExaAnn */{ 91,-1,TabAss,ActSeeExaAnn ,0x110,0x100,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Exa_PutFrmEditAExamAnnouncement,NULL},
|
||||||
/* ActRcvExaAnn */{ 110,-1,TabAss,ActSeeExaAnn ,0x110,0x100,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Exa_ReceiveExamAnnouncement ,NULL},
|
/* ActRcvExaAnn */{ 110,-1,TabAss,ActSeeExaAnn ,0x110,0x100,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Exa_ReceiveExamAnnouncement ,NULL},
|
||||||
|
|
410
swad_calendar.c
Normal file
410
swad_calendar.c
Normal file
|
@ -0,0 +1,410 @@
|
||||||
|
// swad_calendar.c: Draw month and calendar
|
||||||
|
|
||||||
|
/*
|
||||||
|
SWAD (Shared Workspace At a Distance),
|
||||||
|
is a web platform developed at the University of Granada (Spain),
|
||||||
|
and used to support university teaching.
|
||||||
|
|
||||||
|
This file is part of SWAD core.
|
||||||
|
Copyright (C) 1999-2015 Antonio Cañas Vargas
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
|
/********************************* Headers ***********************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#include <string.h> // For string functions
|
||||||
|
|
||||||
|
#include "swad_exam.h"
|
||||||
|
#include "swad_global.h"
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************** External global variables from others modules ****************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
extern struct Globals Gbl;
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/**************************** Private constants ******************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/***************************** Private prototypes ****************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static void Cal_DrawMonth (unsigned RealYear,unsigned RealMonth,
|
||||||
|
bool DrawingCalendar,bool PutLinkToEvents,bool PrintView);
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/***************************** Draw current month ****************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void Cal_DrawCurrentMonth (void)
|
||||||
|
{
|
||||||
|
/***** Get list of holidays *****/
|
||||||
|
if (!Gbl.Hlds.LstIsRead)
|
||||||
|
{
|
||||||
|
Gbl.Hlds.SelectedOrderType = Hld_ORDER_BY_START_DATE;
|
||||||
|
Hld_GetListHolidays ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/***** Create list of dates of exam announcements *****/
|
||||||
|
Exa_CreateListOfExamAnnouncements ();
|
||||||
|
|
||||||
|
/***** Draw the month *****/
|
||||||
|
Cal_DrawMonth (Gbl.Now.Date.Year,Gbl.Now.Date.Month,false,true,false);
|
||||||
|
|
||||||
|
/***** Free list of dates of exam announcements *****/
|
||||||
|
Exa_FreeListExamAnnouncements ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************************ Draw an academic calendar **************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Current Starting
|
||||||
|
month month
|
||||||
|
1 -> 9
|
||||||
|
2 -> 9
|
||||||
|
3 -> 9
|
||||||
|
4 -> 9
|
||||||
|
|
||||||
|
5 -> 1
|
||||||
|
6 -> 1
|
||||||
|
7 -> 1
|
||||||
|
8 -> 1
|
||||||
|
|
||||||
|
9 -> 5
|
||||||
|
10 -> 5
|
||||||
|
11 -> 5
|
||||||
|
12 -> 5
|
||||||
|
*/
|
||||||
|
void Cal_DrawCalendar (void)
|
||||||
|
{
|
||||||
|
static unsigned StartingMonth[1+12] = // Calendar starts one row before current month
|
||||||
|
{
|
||||||
|
0, // Not used
|
||||||
|
9, // January --> September
|
||||||
|
9, // February --> September
|
||||||
|
9, // Mars --> September
|
||||||
|
9, // April --> September
|
||||||
|
1, // May --> January
|
||||||
|
1, // June --> January
|
||||||
|
1, // July --> January
|
||||||
|
1, // Agoust --> January
|
||||||
|
5, // September --> May
|
||||||
|
5, // October --> May
|
||||||
|
5, // November --> May
|
||||||
|
5, // December --> May
|
||||||
|
};
|
||||||
|
unsigned Row,Col;
|
||||||
|
unsigned Month = StartingMonth[Gbl.Now.Date.Month];
|
||||||
|
unsigned Year = (Month < Gbl.Now.Date.Month) ? Gbl.Now.Date.Year :
|
||||||
|
Gbl.Now.Date.Year - 1;
|
||||||
|
bool PrintView = (Gbl.CurrentAct == ActPrnCal);
|
||||||
|
|
||||||
|
/***** Get list of holidays *****/
|
||||||
|
if (!Gbl.Hlds.LstIsRead)
|
||||||
|
{
|
||||||
|
Gbl.Hlds.SelectedOrderType = Hld_ORDER_BY_START_DATE;
|
||||||
|
Hld_GetListHolidays ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/***** Start of table and title *****/
|
||||||
|
if (!PrintView)
|
||||||
|
{
|
||||||
|
/* Link to print view */
|
||||||
|
fprintf (Gbl.F.Out,"<div style=\"text-align:center;\">");
|
||||||
|
Lay_PutLinkToPrintView1 (ActPrnCal);
|
||||||
|
Lay_PutLinkToPrintView2 ();
|
||||||
|
fprintf (Gbl.F.Out,"</div>");
|
||||||
|
}
|
||||||
|
Lay_StartRoundFrameTable10 (NULL,0,NULL);
|
||||||
|
Lay_WriteHeaderClassPhoto (1,PrintView,false,
|
||||||
|
Gbl.CurrentIns.Ins.InsCod,
|
||||||
|
Gbl.CurrentDeg.Deg.DegCod,
|
||||||
|
Gbl.CurrentCrs.Crs.CrsCod);
|
||||||
|
|
||||||
|
/***** Create list of calls for examination *****/
|
||||||
|
Exa_CreateListOfExamAnnouncements ();
|
||||||
|
|
||||||
|
/***** Draw several months *****/
|
||||||
|
fprintf (Gbl.F.Out,"<tr>"
|
||||||
|
"<td style=\"text-align:center;\">"
|
||||||
|
"<table style=\"margin:0 auto; border-spacing:5px;\">");
|
||||||
|
for (Row = 0;
|
||||||
|
Row < 4;
|
||||||
|
Row++)
|
||||||
|
{
|
||||||
|
fprintf (Gbl.F.Out,"<tr>");
|
||||||
|
for (Col = 0;
|
||||||
|
Col < 4;
|
||||||
|
Col++)
|
||||||
|
{
|
||||||
|
fprintf (Gbl.F.Out,"<td style=\"width:120px;"
|
||||||
|
" text-align:center; vertical-align:top;\">");
|
||||||
|
Cal_DrawMonth (Year,Month,true,!PrintView,(Gbl.CurrentAct == ActPrnCal));
|
||||||
|
fprintf (Gbl.F.Out,"</td>");
|
||||||
|
if (++Month == 13)
|
||||||
|
{
|
||||||
|
Month = 1;
|
||||||
|
Year++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fprintf (Gbl.F.Out,"</tr>");
|
||||||
|
}
|
||||||
|
fprintf (Gbl.F.Out,"</table>"
|
||||||
|
"</td>"
|
||||||
|
"</tr>");
|
||||||
|
|
||||||
|
/***** Free list of dates of exam announcements *****/
|
||||||
|
Exa_FreeListExamAnnouncements ();
|
||||||
|
|
||||||
|
/***** End frame *****/
|
||||||
|
Lay_EndRoundFrameTable10 ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/******************************** Draw a month *******************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static void Cal_DrawMonth (unsigned RealYear,unsigned RealMonth,
|
||||||
|
bool DrawingCalendar,bool PutLinkToEvents,bool PrintView)
|
||||||
|
{
|
||||||
|
extern const unsigned Dat_NumDaysMonth[1+12];
|
||||||
|
extern const char *Txt_Show_calendar;
|
||||||
|
extern const char *Txt_DAYS_CAPS[7];
|
||||||
|
extern const char *Txt_MONTHS_CAPS[12];
|
||||||
|
extern const char *Txt_Exam_of_X;
|
||||||
|
char StrExamOfX[512+Crs_MAX_LENGTH_COURSE_FULL_NAME];
|
||||||
|
unsigned Week;
|
||||||
|
unsigned DayOfWeek; /* 0, 1, 2, 3, 4, 5 ó 6 */
|
||||||
|
unsigned DayOfMonth;
|
||||||
|
unsigned NumDaysInMonth;
|
||||||
|
unsigned Year = RealYear;
|
||||||
|
unsigned Month = RealMonth;
|
||||||
|
char YYYYMMDD[4+2+2+1];
|
||||||
|
unsigned NumHld;
|
||||||
|
char *ClassForDay; // Class of day depending on type of day
|
||||||
|
char *TextForDay; // Text associated to a day, for example the name of the holiday
|
||||||
|
unsigned NumExamAnnouncement; // Number of exam announcement
|
||||||
|
int ResultOfCmpStartDate;
|
||||||
|
bool ContinueSearching;
|
||||||
|
bool PutLinkToCalendar = !DrawingCalendar && Gbl.CurrentCrs.Crs.CrsCod > 0;
|
||||||
|
bool ThisDayHasEvent = false;
|
||||||
|
bool IsToday;
|
||||||
|
|
||||||
|
/***** Compute number of day of month for the first box *****/
|
||||||
|
/* The initial day of month can be -5, -4, -3, -2, -1, 0, or 1
|
||||||
|
If it's -5 then write 6 boxes of the previous month.
|
||||||
|
If it's -4 then write 5 boxes of the previous month.
|
||||||
|
If it's -3 then write 4 boxes of the previous month.
|
||||||
|
If it's -2 then write 3 boxes of the previous month.
|
||||||
|
If it's -1 then write 2 boxes of the previous month.
|
||||||
|
If it's 0 then write 1 box of the previous month.
|
||||||
|
If it's 1 then write 0 boxes of the previous month. */
|
||||||
|
|
||||||
|
if ((DayOfWeek = Dat_GetDayOfWeek (Year,Month,1)) == 0)
|
||||||
|
DayOfMonth = 1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Month <= 1)
|
||||||
|
{
|
||||||
|
Month = 12;
|
||||||
|
Year--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Month--;
|
||||||
|
NumDaysInMonth = (Month == 2) ? Dat_GetNumDaysFebruary (Year) :
|
||||||
|
Dat_NumDaysMonth[Month];
|
||||||
|
DayOfMonth = NumDaysInMonth - DayOfWeek + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***** Start of month *****/
|
||||||
|
fprintf (Gbl.F.Out,"<div class=\"MONTH_CONTAINER\">");
|
||||||
|
|
||||||
|
/***** Month name *****/
|
||||||
|
fprintf (Gbl.F.Out,"<div class=\"MONTH\">");
|
||||||
|
if (PutLinkToCalendar)
|
||||||
|
{
|
||||||
|
Act_FormStart (ActSeeCal);
|
||||||
|
Act_LinkFormSubmit (Txt_Show_calendar,"MONTH");
|
||||||
|
}
|
||||||
|
fprintf (Gbl.F.Out,"%s %u",
|
||||||
|
Txt_MONTHS_CAPS[RealMonth-1],RealYear);
|
||||||
|
if (PutLinkToCalendar)
|
||||||
|
fprintf (Gbl.F.Out,"</a>"
|
||||||
|
"</form>");
|
||||||
|
fprintf (Gbl.F.Out,"</div>");
|
||||||
|
|
||||||
|
/***** Month head: first letter for each day of week *****/
|
||||||
|
fprintf (Gbl.F.Out,"<table class=\"MONTH_TABLE_DAYS\">"
|
||||||
|
"<tr>");
|
||||||
|
for (DayOfWeek = 0;
|
||||||
|
DayOfWeek < 7;
|
||||||
|
DayOfWeek++)
|
||||||
|
fprintf (Gbl.F.Out,"<td class=\"%s\" style=\"text-align:center;\">"
|
||||||
|
"%c"
|
||||||
|
"</td>",
|
||||||
|
(DayOfWeek == 6) ? "DAY_NO_WRK_HEAD" :
|
||||||
|
"DAY_WRK_HEAD",
|
||||||
|
Txt_DAYS_CAPS[DayOfWeek][0]);
|
||||||
|
fprintf (Gbl.F.Out,"</tr>");
|
||||||
|
|
||||||
|
/***** Draw every week of the month *****/
|
||||||
|
for (Week = 0;
|
||||||
|
Week < 6;
|
||||||
|
Week++)
|
||||||
|
{
|
||||||
|
fprintf (Gbl.F.Out,"<tr>");
|
||||||
|
|
||||||
|
/***** Draw every day of the week *****/
|
||||||
|
for (DayOfWeek = 0;
|
||||||
|
DayOfWeek < 7;
|
||||||
|
DayOfWeek++)
|
||||||
|
{
|
||||||
|
/***** Set class for day being drawn *****/
|
||||||
|
ClassForDay = (Month == RealMonth) ? "DAY_WRK" :
|
||||||
|
"DAY_WRK_LIGHT";
|
||||||
|
TextForDay = NULL;
|
||||||
|
|
||||||
|
/* Check if day is a holiday or a school day */
|
||||||
|
sprintf (YYYYMMDD,"%04u%02u%02u",Year,Month,DayOfMonth);
|
||||||
|
for (NumHld = 0, ContinueSearching = true;
|
||||||
|
NumHld < Gbl.Hlds.Num && ContinueSearching;
|
||||||
|
NumHld++)
|
||||||
|
if (Gbl.Hlds.Lst[NumHld].PlcCod <= 0 ||
|
||||||
|
Gbl.Hlds.Lst[NumHld].PlcCod == Gbl.CurrentCtr.Ctr.PlcCod)
|
||||||
|
{
|
||||||
|
ResultOfCmpStartDate = strcmp (Gbl.Hlds.Lst[NumHld].StartDate.YYYYMMDD,YYYYMMDD);
|
||||||
|
if (ResultOfCmpStartDate > 0) // List is ordered by start date. If start date is greater than date being drawn, don't continue searching
|
||||||
|
|
||||||
|
ContinueSearching = false;
|
||||||
|
else // ResultOfCmpStartDate <= 0 <==> start date <= date being drawn
|
||||||
|
switch (Gbl.Hlds.Lst[NumHld].HldTyp)
|
||||||
|
{
|
||||||
|
case Hld_HOLIDAY:
|
||||||
|
if (ResultOfCmpStartDate == 0) // If start date == date being drawn
|
||||||
|
{
|
||||||
|
ClassForDay = (Month == RealMonth) ? "DAY_HLD" :
|
||||||
|
"DAY_HLD_LIGHT";
|
||||||
|
TextForDay = Gbl.Hlds.Lst[NumHld].Name;
|
||||||
|
ContinueSearching = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Hld_NON_SCHOOL_PERIOD:
|
||||||
|
if (strcmp (Gbl.Hlds.Lst[NumHld].EndDate.YYYYMMDD,YYYYMMDD) >= 0) // If start date <= date being drawn <= end date
|
||||||
|
{
|
||||||
|
ClassForDay = (Month == RealMonth) ? "DAY_NO_WORK" :
|
||||||
|
"DAY_NO_WORK_LIGHT";
|
||||||
|
TextForDay = Gbl.Hlds.Lst[NumHld].Name;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Day being drawn is sunday? */
|
||||||
|
if (DayOfWeek == 6) // All the sundays are holidays
|
||||||
|
ClassForDay = (Month == RealMonth) ? "DAY_HLD" :
|
||||||
|
"DAY_HLD_LIGHT";
|
||||||
|
|
||||||
|
/* Date being drawn is today? */
|
||||||
|
IsToday = (Gbl.CurrentAct != ActPrnCal && Month == RealMonth &&
|
||||||
|
Year == Gbl.Now.Date.Year &&
|
||||||
|
Month == Gbl.Now.Date.Month &&
|
||||||
|
DayOfMonth == Gbl.Now.Date.Day);
|
||||||
|
|
||||||
|
/* Check if day has an exam announcement */
|
||||||
|
ThisDayHasEvent = false;
|
||||||
|
if (!DrawingCalendar || Month == RealMonth) // If drawing calendar and the month is not the real one, don't draw exam announcements
|
||||||
|
for (NumExamAnnouncement = 0;
|
||||||
|
NumExamAnnouncement < Gbl.LstExamAnnouncements.NumExamAnnounc;
|
||||||
|
NumExamAnnouncement++)
|
||||||
|
if (Year == Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Year &&
|
||||||
|
Month == Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Month &&
|
||||||
|
DayOfMonth == Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Day)
|
||||||
|
{
|
||||||
|
ThisDayHasEvent = true;
|
||||||
|
if (PutLinkToEvents)
|
||||||
|
{
|
||||||
|
sprintf (StrExamOfX,Txt_Exam_of_X,Gbl.CurrentCrs.Crs.FullName);
|
||||||
|
sprintf (Gbl.Title,"%s: %02u/%02u/%04u",
|
||||||
|
StrExamOfX,
|
||||||
|
Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Day,
|
||||||
|
Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Month,
|
||||||
|
Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Year);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***** Write the box with the day *****/
|
||||||
|
fprintf (Gbl.F.Out,"<td class=\"%s\" style=\"text-align:center;\">",
|
||||||
|
IsToday ? (ThisDayHasEvent ? "TODAY_EVENT" :
|
||||||
|
"TODAY") :
|
||||||
|
(ThisDayHasEvent ? "DAY_EVENT" :
|
||||||
|
"DAY" ));
|
||||||
|
|
||||||
|
/* If day has an exam announcement */
|
||||||
|
if (PutLinkToEvents && ThisDayHasEvent)
|
||||||
|
{
|
||||||
|
Act_FormStart (ActSeeExaAnn);
|
||||||
|
fprintf (Gbl.F.Out,"<table style=\"width:100%%;\">"
|
||||||
|
"<tr>"
|
||||||
|
"<td class=\"%s\" style=\"text-align:center;\">",
|
||||||
|
ClassForDay);
|
||||||
|
Act_LinkFormSubmit (Gbl.Title,ClassForDay);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf (Gbl.F.Out,"<div class=\"%s\"",ClassForDay);
|
||||||
|
if (!PrintView && TextForDay)
|
||||||
|
fprintf (Gbl.F.Out," title=\"%s\"",TextForDay);
|
||||||
|
fprintf (Gbl.F.Out,">");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Write the day of month */
|
||||||
|
fprintf (Gbl.F.Out,"%u",DayOfMonth);
|
||||||
|
|
||||||
|
/* If day has an exam announcement */
|
||||||
|
if (PutLinkToEvents && ThisDayHasEvent)
|
||||||
|
fprintf (Gbl.F.Out,"</a>"
|
||||||
|
"</td>"
|
||||||
|
"</tr>"
|
||||||
|
"</table>"
|
||||||
|
"</form>");
|
||||||
|
else
|
||||||
|
fprintf (Gbl.F.Out,"</div>");
|
||||||
|
|
||||||
|
fprintf (Gbl.F.Out,"</td>");
|
||||||
|
|
||||||
|
/***** Set the next day *****/
|
||||||
|
NumDaysInMonth = (Month == 2) ? Dat_GetNumDaysFebruary (Year) :
|
||||||
|
Dat_NumDaysMonth[Month];
|
||||||
|
if (++DayOfMonth > NumDaysInMonth)
|
||||||
|
{
|
||||||
|
if (++Month > 12)
|
||||||
|
{
|
||||||
|
Year++;
|
||||||
|
Month = 1;
|
||||||
|
}
|
||||||
|
DayOfMonth = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fprintf (Gbl.F.Out,"</tr>");
|
||||||
|
}
|
||||||
|
|
||||||
|
/***** End of month *****/
|
||||||
|
fprintf (Gbl.F.Out,"</table>"
|
||||||
|
"</div>");
|
||||||
|
}
|
45
swad_calendar.h
Normal file
45
swad_calendar.h
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
// swad_calendar.h: Draw month and calendar
|
||||||
|
|
||||||
|
#ifndef _SWAD_CAL
|
||||||
|
#define _SWAD_CAL
|
||||||
|
/*
|
||||||
|
SWAD (Shared Workspace At a Distance in Spanish),
|
||||||
|
is a web platform developed at the University of Granada (Spain),
|
||||||
|
and used to support university teaching.
|
||||||
|
|
||||||
|
This file is part of SWAD core.
|
||||||
|
Copyright (C) 1999-2015 Antonio Cañas Vargas
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
|
/********************************* Headers ***********************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/***************************** Public constants ******************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/******************************* Public types ********************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/***************************** Public prototypes *****************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void Cal_DrawCurrentMonth (void);
|
||||||
|
void Cal_DrawCalendar (void);
|
||||||
|
|
||||||
|
#endif
|
|
@ -35,11 +35,15 @@
|
||||||
/****************************** Public constants *****************************/
|
/****************************** Public constants *****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define Log_PLATFORM_VERSION "SWAD 14.52.6 (2015/01/04)"
|
#define Log_PLATFORM_VERSION "SWAD 14.53 (2015/01/04)"
|
||||||
|
|
||||||
// Number of lines (includes comments but not blank lines) has been got with the following command:
|
// Number of lines (includes comments but not blank lines) has been got with the following command:
|
||||||
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h | tail -1
|
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h | tail -1
|
||||||
/*
|
/*
|
||||||
|
Version 14.53 :Jan 04, 2014 New module swad_calendar for calendar. (173254 lines)
|
||||||
|
1 change necessary in Makefile:
|
||||||
|
Add swad_calendar.o to list of object files
|
||||||
|
|
||||||
Version 14.52.6 :Jan 04, 2014 Fixed bugs for HTML5 validation. (173187 lines)
|
Version 14.52.6 :Jan 04, 2014 Fixed bugs for HTML5 validation. (173187 lines)
|
||||||
Version 14.52.5 :Jan 02, 2014 Changes in CSS. (173170 lines)
|
Version 14.52.5 :Jan 02, 2014 Changes in CSS. (173170 lines)
|
||||||
Version 14.52.4 :Jan 02, 2014 Removed unnecessary titles in statistics. (173169 lines)
|
Version 14.52.4 :Jan 02, 2014 Removed unnecessary titles in statistics. (173169 lines)
|
||||||
|
|
377
swad_date.c
377
swad_date.c
|
@ -25,12 +25,9 @@
|
||||||
/********************************* Headers ***********************************/
|
/********************************* Headers ***********************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#include <ctype.h> // For isdigit
|
|
||||||
#include <linux/stddef.h> // For NULL
|
|
||||||
#include <string.h> // For string functions
|
#include <string.h> // For string functions
|
||||||
#include <time.h> // For time
|
|
||||||
|
|
||||||
#include "swad_exam.h"
|
#include "swad_date.h"
|
||||||
#include "swad_global.h"
|
#include "swad_global.h"
|
||||||
#include "swad_parameter.h"
|
#include "swad_parameter.h"
|
||||||
|
|
||||||
|
@ -44,7 +41,7 @@ extern struct Globals Gbl;
|
||||||
/**************************** Private constants ******************************/
|
/**************************** Private constants ******************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
const unsigned NumDaysMonth[1+12] =
|
const unsigned Dat_NumDaysMonth[1+12] =
|
||||||
{
|
{
|
||||||
0,
|
0,
|
||||||
31, // 1: January
|
31, // 1: January
|
||||||
|
@ -171,367 +168,6 @@ void Dat_ShowCurrentDateTime (void)
|
||||||
Gbl.Now.Time.Hour,Gbl.Now.Time.Minute);
|
Gbl.Now.Time.Hour,Gbl.Now.Time.Minute);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/***************************** Draw current month ****************************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
void Dat_DrawCurrentMonth (void)
|
|
||||||
{
|
|
||||||
/***** Get list of holidays *****/
|
|
||||||
if (!Gbl.Hlds.LstIsRead)
|
|
||||||
{
|
|
||||||
Gbl.Hlds.SelectedOrderType = Hld_ORDER_BY_START_DATE;
|
|
||||||
Hld_GetListHolidays ();
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Create list of dates of exam announcements *****/
|
|
||||||
Exa_CreateListOfExamAnnouncements ();
|
|
||||||
|
|
||||||
/***** Draw the month *****/
|
|
||||||
Dat_DrawMonth (Gbl.Now.Date.Year,Gbl.Now.Date.Month,false,true,false);
|
|
||||||
|
|
||||||
/***** Free list of dates of exam announcements *****/
|
|
||||||
Exa_FreeListExamAnnouncements ();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/************************ Draw an academic calendar **************************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* Current Starting
|
|
||||||
month month
|
|
||||||
1 -> 9
|
|
||||||
2 -> 9
|
|
||||||
3 -> 9
|
|
||||||
4 -> 9
|
|
||||||
|
|
||||||
5 -> 1
|
|
||||||
6 -> 1
|
|
||||||
7 -> 1
|
|
||||||
8 -> 1
|
|
||||||
|
|
||||||
9 -> 5
|
|
||||||
10 -> 5
|
|
||||||
11 -> 5
|
|
||||||
12 -> 5
|
|
||||||
*/
|
|
||||||
void Dat_DrawCalendar (void)
|
|
||||||
{
|
|
||||||
static unsigned StartingMonth[1+12] = // Calendar starts one row before current month
|
|
||||||
{
|
|
||||||
0, // Not used
|
|
||||||
9, // January --> September
|
|
||||||
9, // February --> September
|
|
||||||
9, // Mars --> September
|
|
||||||
9, // April --> September
|
|
||||||
1, // May --> January
|
|
||||||
1, // June --> January
|
|
||||||
1, // July --> January
|
|
||||||
1, // Agoust --> January
|
|
||||||
5, // September --> May
|
|
||||||
5, // October --> May
|
|
||||||
5, // November --> May
|
|
||||||
5, // December --> May
|
|
||||||
};
|
|
||||||
unsigned Row,Col;
|
|
||||||
unsigned Month = StartingMonth[Gbl.Now.Date.Month];
|
|
||||||
unsigned Year = (Month < Gbl.Now.Date.Month) ? Gbl.Now.Date.Year :
|
|
||||||
Gbl.Now.Date.Year - 1;
|
|
||||||
bool PrintView = (Gbl.CurrentAct == ActPrnCal);
|
|
||||||
|
|
||||||
/***** Get list of holidays *****/
|
|
||||||
if (!Gbl.Hlds.LstIsRead)
|
|
||||||
{
|
|
||||||
Gbl.Hlds.SelectedOrderType = Hld_ORDER_BY_START_DATE;
|
|
||||||
Hld_GetListHolidays ();
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Start of table and title *****/
|
|
||||||
if (!PrintView)
|
|
||||||
{
|
|
||||||
/* Link to print view */
|
|
||||||
fprintf (Gbl.F.Out,"<div style=\"text-align:center;\">");
|
|
||||||
Lay_PutLinkToPrintView1 (ActPrnCal);
|
|
||||||
Lay_PutLinkToPrintView2 ();
|
|
||||||
fprintf (Gbl.F.Out,"</div>");
|
|
||||||
}
|
|
||||||
Lay_StartRoundFrameTable10 (NULL,0,NULL);
|
|
||||||
Lay_WriteHeaderClassPhoto (1,PrintView,false,
|
|
||||||
Gbl.CurrentIns.Ins.InsCod,
|
|
||||||
Gbl.CurrentDeg.Deg.DegCod,
|
|
||||||
Gbl.CurrentCrs.Crs.CrsCod);
|
|
||||||
|
|
||||||
/***** Create list of calls for examination *****/
|
|
||||||
Exa_CreateListOfExamAnnouncements ();
|
|
||||||
|
|
||||||
/***** Draw several months *****/
|
|
||||||
fprintf (Gbl.F.Out,"<tr>"
|
|
||||||
"<td style=\"text-align:center;\">"
|
|
||||||
"<table style=\"margin:0 auto; border-spacing:5px;\">");
|
|
||||||
for (Row = 0;
|
|
||||||
Row < 4;
|
|
||||||
Row++)
|
|
||||||
{
|
|
||||||
fprintf (Gbl.F.Out,"<tr>");
|
|
||||||
for (Col = 0;
|
|
||||||
Col < 4;
|
|
||||||
Col++)
|
|
||||||
{
|
|
||||||
fprintf (Gbl.F.Out,"<td style=\"width:120px;"
|
|
||||||
" text-align:center; vertical-align:top;\">");
|
|
||||||
Dat_DrawMonth (Year,Month,true,!PrintView,(Gbl.CurrentAct == ActPrnCal));
|
|
||||||
fprintf (Gbl.F.Out,"</td>");
|
|
||||||
if (++Month == 13)
|
|
||||||
{
|
|
||||||
Month = 1;
|
|
||||||
Year++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fprintf (Gbl.F.Out,"</tr>");
|
|
||||||
}
|
|
||||||
fprintf (Gbl.F.Out,"</table>"
|
|
||||||
"</td>"
|
|
||||||
"</tr>");
|
|
||||||
|
|
||||||
/***** Free list of dates of exam announcements *****/
|
|
||||||
Exa_FreeListExamAnnouncements ();
|
|
||||||
|
|
||||||
/***** End frame *****/
|
|
||||||
Lay_EndRoundFrameTable10 ();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/******************************** Draw a month *******************************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
void Dat_DrawMonth (unsigned RealYear,unsigned RealMonth,
|
|
||||||
bool DrawingCalendar,bool PutLinkToEvents,bool PrintView)
|
|
||||||
{
|
|
||||||
extern const char *Txt_Show_calendar;
|
|
||||||
extern const char *Txt_DAYS_CAPS[7];
|
|
||||||
extern const char *Txt_MONTHS_CAPS[12];
|
|
||||||
extern const char *Txt_Exam_of_X;
|
|
||||||
char StrExamOfX[512+Crs_MAX_LENGTH_COURSE_FULL_NAME];
|
|
||||||
unsigned Week;
|
|
||||||
unsigned DayOfWeek; /* 0, 1, 2, 3, 4, 5 ó 6 */
|
|
||||||
unsigned DayOfMonth;
|
|
||||||
unsigned NumDaysInMonth;
|
|
||||||
unsigned Year = RealYear;
|
|
||||||
unsigned Month = RealMonth;
|
|
||||||
char YYYYMMDD[4+2+2+1];
|
|
||||||
unsigned NumHld;
|
|
||||||
char *ClassForDay; // Class of day depending on type of day
|
|
||||||
char *TextForDay; // Text associated to a day, for example the name of the holiday
|
|
||||||
unsigned NumExamAnnouncement; // Number of exam announcement
|
|
||||||
int ResultOfCmpStartDate;
|
|
||||||
bool ContinueSearching;
|
|
||||||
bool PutLinkToCalendar = !DrawingCalendar && Gbl.CurrentCrs.Crs.CrsCod > 0;
|
|
||||||
bool ThisDayHasEvent = false;
|
|
||||||
bool IsToday;
|
|
||||||
|
|
||||||
/***** Compute number of day of month for the first box *****/
|
|
||||||
/* The initial day of month can be -5, -4, -3, -2, -1, 0, or 1
|
|
||||||
If it's -5 then write 6 boxes of the previous month.
|
|
||||||
If it's -4 then write 5 boxes of the previous month.
|
|
||||||
If it's -3 then write 4 boxes of the previous month.
|
|
||||||
If it's -2 then write 3 boxes of the previous month.
|
|
||||||
If it's -1 then write 2 boxes of the previous month.
|
|
||||||
If it's 0 then write 1 box of the previous month.
|
|
||||||
If it's 1 then write 0 boxes of the previous month. */
|
|
||||||
|
|
||||||
if ((DayOfWeek = Dat_GetDayOfWeek (Year,Month,1)) == 0)
|
|
||||||
DayOfMonth = 1;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (Month <= 1)
|
|
||||||
{
|
|
||||||
Month = 12;
|
|
||||||
Year--;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
Month--;
|
|
||||||
NumDaysInMonth = (Month == 2) ? Dat_GetNumDaysFebruary (Year) :
|
|
||||||
NumDaysMonth[Month];
|
|
||||||
DayOfMonth = NumDaysInMonth - DayOfWeek + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Start of month *****/
|
|
||||||
fprintf (Gbl.F.Out,"<div class=\"MONTH_CONTAINER\">");
|
|
||||||
|
|
||||||
/***** Month name *****/
|
|
||||||
fprintf (Gbl.F.Out,"<div class=\"MONTH\">");
|
|
||||||
if (PutLinkToCalendar)
|
|
||||||
{
|
|
||||||
Act_FormStart (ActSeeCal);
|
|
||||||
Act_LinkFormSubmit (Txt_Show_calendar,"MONTH");
|
|
||||||
}
|
|
||||||
fprintf (Gbl.F.Out,"%s %u",
|
|
||||||
Txt_MONTHS_CAPS[RealMonth-1],RealYear);
|
|
||||||
if (PutLinkToCalendar)
|
|
||||||
fprintf (Gbl.F.Out,"</a>"
|
|
||||||
"</form>");
|
|
||||||
fprintf (Gbl.F.Out,"</div>");
|
|
||||||
|
|
||||||
/***** Month head: first letter for each day of week *****/
|
|
||||||
fprintf (Gbl.F.Out,"<table class=\"MONTH_TABLE_DAYS\">"
|
|
||||||
"<tr>");
|
|
||||||
for (DayOfWeek = 0;
|
|
||||||
DayOfWeek < 7;
|
|
||||||
DayOfWeek++)
|
|
||||||
fprintf (Gbl.F.Out,"<td class=\"%s\" style=\"text-align:center;\">"
|
|
||||||
"%c"
|
|
||||||
"</td>",
|
|
||||||
(DayOfWeek == 6) ? "DAY_NO_WRK_HEAD" :
|
|
||||||
"DAY_WRK_HEAD",
|
|
||||||
Txt_DAYS_CAPS[DayOfWeek][0]);
|
|
||||||
fprintf (Gbl.F.Out,"</tr>");
|
|
||||||
|
|
||||||
/***** Draw every week of the month *****/
|
|
||||||
for (Week = 0;
|
|
||||||
Week < 6;
|
|
||||||
Week++)
|
|
||||||
{
|
|
||||||
fprintf (Gbl.F.Out,"<tr>");
|
|
||||||
|
|
||||||
/***** Draw every day of the week *****/
|
|
||||||
for (DayOfWeek = 0;
|
|
||||||
DayOfWeek < 7;
|
|
||||||
DayOfWeek++)
|
|
||||||
{
|
|
||||||
/***** Set class for day being drawn *****/
|
|
||||||
ClassForDay = (Month == RealMonth) ? "DAY_WRK" :
|
|
||||||
"DAY_WRK_LIGHT";
|
|
||||||
TextForDay = NULL;
|
|
||||||
|
|
||||||
/* Check if day is a holiday or a school day */
|
|
||||||
sprintf (YYYYMMDD,"%04u%02u%02u",Year,Month,DayOfMonth);
|
|
||||||
for (NumHld = 0, ContinueSearching = true;
|
|
||||||
NumHld < Gbl.Hlds.Num && ContinueSearching;
|
|
||||||
NumHld++)
|
|
||||||
if (Gbl.Hlds.Lst[NumHld].PlcCod <= 0 ||
|
|
||||||
Gbl.Hlds.Lst[NumHld].PlcCod == Gbl.CurrentCtr.Ctr.PlcCod)
|
|
||||||
{
|
|
||||||
ResultOfCmpStartDate = strcmp (Gbl.Hlds.Lst[NumHld].StartDate.YYYYMMDD,YYYYMMDD);
|
|
||||||
if (ResultOfCmpStartDate > 0) // List is ordered by start date. If start date is greater than date being drawn, don't continue searching
|
|
||||||
|
|
||||||
ContinueSearching = false;
|
|
||||||
else // ResultOfCmpStartDate <= 0 <==> start date <= date being drawn
|
|
||||||
switch (Gbl.Hlds.Lst[NumHld].HldTyp)
|
|
||||||
{
|
|
||||||
case Hld_HOLIDAY:
|
|
||||||
if (ResultOfCmpStartDate == 0) // If start date == date being drawn
|
|
||||||
{
|
|
||||||
ClassForDay = (Month == RealMonth) ? "DAY_HLD" :
|
|
||||||
"DAY_HLD_LIGHT";
|
|
||||||
TextForDay = Gbl.Hlds.Lst[NumHld].Name;
|
|
||||||
ContinueSearching = false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Hld_NON_SCHOOL_PERIOD:
|
|
||||||
if (strcmp (Gbl.Hlds.Lst[NumHld].EndDate.YYYYMMDD,YYYYMMDD) >= 0) // If start date <= date being drawn <= end date
|
|
||||||
{
|
|
||||||
ClassForDay = (Month == RealMonth) ? "DAY_NO_WORK" :
|
|
||||||
"DAY_NO_WORK_LIGHT";
|
|
||||||
TextForDay = Gbl.Hlds.Lst[NumHld].Name;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Day being drawn is sunday? */
|
|
||||||
if (DayOfWeek == 6) // All the sundays are holidays
|
|
||||||
ClassForDay = (Month == RealMonth) ? "DAY_HLD" :
|
|
||||||
"DAY_HLD_LIGHT";
|
|
||||||
|
|
||||||
/* Date being drawn is today? */
|
|
||||||
IsToday = (Gbl.CurrentAct != ActPrnCal && Month == RealMonth &&
|
|
||||||
Year == Gbl.Now.Date.Year &&
|
|
||||||
Month == Gbl.Now.Date.Month &&
|
|
||||||
DayOfMonth == Gbl.Now.Date.Day);
|
|
||||||
|
|
||||||
/* Check if day has an exam announcement */
|
|
||||||
ThisDayHasEvent = false;
|
|
||||||
if (!DrawingCalendar || Month == RealMonth) // If drawing calendar and the month is not the real one, don't draw exam announcements
|
|
||||||
for (NumExamAnnouncement = 0;
|
|
||||||
NumExamAnnouncement < Gbl.LstExamAnnouncements.NumExamAnnounc;
|
|
||||||
NumExamAnnouncement++)
|
|
||||||
if (Year == Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Year &&
|
|
||||||
Month == Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Month &&
|
|
||||||
DayOfMonth == Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Day)
|
|
||||||
{
|
|
||||||
ThisDayHasEvent = true;
|
|
||||||
if (PutLinkToEvents)
|
|
||||||
{
|
|
||||||
sprintf (StrExamOfX,Txt_Exam_of_X,Gbl.CurrentCrs.Crs.FullName);
|
|
||||||
sprintf (Gbl.Title,"%s: %02u/%02u/%04u",
|
|
||||||
StrExamOfX,
|
|
||||||
Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Day,
|
|
||||||
Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Month,
|
|
||||||
Gbl.LstExamAnnouncements.Lst[NumExamAnnouncement].Year);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Write the box with the day *****/
|
|
||||||
fprintf (Gbl.F.Out,"<td class=\"%s\" style=\"text-align:center;\">",
|
|
||||||
IsToday ? (ThisDayHasEvent ? "TODAY_EVENT" :
|
|
||||||
"TODAY") :
|
|
||||||
(ThisDayHasEvent ? "DAY_EVENT" :
|
|
||||||
"DAY" ));
|
|
||||||
|
|
||||||
/* If day has an exam announcement */
|
|
||||||
if (PutLinkToEvents && ThisDayHasEvent)
|
|
||||||
{
|
|
||||||
Act_FormStart (ActSeeExaAnn);
|
|
||||||
fprintf (Gbl.F.Out,"<table style=\"width:100%%;\">"
|
|
||||||
"<tr>"
|
|
||||||
"<td class=\"%s\" style=\"text-align:center;\">",
|
|
||||||
ClassForDay);
|
|
||||||
Act_LinkFormSubmit (Gbl.Title,ClassForDay);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fprintf (Gbl.F.Out,"<div class=\"%s\"",ClassForDay);
|
|
||||||
if (!PrintView && TextForDay)
|
|
||||||
fprintf (Gbl.F.Out," title=\"%s\"",TextForDay);
|
|
||||||
fprintf (Gbl.F.Out,">");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Write the day of month */
|
|
||||||
fprintf (Gbl.F.Out,"%u",DayOfMonth);
|
|
||||||
|
|
||||||
/* If day has an exam announcement */
|
|
||||||
if (PutLinkToEvents && ThisDayHasEvent)
|
|
||||||
fprintf (Gbl.F.Out,"</a>"
|
|
||||||
"</td>"
|
|
||||||
"</tr>"
|
|
||||||
"</table>"
|
|
||||||
"</form>");
|
|
||||||
else
|
|
||||||
fprintf (Gbl.F.Out,"</div>");
|
|
||||||
|
|
||||||
fprintf (Gbl.F.Out,"</td>");
|
|
||||||
|
|
||||||
/***** Set the next day *****/
|
|
||||||
NumDaysInMonth = (Month == 2) ? Dat_GetNumDaysFebruary (Year) :
|
|
||||||
NumDaysMonth[Month];
|
|
||||||
if (++DayOfMonth > NumDaysInMonth)
|
|
||||||
{
|
|
||||||
if (++Month > 12)
|
|
||||||
{
|
|
||||||
Year++;
|
|
||||||
Month = 1;
|
|
||||||
}
|
|
||||||
DayOfMonth = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fprintf (Gbl.F.Out,"</tr>");
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** End of month *****/
|
|
||||||
fprintf (Gbl.F.Out,"</table>"
|
|
||||||
"</div>");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/***************** Compute local time, adjusting day of week *****************/
|
/***************** Compute local time, adjusting day of week *****************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -669,7 +305,7 @@ void Dat_WriteFormDate (unsigned FirstYear,unsigned LastYear,
|
||||||
fprintf (Gbl.F.Out,"><option value=\"0\">-</option>");
|
fprintf (Gbl.F.Out,"><option value=\"0\">-</option>");
|
||||||
NumDaysSelectedMonth = (DateSelected->Month == 0) ? 31 :
|
NumDaysSelectedMonth = (DateSelected->Month == 0) ? 31 :
|
||||||
((DateSelected->Month == 2) ? Dat_GetNumDaysFebruary (DateSelected->Year) :
|
((DateSelected->Month == 2) ? Dat_GetNumDaysFebruary (DateSelected->Year) :
|
||||||
NumDaysMonth[DateSelected->Month]);
|
Dat_NumDaysMonth[DateSelected->Month]);
|
||||||
for (Day = 1;
|
for (Day = 1;
|
||||||
Day <= NumDaysSelectedMonth;
|
Day <= NumDaysSelectedMonth;
|
||||||
Day++)
|
Day++)
|
||||||
|
@ -732,7 +368,6 @@ void Dat_WriteFormDate (unsigned FirstYear,unsigned LastYear,
|
||||||
"</table>");
|
"</table>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*************** Show a form to enter a hour-minute time *********************/
|
/*************** Show a form to enter a hour-minute time *********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -964,7 +599,7 @@ void Dat_GetDateBefore (struct Date *Date,struct Date *PrecedingDate)
|
||||||
PrecedingDate->Year = Date->Year;
|
PrecedingDate->Year = Date->Year;
|
||||||
PrecedingDate->Month = Date->Month - 1;
|
PrecedingDate->Month = Date->Month - 1;
|
||||||
PrecedingDate->Day = (PrecedingDate->Month == 2) ? Dat_GetNumDaysFebruary (PrecedingDate->Year) :
|
PrecedingDate->Day = (PrecedingDate->Month == 2) ? Dat_GetNumDaysFebruary (PrecedingDate->Year) :
|
||||||
NumDaysMonth[PrecedingDate->Month];
|
Dat_NumDaysMonth[PrecedingDate->Month];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -982,7 +617,7 @@ void Dat_GetDateBefore (struct Date *Date,struct Date *PrecedingDate)
|
||||||
void Dat_GetDateAfter (struct Date *Date,struct Date *SubsequentDate)
|
void Dat_GetDateAfter (struct Date *Date,struct Date *SubsequentDate)
|
||||||
{
|
{
|
||||||
unsigned NumDaysInMonth = (Date->Month == 2) ? Dat_GetNumDaysFebruary (Date->Year) :
|
unsigned NumDaysInMonth = (Date->Month == 2) ? Dat_GetNumDaysFebruary (Date->Year) :
|
||||||
NumDaysMonth[Date->Month];
|
Dat_NumDaysMonth[Date->Month];
|
||||||
|
|
||||||
if (Date->Day == NumDaysInMonth)
|
if (Date->Day == NumDaysInMonth)
|
||||||
{
|
{
|
||||||
|
@ -1188,7 +823,7 @@ unsigned Dat_GetDayOfYear (struct Date *Date)
|
||||||
Month < Date->Month;
|
Month < Date->Month;
|
||||||
Month++)
|
Month++)
|
||||||
DayYear += (Month == 2) ? Dat_GetNumDaysFebruary (Date->Year) :
|
DayYear += (Month == 2) ? Dat_GetNumDaysFebruary (Date->Year) :
|
||||||
NumDaysMonth[Month];
|
Dat_NumDaysMonth[Month];
|
||||||
DayYear += Date->Day;
|
DayYear += Date->Day;
|
||||||
|
|
||||||
return DayYear;
|
return DayYear;
|
||||||
|
|
|
@ -73,10 +73,6 @@ bool Dat_GetDateFromYYYYMMDD (struct Date *Date,const char *YYYYMMDDString);
|
||||||
bool Dat_GetDateTimeFromYYYYMMDDHHMMSS (struct DateTime *DateTime,const char *YYYYMMDDHHMMSS);
|
bool Dat_GetDateTimeFromYYYYMMDDHHMMSS (struct DateTime *DateTime,const char *YYYYMMDDHHMMSS);
|
||||||
|
|
||||||
void Dat_ShowCurrentDateTime (void);
|
void Dat_ShowCurrentDateTime (void);
|
||||||
void Dat_DrawCurrentMonth (void);
|
|
||||||
void Dat_DrawCalendar (void);
|
|
||||||
void Dat_DrawMonth (unsigned RealYear,unsigned RealMonth,
|
|
||||||
bool DrawingCalendar,bool PutLinkToEvents,bool PrintView);
|
|
||||||
|
|
||||||
void Dat_GetLocalTimeFromClock (const time_t *clock);
|
void Dat_GetLocalTimeFromClock (const time_t *clock);
|
||||||
void Dat_WriteDateTimeFromtblock (void);
|
void Dat_WriteDateTimeFromtblock (void);
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include <string.h> // For string functions
|
#include <string.h> // For string functions
|
||||||
|
|
||||||
#include "swad_action.h"
|
#include "swad_action.h"
|
||||||
|
#include "swad_calendar.h"
|
||||||
#include "swad_changelog.h"
|
#include "swad_changelog.h"
|
||||||
#include "swad_config.h"
|
#include "swad_config.h"
|
||||||
#include "swad_connected.h"
|
#include "swad_connected.h"
|
||||||
|
@ -1464,7 +1465,7 @@ static void Lay_ShowLeftColumn (void)
|
||||||
/***** Month *****/
|
/***** Month *****/
|
||||||
fprintf (Gbl.F.Out,"<tr>"
|
fprintf (Gbl.F.Out,"<tr>"
|
||||||
"<td style=\"text-align:center; vertical-align:top;\">");
|
"<td style=\"text-align:center; vertical-align:top;\">");
|
||||||
Dat_DrawCurrentMonth ();
|
Cal_DrawCurrentMonth ();
|
||||||
fprintf (Gbl.F.Out,"</td>"
|
fprintf (Gbl.F.Out,"</td>"
|
||||||
"</tr>");
|
"</tr>");
|
||||||
|
|
||||||
|
|
|
@ -26,12 +26,9 @@
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#include <stdio.h> // For fprintf, etc.
|
#include <stdio.h> // For fprintf, etc.
|
||||||
// #include <string.h>
|
|
||||||
|
|
||||||
// #include "swad_config.h"
|
|
||||||
#include "swad_database.h"
|
#include "swad_database.h"
|
||||||
#include "swad_global.h"
|
#include "swad_global.h"
|
||||||
// #include "swad_icon.h"
|
|
||||||
#include "swad_layout.h"
|
#include "swad_layout.h"
|
||||||
#include "swad_menu.h"
|
#include "swad_menu.h"
|
||||||
#include "swad_parameter.h"
|
#include "swad_parameter.h"
|
||||||
|
|
|
@ -728,7 +728,7 @@ static void Sta_WriteSelectorAction (void)
|
||||||
|
|
||||||
void Sta_SetIniEndDates (void)
|
void Sta_SetIniEndDates (void)
|
||||||
{
|
{
|
||||||
extern const unsigned NumDaysMonth[1+12]; // Declaration in swad_date.c
|
extern const unsigned Dat_NumDaysMonth[1+12]; // Declaration in swad_date.c
|
||||||
|
|
||||||
Gbl.DateRange.DateEnd.Day = Gbl.Now.Date.Day;
|
Gbl.DateRange.DateEnd.Day = Gbl.Now.Date.Day;
|
||||||
Gbl.DateRange.DateEnd.Month = Gbl.Now.Date.Month;
|
Gbl.DateRange.DateEnd.Month = Gbl.Now.Date.Month;
|
||||||
|
@ -747,7 +747,7 @@ void Sta_SetIniEndDates (void)
|
||||||
Gbl.DateRange.DateIni.Month = (Gbl.DateRange.DateEnd.Month == 1) ? 12 :
|
Gbl.DateRange.DateIni.Month = (Gbl.DateRange.DateEnd.Month == 1) ? 12 :
|
||||||
Gbl.DateRange.DateEnd.Month - 1;
|
Gbl.DateRange.DateEnd.Month - 1;
|
||||||
Gbl.DateRange.DateIni.Day = ((Gbl.DateRange.DateIni.Month == 2) ? Dat_GetNumDaysFebruary (Gbl.DateRange.DateIni.Year) :
|
Gbl.DateRange.DateIni.Day = ((Gbl.DateRange.DateIni.Month == 2) ? Dat_GetNumDaysFebruary (Gbl.DateRange.DateIni.Year) :
|
||||||
NumDaysMonth[Gbl.DateRange.DateIni.Month]) +
|
Dat_NumDaysMonth[Gbl.DateRange.DateIni.Month]) +
|
||||||
Gbl.DateRange.DateEnd.Day -
|
Gbl.DateRange.DateEnd.Day -
|
||||||
(Cfg_DAYS_IN_RECENT_LOG-1);
|
(Cfg_DAYS_IN_RECENT_LOG-1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user