2021-03-07 21:21:04 +01:00
|
|
|
|
// swad_center.c: centers
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
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.
|
2021-02-09 12:43:45 +01:00
|
|
|
|
Copyright (C) 1999-2021 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 ***********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-10-16 02:24:29 +02:00
|
|
|
|
#include <stdbool.h> // For boolean type
|
2019-12-29 12:39:00 +01:00
|
|
|
|
#include <stddef.h> // For NULL
|
2020-01-03 22:16:51 +01:00
|
|
|
|
#include <stdlib.h> // For free
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include <string.h> // For string functions
|
|
|
|
|
|
2021-06-11 11:36:34 +02:00
|
|
|
|
#include "swad_admin_database.h"
|
2021-03-07 21:21:04 +01:00
|
|
|
|
#include "swad_center.h"
|
|
|
|
|
#include "swad_center_config.h"
|
2021-06-02 13:09:30 +02:00
|
|
|
|
#include "swad_center_database.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_database.h"
|
2021-06-09 20:27:57 +02:00
|
|
|
|
#include "swad_enrolment_database.h"
|
2021-04-26 15:27:27 +02:00
|
|
|
|
#include "swad_error.h"
|
2020-04-14 17:15:17 +02:00
|
|
|
|
#include "swad_figure.h"
|
2020-05-02 13:39:59 +02:00
|
|
|
|
#include "swad_figure_cache.h"
|
2018-11-09 20:47:39 +01:00
|
|
|
|
#include "swad_form.h"
|
2020-04-14 17:15:17 +02:00
|
|
|
|
#include "swad_forum.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_global.h"
|
2021-02-11 22:57:09 +01:00
|
|
|
|
#include "swad_hierarchy.h"
|
2021-05-27 23:30:16 +02:00
|
|
|
|
#include "swad_hierarchy_level.h"
|
2019-10-23 19:05:05 +02:00
|
|
|
|
#include "swad_HTML.h"
|
2015-01-17 13:31:25 +01:00
|
|
|
|
#include "swad_logo.h"
|
2020-04-14 17:15:17 +02:00
|
|
|
|
#include "swad_message.h"
|
|
|
|
|
#include "swad_place.h"
|
|
|
|
|
#include "swad_survey.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private constants *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************************* Private types *******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private variables *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
static struct Ctr_Center *Ctr_EditingCtr = NULL; // Static variable to keep the center being edited
|
2019-04-06 21:39:35 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private prototypes ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
static void Ctr_ListCenters (void);
|
|
|
|
|
static bool Ctr_CheckIfICanCreateCenters (void);
|
|
|
|
|
static void Ctr_PutIconsListingCenters (__attribute__((unused)) void *Args);
|
|
|
|
|
static void Ctr_PutIconToEditCenters (void);
|
|
|
|
|
static void Ctr_ListOneCenterForSeeing (struct Ctr_Center *Ctr,unsigned NumCtr);
|
2017-01-29 12:42:19 +01:00
|
|
|
|
static void Ctr_GetParamCtrOrder (void);
|
2017-04-30 02:35:25 +02:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
static void Ctr_EditCentersInternal (void);
|
|
|
|
|
static void Ctr_PutIconsEditingCenters (__attribute__((unused)) void *Args);
|
2017-04-30 02:35:25 +02:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
static void Ctr_GetDataOfCenterFromRow (struct Ctr_Center *Ctr,MYSQL_ROW row);
|
2019-12-19 11:00:14 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
static void Ctr_ListCentersForEdition (const struct Plc_Places *Places);
|
|
|
|
|
static bool Ctr_CheckIfICanEditACenter (struct Ctr_Center *Ctr);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static Ctr_StatusTxt_t Ctr_GetStatusTxtFromStatusBits (Ctr_Status_t Status);
|
|
|
|
|
static Ctr_Status_t Ctr_GetStatusBitsFromStatusTxt (Ctr_StatusTxt_t StatusTxt);
|
2016-10-23 19:40:14 +02:00
|
|
|
|
|
2020-10-13 22:34:31 +02:00
|
|
|
|
static void Ctr_PutParamOtherCtrCod (void *CtrCod);
|
2016-10-23 19:40:14 +02:00
|
|
|
|
|
2017-05-11 20:55:04 +02:00
|
|
|
|
static void Ctr_ShowAlertAndButtonToGoToCtr (void);
|
2020-04-08 13:40:21 +02:00
|
|
|
|
static void Ctr_PutParamGoToCtr (void *CtrCod);
|
2015-01-17 13:31:25 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
static void Ctr_PutFormToCreateCenter (const struct Plc_Places *Places);
|
|
|
|
|
static void Ctr_PutHeadCentersForSeeing (bool OrderSelectable);
|
|
|
|
|
static void Ctr_PutHeadCentersForEdition (void);
|
2021-06-02 20:47:31 +02:00
|
|
|
|
static void Ctr_ReceiveFormRequestOrCreateCtr (Ctr_Status_t Status);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-05-03 21:56:55 +02:00
|
|
|
|
static unsigned Ctr_GetNumCtrsInCty (long CtyCod);
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
static void Ctr_EditingCenterConstructor (void);
|
|
|
|
|
static void Ctr_EditingCenterDestructor (void);
|
2019-04-06 21:39:35 +02:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
static void Ctr_FormToGoToMap (struct Ctr_Center *Ctr);
|
2020-01-14 13:30:18 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/******************* List centers with pending degrees ***********************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Ctr_SeeCtrWithPendingDegs (void)
|
|
|
|
|
{
|
2020-01-30 20:47:00 +01:00
|
|
|
|
extern const char *Hlp_SYSTEM_Pending;
|
2021-03-07 21:21:04 +01:00
|
|
|
|
extern const char *Txt_Centers_with_pending_degrees;
|
|
|
|
|
extern const char *Txt_Center;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Degrees_ABBREVIATION;
|
2021-03-07 21:21:04 +01:00
|
|
|
|
extern const char *Txt_There_are_no_centers_with_requests_for_degrees_to_be_confirmed;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumCtrs;
|
|
|
|
|
unsigned NumCtr;
|
2021-03-07 21:21:04 +01:00
|
|
|
|
struct Ctr_Center Ctr;
|
2015-09-04 19:26:08 +02:00
|
|
|
|
const char *BgColor;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get centers with pending degrees *****/
|
2021-06-02 13:09:30 +02:00
|
|
|
|
if ((NumCtrs = Ctr_DB_GetCtrsWithPendingDegs (&mysql_res)))
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box and table *****/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Box_BoxTableBegin (NULL,Txt_Centers_with_pending_degrees,
|
2020-03-26 02:54:30 +01:00
|
|
|
|
NULL,NULL,
|
2020-01-30 20:47:00 +01:00
|
|
|
|
Hlp_SYSTEM_Pending,Box_NOT_CLOSABLE,2);
|
2017-06-12 14:16:33 +02:00
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
/***** Wrtie heading *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-11 01:02:51 +02:00
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
HTM_TH (1,1,"LM",Txt_Center);
|
|
|
|
|
HTM_TH (1,1,"RM",Txt_Degrees_ABBREVIATION);
|
2019-10-11 01:02:51 +02:00
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
/***** List the centers *****/
|
|
|
|
|
for (NumCtr = 0;
|
|
|
|
|
NumCtr < NumCtrs;
|
|
|
|
|
NumCtr++, Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd)
|
|
|
|
|
{
|
|
|
|
|
/* Get next center */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
/* Get center code (row[0]) */
|
|
|
|
|
Ctr.CtrCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
|
|
|
BgColor = (Ctr.CtrCod == Gbl.Hierarchy.Ctr.CtrCod) ? "LIGHT_BLUE" :
|
|
|
|
|
Gbl.ColorRows[Gbl.RowEvenOdd];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
/* Get data of center */
|
|
|
|
|
Ctr_GetDataOfCenterByCod (&Ctr);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
/* Center logo and full name */
|
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 23:02:50 +02:00
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LM %s\"",BgColor);
|
|
|
|
|
Ctr_DrawCenterLogoAndNameWithLink (&Ctr,ActSeeDeg,
|
|
|
|
|
"BT_LINK DAT_NOBR","CM");
|
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
/* Number of pending degrees (row[1]) */
|
|
|
|
|
HTM_TD_Begin ("class=\"DAT RM %s\"",BgColor);
|
|
|
|
|
HTM_Txt (row[1]);
|
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
}
|
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 ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Ale_ShowAlert (Ale_INFO,Txt_There_are_no_centers_with_requests_for_degrees_to_be_confirmed);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-19 19:37:44 +01:00
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/******************** Draw center logo and name with link ********************/
|
2015-11-19 19:37:44 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
void Ctr_DrawCenterLogoAndNameWithLink (struct Ctr_Center *Ctr,Act_Action_t Action,
|
2015-11-19 19:37:44 +01:00
|
|
|
|
const char *ClassLink,const char *ClassLogo)
|
|
|
|
|
{
|
2019-10-20 22:00:28 +02:00
|
|
|
|
/***** Begin form *****/
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginFormGoTo (Action);
|
2015-11-19 19:37:44 +01:00
|
|
|
|
Ctr_PutParamCtrCod (Ctr->CtrCod);
|
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
/***** Link to action *****/
|
|
|
|
|
HTM_BUTTON_SUBMIT_Begin (Hie_BuildGoToMsg (Ctr->FullName),ClassLink,NULL);
|
|
|
|
|
Hie_FreeGoToMsg ();
|
2015-11-19 19:37:44 +01:00
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
/***** Center logo and name *****/
|
|
|
|
|
Lgo_DrawLogo (HieLvl_CTR,Ctr->CtrCod,Ctr->ShrtName,16,ClassLogo,true);
|
|
|
|
|
HTM_TxtF (" %s",Ctr->FullName);
|
2015-11-19 19:37:44 +01:00
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
/***** End link *****/
|
|
|
|
|
HTM_BUTTON_End ();
|
2015-11-19 19:37:44 +01:00
|
|
|
|
|
|
|
|
|
/***** End form *****/
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2020-01-14 13:30:18 +01:00
|
|
|
|
|
|
|
|
|
/***** Map *****/
|
|
|
|
|
Ctr_FormToGoToMap (Ctr);
|
2015-11-19 19:37:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/*************** Show the centers of the current institution *****************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Ctr_ShowCtrsOfCurrentIns (void)
|
|
|
|
|
{
|
2019-04-03 20:57:04 +02:00
|
|
|
|
/***** Trivial check *****/
|
|
|
|
|
if (Gbl.Hierarchy.Ins.InsCod <= 0) // No institution selected
|
|
|
|
|
return;
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get parameter with the type of order in the list of centers *****/
|
2019-04-03 20:57:04 +02:00
|
|
|
|
Ctr_GetParamCtrOrder ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get list of centers *****/
|
2021-06-02 13:09:30 +02:00
|
|
|
|
Ctr_GetFullListOfCenters (Gbl.Hierarchy.Ins.InsCod,
|
|
|
|
|
Gbl.Hierarchy.Ctrs.SelectedOrder);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-03 20:57:04 +02:00
|
|
|
|
/***** Write menu to select country and institution *****/
|
|
|
|
|
Hie_WriteMenuHierarchy ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** List centers *****/
|
|
|
|
|
Ctr_ListCenters ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Free list of centers *****/
|
|
|
|
|
Ctr_FreeListCenters ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/******************** List centers in this institution ***********************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
static void Ctr_ListCenters (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
extern const char *Hlp_INSTITUTION_Centers;
|
|
|
|
|
extern const char *Txt_Centers_of_INSTITUTION_X;
|
|
|
|
|
extern const char *Txt_No_centers;
|
|
|
|
|
extern const char *Txt_Create_another_center;
|
|
|
|
|
extern const char *Txt_Create_center;
|
2016-03-20 13:47:46 +01:00
|
|
|
|
unsigned NumCtr;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box *****/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Box_BoxBegin (NULL,Str_BuildStringStr (Txt_Centers_of_INSTITUTION_X,
|
2019-12-30 21:47:07 +01:00
|
|
|
|
Gbl.Hierarchy.Ins.FullName),
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Ctr_PutIconsListingCenters,NULL,
|
|
|
|
|
Hlp_INSTITUTION_Centers,Box_NOT_CLOSABLE);
|
2019-12-30 21:47:07 +01:00
|
|
|
|
Str_FreeString ();
|
2016-03-20 13:47:46 +01:00
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
if (Gbl.Hierarchy.Ctrs.Num) // There are centers in the current institution
|
|
|
|
|
{
|
|
|
|
|
/***** Begin table *****/
|
|
|
|
|
HTM_TABLE_BeginWideMarginPadding (2);
|
2016-03-20 13:47:46 +01:00
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
/***** Write heading *****/
|
|
|
|
|
Ctr_PutHeadCentersForSeeing (true); // Order selectable
|
2016-03-20 13:47:46 +01:00
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
/***** Write all the centers and their nuber of teachers *****/
|
|
|
|
|
for (NumCtr = 0;
|
|
|
|
|
NumCtr < Gbl.Hierarchy.Ctrs.Num;
|
|
|
|
|
NumCtr++)
|
|
|
|
|
Ctr_ListOneCenterForSeeing (&(Gbl.Hierarchy.Ctrs.Lst[NumCtr]),NumCtr + 1);
|
2016-03-16 12:54:05 +01:00
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
/***** End table *****/
|
|
|
|
|
HTM_TABLE_End ();
|
|
|
|
|
}
|
|
|
|
|
else // No centers created in the current institution
|
|
|
|
|
Ale_ShowAlert (Ale_INFO,Txt_No_centers);
|
|
|
|
|
|
|
|
|
|
/***** Button to create center *****/
|
|
|
|
|
if (Ctr_CheckIfICanCreateCenters ())
|
|
|
|
|
{
|
|
|
|
|
Frm_BeginForm (ActEdiCtr);
|
|
|
|
|
Btn_PutConfirmButton (Gbl.Hierarchy.Ctrs.Num ? Txt_Create_another_center :
|
|
|
|
|
Txt_Create_center);
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
}
|
2014-12-01 23:55:08 +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-11-06 23:46:29 +01:00
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/********************** Check if I can create centers ************************/
|
2016-11-06 23:46:29 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
static bool Ctr_CheckIfICanCreateCenters (void)
|
2016-11-06 23:46:29 +01:00
|
|
|
|
{
|
2017-06-04 18:18:54 +02:00
|
|
|
|
return (bool) (Gbl.Usrs.Me.Role.Logged >= Rol_GST);
|
2016-11-06 23:46:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***************** Put contextual icons in list of centers *******************/
|
2016-11-06 23:46:29 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
static void Ctr_PutIconsListingCenters (__attribute__((unused)) void *Args)
|
2016-11-06 23:46:29 +01:00
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Put icon to edit centers *****/
|
|
|
|
|
if (Ctr_CheckIfICanCreateCenters ())
|
|
|
|
|
Ctr_PutIconToEditCenters ();
|
2016-11-06 23:46:29 +01:00
|
|
|
|
|
2020-04-08 13:40:21 +02:00
|
|
|
|
/***** Put icon to view places *****/
|
|
|
|
|
Plc_PutIconToViewPlaces ();
|
2017-03-26 14:57:47 +02:00
|
|
|
|
|
2020-04-08 13:40:21 +02:00
|
|
|
|
/***** Put icon to show a figure *****/
|
|
|
|
|
Fig_PutIconToShowFigure (Fig_HIERARCHY);
|
2016-11-06 23:46:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-16 13:23:10 +01:00
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/********************** Put link (form) to edit centers **********************/
|
2016-03-16 13:23:10 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
static void Ctr_PutIconToEditCenters (void)
|
2016-03-16 13:23:10 +01:00
|
|
|
|
{
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Ico_PutContextualIconToEdit (ActEdiCtr,NULL,
|
|
|
|
|
NULL,NULL);
|
2016-03-16 13:23:10 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/************************* List one center for seeing ************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
static void Ctr_ListOneCenterForSeeing (struct Ctr_Center *Ctr,unsigned NumCtr)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
extern const char *Txt_CENTER_STATUS[Ctr_NUM_STATUS_TXT];
|
2020-04-13 21:26:47 +02:00
|
|
|
|
struct Plc_Place Plc;
|
2015-11-19 16:09:51 +01:00
|
|
|
|
const char *TxtClassNormal;
|
|
|
|
|
const char *TxtClassStrong;
|
2015-09-04 19:26:08 +02:00
|
|
|
|
const char *BgColor;
|
2017-03-17 00:46:28 +01:00
|
|
|
|
Ctr_StatusTxt_t StatusTxt;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get data of place of this center *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Plc.PlcCod = Ctr->PlcCod;
|
|
|
|
|
Plc_GetDataOfPlaceByCod (&Plc);
|
|
|
|
|
|
2015-11-19 16:09:51 +01:00
|
|
|
|
if (Ctr->Status & Ctr_STATUS_BIT_PENDING)
|
|
|
|
|
{
|
|
|
|
|
TxtClassNormal = "DAT_LIGHT";
|
2019-11-18 15:48:46 +01:00
|
|
|
|
TxtClassStrong = "BT_LINK LT DAT_LIGHT";
|
2015-11-19 16:09:51 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TxtClassNormal = "DAT";
|
2019-11-18 15:48:46 +01:00
|
|
|
|
TxtClassStrong = "BT_LINK LT DAT_N";
|
2015-11-19 16:09:51 +01:00
|
|
|
|
}
|
2019-04-03 20:57:04 +02:00
|
|
|
|
BgColor = (Ctr->CtrCod == Gbl.Hierarchy.Ctr.CtrCod) ? "LIGHT_BLUE" :
|
|
|
|
|
Gbl.ColorRows[Gbl.RowEvenOdd];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-06 12:00:55 +02:00
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
/***** Number of center in this list *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"%s RM %s\"",TxtClassNormal,BgColor);
|
|
|
|
|
HTM_Unsigned (NumCtr);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Center logo and name *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"LM %s\"",BgColor);
|
|
|
|
|
Ctr_DrawCenterLogoAndNameWithLink (Ctr,ActSeeDeg,
|
|
|
|
|
TxtClassStrong,"CM");
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Number of users who claim to belong to this center *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"%s RM %s\"",TxtClassNormal,BgColor);
|
|
|
|
|
HTM_Unsigned (Usr_GetCachedNumUsrsWhoClaimToBelongToCtr (Ctr));
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Place *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"%s LM %s\"",TxtClassNormal,BgColor);
|
|
|
|
|
HTM_Txt (Plc.ShrtName);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Number of degrees *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"%s RM %s\"",TxtClassNormal,BgColor);
|
|
|
|
|
HTM_Unsigned (Deg_GetCachedNumDegsInCtr (Ctr->CtrCod));
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Number of courses *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"%s RM %s\"",TxtClassNormal,BgColor);
|
|
|
|
|
HTM_Unsigned (Crs_GetCachedNumCrssInCtr (Ctr->CtrCod));
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Number of users in courses of this center *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"%s RM %s\"",TxtClassNormal,BgColor);
|
|
|
|
|
HTM_Unsigned (Usr_GetCachedNumUsrsInCrss (HieLvl_CTR,Ctr->CtrCod,
|
|
|
|
|
1 << Rol_STD |
|
|
|
|
|
1 << Rol_NET |
|
|
|
|
|
1 << Rol_TCH)); // Any user
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Center status *****/
|
|
|
|
|
StatusTxt = Ctr_GetStatusTxtFromStatusBits (Ctr->Status);
|
|
|
|
|
HTM_TD_Begin ("class=\"%s LM %s\"",TxtClassNormal,BgColor);
|
|
|
|
|
if (StatusTxt != Ctr_STATUS_ACTIVE) // If active ==> do not show anything
|
|
|
|
|
HTM_Txt (Txt_CENTER_STATUS[StatusTxt]);
|
|
|
|
|
HTM_TD_End ();
|
2019-10-07 23:18:45 +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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/********** Get parameter with the type or order in list of centers **********/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-01-29 12:42:19 +01:00
|
|
|
|
static void Ctr_GetParamCtrOrder (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-01-08 14:04:25 +01:00
|
|
|
|
Gbl.Hierarchy.Ctrs.SelectedOrder = (Ctr_Order_t)
|
2021-06-02 00:08:30 +02:00
|
|
|
|
Par_GetParToUnsignedLong ("Order",
|
|
|
|
|
0,
|
|
|
|
|
Ctr_NUM_ORDERS - 1,
|
|
|
|
|
(unsigned long) Ctr_ORDER_DEFAULT);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/************************** Put forms to edit centers ************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
void Ctr_EditCenters (void)
|
2019-04-06 21:39:35 +02:00
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Center constructor *****/
|
|
|
|
|
Ctr_EditingCenterConstructor ();
|
2019-04-06 21:39:35 +02:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Edit centers *****/
|
|
|
|
|
Ctr_EditCentersInternal ();
|
2019-04-06 21:39:35 +02:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Center destructor *****/
|
|
|
|
|
Ctr_EditingCenterDestructor ();
|
2019-04-06 21:39:35 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
static void Ctr_EditCentersInternal (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
extern const char *Hlp_INSTITUTION_Centers;
|
|
|
|
|
extern const char *Txt_Centers_of_INSTITUTION_X;
|
2020-04-13 21:26:47 +02:00
|
|
|
|
struct Plc_Places Places;
|
|
|
|
|
|
|
|
|
|
/***** Reset places context *****/
|
|
|
|
|
Plc_ResetPlaces (&Places);
|
2017-04-30 02:35:25 +02:00
|
|
|
|
|
2016-10-20 21:09:01 +02:00
|
|
|
|
/***** Get list of places *****/
|
2020-04-13 21:26:47 +02:00
|
|
|
|
Places.SelectedOrder = Plc_ORDER_BY_PLACE;
|
|
|
|
|
Plc_GetListPlaces (&Places);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get list of centers *****/
|
|
|
|
|
Gbl.Hierarchy.Ctrs.SelectedOrder = Ctr_ORDER_BY_CENTER;
|
2021-06-02 13:09:30 +02:00
|
|
|
|
Ctr_GetFullListOfCenters (Gbl.Hierarchy.Ins.InsCod,
|
|
|
|
|
Gbl.Hierarchy.Ctrs.SelectedOrder);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2018-11-15 10:33:45 +01:00
|
|
|
|
/***** Write menu to select country and institution *****/
|
|
|
|
|
Hie_WriteMenuHierarchy ();
|
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box *****/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Box_BoxBegin (NULL,Str_BuildStringStr (Txt_Centers_of_INSTITUTION_X,
|
2019-12-30 21:47:07 +01:00
|
|
|
|
Gbl.Hierarchy.Ins.FullName),
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Ctr_PutIconsEditingCenters,NULL,
|
|
|
|
|
Hlp_INSTITUTION_Centers,Box_NOT_CLOSABLE);
|
2019-12-30 21:47:07 +01:00
|
|
|
|
Str_FreeString ();
|
2017-04-30 02:35:25 +02:00
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
/***** Put a form to create a new center *****/
|
|
|
|
|
Ctr_PutFormToCreateCenter (&Places);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
/***** List current centers *****/
|
|
|
|
|
if (Gbl.Hierarchy.Ctrs.Num)
|
|
|
|
|
Ctr_ListCentersForEdition (&Places);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End box *****/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Box_BoxEnd ();
|
2017-04-30 02:35:25 +02:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Free list of centers *****/
|
|
|
|
|
Ctr_FreeListCenters ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-10-20 21:09:01 +02:00
|
|
|
|
/***** Free list of places *****/
|
2020-04-13 21:26:47 +02:00
|
|
|
|
Plc_FreeListPlaces (&Places);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-30 02:35:25 +02:00
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/**************** Put contextual icons in edition of centers *****************/
|
2017-04-30 02:35:25 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
static void Ctr_PutIconsEditingCenters (__attribute__((unused)) void *Args)
|
2017-04-30 02:35:25 +02:00
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Put icon to view centers *****/
|
|
|
|
|
Ctr_PutIconToViewCenters ();
|
2017-04-30 02:35:25 +02:00
|
|
|
|
|
2020-04-08 13:40:21 +02:00
|
|
|
|
/***** Put icon to view places *****/
|
|
|
|
|
Plc_PutIconToViewPlaces ();
|
2018-11-15 10:33:45 +01:00
|
|
|
|
|
2020-04-08 13:40:21 +02:00
|
|
|
|
/***** Put icon to show a figure *****/
|
|
|
|
|
Fig_PutIconToShowFigure (Fig_HIERARCHY);
|
2017-04-30 02:35:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
void Ctr_PutIconToViewCenters (void)
|
2017-04-30 02:35:25 +02:00
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
extern const char *Txt_Centers;
|
2018-11-15 10:13:53 +01:00
|
|
|
|
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Lay_PutContextualLinkOnlyIcon (ActSeeCtr,NULL,
|
|
|
|
|
NULL,NULL,
|
2019-01-12 03:00:59 +01:00
|
|
|
|
"building.svg",
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Txt_Centers);
|
2017-04-30 02:35:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/************ Get basic list of centers ordered by name of center ************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
void Ctr_GetBasicListOfCenters (long InsCod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumCtr;
|
2021-03-07 21:21:04 +01:00
|
|
|
|
struct Ctr_Center *Ctr;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get centers from database *****/
|
2021-06-02 13:09:30 +02:00
|
|
|
|
Gbl.Hierarchy.Ctrs.Num = Ctr_DB_GetListOfCtrsFull (&mysql_res,InsCod);
|
2021-04-16 13:51:12 +02:00
|
|
|
|
|
|
|
|
|
if (Gbl.Hierarchy.Ctrs.Num) // Centers found...
|
2020-01-08 00:47:10 +01:00
|
|
|
|
{
|
2021-06-02 13:09:30 +02:00
|
|
|
|
/***** Create list with centers in institution *****/
|
2021-04-16 13:51:12 +02:00
|
|
|
|
if ((Gbl.Hierarchy.Ctrs.Lst = calloc ((size_t) Gbl.Hierarchy.Ctrs.Num,
|
2021-02-15 16:25:55 +01:00
|
|
|
|
sizeof (*Gbl.Hierarchy.Ctrs.Lst))) == NULL)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
2020-01-08 00:47:10 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get the centers *****/
|
2020-01-08 00:47:10 +01:00
|
|
|
|
for (NumCtr = 0;
|
2020-01-08 14:04:25 +01:00
|
|
|
|
NumCtr < Gbl.Hierarchy.Ctrs.Num;
|
2020-01-08 00:47:10 +01:00
|
|
|
|
NumCtr++)
|
|
|
|
|
{
|
2020-01-08 14:04:25 +01:00
|
|
|
|
Ctr = &(Gbl.Hierarchy.Ctrs.Lst[NumCtr]);
|
2020-01-08 00:47:10 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/* Get center data */
|
2020-01-08 00:47:10 +01:00
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Ctr_GetDataOfCenterFromRow (Ctr,row);
|
2020-01-08 00:47:10 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/* Reset number of users who claim to belong to this center */
|
2020-01-08 00:47:10 +01:00
|
|
|
|
Ctr->NumUsrsWhoClaimToBelongToCtr.Valid = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/************* Get full list of centers **************/
|
2020-01-08 00:47:10 +01:00
|
|
|
|
/************* with number of users who claim to belong to them **************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-06-02 13:09:30 +02:00
|
|
|
|
void Ctr_GetFullListOfCenters (long InsCod,Ctr_Order_t SelectedOrder)
|
2020-01-08 00:47:10 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumCtr;
|
2021-03-07 21:21:04 +01:00
|
|
|
|
struct Ctr_Center *Ctr;
|
|
|
|
|
|
|
|
|
|
/***** Get centers from database *****/
|
2021-06-02 13:09:30 +02:00
|
|
|
|
Gbl.Hierarchy.Ctrs.Num = Ctr_DB_GetListOfCtrsFullWithNumUsrs (&mysql_res,InsCod,SelectedOrder);
|
2021-04-16 13:51:12 +02:00
|
|
|
|
|
|
|
|
|
if (Gbl.Hierarchy.Ctrs.Num) // Centers found...
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Create list with courses in degree *****/
|
2021-04-16 13:51:12 +02:00
|
|
|
|
if ((Gbl.Hierarchy.Ctrs.Lst = calloc ((size_t) Gbl.Hierarchy.Ctrs.Num,
|
2021-02-15 16:25:55 +01:00
|
|
|
|
sizeof (*Gbl.Hierarchy.Ctrs.Lst))) == NULL)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get the centers *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
for (NumCtr = 0;
|
2020-01-08 14:04:25 +01:00
|
|
|
|
NumCtr < Gbl.Hierarchy.Ctrs.Num;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
NumCtr++)
|
|
|
|
|
{
|
2020-01-08 14:04:25 +01:00
|
|
|
|
Ctr = &(Gbl.Hierarchy.Ctrs.Lst[NumCtr]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/* Get center data */
|
2014-12-01 23:55:08 +01:00
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Ctr_GetDataOfCenterFromRow (Ctr,row);
|
2020-01-08 00:47:10 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/* Get number of users who claim to belong to this center (row[11]) */
|
2020-01-08 00:47:10 +01:00
|
|
|
|
Ctr->NumUsrsWhoClaimToBelongToCtr.Valid = false;
|
|
|
|
|
if (sscanf (row[11],"%u",&(Ctr->NumUsrsWhoClaimToBelongToCtr.NumUsrs)) == 1)
|
|
|
|
|
Ctr->NumUsrsWhoClaimToBelongToCtr.Valid = true;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/************************ Get data of center by code *************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
bool Ctr_GetDataOfCenterByCod (struct Ctr_Center *Ctr)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
bool CtrFound = false;
|
|
|
|
|
|
|
|
|
|
/***** Clear data *****/
|
2020-01-05 12:52:03 +01:00
|
|
|
|
Ctr->InsCod = -1L;
|
|
|
|
|
Ctr->PlcCod = -1L;
|
|
|
|
|
Ctr->Status = (Ctr_Status_t) 0;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Ctr->RequesterUsrCod = -1L;
|
2020-01-05 12:52:03 +01:00
|
|
|
|
Ctr->ShrtName[0] = '\0';
|
|
|
|
|
Ctr->FullName[0] = '\0';
|
|
|
|
|
Ctr->WWW[0] = '\0';
|
2020-01-08 00:47:10 +01:00
|
|
|
|
Ctr->NumUsrsWhoClaimToBelongToCtr.Valid = false;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Check if center code is correct *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (Ctr->CtrCod > 0)
|
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get data of a center from database *****/
|
2021-06-02 13:09:30 +02:00
|
|
|
|
if (Ctr_DB_GetDataOfCenterByCod (&mysql_res,Ctr->CtrCod)) // Center found...
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/* Get row */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Ctr_GetDataOfCenterFromRow (Ctr,row);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Set return value */
|
|
|
|
|
CtrFound = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return CtrFound;
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-19 11:00:14 +01:00
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/********** Get data of a center from a row resulting of a query *************/
|
2019-12-19 11:00:14 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
static void Ctr_GetDataOfCenterFromRow (struct Ctr_Center *Ctr,MYSQL_ROW row)
|
2019-12-19 11:00:14 +01:00
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get center code (row[0]) *****/
|
2019-12-19 11:00:14 +01:00
|
|
|
|
if ((Ctr->CtrCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongCenterExit ();
|
2019-12-19 11:00:14 +01:00
|
|
|
|
|
|
|
|
|
/***** Get institution code (row[1]) *****/
|
|
|
|
|
Ctr->InsCod = Str_ConvertStrCodToLongCod (row[1]);
|
|
|
|
|
|
|
|
|
|
/***** Get place code (row[2]) *****/
|
|
|
|
|
Ctr->PlcCod = Str_ConvertStrCodToLongCod (row[2]);
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get center status (row[3]) *****/
|
2019-12-19 11:00:14 +01:00
|
|
|
|
if (sscanf (row[3],"%u",&(Ctr->Status)) != 1)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongStatusExit ();
|
2019-12-19 11:00:14 +01:00
|
|
|
|
|
|
|
|
|
/***** Get requester user's code (row[4]) *****/
|
|
|
|
|
Ctr->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[4]);
|
|
|
|
|
|
2021-02-15 22:49:44 +01:00
|
|
|
|
/***** Get latitude (row[5], longitude (row[6]) and altitude (row[7])*****/
|
|
|
|
|
Ctr->Coord.Latitude = Map_GetLatitudeFromStr (row[5]);
|
2020-01-03 20:31:02 +01:00
|
|
|
|
Ctr->Coord.Longitude = Map_GetLongitudeFromStr (row[6]);
|
2021-02-15 22:49:44 +01:00
|
|
|
|
Ctr->Coord.Altitude = Map_GetAltitudeFromStr (row[7]);
|
2019-12-19 11:00:14 +01:00
|
|
|
|
|
2021-02-15 22:49:44 +01:00
|
|
|
|
/***** Get short name (row[8]), full name (row[9])
|
2021-03-07 21:21:04 +01:00
|
|
|
|
and URL (row[10]) of the center *****/
|
2021-02-15 22:49:44 +01:00
|
|
|
|
Str_Copy (Ctr->ShrtName,row[ 8],sizeof (Ctr->ShrtName) - 1);
|
|
|
|
|
Str_Copy (Ctr->FullName,row[ 9],sizeof (Ctr->FullName) - 1);
|
|
|
|
|
Str_Copy (Ctr->WWW ,row[10],sizeof (Ctr->WWW ) - 1);
|
2019-12-19 11:00:14 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/**************************** Free list of centers ***************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
void Ctr_FreeListCenters (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-01-08 14:04:25 +01:00
|
|
|
|
if (Gbl.Hierarchy.Ctrs.Lst)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Free memory used by the list of courses in degree *****/
|
2020-01-08 14:04:25 +01:00
|
|
|
|
free (Gbl.Hierarchy.Ctrs.Lst);
|
|
|
|
|
Gbl.Hierarchy.Ctrs.Lst = NULL;
|
|
|
|
|
Gbl.Hierarchy.Ctrs.Num = 0;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/************************** Write selector of center *************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
void Ctr_WriteSelectorOfCenter (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
extern const char *Txt_Center;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumCtrs;
|
|
|
|
|
unsigned NumCtr;
|
|
|
|
|
long CtrCod;
|
|
|
|
|
|
2019-10-20 22:00:28 +02:00
|
|
|
|
/***** Begin form *****/
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginFormGoTo (ActSeeDeg);
|
2019-11-05 15:47:35 +01:00
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
/***** Begin selector *****/
|
|
|
|
|
if (Gbl.Hierarchy.Ins.InsCod > 0)
|
|
|
|
|
HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,
|
|
|
|
|
"id=\"ctr\" name=\"ctr\" class=\"HIE_SEL\"");
|
|
|
|
|
else
|
|
|
|
|
HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE,
|
|
|
|
|
"id=\"ctr\" name=\"ctr\" class=\"HIE_SEL\""
|
|
|
|
|
" disabled=\"disabled\"");
|
|
|
|
|
HTM_OPTION (HTM_Type_STRING,"",
|
|
|
|
|
Gbl.Hierarchy.Ctr.CtrCod < 0,true,
|
|
|
|
|
"[%s]",Txt_Center);
|
|
|
|
|
|
|
|
|
|
if (Gbl.Hierarchy.Ins.InsCod > 0)
|
|
|
|
|
{
|
2021-06-02 13:09:30 +02:00
|
|
|
|
/***** Get centers in current institution from database *****/
|
|
|
|
|
NumCtrs = Ctr_DB_GetListOfCtrsInCurrentIns (&mysql_res);
|
2021-06-02 00:08:30 +02:00
|
|
|
|
for (NumCtr = 0;
|
|
|
|
|
NumCtr < NumCtrs;
|
|
|
|
|
NumCtr++)
|
|
|
|
|
{
|
|
|
|
|
/* Get next center */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/* Get center code (row[0]) */
|
|
|
|
|
if ((CtrCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
|
|
|
|
Err_WrongCenterExit ();
|
|
|
|
|
|
|
|
|
|
/* Write option */
|
|
|
|
|
HTM_OPTION (HTM_Type_LONG,&CtrCod,
|
|
|
|
|
Gbl.Hierarchy.Ctr.CtrCod > 0 &&
|
|
|
|
|
CtrCod == Gbl.Hierarchy.Ctr.CtrCod,false,
|
|
|
|
|
"%s",row[1]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
/***** End selector *****/
|
|
|
|
|
HTM_SELECT_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** End form *****/
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/*************************** List all the centers ****************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
static void Ctr_ListCentersForEdition (const struct Plc_Places *Places)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Another_place;
|
2021-03-07 21:21:04 +01:00
|
|
|
|
extern const char *Txt_CENTER_STATUS[Ctr_NUM_STATUS_TXT];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned NumCtr;
|
2021-03-07 21:21:04 +01:00
|
|
|
|
struct Ctr_Center *Ctr;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned NumPlc;
|
2017-03-07 01:56:41 +01:00
|
|
|
|
char WWW[Cns_MAX_BYTES_WWW + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
struct UsrData UsrDat;
|
|
|
|
|
bool ICanEdit;
|
2020-05-02 13:39:59 +02:00
|
|
|
|
unsigned NumDegs;
|
2020-05-03 20:58:03 +02:00
|
|
|
|
unsigned NumUsrsCtr;
|
2020-01-06 11:58:05 +01:00
|
|
|
|
unsigned NumUsrsInCrssOfCtr;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Ctr_StatusTxt_t StatusTxt;
|
2019-11-06 15:27:33 +01:00
|
|
|
|
unsigned StatusUnsigned;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Initialize structure with user's data *****/
|
|
|
|
|
Usr_UsrDataConstructor (&UsrDat);
|
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
/***** Begin table *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_BeginWidePadding (2);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
/***** Write heading *****/
|
|
|
|
|
Ctr_PutHeadCentersForEdition ();
|
2017-03-17 00:46:28 +01:00
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
/***** Write all the centers *****/
|
|
|
|
|
for (NumCtr = 0;
|
|
|
|
|
NumCtr < Gbl.Hierarchy.Ctrs.Num;
|
|
|
|
|
NumCtr++)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-06-02 00:08:30 +02:00
|
|
|
|
Ctr = &Gbl.Hierarchy.Ctrs.Lst[NumCtr];
|
|
|
|
|
|
|
|
|
|
ICanEdit = Ctr_CheckIfICanEditACenter (Ctr);
|
|
|
|
|
NumDegs = Deg_GetNumDegsInCtr (Ctr->CtrCod);
|
|
|
|
|
NumUsrsCtr = Usr_GetNumUsrsWhoClaimToBelongToCtr (Ctr);
|
|
|
|
|
NumUsrsInCrssOfCtr = Usr_GetNumUsrsInCrss (HieLvl_CTR,Ctr->CtrCod,
|
|
|
|
|
1 << Rol_STD |
|
|
|
|
|
1 << Rol_NET |
|
|
|
|
|
1 << Rol_TCH); // Any user
|
|
|
|
|
|
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
|
|
|
|
|
/* Put icon to remove center */
|
|
|
|
|
HTM_TD_Begin ("class=\"BM\"");
|
|
|
|
|
if (!ICanEdit || // I cannot edit
|
|
|
|
|
NumDegs || // Center has degrees
|
|
|
|
|
NumUsrsCtr || // Center has users who claim to belong to it
|
|
|
|
|
NumUsrsInCrssOfCtr) // Center has users
|
|
|
|
|
Ico_PutIconRemovalNotAllowed ();
|
|
|
|
|
else // I can remove center
|
|
|
|
|
Ico_PutContextualIconToRemove (ActRemCtr,NULL,
|
|
|
|
|
Ctr_PutParamOtherCtrCod,&Ctr->CtrCod);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Center code */
|
|
|
|
|
HTM_TD_Begin ("class=\"DAT CODE\"");
|
|
|
|
|
HTM_Long (Ctr->CtrCod);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Center logo */
|
|
|
|
|
HTM_TD_Begin ("title=\"%s\" class=\"HIE_LOGO\"",Ctr->FullName);
|
|
|
|
|
Lgo_DrawLogo (HieLvl_CTR,Ctr->CtrCod,Ctr->ShrtName,20,NULL,true);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Place */
|
|
|
|
|
HTM_TD_Begin ("class=\"DAT LM\"");
|
|
|
|
|
if (ICanEdit)
|
|
|
|
|
{
|
|
|
|
|
Frm_BeginForm (ActChgCtrPlc);
|
|
|
|
|
Ctr_PutParamOtherCtrCod (&Ctr->CtrCod);
|
|
|
|
|
HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,
|
|
|
|
|
"name=\"PlcCod\" class=\"PLC_SEL\"");
|
|
|
|
|
HTM_OPTION (HTM_Type_STRING,"0",
|
|
|
|
|
Ctr->PlcCod == 0,false,
|
|
|
|
|
"%s",Txt_Another_place);
|
|
|
|
|
for (NumPlc = 0;
|
|
|
|
|
NumPlc < Places->Num;
|
|
|
|
|
NumPlc++)
|
|
|
|
|
HTM_OPTION (HTM_Type_LONG,&Places->Lst[NumPlc].PlcCod,
|
|
|
|
|
Places->Lst[NumPlc].PlcCod == Ctr->PlcCod,false,
|
|
|
|
|
"%s",Places->Lst[NumPlc].ShrtName);
|
|
|
|
|
HTM_SELECT_End ();
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
for (NumPlc = 0;
|
|
|
|
|
NumPlc < Places->Num;
|
|
|
|
|
NumPlc++)
|
|
|
|
|
if (Places->Lst[NumPlc].PlcCod == Ctr->PlcCod)
|
|
|
|
|
HTM_Txt (Places->Lst[NumPlc].ShrtName);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Center short name */
|
|
|
|
|
HTM_TD_Begin ("class=\"DAT LM\"");
|
|
|
|
|
if (ICanEdit)
|
|
|
|
|
{
|
|
|
|
|
Frm_BeginForm (ActRenCtrSho);
|
|
|
|
|
Ctr_PutParamOtherCtrCod (&Ctr->CtrCod);
|
|
|
|
|
HTM_INPUT_TEXT ("ShortName",Cns_HIERARCHY_MAX_CHARS_SHRT_NAME,Ctr->ShrtName,
|
|
|
|
|
HTM_SUBMIT_ON_CHANGE,
|
|
|
|
|
"class=\"INPUT_SHORT_NAME\"");
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
HTM_Txt (Ctr->ShrtName);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Center full name */
|
|
|
|
|
HTM_TD_Begin ("class=\"DAT LM\"");
|
|
|
|
|
if (ICanEdit)
|
|
|
|
|
{
|
|
|
|
|
Frm_BeginForm (ActRenCtrFul);
|
|
|
|
|
Ctr_PutParamOtherCtrCod (&Ctr->CtrCod);
|
|
|
|
|
HTM_INPUT_TEXT ("FullName",Cns_HIERARCHY_MAX_CHARS_FULL_NAME,Ctr->FullName,
|
|
|
|
|
HTM_SUBMIT_ON_CHANGE,
|
|
|
|
|
"class=\"INPUT_FULL_NAME\"");
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
HTM_Txt (Ctr->FullName);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Center WWW */
|
|
|
|
|
HTM_TD_Begin ("class=\"DAT LM\"");
|
|
|
|
|
if (ICanEdit)
|
|
|
|
|
{
|
|
|
|
|
Frm_BeginForm (ActChgCtrWWW);
|
|
|
|
|
Ctr_PutParamOtherCtrCod (&Ctr->CtrCod);
|
|
|
|
|
HTM_INPUT_URL ("WWW",Ctr->WWW,HTM_SUBMIT_ON_CHANGE,
|
|
|
|
|
"class=\"INPUT_WWW_NARROW\" required=\"required\"");
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Str_Copy (WWW,Ctr->WWW,sizeof (WWW) - 1);
|
|
|
|
|
HTM_DIV_Begin ("class=\"EXTERNAL_WWW_SHORT\"");
|
|
|
|
|
HTM_A_Begin ("href=\"%s\" target=\"_blank\""
|
|
|
|
|
" class=\"DAT\" title=\"%s\"",Ctr->WWW,Ctr->WWW);
|
|
|
|
|
HTM_Txt (WWW);
|
|
|
|
|
HTM_A_End ();
|
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
}
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Number of users who claim to belong to this center */
|
|
|
|
|
HTM_TD_Begin ("class=\"DAT RM\"");
|
|
|
|
|
HTM_Unsigned (NumUsrsCtr);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Number of degrees */
|
|
|
|
|
HTM_TD_Begin ("class=\"DAT RM\"");
|
|
|
|
|
HTM_Unsigned (NumDegs);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Number of users in courses of this center */
|
|
|
|
|
HTM_TD_Begin ("class=\"DAT RM\"");
|
|
|
|
|
HTM_Unsigned (NumUsrsInCrssOfCtr);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Center requester */
|
|
|
|
|
UsrDat.UsrCod = Ctr->RequesterUsrCod;
|
|
|
|
|
Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,
|
|
|
|
|
Usr_DONT_GET_PREFS,
|
|
|
|
|
Usr_DONT_GET_ROLE_IN_CURRENT_CRS);
|
|
|
|
|
HTM_TD_Begin ("class=\"DAT INPUT_REQUESTER LT\"");
|
|
|
|
|
Msg_WriteMsgAuthor (&UsrDat,true,NULL);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Center status */
|
|
|
|
|
StatusTxt = Ctr_GetStatusTxtFromStatusBits (Ctr->Status);
|
|
|
|
|
HTM_TD_Begin ("class=\"DAT LM\"");
|
|
|
|
|
if (Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM &&
|
|
|
|
|
StatusTxt == Ctr_STATUS_PENDING)
|
|
|
|
|
{
|
|
|
|
|
Frm_BeginForm (ActChgCtrSta);
|
|
|
|
|
Ctr_PutParamOtherCtrCod (&Ctr->CtrCod);
|
|
|
|
|
HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,
|
|
|
|
|
"name=\"Status\" class=\"INPUT_STATUS\"");
|
|
|
|
|
|
|
|
|
|
StatusUnsigned = (unsigned) Ctr_GetStatusBitsFromStatusTxt (Ctr_STATUS_PENDING);
|
|
|
|
|
HTM_OPTION (HTM_Type_UNSIGNED,&StatusUnsigned,true,false,
|
|
|
|
|
"%s",Txt_CENTER_STATUS[Ctr_STATUS_PENDING]);
|
|
|
|
|
|
|
|
|
|
StatusUnsigned = (unsigned) Ctr_GetStatusBitsFromStatusTxt (Ctr_STATUS_ACTIVE);
|
|
|
|
|
HTM_OPTION (HTM_Type_UNSIGNED,&StatusUnsigned,false,false,
|
|
|
|
|
"%s",Txt_CENTER_STATUS[Ctr_STATUS_ACTIVE]);
|
|
|
|
|
|
|
|
|
|
HTM_SELECT_End ();
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
}
|
|
|
|
|
else if (StatusTxt != Ctr_STATUS_ACTIVE) // If active ==> do not show anything
|
|
|
|
|
HTM_Txt (Txt_CENTER_STATUS[StatusTxt]);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** End table *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free memory used for user's data *****/
|
|
|
|
|
Usr_UsrDataDestructor (&UsrDat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/************** Check if I can edit, remove, etc. a center *******************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
static bool Ctr_CheckIfICanEditACenter (struct Ctr_Center *Ctr)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-06-04 18:18:54 +02:00
|
|
|
|
return (bool) (Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM || // I am an institution administrator or higher
|
2021-03-07 21:21:04 +01:00
|
|
|
|
((Ctr->Status & Ctr_STATUS_BIT_PENDING) != 0 && // Center is not yet activated
|
2017-03-09 21:11:06 +01:00
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod == Ctr->RequesterUsrCod)); // I am the requester
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Set StatusTxt depending on status bits ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
// Ctr_STATUS_UNKNOWN = 0 // Other
|
|
|
|
|
// Ctr_STATUS_ACTIVE = 1 // 00 (Status == 0)
|
|
|
|
|
// Ctr_STATUS_PENDING = 2 // 01 (Status == Ctr_STATUS_BIT_PENDING)
|
|
|
|
|
// Ctr_STATUS_REMOVED = 3 // 1- (Status & Ctr_STATUS_BIT_REMOVED)
|
|
|
|
|
|
|
|
|
|
static Ctr_StatusTxt_t Ctr_GetStatusTxtFromStatusBits (Ctr_Status_t Status)
|
|
|
|
|
{
|
|
|
|
|
if (Status == 0)
|
|
|
|
|
return Ctr_STATUS_ACTIVE;
|
|
|
|
|
if (Status == Ctr_STATUS_BIT_PENDING)
|
|
|
|
|
return Ctr_STATUS_PENDING;
|
|
|
|
|
if (Status & Ctr_STATUS_BIT_REMOVED)
|
|
|
|
|
return Ctr_STATUS_REMOVED;
|
|
|
|
|
return Ctr_STATUS_UNKNOWN;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Set status bits depending on StatusTxt ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
// Ctr_STATUS_UNKNOWN = 0 // Other
|
|
|
|
|
// Ctr_STATUS_ACTIVE = 1 // 00 (Status == 0)
|
|
|
|
|
// Ctr_STATUS_PENDING = 2 // 01 (Status == Ctr_STATUS_BIT_PENDING)
|
|
|
|
|
// Ctr_STATUS_REMOVED = 3 // 1- (Status & Ctr_STATUS_BIT_REMOVED)
|
|
|
|
|
|
|
|
|
|
static Ctr_Status_t Ctr_GetStatusBitsFromStatusTxt (Ctr_StatusTxt_t StatusTxt)
|
|
|
|
|
{
|
|
|
|
|
switch (StatusTxt)
|
|
|
|
|
{
|
|
|
|
|
case Ctr_STATUS_UNKNOWN:
|
|
|
|
|
case Ctr_STATUS_ACTIVE:
|
|
|
|
|
return (Ctr_Status_t) 0;
|
|
|
|
|
case Ctr_STATUS_PENDING:
|
|
|
|
|
return Ctr_STATUS_BIT_PENDING;
|
|
|
|
|
case Ctr_STATUS_REMOVED:
|
|
|
|
|
return Ctr_STATUS_BIT_REMOVED;
|
|
|
|
|
}
|
|
|
|
|
return (Ctr_Status_t) 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/******************** Write parameter with code of center ********************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Ctr_PutParamCtrCod (long CtrCod)
|
|
|
|
|
{
|
2019-11-03 13:19:32 +01:00
|
|
|
|
Par_PutHiddenParamLong (NULL,"ctr",CtrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***************** Write parameter with code of other center *****************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-10-13 22:34:31 +02:00
|
|
|
|
static void Ctr_PutParamOtherCtrCod (void *CtrCod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-10-13 22:34:31 +02:00
|
|
|
|
if (CtrCod)
|
|
|
|
|
Par_PutHiddenParamLong (NULL,"OthCtrCod",*((long *) CtrCod));
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/****************** Get parameter with code of other center ******************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-05-31 21:05:59 +02:00
|
|
|
|
long Ctr_GetAndCheckParamOtherCtrCod (long MinCodAllowed)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2016-10-23 18:50:21 +02:00
|
|
|
|
long CtrCod;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get and check parameter with code of center *****/
|
2017-05-31 21:05:59 +02:00
|
|
|
|
if ((CtrCod = Par_GetParToLong ("OthCtrCod")) < MinCodAllowed)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongCenterExit ();
|
2016-10-23 18:50:21 +02:00
|
|
|
|
|
|
|
|
|
return CtrCod;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/******************************* Remove a center *****************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
void Ctr_RemoveCenter (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
extern const char *Txt_To_remove_a_center_you_must_first_remove_all_degrees_and_teachers_in_the_center;
|
|
|
|
|
extern const char *Txt_Center_X_removed;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char PathCtr[PATH_MAX + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Center constructor *****/
|
|
|
|
|
Ctr_EditingCenterConstructor ();
|
2019-04-06 21:39:35 +02:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get center code *****/
|
2019-04-06 21:39:35 +02:00
|
|
|
|
Ctr_EditingCtr->CtrCod = Ctr_GetAndCheckParamOtherCtrCod (1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get data of the center from database *****/
|
|
|
|
|
Ctr_GetDataOfCenterByCod (Ctr_EditingCtr);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Check if this center has teachers *****/
|
|
|
|
|
if (Deg_GetNumDegsInCtr (Ctr_EditingCtr->CtrCod)) // Center has degrees
|
2020-01-05 01:46:45 +01:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Txt_To_remove_a_center_you_must_first_remove_all_degrees_and_teachers_in_the_center);
|
|
|
|
|
else if (Usr_GetNumUsrsWhoClaimToBelongToCtr (Ctr_EditingCtr)) // Center has users who claim to belong to it
|
2020-01-05 01:46:45 +01:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Txt_To_remove_a_center_you_must_first_remove_all_degrees_and_teachers_in_the_center);
|
2021-05-27 23:30:16 +02:00
|
|
|
|
else if (Usr_GetNumUsrsInCrss (HieLvl_CTR,Ctr_EditingCtr->CtrCod,
|
2020-01-08 23:49:04 +01:00
|
|
|
|
1 << Rol_STD |
|
|
|
|
|
1 << Rol_NET |
|
2021-03-07 21:21:04 +01:00
|
|
|
|
1 << Rol_TCH)) // Center has users
|
2020-01-05 01:46:45 +01:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Txt_To_remove_a_center_you_must_first_remove_all_degrees_and_teachers_in_the_center);
|
|
|
|
|
else // Center has no degrees or users ==> remove it
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Remove all the threads and posts in forums of the center *****/
|
2021-05-27 23:30:16 +02:00
|
|
|
|
For_RemoveForums (HieLvl_CTR,Ctr_EditingCtr->CtrCod);
|
2016-10-28 00:23:02 +02:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Remove surveys of the center *****/
|
2021-05-27 23:30:16 +02:00
|
|
|
|
Svy_RemoveSurveys (HieLvl_CTR,Ctr_EditingCtr->CtrCod);
|
2016-10-28 00:23:02 +02:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Remove information related to files in center *****/
|
2021-05-27 00:30:06 +02:00
|
|
|
|
Brw_DB_RemoveCtrFiles (Ctr_EditingCtr->CtrCod);
|
2015-01-25 18:50:43 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Remove all rooms in center *****/
|
2021-07-08 15:00:17 +02:00
|
|
|
|
Roo_DB_RemoveAllRoomsInCtr (Ctr_EditingCtr->CtrCod);
|
2019-01-05 11:51:22 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Remove directories of the center *****/
|
2021-02-15 16:25:55 +01:00
|
|
|
|
snprintf (PathCtr,sizeof (PathCtr),"%s/%02u/%u",
|
2019-03-20 01:36:36 +01:00
|
|
|
|
Cfg_PATH_CTR_PUBLIC,
|
2019-04-06 21:39:35 +02:00
|
|
|
|
(unsigned) (Ctr_EditingCtr->CtrCod % 100),
|
2021-02-15 16:25:55 +01:00
|
|
|
|
(unsigned) Ctr_EditingCtr->CtrCod);
|
2016-10-06 22:18:33 +02:00
|
|
|
|
Fil_RemoveTree (PathCtr);
|
2015-01-20 18:55:59 +01:00
|
|
|
|
|
2021-05-28 19:59:55 +02:00
|
|
|
|
/***** Remove administrators of this center *****/
|
2021-06-11 11:36:34 +02:00
|
|
|
|
Adm_DB_RemAdmins (HieLvl_CTR,Ctr_EditingCtr->CtrCod);
|
2021-05-28 19:59:55 +02:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Remove center *****/
|
2021-06-02 13:09:30 +02:00
|
|
|
|
Ctr_DB_RemoveCenter (Ctr_EditingCtr->CtrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-01-05 00:51:12 +01:00
|
|
|
|
/***** Flush caches *****/
|
2020-01-05 02:18:20 +01:00
|
|
|
|
Deg_FlushCacheNumDegsInCtr ();
|
2020-01-05 01:46:45 +01:00
|
|
|
|
Crs_FlushCacheNumCrssInCtr ();
|
|
|
|
|
Usr_FlushCacheNumUsrsWhoClaimToBelongToCtr ();
|
2020-01-05 00:51:12 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Write message to show the change made *****/
|
2019-04-08 15:33:29 +02:00
|
|
|
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Txt_Center_X_removed,
|
2019-04-08 15:33:29 +02:00
|
|
|
|
Ctr_EditingCtr->FullName);
|
2019-06-13 10:14:05 +02:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Ctr_EditingCtr->CtrCod = -1L; // To not showing button to go to center
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/************************ Change the place of a center ***********************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-06-12 19:14:05 +02:00
|
|
|
|
void Ctr_ChangeCtrPlc (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
extern const char *Txt_The_place_of_the_center_has_changed;
|
2016-03-05 20:39:41 +01:00
|
|
|
|
long NewPlcCod;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Center constructor *****/
|
|
|
|
|
Ctr_EditingCenterConstructor ();
|
2019-04-06 21:39:35 +02:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get center code *****/
|
2019-04-06 21:39:35 +02:00
|
|
|
|
Ctr_EditingCtr->CtrCod = Ctr_GetAndCheckParamOtherCtrCod (1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-05-31 21:05:59 +02:00
|
|
|
|
/***** Get parameter with place code *****/
|
2016-03-05 20:39:41 +01:00
|
|
|
|
NewPlcCod = Plc_GetParamPlcCod ();
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get data of center from database *****/
|
|
|
|
|
Ctr_GetDataOfCenterByCod (Ctr_EditingCtr);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Update place in table of centers *****/
|
2021-06-02 00:08:30 +02:00
|
|
|
|
Ctr_DB_UpdateCtrPlc (Ctr_EditingCtr->CtrCod,NewPlcCod);
|
2019-04-06 21:39:35 +02:00
|
|
|
|
Ctr_EditingCtr->PlcCod = NewPlcCod;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-03-09 20:12:44 +01:00
|
|
|
|
/***** Create alert to show the change made
|
2021-03-07 21:21:04 +01:00
|
|
|
|
and put button to go to center changed *****/
|
2019-03-09 20:12:44 +01:00
|
|
|
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Txt_The_place_of_the_center_has_changed);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/************************ Change the name of a center ************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
void Ctr_RenameCenterShort (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Center constructor *****/
|
|
|
|
|
Ctr_EditingCenterConstructor ();
|
2019-04-06 21:39:35 +02:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Rename center *****/
|
2019-04-06 21:39:35 +02:00
|
|
|
|
Ctr_EditingCtr->CtrCod = Ctr_GetAndCheckParamOtherCtrCod (1);
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Ctr_RenameCenter (Ctr_EditingCtr,Cns_SHRT_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
void Ctr_RenameCenterFull (void)
|
2016-10-23 12:07:16 +02:00
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Center constructor *****/
|
|
|
|
|
Ctr_EditingCenterConstructor ();
|
2019-04-06 21:39:35 +02:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Rename center *****/
|
2019-04-06 21:39:35 +02:00
|
|
|
|
Ctr_EditingCtr->CtrCod = Ctr_GetAndCheckParamOtherCtrCod (1);
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Ctr_RenameCenter (Ctr_EditingCtr,Cns_FULL_NAME);
|
2019-04-06 21:39:35 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/************************ Change the name of a center ************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
void Ctr_RenameCenter (struct Ctr_Center *Ctr,Cns_ShrtOrFullName_t ShrtOrFullName)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
extern const char *Txt_The_center_X_already_exists;
|
|
|
|
|
extern const char *Txt_The_center_X_has_been_renamed_as_Y;
|
|
|
|
|
extern const char *Txt_The_name_of_the_center_X_has_not_changed;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
const char *ParamName = NULL; // Initialized to avoid warning
|
|
|
|
|
const char *FieldName = NULL; // Initialized to avoid warning
|
2017-03-09 11:16:17 +01:00
|
|
|
|
unsigned MaxBytes = 0; // Initialized to avoid warning
|
2014-12-01 23:55:08 +01:00
|
|
|
|
char *CurrentCtrName = NULL; // Initialized to avoid warning
|
2021-02-11 22:57:09 +01:00
|
|
|
|
char NewCtrName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-10-28 10:03:37 +02:00
|
|
|
|
switch (ShrtOrFullName)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2016-10-28 10:03:37 +02:00
|
|
|
|
case Cns_SHRT_NAME:
|
2014-12-01 23:55:08 +01:00
|
|
|
|
ParamName = "ShortName";
|
|
|
|
|
FieldName = "ShortName";
|
2021-02-11 22:57:09 +01:00
|
|
|
|
MaxBytes = Cns_HIERARCHY_MAX_BYTES_SHRT_NAME;
|
2016-10-28 10:03:37 +02:00
|
|
|
|
CurrentCtrName = Ctr->ShrtName;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
case Cns_FULL_NAME:
|
|
|
|
|
ParamName = "FullName";
|
|
|
|
|
FieldName = "FullName";
|
2021-02-11 22:57:09 +01:00
|
|
|
|
MaxBytes = Cns_HIERARCHY_MAX_BYTES_FULL_NAME;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
CurrentCtrName = Ctr->FullName;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Get parameters from form *****/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/* Get the new name for the center */
|
2017-03-09 11:16:17 +01:00
|
|
|
|
Par_GetParToText (ParamName,NewCtrName,MaxBytes);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get from the database the old names of the center *****/
|
|
|
|
|
Ctr_GetDataOfCenterByCod (Ctr);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Check if new name is empty *****/
|
|
|
|
|
if (!NewCtrName[0])
|
2019-12-20 00:30:54 +01:00
|
|
|
|
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
2019-01-02 15:10:51 +01:00
|
|
|
|
/***** Check if old and new names are the same
|
|
|
|
|
(this happens when return is pressed without changes) *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (strcmp (CurrentCtrName,NewCtrName)) // Different names
|
|
|
|
|
{
|
|
|
|
|
/***** If degree was in database... *****/
|
2021-06-02 00:08:30 +02:00
|
|
|
|
if (Ctr_DB_CheckIfCtrNameExistsInIns (ParamName,NewCtrName,Ctr->CtrCod,Gbl.Hierarchy.Ins.InsCod))
|
2019-03-09 20:12:44 +01:00
|
|
|
|
Ale_CreateAlert (Ale_WARNING,NULL,
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Txt_The_center_X_already_exists,
|
2019-03-09 20:12:44 +01:00
|
|
|
|
NewCtrName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Update the table changing old name by new name */
|
2021-06-02 00:08:30 +02:00
|
|
|
|
Ctr_DB_UpdateCtrName (Ctr->CtrCod,FieldName,NewCtrName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-03-01 19:23:02 +01:00
|
|
|
|
/* Write message to show the change made */
|
2019-03-09 20:12:44 +01:00
|
|
|
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Txt_The_center_X_has_been_renamed_as_Y,
|
2019-03-09 20:12:44 +01:00
|
|
|
|
CurrentCtrName,NewCtrName);
|
2016-03-01 19:23:02 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/* Change current center name in order to display it properly */
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (CurrentCtrName,NewCtrName,MaxBytes);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // The same name
|
2019-03-09 20:12:44 +01:00
|
|
|
|
Ale_CreateAlert (Ale_INFO,NULL,
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Txt_The_name_of_the_center_X_has_not_changed,
|
2019-03-09 20:12:44 +01:00
|
|
|
|
CurrentCtrName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/************************* Change the URL of a center ************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Ctr_ChangeCtrWWW (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_The_new_web_address_is_X;
|
2017-03-07 01:56:41 +01:00
|
|
|
|
char NewWWW[Cns_MAX_BYTES_WWW + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Center constructor *****/
|
|
|
|
|
Ctr_EditingCenterConstructor ();
|
2019-04-06 21:39:35 +02:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get the code of the center *****/
|
2019-04-06 21:39:35 +02:00
|
|
|
|
Ctr_EditingCtr->CtrCod = Ctr_GetAndCheckParamOtherCtrCod (1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get the new WWW for the center *****/
|
2017-03-07 01:56:41 +01:00
|
|
|
|
Par_GetParToText ("WWW",NewWWW,Cns_MAX_BYTES_WWW);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get data of center *****/
|
|
|
|
|
Ctr_GetDataOfCenterByCod (Ctr_EditingCtr);
|
2016-03-01 23:58:48 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Check if new WWW is empty *****/
|
|
|
|
|
if (NewWWW[0])
|
|
|
|
|
{
|
2016-10-23 14:49:03 +02:00
|
|
|
|
/***** Update database changing old WWW by new WWW *****/
|
2021-06-02 00:08:30 +02:00
|
|
|
|
Ctr_DB_UpdateCtrWWW (Ctr_EditingCtr->CtrCod,NewWWW);
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (Ctr_EditingCtr->WWW,NewWWW,sizeof (Ctr_EditingCtr->WWW) - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-05-11 20:55:04 +02:00
|
|
|
|
/***** Write message to show the change made
|
2021-03-07 21:21:04 +01:00
|
|
|
|
and put button to go to center changed *****/
|
2019-03-09 20:12:44 +01:00
|
|
|
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
|
|
|
|
Txt_The_new_web_address_is_X,
|
|
|
|
|
NewWWW);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
2019-12-20 00:30:54 +01:00
|
|
|
|
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
2016-10-23 14:49:03 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/*********************** Change the status of a center ***********************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Ctr_ChangeCtrStatus (void)
|
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
extern const char *Txt_The_status_of_the_center_X_has_changed;
|
2021-06-02 23:24:40 +02:00
|
|
|
|
Ctr_Status_t NewStatus;
|
|
|
|
|
Ctr_StatusTxt_t NewStatusTxt;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Center constructor *****/
|
|
|
|
|
Ctr_EditingCenterConstructor ();
|
2019-04-06 21:39:35 +02:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get center code *****/
|
2019-04-06 21:39:35 +02:00
|
|
|
|
Ctr_EditingCtr->CtrCod = Ctr_GetAndCheckParamOtherCtrCod (1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-05-31 21:05:59 +02:00
|
|
|
|
/***** Get parameter with status *****/
|
2021-06-02 23:24:40 +02:00
|
|
|
|
NewStatus = (Ctr_Status_t)
|
|
|
|
|
Par_GetParToUnsignedLong ("Status",
|
|
|
|
|
0,
|
|
|
|
|
(unsigned long) Ctr_MAX_STATUS,
|
|
|
|
|
(unsigned long) Ctr_WRONG_STATUS);
|
|
|
|
|
if (NewStatus == Ctr_WRONG_STATUS)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongStatusExit ();
|
2021-06-02 23:24:40 +02:00
|
|
|
|
NewStatusTxt = Ctr_GetStatusTxtFromStatusBits (NewStatus);
|
|
|
|
|
NewStatus = Ctr_GetStatusBitsFromStatusTxt (NewStatusTxt); // New status
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get data of center *****/
|
|
|
|
|
Ctr_GetDataOfCenterByCod (Ctr_EditingCtr);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Update status in table of centers *****/
|
2021-06-02 23:24:40 +02:00
|
|
|
|
Ctr_DB_UpdateCtrStatus (Ctr_EditingCtr->CtrCod,NewStatus);
|
|
|
|
|
Ctr_EditingCtr->Status = NewStatus;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-05-11 20:55:04 +02:00
|
|
|
|
/***** Write message to show the change made
|
2021-03-07 21:21:04 +01:00
|
|
|
|
and put button to go to center changed *****/
|
2019-03-09 20:12:44 +01:00
|
|
|
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Txt_The_status_of_the_center_X_has_changed,
|
2019-04-06 21:39:35 +02:00
|
|
|
|
Ctr_EditingCtr->ShrtName);
|
2019-04-08 15:33:29 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/********* Show alerts after changing a center and continue editing **********/
|
2019-04-08 15:33:29 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Ctr_ContEditAfterChgCtr (void)
|
|
|
|
|
{
|
|
|
|
|
/***** Write message to show the change made
|
2021-03-07 21:21:04 +01:00
|
|
|
|
and put button to go to center changed *****/
|
2017-05-11 20:55:04 +02:00
|
|
|
|
Ctr_ShowAlertAndButtonToGoToCtr ();
|
2016-03-01 19:23:02 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Show the form again *****/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Ctr_EditCentersInternal ();
|
2016-03-01 19:23:02 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Center destructor *****/
|
|
|
|
|
Ctr_EditingCenterDestructor ();
|
2016-03-01 19:23:02 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-05-11 20:55:04 +02:00
|
|
|
|
/***************** Write message to show the change made ********************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***************** and put button to go to center changed ********************/
|
2016-03-01 19:23:02 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-05-11 20:55:04 +02:00
|
|
|
|
static void Ctr_ShowAlertAndButtonToGoToCtr (void)
|
2016-03-01 19:23:02 +01:00
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
// If the center being edited is different to the current one...
|
2019-04-06 21:39:35 +02:00
|
|
|
|
if (Ctr_EditingCtr->CtrCod != Gbl.Hierarchy.Ctr.CtrCod)
|
2016-03-01 23:58:48 +01:00
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Alert with button to go to center *****/
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Ale_ShowLastAlertAndButton (ActSeeDeg,NULL,NULL,
|
2020-04-08 13:40:21 +02:00
|
|
|
|
Ctr_PutParamGoToCtr,&Ctr_EditingCtr->CtrCod,
|
2019-12-30 12:25:45 +01:00
|
|
|
|
Btn_CONFIRM_BUTTON,
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Hie_BuildGoToMsg (Ctr_EditingCtr->ShrtName));
|
2019-12-30 12:25:45 +01:00
|
|
|
|
Hie_FreeGoToMsg ();
|
2016-03-01 23:58:48 +01:00
|
|
|
|
}
|
2017-05-11 20:55:04 +02:00
|
|
|
|
else
|
2017-05-11 21:53:37 +02:00
|
|
|
|
/***** Alert *****/
|
2019-03-09 20:12:44 +01:00
|
|
|
|
Ale_ShowAlerts (NULL);
|
2017-05-11 20:55:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-08 13:40:21 +02:00
|
|
|
|
static void Ctr_PutParamGoToCtr (void *CtrCod)
|
2017-05-11 20:55:04 +02:00
|
|
|
|
{
|
2020-04-08 13:40:21 +02:00
|
|
|
|
if (CtrCod)
|
2020-04-08 18:18:46 +02:00
|
|
|
|
Ctr_PutParamCtrCod (*((long *) CtrCod));
|
2016-03-01 19:23:02 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/********************* Put a form to create a new center *********************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
static void Ctr_PutFormToCreateCenter (const struct Plc_Places *Places)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
extern const char *Txt_New_center;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Another_place;
|
2021-03-07 21:21:04 +01:00
|
|
|
|
extern const char *Txt_Create_center;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned NumPlc;
|
|
|
|
|
|
2019-10-20 22:00:28 +02:00
|
|
|
|
/***** Begin form *****/
|
2017-06-04 18:18:54 +02:00
|
|
|
|
if (Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM)
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginForm (ActNewCtr);
|
2017-06-04 18:18:54 +02:00
|
|
|
|
else if (Gbl.Usrs.Me.Role.Max >= Rol_GST)
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginForm (ActReqCtr);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NoPermissionExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box and table *****/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Box_BoxTableBegin (NULL,Txt_New_center,
|
2020-03-26 02:54:30 +01:00
|
|
|
|
NULL,NULL,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
NULL,Box_NOT_CLOSABLE,2);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-04-30 02:35:25 +02:00
|
|
|
|
/***** Write heading *****/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Ctr_PutHeadCentersForEdition ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 23:18:45 +02:00
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
/***** Column to remove center, disabled here *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"BM\"");
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Center code *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"CODE\"");
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Center logo *****/
|
|
|
|
|
HTM_TD_Begin ("title=\"%s\" class=\"HIE_LOGO\"",Ctr_EditingCtr->FullName);
|
|
|
|
|
Lgo_DrawLogo (HieLvl_CTR,-1L,"",20,NULL,true);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Place *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"LM\"");
|
|
|
|
|
HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE,
|
|
|
|
|
"name=\"PlcCod\" class=\"PLC_SEL\"");
|
|
|
|
|
HTM_OPTION (HTM_Type_STRING,"0",
|
|
|
|
|
Ctr_EditingCtr->PlcCod == 0,false,
|
|
|
|
|
"%s",Txt_Another_place);
|
|
|
|
|
for (NumPlc = 0;
|
|
|
|
|
NumPlc < Places->Num;
|
|
|
|
|
NumPlc++)
|
|
|
|
|
HTM_OPTION (HTM_Type_LONG,&Places->Lst[NumPlc].PlcCod,
|
|
|
|
|
Places->Lst[NumPlc].PlcCod == Ctr_EditingCtr->PlcCod,false,
|
|
|
|
|
"%s",Places->Lst[NumPlc].ShrtName);
|
|
|
|
|
HTM_SELECT_End ();
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Center short name *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"LM\"");
|
|
|
|
|
HTM_INPUT_TEXT ("ShortName",Cns_HIERARCHY_MAX_CHARS_SHRT_NAME,Ctr_EditingCtr->ShrtName,
|
|
|
|
|
HTM_DONT_SUBMIT_ON_CHANGE,
|
|
|
|
|
"class=\"INPUT_SHORT_NAME\" required=\"required\"");
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Center full name *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"LM\"");
|
|
|
|
|
HTM_INPUT_TEXT ("FullName",Cns_HIERARCHY_MAX_CHARS_FULL_NAME,Ctr_EditingCtr->FullName,
|
|
|
|
|
HTM_DONT_SUBMIT_ON_CHANGE,
|
|
|
|
|
"class=\"INPUT_FULL_NAME\" required=\"required\"");
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Center WWW *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"LM\"");
|
|
|
|
|
HTM_INPUT_URL ("WWW",Ctr_EditingCtr->WWW,HTM_DONT_SUBMIT_ON_CHANGE,
|
|
|
|
|
"class=\"INPUT_WWW_NARROW\" required=\"required\"");
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Number of users who claim to belong to this center *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"DAT RM\"");
|
|
|
|
|
HTM_Unsigned (0);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Number of degrees *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"DAT RM\"");
|
|
|
|
|
HTM_Unsigned (0);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Number of users in courses of this center *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"DAT RM\"");
|
|
|
|
|
HTM_Unsigned (0);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Center requester *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"DAT INPUT_REQUESTER LT\"");
|
|
|
|
|
Msg_WriteMsgAuthor (&Gbl.Usrs.Me.UsrDat,true,NULL);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Center status *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"DAT LM\"");
|
|
|
|
|
HTM_TD_End ();
|
2019-10-07 23:18:45 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End table, send button and end box *****/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Box_BoxTableWithButtonEnd (Btn_CREATE_BUTTON,Txt_Create_center);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-03-26 14:57:47 +02:00
|
|
|
|
/***** End form *****/
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Write header with fields of a degree *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
static void Ctr_PutHeadCentersForSeeing (bool OrderSelectable)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
extern const char *Txt_CENTERS_HELP_ORDER[2];
|
|
|
|
|
extern const char *Txt_CENTERS_ORDER[2];
|
2015-12-09 22:05:21 +01:00
|
|
|
|
extern const char *Txt_Place;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Degrees_ABBREVIATION;
|
2015-12-09 22:05:21 +01:00
|
|
|
|
extern const char *Txt_Courses_ABBREVIATION;
|
2017-05-30 21:43:05 +02:00
|
|
|
|
extern const char *Txt_ROLES_PLURAL_BRIEF_Abc[Rol_NUM_ROLES];
|
2017-01-29 12:42:19 +01:00
|
|
|
|
Ctr_Order_t Order;
|
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
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
HTM_TH_Empty (1);
|
2019-10-11 01:02:51 +02:00
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
for (Order = (Ctr_Order_t) 0;
|
|
|
|
|
Order <= (Ctr_Order_t) (Ctr_NUM_ORDERS - 1);
|
|
|
|
|
Order++)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-06-02 00:08:30 +02:00
|
|
|
|
HTM_TH_Begin (1,1,Order == Ctr_ORDER_BY_CENTER ? "LM" :
|
|
|
|
|
"RM");
|
|
|
|
|
if (OrderSelectable)
|
|
|
|
|
{
|
|
|
|
|
Frm_BeginForm (ActSeeCtr);
|
|
|
|
|
Par_PutHiddenParamUnsigned (NULL,"Order",(unsigned) Order);
|
|
|
|
|
HTM_BUTTON_SUBMIT_Begin (Txt_CENTERS_HELP_ORDER[Order],
|
|
|
|
|
Order == Ctr_ORDER_BY_CENTER ? "BT_LINK LM TIT_TBL" :
|
|
|
|
|
"BT_LINK RM TIT_TBL",
|
|
|
|
|
NULL);
|
|
|
|
|
if (Order == Gbl.Hierarchy.Ctrs.SelectedOrder)
|
|
|
|
|
HTM_U_Begin ();
|
|
|
|
|
}
|
|
|
|
|
HTM_Txt (Txt_CENTERS_ORDER[Order]);
|
|
|
|
|
if (OrderSelectable)
|
|
|
|
|
{
|
|
|
|
|
if (Order == Gbl.Hierarchy.Ctrs.SelectedOrder)
|
|
|
|
|
HTM_U_End ();
|
|
|
|
|
HTM_BUTTON_End ();
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
}
|
|
|
|
|
HTM_TH_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2019-10-11 01:02:51 +02:00
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
HTM_TH (1,1,"LM",Txt_Place);
|
|
|
|
|
HTM_TH (1,1,"RM",Txt_Degrees_ABBREVIATION);
|
|
|
|
|
HTM_TH (1,1,"RM",Txt_Courses_ABBREVIATION);
|
|
|
|
|
HTM_TH_Begin (1,1,"RM");
|
|
|
|
|
HTM_TxtF ("%s+",Txt_ROLES_PLURAL_BRIEF_Abc[Rol_TCH]);
|
|
|
|
|
HTM_BR ();
|
|
|
|
|
HTM_Txt (Txt_ROLES_PLURAL_BRIEF_Abc[Rol_STD]);
|
|
|
|
|
HTM_TH_End ();
|
|
|
|
|
HTM_TH_Empty (1);
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Write header with fields of a degree *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
static void Ctr_PutHeadCentersForEdition (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Code;
|
|
|
|
|
extern const char *Txt_Place;
|
2021-03-07 21:21:04 +01:00
|
|
|
|
extern const char *Txt_Short_name_of_the_center;
|
|
|
|
|
extern const char *Txt_Full_name_of_the_center;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_WWW;
|
2015-12-14 16:44:14 +01:00
|
|
|
|
extern const char *Txt_Users;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Degrees_ABBREVIATION;
|
2017-05-30 21:43:05 +02:00
|
|
|
|
extern const char *Txt_ROLES_PLURAL_BRIEF_Abc[Rol_NUM_ROLES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Requester;
|
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
HTM_TH_Empty (1);
|
|
|
|
|
HTM_TH (1,1,"RM",Txt_Code);
|
|
|
|
|
HTM_TH_Empty (1);
|
|
|
|
|
HTM_TH (1,1,"LM",Txt_Place);
|
|
|
|
|
HTM_TH (1,1,"LM",Txt_Short_name_of_the_center);
|
|
|
|
|
HTM_TH (1,1,"LM",Txt_Full_name_of_the_center);
|
|
|
|
|
HTM_TH (1,1,"LM",Txt_WWW);
|
|
|
|
|
HTM_TH (1,1,"RM",Txt_Users);
|
|
|
|
|
HTM_TH (1,1,"RM",Txt_Degrees_ABBREVIATION);
|
|
|
|
|
HTM_TH_Begin (1,1,"RM");
|
|
|
|
|
HTM_TxtF ("%s+",Txt_ROLES_PLURAL_BRIEF_Abc[Rol_TCH]);
|
|
|
|
|
HTM_BR ();
|
|
|
|
|
HTM_Txt (Txt_ROLES_PLURAL_BRIEF_Abc[Rol_STD]);
|
|
|
|
|
HTM_TH_End ();
|
|
|
|
|
HTM_TH (1,1,"LM",Txt_Requester);
|
|
|
|
|
HTM_TH_Empty (1);
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/****************** Receive form to request a new center *********************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-05-05 21:49:00 +02:00
|
|
|
|
void Ctr_ReceiveFormReqCtr (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Center constructor *****/
|
|
|
|
|
Ctr_EditingCenterConstructor ();
|
2019-04-06 21:39:35 +02:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Receive form to request a new center *****/
|
2021-06-02 20:47:31 +02:00
|
|
|
|
Ctr_ReceiveFormRequestOrCreateCtr ((Ctr_Status_t) Ctr_STATUS_BIT_PENDING);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/******************* Receive form to create a new center *********************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-05-05 21:49:00 +02:00
|
|
|
|
void Ctr_ReceiveFormNewCtr (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Center constructor *****/
|
|
|
|
|
Ctr_EditingCenterConstructor ();
|
2019-04-06 21:39:35 +02:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Receive form to create a new center *****/
|
2021-06-02 20:47:31 +02:00
|
|
|
|
Ctr_ReceiveFormRequestOrCreateCtr ((Ctr_Status_t) 0);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/************* Receive form to request or create a new center ****************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-06-02 20:47:31 +02:00
|
|
|
|
static void Ctr_ReceiveFormRequestOrCreateCtr (Ctr_Status_t Status)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
extern const char *Txt_The_center_X_already_exists;
|
|
|
|
|
extern const char *Txt_Created_new_center_X;
|
|
|
|
|
extern const char *Txt_You_must_specify_the_web_address_of_the_new_center;
|
|
|
|
|
extern const char *Txt_You_must_specify_the_short_name_and_the_full_name_of_the_new_center;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get parameters from form *****/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/* Set center institution */
|
2019-04-06 21:39:35 +02:00
|
|
|
|
Ctr_EditingCtr->InsCod = Gbl.Hierarchy.Ins.InsCod;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get place */
|
2019-04-06 21:39:35 +02:00
|
|
|
|
if ((Ctr_EditingCtr->PlcCod = Plc_GetParamPlcCod ()) < 0) // 0 is reserved for "other place"
|
2019-02-16 14:37:34 +01:00
|
|
|
|
Ale_ShowAlert (Ale_ERROR,"Wrong place.");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-02 20:47:31 +02:00
|
|
|
|
/* Get center short name and full name */
|
2021-02-11 22:57:09 +01:00
|
|
|
|
Par_GetParToText ("ShortName",Ctr_EditingCtr->ShrtName,Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
|
2021-06-02 20:47:31 +02:00
|
|
|
|
Par_GetParToText ("FullName" ,Ctr_EditingCtr->FullName,Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/* Get center WWW */
|
2019-04-06 21:39:35 +02:00
|
|
|
|
Par_GetParToText ("WWW",Ctr_EditingCtr->WWW,Cns_MAX_BYTES_WWW);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-06 21:39:35 +02:00
|
|
|
|
if (Ctr_EditingCtr->ShrtName[0] &&
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Ctr_EditingCtr->FullName[0]) // If there's a center name
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-04-06 21:39:35 +02:00
|
|
|
|
if (Ctr_EditingCtr->WWW[0])
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** If name of center was in database... *****/
|
2021-06-02 00:08:30 +02:00
|
|
|
|
if (Ctr_DB_CheckIfCtrNameExistsInIns ("ShortName",Ctr_EditingCtr->ShrtName,-1L,Gbl.Hierarchy.Ins.InsCod))
|
2019-04-08 15:33:29 +02:00
|
|
|
|
Ale_CreateAlert (Ale_WARNING,NULL,
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Txt_The_center_X_already_exists,
|
2019-04-08 15:33:29 +02:00
|
|
|
|
Ctr_EditingCtr->ShrtName);
|
2021-06-02 00:08:30 +02:00
|
|
|
|
else if (Ctr_DB_CheckIfCtrNameExistsInIns ("FullName",Ctr_EditingCtr->FullName,-1L,Gbl.Hierarchy.Ins.InsCod))
|
2019-04-08 15:33:29 +02:00
|
|
|
|
Ale_CreateAlert (Ale_WARNING,NULL,
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Txt_The_center_X_already_exists,
|
2019-04-08 15:33:29 +02:00
|
|
|
|
Ctr_EditingCtr->FullName);
|
2021-03-07 21:21:04 +01:00
|
|
|
|
else // Add new center to database
|
2019-04-08 15:33:29 +02:00
|
|
|
|
{
|
2021-06-02 13:09:30 +02:00
|
|
|
|
Ctr_EditingCtr->CtrCod = Ctr_DB_CreateCenter (Ctr_EditingCtr,Status);
|
2019-04-08 15:33:29 +02:00
|
|
|
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Txt_Created_new_center_X,
|
2019-04-08 15:33:29 +02:00
|
|
|
|
Ctr_EditingCtr->FullName);
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2015-01-14 00:32:23 +01:00
|
|
|
|
else // If there is not a web
|
2019-04-08 15:33:29 +02:00
|
|
|
|
Ale_CreateAlert (Ale_WARNING,NULL,
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Txt_You_must_specify_the_web_address_of_the_new_center);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2021-03-07 21:21:04 +01:00
|
|
|
|
else // If there is not a center name
|
2019-04-08 15:33:29 +02:00
|
|
|
|
Ale_CreateAlert (Ale_WARNING,NULL,
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Txt_You_must_specify_the_short_name_and_the_full_name_of_the_new_center);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/************************** Get number of centers ****************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-05-03 20:58:03 +02:00
|
|
|
|
unsigned Ctr_GetCachedNumCtrsInSys (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-05-03 20:58:03 +02:00
|
|
|
|
unsigned NumCtrs;
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get number of centers from cache *****/
|
2021-05-27 23:30:16 +02:00
|
|
|
|
if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS,HieLvl_SYS,-1L,
|
2020-05-03 20:58:03 +02:00
|
|
|
|
FigCch_UNSIGNED,&NumCtrs))
|
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get current number of centers from database and update cache *****/
|
|
|
|
|
NumCtrs = (unsigned) DB_GetNumRowsTable ("ctr_centers");
|
2021-05-27 23:30:16 +02:00
|
|
|
|
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS,HieLvl_SYS,-1L,
|
2020-05-03 20:58:03 +02:00
|
|
|
|
FigCch_UNSIGNED,&NumCtrs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NumCtrs;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/******************* Get number of centers in a country **********************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-01-07 16:37:46 +01:00
|
|
|
|
void Ctr_FlushCacheNumCtrsInCty (void)
|
|
|
|
|
{
|
|
|
|
|
Gbl.Cache.NumCtrsInCty.CtyCod = -1L;
|
|
|
|
|
Gbl.Cache.NumCtrsInCty.NumCtrs = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-03 21:56:55 +02:00
|
|
|
|
static unsigned Ctr_GetNumCtrsInCty (long CtyCod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-01-07 16:37:46 +01:00
|
|
|
|
/***** 1. Fast check: Trivial case *****/
|
|
|
|
|
if (CtyCod <= 0)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
/***** 2. Fast check: If cached... *****/
|
|
|
|
|
if (CtyCod == Gbl.Cache.NumCtrsInCty.CtyCod)
|
|
|
|
|
return Gbl.Cache.NumCtrsInCty.NumCtrs;
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** 3. Slow: number of centers in a country from database *****/
|
2020-01-07 16:37:46 +01:00
|
|
|
|
Gbl.Cache.NumCtrsInCty.CtyCod = CtyCod;
|
2021-06-02 20:47:31 +02:00
|
|
|
|
Gbl.Cache.NumCtrsInCty.NumCtrs = Ctr_DB_GetNumCtrsInCty (CtyCod);
|
2021-05-27 23:30:16 +02:00
|
|
|
|
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS,HieLvl_CTY,Gbl.Cache.NumCtrsInCty.CtyCod,
|
2020-05-03 21:56:55 +02:00
|
|
|
|
FigCch_UNSIGNED,&Gbl.Cache.NumCtrsInCty.NumCtrs);
|
2020-01-07 16:37:46 +01:00
|
|
|
|
return Gbl.Cache.NumCtrsInCty.NumCtrs;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-03 20:58:03 +02:00
|
|
|
|
unsigned Ctr_GetCachedNumCtrsInCty (long CtyCod)
|
|
|
|
|
{
|
|
|
|
|
unsigned NumCtrs;
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get number of centers from cache *****/
|
2021-05-27 23:30:16 +02:00
|
|
|
|
if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS,HieLvl_CTY,CtyCod,
|
2020-05-03 20:58:03 +02:00
|
|
|
|
FigCch_UNSIGNED,&NumCtrs))
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get current number of centers from database and update cache *****/
|
2020-05-03 20:58:03 +02:00
|
|
|
|
NumCtrs = Ctr_GetNumCtrsInCty (CtyCod);
|
|
|
|
|
|
|
|
|
|
return NumCtrs;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/**************** Get number of centers in an institution ********************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-01-07 00:09:30 +01:00
|
|
|
|
void Ctr_FlushCacheNumCtrsInIns (void)
|
|
|
|
|
{
|
|
|
|
|
Gbl.Cache.NumCtrsInIns.InsCod = -1L;
|
|
|
|
|
Gbl.Cache.NumCtrsInIns.NumCtrs = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned Ctr_GetNumCtrsInIns (long InsCod)
|
|
|
|
|
{
|
2020-01-07 00:09:30 +01:00
|
|
|
|
/***** 1. Fast check: Trivial case *****/
|
|
|
|
|
if (InsCod <= 0)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
/***** 2. Fast check: If cached... *****/
|
|
|
|
|
if (InsCod == Gbl.Cache.NumCtrsInIns.InsCod)
|
|
|
|
|
return Gbl.Cache.NumCtrsInIns.NumCtrs;
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** 3. Slow: number of centers in an institution from database *****/
|
2020-01-07 00:09:30 +01:00
|
|
|
|
Gbl.Cache.NumCtrsInIns.InsCod = InsCod;
|
2021-06-02 20:47:31 +02:00
|
|
|
|
Gbl.Cache.NumCtrsInIns.NumCtrs = Ctr_DB_GetNumCtrsInIns (InsCod);
|
2021-05-27 23:30:16 +02:00
|
|
|
|
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS,HieLvl_INS,Gbl.Cache.NumCtrsInIns.InsCod,
|
2020-05-03 21:56:55 +02:00
|
|
|
|
FigCch_UNSIGNED,&Gbl.Cache.NumCtrsInIns.NumCtrs);
|
2020-01-07 00:09:30 +01:00
|
|
|
|
return Gbl.Cache.NumCtrsInIns.NumCtrs;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-03 20:58:03 +02:00
|
|
|
|
unsigned Ctr_GetCachedNumCtrsInIns (long InsCod)
|
|
|
|
|
{
|
|
|
|
|
unsigned NumCtrs;
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get number of centers from cache *****/
|
2021-05-27 23:30:16 +02:00
|
|
|
|
if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS,HieLvl_INS,InsCod,
|
2020-05-03 20:58:03 +02:00
|
|
|
|
FigCch_UNSIGNED,&NumCtrs))
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get current number of centers from database and update cache *****/
|
2020-05-03 20:58:03 +02:00
|
|
|
|
NumCtrs = Ctr_GetNumCtrsInIns (InsCod);
|
|
|
|
|
|
|
|
|
|
return NumCtrs;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 14:10:27 +01:00
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/********************** Get number of centers with map ***********************/
|
2020-01-26 14:10:27 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-05-03 20:58:03 +02:00
|
|
|
|
unsigned Ctr_GetCachedNumCtrsWithMapInSys (void)
|
2020-01-26 14:10:27 +01:00
|
|
|
|
{
|
2020-05-03 20:58:03 +02:00
|
|
|
|
unsigned NumCtrsWithMap;
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get number of centers with map from cache *****/
|
2021-05-27 23:30:16 +02:00
|
|
|
|
if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS_WITH_MAP,HieLvl_SYS,-1L,
|
2020-05-03 20:58:03 +02:00
|
|
|
|
FigCch_UNSIGNED,&NumCtrsWithMap))
|
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get current number of centers with map from database and update cache *****/
|
2020-05-03 20:58:03 +02:00
|
|
|
|
/* Ccoordinates 0, 0 means not set ==> don't show map */
|
2021-06-02 20:47:31 +02:00
|
|
|
|
NumCtrsWithMap = (unsigned) Ctr_DB_GetNumCtrsWithMap ();
|
2021-05-27 23:30:16 +02:00
|
|
|
|
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_MAP,HieLvl_SYS,-1L,
|
2020-05-03 20:58:03 +02:00
|
|
|
|
FigCch_UNSIGNED,&NumCtrsWithMap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NumCtrsWithMap;
|
2020-01-26 14:10:27 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/************** Get number of centers with map in a country ******************/
|
2020-01-26 14:10:27 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-05-03 21:56:55 +02:00
|
|
|
|
unsigned Ctr_GetCachedNumCtrsWithMapInCty (long CtyCod)
|
2020-01-26 14:10:27 +01:00
|
|
|
|
{
|
2020-05-03 21:56:55 +02:00
|
|
|
|
unsigned NumCtrsWithMap;
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get number of centers with map from cache *****/
|
2021-05-27 23:30:16 +02:00
|
|
|
|
if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS_WITH_MAP,HieLvl_CTY,CtyCod,
|
2020-05-03 21:56:55 +02:00
|
|
|
|
FigCch_UNSIGNED,&NumCtrsWithMap))
|
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get current number of centers with map from database and update cache *****/
|
2020-05-03 21:56:55 +02:00
|
|
|
|
/* Ccoordinates 0, 0 means not set ==> don't show map */
|
2021-06-02 20:47:31 +02:00
|
|
|
|
NumCtrsWithMap = Ctr_DB_GetNumCtrsWithMapInCty (CtyCod);
|
2021-05-27 23:30:16 +02:00
|
|
|
|
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_MAP,HieLvl_CTY,CtyCod,
|
2020-05-03 21:56:55 +02:00
|
|
|
|
FigCch_UNSIGNED,&NumCtrsWithMap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NumCtrsWithMap;
|
2020-01-26 14:10:27 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/************* Get number of centers with map in an institution **************/
|
2020-01-26 14:10:27 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-05-03 21:56:55 +02:00
|
|
|
|
unsigned Ctr_GetCachedNumCtrsWithMapInIns (long InsCod)
|
2020-01-26 14:10:27 +01:00
|
|
|
|
{
|
2020-05-03 21:56:55 +02:00
|
|
|
|
unsigned NumCtrsWithMap;
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get number of centers with map from cache *****/
|
2021-05-27 23:30:16 +02:00
|
|
|
|
if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS_WITH_MAP,HieLvl_INS,InsCod,
|
2020-05-03 21:56:55 +02:00
|
|
|
|
FigCch_UNSIGNED,&NumCtrsWithMap))
|
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get current number of centers with map from database and update cache *****/
|
2020-05-03 21:56:55 +02:00
|
|
|
|
/* Ccoordinates 0, 0 means not set ==> don't show map */
|
2021-06-02 20:47:31 +02:00
|
|
|
|
NumCtrsWithMap = Ctr_DB_GetNumCtrsWithMapInIns (InsCod);
|
2021-05-27 23:30:16 +02:00
|
|
|
|
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_MAP,HieLvl_INS,InsCod,
|
2020-05-03 21:56:55 +02:00
|
|
|
|
FigCch_UNSIGNED,&NumCtrsWithMap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NumCtrsWithMap;
|
2020-01-26 14:10:27 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/********************* Get number of centers with degrees ********************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-05-03 20:58:03 +02:00
|
|
|
|
unsigned Ctr_GetCachedNumCtrsWithDegs (const char *SubQuery,
|
2021-05-27 23:30:16 +02:00
|
|
|
|
HieLvl_Level_t Scope,long Cod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-05-03 20:58:03 +02:00
|
|
|
|
unsigned NumCtrsWithDegs;
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get number of centers with degrees from cache *****/
|
2020-05-03 20:58:03 +02:00
|
|
|
|
if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS_WITH_DEGS,Scope,Cod,
|
|
|
|
|
FigCch_UNSIGNED,&NumCtrsWithDegs))
|
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get current number of centers with degrees from database and update cache *****/
|
2021-06-02 20:47:31 +02:00
|
|
|
|
NumCtrsWithDegs = Ctr_DB_GetNumCtrsWithDegs (SubQuery);
|
2020-05-03 20:58:03 +02:00
|
|
|
|
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_DEGS,Scope,Cod,
|
|
|
|
|
FigCch_UNSIGNED,&NumCtrsWithDegs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NumCtrsWithDegs;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/********************* Get number of centers with courses ********************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-05-03 20:58:03 +02:00
|
|
|
|
unsigned Ctr_GetCachedNumCtrsWithCrss (const char *SubQuery,
|
2021-05-27 23:30:16 +02:00
|
|
|
|
HieLvl_Level_t Scope,long Cod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-05-03 20:58:03 +02:00
|
|
|
|
unsigned NumCtrsWithCrss;
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get number of centers with courses *****/
|
2020-05-03 20:58:03 +02:00
|
|
|
|
if (!FigCch_GetFigureFromCache (FigCch_NUM_CTRS_WITH_CRSS,Scope,Cod,
|
|
|
|
|
FigCch_UNSIGNED,&NumCtrsWithCrss))
|
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get number of centers with courses *****/
|
2021-06-02 20:47:31 +02:00
|
|
|
|
NumCtrsWithCrss = Ctr_DB_GetNumCtrsWithCrss (SubQuery);
|
2020-05-03 20:58:03 +02:00
|
|
|
|
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_CRSS,Scope,Cod,
|
|
|
|
|
FigCch_UNSIGNED,&NumCtrsWithCrss);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NumCtrsWithCrss;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/********************* Get number of centers with users **********************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-05-03 20:58:03 +02:00
|
|
|
|
unsigned Ctr_GetCachedNumCtrsWithUsrs (Rol_Role_t Role,const char *SubQuery,
|
2021-05-27 23:30:16 +02:00
|
|
|
|
HieLvl_Level_t Scope,long Cod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-05-03 20:58:03 +02:00
|
|
|
|
static const FigCch_FigureCached_t FigureCtrs[Rol_NUM_ROLES] =
|
|
|
|
|
{
|
|
|
|
|
[Rol_STD] = FigCch_NUM_CTRS_WITH_STDS, // Students
|
|
|
|
|
[Rol_NET] = FigCch_NUM_CTRS_WITH_NETS, // Non-editing teachers
|
|
|
|
|
[Rol_TCH] = FigCch_NUM_CTRS_WITH_TCHS, // Teachers
|
|
|
|
|
};
|
|
|
|
|
unsigned NumCtrsWithUsrs;
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get number of centers with users from cache *****/
|
2020-05-03 20:58:03 +02:00
|
|
|
|
if (!FigCch_GetFigureFromCache (FigureCtrs[Role],Scope,Cod,
|
|
|
|
|
FigCch_UNSIGNED,&NumCtrsWithUsrs))
|
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get current number of centers with users from database and update cache *****/
|
2021-06-02 20:47:31 +02:00
|
|
|
|
NumCtrsWithUsrs = Ctr_DB_GetNumCtrsWithUsrs (Role,SubQuery);
|
2020-05-03 20:58:03 +02:00
|
|
|
|
FigCch_UpdateFigureIntoCache (FigureCtrs[Role],Scope,Cod,
|
|
|
|
|
FigCch_UNSIGNED,&NumCtrsWithUsrs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NumCtrsWithUsrs;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/****************************** List centers found ***************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2018-10-30 13:59:37 +01:00
|
|
|
|
void Ctr_ListCtrsFound (MYSQL_RES **mysql_res,unsigned NumCtrs)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
extern const char *Txt_center;
|
|
|
|
|
extern const char *Txt_centers;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned NumCtr;
|
2021-03-07 21:21:04 +01:00
|
|
|
|
struct Ctr_Center Ctr;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Query database *****/
|
2018-10-30 13:59:37 +01:00
|
|
|
|
if (NumCtrs)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box and table *****/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/* Number of centers found */
|
2019-12-30 21:47:07 +01:00
|
|
|
|
Box_BoxTableBegin (NULL,Str_BuildStringLongStr ((long) NumCtrs,
|
2021-03-07 21:21:04 +01:00
|
|
|
|
(NumCtrs == 1) ? Txt_center :
|
|
|
|
|
Txt_centers),
|
2020-03-26 02:54:30 +01:00
|
|
|
|
NULL,NULL,
|
|
|
|
|
NULL,Box_NOT_CLOSABLE,2);
|
2019-12-30 21:47:07 +01:00
|
|
|
|
Str_FreeString ();
|
2017-06-12 14:16:33 +02:00
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
/***** Write heading *****/
|
|
|
|
|
Ctr_PutHeadCentersForSeeing (false); // Order not selectable
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
/***** List the centers (one row per center) *****/
|
|
|
|
|
for (NumCtr = 1;
|
|
|
|
|
NumCtr <= NumCtrs;
|
|
|
|
|
NumCtr++)
|
|
|
|
|
{
|
|
|
|
|
/* Get next center */
|
|
|
|
|
Ctr.CtrCod = DB_GetNextCode (*mysql_res);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
/* Get data of center */
|
|
|
|
|
Ctr_GetDataOfCenterByCod (&Ctr);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-02 00:08:30 +02:00
|
|
|
|
/* Write data of this center */
|
|
|
|
|
Ctr_ListOneCenterForSeeing (&Ctr,NumCtr);
|
|
|
|
|
}
|
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 ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
2018-10-30 13:59:37 +01:00
|
|
|
|
DB_FreeMySQLResult (mysql_res);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2019-04-06 21:39:35 +02:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/************************ Center constructor/destructor **********************/
|
2019-04-06 21:39:35 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
static void Ctr_EditingCenterConstructor (void)
|
2019-04-06 21:39:35 +02:00
|
|
|
|
{
|
|
|
|
|
/***** Pointer must be NULL *****/
|
|
|
|
|
if (Ctr_EditingCtr != NULL)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongCenterExit ();
|
2019-04-06 21:39:35 +02:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Allocate memory for center *****/
|
2021-02-15 16:25:55 +01:00
|
|
|
|
if ((Ctr_EditingCtr = malloc (sizeof (*Ctr_EditingCtr))) == NULL)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
2019-04-06 21:39:35 +02:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Reset center *****/
|
2019-06-13 10:14:05 +02:00
|
|
|
|
Ctr_EditingCtr->CtrCod = -1L;
|
|
|
|
|
Ctr_EditingCtr->InsCod = -1L;
|
|
|
|
|
Ctr_EditingCtr->PlcCod = -1L;
|
2020-01-05 12:52:03 +01:00
|
|
|
|
Ctr_EditingCtr->Status = (Ctr_Status_t) 0;
|
2019-04-06 21:39:35 +02:00
|
|
|
|
Ctr_EditingCtr->RequesterUsrCod = -1L;
|
2019-06-13 10:14:05 +02:00
|
|
|
|
Ctr_EditingCtr->ShrtName[0] = '\0';
|
|
|
|
|
Ctr_EditingCtr->FullName[0] = '\0';
|
|
|
|
|
Ctr_EditingCtr->WWW[0] = '\0';
|
2019-04-06 21:39:35 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
static void Ctr_EditingCenterDestructor (void)
|
2019-04-06 21:39:35 +02:00
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Free memory used for center *****/
|
2019-04-06 21:39:35 +02:00
|
|
|
|
if (Ctr_EditingCtr != NULL)
|
|
|
|
|
{
|
2019-11-06 19:45:20 +01:00
|
|
|
|
free (Ctr_EditingCtr);
|
2019-04-06 21:39:35 +02:00
|
|
|
|
Ctr_EditingCtr = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-01-09 15:36:12 +01:00
|
|
|
|
|
2020-01-14 08:58:29 +01:00
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/************************ Form to go to center map ***************************/
|
2020-01-14 08:58:29 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
static void Ctr_FormToGoToMap (struct Ctr_Center *Ctr)
|
2020-01-14 08:58:29 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Map;
|
|
|
|
|
|
2020-01-14 13:30:18 +01:00
|
|
|
|
if (Ctr_GetIfMapIsAvailable (Ctr))
|
2020-01-14 08:58:29 +01:00
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Ctr_EditingCtr = Ctr; // Used to pass parameter with the code of the center
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Lay_PutContextualLinkOnlyIcon (ActSeeCtrInf,NULL,
|
2020-04-08 13:40:21 +02:00
|
|
|
|
Ctr_PutParamGoToCtr,&Ctr_EditingCtr->CtrCod,
|
2020-01-14 08:58:29 +01:00
|
|
|
|
"map-marker-alt.svg",
|
|
|
|
|
Txt_Map);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-09 15:36:12 +01:00
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/************************ Check if a center has map **************************/
|
2020-01-09 15:36:12 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
bool Ctr_GetIfMapIsAvailable (const struct Ctr_Center *Ctr)
|
2020-01-09 15:36:12 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Coordinates 0, 0 means not set ==> don't show map *****/
|
|
|
|
|
return (bool) (Ctr->Coord.Latitude ||
|
|
|
|
|
Ctr->Coord.Longitude);
|
|
|
|
|
}
|