2019-12-29 19:07:59 +01:00
|
|
|
|
// swad_country_config.c: configuration of current country
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
SWAD (Shared Workspace At a Distance),
|
|
|
|
|
is a web platform developed at the University of Granada (Spain),
|
|
|
|
|
and used to support university teaching.
|
|
|
|
|
|
|
|
|
|
This file is part of SWAD core.
|
2024-02-07 00:40:28 +01:00
|
|
|
|
Copyright (C) 1999-2024 Antonio Ca<EFBFBD>as Vargas
|
2019-12-29 19:07:59 +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 ***********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-01-03 22:16:51 +01:00
|
|
|
|
#define _GNU_SOURCE // For asprintf
|
2019-12-29 19:07:59 +01:00
|
|
|
|
#include <stdbool.h> // For boolean type
|
|
|
|
|
#include <stddef.h> // For NULL
|
2020-01-03 22:16:51 +01:00
|
|
|
|
#include <stdio.h> // For asprintf
|
|
|
|
|
#include <stdlib.h> // For free
|
2019-12-29 19:07:59 +01:00
|
|
|
|
#include <string.h> // For string functions
|
|
|
|
|
|
2022-11-06 18:11:10 +01:00
|
|
|
|
#include "swad_action_list.h"
|
2022-10-19 18:07:49 +02:00
|
|
|
|
#include "swad_box.h"
|
2021-05-22 12:34:10 +02:00
|
|
|
|
#include "swad_country_config.h"
|
|
|
|
|
#include "swad_country_database.h"
|
2019-12-29 19:07:59 +01:00
|
|
|
|
#include "swad_database.h"
|
2021-04-26 15:27:27 +02:00
|
|
|
|
#include "swad_error.h"
|
2020-05-02 13:39:59 +02:00
|
|
|
|
#include "swad_figure_cache.h"
|
2019-12-29 19:07:59 +01:00
|
|
|
|
#include "swad_form.h"
|
|
|
|
|
#include "swad_global.h"
|
|
|
|
|
#include "swad_help.h"
|
2021-02-11 22:57:09 +01:00
|
|
|
|
#include "swad_hierarchy.h"
|
2019-12-29 20:11:57 +01:00
|
|
|
|
#include "swad_hierarchy_config.h"
|
2023-09-22 14:47:56 +02:00
|
|
|
|
#include "swad_hierarchy_type.h"
|
2019-12-29 19:07:59 +01:00
|
|
|
|
#include "swad_HTML.h"
|
2022-10-19 18:07:49 +02:00
|
|
|
|
#include "swad_parameter.h"
|
2019-12-29 19:07:59 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private prototypes ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-10-29 12:32:08 +01:00
|
|
|
|
static void CtyCfg_Configuration (Vie_ViewType_t ViewType);
|
2020-04-08 13:40:21 +02:00
|
|
|
|
static void CtyCfg_PutIconToPrint (__attribute__((unused)) void *Args);
|
2023-11-07 11:01:14 +01:00
|
|
|
|
static void CtyCfg_Title (Hie_PutLink_t PutLink);
|
2020-01-03 21:15:54 +01:00
|
|
|
|
static void CtyCfg_Map (void);
|
2023-11-07 11:01:14 +01:00
|
|
|
|
static void CtyCfg_MapImage (Vie_ViewType_t ViewType,Hie_PutLink_t PutLink);
|
2023-10-29 12:32:08 +01:00
|
|
|
|
static void CtyCfg_Platform (Vie_ViewType_t ViewType);
|
2023-11-07 11:01:14 +01:00
|
|
|
|
static void CtyCfg_Name (Hie_PutLink_t PutLink);
|
2019-12-29 19:07:59 +01:00
|
|
|
|
static void CtyCfg_NumUsrs (void);
|
|
|
|
|
static void CtyCfg_NumInss (void);
|
|
|
|
|
static void CtyCfg_NumDegs (void);
|
|
|
|
|
static void CtyCfg_NumCrss (void);
|
|
|
|
|
|
|
|
|
|
static void CtyCfg_GetMapAttr (long CtyCod,char **MapAttribution);
|
|
|
|
|
static void CtyCfg_FreeMapAttr (char **MapAttribution);
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Show information of the current country *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void CtyCfg_ShowConfiguration (void)
|
|
|
|
|
{
|
2023-10-29 12:32:08 +01:00
|
|
|
|
CtyCfg_Configuration (Vie_VIEW);
|
2019-12-29 19:07:59 +01:00
|
|
|
|
|
|
|
|
|
/***** Show help to enrol me *****/
|
|
|
|
|
Hlp_ShowHelpWhatWouldYouLikeToDo ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Print information of the current country ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void CtyCfg_PrintConfiguration (void)
|
|
|
|
|
{
|
2023-10-29 12:32:08 +01:00
|
|
|
|
CtyCfg_Configuration (Vie_PRINT);
|
2019-12-29 19:07:59 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Information of the current country *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-10-29 12:32:08 +01:00
|
|
|
|
static void CtyCfg_Configuration (Vie_ViewType_t ViewType)
|
2019-12-29 19:07:59 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Hlp_COUNTRY_Information;
|
2023-11-07 11:01:14 +01:00
|
|
|
|
Hie_PutLink_t PutLink;
|
2020-01-03 21:15:54 +01:00
|
|
|
|
bool MapImageExists;
|
2020-01-25 22:18:01 +01:00
|
|
|
|
unsigned NumCtrs;
|
|
|
|
|
unsigned NumCtrsWithMap;
|
2019-12-29 19:07:59 +01:00
|
|
|
|
|
|
|
|
|
/***** Trivial check *****/
|
2023-09-22 14:47:56 +02:00
|
|
|
|
if (Gbl.Hierarchy.Node[Hie_CTY].HieCod <= 0) // No country selected
|
2019-12-29 19:07:59 +01:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/***** Initializations *****/
|
2023-11-07 11:01:14 +01:00
|
|
|
|
PutLink = (ViewType == Vie_VIEW &&
|
|
|
|
|
Gbl.Hierarchy.Node[Hie_CTY].WWW[0]) ? Hie_PUT_LINK :
|
|
|
|
|
Hie_DONT_PUT_LINK;
|
2019-12-29 19:07:59 +01:00
|
|
|
|
|
|
|
|
|
/***** Begin box *****/
|
2024-01-29 09:45:28 +01:00
|
|
|
|
Box_BoxBegin (NULL,
|
2023-10-29 12:32:08 +01:00
|
|
|
|
ViewType == Vie_VIEW ? CtyCfg_PutIconToPrint :
|
|
|
|
|
NULL,NULL,
|
|
|
|
|
ViewType == Vie_VIEW ? Hlp_COUNTRY_Information :
|
|
|
|
|
NULL,Box_NOT_CLOSABLE);
|
|
|
|
|
|
|
|
|
|
/***** Title *****/
|
|
|
|
|
CtyCfg_Title (PutLink);
|
|
|
|
|
|
|
|
|
|
/**************************** Left part ***********************************/
|
2024-02-11 23:29:50 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"HIE_CFG_LEFT\"");
|
2023-10-29 12:32:08 +01:00
|
|
|
|
|
|
|
|
|
/* Begin table */
|
2024-02-11 23:29:50 +01:00
|
|
|
|
HTM_TABLE_BeginPadding (2);
|
2023-10-29 12:32:08 +01:00
|
|
|
|
|
|
|
|
|
/* Platform */
|
|
|
|
|
CtyCfg_Platform (ViewType);
|
|
|
|
|
|
|
|
|
|
/* Country name (an link to WWW if exists) */
|
|
|
|
|
CtyCfg_Name (PutLink);
|
|
|
|
|
|
|
|
|
|
/* Shortcut to the country */
|
2024-02-11 23:29:50 +01:00
|
|
|
|
HieCfg_Shortcut (ViewType,ParCod_Cty,Gbl.Hierarchy.Node[Hie_CTY].HieCod);
|
2023-10-29 12:32:08 +01:00
|
|
|
|
|
|
|
|
|
NumCtrsWithMap = Ctr_GetCachedNumCtrsWithMapInCty (Gbl.Hierarchy.Node[Hie_CTY].HieCod);
|
|
|
|
|
switch (ViewType)
|
|
|
|
|
{
|
|
|
|
|
case Vie_VIEW:
|
|
|
|
|
NumCtrs = Hie_GetCachedNumNodesInHieLvl (Hie_CTR, // Number of centers...
|
|
|
|
|
Hie_CTY, // ...in country
|
|
|
|
|
Gbl.Hierarchy.Node[Hie_CTY].HieCod);
|
|
|
|
|
|
|
|
|
|
/* Number of users who claim to belong to this country,
|
|
|
|
|
number of institutions,
|
|
|
|
|
number of centers,
|
|
|
|
|
number of degrees,
|
|
|
|
|
number of courses */
|
|
|
|
|
CtyCfg_NumUsrs ();
|
|
|
|
|
CtyCfg_NumInss ();
|
2024-02-11 23:29:50 +01:00
|
|
|
|
HieCfg_NumCtrs (NumCtrs,Frm_DONT_PUT_FORM);
|
2023-10-29 12:32:08 +01:00
|
|
|
|
HieCfg_NumCtrsWithMap (NumCtrs,NumCtrsWithMap);
|
|
|
|
|
CtyCfg_NumDegs ();
|
|
|
|
|
CtyCfg_NumCrss ();
|
|
|
|
|
|
|
|
|
|
/* Number of users in courses of this country */
|
|
|
|
|
HieCfg_NumUsrsInCrss (Hie_CTY,Gbl.Hierarchy.Node[Hie_CTY].HieCod,Rol_TCH);
|
|
|
|
|
HieCfg_NumUsrsInCrss (Hie_CTY,Gbl.Hierarchy.Node[Hie_CTY].HieCod,Rol_NET);
|
|
|
|
|
HieCfg_NumUsrsInCrss (Hie_CTY,Gbl.Hierarchy.Node[Hie_CTY].HieCod,Rol_STD);
|
|
|
|
|
HieCfg_NumUsrsInCrss (Hie_CTY,Gbl.Hierarchy.Node[Hie_CTY].HieCod,Rol_UNK);
|
|
|
|
|
break;
|
|
|
|
|
case Vie_PRINT:
|
|
|
|
|
/* QR code with link to the country */
|
2024-02-11 23:29:50 +01:00
|
|
|
|
HieCfg_QR (ParCod_Cty,Gbl.Hierarchy.Node[Hie_CTY].HieCod);
|
2023-10-29 12:32:08 +01:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
Err_WrongTypeExit ();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* End table */
|
|
|
|
|
HTM_TABLE_End ();
|
|
|
|
|
|
|
|
|
|
/* End of left part */
|
|
|
|
|
HTM_DIV_End ();
|
2019-12-29 19:07:59 +01:00
|
|
|
|
|
2023-10-29 12:32:08 +01:00
|
|
|
|
/**************************** Right part **********************************/
|
|
|
|
|
/* Check country map */
|
|
|
|
|
MapImageExists = Cty_CheckIfCountryPhotoExists (&Gbl.Hierarchy.Node[Hie_CTY]);
|
2020-01-03 21:15:54 +01:00
|
|
|
|
|
2023-10-29 12:32:08 +01:00
|
|
|
|
if (NumCtrsWithMap || MapImageExists)
|
|
|
|
|
{
|
|
|
|
|
/* Begin container */
|
2024-02-11 23:29:50 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"HIE_CFG_RIGHT\"");
|
2019-12-29 19:07:59 +01:00
|
|
|
|
|
2023-10-29 12:32:08 +01:00
|
|
|
|
/* Country map */
|
|
|
|
|
if (NumCtrsWithMap)
|
|
|
|
|
CtyCfg_Map ();
|
2020-01-03 21:15:54 +01:00
|
|
|
|
|
2023-10-29 12:32:08 +01:00
|
|
|
|
/* Country map image */
|
|
|
|
|
if (MapImageExists)
|
|
|
|
|
CtyCfg_MapImage (ViewType,PutLink);
|
2019-12-29 19:07:59 +01:00
|
|
|
|
|
2023-10-29 12:32:08 +01:00
|
|
|
|
/* End container */
|
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
}
|
2019-12-29 19:07:59 +01:00
|
|
|
|
|
|
|
|
|
/***** End box *****/
|
|
|
|
|
Box_BoxEnd ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************* Put icon to print the configuration of a country **************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-08 13:40:21 +02:00
|
|
|
|
static void CtyCfg_PutIconToPrint (__attribute__((unused)) void *Args)
|
2019-12-29 19:07:59 +01:00
|
|
|
|
{
|
2024-02-11 23:29:50 +01:00
|
|
|
|
Ico_PutContextualIconToPrint (ActPrnCtyInf,NULL,NULL);
|
2019-12-29 19:07:59 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Show title in country configuration ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-11-07 11:01:14 +01:00
|
|
|
|
static void CtyCfg_Title (Hie_PutLink_t PutLink)
|
2019-12-29 19:07:59 +01:00
|
|
|
|
{
|
2021-05-22 12:34:10 +02:00
|
|
|
|
/***** Begin container *****/
|
2021-12-27 12:58:20 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"FRAME_TITLE FRAME_TITLE_BIG FRAME_TITLE_%s\"",
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix ());
|
2019-12-29 19:07:59 +01:00
|
|
|
|
|
2021-05-22 12:34:10 +02:00
|
|
|
|
/* Begin link */
|
2023-11-07 11:01:14 +01:00
|
|
|
|
if (PutLink == Hie_PUT_LINK)
|
2021-12-20 09:24:49 +01:00
|
|
|
|
HTM_A_Begin ("href=\"%s\" target=\"_blank\" title=\"%s\""
|
2021-12-27 12:58:20 +01:00
|
|
|
|
" class=\"FRAME_TITLE_BIG FRAME_TITLE_%s\"",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CTY].WWW,
|
|
|
|
|
Gbl.Hierarchy.Node[Hie_CTY].FullName,
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix ());
|
2020-01-03 21:15:54 +01:00
|
|
|
|
|
2021-05-22 12:34:10 +02:00
|
|
|
|
/* Country name */
|
2023-09-22 14:47:56 +02:00
|
|
|
|
HTM_Txt (Gbl.Hierarchy.Node[Hie_CTY].FullName);
|
2021-05-22 12:34:10 +02:00
|
|
|
|
|
|
|
|
|
/* End link */
|
2023-11-07 11:01:14 +01:00
|
|
|
|
if (PutLink == Hie_PUT_LINK)
|
2021-05-22 12:34:10 +02:00
|
|
|
|
HTM_A_End ();
|
|
|
|
|
|
|
|
|
|
/***** End container *****/
|
|
|
|
|
HTM_DIV_End ();
|
2020-01-03 21:15:54 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************************** Draw country map *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#define CtyCfg_MAP_CONTAINER_ID "cty_mapid"
|
|
|
|
|
|
|
|
|
|
static void CtyCfg_Map (void)
|
|
|
|
|
{
|
2023-12-06 20:59:19 +01:00
|
|
|
|
extern bool (*Hie_GetDataByCod[Hie_NUM_LEVELS]) (struct Hie_Node *Node);
|
2020-01-03 21:15:54 +01:00
|
|
|
|
MYSQL_RES *mysql_res;
|
2021-05-22 12:34:10 +02:00
|
|
|
|
struct Map_Coordinates CtyAvgCoord;
|
2020-01-03 21:15:54 +01:00
|
|
|
|
unsigned Zoom;
|
|
|
|
|
unsigned NumCtrs;
|
|
|
|
|
unsigned NumCtr;
|
2023-09-18 15:15:29 +02:00
|
|
|
|
struct Hie_Node Ins;
|
|
|
|
|
struct Hie_Node Ctr;
|
2023-09-18 11:19:00 +02:00
|
|
|
|
struct Map_Coordinates Coord;
|
2020-01-03 21:15:54 +01:00
|
|
|
|
|
|
|
|
|
/***** Leaflet CSS *****/
|
|
|
|
|
Map_LeafletCSS ();
|
|
|
|
|
|
|
|
|
|
/***** Leaflet script *****/
|
|
|
|
|
Map_LeafletScript ();
|
|
|
|
|
|
|
|
|
|
/***** Container for the map *****/
|
|
|
|
|
HTM_DIV_Begin ("id=\"%s\"",CtyCfg_MAP_CONTAINER_ID);
|
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
|
|
|
|
|
/***** Script to draw the map *****/
|
|
|
|
|
HTM_SCRIPT_Begin (NULL,NULL);
|
|
|
|
|
|
2021-05-22 12:34:10 +02:00
|
|
|
|
/* Let's create a map with pretty Mapbox Streets tiles */
|
2023-09-18 11:19:00 +02:00
|
|
|
|
Cty_DB_GetAvgCoordAndZoom (&CtyAvgCoord,&Zoom);
|
2021-05-22 12:34:10 +02:00
|
|
|
|
Map_CreateMap (CtyCfg_MAP_CONTAINER_ID,&CtyAvgCoord,Zoom);
|
2020-01-03 21:15:54 +01:00
|
|
|
|
|
2021-05-22 12:34:10 +02:00
|
|
|
|
/* Add Mapbox Streets tile layer to our map */
|
|
|
|
|
Map_AddTileLayer ();
|
2020-01-03 21:15:54 +01:00
|
|
|
|
|
2021-05-22 12:34:10 +02:00
|
|
|
|
/* Get centers which have coordinates in the current country */
|
|
|
|
|
NumCtrs = Cty_DB_GetCtrsWithCoordsInCurrentCty (&mysql_res);
|
2020-01-03 21:15:54 +01:00
|
|
|
|
|
2021-05-22 12:34:10 +02:00
|
|
|
|
/* Add a marker and a popup for each center */
|
|
|
|
|
for (NumCtr = 0;
|
|
|
|
|
NumCtr < NumCtrs;
|
|
|
|
|
NumCtr++)
|
|
|
|
|
{
|
|
|
|
|
/* Get next center */
|
2023-09-20 10:36:07 +02:00
|
|
|
|
Ctr.HieCod = DB_GetNextCode (mysql_res);
|
2020-01-03 21:15:54 +01:00
|
|
|
|
|
2021-05-22 12:34:10 +02:00
|
|
|
|
/* Get data of center */
|
2023-12-06 20:59:19 +01:00
|
|
|
|
Hie_GetDataByCod[Hie_CTR] (&Ctr);
|
2020-01-03 21:15:54 +01:00
|
|
|
|
|
2023-09-18 11:19:00 +02:00
|
|
|
|
/* Get coordinates of center */
|
2023-09-20 10:36:07 +02:00
|
|
|
|
Ctr_GetCoordByCod (Ctr.HieCod,&Coord);
|
2023-09-18 11:19:00 +02:00
|
|
|
|
|
2021-05-22 12:34:10 +02:00
|
|
|
|
/* Get data of institution */
|
2023-09-20 10:36:07 +02:00
|
|
|
|
Ins.HieCod = Ctr.PrtCod;
|
2023-12-06 20:59:19 +01:00
|
|
|
|
Hie_GetDataByCod[Hie_INS] (&Ins);
|
2021-05-22 12:34:10 +02:00
|
|
|
|
|
|
|
|
|
/* Add marker */
|
2023-09-18 11:19:00 +02:00
|
|
|
|
Map_AddMarker (&Coord);
|
2021-05-22 12:34:10 +02:00
|
|
|
|
|
|
|
|
|
/* Add popup */
|
|
|
|
|
Map_AddPopup (Ctr.ShrtName,Ins.ShrtName,
|
|
|
|
|
false); // Closed
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Free structure that stores the query result */
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
2020-01-03 21:15:54 +01:00
|
|
|
|
|
|
|
|
|
HTM_SCRIPT_End ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************* Show country map image in country configuration ***************/
|
2019-12-29 19:07:59 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-11-07 11:01:14 +01:00
|
|
|
|
static void CtyCfg_MapImage (Vie_ViewType_t ViewType,Hie_PutLink_t PutLink)
|
2019-12-29 19:07:59 +01:00
|
|
|
|
{
|
|
|
|
|
char *MapAttribution = NULL;
|
|
|
|
|
|
|
|
|
|
/***** Get map attribution *****/
|
2023-09-22 14:47:56 +02:00
|
|
|
|
CtyCfg_GetMapAttr (Gbl.Hierarchy.Node[Hie_CTY].HieCod,&MapAttribution);
|
2019-12-29 19:07:59 +01:00
|
|
|
|
|
|
|
|
|
/***** Map image *****/
|
2022-01-09 23:27:36 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"CM\"");
|
2023-11-07 11:01:14 +01:00
|
|
|
|
if (PutLink == Hie_PUT_LINK)
|
2021-05-22 12:34:10 +02:00
|
|
|
|
HTM_A_Begin ("href=\"%s\" target=\"_blank\"",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CTY].WWW);
|
|
|
|
|
Cty_DrawCountryMap (&Gbl.Hierarchy.Node[Hie_CTY],
|
2023-10-29 12:32:08 +01:00
|
|
|
|
ViewType == Vie_VIEW ? "COUNTRY_MAP_SHOW" :
|
|
|
|
|
"COUNTRY_MAP_PRINT");
|
2023-11-07 11:01:14 +01:00
|
|
|
|
if (PutLink == Hie_PUT_LINK)
|
2021-05-22 12:34:10 +02:00
|
|
|
|
HTM_A_End ();
|
2019-12-29 19:07:59 +01:00
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
|
|
|
|
|
/***** Map attribution *****/
|
2024-04-19 12:00:30 +02:00
|
|
|
|
if (ViewType == Vie_VIEW && Cty_CheckIfICanEditCountries () == Usr_CAN)
|
2019-12-29 19:07:59 +01:00
|
|
|
|
{
|
|
|
|
|
HTM_DIV_Begin ("class=\"CM\"");
|
2021-05-22 12:34:10 +02:00
|
|
|
|
Frm_BeginForm (ActChgCtyMapAtt);
|
2023-10-29 12:32:08 +01:00
|
|
|
|
HTM_TEXTAREA_Begin ("id=\"AttributionArea\" name=\"Attribution\""
|
|
|
|
|
" rows=\"3\""
|
2022-10-14 23:59:56 +02:00
|
|
|
|
" onchange=\"this.form.submit();return false;\"");
|
2021-05-22 12:34:10 +02:00
|
|
|
|
if (MapAttribution)
|
|
|
|
|
HTM_Txt (MapAttribution);
|
|
|
|
|
HTM_TEXTAREA_End ();
|
|
|
|
|
Frm_EndForm ();
|
2019-12-29 19:07:59 +01:00
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
}
|
|
|
|
|
else if (MapAttribution)
|
|
|
|
|
{
|
|
|
|
|
HTM_DIV_Begin ("class=\"ATTRIBUTION\"");
|
2021-05-22 12:34:10 +02:00
|
|
|
|
HTM_Txt (MapAttribution);
|
2019-12-29 19:07:59 +01:00
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free memory used for map attribution *****/
|
|
|
|
|
CtyCfg_FreeMapAttr (&MapAttribution);
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-08 23:49:04 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Show platform in country configuration *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-10-29 12:32:08 +01:00
|
|
|
|
static void CtyCfg_Platform (Vie_ViewType_t ViewType)
|
2020-01-08 23:49:04 +01:00
|
|
|
|
{
|
2023-11-06 12:36:05 +01:00
|
|
|
|
extern const char *Txt_HIERARCHY_SINGUL_Abc[Hie_NUM_LEVELS];
|
2020-01-08 23:49:04 +01:00
|
|
|
|
|
|
|
|
|
/***** Institution *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
|
2021-05-22 12:34:10 +02:00
|
|
|
|
/* Label */
|
2024-02-11 23:29:50 +01:00
|
|
|
|
Frm_LabelColumn ("Frm_C1 RT",NULL,Txt_HIERARCHY_SINGUL_Abc[Hie_SYS]);
|
2020-01-08 23:49:04 +01:00
|
|
|
|
|
2021-05-22 12:34:10 +02:00
|
|
|
|
/* Data */
|
2024-02-11 23:29:50 +01:00
|
|
|
|
HTM_TD_Begin ("class=\"Frm_C2 LT DAT_%s\"",The_GetSuffix ());
|
2023-10-29 12:32:08 +01:00
|
|
|
|
if (ViewType == Vie_VIEW)
|
2021-05-22 12:34:10 +02:00
|
|
|
|
{
|
|
|
|
|
Frm_BeginFormGoTo (ActSeeSysInf);
|
2022-04-01 01:06:44 +02:00
|
|
|
|
HTM_BUTTON_Submit_Begin (Str_BuildGoToTitle (Cfg_PLATFORM_SHORT_NAME),
|
2022-09-09 12:50:53 +02:00
|
|
|
|
"class=\"LT BT_LINK\"");
|
2021-12-30 11:50:29 +01:00
|
|
|
|
Str_FreeGoToTitle ();
|
2021-05-22 12:34:10 +02:00
|
|
|
|
}
|
2021-12-22 18:54:43 +01:00
|
|
|
|
Ico_PutIcon ("swad64x64.png",Ico_UNCHANGED,Cfg_PLATFORM_FULL_NAME,"ICO20x20");
|
2021-05-22 12:34:10 +02:00
|
|
|
|
HTM_NBSP ();
|
|
|
|
|
HTM_Txt (Cfg_PLATFORM_SHORT_NAME);
|
2023-10-29 12:32:08 +01:00
|
|
|
|
if (ViewType == Vie_VIEW)
|
2021-05-22 12:34:10 +02:00
|
|
|
|
{
|
2021-12-01 01:43:13 +01:00
|
|
|
|
HTM_BUTTON_End ();
|
2021-05-22 12:34:10 +02:00
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
}
|
|
|
|
|
HTM_TD_End ();
|
2020-01-08 23:49:04 +01:00
|
|
|
|
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-29 19:07:59 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************** Show country name in country configuration *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-11-07 11:01:14 +01:00
|
|
|
|
static void CtyCfg_Name (Hie_PutLink_t PutLink)
|
2019-12-29 19:07:59 +01:00
|
|
|
|
{
|
2023-11-06 12:36:05 +01:00
|
|
|
|
extern const char *Txt_HIERARCHY_SINGUL_Abc[Hie_NUM_LEVELS];
|
2019-12-29 19:07:59 +01:00
|
|
|
|
|
|
|
|
|
/***** Country name *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
|
2021-05-22 12:34:10 +02:00
|
|
|
|
/* Label */
|
2024-02-11 23:29:50 +01:00
|
|
|
|
Frm_LabelColumn ("Frm_C1 RT",NULL,Txt_HIERARCHY_SINGUL_Abc[Hie_CTY]);
|
2019-12-29 19:07:59 +01:00
|
|
|
|
|
2021-05-22 12:34:10 +02:00
|
|
|
|
/* Data */
|
2024-02-11 23:29:50 +01:00
|
|
|
|
HTM_TD_Begin ("class=\"Frm_C2 LB DAT_STRONG_%s\"",The_GetSuffix ());
|
2023-11-07 11:01:14 +01:00
|
|
|
|
if (PutLink == Hie_PUT_LINK)
|
2022-03-25 14:39:30 +01:00
|
|
|
|
HTM_A_Begin ("href=\"%s\" target=\"_blank\" class=\"DAT_STRONG_%s\"",
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CTY].WWW,
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix ());
|
2023-09-22 14:47:56 +02:00
|
|
|
|
HTM_Txt (Gbl.Hierarchy.Node[Hie_CTY].FullName);
|
2023-11-07 11:01:14 +01:00
|
|
|
|
if (PutLink == Hie_PUT_LINK)
|
2021-05-22 12:34:10 +02:00
|
|
|
|
HTM_A_End ();
|
|
|
|
|
HTM_TD_End ();
|
2019-12-29 19:07:59 +01:00
|
|
|
|
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*** Show number of users who claim to belong to country in country config. **/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void CtyCfg_NumUsrs (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Users_of_the_country;
|
|
|
|
|
|
|
|
|
|
/***** Number of users *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
|
2021-05-22 12:34:10 +02:00
|
|
|
|
/* Label */
|
2024-02-11 23:29:50 +01:00
|
|
|
|
Frm_LabelColumn ("Frm_C1 RT",NULL,Txt_Users_of_the_country);
|
2019-12-29 19:07:59 +01:00
|
|
|
|
|
2021-05-22 12:34:10 +02:00
|
|
|
|
/* Data */
|
2024-02-11 23:29:50 +01:00
|
|
|
|
HTM_TD_Begin ("class=\"Frm_C2 LB DAT_%s\"",The_GetSuffix ());
|
2023-09-22 14:47:56 +02:00
|
|
|
|
HTM_Unsigned (Hie_GetCachedNumUsrsWhoClaimToBelongTo (Hie_CTY,
|
|
|
|
|
&Gbl.Hierarchy.Node[Hie_CTY]));
|
2021-05-22 12:34:10 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-12-29 19:07:59 +01:00
|
|
|
|
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********** Show number of institutions in country configuration ************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void CtyCfg_NumInss (void)
|
|
|
|
|
{
|
2023-11-06 15:20:34 +01:00
|
|
|
|
extern const char *Txt_HIERARCHY_PLURAL_Abc[Hie_NUM_LEVELS];
|
2019-12-29 19:07:59 +01:00
|
|
|
|
extern const char *Txt_Institutions_of_COUNTRY_X;
|
2021-12-29 21:31:49 +01:00
|
|
|
|
char *Title;
|
2019-12-29 19:07:59 +01:00
|
|
|
|
|
|
|
|
|
/***** Number of institutions ******/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
|
2021-05-22 12:34:10 +02:00
|
|
|
|
/* Label */
|
2024-02-11 23:29:50 +01:00
|
|
|
|
Frm_LabelColumn ("Frm_C1 RT",NULL,Txt_HIERARCHY_PLURAL_Abc[Hie_INS]);
|
2021-05-22 12:34:10 +02:00
|
|
|
|
|
|
|
|
|
/* Data */
|
2024-02-11 23:29:50 +01:00
|
|
|
|
HTM_TD_Begin ("class=\"Frm_C2 LT DAT_%s\"",The_GetSuffix ());
|
2021-05-22 12:34:10 +02:00
|
|
|
|
Frm_BeginFormGoTo (ActSeeIns);
|
2023-09-22 14:47:56 +02:00
|
|
|
|
ParCod_PutPar (ParCod_Cty,Gbl.Hierarchy.Node[Hie_CTY].HieCod);
|
2021-12-29 21:31:49 +01:00
|
|
|
|
if (asprintf (&Title,Txt_Institutions_of_COUNTRY_X,
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Gbl.Hierarchy.Node[Hie_CTY].FullName) < 0)
|
2021-12-29 21:31:49 +01:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
2022-09-09 12:50:53 +02:00
|
|
|
|
HTM_BUTTON_Submit_Begin (Title,"class=\"LT BT_LINK\"");
|
2021-12-29 21:31:49 +01:00
|
|
|
|
free (Title);
|
2023-09-22 14:47:56 +02:00
|
|
|
|
HTM_Unsigned (Hie_GetCachedNumNodesInHieLvl (Hie_INS, // Number of institutions...
|
|
|
|
|
Hie_CTY, // ...in country
|
|
|
|
|
Gbl.Hierarchy.Node[Hie_CTY].HieCod));
|
2021-05-22 12:34:10 +02:00
|
|
|
|
HTM_BUTTON_End ();
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
HTM_TD_End ();
|
2019-12-29 19:07:59 +01:00
|
|
|
|
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************* Show number of degrees in country configuration ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void CtyCfg_NumDegs (void)
|
|
|
|
|
{
|
2023-11-06 15:20:34 +01:00
|
|
|
|
extern const char *Txt_HIERARCHY_PLURAL_Abc[Hie_NUM_LEVELS];
|
2019-12-29 19:07:59 +01:00
|
|
|
|
|
|
|
|
|
/***** Number of degrees *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
|
2021-05-22 12:34:10 +02:00
|
|
|
|
/* Label */
|
2024-02-11 23:29:50 +01:00
|
|
|
|
Frm_LabelColumn ("Frm_C1 RT",NULL,Txt_HIERARCHY_PLURAL_Abc[Hie_DEG]);
|
2019-12-29 19:07:59 +01:00
|
|
|
|
|
2021-05-22 12:34:10 +02:00
|
|
|
|
/* Data */
|
2024-02-11 23:29:50 +01:00
|
|
|
|
HTM_TD_Begin ("class=\"Frm_C2 LB DAT_%s\"",The_GetSuffix ());
|
2023-09-22 14:47:56 +02:00
|
|
|
|
HTM_Unsigned (Hie_GetCachedNumNodesInHieLvl (Hie_DEG, // Number of degrees...
|
|
|
|
|
Hie_CTY, // ...in country
|
|
|
|
|
Gbl.Hierarchy.Node[Hie_CTY].HieCod));
|
2021-05-22 12:34:10 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-12-29 19:07:59 +01:00
|
|
|
|
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************* Show number of courses in country configuration ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void CtyCfg_NumCrss (void)
|
|
|
|
|
{
|
2023-11-06 15:20:34 +01:00
|
|
|
|
extern const char *Txt_HIERARCHY_PLURAL_Abc[Hie_NUM_LEVELS];
|
2019-12-29 19:07:59 +01:00
|
|
|
|
|
|
|
|
|
/***** Number of courses *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
|
2021-05-22 12:34:10 +02:00
|
|
|
|
/* Label */
|
2024-02-11 23:29:50 +01:00
|
|
|
|
Frm_LabelColumn ("Frm_C1 RT",NULL,Txt_HIERARCHY_PLURAL_Abc[Hie_CRS]);
|
2019-12-29 19:07:59 +01:00
|
|
|
|
|
2021-05-22 12:34:10 +02:00
|
|
|
|
/* Data */
|
2024-02-11 23:29:50 +01:00
|
|
|
|
HTM_TD_Begin ("class=\"Frm_C2 LB DAT_%s\"",The_GetSuffix ());
|
2023-09-22 14:47:56 +02:00
|
|
|
|
HTM_Unsigned (Hie_GetCachedNumNodesInHieLvl (Hie_CRS, // Number of courses...
|
|
|
|
|
Hie_CTY, // ...in country
|
|
|
|
|
Gbl.Hierarchy.Node[Hie_CTY].HieCod));
|
2021-05-22 12:34:10 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-12-29 19:07:59 +01:00
|
|
|
|
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Get map attribution from database **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void CtyCfg_GetMapAttr (long CtyCod,char **MapAttribution)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
size_t Length;
|
|
|
|
|
|
|
|
|
|
/***** Free possible former map attribution *****/
|
|
|
|
|
CtyCfg_FreeMapAttr (MapAttribution);
|
|
|
|
|
|
2021-05-22 12:34:10 +02:00
|
|
|
|
/***** Get map attribution from database *****/
|
|
|
|
|
if (Cty_DB_GetMapAttr (&mysql_res,CtyCod))
|
2019-12-29 19:07:59 +01:00
|
|
|
|
{
|
|
|
|
|
/* Get row */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/* Get the attribution of the map of the country (row[0]) */
|
|
|
|
|
if (row[0])
|
|
|
|
|
if (row[0][0])
|
|
|
|
|
{
|
|
|
|
|
Length = strlen (row[0]);
|
2021-02-15 16:25:55 +01:00
|
|
|
|
if ((*MapAttribution = malloc (Length + 1)) == NULL)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (*MapAttribution,row[0],Length);
|
2019-12-29 19:07:59 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Free memory used for map attribution ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void CtyCfg_FreeMapAttr (char **MapAttribution)
|
|
|
|
|
{
|
|
|
|
|
if (*MapAttribution)
|
|
|
|
|
{
|
|
|
|
|
free (*MapAttribution);
|
|
|
|
|
*MapAttribution = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********** Change the attribution of the map of current country ************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void CtyCfg_ChangeCtyMapAttr (void)
|
|
|
|
|
{
|
|
|
|
|
char NewMapAttribution[Med_MAX_BYTES_ATTRIBUTION + 1];
|
|
|
|
|
|
|
|
|
|
/***** Get parameters from form *****/
|
|
|
|
|
/* Get the new map attribution for the country */
|
2023-03-07 09:55:39 +01:00
|
|
|
|
Par_GetParText ("Attribution",NewMapAttribution,Med_MAX_BYTES_ATTRIBUTION);
|
2019-12-29 19:07:59 +01:00
|
|
|
|
|
2021-05-22 12:34:10 +02:00
|
|
|
|
/***** Change old attribution by new attribution in database *****/
|
|
|
|
|
Cty_DB_UpdateCtyMapAttr (NewMapAttribution);
|
2019-12-29 19:07:59 +01:00
|
|
|
|
|
|
|
|
|
/***** Show the country information again *****/
|
|
|
|
|
CtyCfg_ShowConfiguration ();
|
|
|
|
|
}
|