2014-12-01 23:55:08 +01:00
|
|
|
|
// swad_country.c: countries
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
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.
|
2018-04-24 13:21:53 +02:00
|
|
|
|
Copyright (C) 1999-2018 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 ***********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2018-10-20 01:07:58 +02:00
|
|
|
|
#define _GNU_SOURCE // For asprintf
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include <linux/stddef.h> // For NULL
|
|
|
|
|
#include <math.h> // For log10, ceil, pow...
|
2018-10-20 01:07:58 +02:00
|
|
|
|
#include <stdio.h> // For asprintf
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include <stdlib.h> // For calloc
|
|
|
|
|
#include <string.h> // For string functions
|
|
|
|
|
|
2017-06-10 21:38:10 +02:00
|
|
|
|
#include "swad_box.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_constant.h"
|
|
|
|
|
#include "swad_country.h"
|
|
|
|
|
#include "swad_database.h"
|
|
|
|
|
#include "swad_global.h"
|
2015-10-06 20:34:49 +02:00
|
|
|
|
#include "swad_help.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_institution.h"
|
2017-05-07 18:06:34 +02:00
|
|
|
|
#include "swad_language.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_preference.h"
|
|
|
|
|
#include "swad_QR.h"
|
2017-06-11 20:09:59 +02:00
|
|
|
|
#include "swad_table.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_text.h"
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private constants *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************************* Private types *******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private variables *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private prototypes ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Cty_Configuration (bool PrintView);
|
2016-03-18 19:59:27 +01:00
|
|
|
|
static void Cty_PutIconToPrint (void);
|
2017-05-21 14:43:10 +02:00
|
|
|
|
static void Cty_ShowNumUsrsInCrssOfCty (Rol_Role_t Role);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-02-28 00:59:01 +01:00
|
|
|
|
static void Cty_PutHeadCountriesForSeeing (bool OrderSelectable);
|
|
|
|
|
static void Cty_ListOneCountryForSeeing (struct Country *Cty,unsigned NumCty);
|
|
|
|
|
|
2016-11-06 23:24:11 +01:00
|
|
|
|
static bool Cty_CheckIfICanEditCountries (void);
|
2016-11-06 22:42:58 +01:00
|
|
|
|
|
2016-11-06 23:46:29 +01:00
|
|
|
|
static void Cty_PutIconsListCountries (void);
|
2016-03-16 22:40:35 +01:00
|
|
|
|
static void Cty_PutIconToEditCountries (void);
|
2016-03-16 12:11:59 +01:00
|
|
|
|
|
2015-11-17 01:22:57 +01:00
|
|
|
|
static unsigned Cty_GetNumUsrsWhoClaimToBelongToCty (long CtyCod);
|
2017-01-29 12:42:19 +01:00
|
|
|
|
static void Cty_GetParamCtyOrder (void);
|
2017-04-30 20:20:25 +02:00
|
|
|
|
|
|
|
|
|
static void Cty_PutIconToViewCountries (void);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static void Cty_GetMapAttribution (long CtyCod,char **MapAttribution);
|
|
|
|
|
static void Cty_FreeMapAttribution (char **MapAttribution);
|
|
|
|
|
static void Cty_ListCountriesForEdition (void);
|
|
|
|
|
static void Cty_PutParamOtherCtyCod (long CtyCod);
|
2016-10-23 19:40:14 +02:00
|
|
|
|
static long Cty_GetParamOtherCtyCod (void);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static bool Cty_CheckIfNumericCountryCodeExists (long CtyCod);
|
2017-01-28 15:58:46 +01:00
|
|
|
|
static bool Cty_CheckIfAlpha2CountryCodeExists (const char Alpha2[2 + 1]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static bool Cty_CheckIfCountryNameExists (Txt_Language_t Language,const char *Name,long CtyCod);
|
2017-03-10 02:40:01 +01:00
|
|
|
|
static void Cty_UpdateCtyNameDB (long CtyCod,const char *FieldName,const char *NewCtyName);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static void Cty_PutFormToCreateCountry (void);
|
2017-02-28 00:59:01 +01:00
|
|
|
|
static void Cty_PutHeadCountriesForEdition (void);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static void Cty_CreateCountry (struct Country *Cty);
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** List countries with pending institutions ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Cty_SeeCtyWithPendingInss (void)
|
|
|
|
|
{
|
2017-03-27 13:38:10 +02:00
|
|
|
|
extern const char *Hlp_SYSTEM_Hierarchy_pending;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
extern const char *Txt_STR_LANG_ID[1 + Txt_NUM_LANGUAGES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Countries_with_pending_institutions;
|
|
|
|
|
extern const char *Txt_Country;
|
2015-12-09 19:51:17 +01:00
|
|
|
|
extern const char *Txt_Institutions_ABBREVIATION;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_There_are_no_countries_with_requests_for_institutions_to_be_confirmed;
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumCtys;
|
|
|
|
|
unsigned NumCty;
|
|
|
|
|
struct Country Cty;
|
2015-09-04 19:26:08 +02:00
|
|
|
|
const char *BgColor;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get countries with pending institutions *****/
|
2017-06-04 18:18:54 +02:00
|
|
|
|
switch (Gbl.Usrs.Me.Role.Logged)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2015-04-07 21:44:24 +02:00
|
|
|
|
case Rol_SYS_ADM:
|
2018-10-25 11:26:44 +02:00
|
|
|
|
DB_BuildQuery ("SELECT institutions.CtyCod,COUNT(*)"
|
|
|
|
|
" FROM institutions,countries"
|
|
|
|
|
" WHERE (institutions.Status & %u)<>0"
|
|
|
|
|
" AND institutions.CtyCod=countries.CtyCod"
|
|
|
|
|
" GROUP BY institutions.CtyCod"
|
|
|
|
|
" ORDER BY countries.Name_%s",
|
|
|
|
|
(unsigned) Ins_STATUS_BIT_PENDING,
|
|
|
|
|
Txt_STR_LANG_ID[Gbl.Prefs.Language]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
default: // Forbidden for other users
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Get countries *****/
|
2018-10-25 11:26:44 +02:00
|
|
|
|
if ((NumCtys = (unsigned) DB_QuerySELECT_new (&mysql_res,
|
|
|
|
|
"can not get countries"
|
|
|
|
|
"with pending institutions")))
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** Start box and table *****/
|
2017-06-11 22:26:40 +02:00
|
|
|
|
Box_StartBoxTable (NULL,Txt_Countries_with_pending_institutions,NULL,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
Hlp_SYSTEM_Hierarchy_pending,Box_NOT_CLOSABLE,2);
|
2017-06-12 14:16:33 +02:00
|
|
|
|
|
|
|
|
|
/***** Write heading *****/
|
2016-11-14 10:05:41 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2015-09-06 20:02:14 +02:00
|
|
|
|
"<th class=\"LEFT_MIDDLE\">"
|
2014-12-26 22:11:03 +01:00
|
|
|
|
"%s"
|
|
|
|
|
"</th>"
|
2015-09-06 20:02:14 +02:00
|
|
|
|
"<th class=\"RIGHT_MIDDLE\">"
|
2014-12-26 22:11:03 +01:00
|
|
|
|
"%s"
|
|
|
|
|
"</th>"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"</tr>",
|
|
|
|
|
Txt_Country,
|
2015-12-09 19:51:17 +01:00
|
|
|
|
Txt_Institutions_ABBREVIATION);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** List the countries *****/
|
|
|
|
|
for (NumCty = 0;
|
|
|
|
|
NumCty < NumCtys;
|
|
|
|
|
NumCty++)
|
|
|
|
|
{
|
|
|
|
|
/* Get next country */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/* Get country code (row[0]) */
|
|
|
|
|
Cty.CtyCod = Str_ConvertStrCodToLongCod (row[0]);
|
2015-09-04 19:26:08 +02:00
|
|
|
|
BgColor = (Cty.CtyCod == Gbl.CurrentCty.Cty.CtyCod) ? "LIGHT_BLUE" :
|
|
|
|
|
Gbl.ColorRows[Gbl.RowEvenOdd];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get data of country */
|
2015-12-09 19:51:17 +01:00
|
|
|
|
Cty_GetDataOfCountryByCod (&Cty,Cty_GET_BASIC_DATA);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Country map */
|
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2015-11-11 21:14:33 +01:00
|
|
|
|
"<td class=\"LEFT_MIDDLE %s\">",
|
2015-01-16 22:02:21 +01:00
|
|
|
|
BgColor);
|
2015-11-19 18:33:16 +01:00
|
|
|
|
Cty_DrawCountryMapAndNameWithLink (&Cty,ActSeeIns,
|
2017-03-04 19:46:46 +01:00
|
|
|
|
"COUNTRY_SMALL",
|
|
|
|
|
"COUNTRY_MAP_SMALL",
|
|
|
|
|
"DAT");
|
2015-03-13 00:16:02 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</td>");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Number of pending institutions (row[1]) */
|
2015-09-04 17:10:27 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<td class=\"DAT RIGHT_MIDDLE %s\">"
|
2014-12-22 14:08:19 +01:00
|
|
|
|
"%s"
|
|
|
|
|
"</td>"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"</tr>",
|
|
|
|
|
BgColor,row[1]);
|
|
|
|
|
|
|
|
|
|
Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd;
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End table and box *****/
|
2017-06-10 21:38:10 +02:00
|
|
|
|
Box_EndBoxTable ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_INFO,Txt_There_are_no_countries_with_requests_for_institutions_to_be_confirmed);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Show information of the current country *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Cty_ShowConfiguration (void)
|
|
|
|
|
{
|
|
|
|
|
Cty_Configuration (false);
|
2015-10-06 01:19:21 +02:00
|
|
|
|
|
2017-03-30 11:20:06 +02:00
|
|
|
|
/***** Show help to enrol me *****/
|
2015-10-06 20:34:49 +02:00
|
|
|
|
Hlp_ShowHelpWhatWouldYouLikeToDo ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Print information of the current country ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Cty_PrintConfiguration (void)
|
|
|
|
|
{
|
|
|
|
|
Cty_Configuration (true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Information of the current country *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Cty_Configuration (bool PrintView)
|
|
|
|
|
{
|
2016-11-13 16:19:18 +01:00
|
|
|
|
extern const char *Hlp_COUNTRY_Information;
|
2015-07-27 21:25:45 +02:00
|
|
|
|
extern const char *The_ClassForm[The_NUM_THEMES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Country;
|
2015-03-07 18:09:42 +01:00
|
|
|
|
extern const char *Txt_Shortcut;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
extern const char *Txt_STR_LANG_ID[1 + Txt_NUM_LANGUAGES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_QR_code;
|
2016-05-30 19:52:46 +02:00
|
|
|
|
extern const char *Txt_Institutions;
|
|
|
|
|
extern const char *Txt_Institutions_of_COUNTRY_X;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Centres;
|
|
|
|
|
extern const char *Txt_Degrees;
|
|
|
|
|
extern const char *Txt_Courses;
|
2015-12-09 19:51:17 +01:00
|
|
|
|
extern const char *Txt_Users_of_the_country;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
char *MapAttribution = NULL;
|
|
|
|
|
bool PutLink = !PrintView && Gbl.CurrentCty.Cty.WWW[Gbl.Prefs.Language][0];
|
|
|
|
|
|
|
|
|
|
if (Gbl.CurrentCty.Cty.CtyCod > 0)
|
|
|
|
|
{
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** Start box *****/
|
2017-06-11 22:26:40 +02:00
|
|
|
|
if (PrintView)
|
|
|
|
|
Box_StartBox (NULL,NULL,NULL,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
NULL,Box_NOT_CLOSABLE);
|
2017-06-11 22:26:40 +02:00
|
|
|
|
else
|
|
|
|
|
Box_StartBox (NULL,NULL,Cty_PutIconToPrint,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
Hlp_COUNTRY_Information,Box_NOT_CLOSABLE);
|
2014-12-08 17:35:48 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Title *****/
|
2016-11-23 23:58:46 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<div class=\"FRAME_TITLE FRAME_TITLE_BIG\">");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (PutLink)
|
|
|
|
|
fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\""
|
2016-11-23 23:58:46 +01:00
|
|
|
|
" class=\"FRAME_TITLE_BIG\" title=\"%s\">",
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Gbl.CurrentCty.Cty.WWW[Gbl.Prefs.Language],
|
|
|
|
|
Gbl.CurrentCty.Cty.Name[Gbl.Prefs.Language]);
|
|
|
|
|
fprintf (Gbl.F.Out,"%s",Gbl.CurrentCty.Cty.Name[Gbl.Prefs.Language]);
|
|
|
|
|
if (PutLink)
|
|
|
|
|
fprintf (Gbl.F.Out,"</a>");
|
2016-03-18 19:59:27 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</div>");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Country map (and link to WWW if exists) *****/
|
2015-01-16 22:02:21 +01:00
|
|
|
|
if (Cty_CheckIfCountryMapExists (&Gbl.CurrentCty.Cty))
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/* Get map attribution */
|
|
|
|
|
Cty_GetMapAttribution (Gbl.CurrentCty.Cty.CtyCod,&MapAttribution);
|
|
|
|
|
|
|
|
|
|
/* Map image */
|
2016-03-18 19:59:27 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<div class=\"DAT_SMALL CENTER_MIDDLE\">");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (PutLink)
|
|
|
|
|
fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\">",
|
|
|
|
|
Gbl.CurrentCty.Cty.WWW[Gbl.Prefs.Language]);
|
2015-01-16 01:28:42 +01:00
|
|
|
|
Cty_DrawCountryMap (&Gbl.CurrentCty.Cty,PrintView ? "COUNTRY_MAP_PRINT" :
|
|
|
|
|
"COUNTRY_MAP_SHOW");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (PutLink)
|
|
|
|
|
fprintf (Gbl.F.Out,"</a>");
|
2016-03-18 19:59:27 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</div>");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Map attribution */
|
2016-11-06 23:24:11 +01:00
|
|
|
|
if (!PrintView && Cty_CheckIfICanEditCountries ())
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2016-03-18 19:59:27 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<div class=\"CENTER_MIDDLE\">");
|
2018-10-15 14:07:12 +02:00
|
|
|
|
Act_StartForm (ActChgCtyMapAtt);
|
2016-12-26 18:35:52 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<textarea name=\"Attribution\""
|
|
|
|
|
" cols=\"50\" rows=\"2\""
|
2015-10-22 14:49:48 +02:00
|
|
|
|
" onchange=\"document.getElementById('%s').submit();\">",
|
2016-01-14 10:31:09 +01:00
|
|
|
|
Gbl.Form.Id);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (MapAttribution)
|
|
|
|
|
fprintf (Gbl.F.Out,"%s",MapAttribution);
|
2015-03-13 00:16:02 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</textarea>");
|
2018-10-15 14:07:12 +02:00
|
|
|
|
Act_EndForm ();
|
2016-03-18 19:59:27 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</div>");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else if (MapAttribution)
|
2016-03-18 19:59:27 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<div class=\"ATTRIBUTION\">"
|
2014-12-22 14:08:19 +01:00
|
|
|
|
"%s"
|
2016-03-18 19:59:27 +01:00
|
|
|
|
"</div>",
|
2014-12-01 23:55:08 +01:00
|
|
|
|
MapAttribution);
|
|
|
|
|
|
|
|
|
|
/* Free memory used for map attribution */
|
|
|
|
|
Cty_FreeMapAttribution (&MapAttribution);
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-18 19:59:27 +01:00
|
|
|
|
/***** Start table *****/
|
2017-06-11 20:09:59 +02:00
|
|
|
|
Tbl_StartTableWide (2);
|
2016-03-18 19:59:27 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Country name (an link to WWW if exists) *****/
|
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2015-07-27 21:25:45 +02:00
|
|
|
|
"<td class=\"%s RIGHT_MIDDLE\">"
|
2014-12-22 14:08:19 +01:00
|
|
|
|
"%s:"
|
|
|
|
|
"</td>"
|
2015-07-28 11:05:10 +02:00
|
|
|
|
"<td class=\"DAT_N LEFT_MIDDLE\">",
|
2015-07-27 21:25:45 +02:00
|
|
|
|
The_ClassForm[Gbl.Prefs.Theme],
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Txt_Country);
|
|
|
|
|
if (!PrintView && Gbl.CurrentCty.Cty.WWW[Gbl.Prefs.Language][0])
|
|
|
|
|
fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\" class=\"DAT_N\">",
|
|
|
|
|
Gbl.CurrentCty.Cty.WWW[Gbl.Prefs.Language]);
|
|
|
|
|
fprintf (Gbl.F.Out,"%s",Gbl.CurrentCty.Cty.Name[Gbl.Prefs.Language]);
|
|
|
|
|
if (!PrintView && Gbl.CurrentCty.Cty.WWW[Gbl.Prefs.Language][0])
|
|
|
|
|
fprintf (Gbl.F.Out,"</a>");
|
|
|
|
|
fprintf (Gbl.F.Out,"</td>"
|
|
|
|
|
"</tr>");
|
|
|
|
|
|
|
|
|
|
/***** Link to the country inside platform *****/
|
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2015-07-27 21:25:45 +02:00
|
|
|
|
"<td class=\"%s RIGHT_MIDDLE\">"
|
2014-12-22 14:08:19 +01:00
|
|
|
|
"%s:"
|
|
|
|
|
"</td>"
|
2015-07-28 11:05:10 +02:00
|
|
|
|
"<td class=\"DAT LEFT_MIDDLE\">"
|
2015-03-07 21:08:44 +01:00
|
|
|
|
"<a href=\"%s/%s?cty=%ld\" class=\"DAT\" target=\"_blank\">"
|
|
|
|
|
"%s/%s?cty=%ld</a>"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"</td>"
|
|
|
|
|
"</tr>",
|
2015-07-27 21:25:45 +02:00
|
|
|
|
The_ClassForm[Gbl.Prefs.Theme],
|
2015-03-07 18:09:42 +01:00
|
|
|
|
Txt_Shortcut,
|
2016-07-08 12:43:48 +02:00
|
|
|
|
Cfg_URL_SWAD_CGI,
|
2015-12-07 23:13:08 +01:00
|
|
|
|
Txt_STR_LANG_ID[Gbl.Prefs.Language],
|
2015-11-21 20:23:28 +01:00
|
|
|
|
Gbl.CurrentCty.Cty.CtyCod,
|
2016-07-08 12:43:48 +02:00
|
|
|
|
Cfg_URL_SWAD_CGI,
|
2015-12-07 23:13:08 +01:00
|
|
|
|
Txt_STR_LANG_ID[Gbl.Prefs.Language],
|
2015-11-21 20:23:28 +01:00
|
|
|
|
Gbl.CurrentCty.Cty.CtyCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
if (PrintView)
|
|
|
|
|
{
|
|
|
|
|
/***** QR code with link to the country *****/
|
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2015-07-27 21:25:45 +02:00
|
|
|
|
"<td class=\"%s RIGHT_MIDDLE\">"
|
2014-12-22 14:08:19 +01:00
|
|
|
|
"%s:"
|
|
|
|
|
"</td>"
|
2015-07-28 11:05:10 +02:00
|
|
|
|
"<td class=\"DAT LEFT_MIDDLE\">",
|
2015-07-27 21:25:45 +02:00
|
|
|
|
The_ClassForm[Gbl.Prefs.Theme],
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Txt_QR_code);
|
2015-09-28 18:28:29 +02:00
|
|
|
|
QR_LinkTo (250,"cty",Gbl.CurrentCty.Cty.CtyCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</td>"
|
|
|
|
|
"</tr>");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-12-09 19:51:17 +01:00
|
|
|
|
/***** Number of users who claim to belong to this country *****/
|
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
|
|
|
|
"<td class=\"%s RIGHT_MIDDLE\">"
|
|
|
|
|
"%s:"
|
|
|
|
|
"</td>"
|
|
|
|
|
"<td class=\"DAT LEFT_MIDDLE\">"
|
|
|
|
|
"%u"
|
|
|
|
|
"</td>"
|
|
|
|
|
"</tr>",
|
|
|
|
|
The_ClassForm[Gbl.Prefs.Theme],
|
|
|
|
|
Txt_Users_of_the_country,
|
|
|
|
|
Usr_GetNumUsrsWhoClaimToBelongToCty (Gbl.CurrentCty.Cty.CtyCod));
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Number of institutions *****/
|
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2015-07-27 21:25:45 +02:00
|
|
|
|
"<td class=\"%s RIGHT_MIDDLE\">"
|
2016-05-30 19:52:46 +02:00
|
|
|
|
"%s:"
|
|
|
|
|
"</td>"
|
|
|
|
|
"<td class=\"LEFT_MIDDLE\">",
|
2015-07-27 21:25:45 +02:00
|
|
|
|
The_ClassForm[Gbl.Prefs.Theme],
|
2016-05-30 19:52:46 +02:00
|
|
|
|
Txt_Institutions);
|
|
|
|
|
|
|
|
|
|
/* Form to go to see institutions of this country */
|
2018-10-15 14:07:12 +02:00
|
|
|
|
Act_StartFormGoTo (ActSeeIns);
|
2016-05-30 19:52:46 +02:00
|
|
|
|
Cty_PutParamCtyCod (Gbl.CurrentCty.Cty.CtyCod);
|
2018-10-17 10:32:18 +02:00
|
|
|
|
snprintf (Gbl.Title,sizeof (Gbl.Title),
|
|
|
|
|
Txt_Institutions_of_COUNTRY_X,
|
|
|
|
|
Gbl.CurrentCty.Cty.Name[Gbl.Prefs.Language]);
|
2016-07-01 17:13:41 +02:00
|
|
|
|
Act_LinkFormSubmit (Gbl.Title,"DAT",NULL);
|
2016-05-30 19:52:46 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"%u</a>",
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Ins_GetNumInssInCty (Gbl.CurrentCty.Cty.CtyCod));
|
2018-10-15 14:07:12 +02:00
|
|
|
|
Act_EndForm ();
|
2016-05-30 19:52:46 +02:00
|
|
|
|
|
|
|
|
|
fprintf (Gbl.F.Out,"</td>"
|
|
|
|
|
"</tr>");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Number of centres *****/
|
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2015-07-27 21:25:45 +02:00
|
|
|
|
"<td class=\"%s RIGHT_MIDDLE\">"
|
2014-12-22 14:08:19 +01:00
|
|
|
|
"%s:"
|
|
|
|
|
"</td>"
|
2015-07-28 11:05:10 +02:00
|
|
|
|
"<td class=\"DAT LEFT_MIDDLE\">"
|
2014-12-22 14:08:19 +01:00
|
|
|
|
"%u"
|
|
|
|
|
"</td>"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"</tr>",
|
2015-07-27 21:25:45 +02:00
|
|
|
|
The_ClassForm[Gbl.Prefs.Theme],
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Txt_Centres,
|
|
|
|
|
Ctr_GetNumCtrsInCty (Gbl.CurrentCty.Cty.CtyCod));
|
|
|
|
|
|
|
|
|
|
/***** Number of degrees *****/
|
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2015-07-27 21:25:45 +02:00
|
|
|
|
"<td class=\"%s RIGHT_MIDDLE\">"
|
2014-12-22 14:08:19 +01:00
|
|
|
|
"%s:"
|
|
|
|
|
"</td>"
|
2015-07-28 11:05:10 +02:00
|
|
|
|
"<td class=\"DAT LEFT_MIDDLE\">"
|
2014-12-22 14:08:19 +01:00
|
|
|
|
"%u"
|
|
|
|
|
"</td>"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"</tr>",
|
2015-07-27 21:25:45 +02:00
|
|
|
|
The_ClassForm[Gbl.Prefs.Theme],
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Txt_Degrees,
|
|
|
|
|
Deg_GetNumDegsInCty (Gbl.CurrentCty.Cty.CtyCod));
|
|
|
|
|
|
|
|
|
|
/***** Number of courses *****/
|
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2015-07-27 21:25:45 +02:00
|
|
|
|
"<td class=\"%s RIGHT_MIDDLE\">"
|
2014-12-22 14:08:19 +01:00
|
|
|
|
"%s:"
|
|
|
|
|
"</td>"
|
2015-07-28 11:05:10 +02:00
|
|
|
|
"<td class=\"DAT LEFT_MIDDLE\">"
|
2014-12-22 14:08:19 +01:00
|
|
|
|
"%u"
|
|
|
|
|
"</td>"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"</tr>",
|
2015-07-27 21:25:45 +02:00
|
|
|
|
The_ClassForm[Gbl.Prefs.Theme],
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Txt_Courses,
|
|
|
|
|
Crs_GetNumCrssInCty (Gbl.CurrentCty.Cty.CtyCod));
|
|
|
|
|
|
2015-12-09 19:51:17 +01:00
|
|
|
|
/***** Number of users in courses of this country *****/
|
2017-05-21 14:43:10 +02:00
|
|
|
|
Cty_ShowNumUsrsInCrssOfCty (Rol_TCH);
|
2017-05-21 21:23:13 +02:00
|
|
|
|
Cty_ShowNumUsrsInCrssOfCty (Rol_NET);
|
2017-05-21 14:43:10 +02:00
|
|
|
|
Cty_ShowNumUsrsInCrssOfCty (Rol_STD);
|
|
|
|
|
Cty_ShowNumUsrsInCrssOfCty (Rol_UNK);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2014-12-08 17:35:48 +01:00
|
|
|
|
|
2016-03-18 19:59:27 +01:00
|
|
|
|
/***** End table *****/
|
2017-06-11 20:09:59 +02:00
|
|
|
|
Tbl_EndTable ();
|
2016-03-18 19:59:27 +01:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End box *****/
|
2017-06-10 21:38:10 +02:00
|
|
|
|
Box_EndBox ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-18 19:59:27 +01:00
|
|
|
|
/*****************************************************************************/
|
2016-03-18 20:07:40 +01:00
|
|
|
|
/************* Put icon to print the configuration of a country **************/
|
2016-03-18 19:59:27 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Cty_PutIconToPrint (void)
|
|
|
|
|
{
|
2017-06-11 19:13:28 +02:00
|
|
|
|
Ico_PutContextualIconToPrint (ActPrnCtyInf,NULL);
|
2016-03-18 19:59:27 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-21 14:43:10 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************** Number of users in courses of this country *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Cty_ShowNumUsrsInCrssOfCty (Rol_Role_t Role)
|
|
|
|
|
{
|
|
|
|
|
extern const char *The_ClassForm[The_NUM_THEMES];
|
|
|
|
|
extern const char *Txt_Users_in_courses;
|
|
|
|
|
extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
|
|
|
|
|
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
|
|
|
|
"<td class=\"%s RIGHT_MIDDLE\">"
|
|
|
|
|
"%s:"
|
|
|
|
|
"</td>"
|
|
|
|
|
"<td class=\"DAT LEFT_MIDDLE\">"
|
|
|
|
|
"%u"
|
|
|
|
|
"</td>"
|
|
|
|
|
"</tr>",
|
|
|
|
|
The_ClassForm[Gbl.Prefs.Theme],
|
|
|
|
|
(Role == Rol_UNK) ? Txt_Users_in_courses :
|
|
|
|
|
Txt_ROLES_PLURAL_Abc[Role][Usr_SEX_UNKNOWN],
|
|
|
|
|
Usr_GetNumUsrsInCrssOfCty (Role,Gbl.CurrentCty.Cty.CtyCod));
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************************** List all the countries **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Cty_ListCountries (void)
|
|
|
|
|
{
|
|
|
|
|
Cty_ListCountries1 ();
|
|
|
|
|
Cty_ListCountries2 ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************************** List all the countries **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Cty_ListCountries1 (void)
|
|
|
|
|
{
|
|
|
|
|
/***** Get parameter with the type of order in the list of countries *****/
|
2017-01-29 12:42:19 +01:00
|
|
|
|
Cty_GetParamCtyOrder ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get list of countries *****/
|
|
|
|
|
Cty_GetListCountries (Cty_GET_EXTRA_DATA);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Cty_ListCountries2 (void)
|
|
|
|
|
{
|
2016-11-13 14:55:01 +01:00
|
|
|
|
extern const char *Hlp_SYSTEM_Countries;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Countries;
|
|
|
|
|
extern const char *Txt_Other_countries;
|
|
|
|
|
extern const char *Txt_Country_unspecified;
|
|
|
|
|
unsigned NumCty;
|
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** Start box and table *****/
|
2017-06-10 21:38:10 +02:00
|
|
|
|
Box_StartBoxTable (NULL,Txt_Countries,Cty_PutIconsListCountries,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
Hlp_SYSTEM_Countries,Box_NOT_CLOSABLE,2);
|
2017-06-12 14:16:33 +02:00
|
|
|
|
|
|
|
|
|
/***** Write heading *****/
|
2017-02-28 00:59:01 +01:00
|
|
|
|
Cty_PutHeadCountriesForSeeing (true); // Order selectable
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write all the countries and their number of users and institutions *****/
|
|
|
|
|
for (NumCty = 0;
|
|
|
|
|
NumCty < Gbl.Ctys.Num;
|
|
|
|
|
NumCty++)
|
2017-02-28 00:59:01 +01:00
|
|
|
|
Cty_ListOneCountryForSeeing (&Gbl.Ctys.Lst[NumCty],NumCty + 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Separation row *****/
|
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2017-02-28 00:59:01 +01:00
|
|
|
|
"<td colspan=\"8\" class=\"DAT CENTER_MIDDLE\">"
|
2014-12-22 14:08:19 +01:00
|
|
|
|
" "
|
|
|
|
|
"</td>"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"</tr>");
|
|
|
|
|
|
2015-11-17 01:22:57 +01:00
|
|
|
|
/***** Write users and institutions in other countries *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2017-02-28 00:59:01 +01:00
|
|
|
|
"<td class=\"DAT RIGHT_MIDDLE\">"
|
|
|
|
|
"</td>"
|
2015-07-28 11:05:10 +02:00
|
|
|
|
"<td class=\"DAT LEFT_MIDDLE\">"
|
2014-12-22 14:08:19 +01:00
|
|
|
|
"%s"
|
|
|
|
|
"</td>"
|
2015-07-28 11:05:10 +02:00
|
|
|
|
"<td class=\"DAT RIGHT_MIDDLE\">"
|
2014-12-22 14:08:19 +01:00
|
|
|
|
"%u"
|
|
|
|
|
"</td>"
|
2015-07-28 11:05:10 +02:00
|
|
|
|
"<td class=\"DAT RIGHT_MIDDLE\">"
|
2014-12-22 14:08:19 +01:00
|
|
|
|
"%u"
|
|
|
|
|
"</td>"
|
2015-07-28 11:05:10 +02:00
|
|
|
|
"<td class=\"DAT RIGHT_MIDDLE\">"
|
2014-12-22 14:08:19 +01:00
|
|
|
|
"%u"
|
|
|
|
|
"</td>"
|
2015-07-28 11:05:10 +02:00
|
|
|
|
"<td class=\"DAT RIGHT_MIDDLE\">"
|
2014-12-22 14:08:19 +01:00
|
|
|
|
"%u"
|
|
|
|
|
"</td>"
|
2015-11-17 01:22:57 +01:00
|
|
|
|
"<td class=\"DAT RIGHT_MIDDLE\">"
|
|
|
|
|
"%u"
|
|
|
|
|
"</td>"
|
2015-12-09 19:51:17 +01:00
|
|
|
|
"<td class=\"DAT RIGHT_MIDDLE\">"
|
|
|
|
|
"%u"
|
|
|
|
|
"</td>"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"</tr>",
|
|
|
|
|
Txt_Other_countries,
|
2015-11-17 01:22:57 +01:00
|
|
|
|
Cty_GetNumUsrsWhoClaimToBelongToCty (0),
|
2015-12-09 19:51:17 +01:00
|
|
|
|
Ins_GetNumInssInCty (0),
|
|
|
|
|
Ctr_GetNumCtrsInCty (0),
|
|
|
|
|
Deg_GetNumDegsInCty (0),
|
|
|
|
|
Crs_GetNumCrssInCty (0),
|
2017-05-18 19:13:41 +02:00
|
|
|
|
Usr_GetNumUsrsInCrssOfCty (Rol_TCH,0));
|
2015-11-17 01:22:57 +01:00
|
|
|
|
|
|
|
|
|
/***** Write users and institutions with unknown country *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2017-02-28 00:59:01 +01:00
|
|
|
|
"<td class=\"DAT RIGHT_MIDDLE\">"
|
|
|
|
|
"</td>"
|
2015-07-28 11:05:10 +02:00
|
|
|
|
"<td class=\"DAT LEFT_MIDDLE\">"
|
2014-12-22 14:08:19 +01:00
|
|
|
|
"%s"
|
|
|
|
|
"</td>"
|
2015-07-28 11:05:10 +02:00
|
|
|
|
"<td class=\"DAT RIGHT_MIDDLE\">"
|
2014-12-22 14:08:19 +01:00
|
|
|
|
"%u"
|
|
|
|
|
"</td>"
|
2015-07-28 11:05:10 +02:00
|
|
|
|
"<td class=\"DAT RIGHT_MIDDLE\">"
|
2015-12-09 19:51:17 +01:00
|
|
|
|
"%u"
|
|
|
|
|
"</td>"
|
|
|
|
|
"<td class=\"DAT RIGHT_MIDDLE\">"
|
|
|
|
|
"%u"
|
|
|
|
|
"</td>"
|
|
|
|
|
"<td class=\"DAT RIGHT_MIDDLE\">"
|
|
|
|
|
"%u"
|
|
|
|
|
"</td>"
|
|
|
|
|
"<td class=\"DAT RIGHT_MIDDLE\">"
|
|
|
|
|
"%u"
|
2014-12-22 14:08:19 +01:00
|
|
|
|
"</td>"
|
2015-07-28 11:05:10 +02:00
|
|
|
|
"<td class=\"DAT RIGHT_MIDDLE\">"
|
2015-12-09 19:51:17 +01:00
|
|
|
|
"0"
|
2014-12-22 14:08:19 +01:00
|
|
|
|
"</td>"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"</tr>",
|
|
|
|
|
Txt_Country_unspecified,
|
2015-11-17 01:22:57 +01:00
|
|
|
|
Cty_GetNumUsrsWhoClaimToBelongToCty (-1L),
|
2015-12-09 19:51:17 +01:00
|
|
|
|
Ins_GetNumInssInCty (-1L),
|
|
|
|
|
Ctr_GetNumCtrsInCty (-1L),
|
|
|
|
|
Deg_GetNumDegsInCty (-1L),
|
|
|
|
|
Crs_GetNumCrssInCty (-1L));
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End table and box *****/
|
|
|
|
|
Box_EndBoxTable ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Div for Google Geochart *****/
|
2016-01-17 15:10:54 +01:00
|
|
|
|
if (Gbl.Action.Act == ActSeeCty)
|
2015-01-18 19:45:02 +01:00
|
|
|
|
{
|
2015-11-17 01:22:57 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<div id=\"chart_div\""
|
2017-02-28 00:59:01 +01:00
|
|
|
|
" style=\"width:600px; margin:12px auto;\">"
|
2015-01-18 19:45:02 +01:00
|
|
|
|
"</div>");
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free list of countries *****/
|
|
|
|
|
Cty_FreeListCountries ();
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-28 00:59:01 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Write header with fields of a country *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Cty_PutHeadCountriesForSeeing (bool OrderSelectable)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_COUNTRIES_HELP_ORDER[2];
|
|
|
|
|
extern const char *Txt_COUNTRIES_ORDER[2];
|
|
|
|
|
extern const char *Txt_Institutions_ABBREVIATION;
|
|
|
|
|
extern const char *Txt_Centres_ABBREVIATION;
|
|
|
|
|
extern const char *Txt_Degrees_ABBREVIATION;
|
|
|
|
|
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-02-28 00:59:01 +01:00
|
|
|
|
Cty_Order_t Order;
|
|
|
|
|
|
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
|
|
|
|
"<th></th>");
|
|
|
|
|
for (Order = Cty_ORDER_BY_COUNTRY;
|
|
|
|
|
Order <= Cty_ORDER_BY_NUM_USRS;
|
|
|
|
|
Order++)
|
|
|
|
|
{
|
|
|
|
|
fprintf (Gbl.F.Out,"<th class=\"%s\">",
|
|
|
|
|
Order == Cty_ORDER_BY_COUNTRY ? "LEFT_MIDDLE" :
|
|
|
|
|
"RIGHT_MIDDLE");
|
|
|
|
|
if (OrderSelectable)
|
|
|
|
|
{
|
2018-10-15 14:07:12 +02:00
|
|
|
|
Act_StartForm (ActSeeCty);
|
2017-02-28 00:59:01 +01:00
|
|
|
|
Par_PutHiddenParamUnsigned ("Order",(unsigned) Order);
|
|
|
|
|
Act_LinkFormSubmit (Txt_COUNTRIES_HELP_ORDER[Order],"TIT_TBL",NULL);
|
|
|
|
|
if (Order == Gbl.Ctys.SelectedOrder)
|
|
|
|
|
fprintf (Gbl.F.Out,"<u>");
|
|
|
|
|
}
|
|
|
|
|
fprintf (Gbl.F.Out,"%s",Txt_COUNTRIES_ORDER[Order]);
|
|
|
|
|
if (OrderSelectable)
|
|
|
|
|
{
|
|
|
|
|
if (Order == Gbl.Ctys.SelectedOrder)
|
|
|
|
|
fprintf (Gbl.F.Out,"</u>");
|
|
|
|
|
fprintf (Gbl.F.Out,"</a>");
|
2018-10-15 14:07:12 +02:00
|
|
|
|
Act_EndForm ();
|
2017-02-28 00:59:01 +01:00
|
|
|
|
}
|
|
|
|
|
fprintf (Gbl.F.Out,"</th>");
|
|
|
|
|
}
|
|
|
|
|
fprintf (Gbl.F.Out,"<th class=\"RIGHT_MIDDLE\">"
|
|
|
|
|
"%s"
|
|
|
|
|
"</th>"
|
|
|
|
|
"<th class=\"RIGHT_MIDDLE\">"
|
|
|
|
|
"%s"
|
|
|
|
|
"</th>"
|
|
|
|
|
"<th class=\"RIGHT_MIDDLE\">"
|
|
|
|
|
"%s"
|
|
|
|
|
"</th>"
|
|
|
|
|
"<th class=\"RIGHT_MIDDLE\">"
|
|
|
|
|
"%s"
|
|
|
|
|
"</th>"
|
|
|
|
|
"<th class=\"RIGHT_MIDDLE\">"
|
|
|
|
|
"%s+<br />%s"
|
|
|
|
|
"</th>"
|
|
|
|
|
"</tr>",
|
|
|
|
|
Txt_Institutions_ABBREVIATION,
|
|
|
|
|
Txt_Centres_ABBREVIATION,
|
|
|
|
|
Txt_Degrees_ABBREVIATION,
|
|
|
|
|
Txt_Courses_ABBREVIATION,
|
2017-05-30 21:43:05 +02:00
|
|
|
|
Txt_ROLES_PLURAL_BRIEF_Abc[Rol_TCH],
|
|
|
|
|
Txt_ROLES_PLURAL_BRIEF_Abc[Rol_STD]);
|
2017-02-28 00:59:01 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ List one country for seeing ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Cty_ListOneCountryForSeeing (struct Country *Cty,unsigned NumCty)
|
|
|
|
|
{
|
|
|
|
|
const char *BgColor;
|
|
|
|
|
|
|
|
|
|
BgColor = (Cty->CtyCod == Gbl.CurrentCty.Cty.CtyCod) ? "LIGHT_BLUE" :
|
|
|
|
|
Gbl.ColorRows[Gbl.RowEvenOdd];
|
|
|
|
|
|
|
|
|
|
/***** Number of country in this list *****/
|
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
|
|
|
|
"<td class=\"DAT RIGHT_MIDDLE %s\">"
|
|
|
|
|
"%u"
|
|
|
|
|
"</td>",
|
|
|
|
|
BgColor,NumCty);
|
|
|
|
|
|
|
|
|
|
/***** Country map (and link to WWW if exists) *****/
|
2017-03-04 17:28:15 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<td class=\"LEFT_MIDDLE %s\">",BgColor);
|
2017-02-28 00:59:01 +01:00
|
|
|
|
Cty_DrawCountryMapAndNameWithLink (Cty,ActSeeIns,
|
2017-03-04 19:46:46 +01:00
|
|
|
|
"COUNTRY_SMALL",
|
|
|
|
|
"COUNTRY_MAP_SMALL",
|
|
|
|
|
"DAT_N");
|
2017-02-28 00:59:01 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</td>");
|
|
|
|
|
|
|
|
|
|
/* Write stats of this country */
|
|
|
|
|
fprintf (Gbl.F.Out,"<td class=\"DAT RIGHT_MIDDLE %s\">"
|
|
|
|
|
"%u"
|
|
|
|
|
"</td>"
|
|
|
|
|
"<td class=\"DAT RIGHT_MIDDLE %s\">"
|
|
|
|
|
"%u"
|
|
|
|
|
"</td>"
|
|
|
|
|
"<td class=\"DAT RIGHT_MIDDLE %s\">"
|
|
|
|
|
"%u"
|
|
|
|
|
"</td>"
|
|
|
|
|
"<td class=\"DAT RIGHT_MIDDLE %s\">"
|
|
|
|
|
"%u"
|
|
|
|
|
"</td>"
|
|
|
|
|
"<td class=\"DAT RIGHT_MIDDLE %s\">"
|
|
|
|
|
"%u"
|
|
|
|
|
"</td>"
|
|
|
|
|
"<td class=\"DAT RIGHT_MIDDLE %s\">"
|
|
|
|
|
"%u"
|
|
|
|
|
"</td>"
|
|
|
|
|
"</tr>",
|
|
|
|
|
BgColor,Cty->NumUsrsWhoClaimToBelongToCty,
|
|
|
|
|
BgColor,Cty->NumInss,
|
|
|
|
|
BgColor,Cty->NumCtrs,
|
|
|
|
|
BgColor,Cty->NumDegs,
|
|
|
|
|
BgColor,Cty->NumCrss,
|
|
|
|
|
BgColor,Cty->NumUsrs);
|
|
|
|
|
|
|
|
|
|
Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-06 22:42:58 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Check if I can edit countries ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-11-06 23:24:11 +01:00
|
|
|
|
static bool Cty_CheckIfICanEditCountries (void)
|
2016-11-06 22:42:58 +01:00
|
|
|
|
{
|
2017-06-04 18:18:54 +02:00
|
|
|
|
return (bool) (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM);
|
2016-11-06 22:42:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-06 21:19:25 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Put contextual icons in list of countries *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-11-06 23:46:29 +01:00
|
|
|
|
static void Cty_PutIconsListCountries (void)
|
2016-11-06 21:19:25 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Put icon to edit countries *****/
|
2016-11-06 23:24:11 +01:00
|
|
|
|
if (Cty_CheckIfICanEditCountries ())
|
2016-11-06 21:19:25 +01:00
|
|
|
|
Cty_PutIconToEditCountries ();
|
|
|
|
|
|
|
|
|
|
/***** Put icon to show a figure *****/
|
|
|
|
|
Gbl.Stat.FigureType = Sta_HIERARCHY;
|
|
|
|
|
Sta_PutIconToShowFigure ();
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-16 12:11:59 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Put link (form) to edit countries *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-03-16 22:40:35 +01:00
|
|
|
|
static void Cty_PutIconToEditCountries (void)
|
2016-03-16 12:11:59 +01:00
|
|
|
|
{
|
2017-06-11 19:13:28 +02:00
|
|
|
|
Ico_PutContextualIconToEdit (ActEdiCty,NULL);
|
2016-03-16 12:11:59 +01:00
|
|
|
|
}
|
|
|
|
|
|
2015-11-17 01:22:57 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******** Get number of users who claim to belong to other countries *********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static unsigned Cty_GetNumUsrsWhoClaimToBelongToCty (long CtyCod)
|
|
|
|
|
{
|
|
|
|
|
/***** Get number of users from database *****/
|
2018-10-26 11:01:06 +02:00
|
|
|
|
DB_BuildQuery ("SELECT COUNT(*) FROM usr_data WHERE CtyCod=%ld",CtyCod);
|
|
|
|
|
return (unsigned) DB_QueryCOUNT_new ("can not get number of users"
|
|
|
|
|
" who claim to belong"
|
|
|
|
|
" to other countries");
|
2015-11-17 01:22:57 +01:00
|
|
|
|
}
|
|
|
|
|
|
2015-01-16 01:28:42 +01:00
|
|
|
|
/*****************************************************************************/
|
2015-11-19 18:33:16 +01:00
|
|
|
|
/********************* Draw country map and name with link *******************/
|
2015-01-16 22:02:21 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-11-19 18:33:16 +01:00
|
|
|
|
void Cty_DrawCountryMapAndNameWithLink (struct Country *Cty,Act_Action_t Action,
|
2017-03-04 19:46:46 +01:00
|
|
|
|
const char *ClassContainer,
|
|
|
|
|
const char *ClassMap,
|
|
|
|
|
const char *ClassLink)
|
2015-01-16 22:02:21 +01:00
|
|
|
|
{
|
2015-11-11 21:14:33 +01:00
|
|
|
|
extern const char *Txt_Go_to_X;
|
2017-03-10 02:40:01 +01:00
|
|
|
|
char CountryName[Cty_MAX_BYTES_NAME + 1];
|
2015-01-16 22:02:21 +01:00
|
|
|
|
|
2015-11-11 21:14:33 +01:00
|
|
|
|
/***** Start form *****/
|
2018-10-15 14:07:12 +02:00
|
|
|
|
Act_StartFormGoTo (Action);
|
2015-11-11 21:14:33 +01:00
|
|
|
|
Cty_PutParamCtyCod (Cty->CtyCod);
|
2017-03-04 19:46:46 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<div class=\"%s\">",ClassContainer);
|
2015-11-11 21:14:33 +01:00
|
|
|
|
|
|
|
|
|
/***** Link to action *****/
|
2018-10-17 10:32:18 +02:00
|
|
|
|
snprintf (Gbl.Title,sizeof (Gbl.Title),
|
|
|
|
|
Txt_Go_to_X,
|
|
|
|
|
Cty->Name[Gbl.Prefs.Language]);
|
2016-07-01 17:13:41 +02:00
|
|
|
|
Act_LinkFormSubmit (Gbl.Title,ClassLink,NULL);
|
2015-11-11 21:14:33 +01:00
|
|
|
|
|
|
|
|
|
/***** Draw country map *****/
|
|
|
|
|
Cty_DrawCountryMap (Cty,ClassMap);
|
|
|
|
|
|
2015-11-27 23:17:28 +01:00
|
|
|
|
/***** Write country name and end link *****/
|
2017-01-15 18:02:52 +01:00
|
|
|
|
Str_Copy (CountryName,Cty->Name[Gbl.Prefs.Language],
|
2017-03-10 02:40:01 +01:00
|
|
|
|
Cty_MAX_BYTES_NAME);
|
2017-03-04 19:46:46 +01:00
|
|
|
|
fprintf (Gbl.F.Out," %s (%s)"
|
|
|
|
|
"</a>"
|
|
|
|
|
"</div>",
|
2015-11-27 23:17:28 +01:00
|
|
|
|
CountryName,
|
2015-01-16 22:02:21 +01:00
|
|
|
|
Cty->Alpha2);
|
2015-11-11 21:14:33 +01:00
|
|
|
|
|
|
|
|
|
/***** End form *****/
|
2018-10-15 14:07:12 +02:00
|
|
|
|
Act_EndForm ();
|
2015-01-16 22:02:21 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Draw country map ******************************/
|
2015-01-16 01:28:42 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Cty_DrawCountryMap (struct Country *Cty,const char *Class)
|
|
|
|
|
{
|
|
|
|
|
/***** Draw country map *****/
|
2015-11-11 21:14:33 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<img src=\"");
|
|
|
|
|
if (Cty_CheckIfCountryMapExists (Cty))
|
|
|
|
|
fprintf (Gbl.F.Out,"%s/%s/%s/%s.png",
|
|
|
|
|
Gbl.Prefs.IconsURL,Cfg_ICON_FOLDER_COUNTRIES,
|
|
|
|
|
Cty->Alpha2,
|
|
|
|
|
Cty->Alpha2);
|
|
|
|
|
else
|
|
|
|
|
fprintf (Gbl.F.Out,"%s/tr16x16.gif", // TODO: Change for a 1x1 image or a generic image
|
|
|
|
|
Gbl.Prefs.IconsURL);
|
|
|
|
|
fprintf (Gbl.F.Out,"\" alt=\"%s\" title=\"%s\" class=\"%s\" />",
|
2015-01-16 01:28:42 +01:00
|
|
|
|
Cty->Alpha2,
|
|
|
|
|
Cty->Name[Gbl.Prefs.Language],
|
|
|
|
|
Class);
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-11 21:14:33 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********************** Check if country map exists *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
bool Cty_CheckIfCountryMapExists (struct Country *Cty)
|
|
|
|
|
{
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char PathMap[PATH_MAX + 1];
|
2015-11-11 21:14:33 +01:00
|
|
|
|
|
2018-10-17 10:32:18 +02:00
|
|
|
|
snprintf (PathMap,sizeof (PathMap),
|
|
|
|
|
"%s/%s/%s/%s/%s.png",
|
|
|
|
|
Cfg_PATH_SWAD_PUBLIC,
|
|
|
|
|
Cfg_FOLDER_PUBLIC_ICON,
|
|
|
|
|
Cfg_ICON_FOLDER_COUNTRIES,
|
|
|
|
|
Cty->Alpha2,
|
|
|
|
|
Cty->Alpha2);
|
2015-11-11 21:14:33 +01:00
|
|
|
|
return Fil_CheckIfPathExists (PathMap);
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Write script for Google Geochart *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Cty_WriteScriptGoogleGeochart (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Country_NO_HTML;
|
|
|
|
|
extern const char *Txt_Users_NO_HTML;
|
|
|
|
|
extern const char *Txt_Institutions_NO_HTML;
|
|
|
|
|
unsigned NumCty;
|
2016-02-06 12:50:05 +01:00
|
|
|
|
unsigned MaxUsrsInCountry = 0;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned NumCtysWithUsrs = 0;
|
|
|
|
|
|
|
|
|
|
/***** Write start of the script *****/
|
|
|
|
|
fprintf (Gbl.F.Out,"<script type=\"text/javascript\" src=\"https://www.google.com/jsapi\"></script>\n"
|
|
|
|
|
"<script type=\"text/javascript\">\n"
|
|
|
|
|
" google.load('visualization', '1', {'packages': ['geochart']});\n"
|
|
|
|
|
" google.setOnLoadCallback(drawRegionsMap);\n"
|
|
|
|
|
" function drawRegionsMap() {\n"
|
|
|
|
|
" var data = new google.visualization.DataTable();\n"
|
|
|
|
|
" data.addColumn('string', '%s');\n"
|
|
|
|
|
" data.addColumn('number', '%s');\n"
|
|
|
|
|
" data.addColumn('number', '%s');\n"
|
|
|
|
|
" data.addRows([\n",
|
|
|
|
|
Txt_Country_NO_HTML,
|
|
|
|
|
Txt_Users_NO_HTML,
|
|
|
|
|
Txt_Institutions_NO_HTML);
|
|
|
|
|
|
|
|
|
|
/***** Write all the countries and their number of users and institutions *****/
|
|
|
|
|
for (NumCty = 0;
|
|
|
|
|
NumCty < Gbl.Ctys.Num;
|
|
|
|
|
NumCty++)
|
2015-12-09 19:51:17 +01:00
|
|
|
|
if (Gbl.Ctys.Lst[NumCty].NumUsrsWhoClaimToBelongToCty)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/* Write data of this country */
|
|
|
|
|
fprintf (Gbl.F.Out," ['%s', %u, %u],\n",
|
|
|
|
|
Gbl.Ctys.Lst[NumCty].Alpha2,
|
2015-12-09 19:51:17 +01:00
|
|
|
|
Gbl.Ctys.Lst[NumCty].NumUsrsWhoClaimToBelongToCty,
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Gbl.Ctys.Lst[NumCty].NumInss);
|
2016-02-06 12:50:05 +01:00
|
|
|
|
if (Gbl.Ctys.Lst[NumCty].NumUsrsWhoClaimToBelongToCty > MaxUsrsInCountry)
|
|
|
|
|
MaxUsrsInCountry = Gbl.Ctys.Lst[NumCty].NumUsrsWhoClaimToBelongToCty;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
NumCtysWithUsrs++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Write end of the script *****/
|
|
|
|
|
fprintf (Gbl.F.Out," ]);\n"
|
|
|
|
|
" var options = {\n"
|
2017-02-28 00:59:01 +01:00
|
|
|
|
" width:600,\n"
|
|
|
|
|
" height:360,\n"
|
2015-09-04 19:26:08 +02:00
|
|
|
|
" backgroundColor:'white',\n"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
" datalessRegionColor:'white',\n"
|
2017-02-28 00:59:01 +01:00
|
|
|
|
" colorAxis:{colors:['#EAF1F4','#4D88A1'],minValue:0,maxValue:%u}};\n"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
" var chart = new google.visualization.GeoChart(document.getElementById('chart_div'));\n"
|
|
|
|
|
" chart.draw(data, options);\n"
|
|
|
|
|
" };\n"
|
|
|
|
|
"</script>\n",
|
2016-02-06 12:50:05 +01:00
|
|
|
|
NumCtysWithUsrs ? MaxUsrsInCountry :
|
|
|
|
|
0);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******** Get parameter with the type or order in list of countries **********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-01-29 12:42:19 +01:00
|
|
|
|
static void Cty_GetParamCtyOrder (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-01-29 21:41:08 +01:00
|
|
|
|
Gbl.Ctys.SelectedOrder = (Cty_Order_t)
|
|
|
|
|
Par_GetParToUnsignedLong ("Order",
|
|
|
|
|
0,
|
|
|
|
|
Cty_NUM_ORDERS - 1,
|
|
|
|
|
(unsigned long) Cty_ORDER_DEFAULT);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Put forms to edit institution types ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Cty_EditCountries (void)
|
|
|
|
|
{
|
2017-04-30 20:20:25 +02:00
|
|
|
|
extern const char *Hlp_SYSTEM_Countries;
|
|
|
|
|
extern const char *Txt_Countries;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get list of countries *****/
|
2017-01-29 12:42:19 +01:00
|
|
|
|
Gbl.Ctys.SelectedOrder = Cty_ORDER_BY_COUNTRY;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Cty_GetListCountries (Cty_GET_EXTRA_DATA);
|
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** Start box *****/
|
2017-06-10 21:38:10 +02:00
|
|
|
|
Box_StartBox (NULL,Txt_Countries,Cty_PutIconToViewCountries,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
Hlp_SYSTEM_Countries,Box_NOT_CLOSABLE);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Put a form to create a new country *****/
|
|
|
|
|
Cty_PutFormToCreateCountry ();
|
|
|
|
|
|
|
|
|
|
/***** Forms to edit current countries *****/
|
|
|
|
|
if (Gbl.Ctys.Num)
|
|
|
|
|
Cty_ListCountriesForEdition ();
|
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End box *****/
|
2017-06-10 21:38:10 +02:00
|
|
|
|
Box_EndBox ();
|
2017-04-30 20:20:25 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Free list of countries *****/
|
|
|
|
|
Cty_FreeListCountries ();
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-30 20:20:25 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Put contextual icons in edition of countries ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Cty_PutIconToViewCountries (void)
|
|
|
|
|
{
|
2017-06-11 19:13:28 +02:00
|
|
|
|
Ico_PutContextualIconToView (ActSeeCty,NULL);
|
2017-04-30 20:20:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** List all the countries ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-03-07 11:03:05 +01:00
|
|
|
|
#define Cty_MAX_BYTES_SUBQUERY_CTYS ((1 + Txt_NUM_LANGUAGES) * 32)
|
2017-01-16 01:51:01 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Cty_GetListCountries (Cty_GetExtraData_t GetExtraData)
|
|
|
|
|
{
|
2017-01-28 15:58:46 +01:00
|
|
|
|
extern const char *Txt_STR_LANG_ID[1 + Txt_NUM_LANGUAGES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
char StrField[32];
|
2017-03-07 11:03:05 +01:00
|
|
|
|
char SubQueryNam1[Cty_MAX_BYTES_SUBQUERY_CTYS + 1];
|
|
|
|
|
char SubQueryNam2[Cty_MAX_BYTES_SUBQUERY_CTYS + 1];
|
|
|
|
|
char SubQueryWWW1[Cty_MAX_BYTES_SUBQUERY_CTYS + 1];
|
|
|
|
|
char SubQueryWWW2[Cty_MAX_BYTES_SUBQUERY_CTYS + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
char OrderBySubQuery[256];
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned long NumRows;
|
|
|
|
|
unsigned NumCty;
|
|
|
|
|
struct Country *Cty;
|
|
|
|
|
Txt_Language_t Lan;
|
|
|
|
|
|
|
|
|
|
/***** Get countries from database *****/
|
|
|
|
|
switch (GetExtraData)
|
|
|
|
|
{
|
2015-12-09 19:51:17 +01:00
|
|
|
|
case Cty_GET_BASIC_DATA:
|
2018-10-25 11:26:44 +02:00
|
|
|
|
DB_BuildQuery ("SELECT CtyCod,Alpha2,Name_%s"
|
|
|
|
|
" FROM countries ORDER BY Name_%s",
|
|
|
|
|
Txt_STR_LANG_ID[Gbl.Prefs.Language],
|
|
|
|
|
Txt_STR_LANG_ID[Gbl.Prefs.Language]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
case Cty_GET_EXTRA_DATA:
|
|
|
|
|
SubQueryNam1[0] = '\0';
|
|
|
|
|
SubQueryNam2[0] = '\0';
|
|
|
|
|
SubQueryWWW1[0] = '\0';
|
|
|
|
|
SubQueryWWW2[0] = '\0';
|
2015-12-07 23:13:08 +01:00
|
|
|
|
for (Lan = (Txt_Language_t) 1;
|
|
|
|
|
Lan <= Txt_NUM_LANGUAGES;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Lan++)
|
|
|
|
|
{
|
2018-10-17 10:32:18 +02:00
|
|
|
|
snprintf (StrField,sizeof (StrField),
|
|
|
|
|
"countries.Name_%s,",
|
|
|
|
|
Txt_STR_LANG_ID[Lan]);
|
2017-01-17 03:33:05 +01:00
|
|
|
|
Str_Concat (SubQueryNam1,StrField,
|
2017-03-07 11:03:05 +01:00
|
|
|
|
Cty_MAX_BYTES_SUBQUERY_CTYS);
|
2018-10-17 10:32:18 +02:00
|
|
|
|
snprintf (StrField,sizeof (StrField),
|
|
|
|
|
"Name_%s,",
|
|
|
|
|
Txt_STR_LANG_ID[Lan]);
|
2017-01-17 03:33:05 +01:00
|
|
|
|
Str_Concat (SubQueryNam2,StrField,
|
2017-03-07 11:03:05 +01:00
|
|
|
|
Cty_MAX_BYTES_SUBQUERY_CTYS);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2018-10-17 10:32:18 +02:00
|
|
|
|
snprintf (StrField,sizeof (StrField),
|
|
|
|
|
"countries.WWW_%s,",
|
|
|
|
|
Txt_STR_LANG_ID[Lan]);
|
2017-01-17 03:33:05 +01:00
|
|
|
|
Str_Concat (SubQueryWWW1,StrField,
|
2017-03-07 11:03:05 +01:00
|
|
|
|
Cty_MAX_BYTES_SUBQUERY_CTYS);
|
2018-10-17 10:32:18 +02:00
|
|
|
|
snprintf (StrField,sizeof (StrField),
|
|
|
|
|
"WWW_%s,",
|
|
|
|
|
Txt_STR_LANG_ID[Lan]);
|
2017-01-17 03:33:05 +01:00
|
|
|
|
Str_Concat (SubQueryWWW2,StrField,
|
2017-03-07 11:03:05 +01:00
|
|
|
|
Cty_MAX_BYTES_SUBQUERY_CTYS);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-01-29 12:42:19 +01:00
|
|
|
|
switch (Gbl.Ctys.SelectedOrder)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
case Cty_ORDER_BY_COUNTRY:
|
|
|
|
|
sprintf (OrderBySubQuery,"Name_%s",
|
|
|
|
|
Txt_STR_LANG_ID[Gbl.Prefs.Language]);
|
|
|
|
|
break;
|
|
|
|
|
case Cty_ORDER_BY_NUM_USRS:
|
|
|
|
|
sprintf (OrderBySubQuery,"NumUsrs DESC,Name_%s",
|
|
|
|
|
Txt_STR_LANG_ID[Gbl.Prefs.Language]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2018-10-25 11:26:44 +02:00
|
|
|
|
DB_BuildQuery ("(SELECT countries.CtyCod,countries.Alpha2,%s%sCOUNT(*) AS NumUsrs"
|
|
|
|
|
" FROM countries,usr_data"
|
|
|
|
|
" WHERE countries.CtyCod=usr_data.CtyCod"
|
|
|
|
|
" GROUP BY countries.CtyCod)"
|
|
|
|
|
" UNION "
|
|
|
|
|
"(SELECT CtyCod,Alpha2,%s%s0 AS NumUsrs"
|
|
|
|
|
" FROM countries"
|
|
|
|
|
" WHERE CtyCod NOT IN"
|
|
|
|
|
" (SELECT DISTINCT CtyCod FROM usr_data))"
|
|
|
|
|
" ORDER BY %s",
|
|
|
|
|
SubQueryNam1,SubQueryWWW1,
|
|
|
|
|
SubQueryNam2,SubQueryWWW2,OrderBySubQuery);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Count number of rows in result *****/
|
2018-10-25 11:26:44 +02:00
|
|
|
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get countries");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (NumRows) // Countries found...
|
|
|
|
|
{
|
|
|
|
|
Gbl.Ctys.Num = (unsigned) NumRows;
|
|
|
|
|
|
|
|
|
|
/***** Create list with countries *****/
|
|
|
|
|
if ((Gbl.Ctys.Lst = (struct Country *) calloc (NumRows,sizeof (struct Country))) == NULL)
|
2018-10-18 20:06:54 +02:00
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get the countries *****/
|
|
|
|
|
for (NumCty = 0;
|
|
|
|
|
NumCty < Gbl.Ctys.Num;
|
|
|
|
|
NumCty++)
|
|
|
|
|
{
|
|
|
|
|
Cty = &(Gbl.Ctys.Lst[NumCty]);
|
|
|
|
|
|
|
|
|
|
/* Get next country */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/* Get numerical country code (row[0]) */
|
|
|
|
|
if ((Cty->CtyCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
|
|
|
|
Lay_ShowErrorAndExit ("Wrong code of country.");
|
|
|
|
|
|
|
|
|
|
/* Get Alpha-2 country code (row[1]) */
|
2017-01-17 03:10:43 +01:00
|
|
|
|
Str_Copy (Cty->Alpha2,row[1],
|
|
|
|
|
2);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
switch (GetExtraData)
|
|
|
|
|
{
|
2015-12-09 19:51:17 +01:00
|
|
|
|
case Cty_GET_BASIC_DATA:
|
|
|
|
|
for (Lan = (Txt_Language_t) 1;
|
|
|
|
|
Lan <= Txt_NUM_LANGUAGES;
|
|
|
|
|
Lan++)
|
|
|
|
|
{
|
|
|
|
|
Cty->Name[Lan][0] = '\0';
|
|
|
|
|
Cty->WWW[Lan][0] = '\0';
|
|
|
|
|
}
|
|
|
|
|
Cty->NumUsrsWhoClaimToBelongToCty = 0;
|
|
|
|
|
Cty->NumInss = Cty->NumCtrs = Cty->NumDegs = Cty->NumCrss = 0;
|
2015-12-14 12:13:41 +01:00
|
|
|
|
Cty->NumUsrs = 0;
|
2015-12-09 19:51:17 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/* Get the name of the country in current language */
|
2017-01-15 18:02:52 +01:00
|
|
|
|
Str_Copy (Cty->Name[Gbl.Prefs.Language],row[2],
|
2017-03-10 02:40:01 +01:00
|
|
|
|
Cty_MAX_BYTES_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
case Cty_GET_EXTRA_DATA:
|
|
|
|
|
/* Get the name of the country in several languages */
|
2015-12-07 23:13:08 +01:00
|
|
|
|
for (Lan = (Txt_Language_t) 1;
|
|
|
|
|
Lan <= Txt_NUM_LANGUAGES;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Lan++)
|
|
|
|
|
{
|
2017-01-15 18:02:52 +01:00
|
|
|
|
Str_Copy (Cty->Name[Lan],row[1 + Lan],
|
2017-03-10 02:40:01 +01:00
|
|
|
|
Cty_MAX_BYTES_NAME);
|
2017-01-15 18:02:52 +01:00
|
|
|
|
Str_Copy (Cty->WWW[Lan],row[1 + Txt_NUM_LANGUAGES + Lan],
|
2017-03-07 01:56:41 +01:00
|
|
|
|
Cns_MAX_BYTES_WWW);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-09 19:51:17 +01:00
|
|
|
|
/* Get number of users who claim to belong to this country */
|
2017-01-28 15:58:46 +01:00
|
|
|
|
if (sscanf (row[1 + Txt_NUM_LANGUAGES * 2 + 1],"%u",
|
|
|
|
|
&Cty->NumUsrsWhoClaimToBelongToCty) != 1)
|
2015-12-09 19:51:17 +01:00
|
|
|
|
Cty->NumUsrsWhoClaimToBelongToCty = 0;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get number of institutions in this country */
|
|
|
|
|
Cty->NumInss = Ins_GetNumInssInCty (Cty->CtyCod);
|
2015-12-09 19:51:17 +01:00
|
|
|
|
|
|
|
|
|
/* Get number of centres in this country */
|
|
|
|
|
Cty->NumCtrs = Ctr_GetNumCtrsInCty (Cty->CtyCod);
|
|
|
|
|
|
|
|
|
|
/* Get number of degrees in this country */
|
|
|
|
|
Cty->NumDegs = Deg_GetNumDegsInCty (Cty->CtyCod);
|
|
|
|
|
|
|
|
|
|
/* Get number of courses in this country */
|
|
|
|
|
Cty->NumCrss = Crs_GetNumCrssInCty (Cty->CtyCod);
|
|
|
|
|
|
|
|
|
|
/* Get number of users in courses of this country */
|
2017-05-18 19:13:41 +02:00
|
|
|
|
Cty->NumUsrs = Usr_GetNumUsrsInCrssOfCty (Rol_UNK,Cty->CtyCod); // Here Rol_UNK means "all users"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
Gbl.Ctys.Num = 0;
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Write selector of country ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-07-25 20:20:07 +02:00
|
|
|
|
void Cty_WriteSelectorOfCountry (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Country;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
extern const char *Txt_STR_LANG_ID[1 + Txt_NUM_LANGUAGES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumCtys;
|
|
|
|
|
unsigned NumCty;
|
|
|
|
|
long CtyCod;
|
|
|
|
|
|
|
|
|
|
/***** Start form *****/
|
2018-10-15 14:07:12 +02:00
|
|
|
|
Act_StartFormGoTo (ActSeeIns);
|
2016-12-20 10:03:00 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<select id=\"cty\" name=\"cty\" style=\"width:175px;\""
|
2015-10-22 14:49:48 +02:00
|
|
|
|
" onchange=\"document.getElementById('%s').submit();\">"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"<option value=\"\"",
|
2016-01-14 10:31:09 +01:00
|
|
|
|
Gbl.Form.Id);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (Gbl.CurrentCty.Cty.CtyCod < 0)
|
|
|
|
|
fprintf (Gbl.F.Out," selected=\"selected\"");
|
|
|
|
|
fprintf (Gbl.F.Out," disabled=\"disabled\">[%s]</option>",
|
|
|
|
|
Txt_Country);
|
|
|
|
|
|
|
|
|
|
/***** Get countries from database *****/
|
2018-10-25 11:26:44 +02:00
|
|
|
|
DB_BuildQuery ("SELECT DISTINCT CtyCod,Name_%s"
|
|
|
|
|
" FROM countries"
|
|
|
|
|
" ORDER BY countries.Name_%s",
|
|
|
|
|
Txt_STR_LANG_ID[Gbl.Prefs.Language],
|
|
|
|
|
Txt_STR_LANG_ID[Gbl.Prefs.Language]);
|
|
|
|
|
NumCtys = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get countries");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** List countries *****/
|
|
|
|
|
for (NumCty = 0;
|
|
|
|
|
NumCty < NumCtys;
|
|
|
|
|
NumCty++)
|
|
|
|
|
{
|
|
|
|
|
/* Get next country */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/* Get country code (row[0]) */
|
|
|
|
|
if ((CtyCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
|
|
|
|
Lay_ShowErrorAndExit ("Wrong code of country.");
|
|
|
|
|
|
|
|
|
|
/* Write option */
|
|
|
|
|
fprintf (Gbl.F.Out,"<option value=\"%ld\"",CtyCod);
|
|
|
|
|
if (CtyCod == Gbl.CurrentCty.Cty.CtyCod)
|
|
|
|
|
fprintf (Gbl.F.Out," selected=\"selected\"");
|
|
|
|
|
fprintf (Gbl.F.Out,">%s</option>",row[1]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
/***** End form *****/
|
2015-03-13 00:16:02 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</select>");
|
2018-10-15 14:07:12 +02:00
|
|
|
|
Act_EndForm ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-03-02 00:53:34 +01:00
|
|
|
|
/***************************** Write country name ****************************/
|
2015-12-08 00:25:56 +01:00
|
|
|
|
/*****************************************************************************/
|
2017-03-01 14:53:18 +01:00
|
|
|
|
// If ClassLink == NULL ==> do not put link
|
2015-12-08 00:25:56 +01:00
|
|
|
|
|
2017-03-01 14:53:18 +01:00
|
|
|
|
void Cty_WriteCountryName (long CtyCod,const char *ClassLink)
|
2015-12-08 00:25:56 +01:00
|
|
|
|
{
|
2017-03-10 02:40:01 +01:00
|
|
|
|
char CtyName[Cty_MAX_BYTES_NAME + 1];
|
2017-03-07 01:56:41 +01:00
|
|
|
|
char ActTxt[Act_MAX_BYTES_ACTION_TXT + 1];
|
2017-03-01 14:53:18 +01:00
|
|
|
|
bool PutForm = ClassLink &&
|
|
|
|
|
!Gbl.Form.Inside && // Only if not inside another form
|
2018-04-24 13:21:53 +02:00
|
|
|
|
Act_GetBrowserTab (Gbl.Action.Act) == Act_BRW_1ST_TAB; // Only in main browser tab
|
2015-12-08 00:25:56 +01:00
|
|
|
|
|
|
|
|
|
/***** Get country name *****/
|
|
|
|
|
Cty_GetCountryName (CtyCod,CtyName);
|
|
|
|
|
|
2016-09-09 01:17:53 +02:00
|
|
|
|
if (PutForm)
|
2015-12-15 01:33:09 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Write country name with link to country information *****/
|
2018-10-15 14:07:12 +02:00
|
|
|
|
Act_StartForm (ActSeeCtyInf);
|
2015-12-15 01:33:09 +01:00
|
|
|
|
Cty_PutParamCtyCod (CtyCod);
|
2018-04-24 13:21:53 +02:00
|
|
|
|
Act_LinkFormSubmit (Act_GetActionTextFromDB (Act_GetActCod (ActSeeCtyInf),ActTxt),
|
2017-03-01 14:53:18 +01:00
|
|
|
|
ClassLink,NULL);
|
2015-12-15 01:33:09 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"%s</a>",CtyName);
|
2018-10-15 14:07:12 +02:00
|
|
|
|
Act_EndForm ();
|
2015-12-15 01:33:09 +01:00
|
|
|
|
}
|
2016-09-09 01:17:53 +02:00
|
|
|
|
else
|
|
|
|
|
/***** Write country name without link *****/
|
|
|
|
|
fprintf (Gbl.F.Out,"%s",CtyName);
|
2015-12-08 00:25:56 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2015-12-09 19:51:17 +01:00
|
|
|
|
/***************** Get basic data of country given its code ******************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-12-09 19:51:17 +01:00
|
|
|
|
bool Cty_GetDataOfCountryByCod (struct Country *Cty,Cty_GetExtraData_t GetExtraData)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Another_country;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
extern const char *Txt_STR_LANG_ID[1 + Txt_NUM_LANGUAGES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
char StrField[32];
|
2017-03-07 11:03:05 +01:00
|
|
|
|
char SubQueryNam1[Cty_MAX_BYTES_SUBQUERY_CTYS + 1];
|
|
|
|
|
char SubQueryNam2[Cty_MAX_BYTES_SUBQUERY_CTYS + 1];
|
|
|
|
|
char SubQueryWWW1[Cty_MAX_BYTES_SUBQUERY_CTYS + 1];
|
|
|
|
|
char SubQueryWWW2[Cty_MAX_BYTES_SUBQUERY_CTYS + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned long NumRows;
|
|
|
|
|
Txt_Language_t Lan;
|
|
|
|
|
bool CtyFound;
|
|
|
|
|
|
|
|
|
|
if (Cty->CtyCod < 0)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/***** Clear data *****/
|
2015-12-07 23:13:08 +01:00
|
|
|
|
for (Lan = (Txt_Language_t) 1;
|
|
|
|
|
Lan <= Txt_NUM_LANGUAGES;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Lan++)
|
|
|
|
|
{
|
|
|
|
|
Cty->Name[Lan][0] = '\0';
|
|
|
|
|
Cty->WWW[Lan][0] = '\0';
|
|
|
|
|
}
|
2015-12-09 19:51:17 +01:00
|
|
|
|
Cty->NumUsrsWhoClaimToBelongToCty = 0;
|
2015-12-14 12:30:24 +01:00
|
|
|
|
Cty->NumInss = Cty->NumCtrs = Cty->NumDegs = Cty->NumCrss = 0;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Cty->NumUsrs = 0;
|
|
|
|
|
|
|
|
|
|
/***** Check if country code is correct *****/
|
|
|
|
|
if (Cty->CtyCod == 0)
|
|
|
|
|
{
|
2015-12-07 23:13:08 +01:00
|
|
|
|
for (Lan = (Txt_Language_t) 1;
|
|
|
|
|
Lan <= Txt_NUM_LANGUAGES;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Lan++)
|
|
|
|
|
if (Lan == Gbl.Prefs.Language)
|
2017-01-15 18:02:52 +01:00
|
|
|
|
Str_Copy (Cty->Name[Lan],Txt_Another_country,
|
2017-03-10 02:40:01 +01:00
|
|
|
|
Cty_MAX_BYTES_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
|
|
|
|
Cty->Name[Lan][0] = '\0';
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-09 19:51:17 +01:00
|
|
|
|
// Here Cty->CtyCod > 0
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get data of a country from database *****/
|
2015-12-09 19:51:17 +01:00
|
|
|
|
switch (GetExtraData)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2015-12-09 19:51:17 +01:00
|
|
|
|
case Cty_GET_BASIC_DATA:
|
2018-10-25 11:26:44 +02:00
|
|
|
|
DB_BuildQuery ("SELECT Alpha2,Name_%s,WWW_%s"
|
|
|
|
|
" FROM countries"
|
|
|
|
|
" WHERE CtyCod='%03ld'",
|
|
|
|
|
Txt_STR_LANG_ID[Gbl.Prefs.Language],
|
|
|
|
|
Txt_STR_LANG_ID[Gbl.Prefs.Language],
|
|
|
|
|
Cty->CtyCod);
|
2015-12-09 19:51:17 +01:00
|
|
|
|
break;
|
|
|
|
|
case Cty_GET_EXTRA_DATA:
|
|
|
|
|
SubQueryNam1[0] = '\0';
|
|
|
|
|
SubQueryNam2[0] = '\0';
|
|
|
|
|
SubQueryWWW1[0] = '\0';
|
|
|
|
|
SubQueryWWW2[0] = '\0';
|
|
|
|
|
for (Lan = (Txt_Language_t) 1;
|
|
|
|
|
Lan <= Txt_NUM_LANGUAGES;
|
|
|
|
|
Lan++)
|
|
|
|
|
{
|
2018-10-17 10:32:18 +02:00
|
|
|
|
snprintf (StrField,sizeof (StrField),
|
|
|
|
|
"countries.Name_%s,",
|
|
|
|
|
Txt_STR_LANG_ID[Lan]);
|
2017-01-17 03:33:05 +01:00
|
|
|
|
Str_Concat (SubQueryNam1,StrField,
|
2017-03-07 11:03:05 +01:00
|
|
|
|
Cty_MAX_BYTES_SUBQUERY_CTYS);
|
2018-10-17 10:32:18 +02:00
|
|
|
|
snprintf (StrField,sizeof (StrField),
|
|
|
|
|
"Name_%s,",
|
|
|
|
|
Txt_STR_LANG_ID[Lan]);
|
2017-01-17 03:33:05 +01:00
|
|
|
|
Str_Concat (SubQueryNam2,StrField,
|
2017-03-07 11:03:05 +01:00
|
|
|
|
Cty_MAX_BYTES_SUBQUERY_CTYS);
|
2015-12-09 19:51:17 +01:00
|
|
|
|
|
2018-10-17 10:32:18 +02:00
|
|
|
|
snprintf (StrField,sizeof (StrField),
|
|
|
|
|
"countries.WWW_%s,",
|
|
|
|
|
Txt_STR_LANG_ID[Lan]);
|
2017-01-17 03:33:05 +01:00
|
|
|
|
Str_Concat (SubQueryWWW1,StrField,
|
2017-03-07 11:03:05 +01:00
|
|
|
|
Cty_MAX_BYTES_SUBQUERY_CTYS);
|
2018-10-17 10:32:18 +02:00
|
|
|
|
snprintf (StrField,sizeof (StrField),
|
|
|
|
|
"WWW_%s,",
|
|
|
|
|
Txt_STR_LANG_ID[Lan]);
|
2017-01-17 03:33:05 +01:00
|
|
|
|
Str_Concat (SubQueryWWW2,StrField,
|
2017-03-07 11:03:05 +01:00
|
|
|
|
Cty_MAX_BYTES_SUBQUERY_CTYS);
|
2015-12-09 19:51:17 +01:00
|
|
|
|
}
|
2018-10-25 11:26:44 +02:00
|
|
|
|
DB_BuildQuery ("(SELECT countries.Alpha2,%s%sCOUNT(*) AS NumUsrs"
|
|
|
|
|
" FROM countries,usr_data"
|
|
|
|
|
" WHERE countries.CtyCod='%03ld'"
|
|
|
|
|
" AND countries.CtyCod=usr_data.CtyCod)"
|
|
|
|
|
" UNION "
|
|
|
|
|
"(SELECT Alpha2,%s%s0 AS NumUsrs"
|
|
|
|
|
" FROM countries"
|
|
|
|
|
" WHERE CtyCod='%03ld'"
|
|
|
|
|
" AND CtyCod NOT IN"
|
|
|
|
|
" (SELECT DISTINCT CtyCod FROM usr_data))",
|
|
|
|
|
SubQueryNam1,SubQueryWWW1,Cty->CtyCod,
|
|
|
|
|
SubQueryNam2,SubQueryWWW2,Cty->CtyCod);
|
2015-12-09 19:51:17 +01:00
|
|
|
|
break;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2015-12-09 19:51:17 +01:00
|
|
|
|
|
2018-10-25 11:26:44 +02:00
|
|
|
|
NumRows = DB_QuerySELECT_new (&mysql_res,"can not get data of a country");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Count number of rows in result *****/
|
|
|
|
|
if (NumRows) // Country found...
|
|
|
|
|
{
|
|
|
|
|
CtyFound = true;
|
|
|
|
|
|
|
|
|
|
/* Get row */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/* Get Alpha-2 country code (row[0]) */
|
2017-01-17 03:10:43 +01:00
|
|
|
|
Str_Copy (Cty->Alpha2,row[0],
|
|
|
|
|
2);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2015-12-09 19:51:17 +01:00
|
|
|
|
switch (GetExtraData)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2015-12-09 19:51:17 +01:00
|
|
|
|
case Cty_GET_BASIC_DATA:
|
2016-11-13 16:19:18 +01:00
|
|
|
|
/* Get name and WWW of the country in current language */
|
2017-01-15 18:02:52 +01:00
|
|
|
|
Str_Copy (Cty->Name[Gbl.Prefs.Language],row[1],
|
2017-03-10 02:40:01 +01:00
|
|
|
|
Cty_MAX_BYTES_NAME);
|
2017-01-17 03:10:43 +01:00
|
|
|
|
Str_Copy (Cty->WWW[Gbl.Prefs.Language],row[2],
|
2017-03-07 01:56:41 +01:00
|
|
|
|
Cns_MAX_BYTES_WWW);
|
2015-12-09 19:51:17 +01:00
|
|
|
|
break;
|
|
|
|
|
case Cty_GET_EXTRA_DATA:
|
2016-11-13 16:19:18 +01:00
|
|
|
|
/* Get name and WWW of the country in several languages */
|
2015-12-09 19:51:17 +01:00
|
|
|
|
for (Lan = (Txt_Language_t) 1;
|
|
|
|
|
Lan <= Txt_NUM_LANGUAGES;
|
|
|
|
|
Lan++)
|
|
|
|
|
{
|
2017-01-15 18:02:52 +01:00
|
|
|
|
Str_Copy (Cty->Name[Lan],row[Lan],
|
2017-03-10 02:40:01 +01:00
|
|
|
|
Cty_MAX_BYTES_NAME);
|
2017-01-15 18:02:52 +01:00
|
|
|
|
Str_Copy (Cty->WWW[Lan],row[Txt_NUM_LANGUAGES + Lan],
|
2017-03-07 01:56:41 +01:00
|
|
|
|
Cns_MAX_BYTES_WWW);
|
2015-12-09 19:51:17 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Get number of users who claim to belong to this country */
|
2017-01-28 15:58:46 +01:00
|
|
|
|
if (sscanf (row[Txt_NUM_LANGUAGES * 2 + 1],"%u",
|
|
|
|
|
&Cty->NumUsrsWhoClaimToBelongToCty) != 1)
|
2015-12-09 19:51:17 +01:00
|
|
|
|
Cty->NumUsrsWhoClaimToBelongToCty = 0;
|
|
|
|
|
|
|
|
|
|
/* Get number of user in courses of this institution */
|
2017-05-18 19:13:41 +02:00
|
|
|
|
Cty->NumUsrs = Usr_GetNumUsrsInCrssOfCty (Rol_UNK,Cty->CtyCod); // Here Rol_UNK means "all users"
|
2015-12-09 19:51:17 +01:00
|
|
|
|
|
|
|
|
|
/* Get number of institutions in this country */
|
|
|
|
|
Cty->NumInss = Ins_GetNumInssInCty (Cty->CtyCod);
|
|
|
|
|
|
|
|
|
|
break;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
CtyFound = false;
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
return CtyFound;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Get country name ******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-06-20 14:43:26 +02:00
|
|
|
|
void Cty_FlushCacheCountryName (void)
|
|
|
|
|
{
|
|
|
|
|
Gbl.Cache.CountryName.CtyCod = -1L;
|
|
|
|
|
Gbl.Cache.CountryName.CtyName[0] = '\0';
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-10 02:40:01 +01:00
|
|
|
|
void Cty_GetCountryName (long CtyCod,char CtyName[Cty_MAX_BYTES_NAME + 1])
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-01-28 15:58:46 +01:00
|
|
|
|
extern const char *Txt_STR_LANG_ID[1 + Txt_NUM_LANGUAGES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
|
2017-06-20 14:43:26 +02:00
|
|
|
|
/***** 1. Fast check: Trivial case *****/
|
2017-03-01 15:23:30 +01:00
|
|
|
|
if (CtyCod <= 0)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-06-20 14:43:26 +02:00
|
|
|
|
CtyName[0] = '\0'; // Empty name
|
|
|
|
|
return;
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-06-20 14:43:26 +02:00
|
|
|
|
/***** 2. Fast check: If cached... *****/
|
|
|
|
|
if (CtyCod == Gbl.Cache.CountryName.CtyCod)
|
|
|
|
|
{
|
|
|
|
|
Str_Copy (CtyName,Gbl.Cache.CountryName.CtyName,
|
|
|
|
|
Cty_MAX_BYTES_NAME);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2017-03-01 15:23:30 +01:00
|
|
|
|
|
2017-06-20 14:43:26 +02:00
|
|
|
|
/***** 3. Slow: get country name from database *****/
|
|
|
|
|
Gbl.Cache.CountryName.CtyCod = CtyCod;
|
2017-03-01 15:23:30 +01:00
|
|
|
|
|
2018-10-25 11:26:44 +02:00
|
|
|
|
DB_BuildQuery ("SELECT Name_%s FROM countries WHERE CtyCod='%03ld'",
|
|
|
|
|
Txt_STR_LANG_ID[Gbl.Prefs.Language],CtyCod);
|
|
|
|
|
if (DB_QuerySELECT_new (&mysql_res,"can not get the name of a country")) // Country found...
|
2017-06-20 14:43:26 +02:00
|
|
|
|
{
|
|
|
|
|
/* Get row */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-06-20 14:43:26 +02:00
|
|
|
|
/* Get the name of the country */
|
|
|
|
|
Str_Copy (Gbl.Cache.CountryName.CtyName,row[0],
|
2017-03-10 02:40:01 +01:00
|
|
|
|
Cty_MAX_BYTES_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2017-06-20 14:43:26 +02:00
|
|
|
|
else
|
|
|
|
|
Gbl.Cache.CountryName.CtyName[0] = '\0';
|
|
|
|
|
|
|
|
|
|
/* Free structure that stores the query result */
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
Str_Copy (CtyName,Gbl.Cache.CountryName.CtyName,
|
|
|
|
|
Cty_MAX_BYTES_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Get map attribution from database **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Cty_GetMapAttribution (long CtyCod,char **MapAttribution)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2017-01-13 01:51:23 +01:00
|
|
|
|
size_t Length;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free possible former map attribution *****/
|
|
|
|
|
Cty_FreeMapAttribution (MapAttribution);
|
|
|
|
|
|
|
|
|
|
/***** Get photo attribution from database *****/
|
2018-10-25 11:26:44 +02:00
|
|
|
|
DB_BuildQuery ("SELECT MapAttribution FROM countries WHERE CtyCod=%ld",
|
|
|
|
|
CtyCod);
|
|
|
|
|
if (DB_QuerySELECT_new (&mysql_res,"can not get photo attribution"))
|
2014-12-01 23:55:08 +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])
|
|
|
|
|
{
|
2017-01-13 01:51:23 +01:00
|
|
|
|
Length = strlen (row[0]);
|
|
|
|
|
if (((*MapAttribution) = (char *) malloc (Length + 1)) == NULL)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Lay_ShowErrorAndExit ("Error allocating memory for map attribution.");
|
2017-01-17 03:10:43 +01:00
|
|
|
|
Str_Copy (*MapAttribution,row[0],
|
|
|
|
|
Length);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Free memory used for map attribution ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Cty_FreeMapAttribution (char **MapAttribution)
|
|
|
|
|
{
|
|
|
|
|
if (*MapAttribution)
|
|
|
|
|
{
|
|
|
|
|
free ((void *) *MapAttribution);
|
|
|
|
|
*MapAttribution = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************************** Free list of countries **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Cty_FreeListCountries (void)
|
|
|
|
|
{
|
|
|
|
|
if (Gbl.Ctys.Lst)
|
|
|
|
|
{
|
|
|
|
|
/***** Free memory used by the list of courses in institution *****/
|
|
|
|
|
free ((void *) Gbl.Ctys.Lst);
|
|
|
|
|
Gbl.Ctys.Lst = NULL;
|
|
|
|
|
Gbl.Ctys.Num = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************************** List all the countries **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Cty_ListCountriesForEdition (void)
|
|
|
|
|
{
|
2017-01-28 15:58:46 +01:00
|
|
|
|
extern const char *Txt_STR_LANG_NAME[1 + Txt_NUM_LANGUAGES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned NumCty;
|
|
|
|
|
struct Country *Cty;
|
|
|
|
|
Txt_Language_t Lan;
|
|
|
|
|
|
2017-04-30 20:20:25 +02:00
|
|
|
|
/***** Write heading *****/
|
2017-06-11 20:09:59 +02:00
|
|
|
|
Tbl_StartTableWide (2);
|
2017-02-28 00:59:01 +01:00
|
|
|
|
Cty_PutHeadCountriesForEdition ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write all the countries *****/
|
|
|
|
|
for (NumCty = 0;
|
|
|
|
|
NumCty < Gbl.Ctys.Num;
|
|
|
|
|
NumCty++)
|
|
|
|
|
{
|
|
|
|
|
Cty = &Gbl.Ctys.Lst[NumCty];
|
|
|
|
|
|
|
|
|
|
/* Put icon to remove country */
|
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2014-12-22 14:08:19 +01:00
|
|
|
|
"<td rowspan=\"%u\" class=\"BT\">",
|
|
|
|
|
1 + Txt_NUM_LANGUAGES);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (Cty->NumInss ||
|
2015-12-09 19:51:17 +01:00
|
|
|
|
Cty->NumUsrsWhoClaimToBelongToCty ||
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Cty->NumUsrs) // Country has institutions or users ==> deletion forbidden
|
2017-06-11 19:13:28 +02:00
|
|
|
|
Ico_PutIconRemovalNotAllowed ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
2018-10-15 14:07:12 +02:00
|
|
|
|
Act_StartForm (ActRemCty);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Cty_PutParamOtherCtyCod (Cty->CtyCod);
|
2017-06-11 19:13:28 +02:00
|
|
|
|
Ico_PutIconRemove ();
|
2018-10-15 14:07:12 +02:00
|
|
|
|
Act_EndForm ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
fprintf (Gbl.F.Out,"</td>");
|
|
|
|
|
|
|
|
|
|
/* Numerical country code (ISO 3166-1) */
|
2015-07-28 11:05:10 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<td rowspan=\"%u\" class=\"DAT RIGHT_TOP\">"
|
2014-12-22 14:08:19 +01:00
|
|
|
|
"%03ld"
|
|
|
|
|
"</td>",
|
|
|
|
|
1 + Txt_NUM_LANGUAGES,Cty->CtyCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Alphabetic country code with 2 letters (ISO 3166-1) */
|
2015-07-28 11:05:10 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<td rowspan=\"%u\" class=\"DAT RIGHT_TOP\">"
|
2014-12-22 14:08:19 +01:00
|
|
|
|
"%s"
|
|
|
|
|
"</td>",
|
|
|
|
|
1 + Txt_NUM_LANGUAGES,Cty->Alpha2);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
fprintf (Gbl.F.Out,"<td></td>"
|
|
|
|
|
"<td></td>"
|
|
|
|
|
"<td></td>");
|
|
|
|
|
|
|
|
|
|
/* Number of users */
|
2015-07-28 11:05:10 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<td rowspan=\"%u\" class=\"DAT RIGHT_TOP\">"
|
2014-12-22 14:08:19 +01:00
|
|
|
|
"%u"
|
|
|
|
|
"</td>",
|
2015-12-09 19:51:17 +01:00
|
|
|
|
1 + Txt_NUM_LANGUAGES,Cty->NumUsrsWhoClaimToBelongToCty);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Number of institutions */
|
2015-07-28 11:05:10 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<td rowspan=\"%u\" class=\"DAT RIGHT_TOP\">"
|
2014-12-22 14:08:19 +01:00
|
|
|
|
"%u"
|
|
|
|
|
"</td>"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"</tr>",
|
2014-12-22 14:08:19 +01:00
|
|
|
|
1 + Txt_NUM_LANGUAGES,Cty->NumInss);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Country name in several languages */
|
2015-12-07 23:13:08 +01:00
|
|
|
|
for (Lan = (Txt_Language_t) 1;
|
|
|
|
|
Lan <= Txt_NUM_LANGUAGES;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Lan++)
|
|
|
|
|
{
|
|
|
|
|
/* Language */
|
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2015-07-28 11:05:10 +02:00
|
|
|
|
"<td class=\"DAT RIGHT_MIDDLE\">"
|
2014-12-22 14:08:19 +01:00
|
|
|
|
"%s:"
|
|
|
|
|
"</td>",
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Txt_STR_LANG_NAME[Lan]);
|
|
|
|
|
|
|
|
|
|
/* Name */
|
2015-07-28 11:05:10 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<td class=\"LEFT_TOP\">");
|
2018-10-15 14:07:12 +02:00
|
|
|
|
Act_StartForm (ActRenCty);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Cty_PutParamOtherCtyCod (Cty->CtyCod);
|
|
|
|
|
Par_PutHiddenParamUnsigned ("Lan",(unsigned) Lan);
|
2015-10-22 14:49:48 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<input type=\"text\" name=\"Name\""
|
|
|
|
|
" size=\"15\" maxlength=\"%u\" value=\"%s\""
|
|
|
|
|
" onchange=\"document.getElementById('%s').submit();\" />",
|
2017-03-10 02:40:01 +01:00
|
|
|
|
Cty_MAX_CHARS_NAME,
|
2016-01-14 10:31:09 +01:00
|
|
|
|
Cty->Name[Lan],Gbl.Form.Id);
|
2018-10-15 14:07:12 +02:00
|
|
|
|
Act_EndForm ();
|
2015-03-13 00:16:02 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</td>");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* WWW */
|
2015-07-28 11:05:10 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<td class=\"LEFT_TOP\">");
|
2018-10-15 14:07:12 +02:00
|
|
|
|
Act_StartForm (ActChgCtyWWW);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Cty_PutParamOtherCtyCod (Cty->CtyCod);
|
|
|
|
|
Par_PutHiddenParamUnsigned ("Lan",(unsigned) Lan);
|
2016-11-20 14:32:15 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<input type=\"url\" name=\"WWW\""
|
2015-12-05 21:15:30 +01:00
|
|
|
|
" maxlength=\"%u\" value=\"%s\""
|
|
|
|
|
" class=\"INPUT_WWW\""
|
2015-10-22 14:49:48 +02:00
|
|
|
|
" onchange=\"document.getElementById('%s').submit();\" />",
|
2017-03-07 01:56:41 +01:00
|
|
|
|
Cns_MAX_CHARS_WWW,
|
2016-01-14 10:31:09 +01:00
|
|
|
|
Cty->WWW[Lan],Gbl.Form.Id);
|
2018-10-15 14:07:12 +02:00
|
|
|
|
Act_EndForm ();
|
2015-03-13 00:16:02 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</td>"
|
|
|
|
|
"</tr>");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-30 20:20:25 +02:00
|
|
|
|
/***** End table *****/
|
2017-06-11 20:09:59 +02:00
|
|
|
|
Tbl_EndTable ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Write parameter with code of country *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Cty_PutParamCtyCod (long CtyCod)
|
|
|
|
|
{
|
2015-03-07 21:08:44 +01:00
|
|
|
|
Par_PutHiddenParamLong ("cty",CtyCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Write parameter with code of country *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Cty_PutParamOtherCtyCod (long CtyCod)
|
|
|
|
|
{
|
|
|
|
|
Par_PutHiddenParamLong ("OthCtyCod",CtyCod);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Get parameter with code of country **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-05-31 21:05:59 +02:00
|
|
|
|
long Cty_GetAndCheckParamOtherCtyCod (long MinCodAllowed)
|
2016-10-23 19:40:14 +02:00
|
|
|
|
{
|
|
|
|
|
long CtyCod;
|
|
|
|
|
|
|
|
|
|
/***** Get and check parameter with code of country *****/
|
2017-05-31 21:05:59 +02:00
|
|
|
|
if ((CtyCod = Cty_GetParamOtherCtyCod ()) < MinCodAllowed)
|
|
|
|
|
Lay_ShowErrorAndExit ("Code of country is missing or invalid.");
|
2016-10-23 19:40:14 +02:00
|
|
|
|
|
|
|
|
|
return CtyCod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static long Cty_GetParamOtherCtyCod (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-01-28 20:32:50 +01:00
|
|
|
|
/***** Get code of country *****/
|
|
|
|
|
return Par_GetParToLong ("OthCtyCod");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************************** Remove a country *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Cty_RemoveCountry (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_You_can_not_remove_a_country_with_institutions_or_users;
|
|
|
|
|
extern const char *Txt_Country_X_removed;
|
2018-10-20 01:07:58 +02:00
|
|
|
|
char *Query;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
struct Country Cty;
|
|
|
|
|
|
|
|
|
|
/***** Get country code *****/
|
2017-05-31 21:05:59 +02:00
|
|
|
|
Cty.CtyCod = Cty_GetAndCheckParamOtherCtyCod (0);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get data of the country from database *****/
|
2015-12-09 19:51:17 +01:00
|
|
|
|
Cty_GetDataOfCountryByCod (&Cty,Cty_GET_EXTRA_DATA);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Check if this country has users *****/
|
2015-12-09 19:51:17 +01:00
|
|
|
|
if (Cty.NumInss ||
|
|
|
|
|
Cty.NumUsrsWhoClaimToBelongToCty ||
|
|
|
|
|
Cty.NumUsrs) // Country has institutions or users ==> don't remove
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_You_can_not_remove_a_country_with_institutions_or_users);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else // Country has no users ==> remove it
|
|
|
|
|
{
|
2016-10-28 00:30:18 +02:00
|
|
|
|
/***** Remove surveys of the country *****/
|
|
|
|
|
Svy_RemoveSurveys (Sco_SCOPE_CTY,Cty.CtyCod);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Remove country *****/
|
2018-10-20 01:07:58 +02:00
|
|
|
|
if (asprintf (&Query,"DELETE FROM countries WHERE CtyCod='%03ld'",
|
|
|
|
|
Cty.CtyCod) < 0)
|
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
|
|
|
|
DB_QueryDELETE_free (Query,"can not remove a country");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-06-20 14:43:26 +02:00
|
|
|
|
/***** Flush cache *****/
|
|
|
|
|
Cty_FlushCacheCountryName ();
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Write message to show the change made *****/
|
2018-10-16 23:08:04 +02:00
|
|
|
|
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
2018-10-16 21:56:01 +02:00
|
|
|
|
Txt_Country_X_removed,
|
|
|
|
|
Cty.Name[Gbl.Prefs.Language]);
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Show the form again *****/
|
|
|
|
|
Cty_EditCountries ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Change the name of a country ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Cty_RenameCountry (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_You_can_not_leave_the_name_of_the_country_X_empty;
|
|
|
|
|
extern const char *Txt_The_country_X_already_exists;
|
|
|
|
|
extern const char *Txt_The_country_X_has_been_renamed_as_Y;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
extern const char *Txt_STR_LANG_ID[1 + Txt_NUM_LANGUAGES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_The_name_of_the_country_X_has_not_changed;
|
|
|
|
|
struct Country *Cty;
|
2017-03-10 02:40:01 +01:00
|
|
|
|
char NewCtyName[Cty_MAX_BYTES_NAME + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Txt_Language_t Language;
|
2017-03-10 02:40:01 +01:00
|
|
|
|
char FieldName[4 + 1 + 2 + 1]; // Example: "Name_en"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
Cty = &Gbl.Ctys.EditingCty;
|
|
|
|
|
|
2017-05-31 21:05:59 +02:00
|
|
|
|
/***** Get the code of the country *****/
|
|
|
|
|
Cty->CtyCod = Cty_GetAndCheckParamOtherCtyCod (0);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-05-31 21:05:59 +02:00
|
|
|
|
/***** Get the lenguage *****/
|
2017-05-07 18:06:34 +02:00
|
|
|
|
Language = Lan_GetParamLanguage ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-05-31 21:05:59 +02:00
|
|
|
|
/***** Get the new name for the country *****/
|
2017-03-10 02:40:01 +01:00
|
|
|
|
Par_GetParToText ("Name",NewCtyName,Cty_MAX_BYTES_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get from the database the data of the country *****/
|
2015-12-09 19:51:17 +01:00
|
|
|
|
Cty_GetDataOfCountryByCod (Cty,Cty_GET_EXTRA_DATA);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Check if new name is empty *****/
|
|
|
|
|
if (!NewCtyName[0])
|
|
|
|
|
{
|
2018-10-16 23:08:04 +02:00
|
|
|
|
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
2018-10-16 21:56:01 +02:00
|
|
|
|
Txt_You_can_not_leave_the_name_of_the_country_X_empty,
|
|
|
|
|
Cty->Name[Language]);
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/***** Check if old and new names are the same (this happens when user press enter with no changes in the form) *****/
|
|
|
|
|
if (strcmp (Cty->Name[Language],NewCtyName)) // Different names
|
2017-05-31 21:05:59 +02:00
|
|
|
|
{
|
|
|
|
|
/***** If country was in database... *****/
|
|
|
|
|
if (Cty_CheckIfCountryNameExists (Language,NewCtyName,Cty->CtyCod))
|
|
|
|
|
{
|
2018-10-16 23:08:04 +02:00
|
|
|
|
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
2018-10-16 21:56:01 +02:00
|
|
|
|
Txt_The_country_X_already_exists,
|
|
|
|
|
NewCtyName);
|
2017-05-31 21:05:59 +02:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Update the table changing old name by new name */
|
2018-10-17 10:32:18 +02:00
|
|
|
|
snprintf (FieldName,sizeof (FieldName),
|
|
|
|
|
"Name_%s",
|
|
|
|
|
Txt_STR_LANG_ID[Language]);
|
2017-05-31 21:05:59 +02:00
|
|
|
|
Cty_UpdateCtyNameDB (Cty->CtyCod,FieldName,NewCtyName);
|
|
|
|
|
|
|
|
|
|
/* Write message to show the change made */
|
2018-10-16 23:08:04 +02:00
|
|
|
|
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
2018-10-16 21:56:01 +02:00
|
|
|
|
Txt_The_country_X_has_been_renamed_as_Y,
|
|
|
|
|
Cty->Name[Language],NewCtyName);
|
2017-05-31 21:05:59 +02:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt);
|
|
|
|
|
|
|
|
|
|
/* Update country name */
|
|
|
|
|
Str_Copy (Cty->Name[Language],NewCtyName,
|
|
|
|
|
Cty_MAX_BYTES_NAME);
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else // The same name
|
2017-05-31 21:05:59 +02:00
|
|
|
|
{
|
2018-10-16 23:08:04 +02:00
|
|
|
|
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
2018-10-16 21:56:01 +02:00
|
|
|
|
Txt_The_name_of_the_country_X_has_not_changed,
|
|
|
|
|
Cty->Name[Language]);
|
2017-05-31 21:05:59 +02:00
|
|
|
|
Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt);
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Show the form again *****/
|
|
|
|
|
Cty_EditCountries ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Check if a numeric country code exists ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static bool Cty_CheckIfNumericCountryCodeExists (long CtyCod)
|
|
|
|
|
{
|
|
|
|
|
/***** Get number of countries with a name from database *****/
|
2018-10-26 11:01:06 +02:00
|
|
|
|
DB_BuildQuery ("SELECT COUNT(*) FROM countries WHERE CtyCod='%03ld'",CtyCod);
|
|
|
|
|
return (DB_QueryCOUNT_new ("can not check if the numeric code"
|
|
|
|
|
" of a country already existed") != 0);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Check if an alphabetic country code exists ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-01-28 15:58:46 +01:00
|
|
|
|
static bool Cty_CheckIfAlpha2CountryCodeExists (const char Alpha2[2 + 1])
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Get number of countries with a name from database *****/
|
2018-10-26 11:01:06 +02:00
|
|
|
|
DB_BuildQuery ("SELECT COUNT(*) FROM countries WHERE Alpha2='%s'",Alpha2);
|
|
|
|
|
return (DB_QueryCOUNT_new ("can not check if the alphabetic code"
|
|
|
|
|
" of a country already existed") != 0);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Check if the name of country exists ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static bool Cty_CheckIfCountryNameExists (Txt_Language_t Language,const char *Name,long CtyCod)
|
|
|
|
|
{
|
2017-01-28 15:58:46 +01:00
|
|
|
|
extern const char *Txt_STR_LANG_ID[1 + Txt_NUM_LANGUAGES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get number of countries with a name from database *****/
|
2018-10-26 11:01:06 +02:00
|
|
|
|
DB_BuildQuery ("SELECT COUNT(*) FROM countries"
|
|
|
|
|
" WHERE Name_%s='%s' AND CtyCod<>'%03ld'",
|
|
|
|
|
Txt_STR_LANG_ID[Language],Name,CtyCod);
|
|
|
|
|
return (DB_QueryCOUNT_new ("can not check if the name"
|
|
|
|
|
" of a country already existed") != 0);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-10 02:40:01 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************ Update institution name in table of institutions ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Cty_UpdateCtyNameDB (long CtyCod,const char *FieldName,const char *NewCtyName)
|
|
|
|
|
{
|
|
|
|
|
/***** Update country changing old name by new name */
|
2018-10-27 22:08:01 +02:00
|
|
|
|
DB_BuildQuery ("UPDATE countries SET %s='%s' WHERE CtyCod='%03ld'",
|
|
|
|
|
FieldName,NewCtyName,CtyCod);
|
|
|
|
|
DB_QueryUPDATE_new ("can not update the name of a country");
|
2017-06-20 14:43:26 +02:00
|
|
|
|
|
|
|
|
|
/***** Flush cache *****/
|
|
|
|
|
Cty_FlushCacheCountryName ();
|
2017-03-10 02:40:01 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Change the URL of a country ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Cty_ChangeCtyWWW (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_The_new_web_address_is_X;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
extern const char *Txt_STR_LANG_ID[1 + Txt_NUM_LANGUAGES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
struct Country *Cty;
|
2017-03-07 01:56:41 +01:00
|
|
|
|
char NewWWW[Cns_MAX_BYTES_WWW + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Txt_Language_t Language;
|
|
|
|
|
|
|
|
|
|
Cty = &Gbl.Ctys.EditingCty;
|
|
|
|
|
|
2017-05-31 21:05:59 +02:00
|
|
|
|
/***** Get the code of the country *****/
|
|
|
|
|
Cty->CtyCod = Cty_GetAndCheckParamOtherCtyCod (0);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-05-31 21:05:59 +02:00
|
|
|
|
/***** Get the lenguage *****/
|
2017-05-07 18:06:34 +02:00
|
|
|
|
Language = Lan_GetParamLanguage ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-05-31 21:05:59 +02:00
|
|
|
|
/***** Get the new WWW for the country *****/
|
2017-03-10 02:40:01 +01:00
|
|
|
|
Par_GetParToText ("WWW",NewWWW,Cns_MAX_BYTES_WWW);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get from the database the data of the country *****/
|
2015-12-09 19:51:17 +01:00
|
|
|
|
Cty_GetDataOfCountryByCod (Cty,Cty_GET_EXTRA_DATA);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Update the table changing old WWW by new WWW *****/
|
2018-10-27 22:08:01 +02:00
|
|
|
|
DB_BuildQuery ("UPDATE countries SET WWW_%s='%s'"
|
|
|
|
|
" WHERE CtyCod='%03ld'",
|
|
|
|
|
Txt_STR_LANG_ID[Language],NewWWW,Cty->CtyCod);
|
|
|
|
|
DB_QueryUPDATE_new ("can not update the web of a country");
|
2017-05-31 21:05:59 +02:00
|
|
|
|
Str_Copy (Cty->WWW[Language],NewWWW,
|
|
|
|
|
Cns_MAX_BYTES_WWW);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write message to show the change made *****/
|
2018-10-16 23:08:04 +02:00
|
|
|
|
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
2018-10-16 21:56:01 +02:00
|
|
|
|
Txt_The_new_web_address_is_X,
|
|
|
|
|
NewWWW);
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Show the form again *****/
|
|
|
|
|
Cty_EditCountries ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********** Change the attribution of the map of current country ************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Cty_ChangeCtyMapAttribution (void)
|
|
|
|
|
{
|
2017-03-08 14:12:33 +01:00
|
|
|
|
char NewMapAttribution[Img_MAX_BYTES_ATTRIBUTION + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get parameters from form *****/
|
|
|
|
|
/* Get the new map attribution for the country */
|
2017-03-08 14:12:33 +01:00
|
|
|
|
Par_GetParToText ("Attribution",NewMapAttribution,Img_MAX_BYTES_ATTRIBUTION);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Update the table changing old attribution by new attribution *****/
|
2018-10-27 22:08:01 +02:00
|
|
|
|
DB_BuildQuery ("UPDATE countries SET MapAttribution='%s'"
|
|
|
|
|
" WHERE CtyCod='%03ld'",
|
|
|
|
|
NewMapAttribution,Gbl.CurrentCty.Cty.CtyCod);
|
|
|
|
|
DB_QueryUPDATE_new ("can not update the map attribution of a country");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Show the country information again *****/
|
|
|
|
|
Cty_ShowConfiguration ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Put a form to create a new country ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Cty_PutFormToCreateCountry (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_New_country;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
extern const char *Txt_STR_LANG_NAME[1 + Txt_NUM_LANGUAGES];
|
|
|
|
|
extern const char *Txt_STR_LANG_ID[1 + Txt_NUM_LANGUAGES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Create_country;
|
|
|
|
|
struct Country *Cty;
|
|
|
|
|
Txt_Language_t Lan;
|
|
|
|
|
|
2017-04-30 20:20:25 +02:00
|
|
|
|
/***** Country data *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Cty = &Gbl.Ctys.EditingCty;
|
|
|
|
|
|
|
|
|
|
/***** Start form *****/
|
2018-10-15 14:07:12 +02:00
|
|
|
|
Act_StartForm (ActNewCty);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** Start box and table *****/
|
2017-06-10 21:38:10 +02:00
|
|
|
|
Box_StartBoxTable (NULL,Txt_New_country,NULL,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
NULL,Box_NOT_CLOSABLE,2);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write heading *****/
|
2017-02-28 00:59:01 +01:00
|
|
|
|
Cty_PutHeadCountriesForEdition ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-04-30 20:20:25 +02:00
|
|
|
|
/***** Column to remove country, disabled here *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2014-12-22 14:08:19 +01:00
|
|
|
|
"<td rowspan=\"%u\" class=\"BT\"></td>",
|
|
|
|
|
1 + Txt_NUM_LANGUAGES);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Numerical country code (ISO 3166-1) *****/
|
2015-07-28 11:05:10 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<td rowspan=\"%u\" class=\"RIGHT_TOP\">"
|
2015-10-23 01:31:08 +02:00
|
|
|
|
"<input type=\"text\" name=\"OthCtyCod\""
|
|
|
|
|
" size=\"3\" maxlength=\"10\" value=\"",
|
2014-12-22 14:08:19 +01:00
|
|
|
|
1 + Txt_NUM_LANGUAGES);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (Cty->CtyCod > 0)
|
|
|
|
|
fprintf (Gbl.F.Out,"%03ld",Cty->CtyCod);
|
2016-11-19 02:37:09 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"\" required=\"required\" />"
|
|
|
|
|
"</td>");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Alphabetic country code with 2 letters (ISO 3166-1) *****/
|
2015-07-28 11:05:10 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<td rowspan=\"%u\" class=\"RIGHT_TOP\">"
|
2015-10-23 01:31:08 +02:00
|
|
|
|
"<input type=\"text\" name=\"Alpha2\""
|
2016-11-19 02:37:09 +01:00
|
|
|
|
" size=\"2\" maxlength=\"2\" value=\"%s\""
|
|
|
|
|
" required=\"required\" />"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"</td>",
|
2014-12-22 14:08:19 +01:00
|
|
|
|
1 + Txt_NUM_LANGUAGES,Cty->Alpha2);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
fprintf (Gbl.F.Out,"<td></td>"
|
|
|
|
|
"<td></td>"
|
|
|
|
|
"<td></td>");
|
|
|
|
|
|
|
|
|
|
/* Number of users */
|
2015-07-28 11:05:10 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<td rowspan=\"%u\" class=\"DAT RIGHT_TOP\">"
|
2014-12-22 14:08:19 +01:00
|
|
|
|
"0"
|
|
|
|
|
"</td>",
|
|
|
|
|
1 + Txt_NUM_LANGUAGES);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Number of institutions */
|
2015-07-28 11:05:10 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<td rowspan=\"%u\" class=\"DAT RIGHT_TOP\">"
|
2014-12-22 14:08:19 +01:00
|
|
|
|
"0"
|
|
|
|
|
"</td>"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"</tr>",
|
2014-12-22 14:08:19 +01:00
|
|
|
|
1 + Txt_NUM_LANGUAGES);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Country name in several languages *****/
|
2015-12-07 23:13:08 +01:00
|
|
|
|
for (Lan = (Txt_Language_t) 1;
|
|
|
|
|
Lan <= Txt_NUM_LANGUAGES;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Lan++)
|
|
|
|
|
{
|
|
|
|
|
/* Language */
|
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2015-07-28 11:05:10 +02:00
|
|
|
|
"<td class=\"DAT RIGHT_TOP\">"
|
2014-12-22 14:08:19 +01:00
|
|
|
|
"%s"
|
|
|
|
|
"</td>",
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Txt_STR_LANG_NAME[Lan]);
|
|
|
|
|
|
|
|
|
|
/* Name */
|
2015-07-28 11:05:10 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<td class=\"LEFT_MIDDLE\">"
|
2015-10-23 01:31:08 +02:00
|
|
|
|
"<input type=\"text\" name=\"Name_%s\""
|
2016-11-19 02:37:09 +01:00
|
|
|
|
" size=\"15\" maxlength=\"%u\" value=\"%s\""
|
|
|
|
|
" required=\"required\" />"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"</td>",
|
2015-12-07 23:13:08 +01:00
|
|
|
|
Txt_STR_LANG_ID[Lan],
|
2017-03-10 02:40:01 +01:00
|
|
|
|
Cty_MAX_CHARS_NAME,
|
2015-12-07 23:13:08 +01:00
|
|
|
|
Cty->Name[Lan]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* WWW */
|
2015-07-28 11:05:10 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<td class=\"LEFT_MIDDLE\">"
|
2016-11-20 14:32:15 +01:00
|
|
|
|
"<input type=\"url\" name=\"WWW_%s\""
|
2015-12-05 21:15:30 +01:00
|
|
|
|
" maxlength=\"%u\" value=\"%s\""
|
|
|
|
|
" class=\"INPUT_WWW\" />"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"</td>"
|
|
|
|
|
"</tr>",
|
2015-12-07 23:13:08 +01:00
|
|
|
|
Txt_STR_LANG_ID[Lan],
|
2017-03-07 01:56:41 +01:00
|
|
|
|
Cns_MAX_CHARS_WWW,
|
2015-12-07 23:13:08 +01:00
|
|
|
|
Cty->WWW[Lan]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End table, send button and end box *****/
|
2017-06-11 19:02:40 +02:00
|
|
|
|
Box_EndBoxTableWithButton (Btn_CREATE_BUTTON,Txt_Create_country);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End form *****/
|
2018-10-15 14:07:12 +02:00
|
|
|
|
Act_EndForm ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Write header with fields of a country *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-02-28 00:59:01 +01:00
|
|
|
|
static void Cty_PutHeadCountriesForEdition (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Numeric_BR_code_BR_ISO_3166_1;
|
|
|
|
|
extern const char *Txt_Alphabetic_BR_code_BR_ISO_3166_1;
|
|
|
|
|
extern const char *Txt_Name;
|
|
|
|
|
extern const char *Txt_WWW;
|
|
|
|
|
extern const char *Txt_Users;
|
2015-12-09 19:51:17 +01:00
|
|
|
|
extern const char *Txt_Institutions_ABBREVIATION;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
|
|
|
|
"<th class=\"BM\"></th>"
|
2015-09-06 20:02:14 +02:00
|
|
|
|
"<th class=\"RIGHT_MIDDLE\">"
|
2014-12-26 22:11:03 +01:00
|
|
|
|
"%s"
|
|
|
|
|
"</th>"
|
2015-09-06 20:02:14 +02:00
|
|
|
|
"<th class=\"RIGHT_MIDDLE\">"
|
2014-12-26 22:11:03 +01:00
|
|
|
|
"%s"
|
|
|
|
|
"</th>"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"<th></th>"
|
2015-09-06 20:02:14 +02:00
|
|
|
|
"<th class=\"LEFT_MIDDLE\">"
|
2014-12-26 22:11:03 +01:00
|
|
|
|
"%s"
|
|
|
|
|
"</th>"
|
2015-09-06 20:02:14 +02:00
|
|
|
|
"<th class=\"LEFT_MIDDLE\">"
|
2014-12-26 22:11:03 +01:00
|
|
|
|
"%s"
|
|
|
|
|
"</th>"
|
2015-09-06 20:02:14 +02:00
|
|
|
|
"<th class=\"RIGHT_MIDDLE\">"
|
2014-12-26 22:11:03 +01:00
|
|
|
|
"%s"
|
|
|
|
|
"</th>"
|
2015-09-06 20:02:14 +02:00
|
|
|
|
"<th class=\"RIGHT_MIDDLE\">"
|
2014-12-26 22:11:03 +01:00
|
|
|
|
"%s"
|
|
|
|
|
"</th>"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"</tr>",
|
|
|
|
|
Txt_Numeric_BR_code_BR_ISO_3166_1,
|
|
|
|
|
Txt_Alphabetic_BR_code_BR_ISO_3166_1,
|
|
|
|
|
Txt_Name,
|
|
|
|
|
Txt_WWW,
|
|
|
|
|
Txt_Users,
|
2015-12-09 19:51:17 +01:00
|
|
|
|
Txt_Institutions_ABBREVIATION);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Receive form to create a new country ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Cty_RecFormNewCountry (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_You_must_specify_the_numerical_code_of_the_new_country;
|
|
|
|
|
extern const char *Txt_The_numerical_code_X_already_exists;
|
|
|
|
|
extern const char *Txt_The_alphabetical_code_X_is_not_correct;
|
|
|
|
|
extern const char *Txt_The_alphabetical_code_X_already_exists;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
extern const char *Txt_STR_LANG_ID[1 + Txt_NUM_LANGUAGES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_The_country_X_already_exists;
|
|
|
|
|
extern const char *Txt_You_must_specify_the_name_of_the_new_country_in_all_languages;
|
|
|
|
|
char ParamName[32];
|
|
|
|
|
struct Country *Cty;
|
|
|
|
|
bool CreateCountry = true;
|
|
|
|
|
Txt_Language_t Lan;
|
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
|
|
Cty = &Gbl.Ctys.EditingCty;
|
|
|
|
|
|
|
|
|
|
/***** Get parameters from form *****/
|
|
|
|
|
/* Get numeric country code */
|
|
|
|
|
if ((Cty->CtyCod = Cty_GetParamOtherCtyCod ()) < 0)
|
|
|
|
|
{
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_You_must_specify_the_numerical_code_of_the_new_country);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
CreateCountry = false;
|
|
|
|
|
}
|
|
|
|
|
else if (Cty_CheckIfNumericCountryCodeExists (Cty->CtyCod))
|
|
|
|
|
{
|
2018-10-16 23:08:04 +02:00
|
|
|
|
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
2018-10-16 21:56:01 +02:00
|
|
|
|
Txt_The_numerical_code_X_already_exists,
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Cty->CtyCod);
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
CreateCountry = false;
|
|
|
|
|
}
|
|
|
|
|
else // Numeric code correct
|
|
|
|
|
{
|
|
|
|
|
/* Get alphabetic-2 country code */
|
|
|
|
|
Par_GetParToText ("Alpha2",Cty->Alpha2,2);
|
|
|
|
|
Str_ConvertToUpperText (Cty->Alpha2);
|
|
|
|
|
for (i = 0;
|
|
|
|
|
i < 2 && CreateCountry;
|
|
|
|
|
i++)
|
|
|
|
|
if (Cty->Alpha2[i] < 'A' ||
|
|
|
|
|
Cty->Alpha2[i] > 'Z')
|
|
|
|
|
{
|
2018-10-16 23:08:04 +02:00
|
|
|
|
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
2018-10-16 21:56:01 +02:00
|
|
|
|
Txt_The_alphabetical_code_X_is_not_correct,
|
|
|
|
|
Cty->Alpha2);
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
CreateCountry = false;
|
|
|
|
|
}
|
|
|
|
|
if (CreateCountry)
|
|
|
|
|
{
|
|
|
|
|
if (Cty_CheckIfAlpha2CountryCodeExists (Cty->Alpha2))
|
|
|
|
|
{
|
2018-10-16 23:08:04 +02:00
|
|
|
|
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
2018-10-16 21:56:01 +02:00
|
|
|
|
Txt_The_alphabetical_code_X_already_exists,
|
|
|
|
|
Cty->Alpha2);
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
CreateCountry = false;
|
|
|
|
|
}
|
|
|
|
|
else // Alphabetic code correct
|
|
|
|
|
{
|
|
|
|
|
/* Get country name and WWW in different languages */
|
2015-12-07 23:13:08 +01:00
|
|
|
|
for (Lan = (Txt_Language_t) 1;
|
|
|
|
|
Lan <= Txt_NUM_LANGUAGES;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Lan++)
|
|
|
|
|
{
|
2018-10-17 10:32:18 +02:00
|
|
|
|
snprintf (ParamName,sizeof (ParamName),
|
|
|
|
|
"Name_%s",
|
|
|
|
|
Txt_STR_LANG_ID[Lan]);
|
2017-03-10 02:40:01 +01:00
|
|
|
|
Par_GetParToText (ParamName,Cty->Name[Lan],Cty_MAX_BYTES_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
if (Cty->Name[Lan][0]) // If there's a country name
|
|
|
|
|
{
|
|
|
|
|
/***** If name of country was in database... *****/
|
|
|
|
|
if (Cty_CheckIfCountryNameExists (Lan,Cty->Name[Lan],-1L))
|
|
|
|
|
{
|
2018-10-16 23:08:04 +02:00
|
|
|
|
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
2018-10-16 21:56:01 +02:00
|
|
|
|
Txt_The_country_X_already_exists,
|
|
|
|
|
Cty->Name[Lan]);
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
CreateCountry = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // If there is not a country name
|
|
|
|
|
{
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_You_must_specify_the_name_of_the_new_country_in_all_languages);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
CreateCountry = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-17 10:32:18 +02:00
|
|
|
|
snprintf (ParamName,sizeof (ParamName),
|
|
|
|
|
"WWW_%s",
|
|
|
|
|
Txt_STR_LANG_ID[Lan]);
|
2017-03-07 01:56:41 +01:00
|
|
|
|
Par_GetParToText (ParamName,Cty->WWW[Lan],Cns_MAX_BYTES_WWW);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (CreateCountry)
|
|
|
|
|
Cty_CreateCountry (Cty); // Add new country to database
|
|
|
|
|
|
|
|
|
|
/***** Show the form again *****/
|
|
|
|
|
Cty_EditCountries ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************************** Create a new country ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-03-10 02:40:01 +01:00
|
|
|
|
#define Cty_MAX_BYTES_SUBQUERY_CTYS_NAME ((1 + Txt_NUM_LANGUAGES) * Cty_MAX_BYTES_NAME)
|
2017-03-07 11:03:05 +01:00
|
|
|
|
#define Cty_MAX_BYTES_SUBQUERY_CTYS_WWW ((1 + Txt_NUM_LANGUAGES) * Cns_MAX_BYTES_WWW)
|
2017-01-16 01:51:01 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static void Cty_CreateCountry (struct Country *Cty)
|
|
|
|
|
{
|
2017-01-28 15:58:46 +01:00
|
|
|
|
extern const char *Txt_STR_LANG_ID[1 + Txt_NUM_LANGUAGES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Created_new_country_X;
|
|
|
|
|
Txt_Language_t Lan;
|
|
|
|
|
char StrField[32];
|
2017-03-07 11:03:05 +01:00
|
|
|
|
char SubQueryNam1[Cty_MAX_BYTES_SUBQUERY_CTYS + 1];
|
|
|
|
|
char SubQueryNam2[Cty_MAX_BYTES_SUBQUERY_CTYS_NAME + 1];
|
|
|
|
|
char SubQueryWWW1[Cty_MAX_BYTES_SUBQUERY_CTYS + 1];
|
|
|
|
|
char SubQueryWWW2[Cty_MAX_BYTES_SUBQUERY_CTYS_WWW + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Create a new country *****/
|
|
|
|
|
SubQueryNam1[0] = '\0';
|
|
|
|
|
SubQueryNam2[0] = '\0';
|
|
|
|
|
SubQueryWWW1[0] = '\0';
|
|
|
|
|
SubQueryWWW2[0] = '\0';
|
2015-12-07 23:13:08 +01:00
|
|
|
|
for (Lan = (Txt_Language_t) 1;
|
|
|
|
|
Lan <= Txt_NUM_LANGUAGES;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Lan++)
|
|
|
|
|
{
|
2018-10-17 10:32:18 +02:00
|
|
|
|
snprintf (StrField,sizeof (StrField),
|
|
|
|
|
",Name_%s",
|
|
|
|
|
Txt_STR_LANG_ID[Lan]);
|
2017-01-17 03:33:05 +01:00
|
|
|
|
Str_Concat (SubQueryNam1,StrField,
|
2017-03-07 11:03:05 +01:00
|
|
|
|
Cty_MAX_BYTES_SUBQUERY_CTYS);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-01-17 03:33:05 +01:00
|
|
|
|
Str_Concat (SubQueryNam2,",'",
|
2017-03-07 11:03:05 +01:00
|
|
|
|
Cty_MAX_BYTES_SUBQUERY_CTYS_NAME);
|
2017-01-17 03:33:05 +01:00
|
|
|
|
Str_Concat (SubQueryNam2,Cty->Name[Lan],
|
2017-03-07 11:03:05 +01:00
|
|
|
|
Cty_MAX_BYTES_SUBQUERY_CTYS_NAME);
|
2017-01-17 03:33:05 +01:00
|
|
|
|
Str_Concat (SubQueryNam2,"'",
|
2017-03-07 11:03:05 +01:00
|
|
|
|
Cty_MAX_BYTES_SUBQUERY_CTYS_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2018-10-17 10:32:18 +02:00
|
|
|
|
snprintf (StrField,sizeof (StrField),
|
|
|
|
|
",WWW_%s",
|
|
|
|
|
Txt_STR_LANG_ID[Lan]);
|
2017-01-17 03:33:05 +01:00
|
|
|
|
Str_Concat (SubQueryWWW1,StrField,
|
2017-03-07 11:03:05 +01:00
|
|
|
|
Cty_MAX_BYTES_SUBQUERY_CTYS);
|
2017-01-17 03:33:05 +01:00
|
|
|
|
|
|
|
|
|
Str_Concat (SubQueryWWW2,",'",
|
2017-03-07 11:03:05 +01:00
|
|
|
|
Cty_MAX_BYTES_SUBQUERY_CTYS_WWW);
|
2017-01-17 03:33:05 +01:00
|
|
|
|
Str_Concat (SubQueryWWW2,Cty->WWW[Lan],
|
2017-03-07 11:03:05 +01:00
|
|
|
|
Cty_MAX_BYTES_SUBQUERY_CTYS_WWW);
|
2017-01-17 03:33:05 +01:00
|
|
|
|
Str_Concat (SubQueryWWW2,"'",
|
2017-03-07 11:03:05 +01:00
|
|
|
|
Cty_MAX_BYTES_SUBQUERY_CTYS_WWW);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2018-10-27 14:14:34 +02:00
|
|
|
|
DB_BuildQuery ("INSERT INTO countries"
|
|
|
|
|
" (CtyCod,Alpha2%s%s)"
|
|
|
|
|
" VALUES"
|
|
|
|
|
" ('%03ld','%s'%s%s)",
|
|
|
|
|
SubQueryNam1,SubQueryWWW1,
|
|
|
|
|
Cty->CtyCod,Cty->Alpha2,SubQueryNam2,SubQueryWWW2);
|
|
|
|
|
DB_QueryINSERT_new ("can not create country");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write success message *****/
|
2018-10-16 23:08:04 +02:00
|
|
|
|
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
2018-10-16 21:56:01 +02:00
|
|
|
|
Txt_Created_new_country_X,
|
|
|
|
|
Cty->Name);
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********************** Get total number of countries ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
unsigned Cty_GetNumCtysTotal (void)
|
|
|
|
|
{
|
|
|
|
|
/***** Get total number of degrees from database *****/
|
2018-10-26 11:01:06 +02:00
|
|
|
|
DB_BuildQuery ("SELECT COUNT(*) FROM countries");
|
|
|
|
|
return (unsigned) DB_QueryCOUNT_new ("can not get the total number of countries");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Get number of countries with institutions *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
unsigned Cty_GetNumCtysWithInss (const char *SubQuery)
|
|
|
|
|
{
|
|
|
|
|
/***** Get number of countries with institutions from database *****/
|
2018-10-26 11:01:06 +02:00
|
|
|
|
DB_BuildQuery ("SELECT COUNT(DISTINCT countries.CtyCod)"
|
|
|
|
|
" FROM countries,institutions"
|
|
|
|
|
" WHERE %scountries.CtyCod=institutions.CtyCod",
|
|
|
|
|
SubQuery);
|
|
|
|
|
return (unsigned) DB_QueryCOUNT_new ("can not get number of countries with institutions");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Get number of countries with centres ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
unsigned Cty_GetNumCtysWithCtrs (const char *SubQuery)
|
|
|
|
|
{
|
|
|
|
|
/***** Get number of countries with centres from database *****/
|
2018-10-26 11:01:06 +02:00
|
|
|
|
DB_BuildQuery ("SELECT COUNT(DISTINCT countries.CtyCod)"
|
|
|
|
|
" FROM countries,institutions,centres"
|
|
|
|
|
" WHERE %scountries.CtyCod=institutions.CtyCod"
|
|
|
|
|
" AND institutions.InsCod=centres.InsCod",
|
|
|
|
|
SubQuery);
|
|
|
|
|
return (unsigned) DB_QueryCOUNT_new ("can not get number of countries with centres");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Get number of countries with degrees ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
unsigned Cty_GetNumCtysWithDegs (const char *SubQuery)
|
|
|
|
|
{
|
|
|
|
|
/***** Get number of countries with degrees from database *****/
|
2018-10-26 11:01:06 +02:00
|
|
|
|
DB_BuildQuery ("SELECT COUNT(DISTINCT countries.CtyCod)"
|
|
|
|
|
" FROM countries,institutions,centres,degrees"
|
|
|
|
|
" WHERE %scountries.CtyCod=institutions.CtyCod"
|
|
|
|
|
" AND institutions.InsCod=centres.InsCod"
|
|
|
|
|
" AND centres.CtrCod=degrees.CtrCod",
|
|
|
|
|
SubQuery);
|
|
|
|
|
return (unsigned) DB_QueryCOUNT_new ("can not get number of countries with degrees");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Get number of countries with courses ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
unsigned Cty_GetNumCtysWithCrss (const char *SubQuery)
|
|
|
|
|
{
|
|
|
|
|
/***** Get number of countries with courses from database *****/
|
2018-10-26 11:01:06 +02:00
|
|
|
|
DB_BuildQuery ("SELECT COUNT(DISTINCT countries.CtyCod)"
|
|
|
|
|
" FROM countries,institutions,centres,degrees,courses"
|
|
|
|
|
" WHERE %scountries.CtyCod=institutions.CtyCod"
|
|
|
|
|
" AND institutions.InsCod=centres.InsCod"
|
|
|
|
|
" AND centres.CtrCod=degrees.CtrCod"
|
|
|
|
|
" AND degrees.DegCod=courses.DegCod",
|
|
|
|
|
SubQuery);
|
|
|
|
|
return (unsigned) DB_QueryCOUNT_new ("can not get number of countries with courses");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Get number of countries with users **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
unsigned Cty_GetNumCtysWithUsrs (Rol_Role_t Role,const char *SubQuery)
|
|
|
|
|
{
|
|
|
|
|
/***** Get number of countries with users from database *****/
|
2018-10-26 11:01:06 +02:00
|
|
|
|
DB_BuildQuery ("SELECT COUNT(DISTINCT countries.CtyCod)"
|
|
|
|
|
" FROM countries,institutions,centres,degrees,courses,crs_usr"
|
|
|
|
|
" WHERE %scountries.CtyCod=institutions.CtyCod"
|
|
|
|
|
" AND institutions.InsCod=centres.InsCod"
|
|
|
|
|
" AND centres.CtrCod=degrees.CtrCod"
|
|
|
|
|
" AND degrees.DegCod=courses.DegCod"
|
|
|
|
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
|
|
|
|
" AND crs_usr.Role=%u",
|
|
|
|
|
SubQuery,(unsigned) Role);
|
|
|
|
|
return (unsigned) DB_QueryCOUNT_new ("can not get number of countries with users");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2017-02-28 00:59:01 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** List countries found **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
// Returns number of countries found
|
|
|
|
|
|
2018-10-25 11:26:44 +02:00
|
|
|
|
unsigned Cty_ListCtysFound (void)
|
2017-02-28 00:59:01 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_country;
|
|
|
|
|
extern const char *Txt_countries;
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumCtys;
|
|
|
|
|
unsigned NumCty;
|
|
|
|
|
struct Country Cty;
|
|
|
|
|
|
|
|
|
|
/***** Query database *****/
|
2018-10-25 11:26:44 +02:00
|
|
|
|
if ((NumCtys = (unsigned) DB_QuerySELECT_new (&mysql_res,"can not get countries")))
|
2017-02-28 00:59:01 +01:00
|
|
|
|
{
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** Start box and table *****/
|
2017-02-28 00:59:01 +01:00
|
|
|
|
/* Number of countries found */
|
2018-10-17 10:32:18 +02:00
|
|
|
|
snprintf (Gbl.Title,sizeof (Gbl.Title),
|
|
|
|
|
"%u %s",
|
|
|
|
|
NumCtys,NumCtys == 1 ? Txt_country :
|
|
|
|
|
Txt_countries);
|
2017-06-10 21:38:10 +02:00
|
|
|
|
Box_StartBoxTable (NULL,Gbl.Title,NULL,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
NULL,Box_NOT_CLOSABLE,2);
|
2017-06-12 14:16:33 +02:00
|
|
|
|
|
|
|
|
|
/***** Write heading *****/
|
2017-02-28 00:59:01 +01:00
|
|
|
|
Cty_PutHeadCountriesForSeeing (false); // Order not selectable
|
|
|
|
|
|
|
|
|
|
/***** List the countries (one row per country) *****/
|
|
|
|
|
for (NumCty = 1;
|
|
|
|
|
NumCty <= NumCtys;
|
|
|
|
|
NumCty++)
|
|
|
|
|
{
|
|
|
|
|
/* Get next country */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/* Get country code (row[0]) */
|
|
|
|
|
Cty.CtyCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
|
|
|
|
|
|
|
|
/* Get data of country */
|
|
|
|
|
Cty_GetDataOfCountryByCod (&Cty,Cty_GET_EXTRA_DATA);
|
|
|
|
|
|
|
|
|
|
/* Write data of this country */
|
|
|
|
|
Cty_ListOneCountryForSeeing (&Cty,NumCty);
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End table and box *****/
|
2017-06-10 21:38:10 +02:00
|
|
|
|
Box_EndBoxTable ();
|
2017-02-28 00:59:01 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
return NumCtys;
|
|
|
|
|
}
|