diff --git a/swad_call_for_exam.h b/swad_call_for_exam.h index 0d90e926..347d804f 100644 --- a/swad_call_for_exam.h +++ b/swad_call_for_exam.h @@ -65,10 +65,10 @@ struct Cfe_CallForExam 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 char Session[Cfe_MAX_BYTES_SESSION + 1]; // Exam session is june, september, etc. - struct Date CallDate; - struct Date ExamDate; - struct Hour StartTime; - struct Hour Duration; + struct Dat_Date CallDate; + struct Dat_Date ExamDate; + struct Dat_Hour StartTime; + struct Dat_Hour Duration; char *Place; char *Mode; char *Structure; @@ -81,7 +81,7 @@ struct Cfe_CallForExam struct Cfe_ExamCodeAndDate { long ExaCod; - struct Date ExamDate; + struct Dat_Date ExamDate; }; struct Cfe_CallsForExams diff --git a/swad_changelog.h b/swad_changelog.h index a4d7f414..91c82ccd 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -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. */ -#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 JS_FILE "swad20.69.1.js" /* TODO: Rename CENTRE to CENTER in help wiki. 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.7: Sep 18, 2021 New module swad_hierarchy_database for database queries related to hierarchy. (315774 lines) + Version 21.8.1: Sep 20, 2021 Queries moved to module swad_holiday_database. (315927 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.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) diff --git a/swad_date.c b/swad_date.c index 9d0befaa..a4d7d8e9 100644 --- a/swad_date.c +++ b/swad_date.c @@ -103,7 +103,7 @@ static unsigned Dat_GetParamDateFormat (void); /******************************** Reset date *********************************/ /*****************************************************************************/ -void Dat_ResetDate (struct Date *Date) +void Dat_ResetDate (struct Dat_Date *Date) { Date->Day = 0; Date->Month = 0; @@ -112,7 +112,7 @@ void Dat_ResetDate (struct Date *Date) Date->YYYYMMDD[0] = '\0'; } -void Dat_ResetHour (struct Hour *Hour) +void Dat_ResetHour (struct Dat_Hour *Hour) { Hour->Hour = 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 **************/ /*****************************************************************************/ -bool Dat_GetDateFromYYYYMMDD (struct Date *Date,const char *YYYYMMDD) +bool Dat_GetDateFromYYYYMMDD (struct Dat_Date *Date,const char *YYYYMMDD) { if (YYYYMMDD) 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 ********/ /*****************************************************************************/ -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]; @@ -853,7 +853,7 @@ See also http://www.ashleyit.com/rs/jsrs/select/php/select.php */ void Dat_WriteFormDate (unsigned FirstYear,unsigned LastYear, const char *Id, - struct Date *DateSelected, + struct Dat_Date *DateSelected, bool SubmitFormOnChange,bool Disabled) { 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 ******************/ /*****************************************************************************/ -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) : 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 *******************/ /*****************************************************************************/ -void Dat_GetDateBefore (struct Date *Date,struct Date *PrecedingDate) +void Dat_GetDateBefore (struct Dat_Date *Date,struct Dat_Date *PrecedingDate) { 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 ********************/ /*****************************************************************************/ -void Dat_GetWeekBefore (struct Date *Date,struct Date *PrecedingDate) +void Dat_GetWeekBefore (struct Dat_Date *Date,struct Dat_Date *PrecedingDate) { 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 *******************/ /*****************************************************************************/ -void Dat_GetMonthBefore (struct Date *Date,struct Date *PrecedingDate) +void Dat_GetMonthBefore (struct Dat_Date *Date,struct Dat_Date *PrecedingDate) { 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 ********************/ /*****************************************************************************/ -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; } @@ -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 // ... -unsigned Dat_GetNumDaysBetweenDates (struct Date *DateIni, - struct Date *DateEnd) +unsigned Dat_GetNumDaysBetweenDates (struct Dat_Date *DateIni, + struct Dat_Date *DateEnd) { int DiffDays; unsigned Year; @@ -1223,8 +1223,8 @@ unsigned Dat_GetNumDaysBetweenDates (struct Date *DateIni, /*****************************************************************************/ // If the two dates are in the same week, return 1 -unsigned Dat_GetNumWeeksBetweenDates (struct Date *DateIni, - struct Date *DateEnd) +unsigned Dat_GetNumWeeksBetweenDates (struct Dat_Date *DateIni, + struct Dat_Date *DateEnd) { int DiffWeeks; unsigned Year; @@ -1250,8 +1250,8 @@ unsigned Dat_GetNumWeeksBetweenDates (struct Date *DateIni, /*****************************************************************************/ // If the two dates are in the same month, return 1 -unsigned Dat_GetNumMonthsBetweenDates (struct Date *DateIni, - struct Date *DateEnd) +unsigned Dat_GetNumMonthsBetweenDates (struct Dat_Date *DateIni, + struct Dat_Date *DateEnd) { int DiffMonths; @@ -1267,8 +1267,8 @@ unsigned Dat_GetNumMonthsBetweenDates (struct Date *DateIni, /*****************************************************************************/ // If the two dates are in the same year, return 1 -unsigned Dat_GetNumYearsBetweenDates (struct Date *DateIni, - struct Date *DateEnd) +unsigned Dat_GetNumYearsBetweenDates (struct Dat_Date *DateIni, + struct Dat_Date *DateEnd) { int DiffYears; @@ -1496,7 +1496,7 @@ continue: /***************** 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 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). 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 | @@ -1564,7 +1564,7 @@ void Dat_CalculateWeekOfYear (struct Date *Date) /******************* 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->Month = DateSrc->Month; @@ -1628,7 +1628,7 @@ void Dat_WriteHoursMinutesSecondsFromSeconds (time_t Seconds) /******************* Write time as hours:minutes:seconds *********************/ /*****************************************************************************/ -void Dat_WriteHoursMinutesSeconds (struct Time *Time) +void Dat_WriteHoursMinutesSeconds (struct Dat_Time *Time) { if (Time->Hour) HTM_TxtF ("%u:%02u′%02u″",Time->Hour,Time->Minute,Time->Second); diff --git a/swad_date.h b/swad_date.h index 55851c8c..b29b6aec 100644 --- a/swad_date.h +++ b/swad_date.h @@ -48,7 +48,7 @@ /*****************************************************************************/ #define Dat_LENGTH_YYYYMMDD (4 + 2 + 2) -struct Date +struct Dat_Date { unsigned Day; unsigned Month; @@ -56,21 +56,21 @@ struct Date unsigned Week; char YYYYMMDD[Dat_LENGTH_YYYYMMDD + 1]; }; -struct Time +struct Dat_Time { unsigned Hour; unsigned Minute; unsigned Second; }; -struct Hour +struct Dat_Hour { unsigned Hour; unsigned Minute; }; -struct DateTime +struct Dat_DateTime { - struct Date Date; - struct Time Time; + struct Dat_Date Date; + struct Dat_Time Time; char YYYYMMDDHHMMSS[4 + 2 + 2 + 2 + 2 + 2 + 1]; }; @@ -124,8 +124,8 @@ typedef enum /***************************** Public prototypes *****************************/ /*****************************************************************************/ -void Dat_ResetDate (struct Date *Date); -void Dat_ResetHour (struct Hour *Hour); +void Dat_ResetDate (struct Dat_Date *Date); +void Dat_ResetHour (struct Dat_Hour *Hour); void Dat_PutBoxToSelectDateFormat (void); @@ -139,12 +139,12 @@ void Dat_GetStartExecutionTimeUTC (void); void Dat_GetAndConvertCurrentDateTime (void); 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); 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_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, const char *Id, - struct Date *DateSelected, + struct Dat_Date *DateSelected, bool SubmitFormOnChange,bool Disabled); void Dat_GetDateFromForm (const char *ParamNameDay,const char *ParamNameMonth,const char *ParamNameYear, unsigned *Day,unsigned *Month,unsigned *Year); @@ -177,32 +177,32 @@ void Dat_GetIniEndDatesFromForm (void); void Dat_WriteRFC822DateFromTM (FILE *File,struct tm *tm); -void Dat_GetDateAfter (struct Date *Date,struct Date *SubsequentDate); -void Dat_GetDateBefore (struct Date *Date,struct Date *PrecedingDate ); -void Dat_GetWeekBefore (struct Date *Date,struct Date *PrecedingDate ); -void Dat_GetMonthBefore (struct Date *Date,struct Date *PrecedingDate ); -void Dat_GetYearBefore (struct Date *Date,struct Date *PrecedingDate ); -unsigned Dat_GetNumDaysBetweenDates (struct Date *DateIni, - struct Date *DateEnd); -unsigned Dat_GetNumWeeksBetweenDates (struct Date *DateIni, - struct Date *DateEnd); -unsigned Dat_GetNumMonthsBetweenDates (struct Date *DateIni, - struct Date *DateEnd); -unsigned Dat_GetNumYearsBetweenDates (struct Date *DateIni, - struct Date *DateEnd); +void Dat_GetDateAfter (struct Dat_Date *Date,struct Dat_Date *SubsequentDate); +void Dat_GetDateBefore (struct Dat_Date *Date,struct Dat_Date *PrecedingDate ); +void Dat_GetWeekBefore (struct Dat_Date *Date,struct Dat_Date *PrecedingDate ); +void Dat_GetMonthBefore (struct Dat_Date *Date,struct Dat_Date *PrecedingDate ); +void Dat_GetYearBefore (struct Dat_Date *Date,struct Dat_Date *PrecedingDate ); +unsigned Dat_GetNumDaysBetweenDates (struct Dat_Date *DateIni, + struct Dat_Date *DateEnd); +unsigned Dat_GetNumWeeksBetweenDates (struct Dat_Date *DateIni, + struct Dat_Date *DateEnd); +unsigned Dat_GetNumMonthsBetweenDates (struct Dat_Date *DateIni, + struct Dat_Date *DateEnd); +unsigned Dat_GetNumYearsBetweenDates (struct Dat_Date *DateIni, + struct Dat_Date *DateEnd); unsigned Dat_GetNumDaysInYear (unsigned Year); unsigned Dat_GetNumDaysFebruary (unsigned Year); bool Dat_GetIfLeapYear (unsigned Year); unsigned Dat_GetNumWeeksInYear (unsigned Year); unsigned Dat_GetDayOfWeek (unsigned Year,unsigned Month,unsigned Day); -unsigned Dat_GetDayOfYear (struct Date *Date); -void Dat_CalculateWeekOfYear (struct Date *Date); -void Dat_AssignDate (struct Date *DateDst,struct Date *DateSrc); +unsigned Dat_GetDayOfYear (struct Dat_Date *Date); +void Dat_CalculateWeekOfYear (struct Dat_Date *Date); +void Dat_AssignDate (struct Dat_Date *DateDst,struct Dat_Date *DateSrc); void Dat_WriteScriptMonths (void); 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, Dat_Format_t DateFormat,Dat_Separator_t Separator, diff --git a/swad_global.h b/swad_global.h index d3950281..4e183601 100644 --- a/swad_global.h +++ b/swad_global.h @@ -175,8 +175,8 @@ struct Globals bool IsAJAXAutoRefresh; // It's an automatic refresh drom time to time } Action; time_t StartExecutionTimeUTC; - struct DateTime Now; - struct Date Yesterday; + struct Dat_DateTime Now; + struct Dat_Date Yesterday; unsigned RowEvenOdd; // To alternate row colors in listings char *ColorRows[2]; const char *XMLPtr; @@ -435,8 +435,8 @@ struct Globals } FileBrowser; // Struct used for a file browser struct { - struct DateTime DateIni; // TODO: Remove in future versions - struct DateTime DateEnd; // TODO: Remove in future versions + struct Dat_DateTime DateIni; // TODO: Remove in future versions + struct Dat_DateTime DateEnd; // TODO: Remove in future versions time_t TimeUTC[Dat_NUM_START_END_TIME]; } DateRange; diff --git a/swad_holiday.c b/swad_holiday.c index 06940447..e1a5773e 100644 --- a/swad_holiday.c +++ b/swad_holiday.c @@ -664,10 +664,7 @@ void Hld_RemoveHoliday (void) Hld_GetDataOfHolidayByCod (Hld_EditingHld); /***** Remove holiday *****/ - DB_QueryDELETE ("can not remove a holiday", - "DELETE FROM hld_holidays" - " WHERE HldCod=%ld", - Hld_EditingHld->HldCod); + Hld_DB_RemoveHoliday (Hld_EditingHld->HldCod); /***** Write message to show the change made *****/ Ale_CreateAlert (Ale_SUCCESS,NULL, @@ -702,12 +699,7 @@ void Hld_ChangeHolidayPlace (void) Hld_GetDataOfHolidayByCod (Hld_EditingHld); /***** Update the place in database *****/ - DB_QueryUPDATE ("can not update the place of a holiday", - "UPDATE hld_holidays" - " SET PlcCod=%ld" - " WHERE HldCod=%ld", - NewPlace.PlcCod, - Hld_EditingHld->HldCod); + Hld_DB_ChangePlace (Hld_EditingHld->HldCod,NewPlace.PlcCod); Hld_EditingHld->PlcCod = NewPlace.PlcCod; Str_Copy (Hld_EditingHld->PlaceFullName,NewPlace.FullName, sizeof (Hld_EditingHld->PlaceFullName) - 1); @@ -741,13 +733,7 @@ void Hld_ChangeHolidayType (void) /***** Update holiday/no school period in database *****/ Dat_AssignDate (&Hld_EditingHld->EndDate,&Hld_EditingHld->StartDate); - DB_QueryUPDATE ("can not update the type of a holiday", - "UPDATE hld_holidays" - " SET HldTyp=%u," - "EndDate=StartDate" - " WHERE HldCod=%ld", - (unsigned) Hld_EditingHld->HldTyp, - Hld_EditingHld->HldCod); + Hld_DB_ChangeType (Hld_EditingHld->HldCod,Hld_EditingHld->HldTyp); /***** Write message to show the change made *****/ Ale_CreateAlert (Ale_SUCCESS,NULL, @@ -780,8 +766,8 @@ void Hld_ChangeEndDate (void) static void Hld_ChangeDate (Hld_StartOrEndDate_t StartOrEndDate) { extern const char *Txt_The_date_of_the_holiday_X_has_changed_to_Y; - struct Date NewDate; - struct Date *PtrDate = NULL; // Initialized to avoid warning + struct Dat_Date NewDate; + struct Dat_Date *PtrDate = NULL; // Initialized to avoid warning const char *StrStartOrEndDate = NULL; // Initialized to avoid warning char StrDate[Cns_MAX_BYTES_DATE + 1]; @@ -829,15 +815,7 @@ static void Hld_ChangeDate (Hld_StartOrEndDate_t StartOrEndDate) } /***** Update the date in database *****/ - 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, - Hld_EditingHld->HldCod); + Hld_DB_ChangeDate (Hld_EditingHld->HldCod,StrStartOrEndDate,&NewDate); Dat_AssignDate (PtrDate,&NewDate); /***** Write message to show the change made *****/ @@ -880,12 +858,7 @@ void Hld_RenameHoliday (void) { /***** If degree was in database... *****/ /* Update the table changing old name by new name */ - DB_QueryUPDATE ("can not update the text of a holiday", - "UPDATE hld_holidays" - " SET Name='%s'" - " WHERE HldCod=%ld", - NewHldName, - Hld_EditingHld->HldCod); + Hld_DB_ChangeName (Hld_EditingHld->HldCod,NewHldName); Str_Copy (Hld_EditingHld->Name,NewHldName, sizeof (Hld_EditingHld->Name) - 1); diff --git a/swad_holiday.h b/swad_holiday.h index c39161e8..23be809d 100644 --- a/swad_holiday.h +++ b/swad_holiday.h @@ -57,8 +57,8 @@ struct Hld_Holiday long PlcCod; char PlaceFullName[Plc_MAX_BYTES_PLACE_FULL_NAME + 1]; Hld_HolidayType_t HldTyp; - struct Date StartDate; - struct Date EndDate; + struct Dat_Date StartDate; + struct Dat_Date EndDate; char Name[Hld_MAX_BYTES_HOLIDAY_NAME + 1]; }; diff --git a/swad_holiday_database.c b/swad_holiday_database.c index 552d0a8a..ec7c14b1 100644 --- a/swad_holiday_database.c +++ b/swad_holiday_database.c @@ -86,6 +86,67 @@ void Hld_DB_CreateHoliday (const struct Hld_Holiday *Hld) 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 ***************************/ /*****************************************************************************/ @@ -177,3 +238,16 @@ unsigned Hld_DB_GetDataOfHolidayByCod (MYSQL_RES **mysql_res,long HldCod) 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); + } + diff --git a/swad_holiday_database.h b/swad_holiday_database.h index 17b16bc4..c29e096a 100644 --- a/swad_holiday_database.h +++ b/swad_holiday_database.h @@ -27,6 +27,7 @@ /********************************* Headers ***********************************/ /*****************************************************************************/ +#include "swad_date.h" #include "swad_holiday.h" /*****************************************************************************/ @@ -38,8 +39,15 @@ /*****************************************************************************/ 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_GetDataOfHolidayByCod (MYSQL_RES **mysql_res,long HldCod); +void Hld_DB_RemoveHoliday (long HldCod); + #endif diff --git a/swad_match.c b/swad_match.c index 37d5893a..f4589fec 100644 --- a/swad_match.c +++ b/swad_match.c @@ -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_GetElapsedTimeInQuestion (const struct Mch_Match *Match, - struct Time *Time); + struct Dat_Time *Time); 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, - struct Time *Time); + struct Dat_Time *Time); static void Mch_SetMatchStatusToPrev (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, - struct Time *Time) + struct Dat_Time *Time) { MYSQL_RES *mysql_res; unsigned NumRows; @@ -2115,7 +2115,7 @@ static void Mch_GetElapsedTimeInQuestion (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; 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, - struct Time *Time) + struct Dat_Time *Time) { MYSQL_ROW row; bool ElapsedTimeGotFromDB = false; @@ -2643,7 +2643,7 @@ static void Mch_ShowRefreshablePartTch (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\""); @@ -2662,7 +2662,7 @@ static void Mch_WriteElapsedTimeInMch (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\""); diff --git a/swad_statistic.c b/swad_statistic.c index 15f7cc60..9bd9eb11 100644 --- a/swad_statistic.c +++ b/swad_statistic.c @@ -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_DAYS_SMALL[7]; unsigned NumHit; - struct Date ReadDate; - struct Date LastDate; - struct Date Date; + struct Dat_Date ReadDate; + struct Dat_Date LastDate; + struct Dat_Date Date; unsigned D; unsigned NumDaysFromLastDateToCurrDate; int NumDayWeek; @@ -2071,10 +2071,10 @@ static void Sta_ShowDistrAccessesPerDayAndHour (const struct Sta_Stats *Stats, unsigned ColorTypeUnsigned; Sta_ColorType_t SelectedColorType; unsigned NumHit; - struct Date PreviousReadDate; - struct Date CurrentReadDate; - struct Date LastDate; - struct Date Date; + struct Dat_Date PreviousReadDate; + struct Dat_Date CurrentReadDate; + struct Dat_Date LastDate; + struct Dat_Date Date; unsigned D; unsigned NumDaysFromLastDateToCurrDate = 1; unsigned NumDayWeek; @@ -2513,9 +2513,9 @@ static void Sta_ShowNumHitsPerWeek (Sta_CountType_t CountType, extern const char *Txt_Week; extern const char *Txt_STAT_TYPE_COUNT_CAPS[Sta_NUM_COUNT_TYPES]; unsigned NumHit; - struct Date ReadDate; - struct Date LastDate; - struct Date Date; + struct Dat_Date ReadDate; + struct Dat_Date LastDate; + struct Dat_Date Date; unsigned W; unsigned NumWeeksBetweenLastDateAndCurDate; 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_STAT_TYPE_COUNT_CAPS[Sta_NUM_COUNT_TYPES]; unsigned NumHit; - struct Date ReadDate; - struct Date LastDate; - struct Date Date; + struct Dat_Date ReadDate; + struct Dat_Date LastDate; + struct Dat_Date Date; unsigned M; unsigned NumMonthsBetweenLastDateAndCurDate; 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_STAT_TYPE_COUNT_CAPS[Sta_NUM_COUNT_TYPES]; unsigned NumHit; - struct Date ReadDate; - struct Date LastDate; - struct Date Date; + struct Dat_Date ReadDate; + struct Dat_Date LastDate; + struct Dat_Date Date; unsigned Y; unsigned NumYearsBetweenLastDateAndCurDate; struct Sta_Hits Hits; diff --git a/swad_user.c b/swad_user.c index c12bfe19..25a29a45 100644 --- a/swad_user.c +++ b/swad_user.c @@ -2782,7 +2782,7 @@ static void Usr_InsertMyBirthday (void) /************************* Filter some user's data ***************************/ /*****************************************************************************/ -void Usr_FilterUsrBirthday (struct Date *Birthday) +void Usr_FilterUsrBirthday (struct Dat_Date *Birthday) { /***** Fix birthday *****/ if (Birthday->Year < Gbl.Now.Date.Year-99 || diff --git a/swad_user.h b/swad_user.h index 3973fd13..6bf79848 100644 --- a/swad_user.h +++ b/swad_user.h @@ -195,7 +195,7 @@ struct UsrData 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) long CtyCod; // Country - struct Date Birthday; + struct Dat_Date Birthday; char StrBirthday [Cns_MAX_BYTES_DATE + 1]; char Phone [2][Usr_MAX_BYTES_PHONE + 1]; char *Comments; @@ -384,7 +384,7 @@ void Usr_WelcomeUsr (void); void Usr_CreateBirthdayStrDB (const struct UsrData *UsrDat, 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_WriteLoggedUsrHead (void);