2014-12-01 23:55:08 +01:00
|
|
|
|
// swad_holiday.c: holidays
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
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.
|
2024-02-07 00:40:28 +01:00
|
|
|
|
Copyright (C) 1999-2024 Antonio Ca<EFBFBD>as Vargas
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
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 ***********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-12-29 12:39:00 +01:00
|
|
|
|
#include <stddef.h> // For NULL
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include <stdlib.h> // For calloc
|
|
|
|
|
#include <string.h> // For string functions
|
|
|
|
|
|
2022-11-06 18:11:10 +01:00
|
|
|
|
#include "swad_action_list.h"
|
2022-10-19 18:07:49 +02:00
|
|
|
|
#include "swad_alert.h"
|
2017-06-10 21:38:10 +02:00
|
|
|
|
#include "swad_box.h"
|
2019-02-15 13:39:37 +01:00
|
|
|
|
#include "swad_calendar.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_database.h"
|
2021-04-26 15:27:27 +02:00
|
|
|
|
#include "swad_error.h"
|
2018-11-09 20:47:39 +01:00
|
|
|
|
#include "swad_form.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_global.h"
|
|
|
|
|
#include "swad_holiday.h"
|
2021-09-20 14:31:24 +02:00
|
|
|
|
#include "swad_holiday_database.h"
|
2019-10-23 19:05:05 +02:00
|
|
|
|
#include "swad_HTML.h"
|
2018-12-08 16:43:13 +01:00
|
|
|
|
#include "swad_language.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_parameter.h"
|
2023-03-10 17:21:04 +01:00
|
|
|
|
#include "swad_parameter_code.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2023-04-20 01:22:07 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************************** Private constants ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static const bool Hld_ICanEditHlds[Rol_NUM_ROLES] =
|
|
|
|
|
{
|
|
|
|
|
/* Users who can edit */
|
|
|
|
|
[Rol_INS_ADM] = true,
|
|
|
|
|
[Rol_SYS_ADM] = true,
|
|
|
|
|
};
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private variables *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-13 22:04:46 +02:00
|
|
|
|
static struct Hld_Holiday *Hld_EditingHld = NULL; // Static variable to keep the holiday being edited
|
2019-04-09 13:44:57 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private prototypes ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-03-10 00:13:55 +01:00
|
|
|
|
static Hld_Order_t Hld_GetParHldOrder (void);
|
2020-04-08 18:18:46 +02:00
|
|
|
|
static void Hld_PutIconsSeeHolidays (__attribute__((unused)) void *Args);
|
2023-04-20 10:31:14 +02:00
|
|
|
|
static void Hld_PutIconsEditHolidays (__attribute__((unused)) void *Args);
|
2016-11-28 14:48:16 +01:00
|
|
|
|
|
2019-04-09 13:44:57 +02:00
|
|
|
|
static void Hld_EditHolidaysInternal (void);
|
|
|
|
|
|
2023-03-23 09:35:20 +01:00
|
|
|
|
static void Hld_GetHolidayDataByCod (struct Hld_Holiday *Hld);
|
2023-03-23 14:09:45 +01:00
|
|
|
|
static void Hld_GetHolidayDataFromRow (MYSQL_RES *mysql_res,
|
|
|
|
|
struct Hld_Holiday *Hld);
|
2016-11-28 14:48:16 +01:00
|
|
|
|
|
2023-03-10 00:13:55 +01:00
|
|
|
|
static Hld_HolidayType_t Hld_GetParHldType (void);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static Hld_HolidayType_t Hld_GetTypeOfHoliday (const char *UnsignedStr);
|
2020-04-13 22:04:46 +02:00
|
|
|
|
static void Hld_ListHolidaysForEdition (const struct Hld_Holidays *Holidays,
|
|
|
|
|
const struct Plc_Places *Places);
|
2023-03-10 00:13:55 +01:00
|
|
|
|
static void Hld_PutParHldCod (void *HldCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static void Hld_ChangeDate (Hld_StartOrEndDate_t StartOrEndDate);
|
2020-04-13 21:26:47 +02:00
|
|
|
|
static void Hld_PutFormToCreateHoliday (const struct Plc_Places *Places);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static void Hld_PutHeadHolidays (void);
|
|
|
|
|
|
2019-04-09 13:44:57 +02:00
|
|
|
|
static void Hld_EditingHolidayConstructor (void);
|
|
|
|
|
static void Hld_EditingHolidayDestructor (void);
|
|
|
|
|
|
2020-04-13 22:04:46 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Reset departments context *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Hld_ResetHolidays (struct Hld_Holidays *Holidays)
|
|
|
|
|
{
|
|
|
|
|
Holidays->LstIsRead = false; // List is not read
|
|
|
|
|
Holidays->Num = 0;
|
|
|
|
|
Holidays->Lst = NULL;
|
|
|
|
|
Holidays->SelectedOrder = Hld_DEFAULT_ORDER_TYPE;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
2021-10-30 13:28:48 +02:00
|
|
|
|
/****************************** List all holidays ****************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-04-19 12:11:38 +02:00
|
|
|
|
void Hld_SeeAllHolidays (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2016-11-28 14:48:16 +01:00
|
|
|
|
extern const char *Hlp_INSTITUTION_Holidays;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Holidays;
|
|
|
|
|
extern const char *Txt_HOLIDAYS_HELP_ORDER[2];
|
|
|
|
|
extern const char *Txt_HOLIDAYS_ORDER[2];
|
|
|
|
|
extern const char *Txt_End_date;
|
|
|
|
|
extern const char *Txt_Holiday;
|
|
|
|
|
extern const char *Txt_All_places;
|
2017-03-26 23:16:51 +02:00
|
|
|
|
extern const char *Txt_No_holidays;
|
2017-01-29 12:42:19 +01:00
|
|
|
|
Hld_Order_t Order;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned NumHld;
|
2017-05-05 02:03:28 +02:00
|
|
|
|
char StrDate[Cns_MAX_BYTES_DATE + 1];
|
2020-04-13 22:04:46 +02:00
|
|
|
|
struct Hld_Holidays Holidays;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2023-09-22 14:47:56 +02:00
|
|
|
|
if (Gbl.Hierarchy.Node[Hie_INS].HieCod > 0)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-04-13 22:04:46 +02:00
|
|
|
|
/***** Reset places context *****/
|
|
|
|
|
Hld_ResetHolidays (&Holidays);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get parameter with the type of order in the list of holidays *****/
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Holidays.SelectedOrder = Hld_GetParHldOrder ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get list of holidays *****/
|
2020-04-13 22:04:46 +02:00
|
|
|
|
Hld_GetListHolidays (&Holidays);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Table head *****/
|
2024-01-29 09:45:28 +01:00
|
|
|
|
Box_BoxBegin (Txt_Holidays,Hld_PutIconsSeeHolidays,NULL,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
Hlp_INSTITUTION_Holidays,Box_NOT_CLOSABLE);
|
2019-10-13 15:24:06 +02:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
if (Holidays.Num)
|
|
|
|
|
{
|
|
|
|
|
HTM_TABLE_BeginWideMarginPadding (2);
|
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
|
2022-01-02 00:39:26 +01:00
|
|
|
|
for (Order = (Hld_Order_t) 0;
|
|
|
|
|
Order <= (Hld_Order_t) (Hld_NUM_ORDERS - 1);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
Order++)
|
|
|
|
|
{
|
2022-01-02 15:17:30 +01:00
|
|
|
|
HTM_TH_Begin (HTM_HEAD_LEFT);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
Frm_BeginForm (ActSeeHld);
|
2023-03-07 09:55:39 +01:00
|
|
|
|
Par_PutParUnsigned (NULL,"Order",(unsigned) Order);
|
2022-04-01 01:06:44 +02:00
|
|
|
|
HTM_BUTTON_Submit_Begin (Txt_HOLIDAYS_HELP_ORDER[Order],
|
|
|
|
|
"class=\"BT_LINK\"");
|
2021-07-08 15:00:17 +02:00
|
|
|
|
if (Order == Holidays.SelectedOrder)
|
|
|
|
|
HTM_U_Begin ();
|
|
|
|
|
HTM_Txt (Txt_HOLIDAYS_ORDER[Order]);
|
|
|
|
|
if (Order == Holidays.SelectedOrder)
|
|
|
|
|
HTM_U_End ();
|
|
|
|
|
HTM_BUTTON_End ();
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
HTM_TH_End ();
|
|
|
|
|
}
|
2024-01-26 10:26:19 +01:00
|
|
|
|
HTM_TH (Txt_End_date,HTM_HEAD_LEFT);
|
2022-01-02 15:17:30 +01:00
|
|
|
|
HTM_TH (Txt_Holiday,HTM_HEAD_LEFT);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
|
2021-10-30 13:28:48 +02:00
|
|
|
|
/***** Write all holidays *****/
|
2021-07-08 15:00:17 +02:00
|
|
|
|
for (NumHld = 0;
|
|
|
|
|
NumHld < Holidays.Num;
|
|
|
|
|
NumHld++)
|
|
|
|
|
{
|
|
|
|
|
/* Write data of this holiday */
|
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
|
2023-10-14 21:36:39 +02:00
|
|
|
|
HTM_TD_Txt_Left (Holidays.Lst[NumHld].PlcCod <= 0 ? Txt_All_places :
|
|
|
|
|
Holidays.Lst[NumHld].PlaceFullName);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
|
|
|
|
|
Dat_ConvDateToDateStr (&Holidays.Lst[NumHld].StartDate,StrDate);
|
|
|
|
|
|
2023-10-14 21:36:39 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LM DAT_%s\"",The_GetSuffix ());
|
|
|
|
|
HTM_Txt (StrDate);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
2023-10-14 21:36:39 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LM DAT_%s\"",The_GetSuffix ());
|
2021-07-08 15:00:17 +02:00
|
|
|
|
switch (Holidays.Lst[NumHld].HldTyp)
|
|
|
|
|
{
|
|
|
|
|
case Hld_HOLIDAY:
|
|
|
|
|
break;
|
|
|
|
|
case Hld_NON_SCHOOL_PERIOD:
|
|
|
|
|
Dat_ConvDateToDateStr (&Holidays.Lst[NumHld].EndDate,StrDate);
|
|
|
|
|
HTM_Txt (StrDate);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
2023-10-14 21:36:39 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LM DAT_%s\"",The_GetSuffix ());
|
2024-01-26 10:26:19 +01:00
|
|
|
|
HTM_Txt (Holidays.Lst[NumHld].Name);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
}
|
|
|
|
|
HTM_TABLE_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2021-07-08 15:00:17 +02:00
|
|
|
|
else // No holidays created in the current institution
|
|
|
|
|
Ale_ShowAlert (Ale_INFO,Txt_No_holidays);
|
2019-10-12 00:07:52 +02:00
|
|
|
|
|
2019-10-14 15:02:00 +02:00
|
|
|
|
/***** End box *****/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Box_BoxEnd ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free list of holidays *****/
|
2020-04-13 22:04:46 +02:00
|
|
|
|
Hld_FreeListHolidays (&Holidays);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********* Get parameter with the type or order in list of holidays **********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-03-10 00:13:55 +01:00
|
|
|
|
static Hld_Order_t Hld_GetParHldOrder (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2023-03-07 09:55:39 +01:00
|
|
|
|
return (Hld_Order_t) Par_GetParUnsignedLong ("Order",
|
2023-03-10 00:13:55 +01:00
|
|
|
|
0,
|
|
|
|
|
Hld_NUM_ORDERS - 1,
|
|
|
|
|
(unsigned long) Hld_DEFAULT_ORDER_TYPE);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2019-02-15 13:39:37 +01:00
|
|
|
|
/******************** Put contextual icons in calendar ***********************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-08 18:18:46 +02:00
|
|
|
|
static void Hld_PutIconsSeeHolidays (__attribute__((unused)) void *Args)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2023-04-20 10:31:14 +02:00
|
|
|
|
/***** Edit holidays *****/
|
2023-04-20 01:22:07 +02:00
|
|
|
|
if (Hld_ICanEditHlds[Gbl.Usrs.Me.Role.Logged])
|
2020-04-08 18:18:46 +02:00
|
|
|
|
Ico_PutContextualIconToEdit (ActEdiHld,NULL,
|
|
|
|
|
NULL,NULL);
|
2019-02-15 13:39:37 +01:00
|
|
|
|
|
2020-04-08 18:18:46 +02:00
|
|
|
|
/***** View calendar *****/
|
2023-04-20 10:31:14 +02:00
|
|
|
|
Cal_PutIconToSeeCalendar ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void Hld_PutIconsEditHolidays (__attribute__((unused)) void *Args)
|
|
|
|
|
{
|
Version 22.101.9: Apr 21, 2023 Changes in edition of countries, links, banners, institutions, centers, places, degrees, degree types, buildings, rooms and courses.
2023-04-21 00:30:34 +02:00
|
|
|
|
/***** Put icon to view holidays *****/
|
|
|
|
|
Ico_PutContextualIconToView (ActSeeHld,NULL,
|
|
|
|
|
NULL,NULL);
|
2023-04-20 10:31:14 +02:00
|
|
|
|
|
|
|
|
|
/***** View calendar *****/
|
|
|
|
|
Cal_PutIconToSeeCalendar ();
|
2019-02-15 13:39:37 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Put icon to see holidays *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Hld_PutIconToSeeHlds (void)
|
|
|
|
|
{
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Lay_PutContextualLinkOnlyIcon (ActSeeHld,NULL,
|
|
|
|
|
NULL,NULL,
|
2022-06-29 18:34:15 +02:00
|
|
|
|
"calendar-day.svg",Ico_BLACK);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Put forms to edit degree types *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Hld_EditHolidays (void)
|
2019-04-09 13:44:57 +02:00
|
|
|
|
{
|
|
|
|
|
/***** Holiday constructor *****/
|
|
|
|
|
Hld_EditingHolidayConstructor ();
|
|
|
|
|
|
|
|
|
|
/***** Edit holidays *****/
|
|
|
|
|
Hld_EditHolidaysInternal ();
|
|
|
|
|
|
|
|
|
|
/***** Holiday destructor *****/
|
|
|
|
|
Hld_EditingHolidayDestructor ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void Hld_EditHolidaysInternal (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-04-13 22:04:46 +02:00
|
|
|
|
struct Hld_Holidays Holidays;
|
2020-04-13 21:26:47 +02:00
|
|
|
|
struct Plc_Places Places;
|
|
|
|
|
|
2020-04-13 22:04:46 +02:00
|
|
|
|
/***** Reset places context *****/
|
|
|
|
|
Hld_ResetHolidays (&Holidays);
|
|
|
|
|
|
2020-04-13 21:26:47 +02:00
|
|
|
|
/***** Reset places context *****/
|
|
|
|
|
Plc_ResetPlaces (&Places);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get list of places *****/
|
2020-04-13 21:26:47 +02:00
|
|
|
|
Plc_GetListPlaces (&Places);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get list of holidays *****/
|
2020-04-13 22:04:46 +02:00
|
|
|
|
Hld_GetListHolidays (&Holidays);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Forms to edit current holidays *****/
|
2023-04-20 09:07:18 +02:00
|
|
|
|
Hld_ListHolidaysForEdition (&Holidays,&Places);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free list of holidays *****/
|
2020-04-13 22:04:46 +02:00
|
|
|
|
Hld_FreeListHolidays (&Holidays);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free list of places *****/
|
2020-04-13 21:26:47 +02:00
|
|
|
|
Plc_FreeListPlaces (&Places);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-10-30 13:28:48 +02:00
|
|
|
|
/***************************** List all holidays *****************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-13 22:04:46 +02:00
|
|
|
|
void Hld_GetListHolidays (struct Hld_Holidays *Holidays)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
unsigned NumHld;
|
|
|
|
|
|
2022-10-18 19:59:02 +02:00
|
|
|
|
if (DB_CheckIfDatabaseIsOpen ())
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-04-13 22:04:46 +02:00
|
|
|
|
if (Holidays->LstIsRead)
|
|
|
|
|
Hld_FreeListHolidays (Holidays);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get holidays from database *****/
|
2021-09-20 14:31:24 +02:00
|
|
|
|
if ((Holidays->Num = Hld_DB_GetListHolidays (&mysql_res,Holidays->SelectedOrder))) // Holidays found...
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Create list of holidays *****/
|
2021-02-15 16:25:55 +01:00
|
|
|
|
if ((Holidays->Lst = calloc (Holidays->Num,
|
|
|
|
|
sizeof (*Holidays->Lst))) == NULL)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get the holidays *****/
|
|
|
|
|
for (NumHld = 0;
|
2020-04-13 22:04:46 +02:00
|
|
|
|
NumHld < Holidays->Num;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
NumHld++)
|
2023-03-23 22:47:23 +01:00
|
|
|
|
Hld_GetHolidayDataFromRow (mysql_res,&Holidays->Lst[NumHld]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
2020-04-13 22:04:46 +02:00
|
|
|
|
Holidays->LstIsRead = true;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-11-28 14:48:16 +01:00
|
|
|
|
/************************* Get holiday data by code **************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-03-23 09:35:20 +01:00
|
|
|
|
static void Hld_GetHolidayDataByCod (struct Hld_Holiday *Hld)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
|
|
|
|
|
/***** Clear data *****/
|
|
|
|
|
Hld->PlcCod = -1L;
|
|
|
|
|
Hld->PlaceFullName[0] = '\0';
|
|
|
|
|
Hld->StartDate.Day =
|
|
|
|
|
Hld->StartDate.Month =
|
|
|
|
|
Hld->StartDate.Year = 0;
|
|
|
|
|
Hld->Name[0] = '\0';
|
|
|
|
|
|
|
|
|
|
/***** Check if holiday code is correct *****/
|
|
|
|
|
if (Hld->HldCod <= 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongHolidayExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get data of holiday from database *****/
|
2023-03-23 09:35:20 +01:00
|
|
|
|
if (Hld_DB_GetHolidayDataByCod (&mysql_res,Hld->HldCod)) // Holiday found...
|
2023-03-23 14:09:45 +01:00
|
|
|
|
Hld_GetHolidayDataFromRow (mysql_res,Hld);
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Get holiday data from database row *********************/
|
|
|
|
|
/*****************************************************************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2023-03-23 14:09:45 +01:00
|
|
|
|
static void Hld_GetHolidayDataFromRow (MYSQL_RES *mysql_res,
|
|
|
|
|
struct Hld_Holiday *Hld)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
|
2023-03-23 19:56:18 +01:00
|
|
|
|
/***** Get next row from result *****/
|
2023-03-23 14:09:45 +01:00
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
/*
|
2023-03-23 18:06:03 +01:00
|
|
|
|
row[0]: HldCod
|
|
|
|
|
row[1]: PlcCod
|
|
|
|
|
row[2]: Place
|
|
|
|
|
row[3]: HldTyp
|
|
|
|
|
row[4]: StartDate
|
|
|
|
|
row[5]: EndDate
|
|
|
|
|
row[6]: Name
|
2023-03-23 14:09:45 +01:00
|
|
|
|
*/
|
2023-03-23 18:06:03 +01:00
|
|
|
|
/***** Get holiday code (row[0]) and place code (row[1]) *****/
|
|
|
|
|
Hld->HldCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
|
|
|
Hld->PlcCod = Str_ConvertStrCodToLongCod (row[1]);
|
2023-03-23 14:09:45 +01:00
|
|
|
|
|
2023-03-23 18:06:03 +01:00
|
|
|
|
/***** Get the full name of the place (row[2]) *****/
|
|
|
|
|
Str_Copy (Hld->PlaceFullName,row[2],sizeof (Hld->PlaceFullName) - 1);
|
2023-03-23 14:09:45 +01:00
|
|
|
|
|
2023-03-23 18:06:03 +01:00
|
|
|
|
/***** Get type (row[3]) *****/
|
|
|
|
|
Hld->HldTyp = Hld_GetTypeOfHoliday (row[3]);
|
2023-03-23 14:09:45 +01:00
|
|
|
|
|
2023-03-23 18:06:03 +01:00
|
|
|
|
/***** Get start date (row[4] holds the date in YYYYMMDD format) *****/
|
|
|
|
|
if (!(Dat_GetDateFromYYYYMMDD (&(Hld->StartDate),row[4])))
|
2023-03-23 14:09:45 +01:00
|
|
|
|
Err_WrongDateExit ();
|
|
|
|
|
|
|
|
|
|
/***** Set / get end date *****/
|
|
|
|
|
switch (Hld->HldTyp)
|
|
|
|
|
{
|
|
|
|
|
case Hld_HOLIDAY: // Only one day
|
|
|
|
|
/* Assign end date = start date */
|
|
|
|
|
Dat_AssignDate (&Hld->EndDate,&Hld->StartDate);
|
|
|
|
|
break;
|
|
|
|
|
case Hld_NON_SCHOOL_PERIOD: // One or more days
|
2023-03-23 18:06:03 +01:00
|
|
|
|
/* Get end date (row[5] holds the date in YYYYMMDD format) */
|
|
|
|
|
if (!(Dat_GetDateFromYYYYMMDD (&(Hld->EndDate),row[5])))
|
2023-03-23 14:09:45 +01:00
|
|
|
|
Err_WrongDateExit ();
|
|
|
|
|
break;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-23 18:06:03 +01:00
|
|
|
|
/***** Get the name of the holiday/non school period (row[6]) *****/
|
|
|
|
|
Str_Copy (Hld->Name,row[6],sizeof (Hld->Name) - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************ Get parameter from form with the type of a holiday *************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-03-10 00:13:55 +01:00
|
|
|
|
static Hld_HolidayType_t Hld_GetParHldType (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-01-29 21:41:08 +01:00
|
|
|
|
return (Hld_HolidayType_t)
|
2023-03-07 09:55:39 +01:00
|
|
|
|
Par_GetParUnsignedLong ("HldTyp",
|
2023-03-10 00:13:55 +01:00
|
|
|
|
0,
|
|
|
|
|
Hld_NUM_TYPES_HOLIDAY - 1,
|
|
|
|
|
(unsigned long) Hld_HOLIDAY_TYPE_DEFAULT);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Get type of holiday from string ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static Hld_HolidayType_t Hld_GetTypeOfHoliday (const char *UnsignedStr)
|
|
|
|
|
{
|
|
|
|
|
unsigned UnsignedNum;
|
|
|
|
|
|
|
|
|
|
if (sscanf (UnsignedStr,"%u",&UnsignedNum) != 1)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongHolidayExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
if (UnsignedNum >= Hld_NUM_TYPES_HOLIDAY)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongHolidayExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
return (Hld_HolidayType_t) UnsignedNum;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************************** Free list of holidays **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-13 22:04:46 +02:00
|
|
|
|
void Hld_FreeListHolidays (struct Hld_Holidays *Holidays)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-04-13 22:04:46 +02:00
|
|
|
|
if (Holidays->LstIsRead && Holidays->Lst)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Free memory used by the list of courses in degree *****/
|
2020-04-13 22:04:46 +02:00
|
|
|
|
free (Holidays->Lst);
|
|
|
|
|
Holidays->Lst = NULL;
|
|
|
|
|
Holidays->Num = 0;
|
|
|
|
|
Holidays->LstIsRead = false;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-10-30 13:28:48 +02:00
|
|
|
|
/*********************** List all holidays for edition ***********************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-13 22:04:46 +02:00
|
|
|
|
static void Hld_ListHolidaysForEdition (const struct Hld_Holidays *Holidays,
|
|
|
|
|
const struct Plc_Places *Places)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2016-11-28 14:48:16 +01:00
|
|
|
|
extern const char *Hlp_INSTITUTION_Holidays_edit;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Holidays;
|
|
|
|
|
extern const char *Txt_All_places;
|
|
|
|
|
extern const char *Txt_HOLIDAY_TYPES[Hld_NUM_TYPES_HOLIDAY];
|
|
|
|
|
unsigned NumHld;
|
2023-10-10 00:27:25 +02:00
|
|
|
|
struct Hld_Holiday *Hld;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned NumPlc;
|
2023-10-10 00:27:25 +02:00
|
|
|
|
const struct Plc_Place *Plc;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Hld_HolidayType_t HolidayType;
|
2019-11-07 01:13:21 +01:00
|
|
|
|
unsigned HolidayTypeUnsigned;
|
2022-10-19 01:04:19 +02:00
|
|
|
|
unsigned CurrentYear = Dat_GetCurrentYear ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2023-04-20 09:07:18 +02:00
|
|
|
|
/***** Begin box *****/
|
2024-01-29 09:45:28 +01:00
|
|
|
|
Box_BoxBegin (Txt_Holidays,Hld_PutIconsEditHolidays,NULL,
|
2023-04-20 10:31:14 +02:00
|
|
|
|
Hlp_INSTITUTION_Holidays_edit,Box_NOT_CLOSABLE);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2023-04-20 09:07:18 +02:00
|
|
|
|
/***** Put a form to create a new holiday *****/
|
|
|
|
|
Hld_PutFormToCreateHoliday (Places);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2023-04-20 09:07:18 +02:00
|
|
|
|
if (Places->Num)
|
2019-11-07 01:13:21 +01:00
|
|
|
|
{
|
2023-04-20 09:07:18 +02:00
|
|
|
|
/***** Begin table *****/
|
2024-01-30 00:20:11 +01:00
|
|
|
|
HTM_TABLE_Begin ("TBL_SCROLL");
|
2021-07-08 15:00:17 +02:00
|
|
|
|
|
2023-04-20 09:07:18 +02:00
|
|
|
|
/***** Write heading *****/
|
|
|
|
|
Hld_PutHeadHolidays ();
|
2021-07-08 15:00:17 +02:00
|
|
|
|
|
2023-04-20 09:07:18 +02:00
|
|
|
|
/***** Write all holidays *****/
|
|
|
|
|
for (NumHld = 0;
|
|
|
|
|
NumHld < Holidays->Num;
|
|
|
|
|
NumHld++)
|
|
|
|
|
{
|
2023-10-10 00:27:25 +02:00
|
|
|
|
Hld = &Holidays->Lst[NumHld];
|
2021-07-08 15:00:17 +02:00
|
|
|
|
|
2023-04-20 09:07:18 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
|
2023-04-20 09:07:18 +02:00
|
|
|
|
/* Put icon to remove holiday */
|
|
|
|
|
HTM_TD_Begin ("class=\"BM\"");
|
|
|
|
|
Ico_PutContextualIconToRemove (ActRemHld,NULL,
|
2023-10-10 00:27:25 +02:00
|
|
|
|
Hld_PutParHldCod,&Hld->HldCod);
|
2023-04-20 09:07:18 +02:00
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Holiday code */
|
2023-05-09 14:41:57 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"CODE DAT_%s\"",The_GetSuffix ());
|
2023-10-10 00:27:25 +02:00
|
|
|
|
HTM_TxtF ("%ld ",Hld->HldCod);
|
2023-04-20 09:07:18 +02:00
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Holiday place */
|
|
|
|
|
HTM_TD_Begin ("class=\"CM\"");
|
|
|
|
|
Frm_BeginForm (ActChgHldPlc);
|
2023-10-10 00:27:25 +02:00
|
|
|
|
ParCod_PutPar (ParCod_Hld,Hld->HldCod);
|
2023-04-20 09:07:18 +02:00
|
|
|
|
HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,NULL,
|
|
|
|
|
"name=\"PlcCod\" class=\"PLC_SEL INPUT_%s\"",
|
|
|
|
|
The_GetSuffix ());
|
|
|
|
|
HTM_OPTION (HTM_Type_STRING,"-1",
|
2023-10-10 00:27:25 +02:00
|
|
|
|
Hld->PlcCod <= 0 ? HTM_OPTION_SELECTED :
|
|
|
|
|
HTM_OPTION_UNSELECTED,
|
2023-04-20 09:07:18 +02:00
|
|
|
|
HTM_OPTION_ENABLED,
|
|
|
|
|
"%s",Txt_All_places);
|
|
|
|
|
for (NumPlc = 0;
|
|
|
|
|
NumPlc < Places->Num;
|
|
|
|
|
NumPlc++)
|
|
|
|
|
{
|
2023-10-10 00:27:25 +02:00
|
|
|
|
Plc = &Places->Lst[NumPlc];
|
|
|
|
|
HTM_OPTION (HTM_Type_LONG,&Plc->PlcCod,
|
|
|
|
|
Plc->PlcCod == Hld->PlcCod ? HTM_OPTION_SELECTED :
|
|
|
|
|
HTM_OPTION_UNSELECTED,
|
2023-04-20 09:07:18 +02:00
|
|
|
|
HTM_OPTION_ENABLED,
|
2023-10-10 00:27:25 +02:00
|
|
|
|
"%s",Plc->ShrtName);
|
2023-04-20 09:07:18 +02:00
|
|
|
|
}
|
|
|
|
|
HTM_SELECT_End ();
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Holiday type */
|
|
|
|
|
HTM_TD_Begin ("class=\"CM\"");
|
|
|
|
|
Frm_BeginForm (ActChgHldTyp);
|
2023-10-10 00:27:25 +02:00
|
|
|
|
ParCod_PutPar (ParCod_Hld,Hld->HldCod);
|
2023-04-20 09:07:18 +02:00
|
|
|
|
HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,NULL,
|
|
|
|
|
"name=\"HldTyp\" class=\"INPUT_%s\""
|
|
|
|
|
" style=\"width:62px;\"", // TODO: Use a CSS class
|
|
|
|
|
The_GetSuffix ());
|
|
|
|
|
for (HolidayType = (Hld_HolidayType_t) 0;
|
|
|
|
|
HolidayType <= (Hld_HolidayType_t) (Hld_NUM_TYPES_HOLIDAY - 1);
|
|
|
|
|
HolidayType++)
|
|
|
|
|
{
|
|
|
|
|
HolidayTypeUnsigned = (unsigned) HolidayType;
|
|
|
|
|
HTM_OPTION (HTM_Type_UNSIGNED,&HolidayTypeUnsigned,
|
2023-10-10 00:27:25 +02:00
|
|
|
|
HolidayType == Hld->HldTyp ? HTM_OPTION_SELECTED :
|
|
|
|
|
HTM_OPTION_UNSELECTED,
|
2023-04-20 09:07:18 +02:00
|
|
|
|
HTM_OPTION_ENABLED,
|
|
|
|
|
"%s",Txt_HOLIDAY_TYPES[HolidayType]);
|
|
|
|
|
}
|
|
|
|
|
HTM_SELECT_End ();
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Holiday date / Non school period start date */
|
|
|
|
|
HTM_TD_Begin ("class=\"CM\"");
|
|
|
|
|
Frm_BeginForm (ActChgHldStrDat);
|
2023-10-10 00:27:25 +02:00
|
|
|
|
ParCod_PutPar (ParCod_Hld,Hld->HldCod);
|
2023-04-20 09:07:18 +02:00
|
|
|
|
Dat_WriteFormDate (CurrentYear - 1,
|
|
|
|
|
CurrentYear + 1,
|
|
|
|
|
"Start",
|
|
|
|
|
&(Holidays->Lst[NumHld].StartDate),
|
|
|
|
|
HTM_SUBMIT_ON_CHANGE,
|
|
|
|
|
false);
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Non school period end date */
|
|
|
|
|
HTM_TD_Begin ("class=\"CM\"");
|
|
|
|
|
Frm_BeginForm (ActChgHldEndDat);
|
2023-10-10 00:27:25 +02:00
|
|
|
|
ParCod_PutPar (ParCod_Hld,Hld->HldCod);
|
2023-04-20 09:07:18 +02:00
|
|
|
|
Dat_WriteFormDate (CurrentYear - 1,
|
|
|
|
|
CurrentYear + 1,
|
|
|
|
|
"End",
|
|
|
|
|
&(Holidays->Lst[NumHld].EndDate),
|
|
|
|
|
HTM_SUBMIT_ON_CHANGE,
|
2023-10-10 00:27:25 +02:00
|
|
|
|
(Hld->HldTyp == Hld_HOLIDAY));
|
2023-04-20 09:07:18 +02:00
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Holiday name */
|
|
|
|
|
HTM_TD_Begin ("class=\"CM\"");
|
|
|
|
|
Frm_BeginForm (ActRenHld);
|
2023-10-10 00:27:25 +02:00
|
|
|
|
ParCod_PutPar (ParCod_Hld,Hld->HldCod);
|
|
|
|
|
HTM_INPUT_TEXT ("Name",Hld_MAX_CHARS_HOLIDAY_NAME,Hld->Name,
|
2023-04-20 09:07:18 +02:00
|
|
|
|
HTM_SUBMIT_ON_CHANGE,
|
|
|
|
|
"size=\"20\" class=\"INPUT_%s\"",
|
|
|
|
|
The_GetSuffix ());
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** End table *****/
|
|
|
|
|
HTM_TABLE_End ();
|
2019-11-07 01:13:21 +01:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2023-04-20 09:07:18 +02:00
|
|
|
|
/***** End box *****/
|
|
|
|
|
Box_BoxEnd ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Write parameter with code of holiday *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-03-10 00:13:55 +01:00
|
|
|
|
static void Hld_PutParHldCod (void *HldCod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-10-13 22:34:31 +02:00
|
|
|
|
if (HldCod)
|
2023-03-10 17:21:04 +01:00
|
|
|
|
ParCod_PutPar (ParCod_Hld,*((long *) HldCod));
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************************* Remove a holiday ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-04-09 13:44:57 +02:00
|
|
|
|
void Hld_RemoveHoliday (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Holiday_X_removed;
|
2019-04-09 13:44:57 +02:00
|
|
|
|
|
|
|
|
|
/***** Holiday constructor *****/
|
|
|
|
|
Hld_EditingHolidayConstructor ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get holiday code *****/
|
2023-03-10 17:21:04 +01:00
|
|
|
|
Hld_EditingHld->HldCod = ParCod_GetAndCheckPar (ParCod_Hld);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get data of the holiday from database *****/
|
2023-03-23 09:35:20 +01:00
|
|
|
|
Hld_GetHolidayDataByCod (Hld_EditingHld);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Remove holiday *****/
|
2021-09-20 19:49:00 +02:00
|
|
|
|
Hld_DB_RemoveHoliday (Hld_EditingHld->HldCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write message to show the change made *****/
|
2019-03-09 20:12:44 +01:00
|
|
|
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
|
|
|
|
Txt_Holiday_X_removed,
|
2019-04-09 13:44:57 +02:00
|
|
|
|
Hld_EditingHld->Name);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Change the place of a holiday *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-04-09 13:44:57 +02:00
|
|
|
|
void Hld_ChangeHolidayPlace (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_The_place_of_the_holiday_X_has_changed_to_Y;
|
2020-04-13 21:26:47 +02:00
|
|
|
|
struct Plc_Place NewPlace;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 13:44:57 +02:00
|
|
|
|
/***** Holiday constructor *****/
|
|
|
|
|
Hld_EditingHolidayConstructor ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get parameters from form *****/
|
|
|
|
|
/* Get the code of the holiday */
|
2023-03-10 17:21:04 +01:00
|
|
|
|
Hld_EditingHld->HldCod = ParCod_GetAndCheckPar (ParCod_Hld);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get the new place for the holiday */
|
2023-03-08 14:45:02 +01:00
|
|
|
|
// <0 (place unspecified/all places) and 0 (another place) are allowed here
|
2023-03-10 17:21:04 +01:00
|
|
|
|
NewPlace.PlcCod = ParCod_GetPar (ParCod_Plc);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2023-04-13 14:25:52 +02:00
|
|
|
|
/***** Get place and holiday data from database *****/
|
2023-03-23 09:35:20 +01:00
|
|
|
|
Plc_GetPlaceDataByCod (&NewPlace);
|
|
|
|
|
Hld_GetHolidayDataByCod (Hld_EditingHld);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Update the place in database *****/
|
2021-09-20 19:49:00 +02:00
|
|
|
|
Hld_DB_ChangePlace (Hld_EditingHld->HldCod,NewPlace.PlcCod);
|
2019-04-09 13:44:57 +02:00
|
|
|
|
Hld_EditingHld->PlcCod = NewPlace.PlcCod;
|
|
|
|
|
Str_Copy (Hld_EditingHld->PlaceFullName,NewPlace.FullName,
|
2021-02-15 16:25:55 +01:00
|
|
|
|
sizeof (Hld_EditingHld->PlaceFullName) - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write message to show the change made *****/
|
2019-03-09 20:12:44 +01:00
|
|
|
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
|
|
|
|
Txt_The_place_of_the_holiday_X_has_changed_to_Y,
|
2019-04-09 13:44:57 +02:00
|
|
|
|
Hld_EditingHld->Name,NewPlace.FullName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Change the type of a holiday **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-04-09 13:44:57 +02:00
|
|
|
|
void Hld_ChangeHolidayType (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_The_type_of_the_holiday_X_has_changed;
|
|
|
|
|
|
2019-04-09 13:44:57 +02:00
|
|
|
|
/***** Holiday constructor *****/
|
|
|
|
|
Hld_EditingHolidayConstructor ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get the code of the holiday *****/
|
2023-03-10 17:21:04 +01:00
|
|
|
|
Hld_EditingHld->HldCod = ParCod_GetAndCheckPar (ParCod_Hld);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get from the database the data of the holiday *****/
|
2023-03-23 09:35:20 +01:00
|
|
|
|
Hld_GetHolidayDataByCod (Hld_EditingHld);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get the new type for the holiday *****/
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Hld_EditingHld->HldTyp = Hld_GetParHldType ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Update holiday/no school period in database *****/
|
2019-04-09 13:44:57 +02:00
|
|
|
|
Dat_AssignDate (&Hld_EditingHld->EndDate,&Hld_EditingHld->StartDate);
|
2021-09-20 19:49:00 +02:00
|
|
|
|
Hld_DB_ChangeType (Hld_EditingHld->HldCod,Hld_EditingHld->HldTyp);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write message to show the change made *****/
|
2019-03-09 20:12:44 +01:00
|
|
|
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
|
|
|
|
Txt_The_type_of_the_holiday_X_has_changed,
|
2019-04-09 13:44:57 +02:00
|
|
|
|
Hld_EditingHld->Name);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*** Change the date of a holiday / the start date of a non school period ****/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-04-09 13:44:57 +02:00
|
|
|
|
void Hld_ChangeStartDate (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-12-15 20:02:34 +01:00
|
|
|
|
Hld_ChangeDate (Hld_START_DATE);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Change the end date of a non school period ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-04-09 13:44:57 +02:00
|
|
|
|
void Hld_ChangeEndDate (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-12-15 20:02:34 +01:00
|
|
|
|
Hld_ChangeDate (Hld_END_DATE);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************** Change the start/end date of a holiday *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Hld_ChangeDate (Hld_StartOrEndDate_t StartOrEndDate)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_The_date_of_the_holiday_X_has_changed_to_Y;
|
2021-09-20 19:49:00 +02:00
|
|
|
|
struct Dat_Date NewDate;
|
|
|
|
|
struct Dat_Date *PtrDate = NULL; // Initialized to avoid warning
|
2016-12-05 23:13:58 +01:00
|
|
|
|
const char *StrStartOrEndDate = NULL; // Initialized to avoid warning
|
2017-05-05 02:03:28 +02:00
|
|
|
|
char StrDate[Cns_MAX_BYTES_DATE + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 13:44:57 +02:00
|
|
|
|
/***** Holiday constructor *****/
|
|
|
|
|
Hld_EditingHolidayConstructor ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get the code of the holiday *****/
|
2023-03-10 17:21:04 +01:00
|
|
|
|
Hld_EditingHld->HldCod = ParCod_GetAndCheckPar (ParCod_Hld);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get from the database the data of the holiday *****/
|
2023-03-23 09:35:20 +01:00
|
|
|
|
Hld_GetHolidayDataByCod (Hld_EditingHld);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get the new date for the holiday *****/
|
|
|
|
|
switch (StartOrEndDate)
|
|
|
|
|
{
|
2019-12-15 20:02:34 +01:00
|
|
|
|
case Hld_START_DATE:
|
2014-12-01 23:55:08 +01:00
|
|
|
|
StrStartOrEndDate = "StartDate";
|
2019-04-09 13:44:57 +02:00
|
|
|
|
PtrDate = &Hld_EditingHld->StartDate;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Dat_GetDateFromForm ("StartDay","StartMonth","StartYear",
|
|
|
|
|
&(NewDate.Day),&(NewDate.Month),&(NewDate.Year));
|
2016-11-28 14:48:16 +01:00
|
|
|
|
if (NewDate.Day == 0 ||
|
|
|
|
|
NewDate.Month == 0 ||
|
|
|
|
|
NewDate.Year == 0)
|
2022-10-19 01:04:19 +02:00
|
|
|
|
Dat_AssignDate (&NewDate,Dat_GetCurrentDate ());
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2019-12-15 20:02:34 +01:00
|
|
|
|
case Hld_END_DATE:
|
2014-12-01 23:55:08 +01:00
|
|
|
|
StrStartOrEndDate = "EndDate";
|
2019-04-09 13:44:57 +02:00
|
|
|
|
PtrDate = &Hld_EditingHld->EndDate;
|
|
|
|
|
switch (Hld_EditingHld->HldTyp)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
case Hld_HOLIDAY:
|
2019-04-09 13:44:57 +02:00
|
|
|
|
Dat_AssignDate (&NewDate,&Hld_EditingHld->StartDate);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
case Hld_NON_SCHOOL_PERIOD:
|
|
|
|
|
Dat_GetDateFromForm ("EndDay","EndMonth","EndYear",
|
|
|
|
|
&(NewDate.Day),&(NewDate.Month),&(NewDate.Year));
|
2016-11-28 14:48:16 +01:00
|
|
|
|
if (NewDate.Day == 0 ||
|
|
|
|
|
NewDate.Month == 0 ||
|
|
|
|
|
NewDate.Year == 0)
|
2022-10-19 01:04:19 +02:00
|
|
|
|
Dat_AssignDate (&NewDate,Dat_GetCurrentDate ());
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Update the date in database *****/
|
2021-09-20 19:49:00 +02:00
|
|
|
|
Hld_DB_ChangeDate (Hld_EditingHld->HldCod,StrStartOrEndDate,&NewDate);
|
2017-03-26 01:44:27 +01:00
|
|
|
|
Dat_AssignDate (PtrDate,&NewDate);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write message to show the change made *****/
|
2017-05-05 02:03:28 +02:00
|
|
|
|
Dat_ConvDateToDateStr (&NewDate,StrDate);
|
2019-03-09 20:12:44 +01:00
|
|
|
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
|
|
|
|
Txt_The_date_of_the_holiday_X_has_changed_to_Y,
|
2019-04-09 13:44:57 +02:00
|
|
|
|
Hld_EditingHld->Name,StrDate);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Change the name of a degree ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-04-09 13:44:57 +02:00
|
|
|
|
void Hld_RenameHoliday (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2022-05-12 22:16:39 +02:00
|
|
|
|
extern const char *Txt_The_holiday_X_has_been_renamed_as_Y;
|
|
|
|
|
extern const char *Txt_The_name_X_has_not_changed;
|
2017-03-07 19:55:29 +01:00
|
|
|
|
char NewHldName[Hld_MAX_BYTES_HOLIDAY_NAME + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 13:44:57 +02:00
|
|
|
|
/***** Holiday constructor *****/
|
|
|
|
|
Hld_EditingHolidayConstructor ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get parameters from form *****/
|
|
|
|
|
/* Get the code of the holiday */
|
2023-03-10 17:21:04 +01:00
|
|
|
|
Hld_EditingHld->HldCod = ParCod_GetAndCheckPar (ParCod_Hld);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get the new name for the holiday */
|
2023-03-07 09:55:39 +01:00
|
|
|
|
Par_GetParText ("Name",NewHldName,Hld_MAX_BYTES_HOLIDAY_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get from the database the old names of the holiday *****/
|
2023-03-23 09:35:20 +01:00
|
|
|
|
Hld_GetHolidayDataByCod (Hld_EditingHld);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Check if new name is empty *****/
|
2019-12-20 00:30:54 +01:00
|
|
|
|
if (NewHldName[0])
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-01-02 15:10:51 +01:00
|
|
|
|
/***** Check if old and new names are the same
|
|
|
|
|
(this happens when return is pressed without changes) *****/
|
2019-04-09 13:44:57 +02:00
|
|
|
|
if (strcmp (Hld_EditingHld->Name,NewHldName)) // Different names
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** If degree was in database... *****/
|
|
|
|
|
/* Update the table changing old name by new name */
|
2021-09-20 19:49:00 +02:00
|
|
|
|
Hld_DB_ChangeName (Hld_EditingHld->HldCod,NewHldName);
|
2019-04-09 13:44:57 +02:00
|
|
|
|
Str_Copy (Hld_EditingHld->Name,NewHldName,
|
2021-02-15 16:25:55 +01:00
|
|
|
|
sizeof (Hld_EditingHld->Name) - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write message to show the change made *****/
|
2019-03-09 20:12:44 +01:00
|
|
|
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
2022-05-12 22:16:39 +02:00
|
|
|
|
Txt_The_holiday_X_has_been_renamed_as_Y,
|
2019-04-09 13:44:57 +02:00
|
|
|
|
Hld_EditingHld->Name,NewHldName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else // The same name
|
2019-03-09 20:12:44 +01:00
|
|
|
|
Ale_CreateAlert (Ale_INFO,NULL,
|
2022-05-12 22:16:39 +02:00
|
|
|
|
Txt_The_name_X_has_not_changed,Hld_EditingHld->Name);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2019-12-20 00:30:54 +01:00
|
|
|
|
else
|
|
|
|
|
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
2017-03-26 01:44:27 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-04-09 13:44:57 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******** Show alerts after changing a holiday and continue editing **********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Hld_ContEditAfterChgHld (void)
|
2017-03-26 01:44:27 +01:00
|
|
|
|
{
|
2019-04-09 13:44:57 +02:00
|
|
|
|
/***** Write message to show the change made *****/
|
2019-03-09 20:12:44 +01:00
|
|
|
|
Ale_ShowAlerts (NULL);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Show the form again *****/
|
2019-04-09 13:44:57 +02:00
|
|
|
|
Hld_EditHolidaysInternal ();
|
|
|
|
|
|
|
|
|
|
/***** Holiday destructor *****/
|
|
|
|
|
Hld_EditingHolidayDestructor ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Put a form to create a new holiday ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-13 21:26:47 +02:00
|
|
|
|
static void Hld_PutFormToCreateHoliday (const struct Plc_Places *Places)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_All_places;
|
|
|
|
|
extern const char *Txt_HOLIDAY_TYPES[Hld_NUM_TYPES_HOLIDAY];
|
|
|
|
|
unsigned NumPlc;
|
2023-10-10 00:27:25 +02:00
|
|
|
|
const struct Plc_Place *Plc;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Hld_HolidayType_t HolidayType;
|
2019-11-07 01:13:21 +01:00
|
|
|
|
unsigned HolidayTypeUnsigned;
|
2022-10-19 01:04:19 +02:00
|
|
|
|
unsigned CurrentYear = Dat_GetCurrentYear ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2023-05-11 18:35:16 +02:00
|
|
|
|
/***** Begin form to create *****/
|
2024-01-30 00:20:11 +01:00
|
|
|
|
Frm_BeginFormTable (ActNewHld,NULL,NULL,NULL,"TBL_SCROLL");
|
2023-05-11 18:35:16 +02:00
|
|
|
|
|
|
|
|
|
/***** Write heading *****/
|
|
|
|
|
Hld_PutHeadHolidays ();
|
|
|
|
|
|
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
|
|
|
|
|
/***** Column to remove holiday, disabled here *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"BM\"");
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Holiday code *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"CODE\"");
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Holiday place *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"CM\"");
|
|
|
|
|
HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE,NULL,
|
|
|
|
|
"name=\"PlcCod\" class=\"PLC_SEL INPUT_%s\"",
|
|
|
|
|
The_GetSuffix ());
|
|
|
|
|
HTM_OPTION (HTM_Type_STRING,"-1",
|
2023-05-18 12:54:43 +02:00
|
|
|
|
Hld_EditingHld->PlcCod <= 0 ? HTM_OPTION_SELECTED :
|
|
|
|
|
HTM_OPTION_UNSELECTED,
|
2023-05-11 18:35:16 +02:00
|
|
|
|
HTM_OPTION_ENABLED,
|
|
|
|
|
"%s",Txt_All_places);
|
|
|
|
|
for (NumPlc = 0;
|
|
|
|
|
NumPlc < Places->Num;
|
|
|
|
|
NumPlc++)
|
|
|
|
|
{
|
2023-10-10 00:27:25 +02:00
|
|
|
|
Plc = &Places->Lst[NumPlc];
|
|
|
|
|
HTM_OPTION (HTM_Type_LONG,&Plc->PlcCod,
|
|
|
|
|
Plc->PlcCod == Hld_EditingHld->PlcCod ? HTM_OPTION_SELECTED :
|
|
|
|
|
HTM_OPTION_UNSELECTED,
|
2023-05-11 18:35:16 +02:00
|
|
|
|
HTM_OPTION_ENABLED,
|
2023-10-10 00:27:25 +02:00
|
|
|
|
"%s",Plc->ShrtName);
|
2023-05-11 18:35:16 +02:00
|
|
|
|
}
|
|
|
|
|
HTM_SELECT_End ();
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Holiday type *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"CM\"");
|
|
|
|
|
HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE,NULL,
|
|
|
|
|
"name=\"HldTyp\" class=\"INPUT_%s\""
|
|
|
|
|
" style=\"width:62px;\"", // TODO: Use a CSS class
|
|
|
|
|
The_GetSuffix ());
|
|
|
|
|
for (HolidayType = (Hld_HolidayType_t) 0;
|
|
|
|
|
HolidayType <= (Hld_HolidayType_t) (Hld_NUM_TYPES_HOLIDAY - 1);
|
|
|
|
|
HolidayType++)
|
|
|
|
|
{
|
|
|
|
|
HolidayTypeUnsigned = (unsigned) HolidayType;
|
|
|
|
|
HTM_OPTION (HTM_Type_UNSIGNED,&HolidayTypeUnsigned,
|
2023-05-18 12:54:43 +02:00
|
|
|
|
HolidayType == Hld_EditingHld->HldTyp ? HTM_OPTION_SELECTED :
|
|
|
|
|
HTM_OPTION_UNSELECTED,
|
2023-05-11 18:35:16 +02:00
|
|
|
|
HTM_OPTION_ENABLED,
|
|
|
|
|
"%s",Txt_HOLIDAY_TYPES[HolidayType]);
|
|
|
|
|
}
|
|
|
|
|
HTM_SELECT_End ();
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Holiday date / Non school period start date *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"CM\"");
|
|
|
|
|
Dat_WriteFormDate (CurrentYear - 1,
|
|
|
|
|
CurrentYear + 1,
|
|
|
|
|
"Start",
|
|
|
|
|
&Hld_EditingHld->StartDate,
|
|
|
|
|
HTM_DONT_SUBMIT_ON_CHANGE,
|
|
|
|
|
false);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Non school period end date *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"CM\"");
|
|
|
|
|
Dat_WriteFormDate (CurrentYear - 1,
|
|
|
|
|
CurrentYear + 1,
|
|
|
|
|
"End",
|
|
|
|
|
&Hld_EditingHld->EndDate,
|
|
|
|
|
HTM_DONT_SUBMIT_ON_CHANGE,
|
|
|
|
|
false);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Holiday name *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"CM\"");
|
|
|
|
|
HTM_INPUT_TEXT ("Name",Hld_MAX_CHARS_HOLIDAY_NAME,Hld_EditingHld->Name,
|
|
|
|
|
HTM_DONT_SUBMIT_ON_CHANGE,
|
|
|
|
|
"size=\"20\" class=\"INPUT_%s\""
|
|
|
|
|
" required=\"required\"",
|
|
|
|
|
The_GetSuffix ());
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
HTM_TD_Empty (1);
|
|
|
|
|
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
|
|
|
|
|
/***** End form to create *****/
|
|
|
|
|
Frm_EndFormTable (Btn_CREATE_BUTTON);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Write header with fields of a holiday *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Hld_PutHeadHolidays (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Code;
|
|
|
|
|
extern const char *Txt_Place;
|
|
|
|
|
extern const char *Txt_Type;
|
2016-12-15 00:39:52 +01:00
|
|
|
|
extern const char *Txt_START_END_TIME[Dat_NUM_START_END_TIME];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Holiday;
|
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2022-01-02 15:17:30 +01:00
|
|
|
|
HTM_TH_Span (NULL ,HTM_HEAD_CENTER,1,1,"BT");
|
|
|
|
|
HTM_TH (Txt_Code ,HTM_HEAD_RIGHT);
|
2024-01-30 00:20:11 +01:00
|
|
|
|
HTM_TH (Txt_Place ,HTM_HEAD_CENTER);
|
|
|
|
|
HTM_TH (Txt_Type ,HTM_HEAD_CENTER);
|
|
|
|
|
HTM_TH (Txt_START_END_TIME[Dat_STR_TIME],HTM_HEAD_CENTER);
|
|
|
|
|
HTM_TH (Txt_START_END_TIME[Dat_END_TIME],HTM_HEAD_CENTER);
|
|
|
|
|
HTM_TH (Txt_Holiday ,HTM_HEAD_CENTER);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Receive form to create a new holiday ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-05-05 21:49:00 +02:00
|
|
|
|
void Hld_ReceiveFormNewHoliday (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-03-26 00:20:34 +01:00
|
|
|
|
extern const char *Txt_Created_new_holiday_X;
|
2022-06-18 19:50:40 +02:00
|
|
|
|
extern const char *Txt_You_must_specify_the_name;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 13:44:57 +02:00
|
|
|
|
/***** Holiday constructor *****/
|
|
|
|
|
Hld_EditingHolidayConstructor ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get place code *****/
|
2023-03-08 14:45:02 +01:00
|
|
|
|
// <0 (place unspecified/all places) and 0 (another place) are allowed here
|
2023-03-10 17:21:04 +01:00
|
|
|
|
Hld_EditingHld->PlcCod = ParCod_GetPar (ParCod_Plc);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get the type of holiday *****/
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Hld_EditingHld->HldTyp = Hld_GetParHldType ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get start date *****/
|
|
|
|
|
Dat_GetDateFromForm ("StartDay","StartMonth","StartYear",
|
2019-04-09 13:44:57 +02:00
|
|
|
|
&Hld_EditingHld->StartDate.Day,
|
|
|
|
|
&Hld_EditingHld->StartDate.Month,
|
|
|
|
|
&Hld_EditingHld->StartDate.Year);
|
|
|
|
|
if (Hld_EditingHld->StartDate.Day == 0 ||
|
|
|
|
|
Hld_EditingHld->StartDate.Month == 0 ||
|
|
|
|
|
Hld_EditingHld->StartDate.Year == 0)
|
2022-10-19 01:04:19 +02:00
|
|
|
|
Dat_AssignDate (&Hld_EditingHld->StartDate,Dat_GetCurrentDate ());
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-11-28 14:48:16 +01:00
|
|
|
|
/***** Set end date *****/
|
2019-04-09 13:44:57 +02:00
|
|
|
|
switch (Hld_EditingHld->HldTyp)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
case Hld_HOLIDAY:
|
2016-11-28 14:48:16 +01:00
|
|
|
|
/* Set end date = start date (ignore end date from form) */
|
2019-04-09 13:44:57 +02:00
|
|
|
|
Dat_AssignDate (&Hld_EditingHld->EndDate,&Hld_EditingHld->StartDate);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
case Hld_NON_SCHOOL_PERIOD:
|
2016-11-28 14:48:16 +01:00
|
|
|
|
/* Get end date from form */
|
|
|
|
|
Dat_GetDateFromForm ("EndDay","EndMonth","EndYear",
|
2019-04-09 13:44:57 +02:00
|
|
|
|
&Hld_EditingHld->EndDate.Day,
|
|
|
|
|
&Hld_EditingHld->EndDate.Month,
|
|
|
|
|
&Hld_EditingHld->EndDate.Year);
|
|
|
|
|
if (Hld_EditingHld->EndDate.Day == 0 ||
|
|
|
|
|
Hld_EditingHld->EndDate.Month == 0 ||
|
|
|
|
|
Hld_EditingHld->EndDate.Year == 0)
|
2022-10-19 01:04:19 +02:00
|
|
|
|
Dat_AssignDate (&Hld_EditingHld->EndDate,Dat_GetCurrentDate ());
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-28 14:48:16 +01:00
|
|
|
|
/***** Get holiday name *****/
|
2023-03-07 09:55:39 +01:00
|
|
|
|
Par_GetParText ("Name",Hld_EditingHld->Name,Hld_MAX_BYTES_HOLIDAY_NAME);
|
2016-11-28 14:48:16 +01:00
|
|
|
|
|
2017-03-26 00:20:34 +01:00
|
|
|
|
/***** Create the new holiday or set warning message *****/
|
2019-04-09 13:44:57 +02:00
|
|
|
|
if (Hld_EditingHld->Name[0]) // If there's a holiday name
|
2017-03-26 00:20:34 +01:00
|
|
|
|
{
|
|
|
|
|
/* Create the new holiday */
|
2021-07-08 15:00:17 +02:00
|
|
|
|
Hld_DB_CreateHoliday (Hld_EditingHld);
|
2017-03-26 00:20:34 +01:00
|
|
|
|
|
|
|
|
|
/* Success message */
|
2019-03-09 20:12:44 +01:00
|
|
|
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
|
|
|
|
Txt_Created_new_holiday_X,
|
2019-04-09 13:44:57 +02:00
|
|
|
|
Hld_EditingHld->Name);
|
2017-03-26 00:20:34 +01:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else // If there is not a holiday name
|
2017-03-26 00:20:34 +01:00
|
|
|
|
/* Error message */
|
2019-03-09 20:12:44 +01:00
|
|
|
|
Ale_CreateAlert (Ale_WARNING,NULL,
|
2022-06-18 19:50:40 +02:00
|
|
|
|
Txt_You_must_specify_the_name);
|
2017-03-26 00:20:34 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-04-09 13:44:57 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Holiday constructor/destructor ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Hld_EditingHolidayConstructor (void)
|
|
|
|
|
{
|
|
|
|
|
/***** Pointer must be NULL *****/
|
|
|
|
|
if (Hld_EditingHld != NULL)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongHolidayExit ();
|
2019-04-09 13:44:57 +02:00
|
|
|
|
|
|
|
|
|
/***** Allocate memory for holiday *****/
|
2021-02-15 16:25:55 +01:00
|
|
|
|
if ((Hld_EditingHld = malloc (sizeof (*Hld_EditingHld))) == NULL)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
2019-04-09 13:44:57 +02:00
|
|
|
|
|
|
|
|
|
/***** Reset place *****/
|
|
|
|
|
Hld_EditingHld->HldCod = -1L;
|
|
|
|
|
Hld_EditingHld->PlcCod = -1L;
|
|
|
|
|
Hld_EditingHld->PlaceFullName[0] = '\0';
|
|
|
|
|
Hld_EditingHld->HldTyp = Hld_HOLIDAY;
|
2022-10-19 01:04:19 +02:00
|
|
|
|
Hld_EditingHld->StartDate.Year = Hld_EditingHld->EndDate.Year = Dat_GetCurrentYear ();
|
|
|
|
|
Hld_EditingHld->StartDate.Month = Hld_EditingHld->EndDate.Month = Dat_GetCurrentMonth ();
|
|
|
|
|
Hld_EditingHld->StartDate.Day = Hld_EditingHld->EndDate.Day = Dat_GetCurrentDay ();
|
2019-04-09 13:44:57 +02:00
|
|
|
|
Hld_EditingHld->Name[0] = '\0';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void Hld_EditingHolidayDestructor (void)
|
|
|
|
|
{
|
|
|
|
|
/***** Free memory used for holiday *****/
|
|
|
|
|
if (Hld_EditingHld != NULL)
|
|
|
|
|
{
|
2019-11-06 19:45:20 +01:00
|
|
|
|
free (Hld_EditingHld);
|
2019-04-09 13:44:57 +02:00
|
|
|
|
Hld_EditingHld = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|