2014-12-01 23:55:08 +01:00
|
|
|
|
// swad_attendance.c: control of attendance
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
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.
|
2020-01-01 14:53:57 +01:00
|
|
|
|
Copyright (C) 1999-2020 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-11-01 22:53:39 +01:00
|
|
|
|
#define _GNU_SOURCE // For asprintf
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include <linux/limits.h> // For PATH_MAX
|
|
|
|
|
#include <mysql/mysql.h> // To access MySQL databases
|
2019-12-29 12:39:00 +01:00
|
|
|
|
#include <stddef.h> // For NULL
|
2019-11-01 22:53:39 +01:00
|
|
|
|
#include <stdio.h> // For asprintf
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include <stdlib.h> // For calloc
|
|
|
|
|
#include <string.h> // For string functions
|
|
|
|
|
|
|
|
|
|
#include "swad_attendance.h"
|
2017-06-10 21:38:10 +02:00
|
|
|
|
#include "swad_box.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_database.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_group.h"
|
2019-10-23 19:05:05 +02:00
|
|
|
|
#include "swad_HTML.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_ID.h"
|
|
|
|
|
#include "swad_pagination.h"
|
|
|
|
|
#include "swad_parameter.h"
|
|
|
|
|
#include "swad_photo.h"
|
|
|
|
|
#include "swad_QR.h"
|
2019-03-26 11:53:21 +01:00
|
|
|
|
#include "swad_setting.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** External global variables from others modules ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************************** Private constants ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2018-10-18 16:56:07 +02:00
|
|
|
|
#define Att_ATTENDANCE_TABLE_ID "att_table"
|
|
|
|
|
#define Att_ATTENDANCE_DETAILS_ID "att_details"
|
2018-10-18 11:29:02 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************************** Private types ******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-11-13 01:27:44 +01:00
|
|
|
|
typedef enum
|
|
|
|
|
{
|
2019-11-14 17:53:50 +01:00
|
|
|
|
Att_VIEW_ONLY_ME, // View only me
|
|
|
|
|
Att_VIEW_SEL_USR, // View selected users
|
|
|
|
|
Att_PRNT_ONLY_ME, // Print only me
|
|
|
|
|
Att_PRNT_SEL_USR, // Print selected users
|
2015-11-13 01:27:44 +01:00
|
|
|
|
} Att_TypeOfView_t;
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************************** Private variables ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************************** Private prototypes ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_ResetEvents (struct Att_Events *Events);
|
|
|
|
|
|
|
|
|
|
static void Att_ShowAllAttEvents (struct Att_Events *Events);
|
|
|
|
|
static void Att_ParamsWhichGroupsToShow (void *Events);
|
|
|
|
|
static void Att_PutIconsInListOfAttEvents (void *Events);
|
|
|
|
|
static void Att_PutIconToCreateNewAttEvent (struct Att_Events *Events);
|
2020-04-08 13:40:21 +02:00
|
|
|
|
static void Att_PutButtonToCreateNewAttEvent (struct Att_Events *Events);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_PutParamsToCreateNewAttEvent (void *Events);
|
|
|
|
|
static void Att_PutParamsToListUsrsAttendance (void *Events);
|
2019-12-06 22:49:45 +01:00
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_ShowOneAttEvent (struct Att_Events *Events,
|
|
|
|
|
struct Att_Event *Event,
|
|
|
|
|
bool ShowOnlyThisAttEventComplete);
|
|
|
|
|
static void Att_WriteAttEventAuthor (struct Att_Event *Event);
|
|
|
|
|
static Dat_StartEndTime_t Att_GetParamAttOrder (void);
|
2015-04-02 18:39:49 +02:00
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_PutFormsToRemEditOneAttEvent (struct Att_Events *Events,
|
|
|
|
|
const struct Att_Event *Event,
|
2019-04-20 21:11:44 +02:00
|
|
|
|
const char *Anchor);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_PutParams (void *Events);
|
|
|
|
|
static void Att_GetListAttEvents (struct Att_Events *Events,
|
|
|
|
|
Att_OrderNewestOldest_t OrderNewestOldest);
|
|
|
|
|
static void Att_GetDataOfAttEventByCodAndCheckCrs (struct Att_Event *Event);
|
|
|
|
|
static void Att_ResetAttendanceEvent (struct Att_Event *Event);
|
|
|
|
|
static void Att_FreeListAttEvents (struct Att_Events *Events);
|
2019-02-15 21:09:18 +01:00
|
|
|
|
static void Att_GetAttEventDescriptionFromDB (long AttCod,char Description[Cns_MAX_BYTES_TEXT + 1]);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
|
|
|
|
|
static void Att_PutParamSelectedAttCod (void *Events);
|
|
|
|
|
static void Att_PutParamAttCod (long AttCod);
|
|
|
|
|
static long Att_GetParamAttCod (void);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static bool Att_CheckIfSimilarAttEventExists (const char *Field,const char *Value,long AttCod);
|
|
|
|
|
static void Att_ShowLstGrpsToEditAttEvent (long AttCod);
|
|
|
|
|
static void Att_RemoveAllTheGrpsAssociatedToAnAttEvent (long AttCod);
|
|
|
|
|
static void Att_CreateGrps (long AttCod);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_GetAndWriteNamesOfGrpsAssociatedToAttEvent (struct Att_Event *Event);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-09-06 18:29:13 +02:00
|
|
|
|
static void Att_RemoveAllUsrsFromAnAttEvent (long AttCod);
|
|
|
|
|
static void Att_RemoveAttEventFromCurrentCrs (long AttCod);
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_ShowEvent (struct Att_Events *Events);
|
|
|
|
|
|
|
|
|
|
static void Att_ListAttOnlyMeAsStudent (struct Att_Event *Event);
|
|
|
|
|
static void Att_ListAttStudents (struct Att_Events *Events,
|
|
|
|
|
struct Att_Event *Event);
|
2019-04-11 23:15:40 +02:00
|
|
|
|
static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr,
|
2017-05-20 12:04:12 +02:00
|
|
|
|
struct UsrData *UsrDat,
|
2020-04-06 16:00:06 +02:00
|
|
|
|
struct Att_Event *Event);
|
|
|
|
|
static void Att_PutLinkAttEvent (struct Att_Event *AttEvent,
|
2018-12-03 19:49:54 +01:00
|
|
|
|
const char *Title,const char *Txt,
|
2019-11-18 09:35:23 +01:00
|
|
|
|
const char *Class);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static void Att_PutParamsCodGrps (long AttCod);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_GetNumStdsTotalWhoAreInAttEvent (struct Att_Event *Event);
|
2019-11-13 21:31:06 +01:00
|
|
|
|
static unsigned Att_GetNumUsrsFromAListWhoAreInAttEvent (long AttCod,
|
|
|
|
|
long LstSelectedUsrCods[],
|
|
|
|
|
unsigned NumUsrsInList);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static bool Att_CheckIfUsrIsInTableAttUsr (long AttCod,long UsrCod,bool *Present);
|
|
|
|
|
static bool Att_CheckIfUsrIsPresentInAttEvent (long AttCod,long UsrCod);
|
2017-01-17 03:10:43 +01:00
|
|
|
|
static bool Att_CheckIfUsrIsPresentInAttEventAndGetComments (long AttCod,long UsrCod,
|
|
|
|
|
char CommentStd[Cns_MAX_BYTES_TEXT + 1],
|
|
|
|
|
char CommentTch[Cns_MAX_BYTES_TEXT + 1]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static void Att_RegUsrInAttEventChangingComments (long AttCod,long UsrCod,bool Present,
|
|
|
|
|
const char *CommentStd,const char *CommentTch);
|
|
|
|
|
static void Att_RemoveUsrFromAttEvent (long AttCod,long UsrCod);
|
|
|
|
|
|
2020-04-13 16:39:15 +02:00
|
|
|
|
static void Att_ReqListOrPrintUsrsAttendanceCrs (void *TypeOfView);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_ListOrPrintMyAttendanceCrs (Att_TypeOfView_t TypeOfView);
|
|
|
|
|
static void Att_GetUsrsAndListOrPrintAttendanceCrs (Att_TypeOfView_t TypeOfView);
|
|
|
|
|
static void Att_ListOrPrintUsrsAttendanceCrs (void *TypeOfView);
|
2015-11-13 01:27:44 +01:00
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_GetListSelectedAttCods (struct Att_Events *Events);
|
2015-04-02 18:39:49 +02:00
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_PutIconsMyAttList (void *Events);
|
|
|
|
|
static void Att_PutFormToPrintMyListParams (void *Events);
|
|
|
|
|
static void Att_PutIconsStdsAttList (void *Events);
|
|
|
|
|
static void Att_PutParamsToPrintStdsList (void *Events);
|
2015-04-02 18:39:49 +02:00
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_PutButtonToShowDetails (const struct Att_Events *Events);
|
|
|
|
|
static void Att_ListEventsToSelect (const struct Att_Events *Events,
|
|
|
|
|
Att_TypeOfView_t TypeOfView);
|
2020-04-08 03:41:05 +02:00
|
|
|
|
static void Att_PutIconToViewAttEvents (__attribute__((unused)) void *Args);
|
|
|
|
|
static void Att_PutIconToEditAttEvents (__attribute__((unused)) void *Args);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_ListUsrsAttendanceTable (const struct Att_Events *Events,
|
|
|
|
|
Att_TypeOfView_t TypeOfView,
|
|
|
|
|
unsigned NumUsrsInList,
|
2016-03-20 02:08:13 +01:00
|
|
|
|
long *LstSelectedUsrCods);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_WriteTableHeadSeveralAttEvents (const struct Att_Events *Events);
|
|
|
|
|
static void Att_WriteRowUsrSeveralAttEvents (const struct Att_Events *Events,
|
|
|
|
|
unsigned NumUsr,struct UsrData *UsrDat);
|
2019-02-13 21:24:54 +01:00
|
|
|
|
static void Att_PutCheckOrCross (bool Present);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_ListStdsWithAttEventsDetails (const struct Att_Events *Events,
|
|
|
|
|
unsigned NumUsrsInList,
|
2016-11-27 23:08:29 +01:00
|
|
|
|
long *LstSelectedUsrCods);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_ListAttEventsForAStd (const struct Att_Events *Events,
|
|
|
|
|
unsigned NumUsr,struct UsrData *UsrDat);
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Reset attendance events **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Att_ResetEvents (struct Att_Events *Events)
|
|
|
|
|
{
|
|
|
|
|
Events->LstIsRead = false; // List is not read from database
|
|
|
|
|
Events->Num = 0; // Number of attendance events
|
|
|
|
|
Events->Lst = NULL; // List of attendance events
|
|
|
|
|
Events->SelectedOrder = Att_ORDER_DEFAULT;
|
|
|
|
|
Events->AttCod = -1L;
|
|
|
|
|
Events->ShowDetails = false;
|
|
|
|
|
Events->StrAttCodsSelected = NULL;
|
|
|
|
|
Events->CurrentPage = 0;
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** List all the attendance events ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Att_SeeAttEvents (void)
|
|
|
|
|
{
|
2020-04-06 16:00:06 +02:00
|
|
|
|
struct Att_Events Events;
|
|
|
|
|
|
|
|
|
|
/***** Reset attendance events *****/
|
|
|
|
|
Att_ResetEvents (&Events);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get parameters *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Events.SelectedOrder = Att_GetParamAttOrder ();
|
2020-03-27 14:56:54 +01:00
|
|
|
|
Grp_GetParamWhichGroups ();
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Events.CurrentPage = Pag_GetParamPagNum (Pag_ATT_EVENTS);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2015-11-13 01:27:44 +01:00
|
|
|
|
/***** Get list of attendance events *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_GetListAttEvents (&Events,Att_NEWEST_FIRST);
|
2015-11-13 01:27:44 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Show all the attendance events *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_ShowAllAttEvents (&Events);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Show all the attendance events ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_ShowAllAttEvents (struct Att_Events *Events)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2016-11-13 21:08:14 +01:00
|
|
|
|
extern const char *Hlp_USERS_Attendance;
|
2015-01-02 12:57:26 +01:00
|
|
|
|
extern const char *Txt_Events;
|
2016-12-15 00:39:52 +01:00
|
|
|
|
extern const char *Txt_START_END_TIME_HELP[Dat_NUM_START_END_TIME];
|
|
|
|
|
extern const char *Txt_START_END_TIME[Dat_NUM_START_END_TIME];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Event;
|
|
|
|
|
extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
2016-03-20 00:33:27 +01:00
|
|
|
|
extern const char *Txt_No_events;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
struct Pagination Pagination;
|
2020-03-27 14:56:54 +01:00
|
|
|
|
Dat_StartEndTime_t Order;
|
|
|
|
|
Grp_WhichGroups_t WhichGroups;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned NumAttEvent;
|
2017-06-04 18:18:54 +02:00
|
|
|
|
bool ICanEdit = (Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
|
|
|
|
|
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-03-20 00:33:27 +01:00
|
|
|
|
/***** Compute variables related to pagination *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Pagination.NumItems = Events->Num;
|
|
|
|
|
Pagination.CurrentPage = (int) Events->CurrentPage;
|
2016-03-20 00:33:27 +01:00
|
|
|
|
Pag_CalculatePagination (&Pagination);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Events->CurrentPage = (unsigned) Pagination.CurrentPage;
|
2015-01-02 12:57:26 +01:00
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box *****/
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Box_BoxBegin ("100%",Txt_Events,
|
2020-04-08 13:40:21 +02:00
|
|
|
|
Att_PutIconsInListOfAttEvents,Events,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
Hlp_USERS_Attendance,Box_NOT_CLOSABLE);
|
2015-01-02 12:57:26 +01:00
|
|
|
|
|
2016-03-20 00:33:27 +01:00
|
|
|
|
/***** Select whether show only my groups or all groups *****/
|
2019-04-04 10:45:15 +02:00
|
|
|
|
if (Gbl.Crs.Grps.NumGrps)
|
2019-02-25 15:14:28 +01:00
|
|
|
|
{
|
2019-03-26 11:53:21 +01:00
|
|
|
|
Set_StartSettingsHead ();
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Grp_ShowFormToSelWhichGrps (ActSeeAtt,
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_ParamsWhichGroupsToShow,&Events);
|
2019-03-26 11:53:21 +01:00
|
|
|
|
Set_EndSettingsHead ();
|
2019-02-25 15:14:28 +01:00
|
|
|
|
}
|
2015-01-02 12:57:26 +01:00
|
|
|
|
|
2019-12-06 22:18:05 +01:00
|
|
|
|
/***** Write links to pages *****/
|
2020-04-10 19:14:08 +02:00
|
|
|
|
Pag_WriteLinksToPagesCentered (Pag_ATT_EVENTS,&Pagination,
|
|
|
|
|
Events,-1L);
|
2019-12-06 22:18:05 +01:00
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (Events->Num)
|
2016-03-20 00:33:27 +01:00
|
|
|
|
{
|
2015-11-13 01:27:44 +01:00
|
|
|
|
/***** Table head *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_BeginWideMarginPadding (2);
|
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-11 01:02:51 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TH (1,1,"CONTEXT_COL",NULL); // Column for contextual icons
|
2020-03-30 13:21:11 +02:00
|
|
|
|
for (Order = Dat_START_TIME;
|
2016-12-15 00:39:52 +01:00
|
|
|
|
Order <= Dat_END_TIME;
|
2015-11-13 01:27:44 +01:00
|
|
|
|
Order++)
|
|
|
|
|
{
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TH_Begin (1,1,"LM");
|
2019-10-12 19:42:10 +02:00
|
|
|
|
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartForm (ActSeeAtt);
|
2020-03-27 14:56:54 +01:00
|
|
|
|
WhichGroups = Grp_GetParamWhichGroups ();
|
|
|
|
|
Grp_PutParamWhichGroups (&WhichGroups);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Pag_PutHiddenParamPagNum (Pag_ATT_EVENTS,Events->CurrentPage);
|
2020-04-05 22:53:58 +02:00
|
|
|
|
Dat_PutHiddenParamOrder (Order);
|
2019-11-20 10:17:42 +01:00
|
|
|
|
HTM_BUTTON_SUBMIT_Begin (Txt_START_END_TIME_HELP[Order],"BT_LINK TIT_TBL",NULL);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (Order == Events->SelectedOrder)
|
2019-11-10 16:41:47 +01:00
|
|
|
|
HTM_U_Begin ();
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (Txt_START_END_TIME[Order]);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (Order == Events->SelectedOrder)
|
2019-11-10 16:41:47 +01:00
|
|
|
|
HTM_U_End ();
|
2019-11-18 09:35:23 +01:00
|
|
|
|
HTM_BUTTON_End ();
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2019-10-12 19:42:10 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TH_End ();
|
2015-11-13 01:27:44 +01:00
|
|
|
|
}
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TH (1,1,"LM",Txt_Event);
|
|
|
|
|
HTM_TH (1,1,"RM",Txt_ROLES_PLURAL_Abc[Rol_STD][Usr_SEX_UNKNOWN]);
|
2019-10-11 01:02:51 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2015-01-02 12:57:26 +01:00
|
|
|
|
|
2015-11-13 01:27:44 +01:00
|
|
|
|
/***** Write all the attendance events *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
for (NumAttEvent = Pagination.FirstItemVisible, Gbl.RowEvenOdd = 0;
|
2015-11-13 01:27:44 +01:00
|
|
|
|
NumAttEvent <= Pagination.LastItemVisible;
|
|
|
|
|
NumAttEvent++)
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_ShowOneAttEvent (Events,
|
|
|
|
|
&Events->Lst[NumAttEvent - 1],
|
|
|
|
|
false);
|
2015-01-02 12:57:26 +01:00
|
|
|
|
|
2016-03-20 00:33:27 +01:00
|
|
|
|
/***** End table *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_End ();
|
2016-03-20 00:33:27 +01:00
|
|
|
|
}
|
|
|
|
|
else // No events created
|
2019-02-16 14:37:34 +01:00
|
|
|
|
Ale_ShowAlert (Ale_INFO,Txt_No_events);
|
2016-03-20 00:33:27 +01:00
|
|
|
|
|
2019-12-06 22:18:05 +01:00
|
|
|
|
/***** Write again links to pages *****/
|
2020-04-10 19:14:08 +02:00
|
|
|
|
Pag_WriteLinksToPagesCentered (Pag_ATT_EVENTS,&Pagination,
|
|
|
|
|
Events,-1L);
|
2019-12-06 22:18:05 +01:00
|
|
|
|
|
2016-03-20 00:33:27 +01:00
|
|
|
|
/***** Button to create a new attendance event *****/
|
2016-03-20 02:08:13 +01:00
|
|
|
|
if (ICanEdit)
|
2020-04-08 13:40:21 +02:00
|
|
|
|
Att_PutButtonToCreateNewAttEvent (Events);
|
2016-03-20 00:33:27 +01:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End box *****/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Box_BoxEnd ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-03-20 00:33:27 +01:00
|
|
|
|
/***** Free list of attendance events *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_FreeListAttEvents (Events);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2019-02-25 15:14:28 +01:00
|
|
|
|
/***************** Put params to select which groups to show *****************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_ParamsWhichGroupsToShow (void *Events)
|
2016-12-04 23:09:28 +01:00
|
|
|
|
{
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (Events)
|
2020-03-26 02:54:30 +01:00
|
|
|
|
{
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Dat_PutHiddenParamOrder (((struct Att_Events *) Events)->SelectedOrder);
|
|
|
|
|
Pag_PutHiddenParamPagNum (Pag_ATT_EVENTS,((struct Att_Events *) Events)->CurrentPage);
|
2020-03-26 02:54:30 +01:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-10-18 08:56:00 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************* Put contextual icons in list of attendance events *************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_PutIconsInListOfAttEvents (void *Events)
|
2018-10-18 08:56:00 +02:00
|
|
|
|
{
|
2020-03-26 02:54:30 +01:00
|
|
|
|
bool ICanEdit;
|
2018-10-18 08:56:00 +02:00
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (Events)
|
2020-03-26 02:54:30 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Put icon to create a new attendance event *****/
|
|
|
|
|
ICanEdit = (Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
|
|
|
|
|
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM);
|
|
|
|
|
if (ICanEdit)
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_PutIconToCreateNewAttEvent ((struct Att_Events *) Events);
|
2020-03-26 02:54:30 +01:00
|
|
|
|
|
|
|
|
|
/***** Put icon to show attendance list *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (((struct Att_Events *) Events)->Num)
|
2020-03-26 02:54:30 +01:00
|
|
|
|
switch (Gbl.Usrs.Me.Role.Logged)
|
|
|
|
|
{
|
|
|
|
|
case Rol_STD:
|
|
|
|
|
Ico_PutContextualIconToShowAttendanceList (ActSeeLstMyAtt,
|
|
|
|
|
NULL,NULL);
|
|
|
|
|
break;
|
|
|
|
|
case Rol_NET:
|
|
|
|
|
case Rol_TCH:
|
|
|
|
|
case Rol_SYS_ADM:
|
|
|
|
|
Ico_PutContextualIconToShowAttendanceList (ActReqLstUsrAtt,
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_PutParamsToListUsrsAttendance,Events);
|
2020-03-26 02:54:30 +01:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2019-12-06 22:49:45 +01:00
|
|
|
|
|
2020-03-26 02:54:30 +01:00
|
|
|
|
/***** Put icon to print my QR code *****/
|
|
|
|
|
QR_PutLinkToPrintQRCode (ActPrnUsrQR,
|
2020-03-27 14:56:54 +01:00
|
|
|
|
Usr_PutParamMyUsrCodEncrypted,Gbl.Usrs.Me.UsrDat.EncryptedUsrCod);
|
2020-03-26 02:54:30 +01:00
|
|
|
|
}
|
2018-10-18 08:56:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-20 00:33:27 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************** Put icon to create a new attendance event ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_PutIconToCreateNewAttEvent (struct Att_Events *Events)
|
2016-03-20 00:33:27 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_New_event;
|
|
|
|
|
|
2018-10-18 08:56:00 +02:00
|
|
|
|
/***** Put icon to create a new attendance event *****/
|
2019-01-10 15:26:33 +01:00
|
|
|
|
Ico_PutContextualIconToAdd (ActFrmNewAtt,NULL,
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_PutParamsToCreateNewAttEvent,Events,
|
2019-01-10 15:26:33 +01:00
|
|
|
|
Txt_New_event);
|
2016-03-20 00:33:27 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************** Put button to create a new attendance event ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-08 13:40:21 +02:00
|
|
|
|
static void Att_PutButtonToCreateNewAttEvent (struct Att_Events *Events)
|
2016-03-20 00:33:27 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_New_event;
|
|
|
|
|
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartForm (ActFrmNewAtt);
|
2020-04-08 13:40:21 +02:00
|
|
|
|
Att_PutParamsToCreateNewAttEvent (Events);
|
2017-06-11 19:02:40 +02:00
|
|
|
|
Btn_PutConfirmButton (Txt_New_event);
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2016-03-20 00:33:27 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** Put parameters to create a new attendance event **************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_PutParamsToCreateNewAttEvent (void *Events)
|
2016-03-20 00:33:27 +01:00
|
|
|
|
{
|
2020-03-27 14:56:54 +01:00
|
|
|
|
Grp_WhichGroups_t WhichGroups;
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (Events)
|
2020-03-26 02:54:30 +01:00
|
|
|
|
{
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Dat_PutHiddenParamOrder (((struct Att_Events *) Events)->SelectedOrder);
|
2020-03-27 14:56:54 +01:00
|
|
|
|
WhichGroups = Grp_GetParamWhichGroups ();
|
|
|
|
|
Grp_PutParamWhichGroups (&WhichGroups);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Pag_PutHiddenParamPagNum (Pag_ATT_EVENTS,((struct Att_Events *) Events)->CurrentPage);
|
2020-03-26 02:54:30 +01:00
|
|
|
|
}
|
2016-03-20 00:33:27 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-06 22:49:45 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Put parameters to list users attendance *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_PutParamsToListUsrsAttendance (void *Events)
|
2019-12-06 22:49:45 +01:00
|
|
|
|
{
|
2020-03-27 14:56:54 +01:00
|
|
|
|
Grp_WhichGroups_t WhichGroups;
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (Events)
|
2020-03-26 02:54:30 +01:00
|
|
|
|
{
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Dat_PutHiddenParamOrder (((struct Att_Events *) Events)->SelectedOrder);
|
2020-03-27 14:56:54 +01:00
|
|
|
|
WhichGroups = Grp_GetParamWhichGroups ();
|
|
|
|
|
Grp_PutParamWhichGroups (&WhichGroups);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Pag_PutHiddenParamPagNum (Pag_ATT_EVENTS,((struct Att_Events *) Events)->CurrentPage);
|
2020-03-26 02:54:30 +01:00
|
|
|
|
}
|
2019-12-06 22:49:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Show one attendance event *************************/
|
|
|
|
|
/*****************************************************************************/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
// Only Event->AttCod must be filled
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_ShowOneAttEvent (struct Att_Events *Events,
|
|
|
|
|
struct Att_Event *Event,
|
|
|
|
|
bool ShowOnlyThisAttEventComplete)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_View_event;
|
2019-04-20 21:11:44 +02:00
|
|
|
|
char *Anchor = NULL;
|
2015-10-23 13:20:42 +02:00
|
|
|
|
static unsigned UniqueId = 0;
|
2019-11-01 22:53:39 +01:00
|
|
|
|
char *Id;
|
2019-09-27 00:46:02 +02:00
|
|
|
|
Dat_StartEndTime_t StartEndTime;
|
2019-02-15 21:09:18 +01:00
|
|
|
|
char Description[Cns_MAX_BYTES_TEXT + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get data of this attendance event *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_GetDataOfAttEventByCodAndCheckCrs (Event);
|
|
|
|
|
Att_GetNumStdsTotalWhoAreInAttEvent (Event);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-20 21:11:44 +02:00
|
|
|
|
/***** Set anchor string *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Frm_SetAnchorStr (Event->AttCod,&Anchor);
|
2019-04-20 21:11:44 +02:00
|
|
|
|
|
2017-05-02 11:39:17 +02:00
|
|
|
|
/***** Write first row of data of this attendance event *****/
|
|
|
|
|
/* Forms to remove/edit this attendance event */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
|
|
|
|
if (ShowOnlyThisAttEventComplete)
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("rowspan=\"2\" class=\"CONTEXT_COL\"");
|
2019-10-07 22:28:16 +02:00
|
|
|
|
else
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("rowspan=\"2\" class=\"CONTEXT_COL COLOR%u\"",Gbl.RowEvenOdd);
|
2017-06-04 18:18:54 +02:00
|
|
|
|
switch (Gbl.Usrs.Me.Role.Logged)
|
2017-05-02 11:39:17 +02:00
|
|
|
|
{
|
2017-05-18 19:13:41 +02:00
|
|
|
|
case Rol_TCH:
|
2017-05-02 11:39:17 +02:00
|
|
|
|
case Rol_SYS_ADM:
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_PutFormsToRemEditOneAttEvent (Events,Event,Anchor);
|
2017-05-02 11:39:17 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2017-05-02 11:39:17 +02:00
|
|
|
|
|
2019-09-27 00:46:02 +02:00
|
|
|
|
/* Start/end date/time */
|
2017-05-02 11:39:17 +02:00
|
|
|
|
UniqueId++;
|
2019-12-15 01:10:36 +01:00
|
|
|
|
for (StartEndTime = (Dat_StartEndTime_t) 0;
|
2019-09-27 00:46:02 +02:00
|
|
|
|
StartEndTime <= (Dat_StartEndTime_t) (Dat_NUM_START_END_TIME - 1);
|
|
|
|
|
StartEndTime++)
|
|
|
|
|
{
|
2019-11-01 22:53:39 +01:00
|
|
|
|
if (asprintf (&Id,"att_date_%u_%u",(unsigned) StartEndTime,UniqueId) < 0)
|
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
2019-10-07 23:02:50 +02:00
|
|
|
|
if (ShowOnlyThisAttEventComplete)
|
2019-11-01 22:53:39 +01:00
|
|
|
|
HTM_TD_Begin ("id=\"%s\" class=\"%s LB\"",
|
|
|
|
|
Id,
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event->Hidden ? (Event->Open ? "DATE_GREEN_LIGHT" :
|
|
|
|
|
"DATE_RED_LIGHT") :
|
|
|
|
|
(Event->Open ? "DATE_GREEN" :
|
|
|
|
|
"DATE_RED"));
|
2019-10-07 23:02:50 +02:00
|
|
|
|
else
|
2019-11-01 22:53:39 +01:00
|
|
|
|
HTM_TD_Begin ("id=\"%s\" class=\"%s LB COLOR%u\"",
|
|
|
|
|
Id,
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event->Hidden ? (Event->Open ? "DATE_GREEN_LIGHT" :
|
|
|
|
|
"DATE_RED_LIGHT") :
|
|
|
|
|
(Event->Open ? "DATE_GREEN" :
|
|
|
|
|
"DATE_RED"),
|
2019-10-10 23:14:13 +02:00
|
|
|
|
Gbl.RowEvenOdd);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Dat_WriteLocalDateHMSFromUTC (Id,Event->TimeUTC[StartEndTime],
|
2019-11-02 12:10:58 +01:00
|
|
|
|
Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK,
|
2019-11-02 11:45:41 +01:00
|
|
|
|
true,true,true,0x7);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-11-06 19:45:20 +01:00
|
|
|
|
free (Id);
|
2019-09-27 00:46:02 +02:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-05-02 11:39:17 +02:00
|
|
|
|
/* Attendance event title */
|
2019-10-07 23:02:50 +02:00
|
|
|
|
if (ShowOnlyThisAttEventComplete)
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LT\"");
|
2019-10-07 23:02:50 +02:00
|
|
|
|
else
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd);
|
2019-10-26 01:56:36 +02:00
|
|
|
|
HTM_ARTICLE_Begin (Anchor);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_PutLinkAttEvent (Event,Txt_View_event,Event->Title,
|
|
|
|
|
Event->Hidden ? "BT_LINK LT ASG_TITLE_LIGHT" :
|
|
|
|
|
"BT_LINK LT ASG_TITLE");
|
2019-10-26 01:56:36 +02:00
|
|
|
|
HTM_ARTICLE_End ();
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-05-02 11:39:17 +02:00
|
|
|
|
/* Number of students in this event */
|
2019-10-07 23:02:50 +02:00
|
|
|
|
if (ShowOnlyThisAttEventComplete)
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"%s RT\"",
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event->Hidden ? "ASG_TITLE_LIGHT" :
|
|
|
|
|
"ASG_TITLE");
|
2019-10-07 23:02:50 +02:00
|
|
|
|
else
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"%s RT COLOR%u\"",
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event->Hidden ? "ASG_TITLE_LIGHT" :
|
|
|
|
|
"ASG_TITLE",
|
2019-10-10 23:14:13 +02:00
|
|
|
|
Gbl.RowEvenOdd);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
HTM_Unsigned (Event->NumStdsTotal);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-06 12:00:55 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write second row of data of this attendance event *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/* Author of the attendance event */
|
2019-10-07 23:02:50 +02:00
|
|
|
|
if (ShowOnlyThisAttEventComplete)
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"LT\"");
|
2019-10-07 23:02:50 +02:00
|
|
|
|
else
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"LT COLOR%u\"",Gbl.RowEvenOdd);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_WriteAttEventAuthor (Event);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Text of the attendance event */
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_GetAttEventDescriptionFromDB (Event->AttCod,Description);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
|
2019-02-15 21:09:18 +01:00
|
|
|
|
Description,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to recpectful HTML
|
|
|
|
|
Str_InsertLinks (Description,Cns_MAX_BYTES_TEXT,60); // Insert links
|
2019-10-07 23:02:50 +02:00
|
|
|
|
if (ShowOnlyThisAttEventComplete)
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"LT\"");
|
2019-10-07 23:02:50 +02:00
|
|
|
|
else
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"LT COLOR%u\"",Gbl.RowEvenOdd);
|
2019-04-04 10:45:15 +02:00
|
|
|
|
if (Gbl.Crs.Grps.NumGrps)
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_GetAndWriteNamesOfGrpsAssociatedToAttEvent (Event);
|
|
|
|
|
HTM_DIV_Begin ("class=\"%s\"",Event->Hidden ? "DAT_LIGHT" :
|
|
|
|
|
"DAT");
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (Description);
|
2019-10-23 20:07:56 +02:00
|
|
|
|
HTM_DIV_End ();
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-20 21:11:44 +02:00
|
|
|
|
/***** Free anchor string *****/
|
|
|
|
|
Frm_FreeAnchorStr (Anchor);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Write the author of an attendance event ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_WriteAttEventAuthor (struct Att_Event *Event)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Usr_WriteAuthor1Line (Event->UsrCod,Event->Hidden);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**** Get parameter with the type or order in list of attendance events ******/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static Dat_StartEndTime_t Att_GetParamAttOrder (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-04-06 16:00:06 +02:00
|
|
|
|
return (Dat_StartEndTime_t)
|
|
|
|
|
Par_GetParToUnsignedLong ("Order",
|
|
|
|
|
0,
|
|
|
|
|
Dat_NUM_START_END_TIME - 1,
|
|
|
|
|
(unsigned long) Att_ORDER_DEFAULT);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** Put a link (form) to edit one attendance event ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_PutFormsToRemEditOneAttEvent (struct Att_Events *Events,
|
|
|
|
|
const struct Att_Event *Event,
|
2019-04-20 21:11:44 +02:00
|
|
|
|
const char *Anchor)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Events->AttCod = Event->AttCod;
|
2015-12-13 19:37:08 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Put form to remove attendance event *****/
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Ico_PutContextualIconToRemove (ActReqRemAtt,
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_PutParams,Events);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Put form to hide/show attendance event *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (Event->Hidden)
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Ico_PutContextualIconToUnhide (ActShoAtt,Anchor,
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_PutParams,Events);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Ico_PutContextualIconToHide (ActHidAtt,Anchor,
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_PutParams,Events);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Put form to edit attendance event *****/
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Ico_PutContextualIconToEdit (ActEdiOneAtt,NULL,
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_PutParams,Events);
|
2015-12-13 19:37:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Params used to edit an attendance event *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_PutParams (void *Events)
|
2015-12-13 19:37:08 +01:00
|
|
|
|
{
|
2020-03-27 14:56:54 +01:00
|
|
|
|
Grp_WhichGroups_t WhichGroups;
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (Events)
|
2020-03-26 02:54:30 +01:00
|
|
|
|
{
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_PutParamAttCod (((struct Att_Events *) Events)->AttCod);
|
|
|
|
|
Dat_PutHiddenParamOrder (((struct Att_Events *) Events)->SelectedOrder);
|
2020-03-27 14:56:54 +01:00
|
|
|
|
WhichGroups = Grp_GetParamWhichGroups ();
|
|
|
|
|
Grp_PutParamWhichGroups (&WhichGroups);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Pag_PutHiddenParamPagNum (Pag_ATT_EVENTS,((struct Att_Events *) Events)->CurrentPage);
|
2020-03-26 02:54:30 +01:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* List all the attendance events ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_GetListAttEvents (struct Att_Events *Events,
|
|
|
|
|
Att_OrderNewestOldest_t OrderNewestOldest)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-01-03 15:25:18 +01:00
|
|
|
|
static const char *HiddenSubQuery[Rol_NUM_ROLES] =
|
|
|
|
|
{
|
2019-11-21 00:40:35 +01:00
|
|
|
|
[Rol_UNK ] = " AND Hidden='N'",
|
|
|
|
|
[Rol_GST ] = " AND Hidden='N'",
|
|
|
|
|
[Rol_USR ] = " AND Hidden='N'",
|
|
|
|
|
[Rol_STD ] = " AND Hidden='N'",
|
|
|
|
|
[Rol_NET ] = " AND Hidden='N'",
|
|
|
|
|
[Rol_TCH ] = "",
|
|
|
|
|
[Rol_DEG_ADM] = " AND Hidden='N'",
|
|
|
|
|
[Rol_CTR_ADM] = " AND Hidden='N'",
|
|
|
|
|
[Rol_INS_ADM] = " AND Hidden='N'",
|
|
|
|
|
[Rol_SYS_ADM] = "",
|
2019-01-03 15:25:18 +01:00
|
|
|
|
};
|
|
|
|
|
static const char *OrderBySubQuery[Dat_NUM_START_END_TIME][Att_NUM_ORDERS_NEWEST_OLDEST] =
|
|
|
|
|
{
|
2019-11-21 00:40:35 +01:00
|
|
|
|
[Dat_START_TIME][Att_NEWEST_FIRST] = "StartTime DESC,EndTime DESC,Title DESC",
|
|
|
|
|
[Dat_START_TIME][Att_OLDEST_FIRST] = "StartTime,EndTime,Title",
|
|
|
|
|
|
|
|
|
|
[Dat_END_TIME ][Att_NEWEST_FIRST] = "EndTime DESC,StartTime DESC,Title DESC",
|
|
|
|
|
[Dat_END_TIME ][Att_OLDEST_FIRST] = "EndTime,StartTime,Title",
|
2019-01-03 15:25:18 +01:00
|
|
|
|
};
|
2014-12-01 23:55:08 +01:00
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned long NumRows;
|
|
|
|
|
unsigned NumAttEvent;
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (Events->LstIsRead)
|
|
|
|
|
Att_FreeListAttEvents (Events);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get list of attendance events from database *****/
|
2019-09-29 17:33:39 +02:00
|
|
|
|
if (Gbl.Crs.Grps.WhichGrps == Grp_MY_GROUPS)
|
2018-10-30 13:59:37 +01:00
|
|
|
|
NumRows = DB_QuerySELECT (&mysql_res,"can not get attendance events",
|
|
|
|
|
"SELECT AttCod"
|
|
|
|
|
" FROM att_events"
|
|
|
|
|
" WHERE CrsCod=%ld%s"
|
|
|
|
|
" AND (AttCod NOT IN (SELECT AttCod FROM att_grp) OR"
|
|
|
|
|
" AttCod IN (SELECT att_grp.AttCod FROM att_grp,crs_grp_usr"
|
|
|
|
|
" WHERE crs_grp_usr.UsrCod=%ld"
|
|
|
|
|
" AND att_grp.GrpCod=crs_grp_usr.GrpCod))"
|
|
|
|
|
" ORDER BY %s",
|
2019-04-04 10:45:15 +02:00
|
|
|
|
Gbl.Hierarchy.Crs.CrsCod,
|
2019-01-03 15:25:18 +01:00
|
|
|
|
HiddenSubQuery[Gbl.Usrs.Me.Role.Logged],
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
2020-04-06 16:00:06 +02:00
|
|
|
|
OrderBySubQuery[Events->SelectedOrder][OrderNewestOldest]);
|
2019-04-04 10:45:15 +02:00
|
|
|
|
else // Gbl.Crs.Grps.WhichGrps == Grp_ALL_GROUPS
|
2018-10-30 13:59:37 +01:00
|
|
|
|
NumRows = DB_QuerySELECT (&mysql_res,"can not get attendance events",
|
|
|
|
|
"SELECT AttCod"
|
|
|
|
|
" FROM att_events"
|
|
|
|
|
" WHERE CrsCod=%ld%s"
|
|
|
|
|
" ORDER BY %s",
|
2019-04-04 10:45:15 +02:00
|
|
|
|
Gbl.Hierarchy.Crs.CrsCod,
|
2019-01-03 15:25:18 +01:00
|
|
|
|
HiddenSubQuery[Gbl.Usrs.Me.Role.Logged],
|
2020-04-06 16:00:06 +02:00
|
|
|
|
OrderBySubQuery[Events->SelectedOrder][OrderNewestOldest]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2018-10-30 01:00:46 +01:00
|
|
|
|
if (NumRows) // Attendance events found...
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Events->Num = (unsigned) NumRows;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Create list of attendance events *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if ((Events->Lst = (struct Att_Event *) calloc (NumRows,sizeof (struct Att_Event))) == NULL)
|
2018-10-18 20:06:54 +02:00
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get the attendance events codes *****/
|
|
|
|
|
for (NumAttEvent = 0;
|
2020-04-06 16:00:06 +02:00
|
|
|
|
NumAttEvent < Events->Num;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
NumAttEvent++)
|
|
|
|
|
{
|
|
|
|
|
/* Get next attendance event code */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if ((Events->Lst[NumAttEvent].AttCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Lay_ShowErrorAndExit ("Error: wrong attendance event code.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Events->Num = 0;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Events->LstIsRead = true;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********* Get attendance event data using its code and check course *********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_GetDataOfAttEventByCodAndCheckCrs (struct Att_Event *Event)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (Att_GetDataOfAttEventByCod (Event))
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (Event->CrsCod != Gbl.Hierarchy.Crs.CrsCod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Lay_ShowErrorAndExit ("Attendance event does not belong to current course.");
|
|
|
|
|
}
|
|
|
|
|
else // Attendance event not found
|
|
|
|
|
Lay_ShowErrorAndExit ("Error when getting attendance event.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************** Get attendance event data using its code *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
// Returns true if attendance event exists
|
|
|
|
|
// This function can be called from web service, so do not display messages
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
bool Att_GetDataOfAttEventByCod (struct Att_Event *Event)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2018-10-30 13:59:37 +01:00
|
|
|
|
unsigned long NumRows;
|
2016-12-29 23:33:01 +01:00
|
|
|
|
bool Found = false;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-12-29 23:07:30 +01:00
|
|
|
|
/***** Reset attendance event data *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_ResetAttendanceEvent (Event);
|
2016-12-29 23:07:30 +01:00
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (Event->AttCod > 0)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2016-12-29 23:33:01 +01:00
|
|
|
|
/***** Build query *****/
|
2018-10-30 13:59:37 +01:00
|
|
|
|
NumRows = DB_QuerySELECT (&mysql_res,"can not get attendance event data",
|
|
|
|
|
"SELECT AttCod,CrsCod,Hidden,UsrCod,"
|
|
|
|
|
"UNIX_TIMESTAMP(StartTime),"
|
|
|
|
|
"UNIX_TIMESTAMP(EndTime),"
|
|
|
|
|
"NOW() BETWEEN StartTime AND EndTime,"
|
|
|
|
|
"CommentTchVisible,"
|
|
|
|
|
"Title"
|
|
|
|
|
" FROM att_events"
|
|
|
|
|
" WHERE AttCod=%ld",
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event->AttCod);
|
2016-12-29 23:33:01 +01:00
|
|
|
|
|
|
|
|
|
/***** Get data of attendance event from database *****/
|
2018-10-30 13:59:37 +01:00
|
|
|
|
if ((Found = (NumRows != 0))) // Attendance event found...
|
2016-12-29 23:33:01 +01:00
|
|
|
|
{
|
|
|
|
|
/* Get row */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-12-29 23:33:01 +01:00
|
|
|
|
/* Get code of the attendance event (row[0]) */
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event->AttCod = Str_ConvertStrCodToLongCod (row[0]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-12-29 23:33:01 +01:00
|
|
|
|
/* Get code of the course (row[1]) */
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event->CrsCod = Str_ConvertStrCodToLongCod (row[1]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-12-29 23:33:01 +01:00
|
|
|
|
/* Get whether the attendance event is hidden or not (row[2]) */
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event->Hidden = (row[2][0] == 'Y');
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-12-29 23:33:01 +01:00
|
|
|
|
/* Get author of the attendance event (row[3]) */
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event->UsrCod = Str_ConvertStrCodToLongCod (row[3]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-12-29 23:33:01 +01:00
|
|
|
|
/* Get start date (row[4] holds the start UTC time) */
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event->TimeUTC[Att_START_TIME] = Dat_GetUNIXTimeFromStr (row[4]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-12-29 23:33:01 +01:00
|
|
|
|
/* Get end date (row[5] holds the end UTC time) */
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event->TimeUTC[Att_END_TIME ] = Dat_GetUNIXTimeFromStr (row[5]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-12-29 23:33:01 +01:00
|
|
|
|
/* Get whether the attendance event is open or closed (row(6)) */
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event->Open = (row[6][0] == '1');
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-12-29 23:33:01 +01:00
|
|
|
|
/* Get whether the attendance event is visible or not (row[7]) */
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event->CommentTchVisible = (row[7][0] == 'Y');
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-12-29 23:33:01 +01:00
|
|
|
|
/* Get the title of the attendance event (row[8]) */
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Str_Copy (Event->Title,row[8],
|
2017-03-07 01:56:41 +01:00
|
|
|
|
Att_MAX_BYTES_ATTENDANCE_EVENT_TITLE);
|
2016-12-29 23:33:01 +01:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-12-29 23:33:01 +01:00
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
return Found;
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-29 23:07:30 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Clear all attendance event data **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_ResetAttendanceEvent (struct Att_Event *Event)
|
2016-12-29 23:07:30 +01:00
|
|
|
|
{
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (Event->AttCod <= 0) // If > 0 ==> keep values of AttCod and Selected
|
2017-01-17 14:24:54 +01:00
|
|
|
|
{
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event->AttCod = -1L;
|
|
|
|
|
Event->NumStdsTotal = 0;
|
|
|
|
|
Event->NumStdsFromList = 0;
|
|
|
|
|
Event->Selected = false;
|
2017-01-17 14:24:54 +01:00
|
|
|
|
}
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event->CrsCod = -1L;
|
|
|
|
|
Event->Hidden = false;
|
|
|
|
|
Event->UsrCod = -1L;
|
|
|
|
|
Event->TimeUTC[Att_START_TIME] =
|
|
|
|
|
Event->TimeUTC[Att_END_TIME ] = (time_t) 0;
|
|
|
|
|
Event->Open = false;
|
|
|
|
|
Event->Title[0] = '\0';
|
|
|
|
|
Event->CommentTchVisible = false;
|
2016-12-29 23:07:30 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Free list of attendance events ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_FreeListAttEvents (struct Att_Events *Events)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (Events->LstIsRead && Events->Lst)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Free memory used by the list of attendance events *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
free (Events->Lst);
|
|
|
|
|
Events->Lst = NULL;
|
|
|
|
|
Events->Num = 0;
|
|
|
|
|
Events->LstIsRead = false;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Get attendance event text from database *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-02-15 21:09:18 +01:00
|
|
|
|
static void Att_GetAttEventDescriptionFromDB (long AttCod,char Description[Cns_MAX_BYTES_TEXT + 1])
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned long NumRows;
|
|
|
|
|
|
|
|
|
|
/***** Get text of attendance event from database *****/
|
2018-10-30 13:59:37 +01:00
|
|
|
|
NumRows = DB_QuerySELECT (&mysql_res,"can not get attendance event text",
|
|
|
|
|
"SELECT Txt FROM att_events"
|
|
|
|
|
" WHERE AttCod=%ld AND CrsCod=%ld",
|
2019-04-04 10:45:15 +02:00
|
|
|
|
AttCod,Gbl.Hierarchy.Crs.CrsCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** The result of the query must have one row or none *****/
|
|
|
|
|
if (NumRows == 1)
|
|
|
|
|
{
|
2017-01-13 01:51:23 +01:00
|
|
|
|
/* Get row */
|
2014-12-01 23:55:08 +01:00
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2017-01-13 01:51:23 +01:00
|
|
|
|
|
|
|
|
|
/* Get info text */
|
2019-02-15 21:09:18 +01:00
|
|
|
|
Str_Copy (Description,row[0],
|
2017-01-17 03:10:43 +01:00
|
|
|
|
Cns_MAX_BYTES_TEXT);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
2019-02-15 21:09:18 +01:00
|
|
|
|
Description[0] = '\0';
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
if (NumRows > 1)
|
|
|
|
|
Lay_ShowErrorAndExit ("Error when getting attendance event text.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** Write parameter with code of attendance event ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_PutParamSelectedAttCod (void *Events)
|
2019-04-11 09:55:35 +02:00
|
|
|
|
{
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (Events)
|
|
|
|
|
Att_PutParamAttCod (((struct Att_Events *) Events)->AttCod);
|
2019-04-11 09:55:35 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_PutParamAttCod (long AttCod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-11-03 13:19:32 +01:00
|
|
|
|
Par_PutHiddenParamLong (NULL,"AttCod",AttCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Get parameter with code of attendance event *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static long Att_GetParamAttCod (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-01-28 20:32:50 +01:00
|
|
|
|
/***** Get code of attendance event *****/
|
|
|
|
|
return Par_GetParToLong ("AttCod");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********* Ask for confirmation of removing of an attendance event ***********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Att_AskRemAttEvent (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Do_you_really_want_to_remove_the_event_X;
|
|
|
|
|
extern const char *Txt_Remove_event;
|
2020-04-06 16:00:06 +02:00
|
|
|
|
struct Att_Events Events;
|
|
|
|
|
struct Att_Event Event;
|
2020-03-27 14:56:54 +01:00
|
|
|
|
Grp_WhichGroups_t WhichGroups;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
/***** Reset attendance events *****/
|
|
|
|
|
Att_ResetEvents (&Events);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get parameters *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Events.SelectedOrder = Att_GetParamAttOrder ();
|
2020-03-27 14:56:54 +01:00
|
|
|
|
Grp_GetParamWhichGroups ();
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Events.CurrentPage = Pag_GetParamPagNum (Pag_ATT_EVENTS);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get attendance event code *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if ((Event.AttCod = Att_GetParamAttCod ()) == -1L)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Lay_ShowErrorAndExit ("Code of attendance event is missing.");
|
|
|
|
|
|
|
|
|
|
/***** Get data of the attendance event from database *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_GetDataOfAttEventByCodAndCheckCrs (&Event);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Button of confirmation of removing *****/
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartForm (ActRemAtt);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_PutParamAttCod (Event.AttCod);
|
|
|
|
|
Dat_PutHiddenParamOrder (Events.SelectedOrder);
|
2020-03-27 14:56:54 +01:00
|
|
|
|
WhichGroups = Grp_GetParamWhichGroups ();
|
|
|
|
|
Grp_PutParamWhichGroups (&WhichGroups);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Pag_PutHiddenParamPagNum (Pag_ATT_EVENTS,Events.CurrentPage);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-02-15 23:38:44 +01:00
|
|
|
|
/* Ask for confirmation of removing */
|
2019-02-16 14:37:34 +01:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_Do_you_really_want_to_remove_the_event_X,
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event.Title);
|
2019-02-15 23:38:44 +01:00
|
|
|
|
|
2017-06-11 19:02:40 +02:00
|
|
|
|
Btn_PutRemoveButton (Txt_Remove_event);
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Show attendance events again *****/
|
|
|
|
|
Att_SeeAttEvents ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-09-06 18:29:13 +02:00
|
|
|
|
/** Get param., remove an attendance event and show attendance events again **/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-09-06 18:29:13 +02:00
|
|
|
|
void Att_GetAndRemAttEvent (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Event_X_removed;
|
2020-04-06 16:00:06 +02:00
|
|
|
|
struct Att_Event Event;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get attendance event code *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if ((Event.AttCod = Att_GetParamAttCod ()) == -1L)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Lay_ShowErrorAndExit ("Code of attendance event is missing.");
|
|
|
|
|
|
|
|
|
|
/***** Get data of the attendance event from database *****/
|
2016-09-06 18:29:13 +02:00
|
|
|
|
// Inside this function, the course is checked to be the current one
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_GetDataOfAttEventByCodAndCheckCrs (&Event);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-09-06 18:29:13 +02:00
|
|
|
|
/***** Remove the attendance event from database *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_RemoveAttEventFromDB (Event.AttCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write message to show the change made *****/
|
2019-02-16 14:37:34 +01:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_Event_X_removed,
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event.Title);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Show attendance events again *****/
|
|
|
|
|
Att_SeeAttEvents ();
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-06 18:29:13 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************** Remove an attendance event from database *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Att_RemoveAttEventFromDB (long AttCod)
|
|
|
|
|
{
|
|
|
|
|
/***** Remove users registered in the attendance event *****/
|
|
|
|
|
Att_RemoveAllUsrsFromAnAttEvent (AttCod);
|
|
|
|
|
|
|
|
|
|
/***** Remove all the groups of this attendance event *****/
|
|
|
|
|
Att_RemoveAllTheGrpsAssociatedToAnAttEvent (AttCod);
|
|
|
|
|
|
|
|
|
|
/***** Remove attendance event *****/
|
|
|
|
|
Att_RemoveAttEventFromCurrentCrs (AttCod);
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Hide an attendance event **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Att_HideAttEvent (void)
|
|
|
|
|
{
|
2020-04-06 16:00:06 +02:00
|
|
|
|
struct Att_Event Event;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get attendance event code *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if ((Event.AttCod = Att_GetParamAttCod ()) == -1L)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Lay_ShowErrorAndExit ("Code of attendance event is missing.");
|
|
|
|
|
|
|
|
|
|
/***** Get data of the attendance event from database *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_GetDataOfAttEventByCodAndCheckCrs (&Event);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Hide attendance event *****/
|
2018-11-03 12:16:40 +01:00
|
|
|
|
DB_QueryUPDATE ("can not hide attendance event",
|
|
|
|
|
"UPDATE att_events SET Hidden='Y'"
|
|
|
|
|
" WHERE AttCod=%ld AND CrsCod=%ld",
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event.AttCod,Gbl.Hierarchy.Crs.CrsCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Show attendance events again *****/
|
|
|
|
|
Att_SeeAttEvents ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Show an attendance event **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Att_ShowAttEvent (void)
|
|
|
|
|
{
|
2020-04-06 16:00:06 +02:00
|
|
|
|
struct Att_Event Event;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get attendance event code *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if ((Event.AttCod = Att_GetParamAttCod ()) == -1L)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Lay_ShowErrorAndExit ("Code of attendance event is missing.");
|
|
|
|
|
|
|
|
|
|
/***** Get data of the attendance event from database *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_GetDataOfAttEventByCodAndCheckCrs (&Event);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Hide attendance event *****/
|
2018-11-03 12:16:40 +01:00
|
|
|
|
DB_QueryUPDATE ("can not show attendance event",
|
|
|
|
|
"UPDATE att_events SET Hidden='N'"
|
|
|
|
|
" WHERE AttCod=%ld AND CrsCod=%ld",
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event.AttCod,Gbl.Hierarchy.Crs.CrsCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Show attendance events again *****/
|
|
|
|
|
Att_SeeAttEvents ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***** Check if the title or the folder of an attendance event exists ********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static bool Att_CheckIfSimilarAttEventExists (const char *Field,const char *Value,long AttCod)
|
|
|
|
|
{
|
2018-11-03 13:13:11 +01:00
|
|
|
|
/***** Get number of attendance events
|
|
|
|
|
with a field value from database *****/
|
|
|
|
|
return (DB_QueryCOUNT ("can not get similar attendance events",
|
|
|
|
|
"SELECT COUNT(*) FROM att_events"
|
|
|
|
|
" WHERE CrsCod=%ld"
|
|
|
|
|
" AND %s='%s' AND AttCod<>%ld",
|
2019-04-04 10:45:15 +02:00
|
|
|
|
Gbl.Hierarchy.Crs.CrsCod,
|
2018-11-03 13:13:11 +01:00
|
|
|
|
Field,Value,AttCod) != 0);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Put a form to create a new attendance event *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Att_RequestCreatOrEditAttEvent (void)
|
|
|
|
|
{
|
2016-11-27 23:08:29 +01:00
|
|
|
|
extern const char *Hlp_USERS_Attendance_new_event;
|
|
|
|
|
extern const char *Hlp_USERS_Attendance_edit_event;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_New_event;
|
|
|
|
|
extern const char *Txt_Edit_event;
|
2014-12-04 01:19:42 +01:00
|
|
|
|
extern const char *Txt_Teachers_comment;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Title;
|
|
|
|
|
extern const char *Txt_Hidden_MALE_PLURAL;
|
|
|
|
|
extern const char *Txt_Visible_MALE_PLURAL;
|
|
|
|
|
extern const char *Txt_Description;
|
|
|
|
|
extern const char *Txt_Create_event;
|
2019-02-18 18:27:45 +01:00
|
|
|
|
extern const char *Txt_Save_changes;
|
2020-04-06 16:00:06 +02:00
|
|
|
|
struct Att_Events Events;
|
|
|
|
|
struct Att_Event Event;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool ItsANewAttEvent;
|
2020-03-27 14:56:54 +01:00
|
|
|
|
Grp_WhichGroups_t WhichGroups;
|
2019-02-15 21:09:18 +01:00
|
|
|
|
char Description[Cns_MAX_BYTES_TEXT + 1];
|
2020-02-26 19:35:33 +01:00
|
|
|
|
static const Dat_SetHMS SetHMS[Dat_NUM_START_END_TIME] =
|
|
|
|
|
{
|
2020-04-13 16:39:15 +02:00
|
|
|
|
[Dat_START_TIME] = Dat_HMS_DO_NOT_SET,
|
|
|
|
|
[Dat_END_TIME ] = Dat_HMS_DO_NOT_SET
|
2020-02-26 19:35:33 +01:00
|
|
|
|
};
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get parameters *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Events.SelectedOrder = Att_GetParamAttOrder ();
|
2020-03-27 14:56:54 +01:00
|
|
|
|
Grp_GetParamWhichGroups ();
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Events.CurrentPage = Pag_GetParamPagNum (Pag_ATT_EVENTS);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get the code of the attendance event *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event.AttCod = Att_GetParamAttCod ();
|
|
|
|
|
ItsANewAttEvent = (Event.AttCod <= 0);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get from the database the data of the attendance event *****/
|
|
|
|
|
if (ItsANewAttEvent)
|
|
|
|
|
{
|
2016-12-29 23:07:30 +01:00
|
|
|
|
/* Reset attendance event data */
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event.AttCod = -1L;
|
|
|
|
|
Att_ResetAttendanceEvent (&Event);
|
2016-12-29 23:07:30 +01:00
|
|
|
|
|
|
|
|
|
/* Initialize some fields */
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event.CrsCod = Gbl.Hierarchy.Crs.CrsCod;
|
|
|
|
|
Event.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
|
|
|
|
|
Event.TimeUTC[Att_START_TIME] = Gbl.StartExecutionTimeUTC;
|
|
|
|
|
Event.TimeUTC[Att_END_TIME ] = Gbl.StartExecutionTimeUTC + (2 * 60 * 60); // +2 hours
|
|
|
|
|
Event.Open = true;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Get data of the attendance event from database */
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_GetDataOfAttEventByCodAndCheckCrs (&Event);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get text of the attendance event from database */
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_GetAttEventDescriptionFromDB (Event.AttCod,Description);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-20 22:00:28 +02:00
|
|
|
|
/***** Begin form *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (ItsANewAttEvent)
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartForm (ActNewAtt);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartForm (ActChgAtt);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_PutParamAttCod (Event.AttCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Dat_PutHiddenParamOrder (Events.SelectedOrder);
|
2020-03-27 14:56:54 +01:00
|
|
|
|
WhichGroups = Grp_GetParamWhichGroups ();
|
|
|
|
|
Grp_PutParamWhichGroups (&WhichGroups);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Pag_PutHiddenParamPagNum (Pag_ATT_EVENTS,Events.CurrentPage);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box and table *****/
|
2017-06-11 22:26:40 +02:00
|
|
|
|
if (ItsANewAttEvent)
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Box_BoxTableBegin (NULL,Txt_New_event,
|
|
|
|
|
NULL,NULL,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
Hlp_USERS_Attendance_new_event,Box_NOT_CLOSABLE,2);
|
2017-06-11 22:26:40 +02:00
|
|
|
|
else
|
2019-11-25 23:18:08 +01:00
|
|
|
|
Box_BoxTableBegin (NULL,
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event.Title[0] ? Event.Title :
|
|
|
|
|
Txt_Edit_event,
|
2020-03-26 02:54:30 +01:00
|
|
|
|
NULL,NULL,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
Hlp_USERS_Attendance_edit_event,Box_NOT_CLOSABLE,2);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Attendance event title *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2019-12-27 21:10:39 +01:00
|
|
|
|
/* Label */
|
2019-12-27 15:45:19 +01:00
|
|
|
|
Frm_LabelColumn ("RT","Title",Txt_Title);
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2019-12-27 21:10:39 +01:00
|
|
|
|
/* Data */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LT\"");
|
2020-04-06 16:00:06 +02:00
|
|
|
|
HTM_INPUT_TEXT ("Title",Att_MAX_CHARS_ATTENDANCE_EVENT_TITLE,Event.Title,false,
|
2019-11-27 00:27:42 +01:00
|
|
|
|
"id=\"Title\" required=\"required\""
|
|
|
|
|
" class=\"TITLE_DESCRIPTION_WIDTH\"");
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2015-10-24 21:41:41 +02:00
|
|
|
|
/***** Assignment start and end dates *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Dat_PutFormStartEndClientLocalDateTimes (Event.TimeUTC,
|
2020-02-26 19:35:33 +01:00
|
|
|
|
Dat_FORM_SECONDS_ON,
|
|
|
|
|
SetHMS);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Visibility of comments *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2019-12-27 21:10:39 +01:00
|
|
|
|
/* Label */
|
2019-12-27 15:45:19 +01:00
|
|
|
|
Frm_LabelColumn ("RT","ComTchVisible",Txt_Teachers_comment);
|
2019-10-06 12:00:55 +02:00
|
|
|
|
|
2019-12-27 21:10:39 +01:00
|
|
|
|
/* Data */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LT\"");
|
2019-12-27 15:45:19 +01:00
|
|
|
|
HTM_SELECT_Begin (false,"id=\"ComTchVisible\" name=\"ComTchVisible\"");
|
2020-04-06 16:00:06 +02:00
|
|
|
|
HTM_OPTION (HTM_Type_STRING,"N",!Event.CommentTchVisible,false,
|
2019-11-05 23:11:31 +01:00
|
|
|
|
"%s",Txt_Hidden_MALE_PLURAL);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
HTM_OPTION (HTM_Type_STRING,"Y",Event.CommentTchVisible,false,
|
2019-11-05 23:11:31 +01:00
|
|
|
|
"%s",Txt_Visible_MALE_PLURAL);
|
2019-11-05 08:46:38 +01:00
|
|
|
|
HTM_SELECT_End ();
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-12-27 21:10:39 +01:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Attendance event description *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2019-12-27 21:10:39 +01:00
|
|
|
|
/* Label */
|
2019-12-27 15:45:19 +01:00
|
|
|
|
Frm_LabelColumn ("RT","Txt",Txt_Description);
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2019-12-27 21:10:39 +01:00
|
|
|
|
/* Data */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LT\"");
|
2019-11-27 00:27:42 +01:00
|
|
|
|
HTM_TEXTAREA_Begin ("id=\"Txt\" name=\"Txt\" rows=\"5\""
|
|
|
|
|
" class=\"TITLE_DESCRIPTION_WIDTH\"");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (!ItsANewAttEvent)
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (Description);
|
2019-10-31 17:42:05 +01:00
|
|
|
|
HTM_TEXTAREA_End ();
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Groups *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_ShowLstGrpsToEditAttEvent (Event.AttCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End table, send button and end box *****/
|
2015-03-24 17:47:26 +01:00
|
|
|
|
if (ItsANewAttEvent)
|
2019-11-25 23:18:08 +01:00
|
|
|
|
Box_BoxTableWithButtonEnd (Btn_CREATE_BUTTON,Txt_Create_event);
|
2015-03-24 17:47:26 +01:00
|
|
|
|
else
|
2019-11-25 23:18:08 +01:00
|
|
|
|
Box_BoxTableWithButtonEnd (Btn_CONFIRM_BUTTON,Txt_Save_changes);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2015-04-11 17:33:14 +02:00
|
|
|
|
/***** End form *****/
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Show current attendance events *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_GetListAttEvents (&Events,Att_NEWEST_FIRST);
|
|
|
|
|
Att_ShowAllAttEvents (&Events);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************* Show list of groups to edit and attendance event **************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Att_ShowLstGrpsToEditAttEvent (long AttCod)
|
|
|
|
|
{
|
2019-02-22 21:47:50 +01:00
|
|
|
|
extern const char *The_ClassFormInBox[The_NUM_THEMES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Groups;
|
|
|
|
|
extern const char *Txt_The_whole_course;
|
|
|
|
|
unsigned NumGrpTyp;
|
|
|
|
|
|
|
|
|
|
/***** Get list of groups types and groups in this course *****/
|
|
|
|
|
Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_ONLY_GROUP_TYPES_WITH_GROUPS);
|
|
|
|
|
|
2019-04-04 10:45:15 +02:00
|
|
|
|
if (Gbl.Crs.Grps.GrpTypes.Num)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box and table *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"%s RT\"",The_ClassFormInBox[Gbl.Prefs.Theme]);
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF ("%s:",Txt_Groups);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LT\"");
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Box_BoxTableBegin ("100%",NULL,
|
|
|
|
|
NULL,NULL,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
NULL,Box_NOT_CLOSABLE,0);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** First row: checkbox to select the whole course *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("colspan=\"7\" class=\"DAT LM\"");
|
2019-11-03 10:41:31 +01:00
|
|
|
|
HTM_LABEL_Begin (NULL);
|
2020-03-12 13:53:37 +01:00
|
|
|
|
HTM_INPUT_CHECKBOX ("WholeCrs",HTM_DONT_SUBMIT_ON_CHANGE,
|
2019-11-04 20:41:35 +01:00
|
|
|
|
"id=\"WholeCrs\" value=\"Y\"%s"
|
|
|
|
|
" onclick=\"uncheckChildren(this,'GrpCods')\"",
|
|
|
|
|
Att_CheckIfAttEventIsAssociatedToGrps (AttCod) ? "" : " checked=\"checked\"");
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF ("%s %s",Txt_The_whole_course,Gbl.Hierarchy.Crs.ShrtName);
|
2019-11-02 12:59:31 +01:00
|
|
|
|
HTM_LABEL_End ();
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** List the groups for each group type *****/
|
|
|
|
|
for (NumGrpTyp = 0;
|
2019-04-04 10:45:15 +02:00
|
|
|
|
NumGrpTyp < Gbl.Crs.Grps.GrpTypes.Num;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
NumGrpTyp++)
|
2019-04-04 10:45:15 +02:00
|
|
|
|
if (Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps)
|
2019-05-28 15:06:53 +02:00
|
|
|
|
Grp_ListGrpsToEditAsgAttSvyMch (&Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp],
|
2019-04-03 20:57:04 +02:00
|
|
|
|
AttCod,Grp_ATT_EVENT);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End table and box *****/
|
2019-11-25 23:18:08 +01:00
|
|
|
|
Box_BoxTableEnd ();
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free list of groups types and groups in this course *****/
|
|
|
|
|
Grp_FreeListGrpTypesAndGrps ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Receive form to create a new attendance event ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Att_RecFormAttEvent (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Already_existed_an_event_with_the_title_X;
|
|
|
|
|
extern const char *Txt_You_must_specify_the_title_of_the_event;
|
|
|
|
|
extern const char *Txt_Created_new_event_X;
|
|
|
|
|
extern const char *Txt_The_event_has_been_modified;
|
2020-04-06 16:00:06 +02:00
|
|
|
|
struct Att_Event OldAtt;
|
|
|
|
|
struct Att_Event ReceivedAtt;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool ItsANewAttEvent;
|
2016-09-07 18:02:25 +02:00
|
|
|
|
bool ReceivedAttEventIsCorrect = true;
|
2019-02-15 21:09:18 +01:00
|
|
|
|
char Description[Cns_MAX_BYTES_TEXT + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get the code of the attendance event *****/
|
2016-09-07 18:02:25 +02:00
|
|
|
|
ItsANewAttEvent = ((ReceivedAtt.AttCod = Att_GetParamAttCod ()) == -1L);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
if (!ItsANewAttEvent)
|
|
|
|
|
{
|
|
|
|
|
/* Get data of the old (current) attendance event from database */
|
2016-09-07 18:02:25 +02:00
|
|
|
|
OldAtt.AttCod = ReceivedAtt.AttCod;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Att_GetDataOfAttEventByCodAndCheckCrs (&OldAtt);
|
2016-09-19 22:03:58 +02:00
|
|
|
|
ReceivedAtt.Hidden = OldAtt.Hidden;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2015-10-23 13:20:42 +02:00
|
|
|
|
/***** Get start/end date-times *****/
|
2016-09-07 18:02:25 +02:00
|
|
|
|
ReceivedAtt.TimeUTC[Att_START_TIME] = Dat_GetTimeUTCFromForm ("StartTimeUTC");
|
|
|
|
|
ReceivedAtt.TimeUTC[Att_END_TIME ] = Dat_GetTimeUTCFromForm ("EndTimeUTC" );
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get boolean parameter that indicates if teacher's comments are visible by students *****/
|
2017-01-28 20:32:50 +01:00
|
|
|
|
ReceivedAtt.CommentTchVisible = Par_GetParToBool ("ComTchVisible");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get attendance event title *****/
|
2017-03-07 01:56:41 +01:00
|
|
|
|
Par_GetParToText ("Title",ReceivedAtt.Title,Att_MAX_BYTES_ATTENDANCE_EVENT_TITLE);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-02-15 21:09:18 +01:00
|
|
|
|
/***** Get attendance event description *****/
|
|
|
|
|
Par_GetParToHTML ("Txt",Description,Cns_MAX_BYTES_TEXT); // Store in HTML format (not rigorous)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Adjust dates *****/
|
2016-09-07 18:02:25 +02:00
|
|
|
|
if (ReceivedAtt.TimeUTC[Att_START_TIME] == 0)
|
|
|
|
|
ReceivedAtt.TimeUTC[Att_START_TIME] = Gbl.StartExecutionTimeUTC;
|
|
|
|
|
if (ReceivedAtt.TimeUTC[Att_END_TIME] == 0)
|
2017-01-28 15:58:46 +01:00
|
|
|
|
ReceivedAtt.TimeUTC[Att_END_TIME] = ReceivedAtt.TimeUTC[Att_START_TIME] + 2 * 60 * 60; // +2 hours // TODO: 2 * 60 * 60 should be in a #define in swad_config.h
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Check if title is correct *****/
|
2016-09-07 18:02:25 +02:00
|
|
|
|
if (ReceivedAtt.Title[0]) // If there's an attendance event title
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/* If title of attendance event was in database... */
|
2016-09-07 18:02:25 +02:00
|
|
|
|
if (Att_CheckIfSimilarAttEventExists ("Title",ReceivedAtt.Title,ReceivedAtt.AttCod))
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2016-09-07 18:02:25 +02:00
|
|
|
|
ReceivedAttEventIsCorrect = false;
|
2019-02-15 23:38:44 +01:00
|
|
|
|
|
2019-02-16 14:37:34 +01:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_Already_existed_an_event_with_the_title_X,
|
2019-02-15 23:38:44 +01:00
|
|
|
|
ReceivedAtt.Title);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // If there is not an attendance event title
|
|
|
|
|
{
|
2016-09-07 18:02:25 +02:00
|
|
|
|
ReceivedAttEventIsCorrect = false;
|
2019-02-16 14:37:34 +01:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_You_must_specify_the_title_of_the_event);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Create a new attendance event or update an existing one *****/
|
2016-09-07 18:02:25 +02:00
|
|
|
|
if (ReceivedAttEventIsCorrect)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/* Get groups for this attendance events */
|
2017-01-19 20:55:31 +01:00
|
|
|
|
Grp_GetParCodsSeveralGrps ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
if (ItsANewAttEvent)
|
|
|
|
|
{
|
2016-09-07 18:02:25 +02:00
|
|
|
|
ReceivedAtt.Hidden = false; // New attendance events are visible by default
|
2019-02-15 21:09:18 +01:00
|
|
|
|
Att_CreateAttEvent (&ReceivedAtt,Description); // Add new attendance event to database
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write success message *****/
|
2019-02-16 14:37:34 +01:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_Created_new_event_X,
|
2019-02-15 23:38:44 +01:00
|
|
|
|
ReceivedAtt.Title);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-02-15 21:09:18 +01:00
|
|
|
|
Att_UpdateAttEvent (&ReceivedAtt,Description);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write success message *****/
|
2019-02-16 14:37:34 +01:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_The_event_has_been_modified);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Free memory for list of selected groups */
|
|
|
|
|
Grp_FreeListCodSelectedGrps ();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
Att_RequestCreatOrEditAttEvent ();
|
|
|
|
|
|
|
|
|
|
/***** Show attendance events again *****/
|
|
|
|
|
Att_SeeAttEvents ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Create a new attendance event *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
void Att_CreateAttEvent (struct Att_Event *Event,const char *Description)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Create a new attendance event *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event->AttCod =
|
2018-11-03 01:45:36 +01:00
|
|
|
|
DB_QueryINSERTandReturnCode ("can not create new attendance event",
|
|
|
|
|
"INSERT INTO att_events"
|
|
|
|
|
" (CrsCod,Hidden,UsrCod,"
|
|
|
|
|
"StartTime,EndTime,CommentTchVisible,Title,Txt)"
|
|
|
|
|
" VALUES"
|
|
|
|
|
" (%ld,'%c',%ld,"
|
|
|
|
|
"FROM_UNIXTIME(%ld),FROM_UNIXTIME(%ld),'%c','%s','%s')",
|
2019-04-04 10:45:15 +02:00
|
|
|
|
Gbl.Hierarchy.Crs.CrsCod,
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event->Hidden ? 'Y' :
|
2018-11-03 01:45:36 +01:00
|
|
|
|
'N',
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event->TimeUTC[Att_START_TIME],
|
|
|
|
|
Event->TimeUTC[Att_END_TIME ],
|
|
|
|
|
Event->CommentTchVisible ? 'Y' :
|
2018-11-03 01:45:36 +01:00
|
|
|
|
'N',
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event->Title,
|
2019-02-15 21:09:18 +01:00
|
|
|
|
Description);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Create groups *****/
|
2019-04-04 10:45:15 +02:00
|
|
|
|
if (Gbl.Crs.Grps.LstGrpsSel.NumGrps)
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_CreateGrps (Event->AttCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Update an existing attendance event **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
void Att_UpdateAttEvent (struct Att_Event *Event,const char *Description)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Update the data of the attendance event *****/
|
2018-11-03 12:16:40 +01:00
|
|
|
|
DB_QueryUPDATE ("can not update attendance event",
|
|
|
|
|
"UPDATE att_events SET "
|
|
|
|
|
"Hidden='%c',"
|
|
|
|
|
"StartTime=FROM_UNIXTIME(%ld),"
|
|
|
|
|
"EndTime=FROM_UNIXTIME(%ld),"
|
|
|
|
|
"CommentTchVisible='%c',Title='%s',Txt='%s'"
|
|
|
|
|
" WHERE AttCod=%ld AND CrsCod=%ld",
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event->Hidden ? 'Y' :
|
2018-11-03 12:16:40 +01:00
|
|
|
|
'N',
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event->TimeUTC[Att_START_TIME],
|
|
|
|
|
Event->TimeUTC[Att_END_TIME ],
|
|
|
|
|
Event->CommentTchVisible ? 'Y' :
|
2018-11-03 12:16:40 +01:00
|
|
|
|
'N',
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event->Title,
|
2019-02-15 21:09:18 +01:00
|
|
|
|
Description,
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event->AttCod,Gbl.Hierarchy.Crs.CrsCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Update groups *****/
|
|
|
|
|
/* Remove old groups */
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_RemoveAllTheGrpsAssociatedToAnAttEvent (Event->AttCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Create new groups */
|
2019-04-04 10:45:15 +02:00
|
|
|
|
if (Gbl.Crs.Grps.LstGrpsSel.NumGrps)
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_CreateGrps (Event->AttCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******** Check if an attendance event is associated to any group ************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
bool Att_CheckIfAttEventIsAssociatedToGrps (long AttCod)
|
|
|
|
|
{
|
|
|
|
|
/***** Get if an attendance event is associated to a group from database *****/
|
2018-11-03 13:13:11 +01:00
|
|
|
|
return (DB_QueryCOUNT ("can not check if an attendance event"
|
|
|
|
|
" is associated to groups",
|
|
|
|
|
"SELECT COUNT(*) FROM att_grp WHERE AttCod=%ld",
|
|
|
|
|
AttCod) != 0);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********* Check if an attendance event is associated to a group *************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
bool Att_CheckIfAttEventIsAssociatedToGrp (long AttCod,long GrpCod)
|
|
|
|
|
{
|
|
|
|
|
/***** Get if an attendance event is associated to a group from database *****/
|
2018-11-03 13:13:11 +01:00
|
|
|
|
return (DB_QueryCOUNT ("can not check if an attendance event"
|
|
|
|
|
" is associated to a group",
|
|
|
|
|
"SELECT COUNT(*) FROM att_grp"
|
|
|
|
|
" WHERE AttCod=%ld AND GrpCod=%ld",
|
|
|
|
|
AttCod,GrpCod) != 0);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Remove groups of an attendance event *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Att_RemoveAllTheGrpsAssociatedToAnAttEvent (long AttCod)
|
|
|
|
|
{
|
|
|
|
|
/***** Remove groups of the attendance event *****/
|
2018-11-02 22:00:31 +01:00
|
|
|
|
DB_QueryDELETE ("can not remove the groups"
|
|
|
|
|
" associated to an attendance event",
|
|
|
|
|
"DELETE FROM att_grp WHERE AttCod=%ld",
|
|
|
|
|
AttCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************* Remove one group from all the attendance events ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Att_RemoveGroup (long GrpCod)
|
|
|
|
|
{
|
|
|
|
|
/***** Remove group from all the attendance events *****/
|
2018-11-02 22:00:31 +01:00
|
|
|
|
DB_QueryDELETE ("can not remove group from the associations"
|
|
|
|
|
" between attendance events and groups",
|
|
|
|
|
"DELETE FROM att_grp WHERE GrpCod=%ld",
|
|
|
|
|
GrpCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******** Remove groups of one type from all the attendance events ***********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Att_RemoveGroupsOfType (long GrpTypCod)
|
|
|
|
|
{
|
|
|
|
|
/***** Remove group from all the attendance events *****/
|
2018-11-02 22:00:31 +01:00
|
|
|
|
DB_QueryDELETE ("can not remove groups of a type from the associations"
|
|
|
|
|
" between attendance events and groups",
|
|
|
|
|
"DELETE FROM att_grp USING crs_grp,att_grp"
|
|
|
|
|
" WHERE crs_grp.GrpTypCod=%ld"
|
|
|
|
|
" AND crs_grp.GrpCod=att_grp.GrpCod",
|
|
|
|
|
GrpTypCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Create groups of an attendance event **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Att_CreateGrps (long AttCod)
|
|
|
|
|
{
|
|
|
|
|
unsigned NumGrpSel;
|
|
|
|
|
|
|
|
|
|
/***** Create groups of the attendance event *****/
|
|
|
|
|
for (NumGrpSel = 0;
|
2019-04-04 10:45:15 +02:00
|
|
|
|
NumGrpSel < Gbl.Crs.Grps.LstGrpsSel.NumGrps;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
NumGrpSel++)
|
|
|
|
|
/* Create group */
|
2018-11-02 19:37:11 +01:00
|
|
|
|
DB_QueryINSERT ("can not associate a group to an attendance event",
|
|
|
|
|
"INSERT INTO att_grp"
|
|
|
|
|
" (AttCod,GrpCod)"
|
|
|
|
|
" VALUES"
|
|
|
|
|
" (%ld,%ld)",
|
|
|
|
|
AttCod,
|
2019-04-04 10:45:15 +02:00
|
|
|
|
Gbl.Crs.Grps.LstGrpsSel.GrpCods[NumGrpSel]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****** Get and write the names of the groups of an attendance event *********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_GetAndWriteNamesOfGrpsAssociatedToAttEvent (struct Att_Event *Event)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Group;
|
|
|
|
|
extern const char *Txt_Groups;
|
|
|
|
|
extern const char *Txt_and;
|
|
|
|
|
extern const char *Txt_The_whole_course;
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumGrp;
|
|
|
|
|
unsigned NumGrps;
|
|
|
|
|
|
|
|
|
|
/***** Get groups associated to an attendance event from database *****/
|
2018-10-30 13:59:37 +01:00
|
|
|
|
NumGrps = (unsigned) DB_QuerySELECT (&mysql_res,"can not get groups of an attendance event",
|
2019-01-07 21:52:19 +01:00
|
|
|
|
"SELECT crs_grp_types.GrpTypName,"
|
|
|
|
|
"crs_grp.GrpName,"
|
|
|
|
|
"classrooms.ShortName"
|
|
|
|
|
" FROM (att_grp,crs_grp,crs_grp_types)"
|
|
|
|
|
" LEFT JOIN classrooms"
|
|
|
|
|
" ON crs_grp.ClaCod=classrooms.ClaCod"
|
2018-10-30 13:59:37 +01:00
|
|
|
|
" WHERE att_grp.AttCod=%ld"
|
|
|
|
|
" AND att_grp.GrpCod=crs_grp.GrpCod"
|
|
|
|
|
" AND crs_grp.GrpTypCod=crs_grp_types.GrpTypCod"
|
|
|
|
|
" ORDER BY crs_grp_types.GrpTypName,crs_grp.GrpName",
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event->AttCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write heading *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
HTM_DIV_Begin ("class=\"%s\"",Event->Hidden ? "ASG_GRP_LIGHT" :
|
2019-10-23 21:37:01 +02:00
|
|
|
|
"ASG_GRP");
|
2020-01-11 15:22:02 +01:00
|
|
|
|
HTM_TxtColonNBSP (NumGrps == 1 ? Txt_Group :
|
|
|
|
|
Txt_Groups);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write groups *****/
|
|
|
|
|
if (NumGrps) // Groups found...
|
|
|
|
|
{
|
|
|
|
|
/* Get and write the group types and names */
|
|
|
|
|
for (NumGrp = 0;
|
|
|
|
|
NumGrp < NumGrps;
|
|
|
|
|
NumGrp++)
|
|
|
|
|
{
|
|
|
|
|
/* Get next group */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
2019-01-07 21:52:19 +01:00
|
|
|
|
/* Write group type name (row[0]) and group name (row[1]) */
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF ("%s %s",row[0],row[1]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-01-07 21:52:19 +01:00
|
|
|
|
/* Write the name of the classroom (row[2]) */
|
|
|
|
|
if (row[2]) // May be NULL because of LEFT JOIN
|
|
|
|
|
if (row[2][0])
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF (" (%s)",row[2]);
|
2019-01-07 21:52:19 +01:00
|
|
|
|
|
|
|
|
|
/* Write separator */
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (NumGrps >= 2)
|
|
|
|
|
{
|
2019-01-07 21:52:19 +01:00
|
|
|
|
if (NumGrp == NumGrps - 2)
|
2019-11-11 00:15:44 +01:00
|
|
|
|
HTM_TxtF (" %s ",Txt_and);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (NumGrps >= 3)
|
2019-01-07 21:52:19 +01:00
|
|
|
|
if (NumGrp < NumGrps - 2)
|
2019-11-10 13:51:07 +01:00
|
|
|
|
HTM_Txt (", ");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF ("%s %s",Txt_The_whole_course,Gbl.Hierarchy.Crs.ShrtName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-10-23 20:07:56 +02:00
|
|
|
|
HTM_DIV_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-06 18:29:13 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********** Remove all users registered in an attendance event **************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Att_RemoveAllUsrsFromAnAttEvent (long AttCod)
|
|
|
|
|
{
|
2018-11-02 22:00:31 +01:00
|
|
|
|
DB_QueryDELETE ("can not remove attendance event",
|
|
|
|
|
"DELETE FROM att_usr WHERE AttCod=%ld",
|
|
|
|
|
AttCod);
|
2016-09-06 18:29:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/* Remove one user from all the attendance events where he/she is registered */
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Att_RemoveUsrFromAllAttEvents (long UsrCod)
|
|
|
|
|
{
|
|
|
|
|
/***** Remove group from all the attendance events *****/
|
2018-11-02 22:00:31 +01:00
|
|
|
|
DB_QueryDELETE ("can not remove user from all attendance events",
|
|
|
|
|
"DELETE FROM att_usr WHERE UsrCod=%ld",
|
|
|
|
|
UsrCod);
|
2016-09-06 18:29:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********** Remove one student from all the attendance events ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Att_RemoveUsrFromCrsAttEvents (long UsrCod,long CrsCod)
|
|
|
|
|
{
|
|
|
|
|
/***** Remove group from all the attendance events *****/
|
2018-11-02 22:00:31 +01:00
|
|
|
|
DB_QueryDELETE ("can not remove user from attendance events of a course",
|
|
|
|
|
"DELETE FROM att_usr USING att_events,att_usr"
|
|
|
|
|
" WHERE att_events.CrsCod=%ld"
|
|
|
|
|
" AND att_events.AttCod=att_usr.AttCod"
|
|
|
|
|
" AND att_usr.UsrCod=%ld",
|
|
|
|
|
CrsCod,UsrCod);
|
2016-09-06 18:29:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********************** Remove an attendance event **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Att_RemoveAttEventFromCurrentCrs (long AttCod)
|
|
|
|
|
{
|
2018-11-02 22:00:31 +01:00
|
|
|
|
DB_QueryDELETE ("can not remove attendance event",
|
|
|
|
|
"DELETE FROM att_events"
|
|
|
|
|
" WHERE AttCod=%ld AND CrsCod=%ld",
|
2019-04-04 10:45:15 +02:00
|
|
|
|
AttCod,Gbl.Hierarchy.Crs.CrsCod);
|
2016-09-06 18:29:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Remove all the attendance events of a course ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Att_RemoveCrsAttEvents (long CrsCod)
|
|
|
|
|
{
|
|
|
|
|
/***** Remove students *****/
|
2018-11-02 22:00:31 +01:00
|
|
|
|
DB_QueryDELETE ("can not remove all the students registered"
|
|
|
|
|
" in events of a course",
|
|
|
|
|
"DELETE FROM att_usr USING att_events,att_usr"
|
|
|
|
|
" WHERE att_events.CrsCod=%ld"
|
|
|
|
|
" AND att_events.AttCod=att_usr.AttCod",
|
|
|
|
|
CrsCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Remove groups *****/
|
2018-11-02 22:00:31 +01:00
|
|
|
|
DB_QueryDELETE ("can not remove all the groups associated"
|
|
|
|
|
" to attendance events of a course",
|
|
|
|
|
"DELETE FROM att_grp USING att_events,att_grp"
|
|
|
|
|
" WHERE att_events.CrsCod=%ld"
|
|
|
|
|
" AND att_events.AttCod=att_grp.AttCod",
|
|
|
|
|
CrsCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Remove attendance events *****/
|
2018-11-02 22:00:31 +01:00
|
|
|
|
DB_QueryDELETE ("can not remove all the attendance events of a course",
|
|
|
|
|
"DELETE FROM att_events WHERE CrsCod=%ld",
|
|
|
|
|
CrsCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Get number of attendance events in a course *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
unsigned Att_GetNumAttEventsInCrs (long CrsCod)
|
|
|
|
|
{
|
|
|
|
|
/***** Get number of attendance events in a course from database *****/
|
2018-11-03 13:13:11 +01:00
|
|
|
|
return
|
|
|
|
|
(unsigned) DB_QueryCOUNT ("can not get number of attendance events"
|
|
|
|
|
" in course",
|
|
|
|
|
"SELECT COUNT(*) FROM att_events"
|
|
|
|
|
" WHERE CrsCod=%ld",
|
|
|
|
|
CrsCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Get number of courses with attendance events ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
// Returns the number of courses with attendance events
|
|
|
|
|
// in this location (all the platform, current degree or current course)
|
|
|
|
|
|
2019-04-03 20:57:04 +02:00
|
|
|
|
unsigned Att_GetNumCoursesWithAttEvents (Hie_Level_t Scope)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumCourses;
|
|
|
|
|
|
|
|
|
|
/***** Get number of courses with attendance events from database *****/
|
|
|
|
|
switch (Scope)
|
|
|
|
|
{
|
2019-04-03 20:57:04 +02:00
|
|
|
|
case Hie_SYS:
|
2018-10-30 13:59:37 +01:00
|
|
|
|
DB_QuerySELECT (&mysql_res,"can not get number of courses with attendance events",
|
|
|
|
|
"SELECT COUNT(DISTINCT CrsCod)"
|
|
|
|
|
" FROM att_events"
|
|
|
|
|
" WHERE CrsCod>0");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
case Hie_INS:
|
2018-10-30 13:59:37 +01:00
|
|
|
|
DB_QuerySELECT (&mysql_res,"can not get number of courses with attendance events",
|
|
|
|
|
"SELECT COUNT(DISTINCT att_events.CrsCod)"
|
|
|
|
|
" FROM centres,degrees,courses,att_events"
|
|
|
|
|
" WHERE centres.InsCod=%ld"
|
|
|
|
|
" AND centres.CtrCod=degrees.CtrCod"
|
|
|
|
|
" AND degrees.DegCod=courses.DegCod"
|
|
|
|
|
" AND courses.Status=0"
|
|
|
|
|
" AND courses.CrsCod=att_events.CrsCod",
|
2019-04-03 20:57:04 +02:00
|
|
|
|
Gbl.Hierarchy.Ins.InsCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
case Hie_CTR:
|
2018-10-30 13:59:37 +01:00
|
|
|
|
DB_QuerySELECT (&mysql_res,"can not get number of courses with attendance events",
|
|
|
|
|
"SELECT COUNT(DISTINCT att_events.CrsCod)"
|
|
|
|
|
" FROM degrees,courses,att_events"
|
|
|
|
|
" WHERE degrees.CtrCod=%ld"
|
|
|
|
|
" AND degrees.DegCod=courses.DegCod"
|
|
|
|
|
" AND courses.Status=0"
|
|
|
|
|
" AND courses.CrsCod=att_events.CrsCod",
|
2019-04-03 20:57:04 +02:00
|
|
|
|
Gbl.Hierarchy.Ctr.CtrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
case Hie_DEG:
|
2018-10-30 13:59:37 +01:00
|
|
|
|
DB_QuerySELECT (&mysql_res,"can not get number of courses with attendance events",
|
|
|
|
|
"SELECT COUNT(DISTINCT att_events.CrsCod)"
|
|
|
|
|
" FROM courses,att_events"
|
|
|
|
|
" WHERE courses.DegCod=%ld"
|
|
|
|
|
" AND courses.Status=0"
|
|
|
|
|
" AND courses.CrsCod=att_events.CrsCod",
|
2019-04-03 20:57:04 +02:00
|
|
|
|
Gbl.Hierarchy.Deg.DegCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
case Hie_CRS:
|
2018-10-30 13:59:37 +01:00
|
|
|
|
DB_QuerySELECT (&mysql_res,"can not get number of courses with attendance events",
|
|
|
|
|
"SELECT COUNT(DISTINCT CrsCod)"
|
|
|
|
|
" FROM att_events"
|
|
|
|
|
" WHERE CrsCod=%ld",
|
2019-04-04 10:45:15 +02:00
|
|
|
|
Gbl.Hierarchy.Crs.CrsCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2018-10-24 23:03:11 +02:00
|
|
|
|
Lay_WrongScopeExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Get number of courses *****/
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
if (sscanf (row[0],"%u",&NumCourses) != 1)
|
|
|
|
|
Lay_ShowErrorAndExit ("Error when getting number of courses with attendance events.");
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
return NumCourses;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Get number of attendance events ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
// Returns the number of attendance events
|
|
|
|
|
// in this location (all the platform, current degree or current course)
|
|
|
|
|
|
2019-04-03 20:57:04 +02:00
|
|
|
|
unsigned Att_GetNumAttEvents (Hie_Level_t Scope,unsigned *NumNotif)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumAttEvents;
|
|
|
|
|
|
|
|
|
|
/***** Get number of attendance events from database *****/
|
|
|
|
|
switch (Scope)
|
|
|
|
|
{
|
2019-04-03 20:57:04 +02:00
|
|
|
|
case Hie_SYS:
|
2018-10-30 13:59:37 +01:00
|
|
|
|
DB_QuerySELECT (&mysql_res,"can not get number of attendance events",
|
|
|
|
|
"SELECT COUNT(*),SUM(NumNotif)"
|
|
|
|
|
" FROM att_events"
|
|
|
|
|
" WHERE CrsCod>0");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
case Hie_INS:
|
2018-10-30 13:59:37 +01:00
|
|
|
|
DB_QuerySELECT (&mysql_res,"can not get number of attendance events",
|
|
|
|
|
"SELECT COUNT(*),SUM(att_events.NumNotif)"
|
|
|
|
|
" FROM centres,degrees,courses,att_events"
|
|
|
|
|
" WHERE centres.InsCod=%ld"
|
|
|
|
|
" AND centres.CtrCod=degrees.CtrCod"
|
|
|
|
|
" AND degrees.DegCod=courses.DegCod"
|
|
|
|
|
" AND courses.CrsCod=att_events.CrsCod",
|
2019-04-03 20:57:04 +02:00
|
|
|
|
Gbl.Hierarchy.Ins.InsCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
case Hie_CTR:
|
2018-10-30 13:59:37 +01:00
|
|
|
|
DB_QuerySELECT (&mysql_res,"can not get number of attendance events",
|
|
|
|
|
"SELECT COUNT(*),SUM(att_events.NumNotif)"
|
|
|
|
|
" FROM degrees,courses,att_events"
|
|
|
|
|
" WHERE degrees.CtrCod=%ld"
|
|
|
|
|
" AND degrees.DegCod=courses.DegCod"
|
|
|
|
|
" AND courses.CrsCod=att_events.CrsCod",
|
2019-04-03 20:57:04 +02:00
|
|
|
|
Gbl.Hierarchy.Ctr.CtrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
case Hie_DEG:
|
2018-10-30 13:59:37 +01:00
|
|
|
|
DB_QuerySELECT (&mysql_res,"can not get number of attendance events",
|
|
|
|
|
"SELECT COUNT(*),SUM(att_events.NumNotif)"
|
|
|
|
|
" FROM courses,att_events"
|
|
|
|
|
" WHERE courses.DegCod=%ld"
|
|
|
|
|
" AND courses.CrsCod=att_events.CrsCod",
|
2019-04-03 20:57:04 +02:00
|
|
|
|
Gbl.Hierarchy.Deg.DegCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
case Hie_CRS:
|
2018-10-30 13:59:37 +01:00
|
|
|
|
DB_QuerySELECT (&mysql_res,"can not get number of attendance events",
|
|
|
|
|
"SELECT COUNT(*),SUM(NumNotif)"
|
|
|
|
|
" FROM att_events"
|
|
|
|
|
" WHERE CrsCod=%ld",
|
2019-04-04 10:45:15 +02:00
|
|
|
|
Gbl.Hierarchy.Crs.CrsCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2018-10-24 23:03:11 +02:00
|
|
|
|
Lay_WrongScopeExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Get number of attendance events *****/
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
if (sscanf (row[0],"%u",&NumAttEvents) != 1)
|
|
|
|
|
Lay_ShowErrorAndExit ("Error when getting number of attendance events.");
|
|
|
|
|
|
2016-11-16 23:19:52 +01:00
|
|
|
|
/***** Get number of notifications by email *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (row[1])
|
|
|
|
|
{
|
|
|
|
|
if (sscanf (row[1],"%u",NumNotif) != 1)
|
|
|
|
|
Lay_ShowErrorAndExit ("Error when getting number of notifications of attendance events.");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
*NumNotif = 0;
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
return NumAttEvents;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Show one attendance event **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Att_SeeOneAttEvent (void)
|
|
|
|
|
{
|
2020-04-06 16:00:06 +02:00
|
|
|
|
struct Att_Events Events;
|
|
|
|
|
|
|
|
|
|
/***** Reset attendance events *****/
|
|
|
|
|
Att_ResetEvents (&Events);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get attendance event code *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if ((Events.AttCod = Att_GetParamAttCod ()) == -1L)
|
|
|
|
|
Lay_ShowErrorAndExit ("Code of attendance event is missing.");
|
|
|
|
|
|
|
|
|
|
/***** Show event *****/
|
|
|
|
|
Att_ShowEvent (&Events);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void Att_ShowEvent (struct Att_Events *Events)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Hlp_USERS_Attendance;
|
|
|
|
|
extern const char *Txt_Event;
|
|
|
|
|
struct Att_Event Event;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get parameters *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Events->SelectedOrder = Att_GetParamAttOrder ();
|
2020-03-27 14:56:54 +01:00
|
|
|
|
Grp_GetParamWhichGroups ();
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Events->CurrentPage = Pag_GetParamPagNum (Pag_ATT_EVENTS);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box and table *****/
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Box_BoxTableBegin (NULL,Txt_Event,
|
|
|
|
|
NULL,NULL,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
Hlp_USERS_Attendance,Box_NOT_CLOSABLE,2);
|
2017-06-12 14:16:33 +02:00
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event.AttCod = Events->AttCod;
|
|
|
|
|
Att_ShowOneAttEvent (Events,&Event,true);
|
2017-06-12 14:16:33 +02:00
|
|
|
|
|
|
|
|
|
/***** End table and box *****/
|
2019-11-25 23:18:08 +01:00
|
|
|
|
Box_BoxTableEnd ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-06-04 18:18:54 +02:00
|
|
|
|
switch (Gbl.Usrs.Me.Role.Logged)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-05-18 19:13:41 +02:00
|
|
|
|
case Rol_STD:
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_ListAttOnlyMeAsStudent (&Event);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2017-05-21 21:23:13 +02:00
|
|
|
|
case Rol_NET:
|
2017-05-18 19:13:41 +02:00
|
|
|
|
case Rol_TCH:
|
2015-04-07 21:44:24 +02:00
|
|
|
|
case Rol_SYS_ADM:
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Show list of students *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_ListAttStudents (Events,&Event);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********************** List me as student in one event *********************/
|
|
|
|
|
/*****************************************************************************/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
// Event must be filled before calling this function
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_ListAttOnlyMeAsStudent (struct Att_Event *Event)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2016-11-13 21:08:14 +01:00
|
|
|
|
extern const char *Hlp_USERS_Attendance;
|
2019-02-18 18:27:45 +01:00
|
|
|
|
extern const char *Txt_Attendance;
|
2014-12-04 01:19:42 +01:00
|
|
|
|
extern const char *Txt_Student_comment;
|
|
|
|
|
extern const char *Txt_Teachers_comment;
|
2015-03-12 14:45:40 +01:00
|
|
|
|
extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
2019-02-18 18:27:45 +01:00
|
|
|
|
extern const char *Txt_Save_changes;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-03-26 11:53:21 +01:00
|
|
|
|
/***** Get my setting about photos in users' list for current course *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Usr_GetMyPrefAboutListWithPhotosFromDB ();
|
|
|
|
|
|
2019-10-20 22:00:28 +02:00
|
|
|
|
/***** Begin form *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (Event->Open)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartForm (ActRecAttMe);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_PutParamAttCod (Event->AttCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-18 18:27:45 +01:00
|
|
|
|
/***** List students (only me) *****/
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/* Begin box */
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Box_BoxBegin (NULL,Txt_Attendance,
|
|
|
|
|
NULL,NULL,
|
2019-02-18 18:27:45 +01:00
|
|
|
|
Hlp_USERS_Attendance,Box_NOT_CLOSABLE);
|
|
|
|
|
|
2019-10-20 22:00:28 +02:00
|
|
|
|
/* Begin table */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_BeginWideMarginPadding (2);
|
2019-02-18 18:27:45 +01:00
|
|
|
|
|
|
|
|
|
/* Header */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-11 01:02:51 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TH_Empty (3);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (Gbl.Usrs.Listing.WithPhotos)
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TH_Empty (1);
|
|
|
|
|
HTM_TH (1,2,"TIT_TBL LM",Txt_ROLES_SINGUL_Abc[Rol_STD][Usr_SEX_UNKNOWN]);
|
|
|
|
|
HTM_TH (1,1,"LM",Txt_Student_comment);
|
|
|
|
|
HTM_TH (1,1,"LM",Txt_Teachers_comment);
|
2019-10-11 01:02:51 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* List of students (only me) */
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_WriteRowUsrToCallTheRoll (1,&Gbl.Usrs.Me.UsrDat,Event);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-02-18 18:27:45 +01:00
|
|
|
|
/* End table */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-02-18 18:27:45 +01:00
|
|
|
|
/* Send button */
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (Event->Open)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-02-18 18:27:45 +01:00
|
|
|
|
Btn_PutConfirmButton (Txt_Save_changes);
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2019-02-18 18:27:45 +01:00
|
|
|
|
|
|
|
|
|
/* End box */
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Box_BoxEnd ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** List students who attended to one event *********************/
|
|
|
|
|
/*****************************************************************************/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
// Event must be filled before calling this function
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_ListAttStudents (struct Att_Events *Events,
|
|
|
|
|
struct Att_Event *Event)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2016-11-13 21:08:14 +01:00
|
|
|
|
extern const char *Hlp_USERS_Attendance;
|
2015-04-11 17:33:14 +02:00
|
|
|
|
extern const char *Txt_Attendance;
|
2014-12-04 01:19:42 +01:00
|
|
|
|
extern const char *Txt_Student_comment;
|
|
|
|
|
extern const char *Txt_Teachers_comment;
|
2015-03-12 14:45:40 +01:00
|
|
|
|
extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
2019-02-18 18:27:45 +01:00
|
|
|
|
extern const char *Txt_Save_changes;
|
2019-04-11 23:15:40 +02:00
|
|
|
|
unsigned NumUsr;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
struct UsrData UsrDat;
|
|
|
|
|
|
2016-11-25 03:21:02 +01:00
|
|
|
|
/***** Get groups to show ******/
|
|
|
|
|
Grp_GetParCodsSeveralGrpsToShowUsrs ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get and order list of students in this course *****/
|
2019-04-03 20:57:04 +02:00
|
|
|
|
Usr_GetListUsrs (Hie_CRS,Rol_STD);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box *****/
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Box_BoxBegin (NULL,Txt_Attendance,
|
|
|
|
|
NULL,NULL,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
Hlp_USERS_Attendance,Box_NOT_CLOSABLE);
|
2016-11-25 03:21:02 +01:00
|
|
|
|
|
|
|
|
|
/***** Form to select groups *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Grp_ShowFormToSelectSeveralGroups (Att_PutParamSelectedAttCod,Events,
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Grp_MY_GROUPS);
|
2017-05-25 11:04:38 +02:00
|
|
|
|
|
|
|
|
|
/***** Start section with user list *****/
|
2019-10-26 01:56:36 +02:00
|
|
|
|
HTM_SECTION_Begin (Usr_USER_LIST_SECTION_ID);
|
2016-11-25 03:21:02 +01:00
|
|
|
|
|
2017-05-18 19:13:41 +02:00
|
|
|
|
if (Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Get my preference about photos in users' list for current course *****/
|
|
|
|
|
Usr_GetMyPrefAboutListWithPhotosFromDB ();
|
|
|
|
|
|
|
|
|
|
/***** Initialize structure with user's data *****/
|
|
|
|
|
Usr_UsrDataConstructor (&UsrDat);
|
|
|
|
|
|
2019-10-20 22:00:28 +02:00
|
|
|
|
/* Begin form */
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartForm (ActRecAttStd);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_PutParamAttCod (Event->AttCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Grp_PutParamsCodGrps ();
|
|
|
|
|
|
2019-10-20 22:00:28 +02:00
|
|
|
|
/* Begin table */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_BeginWideMarginPadding (2);
|
2017-05-01 12:36:24 +02:00
|
|
|
|
|
2019-02-18 18:27:45 +01:00
|
|
|
|
/* Header */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-11 01:02:51 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TH_Empty (3);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (Gbl.Usrs.Listing.WithPhotos)
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TH_Empty (1);
|
|
|
|
|
HTM_TH (1,2,"LM",Txt_ROLES_SINGUL_Abc[Rol_STD][Usr_SEX_UNKNOWN]);
|
|
|
|
|
HTM_TH (1,1,"LM",Txt_Student_comment);
|
|
|
|
|
HTM_TH (1,1,"LM",Txt_Teachers_comment);
|
2019-10-11 01:02:51 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* List of students */
|
2019-04-11 23:15:40 +02:00
|
|
|
|
for (NumUsr = 0, Gbl.RowEvenOdd = 0;
|
|
|
|
|
NumUsr < Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs;
|
|
|
|
|
NumUsr++)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2016-07-26 02:41:31 +02:00
|
|
|
|
/* Copy user's basic data from list */
|
2019-04-11 23:15:40 +02:00
|
|
|
|
Usr_CopyBasicUsrDataFromList (&UsrDat,&Gbl.Usrs.LstUsrs[Rol_STD].Lst[NumUsr]);
|
2016-07-26 02:41:31 +02:00
|
|
|
|
|
|
|
|
|
/* Get list of user's IDs */
|
|
|
|
|
ID_GetListIDsFromUsrCod (&UsrDat);
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_WriteRowUsrToCallTheRoll (NumUsr + 1,&UsrDat,Event);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-18 18:27:45 +01:00
|
|
|
|
/* End table */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_End ();
|
2016-11-25 03:21:02 +01:00
|
|
|
|
|
|
|
|
|
/* Send button */
|
2019-02-18 18:27:45 +01:00
|
|
|
|
Btn_PutConfirmButton (Txt_Save_changes);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2015-04-11 17:33:14 +02:00
|
|
|
|
/***** End form *****/
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free memory used for user's data *****/
|
|
|
|
|
Usr_UsrDataDestructor (&UsrDat);
|
|
|
|
|
}
|
2017-05-29 21:34:43 +02:00
|
|
|
|
else // Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs == 0
|
|
|
|
|
/***** Show warning indicating no students found *****/
|
2017-05-18 19:13:41 +02:00
|
|
|
|
Usr_ShowWarningNoUsersFound (Rol_STD);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-05-25 11:04:38 +02:00
|
|
|
|
/***** End section with user list *****/
|
2019-10-26 01:56:36 +02:00
|
|
|
|
HTM_SECTION_End ();
|
2017-05-25 11:04:38 +02:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End box *****/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Box_BoxEnd ();
|
2016-11-25 03:21:02 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Free memory for students list *****/
|
2017-05-18 19:13:41 +02:00
|
|
|
|
Usr_FreeUsrsList (Rol_STD);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free memory for list of selected groups *****/
|
|
|
|
|
Grp_FreeListCodSelectedGrps ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2019-04-11 23:15:40 +02:00
|
|
|
|
/************** Write a row of a table with the data of a user ***************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-04-11 23:15:40 +02:00
|
|
|
|
static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr,
|
2017-05-20 12:04:12 +02:00
|
|
|
|
struct UsrData *UsrDat,
|
2020-04-06 16:00:06 +02:00
|
|
|
|
struct Att_Event *Event)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
bool Present;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char PhotoURL[PATH_MAX + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool ShowPhoto;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char CommentStd[Cns_MAX_BYTES_TEXT + 1];
|
|
|
|
|
char CommentTch[Cns_MAX_BYTES_TEXT + 1];
|
2018-10-10 23:56:42 +02:00
|
|
|
|
bool ItsMe;
|
2017-05-20 12:04:12 +02:00
|
|
|
|
bool ICanChangeStdAttendance;
|
|
|
|
|
bool ICanEditStdComment;
|
|
|
|
|
bool ICanEditTchComment;
|
|
|
|
|
|
|
|
|
|
/***** Set who can edit *****/
|
2017-06-04 18:18:54 +02:00
|
|
|
|
switch (Gbl.Usrs.Me.Role.Logged)
|
2017-05-20 12:04:12 +02:00
|
|
|
|
{
|
|
|
|
|
case Rol_STD:
|
|
|
|
|
// A student can see only her/his attendance
|
2018-10-10 23:56:42 +02:00
|
|
|
|
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
|
|
|
|
if (!ItsMe)
|
2017-05-20 12:04:12 +02:00
|
|
|
|
Lay_ShowErrorAndExit ("Wrong call.");
|
|
|
|
|
ICanChangeStdAttendance = false;
|
2020-04-06 16:00:06 +02:00
|
|
|
|
ICanEditStdComment = Event->Open; // Attendance event is open
|
2017-05-20 12:04:12 +02:00
|
|
|
|
ICanEditTchComment = false;
|
|
|
|
|
break;
|
|
|
|
|
case Rol_TCH:
|
|
|
|
|
ICanChangeStdAttendance = true;
|
|
|
|
|
ICanEditStdComment = false;
|
|
|
|
|
ICanEditTchComment = true;
|
|
|
|
|
break;
|
|
|
|
|
case Rol_SYS_ADM:
|
|
|
|
|
ICanChangeStdAttendance = true;
|
|
|
|
|
ICanEditStdComment = false;
|
|
|
|
|
ICanEditTchComment = false;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
ICanChangeStdAttendance = false;
|
|
|
|
|
ICanEditStdComment = false;
|
|
|
|
|
ICanEditTchComment = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-02-13 21:24:54 +01:00
|
|
|
|
/***** Check if this student is already present in the current event *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Present = Att_CheckIfUsrIsPresentInAttEventAndGetComments (Event->AttCod,UsrDat->UsrCod,CommentStd,CommentTch);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-02-13 21:24:54 +01:00
|
|
|
|
/***** Icon to show if the user is already present *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"BT%u\"",Gbl.RowEvenOdd);
|
2019-11-02 23:40:52 +01:00
|
|
|
|
HTM_LABEL_Begin ("for=\"Std%u\"",NumUsr);
|
2019-02-13 21:24:54 +01:00
|
|
|
|
Att_PutCheckOrCross (Present);
|
2019-11-02 12:59:31 +01:00
|
|
|
|
HTM_LABEL_End ();
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Checkbox to select user *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"CT COLOR%u\"",Gbl.RowEvenOdd);
|
2020-03-12 13:53:37 +01:00
|
|
|
|
HTM_INPUT_CHECKBOX ("UsrCodStd",HTM_DONT_SUBMIT_ON_CHANGE,
|
2019-11-04 20:41:35 +01:00
|
|
|
|
"id=\"Std%u\" value=\"%s\"%s%s",
|
|
|
|
|
NumUsr,UsrDat->EncryptedUsrCod,
|
|
|
|
|
Present ? " checked=\"checked\"" : "",
|
|
|
|
|
ICanChangeStdAttendance ? "" : " disabled=\"disabled\"");
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write number of student in the list *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"%s RT COLOR%u\"",
|
2019-10-10 23:14:13 +02:00
|
|
|
|
UsrDat->Accepted ? "DAT_N" :
|
|
|
|
|
"DAT",
|
|
|
|
|
Gbl.RowEvenOdd);
|
2019-11-10 13:31:47 +01:00
|
|
|
|
HTM_Unsigned (NumUsr);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Show student's photo *****/
|
|
|
|
|
if (Gbl.Usrs.Listing.WithPhotos)
|
|
|
|
|
{
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd);
|
2017-01-28 15:58:46 +01:00
|
|
|
|
ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL);
|
2014-12-30 15:14:43 +01:00
|
|
|
|
Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL :
|
|
|
|
|
NULL,
|
2016-01-14 10:31:09 +01:00
|
|
|
|
"PHOTO45x60",Pho_ZOOM,false);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Write user's ID ******/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"%s LT COLOR%u\"",
|
2019-10-10 23:14:13 +02:00
|
|
|
|
UsrDat->Accepted ? "DAT_SMALL_N" :
|
|
|
|
|
"DAT_SMALL",
|
|
|
|
|
Gbl.RowEvenOdd);
|
2017-05-09 20:56:02 +02:00
|
|
|
|
ID_WriteUsrIDs (UsrDat,NULL);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write student's name *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"%s LT COLOR%u\"",
|
2019-10-10 23:14:13 +02:00
|
|
|
|
UsrDat->Accepted ? "DAT_SMALL_N" :
|
|
|
|
|
"DAT_SMALL",
|
|
|
|
|
Gbl.RowEvenOdd);
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (UsrDat->Surname1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (UsrDat->Surname2[0])
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF (" %s",UsrDat->Surname2);
|
2019-11-11 00:15:44 +01:00
|
|
|
|
HTM_TxtF (", %s",UsrDat->FirstName);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Student's comment: write form or text */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT_SMALL LT COLOR%u\"",Gbl.RowEvenOdd);
|
2017-05-20 12:04:12 +02:00
|
|
|
|
if (ICanEditStdComment) // Show with form
|
2019-10-31 17:42:05 +01:00
|
|
|
|
{
|
2019-12-27 19:22:48 +01:00
|
|
|
|
HTM_TEXTAREA_Begin ("name=\"CommentStd%s\" cols=\"40\" rows=\"3\"",
|
|
|
|
|
UsrDat->EncryptedUsrCod);
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (CommentStd);
|
2019-10-31 17:42:05 +01:00
|
|
|
|
HTM_TEXTAREA_End ();
|
|
|
|
|
}
|
2017-05-20 12:04:12 +02:00
|
|
|
|
else // Show without form
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
|
|
|
|
|
CommentStd,Cns_MAX_BYTES_TEXT,false);
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (CommentStd);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Teacher's comment: write form, text or nothing */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT_SMALL LT COLOR%u\"",Gbl.RowEvenOdd);
|
2017-05-20 12:04:12 +02:00
|
|
|
|
if (ICanEditTchComment) // Show with form
|
2019-10-31 17:42:05 +01:00
|
|
|
|
{
|
2019-12-27 19:22:48 +01:00
|
|
|
|
HTM_TEXTAREA_Begin ("name=\"CommentTch%s\" cols=\"40\" rows=\"3\"",
|
|
|
|
|
UsrDat->EncryptedUsrCod);
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (CommentTch);
|
2019-10-31 17:42:05 +01:00
|
|
|
|
HTM_TEXTAREA_End ();
|
|
|
|
|
}
|
2020-04-06 16:00:06 +02:00
|
|
|
|
else if (Event->CommentTchVisible) // Show without form
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
|
|
|
|
|
CommentTch,Cns_MAX_BYTES_TEXT,false);
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (CommentTch);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd;
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-03 19:49:54 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************** Put link to view one attendance event **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_PutLinkAttEvent (struct Att_Event *AttEvent,
|
2018-12-03 19:49:54 +01:00
|
|
|
|
const char *Title,const char *Txt,
|
2019-11-18 09:35:23 +01:00
|
|
|
|
const char *Class)
|
2018-12-03 19:49:54 +01:00
|
|
|
|
{
|
|
|
|
|
Frm_StartForm (ActSeeOneAtt);
|
|
|
|
|
Att_PutParamAttCod (AttEvent->AttCod);
|
|
|
|
|
Att_PutParamsCodGrps (AttEvent->AttCod);
|
2019-11-20 10:17:42 +01:00
|
|
|
|
HTM_BUTTON_SUBMIT_Begin (Title,Class,NULL);
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (Txt);
|
2019-11-18 09:35:23 +01:00
|
|
|
|
HTM_BUTTON_End ();
|
2018-12-03 19:49:54 +01:00
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****** Put parameters with the default groups in an attendance event ********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Att_PutParamsCodGrps (long AttCod)
|
|
|
|
|
{
|
2019-11-03 13:19:32 +01:00
|
|
|
|
extern const char *Par_SEPARATOR_PARAM_MULTIPLE;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumGrp;
|
|
|
|
|
unsigned NumGrps;
|
2019-11-03 13:19:32 +01:00
|
|
|
|
size_t MaxLengthGrpCods;
|
|
|
|
|
char *GrpCods;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get groups associated to an attendance event from database *****/
|
2019-04-04 10:45:15 +02:00
|
|
|
|
if (Gbl.Crs.Grps.NumGrps)
|
2018-10-30 13:59:37 +01:00
|
|
|
|
NumGrps = (unsigned) DB_QuerySELECT (&mysql_res,"can not get groups of an attendance event",
|
|
|
|
|
"SELECT GrpCod FROM att_grp"
|
|
|
|
|
" WHERE att_grp.AttCod=%ld",
|
|
|
|
|
AttCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
|
|
|
|
NumGrps = 0;
|
|
|
|
|
|
|
|
|
|
/***** Get groups *****/
|
|
|
|
|
if (NumGrps) // Groups found...
|
|
|
|
|
{
|
2019-11-03 13:19:32 +01:00
|
|
|
|
MaxLengthGrpCods = NumGrps * (1 + 20) - 1;
|
|
|
|
|
if ((GrpCods = (char *) malloc (MaxLengthGrpCods + 1)) == NULL)
|
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
2019-11-08 01:10:32 +01:00
|
|
|
|
GrpCods[0] = '\0';
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2014-12-08 01:30:47 +01:00
|
|
|
|
/* Get groups */
|
2014-12-01 23:55:08 +01:00
|
|
|
|
for (NumGrp = 0;
|
|
|
|
|
NumGrp < NumGrps;
|
|
|
|
|
NumGrp++)
|
|
|
|
|
{
|
|
|
|
|
/* Get next group */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
2019-11-03 13:19:32 +01:00
|
|
|
|
/* Append group code to list */
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (NumGrp)
|
2019-11-03 13:19:32 +01:00
|
|
|
|
Str_Concat (GrpCods,Par_SEPARATOR_PARAM_MULTIPLE,MaxLengthGrpCods);
|
|
|
|
|
Str_Concat (GrpCods,row[0],MaxLengthGrpCods);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-11-03 13:19:32 +01:00
|
|
|
|
Par_PutHiddenParamString (NULL,"GrpCods",GrpCods);
|
2019-11-06 19:45:20 +01:00
|
|
|
|
free (GrpCods);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
/***** Write the boolean parameter that indicates if all the groups must be listed *****/
|
|
|
|
|
Par_PutHiddenParamChar ("AllGroups",'Y');
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
2019-04-04 10:45:15 +02:00
|
|
|
|
if (Gbl.Crs.Grps.NumGrps)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Save me as students who attended to an event ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Att_RegisterMeAsStdInAttEvent (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Your_comment_has_been_updated;
|
2020-04-06 16:00:06 +02:00
|
|
|
|
struct Att_Events Events;
|
|
|
|
|
struct Att_Event Event;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool Present;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char CommentStd[Cns_MAX_BYTES_TEXT + 1];
|
|
|
|
|
char CommentTch[Cns_MAX_BYTES_TEXT + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
/***** Reset attendance events *****/
|
|
|
|
|
Att_ResetEvents (&Events);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get attendance event code *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if ((Event.AttCod = Att_GetParamAttCod ()) == -1L)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Lay_ShowErrorAndExit ("Code of attendance event is missing.");
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_GetDataOfAttEventByCodAndCheckCrs (&Event); // This checks that event belong to current course
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (Event.Open)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Get comments for this student *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Present = Att_CheckIfUsrIsPresentInAttEventAndGetComments (Event.AttCod,Gbl.Usrs.Me.UsrDat.UsrCod,
|
2018-10-10 23:56:42 +02:00
|
|
|
|
CommentStd,CommentTch);
|
2019-12-30 21:47:07 +01:00
|
|
|
|
Par_GetParToHTML (Str_BuildStringStr ("CommentStd%s",
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.EncryptedUsrCod),
|
|
|
|
|
CommentStd,Cns_MAX_BYTES_TEXT);
|
|
|
|
|
Str_FreeString ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
if (Present ||
|
|
|
|
|
CommentStd[0] ||
|
|
|
|
|
CommentTch[0])
|
|
|
|
|
/***** Register student *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_RegUsrInAttEventChangingComments (Event.AttCod,Gbl.Usrs.Me.UsrDat.UsrCod,
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Present,CommentStd,CommentTch);
|
|
|
|
|
else
|
|
|
|
|
/***** Remove student *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_RemoveUsrFromAttEvent (Event.AttCod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write final message *****/
|
2019-02-16 14:37:34 +01:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_Your_comment_has_been_updated);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Show the attendance event again *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Events.AttCod = Event.AttCod;
|
|
|
|
|
Att_ShowEvent (&Events);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Save students who attended to an event ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/* Algorithm:
|
2017-05-18 19:13:41 +02:00
|
|
|
|
1. Get list of students in the groups selected: Gbl.Usrs.LstUsrs[Rol_STD]
|
2014-12-01 23:55:08 +01:00
|
|
|
|
2. Mark all students in the groups selected setting Remove=true
|
2019-03-11 13:33:34 +01:00
|
|
|
|
3. Get list of students marked as present by me: Gbl.Usrs.Selected.List[Rol_STD]
|
|
|
|
|
4. Loop over the list Gbl.Usrs.Selected.List[Rol_STD],
|
2014-12-01 23:55:08 +01:00
|
|
|
|
that holds the list of the students marked as present,
|
2017-05-18 19:13:41 +02:00
|
|
|
|
marking the students in Gbl.Usrs.LstUsrs[Rol_STD].Lst as Remove=false
|
2014-12-01 23:55:08 +01:00
|
|
|
|
5. Delete from att_usr all the students marked as Remove=true
|
|
|
|
|
6. Replace (insert without duplicated) into att_usr all the students marked as Remove=false
|
|
|
|
|
*/
|
|
|
|
|
void Att_RegisterStudentsInAttEvent (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Presents;
|
|
|
|
|
extern const char *Txt_Absents;
|
2020-04-06 16:00:06 +02:00
|
|
|
|
struct Att_Events Events;
|
|
|
|
|
struct Att_Event Event;
|
2019-04-11 23:15:40 +02:00
|
|
|
|
unsigned NumUsr;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
const char *Ptr;
|
|
|
|
|
bool Present;
|
|
|
|
|
unsigned NumStdsPresent;
|
|
|
|
|
unsigned NumStdsAbsent;
|
|
|
|
|
struct UsrData UsrData;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char CommentStd[Cns_MAX_BYTES_TEXT + 1];
|
|
|
|
|
char CommentTch[Cns_MAX_BYTES_TEXT + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
/***** Reset attendance events *****/
|
|
|
|
|
Att_ResetEvents (&Events);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get attendance event code *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if ((Event.AttCod = Att_GetParamAttCod ()) == -1L)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Lay_ShowErrorAndExit ("Code of attendance event is missing.");
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_GetDataOfAttEventByCodAndCheckCrs (&Event); // This checks that event belong to current course
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get groups selected *****/
|
|
|
|
|
Grp_GetParCodsSeveralGrpsToShowUsrs ();
|
|
|
|
|
|
2017-05-18 19:13:41 +02:00
|
|
|
|
/***** 1. Get list of students in the groups selected: Gbl.Usrs.LstUsrs[Rol_STD] *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/* Get list of students in the groups selected */
|
2019-04-03 20:57:04 +02:00
|
|
|
|
Usr_GetListUsrs (Hie_CRS,Rol_STD);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-05-18 19:13:41 +02:00
|
|
|
|
if (Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs) // If there are students in the groups selected...
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** 2. Mark all students in the groups selected setting Remove=true *****/
|
2019-04-11 23:15:40 +02:00
|
|
|
|
for (NumUsr = 0;
|
|
|
|
|
NumUsr < Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs;
|
|
|
|
|
NumUsr++)
|
|
|
|
|
Gbl.Usrs.LstUsrs[Rol_STD].Lst[NumUsr].Remove = true;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-03-11 13:33:34 +01:00
|
|
|
|
/***** 3. Get list of students marked as present by me: Gbl.Usrs.Selected.List[Rol_STD] *****/
|
2019-11-15 03:34:48 +01:00
|
|
|
|
Usr_GetListsSelectedEncryptedUsrsCods (&Gbl.Usrs.Selected);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Initialize structure with user's data *****/
|
|
|
|
|
Usr_UsrDataConstructor (&UsrData);
|
|
|
|
|
|
2019-03-11 13:33:34 +01:00
|
|
|
|
/***** 4. Loop over the list Gbl.Usrs.Selected.List[Rol_STD],
|
2014-12-01 23:55:08 +01:00
|
|
|
|
that holds the list of the students marked as present,
|
2017-05-18 19:13:41 +02:00
|
|
|
|
marking the students in Gbl.Usrs.LstUsrs[Rol_STD].Lst as Remove=false *****/
|
2019-03-11 13:33:34 +01:00
|
|
|
|
Ptr = Gbl.Usrs.Selected.List[Rol_STD];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
while (*Ptr)
|
|
|
|
|
{
|
2017-03-13 14:22:36 +01:00
|
|
|
|
Par_GetNextStrUntilSeparParamMult (&Ptr,UsrData.EncryptedUsrCod,
|
|
|
|
|
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Usr_GetUsrCodFromEncryptedUsrCod (&UsrData);
|
2016-07-26 02:41:31 +02:00
|
|
|
|
if (UsrData.UsrCod > 0) // Student exists in database
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Mark student to not be removed *****/
|
2019-04-11 23:15:40 +02:00
|
|
|
|
for (NumUsr = 0;
|
|
|
|
|
NumUsr < Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs;
|
|
|
|
|
NumUsr++)
|
|
|
|
|
if (Gbl.Usrs.LstUsrs[Rol_STD].Lst[NumUsr].UsrCod == UsrData.UsrCod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-04-11 23:15:40 +02:00
|
|
|
|
Gbl.Usrs.LstUsrs[Rol_STD].Lst[NumUsr].Remove = false;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break; // Found! Exit loop
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free memory used for user's data *****/
|
|
|
|
|
Usr_UsrDataDestructor (&UsrData);
|
|
|
|
|
|
|
|
|
|
/***** Free memory *****/
|
2016-07-04 14:03:04 +02:00
|
|
|
|
/* Free memory used by list of selected students' codes */
|
2019-11-15 03:34:48 +01:00
|
|
|
|
Usr_FreeListsSelectedEncryptedUsrsCods (&Gbl.Usrs.Selected);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
// 5. Delete from att_usr all the students marked as Remove=true
|
|
|
|
|
// 6. Replace (insert without duplicated) into att_usr all the students marked as Remove=false
|
2019-04-11 23:15:40 +02:00
|
|
|
|
for (NumUsr = 0, NumStdsAbsent = NumStdsPresent = 0;
|
|
|
|
|
NumUsr < Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs;
|
|
|
|
|
NumUsr++)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Get comments for this student *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_CheckIfUsrIsPresentInAttEventAndGetComments (Event.AttCod,Gbl.Usrs.LstUsrs[Rol_STD].Lst[NumUsr].UsrCod,CommentStd,CommentTch);
|
2019-12-30 21:47:07 +01:00
|
|
|
|
Par_GetParToHTML (Str_BuildStringStr ("CommentTch%s",
|
|
|
|
|
Gbl.Usrs.LstUsrs[Rol_STD].Lst[NumUsr].EncryptedUsrCod),
|
|
|
|
|
CommentTch,Cns_MAX_BYTES_TEXT);
|
|
|
|
|
Str_FreeString ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-11 23:15:40 +02:00
|
|
|
|
Present = !Gbl.Usrs.LstUsrs[Rol_STD].Lst[NumUsr].Remove;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
if (Present ||
|
|
|
|
|
CommentStd[0] ||
|
|
|
|
|
CommentTch[0])
|
|
|
|
|
/***** Register student *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_RegUsrInAttEventChangingComments (Event.AttCod,Gbl.Usrs.LstUsrs[Rol_STD].Lst[NumUsr].UsrCod,
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Present,CommentStd,CommentTch);
|
|
|
|
|
else
|
|
|
|
|
/***** Remove student *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_RemoveUsrFromAttEvent (Event.AttCod,Gbl.Usrs.LstUsrs[Rol_STD].Lst[NumUsr].UsrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
if (Present)
|
|
|
|
|
NumStdsPresent++;
|
|
|
|
|
else
|
|
|
|
|
NumStdsAbsent++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free memory for students list *****/
|
2017-05-18 19:13:41 +02:00
|
|
|
|
Usr_FreeUsrsList (Rol_STD);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write final message *****/
|
2019-02-16 14:37:34 +01:00
|
|
|
|
Ale_ShowAlert (Ale_INFO,"%s: %u<br />"
|
2019-02-15 23:38:44 +01:00
|
|
|
|
"%s: %u",
|
|
|
|
|
Txt_Presents,NumStdsPresent,
|
|
|
|
|
Txt_Absents ,NumStdsAbsent );
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2017-05-18 19:13:41 +02:00
|
|
|
|
else // Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs == 0
|
2017-02-09 19:27:18 +01:00
|
|
|
|
/***** Show warning indicating no students found *****/
|
2017-05-18 19:13:41 +02:00
|
|
|
|
Usr_ShowWarningNoUsersFound (Rol_STD);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Show the attendance event again *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Events.AttCod = Event.AttCod;
|
|
|
|
|
Att_ShowEvent (&Events);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free memory for list of groups selected *****/
|
|
|
|
|
Grp_FreeListCodSelectedGrps ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******* Get number of students from a list who attended to an event *********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_GetNumStdsTotalWhoAreInAttEvent (struct Att_Event *Event)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Count number of students registered in an event in database *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event->NumStdsTotal =
|
2018-11-03 13:13:11 +01:00
|
|
|
|
(unsigned) DB_QueryCOUNT ("can not get number of students"
|
|
|
|
|
" who are registered in an event",
|
|
|
|
|
"SELECT COUNT(*) FROM att_usr"
|
|
|
|
|
" WHERE AttCod=%ld AND Present='Y'",
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Event->AttCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2019-11-13 21:31:06 +01:00
|
|
|
|
/********* Get number of users from a list who attended to an event **********/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-11-13 21:31:06 +01:00
|
|
|
|
static unsigned Att_GetNumUsrsFromAListWhoAreInAttEvent (long AttCod,
|
|
|
|
|
long LstSelectedUsrCods[],
|
|
|
|
|
unsigned NumUsrsInList)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-11-14 02:29:18 +01:00
|
|
|
|
char *SubQueryUsrs;
|
2019-11-13 21:31:06 +01:00
|
|
|
|
unsigned NumUsrsInAttEvent;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-11 23:15:40 +02:00
|
|
|
|
if (NumUsrsInList)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-11-13 21:31:06 +01:00
|
|
|
|
/***** Create subquery string *****/
|
|
|
|
|
Usr_CreateSubqueryUsrCods (LstSelectedUsrCods,NumUsrsInList,
|
2019-11-14 02:29:18 +01:00
|
|
|
|
&SubQueryUsrs);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-11-13 21:31:06 +01:00
|
|
|
|
/***** Get number of users in attendance event from database ****/
|
|
|
|
|
NumUsrsInAttEvent =
|
2018-11-04 20:51:38 +01:00
|
|
|
|
(unsigned) DB_QueryCOUNT ("can not get number of students"
|
|
|
|
|
" from a list who are registered in an event",
|
|
|
|
|
"SELECT COUNT(*) FROM att_usr"
|
|
|
|
|
" WHERE AttCod=%ld"
|
|
|
|
|
" AND UsrCod IN (%s) AND Present='Y'",
|
2019-11-14 02:29:18 +01:00
|
|
|
|
AttCod,SubQueryUsrs);
|
2018-11-04 21:28:11 +01:00
|
|
|
|
|
|
|
|
|
/***** Free memory for subquery string *****/
|
2019-11-14 02:29:18 +01:00
|
|
|
|
Usr_FreeSubqueryUsrCods (SubQueryUsrs);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2019-11-13 21:31:06 +01:00
|
|
|
|
else
|
|
|
|
|
NumUsrsInAttEvent = 0;
|
|
|
|
|
|
|
|
|
|
return NumUsrsInAttEvent;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Check if a student attended to an event *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static bool Att_CheckIfUsrIsInTableAttUsr (long AttCod,long UsrCod,bool *Present)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2018-10-30 13:59:37 +01:00
|
|
|
|
unsigned long NumRows;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool InDBTable;
|
|
|
|
|
|
|
|
|
|
/***** Check if a student is registered in an event in database *****/
|
2018-10-30 13:59:37 +01:00
|
|
|
|
NumRows = DB_QuerySELECT (&mysql_res,"can not get if a student"
|
|
|
|
|
" is already registered"
|
|
|
|
|
" in an event",
|
|
|
|
|
"SELECT Present FROM att_usr"
|
|
|
|
|
" WHERE AttCod=%ld AND UsrCod=%ld",
|
|
|
|
|
AttCod,UsrCod);
|
|
|
|
|
if (NumRows)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
InDBTable = true;
|
|
|
|
|
|
|
|
|
|
/* Get row */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/* Get if present (row[0]) */
|
2016-09-07 18:48:10 +02:00
|
|
|
|
*Present = (row[0][0] == 'Y');
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else // User is not present
|
|
|
|
|
{
|
|
|
|
|
InDBTable = false;
|
|
|
|
|
*Present = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
return InDBTable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Check if a student attended to an event *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static bool Att_CheckIfUsrIsPresentInAttEvent (long AttCod,long UsrCod)
|
|
|
|
|
{
|
|
|
|
|
bool Present;
|
|
|
|
|
|
|
|
|
|
Att_CheckIfUsrIsInTableAttUsr (AttCod,UsrCod,&Present);
|
|
|
|
|
|
|
|
|
|
return Present;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Check if a student attended to an event *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-01-17 03:10:43 +01:00
|
|
|
|
static bool Att_CheckIfUsrIsPresentInAttEventAndGetComments (long AttCod,long UsrCod,
|
|
|
|
|
char CommentStd[Cns_MAX_BYTES_TEXT + 1],
|
|
|
|
|
char CommentTch[Cns_MAX_BYTES_TEXT + 1])
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2018-10-30 13:59:37 +01:00
|
|
|
|
unsigned long NumRows;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool Present;
|
|
|
|
|
|
|
|
|
|
/***** Check if a students is registered in an event in database *****/
|
2018-10-30 13:59:37 +01:00
|
|
|
|
NumRows = DB_QuerySELECT (&mysql_res,"can not get if a student"
|
|
|
|
|
" is already registered"
|
|
|
|
|
" in an event",
|
|
|
|
|
"SELECT Present,CommentStd,CommentTch"
|
|
|
|
|
" FROM att_usr"
|
|
|
|
|
" WHERE AttCod=%ld AND UsrCod=%ld",
|
|
|
|
|
AttCod,UsrCod);
|
|
|
|
|
if (NumRows)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/* Get row */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/* Get if present (row[0]) */
|
2016-09-07 18:48:10 +02:00
|
|
|
|
Present = (row[0][0] == 'Y');
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get student's comment (row[1]) */
|
2017-01-17 03:10:43 +01:00
|
|
|
|
Str_Copy (CommentStd,row[1],
|
|
|
|
|
Cns_MAX_BYTES_TEXT);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get teacher's comment (row[2]) */
|
2017-01-17 03:10:43 +01:00
|
|
|
|
Str_Copy (CommentTch,row[2],
|
|
|
|
|
Cns_MAX_BYTES_TEXT);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else // User is not present
|
|
|
|
|
{
|
|
|
|
|
Present = false;
|
|
|
|
|
CommentStd[0] =
|
|
|
|
|
CommentTch[0] = '\0';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
return Present;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******* Register a user in an attendance event not changing comments ********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Att_RegUsrInAttEventNotChangingComments (long AttCod,long UsrCod)
|
|
|
|
|
{
|
|
|
|
|
bool Present;
|
|
|
|
|
|
|
|
|
|
/***** Check if user is already in table att_usr (present or not) *****/
|
|
|
|
|
if (Att_CheckIfUsrIsInTableAttUsr (AttCod,UsrCod,&Present)) // User is in table att_usr
|
|
|
|
|
{
|
|
|
|
|
// If already present ==> nothing to do
|
|
|
|
|
if (!Present)
|
|
|
|
|
/***** Set user as present in database *****/
|
2018-11-03 12:16:40 +01:00
|
|
|
|
DB_QueryUPDATE ("can not set user as present in an event",
|
|
|
|
|
"UPDATE att_usr SET Present='Y'"
|
|
|
|
|
" WHERE AttCod=%ld AND UsrCod=%ld",
|
|
|
|
|
AttCod,UsrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else // User is not in table att_usr
|
|
|
|
|
Att_RegUsrInAttEventChangingComments (AttCod,UsrCod,true,"","");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********* Register a user in an attendance event changing comments **********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Att_RegUsrInAttEventChangingComments (long AttCod,long UsrCod,bool Present,
|
|
|
|
|
const char *CommentStd,const char *CommentTch)
|
|
|
|
|
{
|
|
|
|
|
/***** Register user as assistant to an event in database *****/
|
2018-11-02 16:39:35 +01:00
|
|
|
|
DB_QueryREPLACE ("can not register user in an event",
|
|
|
|
|
"REPLACE INTO att_usr"
|
|
|
|
|
" (AttCod,UsrCod,Present,CommentStd,CommentTch)"
|
|
|
|
|
" VALUES"
|
|
|
|
|
" (%ld,%ld,'%c','%s','%s')",
|
|
|
|
|
AttCod,UsrCod,
|
|
|
|
|
Present ? 'Y' :
|
|
|
|
|
'N',
|
|
|
|
|
CommentStd,
|
|
|
|
|
CommentTch);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Remove a user from an event **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Att_RemoveUsrFromAttEvent (long AttCod,long UsrCod)
|
|
|
|
|
{
|
|
|
|
|
/***** Remove user if there is no comment in database *****/
|
2018-11-02 22:00:31 +01:00
|
|
|
|
DB_QueryDELETE ("can not remove student from an event",
|
|
|
|
|
"DELETE FROM att_usr WHERE AttCod=%ld AND UsrCod=%ld",
|
|
|
|
|
AttCod,UsrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************ Remove users absent without comments from an event *************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Att_RemoveUsrsAbsentWithoutCommentsFromAttEvent (long AttCod)
|
|
|
|
|
{
|
|
|
|
|
/***** Clean table att_usr *****/
|
2018-11-02 22:00:31 +01:00
|
|
|
|
DB_QueryDELETE ("can not remove users absent"
|
|
|
|
|
" without comments from an event",
|
|
|
|
|
"DELETE FROM att_usr"
|
|
|
|
|
" WHERE AttCod=%ld AND Present='N'"
|
|
|
|
|
" AND CommentStd='' AND CommentTch=''",
|
|
|
|
|
AttCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2019-04-11 23:15:40 +02:00
|
|
|
|
/********** Request listing attendance of users to several events ************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-13 16:39:15 +02:00
|
|
|
|
void Att_ReqListUsrsAttendanceCrs (void)
|
|
|
|
|
{
|
|
|
|
|
Att_TypeOfView_t TypeOfView = Att_VIEW_SEL_USR;
|
|
|
|
|
|
|
|
|
|
Att_ReqListOrPrintUsrsAttendanceCrs (&TypeOfView);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void Att_ReqListOrPrintUsrsAttendanceCrs (void *TypeOfView)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2016-11-27 23:08:29 +01:00
|
|
|
|
extern const char *Hlp_USERS_Attendance_attendance_list;
|
2019-04-11 23:15:40 +02:00
|
|
|
|
extern const char *Txt_Attendance_list;
|
2019-03-12 10:28:50 +01:00
|
|
|
|
extern const char *Txt_View_attendance;
|
2020-04-06 16:00:06 +02:00
|
|
|
|
struct Att_Events Events;
|
|
|
|
|
|
2020-04-08 18:18:46 +02:00
|
|
|
|
switch (*((Att_TypeOfView_t *) TypeOfView))
|
2020-04-08 03:06:45 +02:00
|
|
|
|
{
|
|
|
|
|
case Att_VIEW_SEL_USR:
|
|
|
|
|
case Att_PRNT_SEL_USR:
|
|
|
|
|
/***** Reset attendance events *****/
|
|
|
|
|
Att_ResetEvents (&Events);
|
|
|
|
|
|
|
|
|
|
/***** Get list of attendance events *****/
|
|
|
|
|
Att_GetListAttEvents (&Events,Att_OLDEST_FIRST);
|
|
|
|
|
|
|
|
|
|
/***** List users to select some of them *****/
|
|
|
|
|
Usr_PutFormToSelectUsrsToGoToAct (&Gbl.Usrs.Selected,
|
|
|
|
|
ActSeeLstUsrAtt,
|
|
|
|
|
NULL,NULL,
|
|
|
|
|
Txt_Attendance_list,
|
|
|
|
|
Hlp_USERS_Attendance_attendance_list,
|
|
|
|
|
Txt_View_attendance,
|
|
|
|
|
false); // Do not put form with date range
|
|
|
|
|
|
|
|
|
|
/***** Free list of attendance events *****/
|
|
|
|
|
Att_FreeListAttEvents (&Events);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
Lay_WrongTypeOfViewExit ();
|
|
|
|
|
break;
|
|
|
|
|
}
|
2015-11-13 01:27:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********** List my attendance (I am a student) to several events ************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-11-14 17:53:50 +01:00
|
|
|
|
void Att_ListMyAttendanceCrs (void)
|
2015-11-13 01:27:44 +01:00
|
|
|
|
{
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_ListOrPrintMyAttendanceCrs (Att_VIEW_ONLY_ME);
|
2015-11-13 01:27:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-11-14 17:53:50 +01:00
|
|
|
|
void Att_PrintMyAttendanceCrs (void)
|
2015-11-13 01:27:44 +01:00
|
|
|
|
{
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_ListOrPrintMyAttendanceCrs (Att_PRNT_ONLY_ME);
|
2015-11-13 01:27:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_ListOrPrintMyAttendanceCrs (Att_TypeOfView_t TypeOfView)
|
2015-11-13 01:27:44 +01:00
|
|
|
|
{
|
2018-10-18 09:59:38 +02:00
|
|
|
|
extern const char *Hlp_USERS_Attendance_attendance_list;
|
|
|
|
|
extern const char *Txt_Attendance;
|
2020-04-06 16:00:06 +02:00
|
|
|
|
struct Att_Events Events;
|
2015-11-13 01:27:44 +01:00
|
|
|
|
unsigned NumAttEvent;
|
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
switch (TypeOfView)
|
|
|
|
|
{
|
|
|
|
|
case Att_VIEW_ONLY_ME:
|
|
|
|
|
case Att_PRNT_ONLY_ME:
|
|
|
|
|
/***** Reset attendance events *****/
|
|
|
|
|
Att_ResetEvents (&Events);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
/***** Get list of attendance events *****/
|
|
|
|
|
Att_GetListAttEvents (&Events,Att_OLDEST_FIRST);
|
2015-11-13 01:27:44 +01:00
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
/***** Get boolean parameter that indicates if details must be shown *****/
|
|
|
|
|
Events.ShowDetails = Par_GetParToBool ("ShowDetails");
|
2015-11-13 01:27:44 +01:00
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
/***** Get list of groups selected ******/
|
|
|
|
|
Grp_GetParCodsSeveralGrpsToShowUsrs ();
|
2015-11-13 01:27:44 +01:00
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
/***** Get number of students in each event *****/
|
|
|
|
|
for (NumAttEvent = 0;
|
|
|
|
|
NumAttEvent < Events.Num;
|
|
|
|
|
NumAttEvent++)
|
|
|
|
|
/* Get number of students in this event */
|
|
|
|
|
Events.Lst[NumAttEvent].NumStdsFromList =
|
|
|
|
|
Att_GetNumUsrsFromAListWhoAreInAttEvent (Events.Lst[NumAttEvent].AttCod,
|
|
|
|
|
&Gbl.Usrs.Me.UsrDat.UsrCod,1);
|
2015-11-13 01:27:44 +01:00
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
/***** Get list of attendance events selected *****/
|
|
|
|
|
Att_GetListSelectedAttCods (&Events);
|
2015-11-13 01:27:44 +01:00
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
/***** Begin box *****/
|
|
|
|
|
switch (TypeOfView)
|
|
|
|
|
{
|
|
|
|
|
case Att_VIEW_ONLY_ME:
|
|
|
|
|
Box_BoxBegin (NULL,Txt_Attendance,
|
2020-04-08 13:40:21 +02:00
|
|
|
|
Att_PutIconsMyAttList,&Events,
|
2020-04-08 03:06:45 +02:00
|
|
|
|
Hlp_USERS_Attendance_attendance_list,Box_NOT_CLOSABLE);
|
|
|
|
|
break;
|
|
|
|
|
case Att_PRNT_ONLY_ME:
|
|
|
|
|
Box_BoxBegin (NULL,Txt_Attendance,
|
|
|
|
|
NULL,NULL,
|
|
|
|
|
NULL,Box_NOT_CLOSABLE);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
Lay_WrongTypeOfViewExit ();
|
|
|
|
|
break;
|
|
|
|
|
}
|
2018-10-18 09:59:38 +02:00
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
/***** List events to select *****/
|
|
|
|
|
Att_ListEventsToSelect (&Events,TypeOfView);
|
2015-11-13 01:27:44 +01:00
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
/***** Get my preference about photos in users' list for current course *****/
|
|
|
|
|
Usr_GetMyPrefAboutListWithPhotosFromDB ();
|
2015-11-13 01:27:44 +01:00
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
/***** Show table with attendances for every student in list *****/
|
|
|
|
|
Att_ListUsrsAttendanceTable (&Events,TypeOfView,1,&Gbl.Usrs.Me.UsrDat.UsrCod);
|
2015-11-13 01:27:44 +01:00
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
/***** Show details or put button to show details *****/
|
|
|
|
|
if (Events.ShowDetails)
|
|
|
|
|
Att_ListStdsWithAttEventsDetails (&Events,1,&Gbl.Usrs.Me.UsrDat.UsrCod);
|
2018-10-18 09:59:38 +02:00
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
/***** End box *****/
|
|
|
|
|
Box_BoxEnd ();
|
2015-11-13 01:27:44 +01:00
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
/***** Free memory for list of attendance events selected *****/
|
|
|
|
|
free (Events.StrAttCodsSelected);
|
2015-11-13 01:27:44 +01:00
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
/***** Free list of groups selected *****/
|
|
|
|
|
Grp_FreeListCodSelectedGrps ();
|
2015-11-13 01:27:44 +01:00
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
/***** Free list of attendance events *****/
|
|
|
|
|
Att_FreeListAttEvents (&Events);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
Lay_WrongTypeOfViewExit ();
|
|
|
|
|
break;
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2019-04-11 23:15:40 +02:00
|
|
|
|
/*************** List attendance of users to several events ******************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-11-14 17:53:50 +01:00
|
|
|
|
void Att_ListUsrsAttendanceCrs (void)
|
|
|
|
|
{
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_GetUsrsAndListOrPrintAttendanceCrs (Att_VIEW_SEL_USR);
|
2019-11-14 17:53:50 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Att_PrintUsrsAttendanceCrs (void)
|
2015-11-13 01:27:44 +01:00
|
|
|
|
{
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_GetUsrsAndListOrPrintAttendanceCrs (Att_PRNT_SEL_USR);
|
2015-11-13 01:27:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_GetUsrsAndListOrPrintAttendanceCrs (Att_TypeOfView_t TypeOfView)
|
2015-11-13 01:27:44 +01:00
|
|
|
|
{
|
2019-11-15 03:34:48 +01:00
|
|
|
|
Usr_GetSelectedUsrsAndGoToAct (&Gbl.Usrs.Selected,
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_ListOrPrintUsrsAttendanceCrs,&TypeOfView,
|
2020-04-13 16:39:15 +02:00
|
|
|
|
Att_ReqListOrPrintUsrsAttendanceCrs,&TypeOfView);
|
2015-11-13 01:27:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_ListOrPrintUsrsAttendanceCrs (void *TypeOfView)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2018-10-18 09:59:38 +02:00
|
|
|
|
extern const char *Hlp_USERS_Attendance_attendance_list;
|
2019-04-11 23:15:40 +02:00
|
|
|
|
extern const char *Txt_Attendance_list;
|
2020-04-06 16:00:06 +02:00
|
|
|
|
struct Att_Events Events;
|
2019-04-11 23:15:40 +02:00
|
|
|
|
unsigned NumUsrsInList;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
long *LstSelectedUsrCods;
|
2014-12-06 02:21:34 +01:00
|
|
|
|
unsigned NumAttEvent;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-08 18:18:46 +02:00
|
|
|
|
switch (*((Att_TypeOfView_t *) TypeOfView))
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-04-08 03:06:45 +02:00
|
|
|
|
case Att_VIEW_SEL_USR:
|
|
|
|
|
case Att_PRNT_SEL_USR:
|
|
|
|
|
/***** Reset attendance events *****/
|
|
|
|
|
Att_ResetEvents (&Events);
|
2014-12-06 02:21:34 +01:00
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
/***** Get parameters *****/
|
|
|
|
|
/* Get boolean parameter that indicates if details must be shown */
|
|
|
|
|
Events.ShowDetails = Par_GetParToBool ("ShowDetails");
|
2019-11-14 17:53:50 +01:00
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
/* Get list of groups selected */
|
|
|
|
|
Grp_GetParCodsSeveralGrpsToShowUsrs ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
/***** Count number of valid users in list of encrypted user codes *****/
|
|
|
|
|
NumUsrsInList = Usr_CountNumUsrsInListOfSelectedEncryptedUsrCods (&Gbl.Usrs.Selected);
|
2014-12-08 01:30:47 +01:00
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
if (NumUsrsInList)
|
|
|
|
|
{
|
|
|
|
|
/***** Get list of students selected to show their attendances *****/
|
|
|
|
|
Usr_GetListSelectedUsrCods (&Gbl.Usrs.Selected,NumUsrsInList,&LstSelectedUsrCods);
|
|
|
|
|
|
|
|
|
|
/***** Get list of attendance events *****/
|
|
|
|
|
Att_GetListAttEvents (&Events,Att_OLDEST_FIRST);
|
|
|
|
|
|
|
|
|
|
/***** Get number of students in each event *****/
|
|
|
|
|
for (NumAttEvent = 0;
|
|
|
|
|
NumAttEvent < Events.Num;
|
|
|
|
|
NumAttEvent++)
|
|
|
|
|
/* Get number of students in this event */
|
|
|
|
|
Events.Lst[NumAttEvent].NumStdsFromList =
|
|
|
|
|
Att_GetNumUsrsFromAListWhoAreInAttEvent (Events.Lst[NumAttEvent].AttCod,
|
|
|
|
|
LstSelectedUsrCods,NumUsrsInList);
|
|
|
|
|
|
|
|
|
|
/***** Get list of attendance events selected *****/
|
|
|
|
|
Att_GetListSelectedAttCods (&Events);
|
|
|
|
|
|
|
|
|
|
/***** Begin box *****/
|
2020-04-08 18:18:46 +02:00
|
|
|
|
switch (*((Att_TypeOfView_t *) TypeOfView))
|
2020-04-08 03:06:45 +02:00
|
|
|
|
{
|
|
|
|
|
case Att_VIEW_SEL_USR:
|
|
|
|
|
Box_BoxBegin (NULL,Txt_Attendance_list,
|
|
|
|
|
Att_PutIconsStdsAttList,&Events,
|
|
|
|
|
Hlp_USERS_Attendance_attendance_list,Box_NOT_CLOSABLE);
|
|
|
|
|
break;
|
|
|
|
|
case Att_PRNT_SEL_USR:
|
|
|
|
|
Box_BoxBegin (NULL,Txt_Attendance_list,
|
|
|
|
|
NULL,NULL,
|
|
|
|
|
NULL,Box_NOT_CLOSABLE);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
Lay_WrongTypeOfViewExit ();
|
|
|
|
|
}
|
2018-10-18 09:59:38 +02:00
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
/***** List events to select *****/
|
2020-04-08 18:18:46 +02:00
|
|
|
|
Att_ListEventsToSelect (&Events,*((Att_TypeOfView_t *) TypeOfView));
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
/***** Get my preference about photos in users' list for current course *****/
|
|
|
|
|
Usr_GetMyPrefAboutListWithPhotosFromDB ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
/***** Show table with attendances for every student in list *****/
|
2020-04-08 18:18:46 +02:00
|
|
|
|
Att_ListUsrsAttendanceTable (&Events,*((Att_TypeOfView_t *) TypeOfView),
|
|
|
|
|
NumUsrsInList,LstSelectedUsrCods);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
/***** Show details or put button to show details *****/
|
|
|
|
|
if (Events.ShowDetails)
|
|
|
|
|
Att_ListStdsWithAttEventsDetails (&Events,NumUsrsInList,LstSelectedUsrCods);
|
2018-10-18 09:59:38 +02:00
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
/***** End box *****/
|
|
|
|
|
Box_BoxEnd ();
|
2014-12-08 14:29:11 +01:00
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
/***** Free memory for list of attendance events selected *****/
|
|
|
|
|
free (Events.StrAttCodsSelected);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
/***** Free list of attendance events *****/
|
|
|
|
|
Att_FreeListAttEvents (&Events);
|
2019-11-14 17:53:50 +01:00
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
/***** Free list of user codes *****/
|
|
|
|
|
Usr_FreeListSelectedUsrCods (LstSelectedUsrCods);
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
/***** Free list of groups selected *****/
|
|
|
|
|
Grp_FreeListCodSelectedGrps ();
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
Lay_WrongTypeOfViewExit ();
|
|
|
|
|
break;
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-07 02:04:30 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Get list of attendance events selected *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_GetListSelectedAttCods (struct Att_Events *Events)
|
2014-12-07 02:04:30 +01:00
|
|
|
|
{
|
2020-02-17 12:00:39 +01:00
|
|
|
|
size_t MaxSizeListAttCodsSelected;
|
2014-12-07 02:04:30 +01:00
|
|
|
|
unsigned NumAttEvent;
|
|
|
|
|
const char *Ptr;
|
|
|
|
|
long AttCod;
|
2019-11-08 01:10:32 +01:00
|
|
|
|
char LongStr[Cns_MAX_DECIMAL_DIGITS_LONG + 1];
|
2014-12-08 01:30:47 +01:00
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumGrpsInThisEvent;
|
|
|
|
|
unsigned NumGrpInThisEvent;
|
|
|
|
|
long GrpCodInThisEvent;
|
|
|
|
|
unsigned NumGrpSel;
|
2014-12-07 02:04:30 +01:00
|
|
|
|
|
|
|
|
|
/***** Allocate memory for list of attendance events selected *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
MaxSizeListAttCodsSelected = (size_t) Events->Num * (Cns_MAX_DECIMAL_DIGITS_LONG + 1);
|
|
|
|
|
if ((Events->StrAttCodsSelected = (char *) malloc (MaxSizeListAttCodsSelected + 1)) == NULL)
|
2018-10-18 20:06:54 +02:00
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
2014-12-07 02:04:30 +01:00
|
|
|
|
|
|
|
|
|
/***** Get parameter multiple with list of attendance events selected *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Par_GetParMultiToText ("AttCods",Events->StrAttCodsSelected,MaxSizeListAttCodsSelected);
|
2014-12-07 02:04:30 +01:00
|
|
|
|
|
2014-12-08 01:30:47 +01:00
|
|
|
|
/***** Set which attendance events will be shown as selected (checkboxes on) *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (Events->StrAttCodsSelected[0]) // There are events selected
|
2014-12-08 01:30:47 +01:00
|
|
|
|
{
|
|
|
|
|
/* Reset selection */
|
|
|
|
|
for (NumAttEvent = 0;
|
2020-04-06 16:00:06 +02:00
|
|
|
|
NumAttEvent < Events->Num;
|
2014-12-08 01:30:47 +01:00
|
|
|
|
NumAttEvent++)
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Events->Lst[NumAttEvent].Selected = false;
|
2014-12-07 02:04:30 +01:00
|
|
|
|
|
2014-12-08 01:30:47 +01:00
|
|
|
|
/* Set some events as selected */
|
2020-04-06 16:00:06 +02:00
|
|
|
|
for (Ptr = Events->StrAttCodsSelected;
|
2014-12-07 02:04:30 +01:00
|
|
|
|
*Ptr;
|
2020-02-17 12:00:39 +01:00
|
|
|
|
)
|
2014-12-07 02:04:30 +01:00
|
|
|
|
{
|
|
|
|
|
/* Get next attendance event selected */
|
2019-11-08 01:10:32 +01:00
|
|
|
|
Par_GetNextStrUntilSeparParamMult (&Ptr,LongStr,Cns_MAX_DECIMAL_DIGITS_LONG);
|
2014-12-07 02:04:30 +01:00
|
|
|
|
AttCod = Str_ConvertStrCodToLongCod (LongStr);
|
|
|
|
|
|
2014-12-08 01:30:47 +01:00
|
|
|
|
/* Set each event in *StrAttCodsSelected as selected */
|
2014-12-07 02:04:30 +01:00
|
|
|
|
for (NumAttEvent = 0;
|
2020-04-06 16:00:06 +02:00
|
|
|
|
NumAttEvent < Events->Num;
|
2014-12-07 02:04:30 +01:00
|
|
|
|
NumAttEvent++)
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (Events->Lst[NumAttEvent].AttCod == AttCod)
|
2019-11-25 23:18:08 +01:00
|
|
|
|
{
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Events->Lst[NumAttEvent].Selected = true;
|
2019-11-25 23:18:08 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
2014-12-07 02:04:30 +01:00
|
|
|
|
}
|
2014-12-08 01:30:47 +01:00
|
|
|
|
}
|
|
|
|
|
else // No events selected
|
|
|
|
|
{
|
|
|
|
|
/***** Set which events will be marked as selected by default *****/
|
2019-04-04 10:45:15 +02:00
|
|
|
|
if (!Gbl.Crs.Grps.NumGrps || // Course has no groups
|
2014-12-08 01:30:47 +01:00
|
|
|
|
Gbl.Usrs.ClassPhoto.AllGroups) // All groups selected
|
|
|
|
|
/* Set all events as selected */
|
|
|
|
|
for (NumAttEvent = 0;
|
2020-04-06 16:00:06 +02:00
|
|
|
|
NumAttEvent < Events->Num;
|
2014-12-08 01:30:47 +01:00
|
|
|
|
NumAttEvent++)
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Events->Lst[NumAttEvent].Selected = true;
|
2014-12-08 01:30:47 +01:00
|
|
|
|
else // Course has groups and not all of them are selected
|
|
|
|
|
for (NumAttEvent = 0;
|
2020-04-06 16:00:06 +02:00
|
|
|
|
NumAttEvent < Events->Num;
|
2014-12-08 01:30:47 +01:00
|
|
|
|
NumAttEvent++)
|
|
|
|
|
{
|
|
|
|
|
/* Reset selection */
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Events->Lst[NumAttEvent].Selected = false;
|
2014-12-07 02:04:30 +01:00
|
|
|
|
|
2014-12-08 01:30:47 +01:00
|
|
|
|
/* Set this event as selected? */
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (Events->Lst[NumAttEvent].NumStdsFromList) // Some students attended to this event
|
|
|
|
|
Events->Lst[NumAttEvent].Selected = true;
|
2014-12-08 01:30:47 +01:00
|
|
|
|
else // No students attended to this event
|
|
|
|
|
{
|
|
|
|
|
/***** Get groups associated to an attendance event from database *****/
|
2018-10-30 13:59:37 +01:00
|
|
|
|
NumGrpsInThisEvent = (unsigned) DB_QuerySELECT (&mysql_res,"can not get groups"
|
|
|
|
|
" of an attendance event",
|
|
|
|
|
"SELECT GrpCod FROM att_grp"
|
|
|
|
|
" WHERE att_grp.AttCod=%ld",
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Events->Lst[NumAttEvent].AttCod);
|
2014-12-08 01:30:47 +01:00
|
|
|
|
if (NumGrpsInThisEvent) // This event is associated to groups
|
|
|
|
|
/* Get groups associated to this event */
|
|
|
|
|
for (NumGrpInThisEvent = 0;
|
|
|
|
|
NumGrpInThisEvent < NumGrpsInThisEvent &&
|
2020-04-06 16:00:06 +02:00
|
|
|
|
!Events->Lst[NumAttEvent].Selected;
|
2014-12-08 01:30:47 +01:00
|
|
|
|
NumGrpInThisEvent++)
|
|
|
|
|
{
|
|
|
|
|
/* Get next group associated to this event */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
if ((GrpCodInThisEvent = Str_ConvertStrCodToLongCod (row[0])) > 0)
|
|
|
|
|
/* Check if this group is selected */
|
|
|
|
|
for (NumGrpSel = 0;
|
2019-04-04 10:45:15 +02:00
|
|
|
|
NumGrpSel < Gbl.Crs.Grps.LstGrpsSel.NumGrps &&
|
2020-04-06 16:00:06 +02:00
|
|
|
|
!Events->Lst[NumAttEvent].Selected;
|
2014-12-08 01:30:47 +01:00
|
|
|
|
NumGrpSel++)
|
2019-04-04 10:45:15 +02:00
|
|
|
|
if (Gbl.Crs.Grps.LstGrpsSel.GrpCods[NumGrpSel] == GrpCodInThisEvent)
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Events->Lst[NumAttEvent].Selected = true;
|
2014-12-08 01:30:47 +01:00
|
|
|
|
}
|
|
|
|
|
else // This event is not associated to groups
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Events->Lst[NumAttEvent].Selected = true;
|
2014-12-08 01:30:47 +01:00
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-12-07 02:04:30 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-08 14:29:11 +01:00
|
|
|
|
/*****************************************************************************/
|
2018-10-18 11:10:04 +02:00
|
|
|
|
/******* Put contextual icons when listing my assistance (as student) ********/
|
2014-12-08 14:29:11 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_PutIconsMyAttList (void *Events)
|
2014-12-08 14:29:11 +01:00
|
|
|
|
{
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (Events)
|
2020-03-26 02:54:30 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Put icon to print my assistance (as student) to several events *****/
|
|
|
|
|
Ico_PutContextualIconToPrint (ActPrnLstMyAtt,
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_PutFormToPrintMyListParams,Events);
|
2018-10-18 11:10:04 +02:00
|
|
|
|
|
2020-03-26 02:54:30 +01:00
|
|
|
|
/***** Put icon to print my QR code *****/
|
|
|
|
|
QR_PutLinkToPrintQRCode (ActPrnUsrQR,
|
2020-03-27 14:56:54 +01:00
|
|
|
|
Usr_PutParamMyUsrCodEncrypted,Gbl.Usrs.Me.UsrDat.EncryptedUsrCod);
|
2020-03-26 02:54:30 +01:00
|
|
|
|
}
|
2015-04-02 18:39:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_PutFormToPrintMyListParams (void *Events)
|
2015-11-13 01:27:44 +01:00
|
|
|
|
{
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (Events)
|
2020-03-26 02:54:30 +01:00
|
|
|
|
{
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (((struct Att_Events *) Events)->ShowDetails)
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Par_PutHiddenParamChar ("ShowDetails",'Y');
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (((struct Att_Events *) Events)->StrAttCodsSelected)
|
|
|
|
|
if (((struct Att_Events *) Events)->StrAttCodsSelected[0])
|
|
|
|
|
Par_PutHiddenParamString (NULL,"AttCods",((struct Att_Events *) Events)->StrAttCodsSelected);
|
2020-03-26 02:54:30 +01:00
|
|
|
|
}
|
2015-11-13 01:27:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-03-20 02:08:13 +01:00
|
|
|
|
/******** Put icon to print assistance of students to several events *********/
|
2015-11-13 01:27:44 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_PutIconsStdsAttList (void *Events)
|
2015-11-13 01:27:44 +01:00
|
|
|
|
{
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (Events)
|
2020-03-26 02:54:30 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Put icon to print assistance of students to several events *****/
|
|
|
|
|
Ico_PutContextualIconToPrint (ActPrnLstUsrAtt,
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_PutParamsToPrintStdsList,Events);
|
2018-10-18 11:10:04 +02:00
|
|
|
|
|
2020-03-26 02:54:30 +01:00
|
|
|
|
/***** Put icon to print my QR code *****/
|
|
|
|
|
QR_PutLinkToPrintQRCode (ActPrnUsrQR,
|
2020-03-27 14:56:54 +01:00
|
|
|
|
Usr_PutParamMyUsrCodEncrypted,Gbl.Usrs.Me.UsrDat.EncryptedUsrCod);
|
2020-03-26 02:54:30 +01:00
|
|
|
|
}
|
2015-11-13 01:27:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_PutParamsToPrintStdsList (void *Events)
|
2015-04-02 18:39:49 +02:00
|
|
|
|
{
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (Events)
|
2020-03-26 02:54:30 +01:00
|
|
|
|
{
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (((struct Att_Events *) Events)->ShowDetails)
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Par_PutHiddenParamChar ("ShowDetails",'Y');
|
|
|
|
|
Grp_PutParamsCodGrps ();
|
|
|
|
|
Usr_PutHiddenParSelectedUsrsCods (&Gbl.Usrs.Selected);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (((struct Att_Events *) Events)->StrAttCodsSelected)
|
|
|
|
|
if (((struct Att_Events *) Events)->StrAttCodsSelected[0])
|
|
|
|
|
Par_PutHiddenParamString (NULL,"AttCods",((struct Att_Events *) Events)->StrAttCodsSelected);
|
2020-03-26 02:54:30 +01:00
|
|
|
|
}
|
2014-12-08 14:29:11 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**** Put a link (form) to list assistance of students to several events *****/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_PutButtonToShowDetails (const struct Att_Events *Events)
|
2014-12-08 14:29:11 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Show_more_details;
|
|
|
|
|
|
|
|
|
|
/***** Button to show more details *****/
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartFormAnchor (Gbl.Action.Act,Att_ATTENDANCE_DETAILS_ID);
|
2014-12-08 14:29:11 +01:00
|
|
|
|
Par_PutHiddenParamChar ("ShowDetails",'Y');
|
|
|
|
|
Grp_PutParamsCodGrps ();
|
2019-11-15 03:34:48 +01:00
|
|
|
|
Usr_PutHiddenParSelectedUsrsCods (&Gbl.Usrs.Selected);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (Events->StrAttCodsSelected)
|
|
|
|
|
if (Events->StrAttCodsSelected[0])
|
|
|
|
|
Par_PutHiddenParamString (NULL,"AttCods",Events->StrAttCodsSelected);
|
2017-06-11 19:02:40 +02:00
|
|
|
|
Btn_PutConfirmButton (Txt_Show_more_details);
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2014-12-08 14:29:11 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********** Write list of those attendance events that have students *********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_ListEventsToSelect (const struct Att_Events *Events,
|
|
|
|
|
Att_TypeOfView_t TypeOfView)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-11-19 00:17:23 +01:00
|
|
|
|
extern const char *The_ClassFormLinkInBoxBold[The_NUM_THEMES];
|
2014-12-04 01:19:42 +01:00
|
|
|
|
extern const char *Txt_Events;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Event;
|
|
|
|
|
extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
2014-12-08 01:30:47 +01:00
|
|
|
|
extern const char *Txt_Update_attendance;
|
2015-10-24 20:46:11 +02:00
|
|
|
|
unsigned UniqueId;
|
2019-11-01 22:53:39 +01:00
|
|
|
|
char *Id;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned NumAttEvent;
|
2020-04-06 16:00:06 +02:00
|
|
|
|
bool NormalView = (TypeOfView == Att_VIEW_ONLY_ME ||
|
|
|
|
|
TypeOfView == Att_VIEW_SEL_USR);
|
2018-10-18 09:59:38 +02:00
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
switch (TypeOfView)
|
2020-03-26 02:54:30 +01:00
|
|
|
|
{
|
|
|
|
|
case Att_VIEW_ONLY_ME:
|
|
|
|
|
Box_BoxBegin (NULL,Txt_Events,
|
2020-04-08 03:41:05 +02:00
|
|
|
|
Att_PutIconToViewAttEvents,NULL,
|
2020-03-26 02:54:30 +01:00
|
|
|
|
NULL,Box_NOT_CLOSABLE);
|
|
|
|
|
break;
|
|
|
|
|
case Att_VIEW_SEL_USR:
|
|
|
|
|
Box_BoxBegin (NULL,Txt_Events,
|
2020-04-08 03:41:05 +02:00
|
|
|
|
Att_PutIconToEditAttEvents,NULL,
|
2020-03-26 02:54:30 +01:00
|
|
|
|
NULL,Box_NOT_CLOSABLE);
|
|
|
|
|
break;
|
|
|
|
|
case Att_PRNT_ONLY_ME:
|
|
|
|
|
case Att_PRNT_SEL_USR:
|
|
|
|
|
Box_BoxBegin (NULL,Txt_Events,
|
|
|
|
|
NULL,NULL,
|
|
|
|
|
NULL,Box_NOT_CLOSABLE);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-10-20 22:00:28 +02:00
|
|
|
|
/***** Begin form to update the attendance
|
2014-12-08 14:29:11 +01:00
|
|
|
|
depending on the events selected *****/
|
2018-10-18 09:59:38 +02:00
|
|
|
|
if (NormalView)
|
2014-12-08 01:30:47 +01:00
|
|
|
|
{
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartFormAnchor (Gbl.Action.Act,Att_ATTENDANCE_TABLE_ID);
|
2014-12-08 14:29:11 +01:00
|
|
|
|
Grp_PutParamsCodGrps ();
|
2019-11-15 03:34:48 +01:00
|
|
|
|
Usr_PutHiddenParSelectedUsrsCods (&Gbl.Usrs.Selected);
|
2014-12-08 01:30:47 +01:00
|
|
|
|
}
|
2014-12-05 02:33:47 +01:00
|
|
|
|
|
2019-10-20 22:00:28 +02:00
|
|
|
|
/***** Begin table *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_BeginWidePadding (2);
|
2014-12-08 14:29:11 +01:00
|
|
|
|
|
|
|
|
|
/***** Heading row *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-11 01:02:51 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TH (1,4,"LM",Txt_Event);
|
|
|
|
|
HTM_TH (1,1,"RM",Txt_ROLES_PLURAL_Abc[Rol_STD][Usr_SEX_UNKNOWN]);
|
2019-10-11 01:02:51 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2014-12-08 01:30:47 +01:00
|
|
|
|
/***** List the events *****/
|
2015-10-24 20:46:11 +02:00
|
|
|
|
for (NumAttEvent = 0, UniqueId = 1, Gbl.RowEvenOdd = 0;
|
2020-04-06 16:00:06 +02:00
|
|
|
|
NumAttEvent < Events->Num;
|
2015-10-24 20:46:11 +02:00
|
|
|
|
NumAttEvent++, UniqueId++, Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd)
|
2014-12-07 02:04:30 +01:00
|
|
|
|
{
|
2014-12-08 14:29:11 +01:00
|
|
|
|
/* Get data of the attendance event from database */
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_GetDataOfAttEventByCodAndCheckCrs (&Events->Lst[NumAttEvent]);
|
|
|
|
|
Att_GetNumStdsTotalWhoAreInAttEvent (&Events->Lst[NumAttEvent]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2014-12-08 14:29:11 +01:00
|
|
|
|
/* Write a row for this event */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT CT COLOR%u\"",Gbl.RowEvenOdd);
|
2020-03-12 13:53:37 +01:00
|
|
|
|
HTM_INPUT_CHECKBOX ("AttCods",HTM_DONT_SUBMIT_ON_CHANGE,
|
2020-04-06 16:00:06 +02:00
|
|
|
|
"id=\"Event%u\" value=\"%ld\"%s",
|
|
|
|
|
NumAttEvent,Events->Lst[NumAttEvent].AttCod,
|
|
|
|
|
Events->Lst[NumAttEvent].Selected ? " checked=\"checked\"" :
|
|
|
|
|
"");
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT RT COLOR%u\"",Gbl.RowEvenOdd);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
HTM_LABEL_Begin ("for=\"Event%u\"",NumAttEvent);
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF ("%u:",NumAttEvent + 1);
|
2019-11-02 12:59:31 +01:00
|
|
|
|
HTM_LABEL_End ();
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2019-11-01 22:53:39 +01:00
|
|
|
|
if (asprintf (&Id,"att_date_start_%u",UniqueId) < 0)
|
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT LT COLOR%u\"",Gbl.RowEvenOdd);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
HTM_LABEL_Begin ("for=\"Event%u\"",NumAttEvent);
|
2019-11-07 10:24:00 +01:00
|
|
|
|
HTM_SPAN_Begin ("id=\"%s\"",Id);
|
|
|
|
|
HTM_SPAN_End ();
|
2019-11-02 12:59:31 +01:00
|
|
|
|
HTM_LABEL_End ();
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Dat_WriteLocalDateHMSFromUTC (Id,Events->Lst[NumAttEvent].TimeUTC[Att_START_TIME],
|
2019-11-02 12:10:58 +01:00
|
|
|
|
Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA,
|
2019-11-02 11:45:41 +01:00
|
|
|
|
true,true,true,0x7);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-11-06 19:45:20 +01:00
|
|
|
|
free (Id);
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT LT COLOR%u\"",Gbl.RowEvenOdd);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
HTM_Txt (Events->Lst[NumAttEvent].Title);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT RT COLOR%u\"",Gbl.RowEvenOdd);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
HTM_Unsigned (Events->Lst[NumAttEvent].NumStdsTotal);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-07 02:04:30 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Put button to refresh *****/
|
2018-10-18 09:59:38 +02:00
|
|
|
|
if (NormalView)
|
2014-12-08 01:30:47 +01:00
|
|
|
|
{
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("colspan=\"5\" class=\"CM\"");
|
2019-11-19 00:17:23 +01:00
|
|
|
|
HTM_BUTTON_Animated_Begin (Txt_Update_attendance,
|
|
|
|
|
The_ClassFormLinkInBoxBold[Gbl.Prefs.Theme],
|
|
|
|
|
NULL);
|
2019-01-12 19:46:33 +01:00
|
|
|
|
Ico_PutCalculateIconWithText (Txt_Update_attendance);
|
2019-11-19 00:17:23 +01:00
|
|
|
|
HTM_BUTTON_End ();
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-08 14:29:11 +01:00
|
|
|
|
}
|
2014-12-08 01:30:47 +01:00
|
|
|
|
|
2018-10-18 09:59:38 +02:00
|
|
|
|
/***** End table *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_End ();
|
2014-12-08 14:29:11 +01:00
|
|
|
|
|
|
|
|
|
/***** End form *****/
|
2018-10-18 09:59:38 +02:00
|
|
|
|
if (NormalView)
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2018-10-18 09:59:38 +02:00
|
|
|
|
|
|
|
|
|
/***** End box *****/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Box_BoxEnd ();
|
2018-10-18 09:59:38 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2020-03-26 02:54:30 +01:00
|
|
|
|
/*********** Put icon to list (without edition) attendance events ************/
|
2018-10-18 09:59:38 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-08 03:41:05 +02:00
|
|
|
|
static void Att_PutIconToViewAttEvents (__attribute__((unused)) void *Args)
|
2018-10-18 09:59:38 +02:00
|
|
|
|
{
|
2020-04-08 03:41:05 +02:00
|
|
|
|
Ico_PutContextualIconToView (ActSeeAtt,
|
|
|
|
|
NULL,NULL);
|
2014-12-05 02:33:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2020-03-26 02:54:30 +01:00
|
|
|
|
/************ Put icon to list (with edition) attendance events **************/
|
2018-10-18 11:10:04 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-08 03:41:05 +02:00
|
|
|
|
static void Att_PutIconToEditAttEvents (__attribute__((unused)) void *Args)
|
2018-10-18 11:10:04 +02:00
|
|
|
|
{
|
2020-04-08 03:41:05 +02:00
|
|
|
|
Ico_PutContextualIconToEdit (ActSeeAtt,NULL,
|
|
|
|
|
NULL,NULL);
|
2018-10-18 11:10:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2019-04-11 23:15:40 +02:00
|
|
|
|
/************ Show table with attendances for every user in list *************/
|
2014-12-05 02:33:47 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_ListUsrsAttendanceTable (const struct Att_Events *Events,
|
|
|
|
|
Att_TypeOfView_t TypeOfView,
|
|
|
|
|
unsigned NumUsrsInList,
|
2016-03-20 02:08:13 +01:00
|
|
|
|
long *LstSelectedUsrCods)
|
2014-12-05 02:33:47 +01:00
|
|
|
|
{
|
2019-04-11 23:15:40 +02:00
|
|
|
|
extern const char *Txt_Number_of_users;
|
2014-12-06 02:21:34 +01:00
|
|
|
|
struct UsrData UsrDat;
|
2019-04-11 23:15:40 +02:00
|
|
|
|
unsigned NumUsr;
|
2014-12-05 02:33:47 +01:00
|
|
|
|
unsigned NumAttEvent;
|
2014-12-06 02:21:34 +01:00
|
|
|
|
unsigned Total;
|
2020-04-06 16:00:06 +02:00
|
|
|
|
bool PutButtonShowDetails = (TypeOfView == Att_VIEW_ONLY_ME ||
|
|
|
|
|
TypeOfView == Att_VIEW_SEL_USR) &&
|
|
|
|
|
!Events->ShowDetails;
|
2014-12-05 02:33:47 +01:00
|
|
|
|
|
2014-12-06 02:21:34 +01:00
|
|
|
|
/***** Initialize structure with user's data *****/
|
|
|
|
|
Usr_UsrDataConstructor (&UsrDat);
|
2014-12-05 02:33:47 +01:00
|
|
|
|
|
2018-10-18 11:29:02 +02:00
|
|
|
|
/***** Start section with attendance table *****/
|
2019-10-26 01:56:36 +02:00
|
|
|
|
HTM_SECTION_Begin (Att_ATTENDANCE_TABLE_ID);
|
2018-10-18 11:29:02 +02:00
|
|
|
|
|
2019-10-20 22:00:28 +02:00
|
|
|
|
/***** Begin table *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_BeginCenterPadding (2);
|
2014-12-08 14:29:11 +01:00
|
|
|
|
|
|
|
|
|
/***** Heading row *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_WriteTableHeadSeveralAttEvents (Events);
|
2014-12-05 02:33:47 +01:00
|
|
|
|
|
2019-04-11 23:15:40 +02:00
|
|
|
|
/***** List the users *****/
|
|
|
|
|
for (NumUsr = 0, Gbl.RowEvenOdd = 0;
|
|
|
|
|
NumUsr < NumUsrsInList;
|
|
|
|
|
NumUsr++)
|
2014-12-06 02:21:34 +01:00
|
|
|
|
{
|
2019-04-11 23:15:40 +02:00
|
|
|
|
UsrDat.UsrCod = LstSelectedUsrCods[NumUsr];
|
2019-03-19 13:22:14 +01:00
|
|
|
|
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS)) // Get from the database the data of the student
|
2017-10-05 22:29:33 +02:00
|
|
|
|
if (Usr_CheckIfICanViewAtt (&UsrDat))
|
2017-06-09 15:04:02 +02:00
|
|
|
|
{
|
|
|
|
|
UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&UsrDat);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_WriteRowUsrSeveralAttEvents (Events,NumUsr,&UsrDat);
|
2017-06-09 15:04:02 +02:00
|
|
|
|
}
|
2014-12-06 02:21:34 +01:00
|
|
|
|
}
|
2014-12-05 02:33:47 +01:00
|
|
|
|
|
2019-04-11 23:15:40 +02:00
|
|
|
|
/***** Last row with the total of users present in each event *****/
|
|
|
|
|
if (NumUsrsInList > 1)
|
2015-11-13 01:27:44 +01:00
|
|
|
|
{
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("colspan=\"%u\" class=\"DAT_N_LINE_TOP RM\"",
|
2019-10-10 23:14:13 +02:00
|
|
|
|
Gbl.Usrs.Listing.WithPhotos ? 4 :
|
|
|
|
|
3);
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF ("%s:",Txt_Number_of_users);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2015-11-13 01:27:44 +01:00
|
|
|
|
for (NumAttEvent = 0, Total = 0;
|
2020-04-06 16:00:06 +02:00
|
|
|
|
NumAttEvent < Events->Num;
|
2015-11-13 01:27:44 +01:00
|
|
|
|
NumAttEvent++)
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (Events->Lst[NumAttEvent].Selected)
|
2015-11-13 01:27:44 +01:00
|
|
|
|
{
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT_N_LINE_TOP RM\"");
|
2020-04-06 16:00:06 +02:00
|
|
|
|
HTM_Unsigned (Events->Lst[NumAttEvent].NumStdsFromList);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Total += Events->Lst[NumAttEvent].NumStdsFromList;
|
2015-11-13 01:27:44 +01:00
|
|
|
|
}
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT_N_LINE_TOP RM\"");
|
2019-11-10 13:31:47 +01:00
|
|
|
|
HTM_Unsigned (Total);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2015-11-13 01:27:44 +01:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-03-20 02:08:13 +01:00
|
|
|
|
/***** End table *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_End ();
|
2016-03-20 02:08:13 +01:00
|
|
|
|
|
2015-04-11 17:33:14 +02:00
|
|
|
|
/***** Button to show more details *****/
|
2016-03-21 18:37:28 +01:00
|
|
|
|
if (PutButtonShowDetails)
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_PutButtonToShowDetails (Events);
|
2015-04-11 17:33:14 +02:00
|
|
|
|
|
2018-10-18 11:29:02 +02:00
|
|
|
|
/***** End section with attendance table *****/
|
2019-10-26 01:56:36 +02:00
|
|
|
|
HTM_SECTION_End ();
|
2018-10-18 11:29:02 +02:00
|
|
|
|
|
2014-12-06 02:21:34 +01:00
|
|
|
|
/***** Free memory used for user's data *****/
|
|
|
|
|
Usr_UsrDataDestructor (&UsrDat);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/* Write table heading for listing of students in several attendance events **/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_WriteTableHeadSeveralAttEvents (const struct Att_Events *Events)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2015-03-12 14:45:40 +01:00
|
|
|
|
extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Attendance;
|
|
|
|
|
unsigned NumAttEvent;
|
2019-11-08 01:10:32 +01:00
|
|
|
|
char StrNumAttEvent[Cns_MAX_DECIMAL_DIGITS_UINT + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-11 01:02:51 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TH (1,Gbl.Usrs.Listing.WithPhotos ? 4 :
|
2019-10-12 19:42:10 +02:00
|
|
|
|
3,
|
2019-10-15 15:23:38 +02:00
|
|
|
|
"LM",Txt_ROLES_SINGUL_Abc[Rol_USR][Usr_SEX_UNKNOWN]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
for (NumAttEvent = 0;
|
2020-04-06 16:00:06 +02:00
|
|
|
|
NumAttEvent < Events->Num;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
NumAttEvent++)
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (Events->Lst[NumAttEvent].Selected)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Get data of this attendance event *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_GetDataOfAttEventByCodAndCheckCrs (&Events->Lst[NumAttEvent]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2018-12-03 19:49:54 +01:00
|
|
|
|
/***** Put link to this attendance event *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TH_Begin (1,1,"CM");
|
2018-12-03 19:49:54 +01:00
|
|
|
|
snprintf (StrNumAttEvent,sizeof (StrNumAttEvent),
|
|
|
|
|
"%u",
|
|
|
|
|
NumAttEvent + 1);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_PutLinkAttEvent (&Events->Lst[NumAttEvent],
|
|
|
|
|
Events->Lst[NumAttEvent].Title,
|
2018-12-03 19:49:54 +01:00
|
|
|
|
StrNumAttEvent,
|
2019-11-18 09:35:23 +01:00
|
|
|
|
"BT_LINK TIT_TBL");
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TH_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TH (1,1,"RM",Txt_Attendance);
|
2019-10-11 01:02:51 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2019-04-11 23:15:40 +02:00
|
|
|
|
/************** Write a row of a table with the data of a user ***************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_WriteRowUsrSeveralAttEvents (const struct Att_Events *Events,
|
|
|
|
|
unsigned NumUsr,struct UsrData *UsrDat)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char PhotoURL[PATH_MAX + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool ShowPhoto;
|
|
|
|
|
unsigned NumAttEvent;
|
|
|
|
|
bool Present;
|
|
|
|
|
unsigned NumTimesPresent;
|
|
|
|
|
|
2019-04-11 23:15:40 +02:00
|
|
|
|
/***** Write number of user in the list *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"%s RM COLOR%u\"",
|
2019-10-10 23:14:13 +02:00
|
|
|
|
UsrDat->Accepted ? "DAT_N" :
|
|
|
|
|
"DAT",
|
|
|
|
|
Gbl.RowEvenOdd);
|
2019-11-10 13:31:47 +01:00
|
|
|
|
HTM_Unsigned (NumUsr + 1);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-11 23:15:40 +02:00
|
|
|
|
/***** Show user's photo *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (Gbl.Usrs.Listing.WithPhotos)
|
|
|
|
|
{
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LM COLOR%u\"",Gbl.RowEvenOdd);
|
2017-01-28 15:58:46 +01:00
|
|
|
|
ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL);
|
2014-12-30 15:14:43 +01:00
|
|
|
|
Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL :
|
|
|
|
|
NULL,
|
2016-01-14 10:31:09 +01:00
|
|
|
|
"PHOTO21x28",Pho_ZOOM,false);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Write user's ID ******/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"%s LM COLOR%u\"",
|
2019-10-10 23:14:13 +02:00
|
|
|
|
UsrDat->Accepted ? "DAT_SMALL_N" :
|
|
|
|
|
"DAT_SMALL",
|
|
|
|
|
Gbl.RowEvenOdd);
|
2017-05-09 20:56:02 +02:00
|
|
|
|
ID_WriteUsrIDs (UsrDat,NULL);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-11 23:15:40 +02:00
|
|
|
|
/***** Write user's name *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"%s LM COLOR%u\"",
|
2019-10-10 23:14:13 +02:00
|
|
|
|
UsrDat->Accepted ? "DAT_SMALL_N" :
|
|
|
|
|
"DAT_SMALL",
|
|
|
|
|
Gbl.RowEvenOdd);
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (UsrDat->Surname1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (UsrDat->Surname2[0])
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF (" %s",UsrDat->Surname2);
|
2019-11-11 00:15:44 +01:00
|
|
|
|
HTM_TxtF (", %s",UsrDat->FirstName);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-02-13 21:24:54 +01:00
|
|
|
|
/***** Check/cross to show if the user is present/absent *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
for (NumAttEvent = 0, NumTimesPresent = 0;
|
2020-04-06 16:00:06 +02:00
|
|
|
|
NumAttEvent < Events->Num;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
NumAttEvent++)
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (Events->Lst[NumAttEvent].Selected)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-02-13 21:24:54 +01:00
|
|
|
|
/* Check if this student is already registered in the current event */
|
2014-12-01 23:55:08 +01:00
|
|
|
|
// Here it is not necessary to get comments
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Present = Att_CheckIfUsrIsPresentInAttEvent (Events->Lst[NumAttEvent].AttCod,
|
2019-02-13 21:24:54 +01:00
|
|
|
|
UsrDat->UsrCod);
|
|
|
|
|
|
|
|
|
|
/* Write check or cross */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"BM%u\"",Gbl.RowEvenOdd);
|
2019-02-13 21:24:54 +01:00
|
|
|
|
Att_PutCheckOrCross (Present);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
if (Present)
|
|
|
|
|
NumTimesPresent++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Last column with the number of times this user is present *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT_N RM COLOR%u\"",Gbl.RowEvenOdd);
|
2019-11-10 13:31:47 +01:00
|
|
|
|
HTM_Unsigned (NumTimesPresent);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd;
|
|
|
|
|
}
|
2014-12-06 02:21:34 +01:00
|
|
|
|
|
2019-02-13 21:24:54 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********************** Put check or cross character ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Att_PutCheckOrCross (bool Present)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Present;
|
|
|
|
|
extern const char *Txt_Absent;
|
|
|
|
|
|
|
|
|
|
if (Present)
|
2019-10-24 00:04:40 +02:00
|
|
|
|
{
|
|
|
|
|
HTM_DIV_Begin ("class=\"ATT_CHECK\" title=\"%s\"",Txt_Present);
|
2019-11-11 00:15:44 +01:00
|
|
|
|
HTM_Txt ("✓");
|
2019-10-24 00:04:40 +02:00
|
|
|
|
}
|
2019-02-13 21:24:54 +01:00
|
|
|
|
else
|
2019-10-24 00:04:40 +02:00
|
|
|
|
{
|
|
|
|
|
HTM_DIV_Begin ("class=\"ATT_CROSS\" title=\"%s\"",Txt_Absent);
|
2019-11-11 00:15:44 +01:00
|
|
|
|
HTM_Txt ("✗");
|
2019-10-24 00:04:40 +02:00
|
|
|
|
}
|
2019-10-23 20:07:56 +02:00
|
|
|
|
HTM_DIV_End ();
|
2019-02-13 21:24:54 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-06 02:21:34 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************** List the students with details and comments ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_ListStdsWithAttEventsDetails (const struct Att_Events *Events,
|
|
|
|
|
unsigned NumUsrsInList,
|
2016-11-27 23:08:29 +01:00
|
|
|
|
long *LstSelectedUsrCods)
|
2014-12-06 02:21:34 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Details;
|
|
|
|
|
struct UsrData UsrDat;
|
2019-04-11 23:15:40 +02:00
|
|
|
|
unsigned NumUsr;
|
2014-12-06 02:21:34 +01:00
|
|
|
|
|
|
|
|
|
/***** Initialize structure with user's data *****/
|
|
|
|
|
Usr_UsrDataConstructor (&UsrDat);
|
|
|
|
|
|
2018-10-18 16:56:07 +02:00
|
|
|
|
/***** Start section with attendance details *****/
|
2019-10-26 01:56:36 +02:00
|
|
|
|
HTM_SECTION_Begin (Att_ATTENDANCE_DETAILS_ID);
|
2018-10-18 16:56:07 +02:00
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box and table *****/
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Box_BoxTableBegin (NULL,Txt_Details,
|
|
|
|
|
NULL,NULL,
|
2018-10-18 09:59:38 +02:00
|
|
|
|
NULL,Box_NOT_CLOSABLE,2);
|
2014-12-06 02:21:34 +01:00
|
|
|
|
|
|
|
|
|
/***** List students with attendance details *****/
|
2019-04-11 23:15:40 +02:00
|
|
|
|
for (NumUsr = 0, Gbl.RowEvenOdd = 0;
|
|
|
|
|
NumUsr < NumUsrsInList;
|
|
|
|
|
NumUsr++)
|
2014-12-06 02:21:34 +01:00
|
|
|
|
{
|
2019-04-11 23:15:40 +02:00
|
|
|
|
UsrDat.UsrCod = LstSelectedUsrCods[NumUsr];
|
2019-03-19 13:22:14 +01:00
|
|
|
|
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS)) // Get from the database the data of the student
|
2017-10-05 22:29:33 +02:00
|
|
|
|
if (Usr_CheckIfICanViewAtt (&UsrDat))
|
2017-06-09 15:04:02 +02:00
|
|
|
|
{
|
|
|
|
|
UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&UsrDat);
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_ListAttEventsForAStd (Events,NumUsr,&UsrDat);
|
2017-06-09 15:04:02 +02:00
|
|
|
|
}
|
2014-12-06 02:21:34 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End table and box *****/
|
2019-11-25 23:18:08 +01:00
|
|
|
|
Box_BoxTableEnd ();
|
2014-12-06 02:21:34 +01:00
|
|
|
|
|
2018-10-18 16:56:07 +02:00
|
|
|
|
/***** End section with attendance details *****/
|
2019-10-26 01:56:36 +02:00
|
|
|
|
HTM_SECTION_End ();
|
2018-10-18 16:56:07 +02:00
|
|
|
|
|
2014-12-06 02:21:34 +01:00
|
|
|
|
/***** Free memory used for user's data *****/
|
|
|
|
|
Usr_UsrDataDestructor (&UsrDat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Write list of attendance events for a student ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-06 16:00:06 +02:00
|
|
|
|
static void Att_ListAttEventsForAStd (const struct Att_Events *Events,
|
|
|
|
|
unsigned NumUsr,struct UsrData *UsrDat)
|
2014-12-06 02:21:34 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Student_comment;
|
|
|
|
|
extern const char *Txt_Teachers_comment;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char PhotoURL[PATH_MAX + 1];
|
2014-12-06 02:21:34 +01:00
|
|
|
|
bool ShowPhoto;
|
|
|
|
|
unsigned NumAttEvent;
|
2015-10-24 20:46:11 +02:00
|
|
|
|
unsigned UniqueId;
|
2019-11-01 22:53:39 +01:00
|
|
|
|
char *Id;
|
2014-12-06 02:21:34 +01:00
|
|
|
|
bool Present;
|
2015-11-13 01:27:44 +01:00
|
|
|
|
bool ShowCommentStd;
|
|
|
|
|
bool ShowCommentTch;
|
2017-01-17 03:10:43 +01:00
|
|
|
|
char CommentStd[Cns_MAX_BYTES_TEXT + 1];
|
|
|
|
|
char CommentTch[Cns_MAX_BYTES_TEXT + 1];
|
2014-12-06 02:21:34 +01:00
|
|
|
|
|
|
|
|
|
/***** Write number of student in the list *****/
|
2019-04-11 23:15:40 +02:00
|
|
|
|
NumUsr++;
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"%s RM COLOR%u\"",
|
2019-10-10 23:14:13 +02:00
|
|
|
|
UsrDat->Accepted ? "DAT_N" :
|
|
|
|
|
"DAT",
|
|
|
|
|
Gbl.RowEvenOdd);
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF ("%u:",NumUsr);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-06 02:21:34 +01:00
|
|
|
|
|
|
|
|
|
/***** Show student's photo *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"RM COLOR%u\"",Gbl.RowEvenOdd);
|
2017-01-28 15:58:46 +01:00
|
|
|
|
ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL);
|
2014-12-30 15:14:43 +01:00
|
|
|
|
Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL :
|
|
|
|
|
NULL,
|
2016-01-14 10:31:09 +01:00
|
|
|
|
"PHOTO21x28",Pho_ZOOM,false);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-06 02:21:34 +01:00
|
|
|
|
|
|
|
|
|
/***** Write user's ID ******/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LM COLOR%u\"",Gbl.RowEvenOdd);
|
|
|
|
|
HTM_TABLE_Begin (NULL);
|
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"%s LM\"",
|
2019-10-10 23:14:13 +02:00
|
|
|
|
UsrDat->Accepted ? "DAT_N" :
|
|
|
|
|
"DAT");
|
2017-05-09 20:56:02 +02:00
|
|
|
|
ID_WriteUsrIDs (UsrDat,NULL);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-06 02:21:34 +01:00
|
|
|
|
|
|
|
|
|
/***** Write student's name *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"%s LM\"",
|
2019-10-10 23:14:13 +02:00
|
|
|
|
UsrDat->Accepted ? "DAT_SMALL_N" :
|
|
|
|
|
"DAT_SMALL");
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (UsrDat->Surname1);
|
2014-12-06 02:21:34 +01:00
|
|
|
|
if (UsrDat->Surname2[0])
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF (" %s",UsrDat->Surname2);
|
2019-11-11 00:15:44 +01:00
|
|
|
|
HTM_TxtF (", %s",UsrDat->FirstName);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 22:28:16 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
HTM_TABLE_End ();
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
HTM_TR_End ();
|
2014-12-06 02:21:34 +01:00
|
|
|
|
|
|
|
|
|
/***** List the events with students *****/
|
2015-10-24 20:46:11 +02:00
|
|
|
|
for (NumAttEvent = 0, UniqueId = 1;
|
2020-04-06 16:00:06 +02:00
|
|
|
|
NumAttEvent < Events->Num;
|
2015-10-24 20:46:11 +02:00
|
|
|
|
NumAttEvent++, UniqueId++)
|
2020-04-06 16:00:06 +02:00
|
|
|
|
if (Events->Lst[NumAttEvent].Selected)
|
2014-12-06 02:21:34 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Get data of the attendance event from database *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Att_GetDataOfAttEventByCodAndCheckCrs (&Events->Lst[NumAttEvent]);
|
|
|
|
|
Att_GetNumStdsTotalWhoAreInAttEvent (&Events->Lst[NumAttEvent]);
|
2014-12-06 02:21:34 +01:00
|
|
|
|
|
|
|
|
|
/***** Get comments for this student *****/
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Present = Att_CheckIfUsrIsPresentInAttEventAndGetComments (Events->Lst[NumAttEvent].AttCod,UsrDat->UsrCod,CommentStd,CommentTch);
|
2015-11-13 01:27:44 +01:00
|
|
|
|
ShowCommentStd = CommentStd[0];
|
|
|
|
|
ShowCommentTch = CommentTch[0] &&
|
2017-06-04 18:18:54 +02:00
|
|
|
|
(Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
|
2020-04-06 16:00:06 +02:00
|
|
|
|
Events->Lst[NumAttEvent].CommentTchVisible);
|
2014-12-06 02:21:34 +01:00
|
|
|
|
|
|
|
|
|
/***** Write a row for this event *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-06 12:00:55 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_ColouredEmpty (1);
|
2019-10-06 12:00:55 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"%s RT COLOR%u\"",
|
2019-10-10 23:14:13 +02:00
|
|
|
|
Present ? "DAT_GREEN" :
|
|
|
|
|
"DAT_RED",
|
|
|
|
|
Gbl.RowEvenOdd);
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF ("%u:",NumAttEvent + 1);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-06 12:00:55 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"BT%u\"",Gbl.RowEvenOdd);
|
2019-02-13 21:24:54 +01:00
|
|
|
|
Att_PutCheckOrCross (Present);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-06 12:00:55 +02:00
|
|
|
|
|
2019-11-01 22:53:39 +01:00
|
|
|
|
if (asprintf (&Id,"att_date_start_%u_%u",NumUsr,UniqueId) < 0)
|
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT LT COLOR%u\"",Gbl.RowEvenOdd);
|
2019-11-07 10:24:00 +01:00
|
|
|
|
HTM_SPAN_Begin ("id=\"%s\"",Id);
|
|
|
|
|
HTM_SPAN_End ();
|
2019-11-09 21:08:20 +01:00
|
|
|
|
HTM_BR ();
|
2020-04-06 16:00:06 +02:00
|
|
|
|
HTM_Txt (Events->Lst[NumAttEvent].Title);
|
|
|
|
|
Dat_WriteLocalDateHMSFromUTC (Id,Events->Lst[NumAttEvent].TimeUTC[Att_START_TIME],
|
2019-11-02 12:10:58 +01:00
|
|
|
|
Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA,
|
2019-11-02 11:45:41 +01:00
|
|
|
|
true,true,true,0x7);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-11-06 19:45:20 +01:00
|
|
|
|
free (Id);
|
2019-10-06 12:00:55 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-06 02:21:34 +01:00
|
|
|
|
|
|
|
|
|
/***** Write comments for this student *****/
|
2015-11-13 01:27:44 +01:00
|
|
|
|
if (ShowCommentStd || ShowCommentTch)
|
2014-12-06 02:21:34 +01:00
|
|
|
|
{
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-06 12:00:55 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_ColouredEmpty (2);
|
2019-10-06 12:00:55 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"BT%u\"",Gbl.RowEvenOdd);
|
|
|
|
|
HTM_TD_End ();
|
2019-10-06 12:00:55 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT LM COLOR%u\"",Gbl.RowEvenOdd);
|
2019-11-09 20:04:35 +01:00
|
|
|
|
|
|
|
|
|
HTM_DL_Begin ();
|
2015-11-13 01:27:44 +01:00
|
|
|
|
if (ShowCommentStd)
|
2014-12-06 02:21:34 +01:00
|
|
|
|
{
|
|
|
|
|
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
|
|
|
|
|
CommentStd,Cns_MAX_BYTES_TEXT,false);
|
2019-11-09 20:04:35 +01:00
|
|
|
|
HTM_DT_Begin ();
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF ("%s:",Txt_Student_comment);
|
2019-11-09 20:04:35 +01:00
|
|
|
|
HTM_DT_End ();
|
|
|
|
|
HTM_DD_Begin ();
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (CommentStd);
|
2019-11-09 20:04:35 +01:00
|
|
|
|
HTM_DD_End ();
|
2014-12-06 02:21:34 +01:00
|
|
|
|
}
|
2015-11-13 01:27:44 +01:00
|
|
|
|
if (ShowCommentTch)
|
2014-12-06 02:21:34 +01:00
|
|
|
|
{
|
|
|
|
|
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
|
|
|
|
|
CommentTch,Cns_MAX_BYTES_TEXT,false);
|
2019-11-09 20:04:35 +01:00
|
|
|
|
HTM_DT_Begin ();
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF ("%s:",Txt_Teachers_comment);
|
2019-11-09 20:04:35 +01:00
|
|
|
|
HTM_DT_End ();
|
|
|
|
|
HTM_DD_Begin ();
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (CommentTch);
|
2019-11-09 20:04:35 +01:00
|
|
|
|
HTM_DD_End ();
|
2014-12-06 02:21:34 +01:00
|
|
|
|
}
|
2019-11-09 20:04:35 +01:00
|
|
|
|
HTM_DL_End ();
|
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-06 12:00:55 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-06 02:21:34 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd;
|
|
|
|
|
}
|