Version 21.8.1: Sep 20, 2021 Queries moved to module swad_holiday_database.

This commit is contained in:
acanas 2021-09-20 19:49:00 +02:00
parent ce17284fea
commit 0fd2757875
13 changed files with 181 additions and 125 deletions

View File

@ -65,10 +65,10 @@ struct Cfe_CallForExam
char CrsFullName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1]; char CrsFullName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1];
unsigned Year; // Number of year (0 (N.A.), 1, 2, 3, 4, 5, 6) in the degree unsigned Year; // Number of year (0 (N.A.), 1, 2, 3, 4, 5, 6) in the degree
char Session[Cfe_MAX_BYTES_SESSION + 1]; // Exam session is june, september, etc. char Session[Cfe_MAX_BYTES_SESSION + 1]; // Exam session is june, september, etc.
struct Date CallDate; struct Dat_Date CallDate;
struct Date ExamDate; struct Dat_Date ExamDate;
struct Hour StartTime; struct Dat_Hour StartTime;
struct Hour Duration; struct Dat_Hour Duration;
char *Place; char *Place;
char *Mode; char *Mode;
char *Structure; char *Structure;
@ -81,7 +81,7 @@ struct Cfe_CallForExam
struct Cfe_ExamCodeAndDate struct Cfe_ExamCodeAndDate
{ {
long ExaCod; long ExaCod;
struct Date ExamDate; struct Dat_Date ExamDate;
}; };
struct Cfe_CallsForExams struct Cfe_CallsForExams

View File

@ -602,15 +602,16 @@ TODO: FIX BUG, URGENT! En las fechas como par
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo. TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
*/ */
#define Log_PLATFORM_VERSION "SWAD 21.8 (2021-09-20)" #define Log_PLATFORM_VERSION "SWAD 21.8.1 (2021-09-20)"
#define CSS_FILE "swad20.45.css" #define CSS_FILE "swad20.45.css"
#define JS_FILE "swad20.69.1.js" #define JS_FILE "swad20.69.1.js"
/* /*
TODO: Rename CENTRE to CENTER in help wiki. TODO: Rename CENTRE to CENTER in help wiki.
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
Version 21.8: Sep 18, 2021 New module swad_holiday_database for database queries related to holidays. (315883 lines) Version 21.8.1: Sep 20, 2021 Queries moved to module swad_holiday_database. (315927 lines)
Version 21.7: Sep 18, 2021 New module swad_hierarchy_database for database queries related to hierarchy. (315774 lines) Version 21.8: Sep 20, 2021 New module swad_holiday_database for database queries related to holidays. (315883 lines)
Version 21.7: Sep 20, 2021 New module swad_hierarchy_database for database queries related to hierarchy. (315774 lines)
Version 21.6.3: Sep 20, 2021 Queries moved to module swad_game_database. (315708 lines) Version 21.6.3: Sep 20, 2021 Queries moved to module swad_game_database. (315708 lines)
Version 21.6.2: Sep 18, 2021 Queries moved to module swad_game_database. (315679 lines) Version 21.6.2: Sep 18, 2021 Queries moved to module swad_game_database. (315679 lines)
Version 21.6.1: Sep 18, 2021 Queries moved to module swad_game_database. (315571 lines) Version 21.6.1: Sep 18, 2021 Queries moved to module swad_game_database. (315571 lines)

View File

@ -103,7 +103,7 @@ static unsigned Dat_GetParamDateFormat (void);
/******************************** Reset date *********************************/ /******************************** Reset date *********************************/
/*****************************************************************************/ /*****************************************************************************/
void Dat_ResetDate (struct Date *Date) void Dat_ResetDate (struct Dat_Date *Date)
{ {
Date->Day = 0; Date->Day = 0;
Date->Month = 0; Date->Month = 0;
@ -112,7 +112,7 @@ void Dat_ResetDate (struct Date *Date)
Date->YYYYMMDD[0] = '\0'; Date->YYYYMMDD[0] = '\0';
} }
void Dat_ResetHour (struct Hour *Hour) void Dat_ResetHour (struct Dat_Hour *Hour)
{ {
Hour->Hour = 0; Hour->Hour = 0;
Hour->Minute = 0; Hour->Minute = 0;
@ -303,7 +303,7 @@ time_t Dat_GetUNIXTimeFromStr (const char *Str)
/*********** Get a struct Date from a string in YYYYMMDD format **************/ /*********** Get a struct Date from a string in YYYYMMDD format **************/
/*****************************************************************************/ /*****************************************************************************/
bool Dat_GetDateFromYYYYMMDD (struct Date *Date,const char *YYYYMMDD) bool Dat_GetDateFromYYYYMMDD (struct Dat_Date *Date,const char *YYYYMMDD)
{ {
if (YYYYMMDD) if (YYYYMMDD)
if (YYYYMMDD[0]) if (YYYYMMDD[0])
@ -402,7 +402,7 @@ struct tm *Dat_GetLocalTimeFromClock (const time_t *timep)
/********* Convert a struct with Day, Month and Year to a date string ********/ /********* Convert a struct with Day, Month and Year to a date string ********/
/*****************************************************************************/ /*****************************************************************************/
void Dat_ConvDateToDateStr (const struct Date *Date,char StrDate[Cns_MAX_BYTES_DATE + 1]) void Dat_ConvDateToDateStr (const struct Dat_Date *Date,char StrDate[Cns_MAX_BYTES_DATE + 1])
{ {
extern const char *Txt_MONTHS_SMALL_SHORT[12]; extern const char *Txt_MONTHS_SMALL_SHORT[12];
@ -853,7 +853,7 @@ See also http://www.ashleyit.com/rs/jsrs/select/php/select.php
*/ */
void Dat_WriteFormDate (unsigned FirstYear,unsigned LastYear, void Dat_WriteFormDate (unsigned FirstYear,unsigned LastYear,
const char *Id, const char *Id,
struct Date *DateSelected, struct Dat_Date *DateSelected,
bool SubmitFormOnChange,bool Disabled) bool SubmitFormOnChange,bool Disabled)
{ {
extern const char *Txt_MONTHS_SMALL[12]; extern const char *Txt_MONTHS_SMALL[12];
@ -1087,7 +1087,7 @@ void Dat_WriteRFC822DateFromTM (FILE *File,struct tm *tm_ptr)
/************** Compute the subsequent date of a given date ******************/ /************** Compute the subsequent date of a given date ******************/
/*****************************************************************************/ /*****************************************************************************/
void Dat_GetDateAfter (struct Date *Date,struct Date *SubsequentDate) void Dat_GetDateAfter (struct Dat_Date *Date,struct Dat_Date *SubsequentDate)
{ {
unsigned NumDaysInMonth = (Date->Month == 2) ? Dat_GetNumDaysFebruary (Date->Year) : unsigned NumDaysInMonth = (Date->Month == 2) ? Dat_GetNumDaysFebruary (Date->Year) :
Dat_NumDaysMonth[Date->Month]; Dat_NumDaysMonth[Date->Month];
@ -1119,7 +1119,7 @@ void Dat_GetDateAfter (struct Date *Date,struct Date *SubsequentDate)
/************** Compute the preceding date of a given date *******************/ /************** Compute the preceding date of a given date *******************/
/*****************************************************************************/ /*****************************************************************************/
void Dat_GetDateBefore (struct Date *Date,struct Date *PrecedingDate) void Dat_GetDateBefore (struct Dat_Date *Date,struct Dat_Date *PrecedingDate)
{ {
if (Date->Day == 1) if (Date->Day == 1)
{ {
@ -1149,7 +1149,7 @@ void Dat_GetDateBefore (struct Date *Date,struct Date *PrecedingDate)
/**************** Compute the week before to a given week ********************/ /**************** Compute the week before to a given week ********************/
/*****************************************************************************/ /*****************************************************************************/
void Dat_GetWeekBefore (struct Date *Date,struct Date *PrecedingDate) void Dat_GetWeekBefore (struct Dat_Date *Date,struct Dat_Date *PrecedingDate)
{ {
if (Date->Week == 1) if (Date->Week == 1)
{ {
@ -1167,7 +1167,7 @@ void Dat_GetWeekBefore (struct Date *Date,struct Date *PrecedingDate)
/*************** Compute the month before to a given month *******************/ /*************** Compute the month before to a given month *******************/
/*****************************************************************************/ /*****************************************************************************/
void Dat_GetMonthBefore (struct Date *Date,struct Date *PrecedingDate) void Dat_GetMonthBefore (struct Dat_Date *Date,struct Dat_Date *PrecedingDate)
{ {
if (Date->Month == 1) if (Date->Month == 1)
{ {
@ -1185,7 +1185,7 @@ void Dat_GetMonthBefore (struct Date *Date,struct Date *PrecedingDate)
/**************** Compute the year before to a given year ********************/ /**************** Compute the year before to a given year ********************/
/*****************************************************************************/ /*****************************************************************************/
void Dat_GetYearBefore (struct Date *Date,struct Date *PrecedingDate) void Dat_GetYearBefore (struct Dat_Date *Date,struct Dat_Date *PrecedingDate)
{ {
PrecedingDate->Year = Date->Year - 1; PrecedingDate->Year = Date->Year - 1;
} }
@ -1197,8 +1197,8 @@ void Dat_GetYearBefore (struct Date *Date,struct Date *PrecedingDate)
// If the old date is the day before the new data, return 2 // If the old date is the day before the new data, return 2
// ... // ...
unsigned Dat_GetNumDaysBetweenDates (struct Date *DateIni, unsigned Dat_GetNumDaysBetweenDates (struct Dat_Date *DateIni,
struct Date *DateEnd) struct Dat_Date *DateEnd)
{ {
int DiffDays; int DiffDays;
unsigned Year; unsigned Year;
@ -1223,8 +1223,8 @@ unsigned Dat_GetNumDaysBetweenDates (struct Date *DateIni,
/*****************************************************************************/ /*****************************************************************************/
// If the two dates are in the same week, return 1 // If the two dates are in the same week, return 1
unsigned Dat_GetNumWeeksBetweenDates (struct Date *DateIni, unsigned Dat_GetNumWeeksBetweenDates (struct Dat_Date *DateIni,
struct Date *DateEnd) struct Dat_Date *DateEnd)
{ {
int DiffWeeks; int DiffWeeks;
unsigned Year; unsigned Year;
@ -1250,8 +1250,8 @@ unsigned Dat_GetNumWeeksBetweenDates (struct Date *DateIni,
/*****************************************************************************/ /*****************************************************************************/
// If the two dates are in the same month, return 1 // If the two dates are in the same month, return 1
unsigned Dat_GetNumMonthsBetweenDates (struct Date *DateIni, unsigned Dat_GetNumMonthsBetweenDates (struct Dat_Date *DateIni,
struct Date *DateEnd) struct Dat_Date *DateEnd)
{ {
int DiffMonths; int DiffMonths;
@ -1267,8 +1267,8 @@ unsigned Dat_GetNumMonthsBetweenDates (struct Date *DateIni,
/*****************************************************************************/ /*****************************************************************************/
// If the two dates are in the same year, return 1 // If the two dates are in the same year, return 1
unsigned Dat_GetNumYearsBetweenDates (struct Date *DateIni, unsigned Dat_GetNumYearsBetweenDates (struct Dat_Date *DateIni,
struct Date *DateEnd) struct Dat_Date *DateEnd)
{ {
int DiffYears; int DiffYears;
@ -1496,7 +1496,7 @@ continue:
/***************** Compute the day of year (from 1 to 366) *******************/ /***************** Compute the day of year (from 1 to 366) *******************/
/*****************************************************************************/ /*****************************************************************************/
unsigned Dat_GetDayOfYear (struct Date *Date) unsigned Dat_GetDayOfYear (struct Dat_Date *Date)
{ {
unsigned Month; unsigned Month;
unsigned DayYear; unsigned DayYear;
@ -1519,7 +1519,7 @@ unsigned Dat_GetDayOfYear (struct Date *Date)
01/01/2006 was sunday => it is counted in the week 52 of 2005, which goes from the 26/12/2005 (monday) until the 01/01/2006 (sunday). 01/01/2006 was sunday => it is counted in the week 52 of 2005, which goes from the 26/12/2005 (monday) until the 01/01/2006 (sunday).
Week 1 of 2006 goes from the 02/01/2006 (monday) until the 08/01/2006 (sunday) */ Week 1 of 2006 goes from the 02/01/2006 (monday) until the 08/01/2006 (sunday) */
void Dat_CalculateWeekOfYear (struct Date *Date) void Dat_CalculateWeekOfYear (struct Dat_Date *Date)
{ {
/* /*
If January 1 of Year is... | ...then first week of Year starts the day | If January 1 of Year is... | ...then first week of Year starts the day |
@ -1564,7 +1564,7 @@ void Dat_CalculateWeekOfYear (struct Date *Date)
/******************* Assign the values of a date to another ******************/ /******************* Assign the values of a date to another ******************/
/*****************************************************************************/ /*****************************************************************************/
void Dat_AssignDate (struct Date *DateDst,struct Date *DateSrc) void Dat_AssignDate (struct Dat_Date *DateDst,struct Dat_Date *DateSrc)
{ {
DateDst->Year = DateSrc->Year; DateDst->Year = DateSrc->Year;
DateDst->Month = DateSrc->Month; DateDst->Month = DateSrc->Month;
@ -1628,7 +1628,7 @@ void Dat_WriteHoursMinutesSecondsFromSeconds (time_t Seconds)
/******************* Write time as hours:minutes:seconds *********************/ /******************* Write time as hours:minutes:seconds *********************/
/*****************************************************************************/ /*****************************************************************************/
void Dat_WriteHoursMinutesSeconds (struct Time *Time) void Dat_WriteHoursMinutesSeconds (struct Dat_Time *Time)
{ {
if (Time->Hour) if (Time->Hour)
HTM_TxtF ("%u:%02u′%02u″",Time->Hour,Time->Minute,Time->Second); HTM_TxtF ("%u:%02u′%02u″",Time->Hour,Time->Minute,Time->Second);

View File

@ -48,7 +48,7 @@
/*****************************************************************************/ /*****************************************************************************/
#define Dat_LENGTH_YYYYMMDD (4 + 2 + 2) #define Dat_LENGTH_YYYYMMDD (4 + 2 + 2)
struct Date struct Dat_Date
{ {
unsigned Day; unsigned Day;
unsigned Month; unsigned Month;
@ -56,21 +56,21 @@ struct Date
unsigned Week; unsigned Week;
char YYYYMMDD[Dat_LENGTH_YYYYMMDD + 1]; char YYYYMMDD[Dat_LENGTH_YYYYMMDD + 1];
}; };
struct Time struct Dat_Time
{ {
unsigned Hour; unsigned Hour;
unsigned Minute; unsigned Minute;
unsigned Second; unsigned Second;
}; };
struct Hour struct Dat_Hour
{ {
unsigned Hour; unsigned Hour;
unsigned Minute; unsigned Minute;
}; };
struct DateTime struct Dat_DateTime
{ {
struct Date Date; struct Dat_Date Date;
struct Time Time; struct Dat_Time Time;
char YYYYMMDDHHMMSS[4 + 2 + 2 + 2 + 2 + 2 + 1]; char YYYYMMDDHHMMSS[4 + 2 + 2 + 2 + 2 + 2 + 1];
}; };
@ -124,8 +124,8 @@ typedef enum
/***************************** Public prototypes *****************************/ /***************************** Public prototypes *****************************/
/*****************************************************************************/ /*****************************************************************************/
void Dat_ResetDate (struct Date *Date); void Dat_ResetDate (struct Dat_Date *Date);
void Dat_ResetHour (struct Hour *Hour); void Dat_ResetHour (struct Dat_Hour *Hour);
void Dat_PutBoxToSelectDateFormat (void); void Dat_PutBoxToSelectDateFormat (void);
@ -139,12 +139,12 @@ void Dat_GetStartExecutionTimeUTC (void);
void Dat_GetAndConvertCurrentDateTime (void); void Dat_GetAndConvertCurrentDateTime (void);
time_t Dat_GetUNIXTimeFromStr (const char *Str); time_t Dat_GetUNIXTimeFromStr (const char *Str);
bool Dat_GetDateFromYYYYMMDD (struct Date *Date,const char *YYYYMMDDString); bool Dat_GetDateFromYYYYMMDD (struct Dat_Date *Date,const char *YYYYMMDDString);
void Dat_ShowClientLocalTime (void); void Dat_ShowClientLocalTime (void);
struct tm *Dat_GetLocalTimeFromClock (const time_t *timep); struct tm *Dat_GetLocalTimeFromClock (const time_t *timep);
void Dat_ConvDateToDateStr (const struct Date *Date,char StrDate[Cns_MAX_BYTES_DATE + 1]); void Dat_ConvDateToDateStr (const struct Dat_Date *Date,char StrDate[Cns_MAX_BYTES_DATE + 1]);
void Dat_PutFormStartEndClientLocalDateTimesWithYesterdayToday (const Dat_SetHMS SetHMS[Dat_NUM_START_END_TIME]); void Dat_PutFormStartEndClientLocalDateTimesWithYesterdayToday (const Dat_SetHMS SetHMS[Dat_NUM_START_END_TIME]);
void Dat_PutFormStartEndClientLocalDateTimes (const time_t TimeUTC[Dat_NUM_START_END_TIME], void Dat_PutFormStartEndClientLocalDateTimes (const time_t TimeUTC[Dat_NUM_START_END_TIME],
@ -166,7 +166,7 @@ void Dat_GetBrowserTimeZone (char BrowserTimeZone[Dat_MAX_BYTES_TIME_ZONE + 1]);
void Dat_WriteFormDate (unsigned FirstYear,unsigned LastYear, void Dat_WriteFormDate (unsigned FirstYear,unsigned LastYear,
const char *Id, const char *Id,
struct Date *DateSelected, struct Dat_Date *DateSelected,
bool SubmitFormOnChange,bool Disabled); bool SubmitFormOnChange,bool Disabled);
void Dat_GetDateFromForm (const char *ParamNameDay,const char *ParamNameMonth,const char *ParamNameYear, void Dat_GetDateFromForm (const char *ParamNameDay,const char *ParamNameMonth,const char *ParamNameYear,
unsigned *Day,unsigned *Month,unsigned *Year); unsigned *Day,unsigned *Month,unsigned *Year);
@ -177,32 +177,32 @@ void Dat_GetIniEndDatesFromForm (void);
void Dat_WriteRFC822DateFromTM (FILE *File,struct tm *tm); void Dat_WriteRFC822DateFromTM (FILE *File,struct tm *tm);
void Dat_GetDateAfter (struct Date *Date,struct Date *SubsequentDate); void Dat_GetDateAfter (struct Dat_Date *Date,struct Dat_Date *SubsequentDate);
void Dat_GetDateBefore (struct Date *Date,struct Date *PrecedingDate ); void Dat_GetDateBefore (struct Dat_Date *Date,struct Dat_Date *PrecedingDate );
void Dat_GetWeekBefore (struct Date *Date,struct Date *PrecedingDate ); void Dat_GetWeekBefore (struct Dat_Date *Date,struct Dat_Date *PrecedingDate );
void Dat_GetMonthBefore (struct Date *Date,struct Date *PrecedingDate ); void Dat_GetMonthBefore (struct Dat_Date *Date,struct Dat_Date *PrecedingDate );
void Dat_GetYearBefore (struct Date *Date,struct Date *PrecedingDate ); void Dat_GetYearBefore (struct Dat_Date *Date,struct Dat_Date *PrecedingDate );
unsigned Dat_GetNumDaysBetweenDates (struct Date *DateIni, unsigned Dat_GetNumDaysBetweenDates (struct Dat_Date *DateIni,
struct Date *DateEnd); struct Dat_Date *DateEnd);
unsigned Dat_GetNumWeeksBetweenDates (struct Date *DateIni, unsigned Dat_GetNumWeeksBetweenDates (struct Dat_Date *DateIni,
struct Date *DateEnd); struct Dat_Date *DateEnd);
unsigned Dat_GetNumMonthsBetweenDates (struct Date *DateIni, unsigned Dat_GetNumMonthsBetweenDates (struct Dat_Date *DateIni,
struct Date *DateEnd); struct Dat_Date *DateEnd);
unsigned Dat_GetNumYearsBetweenDates (struct Date *DateIni, unsigned Dat_GetNumYearsBetweenDates (struct Dat_Date *DateIni,
struct Date *DateEnd); struct Dat_Date *DateEnd);
unsigned Dat_GetNumDaysInYear (unsigned Year); unsigned Dat_GetNumDaysInYear (unsigned Year);
unsigned Dat_GetNumDaysFebruary (unsigned Year); unsigned Dat_GetNumDaysFebruary (unsigned Year);
bool Dat_GetIfLeapYear (unsigned Year); bool Dat_GetIfLeapYear (unsigned Year);
unsigned Dat_GetNumWeeksInYear (unsigned Year); unsigned Dat_GetNumWeeksInYear (unsigned Year);
unsigned Dat_GetDayOfWeek (unsigned Year,unsigned Month,unsigned Day); unsigned Dat_GetDayOfWeek (unsigned Year,unsigned Month,unsigned Day);
unsigned Dat_GetDayOfYear (struct Date *Date); unsigned Dat_GetDayOfYear (struct Dat_Date *Date);
void Dat_CalculateWeekOfYear (struct Date *Date); void Dat_CalculateWeekOfYear (struct Dat_Date *Date);
void Dat_AssignDate (struct Date *DateDst,struct Date *DateSrc); void Dat_AssignDate (struct Dat_Date *DateDst,struct Dat_Date *DateSrc);
void Dat_WriteScriptMonths (void); void Dat_WriteScriptMonths (void);
void Dat_WriteHoursMinutesSecondsFromSeconds (time_t Seconds); void Dat_WriteHoursMinutesSecondsFromSeconds (time_t Seconds);
void Dat_WriteHoursMinutesSeconds (struct Time *Time); void Dat_WriteHoursMinutesSeconds (struct Dat_Time *Time);
void Dat_WriteLocalDateHMSFromUTC (const char *Id,time_t TimeUTC, void Dat_WriteLocalDateHMSFromUTC (const char *Id,time_t TimeUTC,
Dat_Format_t DateFormat,Dat_Separator_t Separator, Dat_Format_t DateFormat,Dat_Separator_t Separator,

View File

@ -175,8 +175,8 @@ struct Globals
bool IsAJAXAutoRefresh; // It's an automatic refresh drom time to time bool IsAJAXAutoRefresh; // It's an automatic refresh drom time to time
} Action; } Action;
time_t StartExecutionTimeUTC; time_t StartExecutionTimeUTC;
struct DateTime Now; struct Dat_DateTime Now;
struct Date Yesterday; struct Dat_Date Yesterday;
unsigned RowEvenOdd; // To alternate row colors in listings unsigned RowEvenOdd; // To alternate row colors in listings
char *ColorRows[2]; char *ColorRows[2];
const char *XMLPtr; const char *XMLPtr;
@ -435,8 +435,8 @@ struct Globals
} FileBrowser; // Struct used for a file browser } FileBrowser; // Struct used for a file browser
struct struct
{ {
struct DateTime DateIni; // TODO: Remove in future versions struct Dat_DateTime DateIni; // TODO: Remove in future versions
struct DateTime DateEnd; // TODO: Remove in future versions struct Dat_DateTime DateEnd; // TODO: Remove in future versions
time_t TimeUTC[Dat_NUM_START_END_TIME]; time_t TimeUTC[Dat_NUM_START_END_TIME];
} DateRange; } DateRange;

View File

@ -664,10 +664,7 @@ void Hld_RemoveHoliday (void)
Hld_GetDataOfHolidayByCod (Hld_EditingHld); Hld_GetDataOfHolidayByCod (Hld_EditingHld);
/***** Remove holiday *****/ /***** Remove holiday *****/
DB_QueryDELETE ("can not remove a holiday", Hld_DB_RemoveHoliday (Hld_EditingHld->HldCod);
"DELETE FROM hld_holidays"
" WHERE HldCod=%ld",
Hld_EditingHld->HldCod);
/***** Write message to show the change made *****/ /***** Write message to show the change made *****/
Ale_CreateAlert (Ale_SUCCESS,NULL, Ale_CreateAlert (Ale_SUCCESS,NULL,
@ -702,12 +699,7 @@ void Hld_ChangeHolidayPlace (void)
Hld_GetDataOfHolidayByCod (Hld_EditingHld); Hld_GetDataOfHolidayByCod (Hld_EditingHld);
/***** Update the place in database *****/ /***** Update the place in database *****/
DB_QueryUPDATE ("can not update the place of a holiday", Hld_DB_ChangePlace (Hld_EditingHld->HldCod,NewPlace.PlcCod);
"UPDATE hld_holidays"
" SET PlcCod=%ld"
" WHERE HldCod=%ld",
NewPlace.PlcCod,
Hld_EditingHld->HldCod);
Hld_EditingHld->PlcCod = NewPlace.PlcCod; Hld_EditingHld->PlcCod = NewPlace.PlcCod;
Str_Copy (Hld_EditingHld->PlaceFullName,NewPlace.FullName, Str_Copy (Hld_EditingHld->PlaceFullName,NewPlace.FullName,
sizeof (Hld_EditingHld->PlaceFullName) - 1); sizeof (Hld_EditingHld->PlaceFullName) - 1);
@ -741,13 +733,7 @@ void Hld_ChangeHolidayType (void)
/***** Update holiday/no school period in database *****/ /***** Update holiday/no school period in database *****/
Dat_AssignDate (&Hld_EditingHld->EndDate,&Hld_EditingHld->StartDate); Dat_AssignDate (&Hld_EditingHld->EndDate,&Hld_EditingHld->StartDate);
DB_QueryUPDATE ("can not update the type of a holiday", Hld_DB_ChangeType (Hld_EditingHld->HldCod,Hld_EditingHld->HldTyp);
"UPDATE hld_holidays"
" SET HldTyp=%u,"
"EndDate=StartDate"
" WHERE HldCod=%ld",
(unsigned) Hld_EditingHld->HldTyp,
Hld_EditingHld->HldCod);
/***** Write message to show the change made *****/ /***** Write message to show the change made *****/
Ale_CreateAlert (Ale_SUCCESS,NULL, Ale_CreateAlert (Ale_SUCCESS,NULL,
@ -780,8 +766,8 @@ void Hld_ChangeEndDate (void)
static void Hld_ChangeDate (Hld_StartOrEndDate_t StartOrEndDate) static void Hld_ChangeDate (Hld_StartOrEndDate_t StartOrEndDate)
{ {
extern const char *Txt_The_date_of_the_holiday_X_has_changed_to_Y; extern const char *Txt_The_date_of_the_holiday_X_has_changed_to_Y;
struct Date NewDate; struct Dat_Date NewDate;
struct Date *PtrDate = NULL; // Initialized to avoid warning struct Dat_Date *PtrDate = NULL; // Initialized to avoid warning
const char *StrStartOrEndDate = NULL; // Initialized to avoid warning const char *StrStartOrEndDate = NULL; // Initialized to avoid warning
char StrDate[Cns_MAX_BYTES_DATE + 1]; char StrDate[Cns_MAX_BYTES_DATE + 1];
@ -829,15 +815,7 @@ static void Hld_ChangeDate (Hld_StartOrEndDate_t StartOrEndDate)
} }
/***** Update the date in database *****/ /***** Update the date in database *****/
DB_QueryUPDATE ("can not update the date of a holiday", Hld_DB_ChangeDate (Hld_EditingHld->HldCod,StrStartOrEndDate,&NewDate);
"UPDATE hld_holidays"
" SET %s='%04u%02u%02u'"
" WHERE HldCod=%ld",
StrStartOrEndDate,
NewDate.Year,
NewDate.Month,
NewDate.Day,
Hld_EditingHld->HldCod);
Dat_AssignDate (PtrDate,&NewDate); Dat_AssignDate (PtrDate,&NewDate);
/***** Write message to show the change made *****/ /***** Write message to show the change made *****/
@ -880,12 +858,7 @@ void Hld_RenameHoliday (void)
{ {
/***** If degree was in database... *****/ /***** If degree was in database... *****/
/* Update the table changing old name by new name */ /* Update the table changing old name by new name */
DB_QueryUPDATE ("can not update the text of a holiday", Hld_DB_ChangeName (Hld_EditingHld->HldCod,NewHldName);
"UPDATE hld_holidays"
" SET Name='%s'"
" WHERE HldCod=%ld",
NewHldName,
Hld_EditingHld->HldCod);
Str_Copy (Hld_EditingHld->Name,NewHldName, Str_Copy (Hld_EditingHld->Name,NewHldName,
sizeof (Hld_EditingHld->Name) - 1); sizeof (Hld_EditingHld->Name) - 1);

View File

@ -57,8 +57,8 @@ struct Hld_Holiday
long PlcCod; long PlcCod;
char PlaceFullName[Plc_MAX_BYTES_PLACE_FULL_NAME + 1]; char PlaceFullName[Plc_MAX_BYTES_PLACE_FULL_NAME + 1];
Hld_HolidayType_t HldTyp; Hld_HolidayType_t HldTyp;
struct Date StartDate; struct Dat_Date StartDate;
struct Date EndDate; struct Dat_Date EndDate;
char Name[Hld_MAX_BYTES_HOLIDAY_NAME + 1]; char Name[Hld_MAX_BYTES_HOLIDAY_NAME + 1];
}; };

View File

@ -86,6 +86,67 @@ void Hld_DB_CreateHoliday (const struct Hld_Holiday *Hld)
Hld->Name); Hld->Name);
} }
/*****************************************************************************/
/************************* Change the place of a holiday *********************/
/*****************************************************************************/
void Hld_DB_ChangePlace (long HldCod,long PlcCod)
{
DB_QueryUPDATE ("can not update the place of a holiday",
"UPDATE hld_holidays"
" SET PlcCod=%ld"
" WHERE HldCod=%ld",
PlcCod,
HldCod);
}
/*****************************************************************************/
/************************* Change the type of a holiday **********************/
/*****************************************************************************/
void Hld_DB_ChangeType (long HldCod,Hld_HolidayType_t HldTyp)
{
DB_QueryUPDATE ("can not update the type of a holiday",
"UPDATE hld_holidays"
" SET HldTyp=%u,"
"EndDate=StartDate"
" WHERE HldCod=%ld",
(unsigned) HldTyp,
HldCod);
}
/*****************************************************************************/
/**************** Change the start/end date of a holiday *********************/
/*****************************************************************************/
void Hld_DB_ChangeDate (long HldCod,const char *StrStartOrEndDate,
const struct Dat_Date *NewDate)
{
DB_QueryUPDATE ("can not update the date of a holiday",
"UPDATE hld_holidays"
" SET %s='%04u%02u%02u'"
" WHERE HldCod=%ld",
StrStartOrEndDate,
NewDate->Year,
NewDate->Month,
NewDate->Day,
HldCod);
}
/*****************************************************************************/
/************* Update holiday name changing old name by new name *************/
/*****************************************************************************/
void Hld_DB_ChangeName (long HldCod,char NewHldName[Hld_MAX_BYTES_HOLIDAY_NAME + 1])
{
DB_QueryUPDATE ("can not update the text of a holiday",
"UPDATE hld_holidays"
" SET Name='%s'"
" WHERE HldCod=%ld",
NewHldName,
HldCod);
}
/*****************************************************************************/ /*****************************************************************************/
/*************************** List all the holidays ***************************/ /*************************** List all the holidays ***************************/
/*****************************************************************************/ /*****************************************************************************/
@ -177,3 +238,16 @@ unsigned Hld_DB_GetDataOfHolidayByCod (MYSQL_RES **mysql_res,long HldCod)
Gbl.Hierarchy.Ins.InsCod, Gbl.Hierarchy.Ins.InsCod,
Gbl.Hierarchy.Ins.InsCod); Gbl.Hierarchy.Ins.InsCod);
} }
/*****************************************************************************/
/******************************* Remove a holiday ****************************/
/*****************************************************************************/
void Hld_DB_RemoveHoliday (long HldCod)
{
DB_QueryDELETE ("can not remove a holiday",
"DELETE FROM hld_holidays"
" WHERE HldCod=%ld",
HldCod);
}

View File

@ -27,6 +27,7 @@
/********************************* Headers ***********************************/ /********************************* Headers ***********************************/
/*****************************************************************************/ /*****************************************************************************/
#include "swad_date.h"
#include "swad_holiday.h" #include "swad_holiday.h"
/*****************************************************************************/ /*****************************************************************************/
@ -38,8 +39,15 @@
/*****************************************************************************/ /*****************************************************************************/
void Hld_DB_CreateHoliday (const struct Hld_Holiday *Hld); void Hld_DB_CreateHoliday (const struct Hld_Holiday *Hld);
void Hld_DB_ChangePlace (long HldCod,long PlcCod);
void Hld_DB_ChangeType (long HldCod,Hld_HolidayType_t HldTyp);
void Hld_DB_ChangeDate (long HldCod,const char *StrStartOrEndDate,
const struct Dat_Date *NewDate);
void Hld_DB_ChangeName (long HldCod,char NewHldName[Hld_MAX_BYTES_HOLIDAY_NAME + 1]);
unsigned Hld_DB_GetListHolidays (MYSQL_RES **mysql_res,Hld_Order_t SelectedOrder); unsigned Hld_DB_GetListHolidays (MYSQL_RES **mysql_res,Hld_Order_t SelectedOrder);
unsigned Hld_DB_GetDataOfHolidayByCod (MYSQL_RES **mysql_res,long HldCod); unsigned Hld_DB_GetDataOfHolidayByCod (MYSQL_RES **mysql_res,long HldCod);
void Hld_DB_RemoveHoliday (long HldCod);
#endif #endif

View File

@ -164,11 +164,11 @@ static void Mch_UpdateMatchStatusInDB (const struct Mch_Match *Match);
static void Mch_UpdateElapsedTimeInQuestion (const struct Mch_Match *Match); static void Mch_UpdateElapsedTimeInQuestion (const struct Mch_Match *Match);
static void Mch_GetElapsedTimeInQuestion (const struct Mch_Match *Match, static void Mch_GetElapsedTimeInQuestion (const struct Mch_Match *Match,
struct Time *Time); struct Dat_Time *Time);
static void Mch_GetElapsedTimeInMatch (const struct Mch_Match *Match, static void Mch_GetElapsedTimeInMatch (const struct Mch_Match *Match,
struct Time *Time); struct Dat_Time *Time);
static void Mch_GetElapsedTime (unsigned NumRows,MYSQL_RES *mysql_res, static void Mch_GetElapsedTime (unsigned NumRows,MYSQL_RES *mysql_res,
struct Time *Time); struct Dat_Time *Time);
static void Mch_SetMatchStatusToPrev (struct Mch_Match *Match); static void Mch_SetMatchStatusToPrev (struct Mch_Match *Match);
static void Mch_SetMatchStatusToPrevQst (struct Mch_Match *Match); static void Mch_SetMatchStatusToPrevQst (struct Mch_Match *Match);
@ -2088,7 +2088,7 @@ static void Mch_UpdateElapsedTimeInQuestion (const struct Mch_Match *Match)
/*****************************************************************************/ /*****************************************************************************/
static void Mch_GetElapsedTimeInQuestion (const struct Mch_Match *Match, static void Mch_GetElapsedTimeInQuestion (const struct Mch_Match *Match,
struct Time *Time) struct Dat_Time *Time)
{ {
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
unsigned NumRows; unsigned NumRows;
@ -2115,7 +2115,7 @@ static void Mch_GetElapsedTimeInQuestion (const struct Mch_Match *Match,
/*****************************************************************************/ /*****************************************************************************/
static void Mch_GetElapsedTimeInMatch (const struct Mch_Match *Match, static void Mch_GetElapsedTimeInMatch (const struct Mch_Match *Match,
struct Time *Time) struct Dat_Time *Time)
{ {
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
unsigned NumRows; unsigned NumRows;
@ -2140,7 +2140,7 @@ static void Mch_GetElapsedTimeInMatch (const struct Mch_Match *Match,
/*****************************************************************************/ /*****************************************************************************/
static void Mch_GetElapsedTime (unsigned NumRows,MYSQL_RES *mysql_res, static void Mch_GetElapsedTime (unsigned NumRows,MYSQL_RES *mysql_res,
struct Time *Time) struct Dat_Time *Time)
{ {
MYSQL_ROW row; MYSQL_ROW row;
bool ElapsedTimeGotFromDB = false; bool ElapsedTimeGotFromDB = false;
@ -2643,7 +2643,7 @@ static void Mch_ShowRefreshablePartTch (struct Mch_Match *Match)
static void Mch_WriteElapsedTimeInMch (struct Mch_Match *Match) static void Mch_WriteElapsedTimeInMch (struct Mch_Match *Match)
{ {
struct Time Time; struct Dat_Time Time;
HTM_DIV_Begin ("class=\"MCH_TOP CT\""); HTM_DIV_Begin ("class=\"MCH_TOP CT\"");
@ -2662,7 +2662,7 @@ static void Mch_WriteElapsedTimeInMch (struct Mch_Match *Match)
static void Mch_WriteElapsedTimeInQst (struct Mch_Match *Match) static void Mch_WriteElapsedTimeInQst (struct Mch_Match *Match)
{ {
struct Time Time; struct Dat_Time Time;
HTM_DIV_Begin ("class=\"MCH_TIME_QST\""); HTM_DIV_Begin ("class=\"MCH_TIME_QST\"");

View File

@ -1933,9 +1933,9 @@ static void Sta_ShowNumHitsPerDay (Sta_CountType_t CountType,
extern const char *Txt_STAT_TYPE_COUNT_CAPS[Sta_NUM_COUNT_TYPES]; extern const char *Txt_STAT_TYPE_COUNT_CAPS[Sta_NUM_COUNT_TYPES];
extern const char *Txt_DAYS_SMALL[7]; extern const char *Txt_DAYS_SMALL[7];
unsigned NumHit; unsigned NumHit;
struct Date ReadDate; struct Dat_Date ReadDate;
struct Date LastDate; struct Dat_Date LastDate;
struct Date Date; struct Dat_Date Date;
unsigned D; unsigned D;
unsigned NumDaysFromLastDateToCurrDate; unsigned NumDaysFromLastDateToCurrDate;
int NumDayWeek; int NumDayWeek;
@ -2071,10 +2071,10 @@ static void Sta_ShowDistrAccessesPerDayAndHour (const struct Sta_Stats *Stats,
unsigned ColorTypeUnsigned; unsigned ColorTypeUnsigned;
Sta_ColorType_t SelectedColorType; Sta_ColorType_t SelectedColorType;
unsigned NumHit; unsigned NumHit;
struct Date PreviousReadDate; struct Dat_Date PreviousReadDate;
struct Date CurrentReadDate; struct Dat_Date CurrentReadDate;
struct Date LastDate; struct Dat_Date LastDate;
struct Date Date; struct Dat_Date Date;
unsigned D; unsigned D;
unsigned NumDaysFromLastDateToCurrDate = 1; unsigned NumDaysFromLastDateToCurrDate = 1;
unsigned NumDayWeek; unsigned NumDayWeek;
@ -2513,9 +2513,9 @@ static void Sta_ShowNumHitsPerWeek (Sta_CountType_t CountType,
extern const char *Txt_Week; extern const char *Txt_Week;
extern const char *Txt_STAT_TYPE_COUNT_CAPS[Sta_NUM_COUNT_TYPES]; extern const char *Txt_STAT_TYPE_COUNT_CAPS[Sta_NUM_COUNT_TYPES];
unsigned NumHit; unsigned NumHit;
struct Date ReadDate; struct Dat_Date ReadDate;
struct Date LastDate; struct Dat_Date LastDate;
struct Date Date; struct Dat_Date Date;
unsigned W; unsigned W;
unsigned NumWeeksBetweenLastDateAndCurDate; unsigned NumWeeksBetweenLastDateAndCurDate;
struct Sta_Hits Hits; struct Sta_Hits Hits;
@ -2615,9 +2615,9 @@ static void Sta_ShowNumHitsPerMonth (Sta_CountType_t CountType,
extern const char *Txt_Month; extern const char *Txt_Month;
extern const char *Txt_STAT_TYPE_COUNT_CAPS[Sta_NUM_COUNT_TYPES]; extern const char *Txt_STAT_TYPE_COUNT_CAPS[Sta_NUM_COUNT_TYPES];
unsigned NumHit; unsigned NumHit;
struct Date ReadDate; struct Dat_Date ReadDate;
struct Date LastDate; struct Dat_Date LastDate;
struct Date Date; struct Dat_Date Date;
unsigned M; unsigned M;
unsigned NumMonthsBetweenLastDateAndCurDate; unsigned NumMonthsBetweenLastDateAndCurDate;
struct Sta_Hits Hits; struct Sta_Hits Hits;
@ -2716,9 +2716,9 @@ static void Sta_ShowNumHitsPerYear (Sta_CountType_t CountType,
extern const char *Txt_Year; extern const char *Txt_Year;
extern const char *Txt_STAT_TYPE_COUNT_CAPS[Sta_NUM_COUNT_TYPES]; extern const char *Txt_STAT_TYPE_COUNT_CAPS[Sta_NUM_COUNT_TYPES];
unsigned NumHit; unsigned NumHit;
struct Date ReadDate; struct Dat_Date ReadDate;
struct Date LastDate; struct Dat_Date LastDate;
struct Date Date; struct Dat_Date Date;
unsigned Y; unsigned Y;
unsigned NumYearsBetweenLastDateAndCurDate; unsigned NumYearsBetweenLastDateAndCurDate;
struct Sta_Hits Hits; struct Sta_Hits Hits;

View File

@ -2782,7 +2782,7 @@ static void Usr_InsertMyBirthday (void)
/************************* Filter some user's data ***************************/ /************************* Filter some user's data ***************************/
/*****************************************************************************/ /*****************************************************************************/
void Usr_FilterUsrBirthday (struct Date *Birthday) void Usr_FilterUsrBirthday (struct Dat_Date *Birthday)
{ {
/***** Fix birthday *****/ /***** Fix birthday *****/
if (Birthday->Year < Gbl.Now.Date.Year-99 || if (Birthday->Year < Gbl.Now.Date.Year-99 ||

View File

@ -195,7 +195,7 @@ struct UsrData
Pri_Visibility_t BaPrfVisibility; // Who can see user's basic public profile (minimal record card) Pri_Visibility_t BaPrfVisibility; // Who can see user's basic public profile (minimal record card)
Pri_Visibility_t ExPrfVisibility; // Who can see user's extended public profile (figures, follow) Pri_Visibility_t ExPrfVisibility; // Who can see user's extended public profile (figures, follow)
long CtyCod; // Country long CtyCod; // Country
struct Date Birthday; struct Dat_Date Birthday;
char StrBirthday [Cns_MAX_BYTES_DATE + 1]; char StrBirthday [Cns_MAX_BYTES_DATE + 1];
char Phone [2][Usr_MAX_BYTES_PHONE + 1]; char Phone [2][Usr_MAX_BYTES_PHONE + 1];
char *Comments; char *Comments;
@ -384,7 +384,7 @@ void Usr_WelcomeUsr (void);
void Usr_CreateBirthdayStrDB (const struct UsrData *UsrDat, void Usr_CreateBirthdayStrDB (const struct UsrData *UsrDat,
char BirthdayStrDB[Usr_BIRTHDAY_STR_DB_LENGTH + 1]); char BirthdayStrDB[Usr_BIRTHDAY_STR_DB_LENGTH + 1]);
void Usr_FilterUsrBirthday (struct Date *Birthday); void Usr_FilterUsrBirthday (struct Dat_Date *Birthday);
void Usr_PutFormLogIn (void); void Usr_PutFormLogIn (void);
void Usr_WriteLoggedUsrHead (void); void Usr_WriteLoggedUsrHead (void);