2014-12-01 23:55:08 +01:00
|
|
|
|
// swad_institution.c: institutions
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
SWAD (Shared Workspace At a Distance),
|
|
|
|
|
is a web platform developed at the University of Granada (Spain),
|
|
|
|
|
and used to support university teaching.
|
|
|
|
|
|
|
|
|
|
This file is part of SWAD core.
|
2021-02-09 12:43:45 +01:00
|
|
|
|
Copyright (C) 1999-2021 Antonio Ca<EFBFBD>as Vargas
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU Affero General Public License as
|
|
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************************* Headers ***********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-12-29 16:21:42 +01:00
|
|
|
|
#include <stdbool.h> // For boolean type
|
2019-12-29 12:39:00 +01:00
|
|
|
|
#include <stddef.h> // For NULL
|
2020-01-03 22:16:51 +01:00
|
|
|
|
#include <stdlib.h> // For free
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include <string.h> // For string functions
|
|
|
|
|
|
|
|
|
|
#include "swad_database.h"
|
2020-04-14 17:15:17 +02:00
|
|
|
|
#include "swad_department.h"
|
|
|
|
|
#include "swad_figure.h"
|
2020-05-02 13:39:59 +02:00
|
|
|
|
#include "swad_figure_cache.h"
|
2018-11-09 20:47:39 +01:00
|
|
|
|
#include "swad_form.h"
|
2020-04-14 17:15:17 +02:00
|
|
|
|
#include "swad_forum.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_global.h"
|
2021-02-11 22:57:09 +01:00
|
|
|
|
#include "swad_hierarchy.h"
|
2019-10-23 19:05:05 +02:00
|
|
|
|
#include "swad_HTML.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_institution.h"
|
2015-01-17 13:31:25 +01:00
|
|
|
|
#include "swad_logo.h"
|
2020-04-14 17:15:17 +02:00
|
|
|
|
#include "swad_message.h"
|
|
|
|
|
#include "swad_place.h"
|
|
|
|
|
#include "swad_survey.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private constants *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************************* Private types *******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private variables *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-02-11 00:58:53 +01:00
|
|
|
|
static struct Ins_Instit *Ins_EditingIns = NULL; // Static variable to keep the institution being edited
|
2019-04-06 20:43:31 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private prototypes ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-10-06 01:19:21 +02:00
|
|
|
|
static void Ins_ListInstitutions (void);
|
2016-11-07 00:03:50 +01:00
|
|
|
|
static bool Ins_CheckIfICanCreateInstitutions (void);
|
2020-04-08 18:18:46 +02:00
|
|
|
|
static void Ins_PutIconsListingInstitutions (__attribute__((unused)) void *Args);
|
2016-03-16 22:40:35 +01:00
|
|
|
|
static void Ins_PutIconToEditInstitutions (void);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
static void Ins_ListOneInstitutionForSeeing (struct Ins_Instit *Ins,unsigned NumIns);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static void Ins_PutHeadInstitutionsForSeeing (bool OrderSelectable);
|
2017-01-29 12:42:19 +01:00
|
|
|
|
static void Ins_GetParamInsOrder (void);
|
2017-03-02 00:53:34 +01:00
|
|
|
|
|
2019-04-06 20:43:31 +02:00
|
|
|
|
static void Ins_EditInstitutionsInternal (void);
|
2020-04-08 18:18:46 +02:00
|
|
|
|
static void Ins_PutIconsEditingInstitutions (__attribute__((unused)) void *Args);
|
2017-04-30 01:20:18 +02:00
|
|
|
|
static void Ins_PutIconToViewInstitutions (void);
|
|
|
|
|
|
2021-02-11 00:58:53 +01:00
|
|
|
|
static void Ins_GetDataOfInstitFromRow (struct Ins_Instit *Ins,MYSQL_ROW row);
|
2020-01-07 22:07:06 +01:00
|
|
|
|
|
2021-02-11 00:58:53 +01:00
|
|
|
|
static void Ins_GetShrtNameAndCtyOfInstitution (struct Ins_Instit *Ins,
|
2021-02-11 22:57:09 +01:00
|
|
|
|
char CtyName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1]);
|
2017-03-02 00:53:34 +01:00
|
|
|
|
|
2019-04-06 20:43:31 +02:00
|
|
|
|
static void Ins_ListInstitutionsForEdition (void);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
static bool Ins_CheckIfICanEdit (struct Ins_Instit *Ins);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static Ins_StatusTxt_t Ins_GetStatusTxtFromStatusBits (Ins_Status_t Status);
|
|
|
|
|
static Ins_Status_t Ins_GetStatusBitsFromStatusTxt (Ins_StatusTxt_t StatusTxt);
|
2016-10-23 19:40:14 +02:00
|
|
|
|
|
2020-10-13 22:34:31 +02:00
|
|
|
|
static void Ins_PutParamOtherInsCod (void *InsCod);
|
2016-10-23 19:40:14 +02:00
|
|
|
|
static long Ins_GetParamOtherInsCod (void);
|
|
|
|
|
|
2016-10-22 17:27:30 +02:00
|
|
|
|
static void Ins_UpdateInsNameDB (long InsCod,const char *FieldName,const char *NewInsName);
|
2017-03-09 11:16:17 +01:00
|
|
|
|
|
2019-04-06 20:43:31 +02:00
|
|
|
|
static void Ins_ShowAlertAndButtonToGoToIns (void);
|
2020-04-08 18:18:46 +02:00
|
|
|
|
static void Ins_PutParamGoToIns (void *InsCod);
|
2016-03-01 23:58:48 +01:00
|
|
|
|
|
2019-04-06 20:43:31 +02:00
|
|
|
|
static void Ins_PutFormToCreateInstitution (void);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static void Ins_PutHeadInstitutionsForEdition (void);
|
2020-05-05 21:49:00 +02:00
|
|
|
|
static void Ins_ReceiveFormRequestOrCreateIns (unsigned Status);
|
2019-04-06 20:43:31 +02:00
|
|
|
|
static void Ins_CreateInstitution (unsigned Status);
|
2019-04-04 14:48:05 +02:00
|
|
|
|
|
2019-04-06 20:43:31 +02:00
|
|
|
|
static void Ins_EditingInstitutionConstructor ();
|
|
|
|
|
static void Ins_EditingInstitutionDestructor ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-02-11 00:58:53 +01:00
|
|
|
|
static void Ins_FormToGoToMap (struct Ins_Instit *Ins);
|
2020-01-14 13:30:18 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***************** List institutions with pending centers ********************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Ins_SeeInsWithPendingCtrs (void)
|
|
|
|
|
{
|
2020-01-30 20:47:00 +01:00
|
|
|
|
extern const char *Hlp_SYSTEM_Pending;
|
2021-03-07 21:21:04 +01:00
|
|
|
|
extern const char *Txt_Institutions_with_pending_centers;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Institution;
|
2021-03-07 21:21:04 +01:00
|
|
|
|
extern const char *Txt_Centers_ABBREVIATION;
|
|
|
|
|
extern const char *Txt_There_are_no_institutions_with_requests_for_centers_to_be_confirmed;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumInss;
|
|
|
|
|
unsigned NumIns;
|
2021-02-11 00:58:53 +01:00
|
|
|
|
struct Ins_Instit Ins;
|
2015-09-04 19:26:08 +02:00
|
|
|
|
const char *BgColor;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get institutions with pending centers *****/
|
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_INS_ADM:
|
2018-10-31 16:16:57 +01:00
|
|
|
|
NumInss =
|
|
|
|
|
(unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions"
|
2021-03-07 21:21:04 +01:00
|
|
|
|
" with pending centers",
|
|
|
|
|
"SELECT ctr_centers.InsCod,"
|
|
|
|
|
"COUNT(*)"
|
|
|
|
|
" FROM ctr_centers,"
|
|
|
|
|
"ins_admin,"
|
2021-03-07 21:52:56 +01:00
|
|
|
|
"ins_instits"
|
2021-03-07 21:21:04 +01:00
|
|
|
|
" WHERE (ctr_centers.Status & %u)<>0"
|
|
|
|
|
" AND ctr_centers.InsCod=ins_admin.InsCod"
|
|
|
|
|
" AND ins_admin.UsrCod=%ld"
|
2021-03-07 21:52:56 +01:00
|
|
|
|
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
2021-03-07 21:21:04 +01:00
|
|
|
|
" GROUP BY ctr_centers.InsCod"
|
2021-03-07 21:52:56 +01:00
|
|
|
|
" ORDER BY ins_instits.ShortName",
|
2018-10-31 16:16:57 +01:00
|
|
|
|
(unsigned) Ctr_STATUS_BIT_PENDING,
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2015-04-07 21:44:24 +02:00
|
|
|
|
case Rol_SYS_ADM:
|
2018-10-31 16:16:57 +01:00
|
|
|
|
NumInss =
|
|
|
|
|
(unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions"
|
2021-03-07 21:21:04 +01:00
|
|
|
|
" with pending centers",
|
|
|
|
|
"SELECT ctr_centers.InsCod,"
|
|
|
|
|
"COUNT(*)"
|
2021-03-07 21:52:56 +01:00
|
|
|
|
" FROM ctr_centers,"
|
|
|
|
|
"ins_instits"
|
2021-03-07 21:21:04 +01:00
|
|
|
|
" WHERE (ctr_centers.Status & %u)<>0"
|
2021-03-07 21:52:56 +01:00
|
|
|
|
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
2021-03-07 21:21:04 +01:00
|
|
|
|
" GROUP BY ctr_centers.InsCod"
|
2021-03-07 21:52:56 +01:00
|
|
|
|
" ORDER BY ins_instits.ShortName",
|
2018-10-31 16:16:57 +01:00
|
|
|
|
(unsigned) Ctr_STATUS_BIT_PENDING);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
default: // Forbidden for other users
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Get institutions *****/
|
2018-10-31 16:16:57 +01:00
|
|
|
|
if (NumInss)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box and table *****/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Box_BoxTableBegin (NULL,Txt_Institutions_with_pending_centers,
|
2020-03-26 02:54:30 +01:00
|
|
|
|
NULL,NULL,
|
2020-01-30 20:47:00 +01:00
|
|
|
|
Hlp_SYSTEM_Pending,Box_NOT_CLOSABLE,2);
|
2017-06-12 14:16:33 +02:00
|
|
|
|
|
|
|
|
|
/***** Write heading *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-12 00:07:52 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TH (1,1,"LM",Txt_Institution);
|
2021-03-07 21:21:04 +01:00
|
|
|
|
HTM_TH (1,1,"RM",Txt_Centers_ABBREVIATION);
|
2019-10-12 00:07:52 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** List the institutions *****/
|
|
|
|
|
for (NumIns = 0;
|
|
|
|
|
NumIns < NumInss;
|
|
|
|
|
NumIns++)
|
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/* Get next center */
|
2014-12-01 23:55:08 +01:00
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/* Get institution code (row[0]) */
|
|
|
|
|
Ins.InsCod = Str_ConvertStrCodToLongCod (row[0]);
|
2019-04-03 20:57:04 +02:00
|
|
|
|
BgColor = (Ins.InsCod == Gbl.Hierarchy.Ins.InsCod) ? "LIGHT_BLUE" :
|
2015-09-04 19:26:08 +02:00
|
|
|
|
Gbl.ColorRows[Gbl.RowEvenOdd];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get data of institution */
|
2020-01-07 00:09:30 +01:00
|
|
|
|
Ins_GetDataOfInstitutionByCod (&Ins);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2015-11-19 16:33:50 +01:00
|
|
|
|
/* Institution logo and name */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
HTM_TD_Begin ("class=\"LM %s\"",BgColor);
|
2015-11-19 18:33:16 +01:00
|
|
|
|
Ins_DrawInstitutionLogoAndNameWithLink (&Ins,ActSeeCtr,
|
2019-11-18 14:21:01 +01:00
|
|
|
|
"BT_LINK DAT_NOBR","CM");
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/* Number of pending centers (row[1]) */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT RM %s\"",BgColor);
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (row[1]);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 17:36:41 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd;
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End table and box *****/
|
2019-11-25 23:18:08 +01:00
|
|
|
|
Box_BoxTableEnd ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Ale_ShowAlert (Ale_INFO,Txt_There_are_no_institutions_with_requests_for_centers_to_be_confirmed);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-27 14:58:26 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Draw institution logo with link **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-02-11 00:58:53 +01:00
|
|
|
|
void Ins_DrawInstitutionLogoWithLink (struct Ins_Instit *Ins,unsigned Size)
|
2016-07-27 14:58:26 +02:00
|
|
|
|
{
|
2016-07-30 00:21:35 +02:00
|
|
|
|
bool PutLink = !Gbl.Form.Inside; // Don't put link to institution if already inside a form
|
|
|
|
|
|
2016-07-27 14:58:26 +02:00
|
|
|
|
if (PutLink)
|
|
|
|
|
{
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginForm (ActSeeInsInf);
|
2016-07-27 14:58:26 +02:00
|
|
|
|
Ins_PutParamInsCod (Ins->InsCod);
|
2019-11-20 10:17:42 +01:00
|
|
|
|
HTM_BUTTON_SUBMIT_Begin (Ins->FullName,"BT_LINK",NULL);
|
2016-07-27 14:58:26 +02:00
|
|
|
|
}
|
2021-02-11 22:57:09 +01:00
|
|
|
|
Lgo_DrawLogo (Hie_Lvl_INS,Ins->InsCod,Ins->FullName,
|
2016-07-27 14:58:26 +02:00
|
|
|
|
Size,NULL,true);
|
|
|
|
|
if (PutLink)
|
|
|
|
|
{
|
2019-11-18 14:21:01 +01:00
|
|
|
|
HTM_BUTTON_End ();
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2016-07-27 14:58:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-19 18:33:16 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Draw institution logo and name with link *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-02-11 00:58:53 +01:00
|
|
|
|
void Ins_DrawInstitutionLogoAndNameWithLink (struct Ins_Instit *Ins,Act_Action_t Action,
|
2015-11-19 18:33:16 +01:00
|
|
|
|
const char *ClassLink,const char *ClassLogo)
|
|
|
|
|
{
|
2019-10-20 22:00:28 +02:00
|
|
|
|
/***** Begin form *****/
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginFormGoTo (Action);
|
2015-11-19 18:33:16 +01:00
|
|
|
|
Ins_PutParamInsCod (Ins->InsCod);
|
|
|
|
|
|
|
|
|
|
/***** Link to action *****/
|
2019-12-30 12:25:45 +01:00
|
|
|
|
HTM_BUTTON_SUBMIT_Begin (Hie_BuildGoToMsg (Ins->FullName),ClassLink,NULL);
|
|
|
|
|
Hie_FreeGoToMsg ();
|
2015-11-19 18:33:16 +01:00
|
|
|
|
|
2019-10-27 09:28:51 +01:00
|
|
|
|
/***** Institution logo and name *****/
|
2021-02-11 22:57:09 +01:00
|
|
|
|
Lgo_DrawLogo (Hie_Lvl_INS,Ins->InsCod,Ins->ShrtName,16,ClassLogo,true);
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF (" %s",Ins->FullName);
|
2015-11-19 18:33:16 +01:00
|
|
|
|
|
|
|
|
|
/***** End link *****/
|
2019-11-18 14:21:01 +01:00
|
|
|
|
HTM_BUTTON_End ();
|
2015-11-19 18:33:16 +01:00
|
|
|
|
|
|
|
|
|
/***** End form *****/
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2020-01-14 13:30:18 +01:00
|
|
|
|
|
|
|
|
|
/***** Map *****/
|
|
|
|
|
Ins_FormToGoToMap (Ins);
|
2015-11-19 18:33:16 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************** List the institutions of the current country ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Ins_ShowInssOfCurrentCty (void)
|
|
|
|
|
{
|
2019-04-03 20:57:04 +02:00
|
|
|
|
if (Gbl.Hierarchy.Cty.CtyCod > 0)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Get parameter with the type of order in the list of institutions *****/
|
2017-01-29 12:42:19 +01:00
|
|
|
|
Ins_GetParamInsOrder ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get list of institutions *****/
|
2020-01-07 22:07:06 +01:00
|
|
|
|
Ins_GetFullListOfInstitutions (Gbl.Hierarchy.Cty.CtyCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write menu to select country *****/
|
2016-11-14 17:26:32 +01:00
|
|
|
|
Hie_WriteMenuHierarchy ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** List institutions *****/
|
2015-10-06 01:19:21 +02:00
|
|
|
|
Ins_ListInstitutions ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free list of institutions *****/
|
|
|
|
|
Ins_FreeListInstitutions ();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** List the institutions of the current country ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-10-06 01:19:21 +02:00
|
|
|
|
static void Ins_ListInstitutions (void)
|
|
|
|
|
{
|
2016-11-13 14:56:59 +01:00
|
|
|
|
extern const char *Hlp_COUNTRY_Institutions;
|
2016-03-20 14:11:04 +01:00
|
|
|
|
extern const char *Txt_Institutions_of_COUNTRY_X;
|
|
|
|
|
extern const char *Txt_No_institutions;
|
2016-03-16 13:23:10 +01:00
|
|
|
|
extern const char *Txt_Create_another_institution;
|
2015-10-06 01:19:21 +02:00
|
|
|
|
extern const char *Txt_Create_institution;
|
2016-03-20 14:11:04 +01:00
|
|
|
|
unsigned NumIns;
|
2015-10-06 01:19:21 +02:00
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box *****/
|
2019-12-30 21:47:07 +01:00
|
|
|
|
Box_BoxBegin (NULL,Str_BuildStringStr (Txt_Institutions_of_COUNTRY_X,
|
|
|
|
|
Gbl.Hierarchy.Cty.Name[Gbl.Prefs.Language]),
|
2020-04-08 18:18:46 +02:00
|
|
|
|
Ins_PutIconsListingInstitutions,NULL,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
Hlp_COUNTRY_Institutions,Box_NOT_CLOSABLE);
|
2019-12-30 21:47:07 +01:00
|
|
|
|
Str_FreeString ();
|
2016-03-20 14:11:04 +01:00
|
|
|
|
|
2020-01-08 14:04:25 +01:00
|
|
|
|
if (Gbl.Hierarchy.Inss.Num) // There are institutions in the current country
|
2016-03-20 14:11:04 +01:00
|
|
|
|
{
|
2019-10-20 22:00:28 +02:00
|
|
|
|
/***** Begin table *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_BeginWideMarginPadding (2);
|
2016-03-20 14:11:04 +01:00
|
|
|
|
Ins_PutHeadInstitutionsForSeeing (true); // Order selectable
|
2016-03-16 12:49:28 +01:00
|
|
|
|
|
2016-03-20 14:11:04 +01:00
|
|
|
|
/***** Write all the institutions and their nuber of users *****/
|
|
|
|
|
for (NumIns = 0;
|
2020-01-08 14:04:25 +01:00
|
|
|
|
NumIns < Gbl.Hierarchy.Inss.Num;
|
2016-03-20 14:11:04 +01:00
|
|
|
|
NumIns++)
|
2020-01-08 14:04:25 +01:00
|
|
|
|
Ins_ListOneInstitutionForSeeing (&(Gbl.Hierarchy.Inss.Lst[NumIns]),NumIns + 1);
|
2016-03-20 14:11:04 +01:00
|
|
|
|
|
|
|
|
|
/***** End table *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_End ();
|
2016-03-20 14:11:04 +01:00
|
|
|
|
}
|
|
|
|
|
else // No insrtitutions created in the current country
|
2019-02-16 16:18:54 +01:00
|
|
|
|
Ale_ShowAlert (Ale_INFO,Txt_No_institutions);
|
2016-03-20 14:11:04 +01:00
|
|
|
|
|
|
|
|
|
/***** Button to create institution *****/
|
2016-11-07 00:03:50 +01:00
|
|
|
|
if (Ins_CheckIfICanCreateInstitutions ())
|
2016-03-16 12:49:28 +01:00
|
|
|
|
{
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginForm (ActEdiIns);
|
2020-01-08 14:04:25 +01:00
|
|
|
|
Btn_PutConfirmButton (Gbl.Hierarchy.Inss.Num ? Txt_Create_another_institution :
|
2020-01-07 00:42:24 +01:00
|
|
|
|
Txt_Create_institution);
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2015-10-06 01:19:21 +02:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Box_BoxEnd ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-06 23:24:11 +01:00
|
|
|
|
/*****************************************************************************/
|
2016-11-07 00:03:50 +01:00
|
|
|
|
/******************* Check if I can create institutions **********************/
|
2016-11-06 23:24:11 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-11-07 00:03:50 +01:00
|
|
|
|
static bool Ins_CheckIfICanCreateInstitutions (void)
|
2016-11-06 23:24:11 +01:00
|
|
|
|
{
|
2017-06-04 18:18:54 +02:00
|
|
|
|
return (bool) (Gbl.Usrs.Me.Role.Logged >= Rol_GST);
|
2016-11-06 23:24:11 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-06 21:51:21 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Put contextual icons in list of institutions ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-08 18:18:46 +02:00
|
|
|
|
static void Ins_PutIconsListingInstitutions (__attribute__((unused)) void *Args)
|
2016-11-06 21:51:21 +01:00
|
|
|
|
{
|
2020-04-08 18:18:46 +02:00
|
|
|
|
/***** Put icon to edit institutions *****/
|
|
|
|
|
if (Ins_CheckIfICanCreateInstitutions ())
|
|
|
|
|
Ins_PutIconToEditInstitutions ();
|
2016-11-06 21:51:21 +01:00
|
|
|
|
|
2020-04-08 18:18:46 +02:00
|
|
|
|
/***** Put icon to show a figure *****/
|
|
|
|
|
Fig_PutIconToShowFigure (Fig_INSTITS);
|
2016-11-06 21:51:21 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-16 13:23:10 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Put link (form) to edit institutions *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-03-16 22:40:35 +01:00
|
|
|
|
static void Ins_PutIconToEditInstitutions (void)
|
2016-03-16 13:23:10 +01:00
|
|
|
|
{
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Ico_PutContextualIconToEdit (ActEdiIns,NULL,
|
|
|
|
|
NULL,NULL);
|
2016-03-16 13:23:10 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** List one institution for seeing **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-02-11 00:58:53 +01:00
|
|
|
|
static void Ins_ListOneInstitutionForSeeing (struct Ins_Instit *Ins,unsigned NumIns)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_INSTITUTION_STATUS[Ins_NUM_STATUS_TXT];
|
2015-11-19 16:09:51 +01:00
|
|
|
|
const char *TxtClassNormal;
|
|
|
|
|
const char *TxtClassStrong;
|
2015-09-04 19:26:08 +02:00
|
|
|
|
const char *BgColor;
|
2017-03-17 00:46:28 +01:00
|
|
|
|
Ins_StatusTxt_t StatusTxt;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2015-11-19 16:09:51 +01:00
|
|
|
|
if (Ins->Status & Ins_STATUS_BIT_PENDING)
|
|
|
|
|
{
|
|
|
|
|
TxtClassNormal = "DAT_LIGHT";
|
2019-11-18 15:48:46 +01:00
|
|
|
|
TxtClassStrong = "BT_LINK LT DAT_LIGHT";
|
2015-11-19 16:09:51 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TxtClassNormal = "DAT";
|
2019-11-18 15:48:46 +01:00
|
|
|
|
TxtClassStrong = "BT_LINK LT DAT_N";
|
2015-11-19 16:09:51 +01:00
|
|
|
|
}
|
2019-04-03 20:57:04 +02:00
|
|
|
|
BgColor = (Ins->InsCod == Gbl.Hierarchy.Ins.InsCod) ? "LIGHT_BLUE" :
|
2015-09-04 19:26:08 +02:00
|
|
|
|
Gbl.ColorRows[Gbl.RowEvenOdd];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 17:36:41 +02:00
|
|
|
|
|
|
|
|
|
/***** Number of institution in this list *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"%s RM %s\"",TxtClassNormal,BgColor);
|
2019-11-10 13:31:47 +01:00
|
|
|
|
HTM_Unsigned (NumIns);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2015-11-19 16:09:51 +01:00
|
|
|
|
/***** Institution logo and name *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LM %s\"",BgColor);
|
2015-11-19 18:33:16 +01:00
|
|
|
|
Ins_DrawInstitutionLogoAndNameWithLink (Ins,ActSeeCtr,
|
2019-10-15 15:23:38 +02:00
|
|
|
|
TxtClassStrong,"CM");
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-01-09 15:36:12 +01:00
|
|
|
|
/***** Number of users who claim to belong to this institution *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"%s RM %s\"",TxtClassNormal,BgColor);
|
2020-05-03 21:56:55 +02:00
|
|
|
|
HTM_Unsigned (Usr_GetCachedNumUsrsWhoClaimToBelongToIns (Ins));
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2015-12-09 19:51:17 +01:00
|
|
|
|
|
2020-01-09 15:36:12 +01:00
|
|
|
|
/***** Other stats *****/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/* Number of centers in this institution */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"%s RM %s\"",TxtClassNormal,BgColor);
|
2020-05-03 20:58:03 +02:00
|
|
|
|
HTM_Unsigned (Ctr_GetCachedNumCtrsInIns (Ins->InsCod));
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2015-12-09 19:51:17 +01:00
|
|
|
|
|
|
|
|
|
/* Number of degrees in this institution */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"%s RM %s\"",TxtClassNormal,BgColor);
|
2020-05-03 20:58:03 +02:00
|
|
|
|
HTM_Unsigned (Deg_GetCachedNumDegsInIns (Ins->InsCod));
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2015-12-09 19:51:17 +01:00
|
|
|
|
|
|
|
|
|
/* Number of courses in this institution */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"%s RM %s\"",TxtClassNormal,BgColor);
|
2020-05-03 20:58:03 +02:00
|
|
|
|
HTM_Unsigned (Crs_GetCachedNumCrssInIns (Ins->InsCod));
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2015-12-09 19:51:17 +01:00
|
|
|
|
|
|
|
|
|
/* Number of departments in this institution */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"%s RM %s\"",TxtClassNormal,BgColor);
|
2020-01-06 18:27:43 +01:00
|
|
|
|
HTM_Unsigned (Dpt_GetNumDptsInIns (Ins->InsCod));
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2015-12-09 19:51:17 +01:00
|
|
|
|
|
|
|
|
|
/* Number of users in courses of this institution */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"%s RM %s\"",TxtClassNormal,BgColor);
|
2021-02-11 22:57:09 +01:00
|
|
|
|
HTM_Unsigned (Usr_GetCachedNumUsrsInCrss (Hie_Lvl_INS,Ins->InsCod,
|
2020-05-03 20:58:03 +02:00
|
|
|
|
1 << Rol_STD |
|
|
|
|
|
1 << Rol_NET |
|
|
|
|
|
1 << Rol_TCH)); // Any user);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Institution status *****/
|
|
|
|
|
StatusTxt = Ins_GetStatusTxtFromStatusBits (Ins->Status);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"%s LM %s\"",TxtClassNormal,BgColor);
|
2017-03-17 00:46:28 +01:00
|
|
|
|
if (StatusTxt != Ins_STATUS_ACTIVE) // If active ==> do not show anything
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (Txt_INSTITUTION_STATUS[StatusTxt]);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 17:36:41 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************** Write header with fields of an institution *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Ins_PutHeadInstitutionsForSeeing (bool OrderSelectable)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_INSTITUTIONS_HELP_ORDER[2];
|
|
|
|
|
extern const char *Txt_INSTITUTIONS_ORDER[2];
|
2017-05-30 21:43:05 +02:00
|
|
|
|
extern const char *Txt_ROLES_PLURAL_BRIEF_Abc[Rol_NUM_ROLES];
|
2021-03-07 21:21:04 +01:00
|
|
|
|
extern const char *Txt_Centers_ABBREVIATION;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Degrees_ABBREVIATION;
|
2015-12-09 19:51:17 +01:00
|
|
|
|
extern const char *Txt_Courses_ABBREVIATION;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Departments_ABBREVIATION;
|
2017-01-29 12:42:19 +01:00
|
|
|
|
Ins_Order_t Order;
|
2020-01-07 22:25:05 +01:00
|
|
|
|
static const char *ClassTH[Ins_NUM_ORDERS] =
|
|
|
|
|
{
|
|
|
|
|
[Ins_ORDER_BY_INSTITUTION] = "LM",
|
|
|
|
|
[Ins_ORDER_BY_NUM_USRS ] = "RM"
|
|
|
|
|
};
|
|
|
|
|
static const char *ClassButton[Ins_NUM_ORDERS] =
|
|
|
|
|
{
|
|
|
|
|
[Ins_ORDER_BY_INSTITUTION] = "BT_LINK LM TIT_TBL",
|
|
|
|
|
[Ins_ORDER_BY_NUM_USRS ] = "BT_LINK RM TIT_TBL"
|
|
|
|
|
};
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
HTM_TH_Empty (1);
|
2019-12-15 20:02:34 +01:00
|
|
|
|
for (Order = (Ins_Order_t) 0;
|
|
|
|
|
Order <= (Ins_Order_t) (Ins_NUM_ORDERS - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Order++)
|
|
|
|
|
{
|
2020-01-07 22:25:05 +01:00
|
|
|
|
HTM_TH_Begin (1,1,ClassTH[Order]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (OrderSelectable)
|
|
|
|
|
{
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginForm (ActSeeIns);
|
2019-11-03 13:19:32 +01:00
|
|
|
|
Par_PutHiddenParamUnsigned (NULL,"Order",(unsigned) Order);
|
2020-01-07 22:25:05 +01:00
|
|
|
|
HTM_BUTTON_SUBMIT_Begin (Txt_INSTITUTIONS_HELP_ORDER[Order],ClassButton[Order],NULL);
|
2020-01-08 14:04:25 +01:00
|
|
|
|
if (Order == Gbl.Hierarchy.Inss.SelectedOrder)
|
2019-11-10 16:41:47 +01:00
|
|
|
|
HTM_U_Begin ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (Txt_INSTITUTIONS_ORDER[Order]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (OrderSelectable)
|
|
|
|
|
{
|
2020-01-08 14:04:25 +01:00
|
|
|
|
if (Order == Gbl.Hierarchy.Inss.SelectedOrder)
|
2019-11-10 16:41:47 +01:00
|
|
|
|
HTM_U_End ();
|
2019-11-18 14:21:01 +01:00
|
|
|
|
HTM_BUTTON_End ();
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TH_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2019-10-12 00:07:52 +02:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
HTM_TH (1,1,"RM",Txt_Centers_ABBREVIATION);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TH (1,1,"RM",Txt_Degrees_ABBREVIATION);
|
|
|
|
|
HTM_TH (1,1,"RM",Txt_Courses_ABBREVIATION);
|
|
|
|
|
HTM_TH (1,1,"RM",Txt_Departments_ABBREVIATION);
|
|
|
|
|
HTM_TH_Begin (1,1,"RM");
|
2019-11-11 00:15:44 +01:00
|
|
|
|
HTM_TxtF ("%s+",Txt_ROLES_PLURAL_BRIEF_Abc[Rol_TCH]);
|
2019-11-09 21:08:20 +01:00
|
|
|
|
HTM_BR ();
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (Txt_ROLES_PLURAL_BRIEF_Abc[Rol_STD]);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TH_End ();
|
|
|
|
|
HTM_TH_Empty (1);
|
2019-10-12 00:07:52 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2019-10-05 13:09:24 +02:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******* Get parameter with the type or order in list of institutions ********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-01-29 12:42:19 +01:00
|
|
|
|
static void Ins_GetParamInsOrder (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-01-08 14:04:25 +01:00
|
|
|
|
Gbl.Hierarchy.Inss.SelectedOrder = (Ins_Order_t)
|
2021-03-07 21:52:56 +01:00
|
|
|
|
Par_GetParToUnsignedLong ("Order",
|
|
|
|
|
0,
|
|
|
|
|
Ins_NUM_ORDERS - 1,
|
|
|
|
|
(unsigned long) Ins_ORDER_DEFAULT);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Put forms to edit institutions *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Ins_EditInstitutions (void)
|
2019-04-06 20:43:31 +02:00
|
|
|
|
{
|
|
|
|
|
/***** Institution constructor *****/
|
|
|
|
|
Ins_EditingInstitutionConstructor ();
|
|
|
|
|
|
|
|
|
|
/***** Edit institutions *****/
|
|
|
|
|
Ins_EditInstitutionsInternal ();
|
|
|
|
|
|
|
|
|
|
/***** Institution destructor *****/
|
|
|
|
|
Ins_EditingInstitutionDestructor ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void Ins_EditInstitutionsInternal (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-04-30 01:20:18 +02:00
|
|
|
|
extern const char *Hlp_COUNTRY_Institutions;
|
|
|
|
|
extern const char *Txt_Institutions_of_COUNTRY_X;
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get list of institutions *****/
|
2020-01-07 22:07:06 +01:00
|
|
|
|
Ins_GetFullListOfInstitutions (Gbl.Hierarchy.Cty.CtyCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2018-11-15 12:21:48 +01:00
|
|
|
|
/***** Write menu to select country *****/
|
|
|
|
|
Hie_WriteMenuHierarchy ();
|
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box *****/
|
2019-12-30 21:47:07 +01:00
|
|
|
|
Box_BoxBegin (NULL,Str_BuildStringStr (Txt_Institutions_of_COUNTRY_X,
|
|
|
|
|
Gbl.Hierarchy.Cty.Name[Gbl.Prefs.Language]),
|
2020-04-08 18:18:46 +02:00
|
|
|
|
Ins_PutIconsEditingInstitutions,NULL,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
Hlp_COUNTRY_Institutions,Box_NOT_CLOSABLE);
|
2019-12-30 21:47:07 +01:00
|
|
|
|
Str_FreeString ();
|
2017-04-30 01:20:18 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Put a form to create a new institution *****/
|
2019-04-06 20:43:31 +02:00
|
|
|
|
Ins_PutFormToCreateInstitution ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Forms to edit current institutions *****/
|
2020-01-08 14:04:25 +01:00
|
|
|
|
if (Gbl.Hierarchy.Inss.Num)
|
2019-04-06 20:43:31 +02:00
|
|
|
|
Ins_ListInstitutionsForEdition ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End box *****/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Box_BoxEnd ();
|
2017-04-30 01:20:18 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Free list of institutions *****/
|
|
|
|
|
Ins_FreeListInstitutions ();
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-30 01:20:18 +02:00
|
|
|
|
/*****************************************************************************/
|
2018-11-15 12:21:48 +01:00
|
|
|
|
/************ Put contextual icons in edition of institutions ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-08 18:18:46 +02:00
|
|
|
|
static void Ins_PutIconsEditingInstitutions (__attribute__((unused)) void *Args)
|
2018-11-15 12:21:48 +01:00
|
|
|
|
{
|
2020-04-08 18:18:46 +02:00
|
|
|
|
/***** Put icon to view institutions *****/
|
|
|
|
|
Ins_PutIconToViewInstitutions ();
|
2018-11-15 12:21:48 +01:00
|
|
|
|
|
2020-04-08 18:18:46 +02:00
|
|
|
|
/***** Put icon to show a figure *****/
|
|
|
|
|
Fig_PutIconToShowFigure (Fig_INSTITS);
|
2018-11-15 12:21:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********************** Put icon to view institutions ***********************/
|
2017-04-30 01:20:18 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Ins_PutIconToViewInstitutions (void)
|
|
|
|
|
{
|
2018-11-15 10:33:45 +01:00
|
|
|
|
extern const char *Txt_Institutions;
|
|
|
|
|
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Lay_PutContextualLinkOnlyIcon (ActSeeIns,NULL,
|
|
|
|
|
NULL,NULL,
|
2019-01-12 03:00:59 +01:00
|
|
|
|
"university.svg",
|
|
|
|
|
Txt_Institutions);
|
2017-04-30 01:20:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
2020-01-07 22:07:06 +01:00
|
|
|
|
/******* Get basic list of institutions ordered by name of institution *******/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-01-07 22:07:06 +01:00
|
|
|
|
void Ins_GetBasicListOfInstitutions (long CtyCod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2018-10-31 16:16:57 +01:00
|
|
|
|
unsigned long NumRows = 0; // Initialized to avoid warning
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned NumIns;
|
2021-02-11 00:58:53 +01:00
|
|
|
|
struct Ins_Instit *Ins;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get institutions from database *****/
|
2020-01-07 22:07:06 +01:00
|
|
|
|
NumRows = DB_QuerySELECT (&mysql_res,"can not get institutions",
|
|
|
|
|
"SELECT InsCod," // row[0]
|
|
|
|
|
"CtyCod," // row[1]
|
|
|
|
|
"Status," // row[2]
|
|
|
|
|
"RequesterUsrCod," // row[3]
|
|
|
|
|
"ShortName," // row[4]
|
|
|
|
|
"FullName," // row[5]
|
|
|
|
|
"WWW" // row[6]
|
2021-03-07 21:52:56 +01:00
|
|
|
|
" FROM ins_instits"
|
2020-01-07 22:07:06 +01:00
|
|
|
|
" WHERE CtyCod=%ld"
|
|
|
|
|
" ORDER BY FullName",
|
|
|
|
|
CtyCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
if (NumRows) // Institutions found...
|
|
|
|
|
{
|
|
|
|
|
// NumRows should be equal to Deg->NumCourses
|
2020-01-08 14:04:25 +01:00
|
|
|
|
Gbl.Hierarchy.Inss.Num = (unsigned) NumRows;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Create list with institutions *****/
|
2021-02-15 16:25:55 +01:00
|
|
|
|
if ((Gbl.Hierarchy.Inss.Lst = calloc (NumRows,
|
|
|
|
|
sizeof (*Gbl.Hierarchy.Inss.Lst))) == NULL)
|
2018-10-18 20:06:54 +02:00
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get the institutions *****/
|
|
|
|
|
for (NumIns = 0;
|
2020-01-08 14:04:25 +01:00
|
|
|
|
NumIns < Gbl.Hierarchy.Inss.Num;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
NumIns++)
|
|
|
|
|
{
|
2020-01-08 14:04:25 +01:00
|
|
|
|
Ins = &(Gbl.Hierarchy.Inss.Lst[NumIns]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-01-07 22:07:06 +01:00
|
|
|
|
/* Get institution data */
|
2014-12-01 23:55:08 +01:00
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2020-01-07 22:07:06 +01:00
|
|
|
|
Ins_GetDataOfInstitFromRow (Ins,row);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-01-07 22:07:06 +01:00
|
|
|
|
/* Reset number of users who claim to belong to this institution */
|
|
|
|
|
Ins->NumUsrsWhoClaimToBelongToIns.Valid = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-01-08 14:04:25 +01:00
|
|
|
|
Gbl.Hierarchy.Inss.Num = 0;
|
|
|
|
|
Gbl.Hierarchy.Inss.Lst = NULL;
|
2020-01-07 22:07:06 +01:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-01-07 22:07:06 +01:00
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-01-07 22:07:06 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************* Get full list of institutions **************/
|
|
|
|
|
/************* with number of users who claim to belong to them **************/
|
|
|
|
|
/*****************************************************************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-01-07 22:07:06 +01:00
|
|
|
|
void Ins_GetFullListOfInstitutions (long CtyCod)
|
|
|
|
|
{
|
2020-01-08 00:47:10 +01:00
|
|
|
|
static const char *OrderBySubQuery[Ins_NUM_ORDERS] =
|
|
|
|
|
{
|
|
|
|
|
[Ins_ORDER_BY_INSTITUTION] = "FullName",
|
|
|
|
|
[Ins_ORDER_BY_NUM_USRS ] = "NumUsrs DESC,FullName",
|
|
|
|
|
};
|
2020-01-07 22:07:06 +01:00
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned long NumRows = 0; // Initialized to avoid warning
|
|
|
|
|
unsigned NumIns;
|
2021-02-11 00:58:53 +01:00
|
|
|
|
struct Ins_Instit *Ins;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-01-07 22:07:06 +01:00
|
|
|
|
/***** Get institutions from database *****/
|
|
|
|
|
/* Query database */
|
|
|
|
|
NumRows = DB_QuerySELECT (&mysql_res,"can not get institutions",
|
2021-03-07 21:52:56 +01:00
|
|
|
|
"(SELECT ins_instits.InsCod," // row[0]
|
|
|
|
|
"ins_instits.CtyCod," // row[1]
|
|
|
|
|
"ins_instits.Status," // row[2]
|
|
|
|
|
"ins_instits.RequesterUsrCod," // row[3]
|
|
|
|
|
"ins_instits.ShortName," // row[4]
|
|
|
|
|
"ins_instits.FullName," // row[5]
|
|
|
|
|
"ins_instits.WWW," // row[6]
|
2020-01-07 22:07:06 +01:00
|
|
|
|
"COUNT(*) AS NumUsrs" // row[7]
|
2021-03-07 21:52:56 +01:00
|
|
|
|
" FROM ins_instits,usr_data"
|
|
|
|
|
" WHERE ins_instits.CtyCod=%ld"
|
|
|
|
|
" AND ins_instits.InsCod=usr_data.InsCod"
|
|
|
|
|
" GROUP BY ins_instits.InsCod)"
|
2020-01-07 22:07:06 +01:00
|
|
|
|
" UNION "
|
|
|
|
|
"(SELECT InsCod," // row[0]
|
|
|
|
|
"CtyCod," // row[1]
|
|
|
|
|
"Status," // row[2]
|
|
|
|
|
"RequesterUsrCod," // row[3]
|
|
|
|
|
"ShortName," // row[4]
|
|
|
|
|
"FullName," // row[5]
|
|
|
|
|
"WWW," // row[6]
|
|
|
|
|
"0 AS NumUsrs" // row[7]
|
2021-03-07 21:52:56 +01:00
|
|
|
|
" FROM ins_instits"
|
2020-01-07 22:07:06 +01:00
|
|
|
|
" WHERE CtyCod=%ld"
|
|
|
|
|
" AND InsCod NOT IN"
|
|
|
|
|
" (SELECT DISTINCT InsCod FROM usr_data))"
|
|
|
|
|
" ORDER BY %s",
|
2020-01-08 14:04:25 +01:00
|
|
|
|
CtyCod,CtyCod,OrderBySubQuery[Gbl.Hierarchy.Inss.SelectedOrder]);
|
2020-01-07 22:07:06 +01:00
|
|
|
|
|
|
|
|
|
if (NumRows) // Institutions found...
|
|
|
|
|
{
|
|
|
|
|
// NumRows should be equal to Deg->NumCourses
|
2020-01-08 14:04:25 +01:00
|
|
|
|
Gbl.Hierarchy.Inss.Num = (unsigned) NumRows;
|
2020-01-07 22:07:06 +01:00
|
|
|
|
|
|
|
|
|
/***** Create list with institutions *****/
|
2021-02-15 16:25:55 +01:00
|
|
|
|
if ((Gbl.Hierarchy.Inss.Lst = calloc (NumRows,
|
|
|
|
|
sizeof (*Gbl.Hierarchy.Inss.Lst))) == NULL)
|
2020-01-07 22:07:06 +01:00
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
|
|
|
|
|
|
|
|
|
/***** Get the institutions *****/
|
|
|
|
|
for (NumIns = 0;
|
2020-01-08 14:04:25 +01:00
|
|
|
|
NumIns < Gbl.Hierarchy.Inss.Num;
|
2020-01-07 22:07:06 +01:00
|
|
|
|
NumIns++)
|
|
|
|
|
{
|
2020-01-08 14:04:25 +01:00
|
|
|
|
Ins = &(Gbl.Hierarchy.Inss.Lst[NumIns]);
|
2020-01-07 22:07:06 +01:00
|
|
|
|
|
|
|
|
|
/* Get institution data */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
Ins_GetDataOfInstitFromRow (Ins,row);
|
|
|
|
|
|
|
|
|
|
/* Get number of users who claim to belong to this institution (row[7]) */
|
|
|
|
|
Ins->NumUsrsWhoClaimToBelongToIns.Valid = false;
|
|
|
|
|
if (sscanf (row[7],"%u",&(Ins->NumUsrsWhoClaimToBelongToIns.NumUsrs)) == 1)
|
|
|
|
|
Ins->NumUsrsWhoClaimToBelongToIns.Valid = true;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
2020-01-07 00:42:24 +01:00
|
|
|
|
{
|
2020-01-08 14:04:25 +01:00
|
|
|
|
Gbl.Hierarchy.Inss.Num = 0;
|
|
|
|
|
Gbl.Hierarchy.Inss.Lst = NULL;
|
2020-01-07 00:42:24 +01:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-02 00:53:34 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Write institution full name and country *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
// If ClassLink == NULL ==> do not put link
|
|
|
|
|
|
|
|
|
|
void Ins_WriteInstitutionNameAndCty (long InsCod)
|
|
|
|
|
{
|
2021-02-11 00:58:53 +01:00
|
|
|
|
struct Ins_Instit Ins;
|
2021-02-11 22:57:09 +01:00
|
|
|
|
char CtyName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1];
|
2017-03-02 00:53:34 +01:00
|
|
|
|
|
2019-03-07 13:00:18 +01:00
|
|
|
|
/***** Get institution short name and country name *****/
|
2017-03-02 00:53:34 +01:00
|
|
|
|
Ins.InsCod = InsCod;
|
2019-03-07 13:00:18 +01:00
|
|
|
|
Ins_GetShrtNameAndCtyOfInstitution (&Ins,CtyName);
|
2017-03-02 00:53:34 +01:00
|
|
|
|
|
2019-03-07 13:00:18 +01:00
|
|
|
|
/***** Write institution short name and country name *****/
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF ("%s (%s)",Ins.ShrtName,CtyName);
|
2017-03-02 00:53:34 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Get data of an institution ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-02-11 00:58:53 +01:00
|
|
|
|
bool Ins_GetDataOfInstitutionByCod (struct Ins_Instit *Ins)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2016-12-30 01:20:49 +01:00
|
|
|
|
bool InsFound = false;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Clear data *****/
|
2020-01-07 00:09:30 +01:00
|
|
|
|
Ins->CtyCod = -1L;
|
|
|
|
|
Ins->Status = (Ins_Status_t) 0;
|
|
|
|
|
Ins->RequesterUsrCod = -1L;
|
|
|
|
|
Ins->ShrtName[0] =
|
|
|
|
|
Ins->FullName[0] =
|
|
|
|
|
Ins->WWW[0] = '\0';
|
2020-01-07 22:07:06 +01:00
|
|
|
|
Ins->NumUsrsWhoClaimToBelongToIns.Valid = false;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Check if institution code is correct *****/
|
2016-12-30 01:20:49 +01:00
|
|
|
|
if (Ins->InsCod > 0)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2016-12-30 01:20:49 +01:00
|
|
|
|
/***** Get data of an institution from database *****/
|
2018-10-31 16:16:57 +01:00
|
|
|
|
if (DB_QuerySELECT (&mysql_res,"can not get data of an institution",
|
2020-01-07 22:07:06 +01:00
|
|
|
|
"SELECT InsCod," // row[0]
|
|
|
|
|
"CtyCod," // row[1]
|
|
|
|
|
"Status," // row[2]
|
|
|
|
|
"RequesterUsrCod," // row[3]
|
|
|
|
|
"ShortName," // row[4]
|
|
|
|
|
"FullName," // row[5]
|
|
|
|
|
"WWW" // row[6]
|
2021-03-07 21:52:56 +01:00
|
|
|
|
" FROM ins_instits WHERE InsCod=%ld",
|
2018-10-31 16:16:57 +01:00
|
|
|
|
Ins->InsCod)) // Institution found...
|
2016-12-30 01:20:49 +01:00
|
|
|
|
{
|
2020-01-07 22:07:06 +01:00
|
|
|
|
/* Get institution data */
|
2016-12-30 01:20:49 +01:00
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2020-01-07 22:07:06 +01:00
|
|
|
|
Ins_GetDataOfInstitFromRow (Ins,row);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-12-30 01:20:49 +01:00
|
|
|
|
/* Set return value */
|
|
|
|
|
InsFound = true;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-30 01:20:49 +01:00
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
return InsFound;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 22:07:06 +01:00
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/********** Get data of a center from a row resulting of a query *************/
|
2020-01-07 22:07:06 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-02-11 00:58:53 +01:00
|
|
|
|
static void Ins_GetDataOfInstitFromRow (struct Ins_Instit *Ins,MYSQL_ROW row)
|
2020-01-07 22:07:06 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Get institution code (row[0]) *****/
|
|
|
|
|
if ((Ins->InsCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
|
|
|
|
Lay_ShowErrorAndExit ("Wrong code of institution.");
|
|
|
|
|
|
|
|
|
|
/***** Get country code (row[1]) *****/
|
|
|
|
|
Ins->CtyCod = Str_ConvertStrCodToLongCod (row[1]);
|
|
|
|
|
|
|
|
|
|
/***** Get institution status (row[2]) *****/
|
|
|
|
|
if (sscanf (row[2],"%u",&(Ins->Status)) != 1)
|
|
|
|
|
Lay_ShowErrorAndExit ("Wrong institution status.");
|
|
|
|
|
|
|
|
|
|
/***** Get requester user's code (row[3]) *****/
|
|
|
|
|
Ins->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[3]);
|
|
|
|
|
|
2021-02-15 22:49:44 +01:00
|
|
|
|
/***** Get short name (row[4]), full name (row[5])
|
|
|
|
|
and URL (row[6]) of the institution *****/
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (Ins->ShrtName,row[4],sizeof (Ins->ShrtName) - 1);
|
|
|
|
|
Str_Copy (Ins->FullName,row[5],sizeof (Ins->FullName) - 1);
|
|
|
|
|
Str_Copy (Ins->WWW ,row[6],sizeof (Ins->WWW ) - 1);
|
2020-01-07 22:07:06 +01:00
|
|
|
|
}
|
|
|
|
|
|
2015-10-10 22:16:46 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********** Get the short name of an institution from its code **************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-06-20 14:43:26 +02:00
|
|
|
|
void Ins_FlushCacheShortNameOfInstitution (void)
|
|
|
|
|
{
|
|
|
|
|
Gbl.Cache.InstitutionShrtName.InsCod = -1L;
|
|
|
|
|
Gbl.Cache.InstitutionShrtName.ShrtName[0] = '\0';
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-11 00:58:53 +01:00
|
|
|
|
void Ins_GetShortNameOfInstitution (struct Ins_Instit *Ins)
|
2015-10-10 22:16:46 +02:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
|
2017-06-20 14:43:26 +02:00
|
|
|
|
/***** 1. Fast check: Trivial case *****/
|
2017-03-02 00:53:34 +01:00
|
|
|
|
if (Ins->InsCod <= 0)
|
2017-06-20 14:43:26 +02:00
|
|
|
|
{
|
2017-03-02 00:53:34 +01:00
|
|
|
|
Ins->ShrtName[0] = '\0'; // Empty name
|
2017-06-20 14:43:26 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** 2. Fast check: If cached... *****/
|
|
|
|
|
if (Ins->InsCod == Gbl.Cache.InstitutionShrtName.InsCod)
|
2015-10-10 22:16:46 +02:00
|
|
|
|
{
|
2017-06-20 14:43:26 +02:00
|
|
|
|
Str_Copy (Ins->ShrtName,Gbl.Cache.InstitutionShrtName.ShrtName,
|
2021-02-15 16:25:55 +01:00
|
|
|
|
sizeof (Ins->ShrtName) - 1);
|
2017-06-20 14:43:26 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
2017-01-13 10:49:56 +01:00
|
|
|
|
|
2017-06-20 14:43:26 +02:00
|
|
|
|
/***** 3. Slow: get short name of institution from database *****/
|
|
|
|
|
Gbl.Cache.InstitutionShrtName.InsCod = Ins->InsCod;
|
2017-03-02 00:53:34 +01:00
|
|
|
|
|
2018-10-31 16:16:57 +01:00
|
|
|
|
if (DB_QuerySELECT (&mysql_res,"can not get the short name"
|
|
|
|
|
" of an institution",
|
2021-03-07 21:52:56 +01:00
|
|
|
|
"SELECT ShortName FROM ins_instits"
|
2018-10-31 16:16:57 +01:00
|
|
|
|
" WHERE InsCod=%ld",
|
|
|
|
|
Ins->InsCod) == 1)
|
2017-06-20 14:43:26 +02:00
|
|
|
|
{
|
|
|
|
|
/* Get the short name of this institution */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2015-10-10 22:16:46 +02:00
|
|
|
|
|
2017-06-20 14:43:26 +02:00
|
|
|
|
Str_Copy (Gbl.Cache.InstitutionShrtName.ShrtName,row[0],
|
2021-02-15 16:25:55 +01:00
|
|
|
|
sizeof (Gbl.Cache.InstitutionShrtName.ShrtName) - 1);
|
2017-03-02 00:53:34 +01:00
|
|
|
|
}
|
2017-06-20 14:43:26 +02:00
|
|
|
|
else
|
|
|
|
|
Gbl.Cache.InstitutionShrtName.ShrtName[0] = '\0';
|
|
|
|
|
|
|
|
|
|
/* Free structure that stores the query result */
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
Str_Copy (Ins->ShrtName,Gbl.Cache.InstitutionShrtName.ShrtName,
|
2021-02-15 16:25:55 +01:00
|
|
|
|
sizeof (Ins->ShrtName) - 1);
|
2017-03-02 00:53:34 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************ Get the full name of an institution from its code **************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-06-20 14:43:26 +02:00
|
|
|
|
void Ins_FlushCacheFullNameAndCtyOfInstitution (void)
|
|
|
|
|
{
|
2019-03-07 13:00:18 +01:00
|
|
|
|
Gbl.Cache.InstitutionShrtNameAndCty.InsCod = -1L;
|
|
|
|
|
Gbl.Cache.InstitutionShrtNameAndCty.ShrtName[0] = '\0';
|
|
|
|
|
Gbl.Cache.InstitutionShrtNameAndCty.CtyName[0] = '\0';
|
2017-06-20 14:43:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-02-11 00:58:53 +01:00
|
|
|
|
static void Ins_GetShrtNameAndCtyOfInstitution (struct Ins_Instit *Ins,
|
2021-02-11 22:57:09 +01:00
|
|
|
|
char CtyName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1])
|
2017-03-02 00:53:34 +01:00
|
|
|
|
{
|
2018-12-08 16:43:13 +01:00
|
|
|
|
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
|
2017-03-02 00:53:34 +01:00
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
|
2017-06-20 14:43:26 +02:00
|
|
|
|
/***** 1. Fast check: Trivial case *****/
|
2017-03-02 00:53:34 +01:00
|
|
|
|
if (Ins->InsCod <= 0)
|
|
|
|
|
{
|
2019-03-07 13:00:18 +01:00
|
|
|
|
Ins->ShrtName[0] = '\0'; // Empty name
|
2017-03-02 00:53:34 +01:00
|
|
|
|
CtyName[0] = '\0'; // Empty name
|
2017-06-20 14:43:26 +02:00
|
|
|
|
return;
|
2017-03-02 00:53:34 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-20 14:43:26 +02:00
|
|
|
|
/***** 2. Fast check: If cached... *****/
|
2019-03-07 13:00:18 +01:00
|
|
|
|
if (Ins->InsCod == Gbl.Cache.InstitutionShrtNameAndCty.InsCod)
|
2017-06-20 14:43:26 +02:00
|
|
|
|
{
|
2019-03-07 13:00:18 +01:00
|
|
|
|
Str_Copy (Ins->ShrtName,Gbl.Cache.InstitutionShrtNameAndCty.ShrtName,
|
2021-02-15 16:25:55 +01:00
|
|
|
|
sizeof (Ins->ShrtName) - 1);
|
2019-03-07 13:00:18 +01:00
|
|
|
|
Str_Copy (CtyName,Gbl.Cache.InstitutionShrtNameAndCty.CtyName,
|
2021-02-11 22:57:09 +01:00
|
|
|
|
Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
|
2017-06-20 14:43:26 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
2017-03-02 00:53:34 +01:00
|
|
|
|
|
2019-03-07 13:00:18 +01:00
|
|
|
|
/***** 3. Slow: get short name and country of institution from database *****/
|
|
|
|
|
Gbl.Cache.InstitutionShrtNameAndCty.InsCod = Ins->InsCod;
|
2017-03-02 00:53:34 +01:00
|
|
|
|
|
2019-03-07 13:00:18 +01:00
|
|
|
|
if (DB_QuerySELECT (&mysql_res,"can not get short name and country"
|
2018-10-31 16:16:57 +01:00
|
|
|
|
" of an institution",
|
2021-03-08 09:48:13 +01:00
|
|
|
|
"SELECT ins_instits.ShortName," // row[0]
|
|
|
|
|
"cty_countrs.Name_%s" // row[1]
|
2021-03-07 21:52:56 +01:00
|
|
|
|
" FROM ins_instits,"
|
2021-03-08 09:48:13 +01:00
|
|
|
|
"cty_countrs"
|
2021-03-07 21:52:56 +01:00
|
|
|
|
" WHERE ins_instits.InsCod=%ld"
|
2021-03-08 09:48:13 +01:00
|
|
|
|
" AND ins_instits.CtyCod=cty_countrs.CtyCod",
|
2018-12-08 16:43:13 +01:00
|
|
|
|
Lan_STR_LANG_ID[Gbl.Prefs.Language],Ins->InsCod) == 1)
|
2017-06-20 14:43:26 +02:00
|
|
|
|
{
|
|
|
|
|
/* Get row */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2017-03-02 00:53:34 +01:00
|
|
|
|
|
2021-02-15 22:49:44 +01:00
|
|
|
|
/* Get short name (row[0]) and country name (row[1]) of this institution */
|
2019-03-07 13:00:18 +01:00
|
|
|
|
Str_Copy (Gbl.Cache.InstitutionShrtNameAndCty.ShrtName,row[0],
|
2021-02-15 16:25:55 +01:00
|
|
|
|
sizeof (Gbl.Cache.InstitutionShrtNameAndCty.ShrtName) - 1);
|
2021-02-15 22:49:44 +01:00
|
|
|
|
Str_Copy (Gbl.Cache.InstitutionShrtNameAndCty.CtyName ,row[1],
|
|
|
|
|
sizeof (Gbl.Cache.InstitutionShrtNameAndCty.CtyName ) - 1);
|
2015-10-10 22:16:46 +02:00
|
|
|
|
}
|
2017-06-20 14:43:26 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
2019-03-07 13:00:18 +01:00
|
|
|
|
Gbl.Cache.InstitutionShrtNameAndCty.ShrtName[0] = '\0';
|
2021-02-15 22:49:44 +01:00
|
|
|
|
Gbl.Cache.InstitutionShrtNameAndCty.CtyName [0] = '\0';
|
2017-06-20 14:43:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Free structure that stores the query result */
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
2019-03-07 13:00:18 +01:00
|
|
|
|
Str_Copy (Ins->ShrtName,Gbl.Cache.InstitutionShrtNameAndCty.ShrtName,
|
2021-02-15 16:25:55 +01:00
|
|
|
|
sizeof (Ins->ShrtName) - 1);
|
2021-02-15 22:49:44 +01:00
|
|
|
|
Str_Copy (CtyName ,Gbl.Cache.InstitutionShrtNameAndCty.CtyName ,
|
2021-02-11 22:57:09 +01:00
|
|
|
|
Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
|
2015-10-10 22:16:46 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Free list of institutions *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Ins_FreeListInstitutions (void)
|
|
|
|
|
{
|
2020-01-08 14:04:25 +01:00
|
|
|
|
if (Gbl.Hierarchy.Inss.Lst)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Free memory used by the list of institutions *****/
|
2020-01-08 14:04:25 +01:00
|
|
|
|
free (Gbl.Hierarchy.Inss.Lst);
|
|
|
|
|
Gbl.Hierarchy.Inss.Num = 0;
|
|
|
|
|
Gbl.Hierarchy.Inss.Lst = NULL;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Write selector of institution **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-07-25 20:20:07 +02:00
|
|
|
|
void Ins_WriteSelectorOfInstitution (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Institution;
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumInss;
|
|
|
|
|
unsigned NumIns;
|
|
|
|
|
long InsCod;
|
|
|
|
|
|
2019-10-20 22:00:28 +02:00
|
|
|
|
/***** Begin form *****/
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginFormGoTo (ActSeeCtr);
|
2019-04-03 20:57:04 +02:00
|
|
|
|
if (Gbl.Hierarchy.Cty.CtyCod > 0)
|
2020-04-27 03:16:55 +02:00
|
|
|
|
HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,
|
2019-11-05 15:47:35 +01:00
|
|
|
|
"id=\"ins\" name=\"ins\" class=\"HIE_SEL\"");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
2020-04-27 03:16:55 +02:00
|
|
|
|
HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE,
|
2019-11-05 15:47:35 +01:00
|
|
|
|
"id=\"ins\" name=\"ins\" class=\"HIE_SEL\""
|
|
|
|
|
" disabled=\"disabled\"");
|
2019-11-07 01:13:21 +01:00
|
|
|
|
HTM_OPTION (HTM_Type_STRING,"",
|
|
|
|
|
Gbl.Hierarchy.Ins.InsCod < 0,true,
|
|
|
|
|
"[%s]",Txt_Institution);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-03 20:57:04 +02:00
|
|
|
|
if (Gbl.Hierarchy.Cty.CtyCod > 0)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Get institutions of selected country from database *****/
|
2018-10-31 16:16:57 +01:00
|
|
|
|
NumInss =
|
|
|
|
|
(unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions",
|
2021-03-07 21:52:56 +01:00
|
|
|
|
"SELECT DISTINCT InsCod,"
|
|
|
|
|
"ShortName"
|
|
|
|
|
" FROM ins_instits"
|
2018-10-31 16:16:57 +01:00
|
|
|
|
" WHERE CtyCod=%ld"
|
|
|
|
|
" ORDER BY ShortName",
|
2019-04-03 20:57:04 +02:00
|
|
|
|
Gbl.Hierarchy.Cty.CtyCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** List institutions *****/
|
|
|
|
|
for (NumIns = 0;
|
|
|
|
|
NumIns < NumInss;
|
|
|
|
|
NumIns++)
|
|
|
|
|
{
|
|
|
|
|
/* Get next institution */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/* Get institution code (row[0]) */
|
|
|
|
|
if ((InsCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
|
|
|
|
Lay_ShowErrorAndExit ("Wrong code of institution.");
|
|
|
|
|
|
|
|
|
|
/* Write option */
|
2019-11-07 01:13:21 +01:00
|
|
|
|
HTM_OPTION (HTM_Type_LONG,&InsCod,
|
|
|
|
|
Gbl.Hierarchy.Ins.InsCod > 0 &&
|
|
|
|
|
InsCod == Gbl.Hierarchy.Ins.InsCod,false,
|
|
|
|
|
"%s",row[1]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** End form *****/
|
2019-11-05 08:46:38 +01:00
|
|
|
|
HTM_SELECT_End ();
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* List all the institutions *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-04-06 20:43:31 +02:00
|
|
|
|
static void Ins_ListInstitutionsForEdition (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_INSTITUTION_STATUS[Ins_NUM_STATUS_TXT];
|
|
|
|
|
unsigned NumIns;
|
2021-02-11 00:58:53 +01:00
|
|
|
|
struct Ins_Instit *Ins;
|
2017-03-07 01:56:41 +01:00
|
|
|
|
char WWW[Cns_MAX_BYTES_WWW + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
struct UsrData UsrDat;
|
|
|
|
|
bool ICanEdit;
|
2020-05-03 21:56:55 +02:00
|
|
|
|
unsigned NumCtrs;
|
2020-05-03 20:58:03 +02:00
|
|
|
|
unsigned NumUsrsIns;
|
2020-01-06 11:58:05 +01:00
|
|
|
|
unsigned NumUsrsInCrssOfIns;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Ins_StatusTxt_t StatusTxt;
|
2019-11-07 01:13:21 +01:00
|
|
|
|
unsigned StatusUnsigned;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Initialize structure with user's data *****/
|
|
|
|
|
Usr_UsrDataConstructor (&UsrDat);
|
|
|
|
|
|
|
|
|
|
/***** Write heading *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_BeginWidePadding (2);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Ins_PutHeadInstitutionsForEdition ();
|
|
|
|
|
|
|
|
|
|
/***** Write all the institutions *****/
|
|
|
|
|
for (NumIns = 0;
|
2020-01-08 14:04:25 +01:00
|
|
|
|
NumIns < Gbl.Hierarchy.Inss.Num;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
NumIns++)
|
|
|
|
|
{
|
2020-01-08 14:04:25 +01:00
|
|
|
|
Ins = &Gbl.Hierarchy.Inss.Lst[NumIns];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
ICanEdit = Ins_CheckIfICanEdit (Ins);
|
2020-05-03 21:56:55 +02:00
|
|
|
|
NumCtrs = Ctr_GetNumCtrsInIns (Ins->InsCod);
|
2020-05-03 20:58:03 +02:00
|
|
|
|
NumUsrsIns = Usr_GetNumUsrsWhoClaimToBelongToIns (Ins);
|
2021-02-11 22:57:09 +01:00
|
|
|
|
NumUsrsInCrssOfIns = Usr_GetNumUsrsInCrss (Hie_Lvl_INS,Ins->InsCod,
|
2020-01-08 23:49:04 +01:00
|
|
|
|
1 << Rol_STD |
|
|
|
|
|
1 << Rol_NET |
|
|
|
|
|
1 << Rol_TCH); // Any user
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-09 15:09:42 +02:00
|
|
|
|
|
|
|
|
|
/* Put icon to remove institution */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"BM\"");
|
2020-01-06 11:58:05 +01:00
|
|
|
|
if (!ICanEdit ||
|
2021-03-07 21:21:04 +01:00
|
|
|
|
NumCtrs || // Institution has centers
|
2020-05-03 20:58:03 +02:00
|
|
|
|
NumUsrsIns || // Institution has users
|
|
|
|
|
NumUsrsInCrssOfIns) // Institution has users
|
2021-03-07 21:21:04 +01:00
|
|
|
|
// Institution has centers or users ==> deletion forbidden
|
2017-06-11 19:13:28 +02:00
|
|
|
|
Ico_PutIconRemovalNotAllowed ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
2020-10-13 22:34:31 +02:00
|
|
|
|
Ico_PutContextualIconToRemove (ActRemIns,NULL,
|
|
|
|
|
Ins_PutParamOtherInsCod,&Ins->InsCod);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Institution code */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT CODE\"");
|
2019-11-10 13:38:17 +01:00
|
|
|
|
HTM_Long (Ins->InsCod);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Institution logo */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("title=\"%s\" class=\"HIE_LOGO\"",Ins->FullName);
|
2021-02-11 22:57:09 +01:00
|
|
|
|
Lgo_DrawLogo (Hie_Lvl_INS,Ins->InsCod,Ins->ShrtName,20,NULL,true);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Institution short name */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT LM\"");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (ICanEdit)
|
|
|
|
|
{
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginForm (ActRenInsSho);
|
2020-10-13 22:34:31 +02:00
|
|
|
|
Ins_PutParamOtherInsCod (&Ins->InsCod);
|
2021-02-11 22:57:09 +01:00
|
|
|
|
HTM_INPUT_TEXT ("ShortName",Cns_HIERARCHY_MAX_CHARS_SHRT_NAME,Ins->ShrtName,
|
2020-04-27 03:16:55 +02:00
|
|
|
|
HTM_SUBMIT_ON_CHANGE,
|
2019-11-04 12:25:48 +01:00
|
|
|
|
"class=\"INPUT_SHORT_NAME\"");
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (Ins->ShrtName);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Institution full name */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT LM\"");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (ICanEdit)
|
|
|
|
|
{
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginForm (ActRenInsFul);
|
2020-10-13 22:34:31 +02:00
|
|
|
|
Ins_PutParamOtherInsCod (&Ins->InsCod);
|
2021-02-11 22:57:09 +01:00
|
|
|
|
HTM_INPUT_TEXT ("FullName",Cns_HIERARCHY_MAX_CHARS_FULL_NAME,Ins->FullName,
|
2020-04-27 03:16:55 +02:00
|
|
|
|
HTM_SUBMIT_ON_CHANGE,
|
2019-11-04 12:25:48 +01:00
|
|
|
|
"class=\"INPUT_FULL_NAME\"");
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (Ins->FullName);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Institution WWW */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT LM\"");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (ICanEdit)
|
|
|
|
|
{
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginForm (ActChgInsWWW);
|
2020-10-13 22:34:31 +02:00
|
|
|
|
Ins_PutParamOtherInsCod (&Ins->InsCod);
|
2020-04-27 03:16:55 +02:00
|
|
|
|
HTM_INPUT_URL ("WWW",Ins->WWW,HTM_SUBMIT_ON_CHANGE,
|
2019-12-19 11:00:14 +01:00
|
|
|
|
"class=\"INPUT_WWW_NARROW\" required=\"required\"");
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (WWW,Ins->WWW,sizeof (WWW) - 1);
|
2019-10-24 00:04:40 +02:00
|
|
|
|
HTM_DIV_Begin ("class=\"EXTERNAL_WWW_SHORT\"");
|
2019-10-28 20:38:29 +01:00
|
|
|
|
HTM_A_Begin ("href=\"%s\" target=\"_blank\" class=\"DAT\" title=\"%s\"",
|
|
|
|
|
Ins->WWW,Ins->WWW);
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (WWW);
|
2019-10-28 13:56:04 +01:00
|
|
|
|
HTM_A_End ();
|
2019-10-23 20:07:56 +02:00
|
|
|
|
HTM_DIV_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2015-12-14 16:44:14 +01:00
|
|
|
|
/* Number of users who claim to belong to this institution */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT RM\"");
|
2020-05-03 20:58:03 +02:00
|
|
|
|
HTM_Unsigned (NumUsrsIns);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/* Number of centers */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT RM\"");
|
2020-05-03 21:56:55 +02:00
|
|
|
|
HTM_Unsigned (NumCtrs);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2015-12-14 16:44:14 +01:00
|
|
|
|
/* Number of users in courses of this institution */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT RM\"");
|
2020-01-06 11:58:05 +01:00
|
|
|
|
HTM_Unsigned (NumUsrsInCrssOfIns);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2015-12-14 16:44:14 +01:00
|
|
|
|
|
2017-03-17 00:46:28 +01:00
|
|
|
|
/* Institution requester */
|
|
|
|
|
UsrDat.UsrCod = Ins->RequesterUsrCod;
|
2019-03-19 13:22:14 +01:00
|
|
|
|
Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT INPUT_REQUESTER LT\"");
|
2017-05-02 01:16:06 +02:00
|
|
|
|
Msg_WriteMsgAuthor (&UsrDat,true,NULL);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2017-03-17 00:46:28 +01:00
|
|
|
|
|
2015-12-05 21:15:30 +01:00
|
|
|
|
/* Institution status */
|
2014-12-01 23:55:08 +01:00
|
|
|
|
StatusTxt = Ins_GetStatusTxtFromStatusBits (Ins->Status);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT LM\"");
|
2017-06-04 18:18:54 +02:00
|
|
|
|
if (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM &&
|
2014-12-01 23:55:08 +01:00
|
|
|
|
StatusTxt == Ins_STATUS_PENDING)
|
|
|
|
|
{
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginForm (ActChgInsSta);
|
2020-10-13 22:34:31 +02:00
|
|
|
|
Ins_PutParamOtherInsCod (&Ins->InsCod);
|
2020-04-27 03:16:55 +02:00
|
|
|
|
HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,
|
2019-11-05 15:47:35 +01:00
|
|
|
|
"name=\"Status\" class=\"INPUT_STATUS\"");
|
2019-11-07 01:13:21 +01:00
|
|
|
|
StatusUnsigned = (unsigned) Ins_GetStatusBitsFromStatusTxt (Ins_STATUS_PENDING);
|
|
|
|
|
HTM_OPTION (HTM_Type_UNSIGNED,&StatusUnsigned,true,false,
|
|
|
|
|
"%s",Txt_INSTITUTION_STATUS[Ins_STATUS_PENDING]);
|
|
|
|
|
StatusUnsigned = (unsigned) Ins_GetStatusBitsFromStatusTxt (Ins_STATUS_ACTIVE);
|
2020-01-23 17:08:57 +01:00
|
|
|
|
HTM_OPTION (HTM_Type_UNSIGNED,&StatusUnsigned,false,false,
|
2019-11-07 01:13:21 +01:00
|
|
|
|
"%s",Txt_INSTITUTION_STATUS[Ins_STATUS_ACTIVE]);
|
2019-11-05 08:46:38 +01:00
|
|
|
|
HTM_SELECT_End ();
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2017-03-17 00:46:28 +01:00
|
|
|
|
else if (StatusTxt != Ins_STATUS_ACTIVE) // If active ==> do not show anything
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (Txt_INSTITUTION_STATUS[StatusTxt]);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** End table *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free memory used for user's data *****/
|
|
|
|
|
Usr_UsrDataDestructor (&UsrDat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************ Check if I can edit, remove, etc. an institution ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-02-11 00:58:53 +01:00
|
|
|
|
static bool Ins_CheckIfICanEdit (struct Ins_Instit *Ins)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-06-04 18:18:54 +02:00
|
|
|
|
return (bool) (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM || // I am a superuser
|
2014-12-01 23:55:08 +01:00
|
|
|
|
((Ins->Status & Ins_STATUS_BIT_PENDING) != 0 && // Institution is not yet activated
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod == Ins->RequesterUsrCod)); // I am the requester
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Set StatusTxt depending on status bits ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
// Ins_STATUS_UNKNOWN = 0 // Other
|
|
|
|
|
// Ins_STATUS_ACTIVE = 1 // 00 (Status == 0)
|
|
|
|
|
// Ins_STATUS_PENDING = 2 // 01 (Status == Ins_STATUS_BIT_PENDING)
|
|
|
|
|
// Ins_STATUS_REMOVED = 3 // 1- (Status & Ins_STATUS_BIT_REMOVED)
|
|
|
|
|
|
|
|
|
|
static Ins_StatusTxt_t Ins_GetStatusTxtFromStatusBits (Ins_Status_t Status)
|
|
|
|
|
{
|
|
|
|
|
if (Status == 0)
|
|
|
|
|
return Ins_STATUS_ACTIVE;
|
|
|
|
|
if (Status == Ins_STATUS_BIT_PENDING)
|
|
|
|
|
return Ins_STATUS_PENDING;
|
|
|
|
|
if (Status & Ins_STATUS_BIT_REMOVED)
|
|
|
|
|
return Ins_STATUS_REMOVED;
|
|
|
|
|
return Ins_STATUS_UNKNOWN;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Set status bits depending on StatusTxt ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
// Ins_STATUS_UNKNOWN = 0 // Other
|
|
|
|
|
// Ins_STATUS_ACTIVE = 1 // 00 (Status == 0)
|
|
|
|
|
// Ins_STATUS_PENDING = 2 // 01 (Status == Ins_STATUS_BIT_PENDING)
|
|
|
|
|
// Ins_STATUS_REMOVED = 3 // 1- (Status & Ins_STATUS_BIT_REMOVED)
|
|
|
|
|
|
|
|
|
|
static Ins_Status_t Ins_GetStatusBitsFromStatusTxt (Ins_StatusTxt_t StatusTxt)
|
|
|
|
|
{
|
|
|
|
|
switch (StatusTxt)
|
|
|
|
|
{
|
|
|
|
|
case Ins_STATUS_UNKNOWN:
|
|
|
|
|
case Ins_STATUS_ACTIVE:
|
|
|
|
|
return (Ins_Status_t) 0;
|
|
|
|
|
case Ins_STATUS_PENDING:
|
|
|
|
|
return Ins_STATUS_BIT_PENDING;
|
|
|
|
|
case Ins_STATUS_REMOVED:
|
|
|
|
|
return Ins_STATUS_BIT_REMOVED;
|
|
|
|
|
}
|
|
|
|
|
return (Ins_Status_t) 0;
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-23 22:13:02 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************* Write parameter with code of current institution **************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-08 18:18:46 +02:00
|
|
|
|
void Ins_PutParamCurrentInsCod (void *InsCod)
|
2019-12-23 22:13:02 +01:00
|
|
|
|
{
|
2020-04-08 18:18:46 +02:00
|
|
|
|
if (InsCod)
|
|
|
|
|
Ins_PutParamInsCod (*((long *) InsCod));
|
2019-12-23 22:13:02 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Write parameter with code of institution ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Ins_PutParamInsCod (long InsCod)
|
|
|
|
|
{
|
2019-11-03 13:19:32 +01:00
|
|
|
|
Par_PutHiddenParamLong (NULL,"ins",InsCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Write parameter with code of institution ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-10-13 22:34:31 +02:00
|
|
|
|
static void Ins_PutParamOtherInsCod (void *InsCod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-10-13 22:34:31 +02:00
|
|
|
|
if (InsCod)
|
|
|
|
|
Par_PutHiddenParamLong (NULL,"OthInsCod",*((long *) InsCod));
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Get parameter with code of institution ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-05-31 21:05:59 +02:00
|
|
|
|
long Ins_GetAndCheckParamOtherInsCod (long MinCodAllowed)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2016-10-23 18:55:11 +02:00
|
|
|
|
long InsCod;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-10-23 19:40:14 +02:00
|
|
|
|
/***** Get and check parameter with code of institution *****/
|
2017-05-31 21:05:59 +02:00
|
|
|
|
if ((InsCod = Ins_GetParamOtherInsCod ()) < MinCodAllowed)
|
|
|
|
|
Lay_ShowErrorAndExit ("Code of institution is missing or invalid.");
|
2016-10-23 18:55:11 +02:00
|
|
|
|
|
|
|
|
|
return InsCod;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-23 19:40:14 +02:00
|
|
|
|
static long Ins_GetParamOtherInsCod (void)
|
|
|
|
|
{
|
2017-01-28 20:32:50 +01:00
|
|
|
|
/***** Get code of institution *****/
|
|
|
|
|
return Par_GetParToLong ("OthInsCod");
|
2016-10-23 19:40:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************************** Remove a institution ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Ins_RemoveInstitution (void)
|
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
extern const char *Txt_To_remove_an_institution_you_must_first_remove_all_centers_and_users_in_the_institution;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Institution_X_removed;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char PathIns[PATH_MAX + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-06 20:43:31 +02:00
|
|
|
|
/***** Institution constructor *****/
|
|
|
|
|
Ins_EditingInstitutionConstructor ();
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get institution code *****/
|
2019-04-06 20:43:31 +02:00
|
|
|
|
Ins_EditingIns->InsCod = Ins_GetAndCheckParamOtherInsCod (1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get data of the institution from database *****/
|
2020-01-07 00:09:30 +01:00
|
|
|
|
Ins_GetDataOfInstitutionByCod (Ins_EditingIns);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Check if this institution has users *****/
|
2019-04-06 20:43:31 +02:00
|
|
|
|
if (!Ins_CheckIfICanEdit (Ins_EditingIns))
|
2019-10-26 01:56:36 +02:00
|
|
|
|
Lay_NoPermissionExit ();
|
2020-01-07 00:09:30 +01:00
|
|
|
|
else if (Ctr_GetNumCtrsInIns (Ins_EditingIns->InsCod))
|
2021-03-07 21:21:04 +01:00
|
|
|
|
// Institution has centers ==> don't remove
|
2020-01-06 11:58:05 +01:00
|
|
|
|
Ale_CreateAlert (Ale_WARNING,NULL,
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Txt_To_remove_an_institution_you_must_first_remove_all_centers_and_users_in_the_institution);
|
2020-01-08 23:49:04 +01:00
|
|
|
|
else if (Usr_GetNumUsrsWhoClaimToBelongToIns (Ins_EditingIns))
|
2020-01-06 11:58:05 +01:00
|
|
|
|
// Institution has users ==> don't remove
|
2019-04-08 15:33:29 +02:00
|
|
|
|
Ale_CreateAlert (Ale_WARNING,NULL,
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Txt_To_remove_an_institution_you_must_first_remove_all_centers_and_users_in_the_institution);
|
2021-02-11 22:57:09 +01:00
|
|
|
|
else if (Usr_GetNumUsrsInCrss (Hie_Lvl_INS,Ins_EditingIns->InsCod,
|
2020-01-08 23:49:04 +01:00
|
|
|
|
1 << Rol_STD |
|
|
|
|
|
1 << Rol_NET |
|
|
|
|
|
1 << Rol_TCH)) // Any user
|
2020-01-06 18:00:23 +01:00
|
|
|
|
// Institution has users ==> don't remove
|
|
|
|
|
Ale_CreateAlert (Ale_WARNING,NULL,
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Txt_To_remove_an_institution_you_must_first_remove_all_centers_and_users_in_the_institution);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else // Institution has no users ==> remove it
|
|
|
|
|
{
|
2016-10-28 00:25:31 +02:00
|
|
|
|
/***** Remove all the threads and posts in forums of the institution *****/
|
2021-02-11 22:57:09 +01:00
|
|
|
|
For_RemoveForums (Hie_Lvl_INS,Ins_EditingIns->InsCod);
|
2016-10-28 00:25:31 +02:00
|
|
|
|
|
|
|
|
|
/***** Remove surveys of the institution *****/
|
2021-02-11 22:57:09 +01:00
|
|
|
|
Svy_RemoveSurveys (Hie_Lvl_INS,Ins_EditingIns->InsCod);
|
2016-10-28 00:25:31 +02:00
|
|
|
|
|
2015-01-20 02:00:42 +01:00
|
|
|
|
/***** Remove information related to files in institution *****/
|
2019-04-06 20:43:31 +02:00
|
|
|
|
Brw_RemoveInsFilesFromDB (Ins_EditingIns->InsCod);
|
2015-01-25 18:50:43 +01:00
|
|
|
|
|
|
|
|
|
/***** Remove directories of the institution *****/
|
2021-02-15 16:25:55 +01:00
|
|
|
|
snprintf (PathIns,sizeof (PathIns),"%s/%02u/%u",
|
2019-03-20 01:36:36 +01:00
|
|
|
|
Cfg_PATH_INS_PUBLIC,
|
2019-04-06 20:43:31 +02:00
|
|
|
|
(unsigned) (Ins_EditingIns->InsCod % 100),
|
2021-02-15 16:25:55 +01:00
|
|
|
|
(unsigned) Ins_EditingIns->InsCod);
|
2016-10-06 22:18:33 +02:00
|
|
|
|
Fil_RemoveTree (PathIns);
|
2015-01-20 18:55:59 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Remove institution *****/
|
2018-11-02 22:00:31 +01:00
|
|
|
|
DB_QueryDELETE ("can not remove an institution",
|
2021-03-07 21:52:56 +01:00
|
|
|
|
"DELETE FROM ins_instits WHERE InsCod=%ld",
|
2019-04-06 20:43:31 +02:00
|
|
|
|
Ins_EditingIns->InsCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-06-20 14:43:26 +02:00
|
|
|
|
/***** Flush caches *****/
|
|
|
|
|
Ins_FlushCacheShortNameOfInstitution ();
|
|
|
|
|
Ins_FlushCacheFullNameAndCtyOfInstitution ();
|
2020-01-06 18:27:43 +01:00
|
|
|
|
Dpt_FlushCacheNumDptsInIns ();
|
2020-01-07 00:09:30 +01:00
|
|
|
|
Ctr_FlushCacheNumCtrsInIns ();
|
|
|
|
|
Deg_FlushCacheNumDegsInIns ();
|
2020-01-06 18:43:48 +01:00
|
|
|
|
Crs_FlushCacheNumCrssInIns ();
|
2020-01-06 18:00:23 +01:00
|
|
|
|
Usr_FlushCacheNumUsrsWhoClaimToBelongToIns ();
|
2017-06-20 14:43:26 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Write message to show the change made *****/
|
2019-04-08 15:33:29 +02:00
|
|
|
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
|
|
|
|
Txt_Institution_X_removed,
|
|
|
|
|
Ins_EditingIns->FullName);
|
2019-06-13 10:14:05 +02:00
|
|
|
|
|
|
|
|
|
Ins_EditingIns->InsCod = -1L; // To not showing button to go to institution
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2019-05-16 14:22:10 +02:00
|
|
|
|
/********************* Change the name of an institution *********************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Ins_RenameInsShort (void)
|
|
|
|
|
{
|
2019-04-04 14:48:05 +02:00
|
|
|
|
/***** Institution constructor *****/
|
2019-04-06 20:43:31 +02:00
|
|
|
|
Ins_EditingInstitutionConstructor ();
|
2019-04-04 14:48:05 +02:00
|
|
|
|
|
|
|
|
|
/***** Rename institution *****/
|
2019-04-06 20:43:31 +02:00
|
|
|
|
Ins_EditingIns->InsCod = Ins_GetAndCheckParamOtherInsCod (1);
|
|
|
|
|
Ins_RenameInstitution (Ins_EditingIns,Cns_SHRT_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-04-06 20:43:31 +02:00
|
|
|
|
void Ins_RenameInsFull (void)
|
2016-10-22 18:24:57 +02:00
|
|
|
|
{
|
2019-04-04 14:48:05 +02:00
|
|
|
|
/***** Institution constructor *****/
|
2019-04-06 20:43:31 +02:00
|
|
|
|
Ins_EditingInstitutionConstructor ();
|
2019-04-04 14:48:05 +02:00
|
|
|
|
|
|
|
|
|
/***** Rename institution *****/
|
2019-04-06 20:43:31 +02:00
|
|
|
|
Ins_EditingIns->InsCod = Ins_GetAndCheckParamOtherInsCod (1);
|
|
|
|
|
Ins_RenameInstitution (Ins_EditingIns,Cns_FULL_NAME);
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Change the name of an institution **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-02-11 00:58:53 +01:00
|
|
|
|
void Ins_RenameInstitution (struct Ins_Instit *Ins,Cns_ShrtOrFullName_t ShrtOrFullName)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_The_institution_X_already_exists;
|
2016-03-01 23:58:48 +01:00
|
|
|
|
extern const char *Txt_The_institution_X_has_been_renamed_as_Y;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_The_name_of_the_institution_X_has_not_changed;
|
|
|
|
|
const char *ParamName = NULL; // Initialized to avoid warning
|
|
|
|
|
const char *FieldName = NULL; // Initialized to avoid warning
|
2017-03-07 19:55:29 +01:00
|
|
|
|
unsigned MaxBytes = 0; // Initialized to avoid warning
|
2014-12-01 23:55:08 +01:00
|
|
|
|
char *CurrentInsName = NULL; // Initialized to avoid warning
|
2021-02-11 22:57:09 +01:00
|
|
|
|
char NewInsName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-10-28 10:03:37 +02:00
|
|
|
|
switch (ShrtOrFullName)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2016-10-28 10:03:37 +02:00
|
|
|
|
case Cns_SHRT_NAME:
|
2014-12-01 23:55:08 +01:00
|
|
|
|
ParamName = "ShortName";
|
|
|
|
|
FieldName = "ShortName";
|
2021-02-11 22:57:09 +01:00
|
|
|
|
MaxBytes = Cns_HIERARCHY_MAX_BYTES_SHRT_NAME;
|
2016-10-28 10:03:37 +02:00
|
|
|
|
CurrentInsName = Ins->ShrtName;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
case Cns_FULL_NAME:
|
|
|
|
|
ParamName = "FullName";
|
|
|
|
|
FieldName = "FullName";
|
2021-02-11 22:57:09 +01:00
|
|
|
|
MaxBytes = Cns_HIERARCHY_MAX_BYTES_FULL_NAME;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
CurrentInsName = Ins->FullName;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-22 17:27:30 +02:00
|
|
|
|
/***** Get the new name for the institution from form *****/
|
2017-03-07 19:55:29 +01:00
|
|
|
|
Par_GetParToText (ParamName,NewInsName,MaxBytes);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get from the database the old names of the institution *****/
|
2020-01-07 00:09:30 +01:00
|
|
|
|
Ins_GetDataOfInstitutionByCod (Ins);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Check if new name is empty *****/
|
2019-12-20 00:30:54 +01:00
|
|
|
|
if (NewInsName[0])
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-01-02 15:10:51 +01:00
|
|
|
|
/***** Check if old and new names are the same
|
|
|
|
|
(this happens when return is pressed without changes) *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (strcmp (CurrentInsName,NewInsName)) // Different names
|
|
|
|
|
{
|
|
|
|
|
/***** If institution was in database... *****/
|
2019-03-09 20:12:44 +01:00
|
|
|
|
if (Ins_CheckIfInsNameExistsInCty (ParamName,NewInsName,Ins->InsCod,
|
2019-04-03 20:57:04 +02:00
|
|
|
|
Gbl.Hierarchy.Cty.CtyCod))
|
2019-03-09 20:12:44 +01:00
|
|
|
|
Ale_CreateAlert (Ale_WARNING,NULL,
|
|
|
|
|
Txt_The_institution_X_already_exists,
|
|
|
|
|
NewInsName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Update the table changing old name by new name */
|
2016-10-22 17:27:30 +02:00
|
|
|
|
Ins_UpdateInsNameDB (Ins->InsCod,FieldName,NewInsName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-03-09 11:16:17 +01:00
|
|
|
|
/* Create message to show the change made */
|
2019-03-09 20:12:44 +01:00
|
|
|
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
|
|
|
|
Txt_The_institution_X_has_been_renamed_as_Y,
|
|
|
|
|
CurrentInsName,NewInsName);
|
2016-03-01 23:58:48 +01:00
|
|
|
|
|
|
|
|
|
/* Change current institution name in order to display it properly */
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (CurrentInsName,NewInsName,MaxBytes);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // The same name
|
2019-03-09 20:12:44 +01:00
|
|
|
|
Ale_CreateAlert (Ale_INFO,NULL,
|
|
|
|
|
Txt_The_name_of_the_institution_X_has_not_changed,
|
|
|
|
|
CurrentInsName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2019-12-20 00:30:54 +01:00
|
|
|
|
else
|
|
|
|
|
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****** Check if the name of institution exists in the current country *******/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-12-29 16:21:42 +01:00
|
|
|
|
bool Ins_CheckIfInsNameExistsInCty (const char *FieldName,
|
|
|
|
|
const char *Name,
|
|
|
|
|
long InsCod,
|
|
|
|
|
long CtyCod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Get number of institutions in current country with a name from database *****/
|
2018-11-03 20:52:00 +01:00
|
|
|
|
return (DB_QueryCOUNT ("can not check if the name of an institution"
|
|
|
|
|
" already existed",
|
2021-03-07 21:52:56 +01:00
|
|
|
|
"SELECT COUNT(*) FROM ins_instits"
|
2018-11-03 20:52:00 +01:00
|
|
|
|
" WHERE CtyCod=%ld AND %s='%s' AND InsCod<>%ld",
|
|
|
|
|
CtyCod,FieldName,Name,InsCod) != 0);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-22 17:27:30 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************ Update institution name in table of institutions ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Ins_UpdateInsNameDB (long InsCod,const char *FieldName,const char *NewInsName)
|
|
|
|
|
{
|
|
|
|
|
/***** Update institution changing old name by new name */
|
2018-11-03 12:16:40 +01:00
|
|
|
|
DB_QueryUPDATE ("can not update the name of an institution",
|
2021-03-07 21:52:56 +01:00
|
|
|
|
"UPDATE ins_instits SET %s='%s' WHERE InsCod=%ld",
|
2018-11-03 12:16:40 +01:00
|
|
|
|
FieldName,NewInsName,InsCod);
|
2017-06-20 14:43:26 +02:00
|
|
|
|
|
|
|
|
|
/***** Flush caches *****/
|
|
|
|
|
Ins_FlushCacheShortNameOfInstitution ();
|
|
|
|
|
Ins_FlushCacheFullNameAndCtyOfInstitution ();
|
2016-10-22 17:27:30 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-20 19:46:06 +02:00
|
|
|
|
/*****************************************************************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/********************** Change the URL of a institution **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Ins_ChangeInsWWW (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_The_new_web_address_is_X;
|
2017-03-07 01:56:41 +01:00
|
|
|
|
char NewWWW[Cns_MAX_BYTES_WWW + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-04 14:48:05 +02:00
|
|
|
|
/***** Institution constructor *****/
|
2019-04-06 20:43:31 +02:00
|
|
|
|
Ins_EditingInstitutionConstructor ();
|
2019-04-04 14:48:05 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get parameters from form *****/
|
|
|
|
|
/* Get the code of the institution */
|
2019-04-06 20:43:31 +02:00
|
|
|
|
Ins_EditingIns->InsCod = Ins_GetAndCheckParamOtherInsCod (1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get the new WWW for the institution */
|
2017-03-07 01:56:41 +01:00
|
|
|
|
Par_GetParToText ("WWW",NewWWW,Cns_MAX_BYTES_WWW);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-03-01 23:58:48 +01:00
|
|
|
|
/***** Get data of institution *****/
|
2020-01-07 00:09:30 +01:00
|
|
|
|
Ins_GetDataOfInstitutionByCod (Ins_EditingIns);
|
2016-03-01 23:58:48 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Check if new WWW is empty *****/
|
|
|
|
|
if (NewWWW[0])
|
|
|
|
|
{
|
2016-10-22 19:49:33 +02:00
|
|
|
|
/***** Update database changing old WWW by new WWW *****/
|
2019-04-06 20:43:31 +02:00
|
|
|
|
Ins_UpdateInsWWWDB (Ins_EditingIns->InsCod,NewWWW);
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (Ins_EditingIns->WWW,NewWWW,sizeof (Ins_EditingIns->WWW) - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-05-11 21:53:37 +02:00
|
|
|
|
/***** Write message to show the change made
|
|
|
|
|
and put button to go to institution changed *****/
|
2019-03-09 20:12:44 +01:00
|
|
|
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
|
|
|
|
Txt_The_new_web_address_is_X,
|
|
|
|
|
NewWWW);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
2019-12-20 00:30:54 +01:00
|
|
|
|
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-22 19:49:33 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************** Update database changing old WWW by new WWW ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-12-29 16:21:42 +01:00
|
|
|
|
void Ins_UpdateInsWWWDB (long InsCod,const char NewWWW[Cns_MAX_BYTES_WWW + 1])
|
2016-10-22 19:49:33 +02:00
|
|
|
|
{
|
|
|
|
|
/***** Update database changing old WWW by new WWW *****/
|
2018-11-03 12:16:40 +01:00
|
|
|
|
DB_QueryUPDATE ("can not update the web of an institution",
|
2021-03-07 21:52:56 +01:00
|
|
|
|
"UPDATE ins_instits SET WWW='%s' WHERE InsCod=%ld",
|
2018-11-03 12:16:40 +01:00
|
|
|
|
NewWWW,InsCod);
|
2016-10-22 19:49:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Change the status of an institution ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Ins_ChangeInsStatus (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_The_status_of_the_institution_X_has_changed;
|
|
|
|
|
Ins_Status_t Status;
|
|
|
|
|
Ins_StatusTxt_t StatusTxt;
|
|
|
|
|
|
2019-04-04 14:48:05 +02:00
|
|
|
|
/***** Institution constructor *****/
|
2019-04-06 20:43:31 +02:00
|
|
|
|
Ins_EditingInstitutionConstructor ();
|
2019-04-04 14:48:05 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get parameters from form *****/
|
|
|
|
|
/* Get institution code */
|
2019-04-06 20:43:31 +02:00
|
|
|
|
Ins_EditingIns->InsCod = Ins_GetAndCheckParamOtherInsCod (1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get parameter with status */
|
2017-01-29 21:41:08 +01:00
|
|
|
|
Status = (Ins_Status_t)
|
|
|
|
|
Par_GetParToUnsignedLong ("Status",
|
|
|
|
|
0,
|
|
|
|
|
(unsigned long) Ins_MAX_STATUS,
|
|
|
|
|
(unsigned long) Ins_WRONG_STATUS);
|
|
|
|
|
if (Status == Ins_WRONG_STATUS)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Lay_ShowErrorAndExit ("Wrong status.");
|
|
|
|
|
StatusTxt = Ins_GetStatusTxtFromStatusBits (Status);
|
|
|
|
|
Status = Ins_GetStatusBitsFromStatusTxt (StatusTxt); // New status
|
|
|
|
|
|
|
|
|
|
/***** Get data of institution *****/
|
2020-01-07 00:09:30 +01:00
|
|
|
|
Ins_GetDataOfInstitutionByCod (Ins_EditingIns);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Update status in table of institutions *****/
|
2018-11-03 12:16:40 +01:00
|
|
|
|
DB_QueryUPDATE ("can not update the status of an institution",
|
2021-03-07 21:52:56 +01:00
|
|
|
|
"UPDATE ins_instits SET Status=%u WHERE InsCod=%ld",
|
2019-04-06 20:43:31 +02:00
|
|
|
|
(unsigned) Status,Ins_EditingIns->InsCod);
|
|
|
|
|
Ins_EditingIns->Status = Status;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-08 15:33:29 +02:00
|
|
|
|
/***** Create message to show the change made
|
2017-05-11 21:53:37 +02:00
|
|
|
|
and put button to go to institution changed *****/
|
2019-03-09 20:12:44 +01:00
|
|
|
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
|
|
|
|
Txt_The_status_of_the_institution_X_has_changed,
|
2019-04-06 20:43:31 +02:00
|
|
|
|
Ins_EditingIns->ShrtName);
|
2019-04-08 15:33:29 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****** Show alerts after changing an institution and continue editing *******/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Ins_ContEditAfterChgIns (void)
|
|
|
|
|
{
|
|
|
|
|
/***** Write message to show the change made
|
|
|
|
|
and put button to go to institution changed *****/
|
2019-04-06 20:43:31 +02:00
|
|
|
|
Ins_ShowAlertAndButtonToGoToIns ();
|
2016-03-01 23:58:48 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Show the form again *****/
|
2019-04-06 20:43:31 +02:00
|
|
|
|
Ins_EditInstitutionsInternal ();
|
2016-03-01 23:58:48 +01:00
|
|
|
|
|
2019-04-06 20:43:31 +02:00
|
|
|
|
/***** Institution destructor *****/
|
|
|
|
|
Ins_EditingInstitutionDestructor ();
|
2016-03-01 23:58:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-05-11 21:53:37 +02:00
|
|
|
|
/*************** Write message to show the change made *****************/
|
|
|
|
|
/*************** and put button to go to institution changed *****************/
|
2016-03-01 23:58:48 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-04-06 20:43:31 +02:00
|
|
|
|
static void Ins_ShowAlertAndButtonToGoToIns (void)
|
2016-03-01 23:58:48 +01:00
|
|
|
|
{
|
2019-04-08 23:34:58 +02:00
|
|
|
|
// If the institution being edited is different to the current one...
|
2019-04-06 20:43:31 +02:00
|
|
|
|
if (Ins_EditingIns->InsCod != Gbl.Hierarchy.Ins.InsCod)
|
2019-04-04 14:48:05 +02:00
|
|
|
|
{
|
2019-04-08 15:33:29 +02:00
|
|
|
|
/***** Alert with button to go to institution *****/
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Ale_ShowLastAlertAndButton (ActSeeCtr,NULL,NULL,
|
2020-04-08 18:18:46 +02:00
|
|
|
|
Ins_PutParamGoToIns,&Ins_EditingIns->InsCod,
|
2019-12-30 12:25:45 +01:00
|
|
|
|
Btn_CONFIRM_BUTTON,
|
|
|
|
|
Hie_BuildGoToMsg (Ins_EditingIns->ShrtName));
|
|
|
|
|
Hie_FreeGoToMsg ();
|
2019-04-04 14:48:05 +02:00
|
|
|
|
}
|
2017-05-11 21:53:37 +02:00
|
|
|
|
else
|
|
|
|
|
/***** Alert *****/
|
2019-03-09 20:12:44 +01:00
|
|
|
|
Ale_ShowAlerts (NULL);
|
2017-05-11 21:53:37 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-08 18:18:46 +02:00
|
|
|
|
static void Ins_PutParamGoToIns (void *InsCod)
|
2017-05-11 21:53:37 +02:00
|
|
|
|
{
|
2020-04-08 18:18:46 +02:00
|
|
|
|
if (InsCod)
|
2020-03-26 02:54:30 +01:00
|
|
|
|
/***** Put parameter *****/
|
2020-04-08 18:18:46 +02:00
|
|
|
|
Ins_PutParamInsCod (*((long *) InsCod));
|
2016-03-01 23:58:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
2015-02-03 18:43:55 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Put a form to create a new institution *******************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-04-06 20:43:31 +02:00
|
|
|
|
static void Ins_PutFormToCreateInstitution (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-04-30 01:20:18 +02:00
|
|
|
|
extern const char *Txt_New_institution;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Create_institution;
|
|
|
|
|
|
2019-10-20 22:00:28 +02:00
|
|
|
|
/***** Begin form *****/
|
2017-06-04 18:18:54 +02:00
|
|
|
|
if (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginForm (ActNewIns);
|
2017-06-04 18:18:54 +02:00
|
|
|
|
else if (Gbl.Usrs.Me.Role.Max >= Rol_GST)
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginForm (ActReqIns);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
2019-10-26 01:56:36 +02:00
|
|
|
|
Lay_NoPermissionExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box and table *****/
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Box_BoxTableBegin (NULL,Txt_New_institution,
|
|
|
|
|
NULL,NULL,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
NULL,Box_NOT_CLOSABLE,2);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write heading *****/
|
|
|
|
|
Ins_PutHeadInstitutionsForEdition ();
|
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 17:36:41 +02:00
|
|
|
|
|
|
|
|
|
/***** Column to remove institution, disabled here *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"BM\"");
|
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Institution code *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"CODE\"");
|
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Institution logo *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("title=\"%s\" class=\"HIE_LOGO\"",Ins_EditingIns->FullName);
|
2021-02-11 22:57:09 +01:00
|
|
|
|
Lgo_DrawLogo (Hie_Lvl_INS,-1L,"",20,NULL,true);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Institution short name *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LM\"");
|
2021-02-11 22:57:09 +01:00
|
|
|
|
HTM_INPUT_TEXT ("ShortName",Cns_HIERARCHY_MAX_CHARS_SHRT_NAME,Ins_EditingIns->ShrtName,
|
2020-04-27 03:16:55 +02:00
|
|
|
|
HTM_DONT_SUBMIT_ON_CHANGE,
|
2019-11-04 09:45:57 +01:00
|
|
|
|
"class=\"INPUT_SHORT_NAME\" required=\"required\"");
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Institution full name *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LM\"");
|
2021-02-11 22:57:09 +01:00
|
|
|
|
HTM_INPUT_TEXT ("FullName",Cns_HIERARCHY_MAX_CHARS_FULL_NAME,Ins_EditingIns->FullName,
|
2020-04-27 03:16:55 +02:00
|
|
|
|
HTM_DONT_SUBMIT_ON_CHANGE,
|
2019-11-04 09:45:57 +01:00
|
|
|
|
"class=\"INPUT_FULL_NAME\" required=\"required\"");
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Institution WWW *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LM\"");
|
2020-04-27 03:16:55 +02:00
|
|
|
|
HTM_INPUT_URL ("WWW",Ins_EditingIns->WWW,HTM_DONT_SUBMIT_ON_CHANGE,
|
2019-12-19 11:00:14 +01:00
|
|
|
|
"class=\"INPUT_WWW_NARROW\" required=\"required\"");
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2015-12-14 16:44:14 +01:00
|
|
|
|
/***** Number of users who claim to belong to this institution ****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT RM\"");
|
2019-11-10 13:51:07 +01:00
|
|
|
|
HTM_Unsigned (0);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Number of centers *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT RM\"");
|
2019-11-10 13:51:07 +01:00
|
|
|
|
HTM_Unsigned (0);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2015-12-14 16:44:14 +01:00
|
|
|
|
/***** Number of users in courses of this institution ****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT RM\"");
|
2019-11-10 13:51:07 +01:00
|
|
|
|
HTM_Unsigned (0);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2015-12-14 16:44:14 +01:00
|
|
|
|
|
2015-12-05 21:15:30 +01:00
|
|
|
|
/***** Institution requester *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT INPUT_REQUESTER LT\"");
|
2017-05-02 01:16:06 +02:00
|
|
|
|
Msg_WriteMsgAuthor (&Gbl.Usrs.Me.UsrDat,true,NULL);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2017-03-17 00:46:28 +01:00
|
|
|
|
|
|
|
|
|
/***** Institution status *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT LM\"");
|
|
|
|
|
HTM_TD_End ();
|
2019-10-07 17:36:41 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End table, send button and end box *****/
|
2019-11-25 23:18:08 +01:00
|
|
|
|
Box_BoxTableWithButtonEnd (Btn_CREATE_BUTTON,Txt_Create_institution);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-04-30 02:35:25 +02:00
|
|
|
|
/***** End form *****/
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************** Write header with fields of an institution *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Ins_PutHeadInstitutionsForEdition (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Code;
|
2016-03-02 14:53:46 +01:00
|
|
|
|
extern const char *Txt_Short_name_of_the_institution;
|
|
|
|
|
extern const char *Txt_Full_name_of_the_institution;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_WWW;
|
|
|
|
|
extern const char *Txt_Users;
|
2021-03-07 21:21:04 +01:00
|
|
|
|
extern const char *Txt_Centers_ABBREVIATION;
|
2017-05-30 21:43:05 +02:00
|
|
|
|
extern const char *Txt_ROLES_PLURAL_BRIEF_Abc[Rol_NUM_ROLES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Requester;
|
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
|
|
|
|
|
HTM_TH_Empty (1);
|
|
|
|
|
HTM_TH (1,1,"RM",Txt_Code);
|
|
|
|
|
HTM_TH_Empty (1);
|
|
|
|
|
HTM_TH (1,1,"LM",Txt_Short_name_of_the_institution);
|
|
|
|
|
HTM_TH (1,1,"LM",Txt_Full_name_of_the_institution);
|
|
|
|
|
HTM_TH (1,1,"LM",Txt_WWW);
|
|
|
|
|
HTM_TH (1,1,"RM",Txt_Users);
|
2021-03-07 21:21:04 +01:00
|
|
|
|
HTM_TH (1,1,"RM",Txt_Centers_ABBREVIATION);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TH_Begin (1,1,"RM");
|
2019-11-11 00:15:44 +01:00
|
|
|
|
HTM_TxtF ("%s+",Txt_ROLES_PLURAL_BRIEF_Abc[Rol_TCH]);
|
2019-11-09 21:08:20 +01:00
|
|
|
|
HTM_BR ();
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (Txt_ROLES_PLURAL_BRIEF_Abc[Rol_STD]);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TH_End ();
|
|
|
|
|
HTM_TH (1,1,"LM",Txt_Requester);
|
|
|
|
|
HTM_TH_Empty (1);
|
2019-10-12 00:07:52 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Receive form to request a new institution *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-05-05 21:49:00 +02:00
|
|
|
|
void Ins_ReceiveFormReqIns (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-04-04 14:48:05 +02:00
|
|
|
|
/***** Institution constructor *****/
|
2019-04-06 20:43:31 +02:00
|
|
|
|
Ins_EditingInstitutionConstructor ();
|
2019-04-04 14:48:05 +02:00
|
|
|
|
|
|
|
|
|
/***** Receive form to request a new institution *****/
|
2020-05-05 21:49:00 +02:00
|
|
|
|
Ins_ReceiveFormRequestOrCreateIns ((unsigned) Ins_STATUS_BIT_PENDING);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Receive form to create a new institution ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-05-05 21:49:00 +02:00
|
|
|
|
void Ins_ReceiveFormNewIns (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-04-04 14:48:05 +02:00
|
|
|
|
/***** Institution constructor *****/
|
2019-04-06 20:43:31 +02:00
|
|
|
|
Ins_EditingInstitutionConstructor ();
|
2019-04-04 14:48:05 +02:00
|
|
|
|
|
|
|
|
|
/***** Receive form to create a new institution *****/
|
2020-05-05 21:49:00 +02:00
|
|
|
|
Ins_ReceiveFormRequestOrCreateIns (0);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********** Receive form to request or create a new institution *************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-05-05 21:49:00 +02:00
|
|
|
|
static void Ins_ReceiveFormRequestOrCreateIns (unsigned Status)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_The_institution_X_already_exists;
|
2019-04-08 15:33:29 +02:00
|
|
|
|
extern const char *Txt_Created_new_institution_X;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_You_must_specify_the_web_address_of_the_new_institution;
|
|
|
|
|
extern const char *Txt_You_must_specify_the_short_name_and_the_full_name_of_the_new_institution;
|
|
|
|
|
|
|
|
|
|
/***** Get parameters from form *****/
|
|
|
|
|
/* Set institution country */
|
2019-04-06 20:43:31 +02:00
|
|
|
|
Ins_EditingIns->CtyCod = Gbl.Hierarchy.Cty.CtyCod;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get institution short name */
|
2021-02-11 22:57:09 +01:00
|
|
|
|
Par_GetParToText ("ShortName",Ins_EditingIns->ShrtName,Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get institution full name */
|
2021-02-11 22:57:09 +01:00
|
|
|
|
Par_GetParToText ("FullName",Ins_EditingIns->FullName,Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get institution WWW */
|
2019-04-06 20:43:31 +02:00
|
|
|
|
Par_GetParToText ("WWW",Ins_EditingIns->WWW,Cns_MAX_BYTES_WWW);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-06 20:43:31 +02:00
|
|
|
|
if (Ins_EditingIns->ShrtName[0] &&
|
|
|
|
|
Ins_EditingIns->FullName[0]) // If there's a institution name
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-04-06 20:43:31 +02:00
|
|
|
|
if (Ins_EditingIns->WWW[0])
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** If name of institution was in database... *****/
|
2019-04-06 20:43:31 +02:00
|
|
|
|
if (Ins_CheckIfInsNameExistsInCty ("ShortName",Ins_EditingIns->ShrtName,
|
|
|
|
|
-1L,Gbl.Hierarchy.Cty.CtyCod))
|
2019-04-08 15:33:29 +02:00
|
|
|
|
Ale_CreateAlert (Ale_WARNING,NULL,
|
|
|
|
|
Txt_The_institution_X_already_exists,
|
|
|
|
|
Ins_EditingIns->ShrtName);
|
2019-04-06 20:43:31 +02:00
|
|
|
|
else if (Ins_CheckIfInsNameExistsInCty ("FullName",Ins_EditingIns->FullName,
|
|
|
|
|
-1L,Gbl.Hierarchy.Cty.CtyCod))
|
2019-04-08 15:33:29 +02:00
|
|
|
|
Ale_CreateAlert (Ale_WARNING,NULL,
|
|
|
|
|
Txt_The_institution_X_already_exists,
|
|
|
|
|
Ins_EditingIns->FullName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else // Add new institution to database
|
2019-04-08 15:33:29 +02:00
|
|
|
|
{
|
2019-04-06 20:43:31 +02:00
|
|
|
|
Ins_CreateInstitution (Status);
|
2019-04-08 15:33:29 +02:00
|
|
|
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
|
|
|
|
Txt_Created_new_institution_X,
|
|
|
|
|
Ins_EditingIns->FullName);
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2015-01-17 13:31:25 +01:00
|
|
|
|
else // If there is not a web
|
2019-04-08 15:33:29 +02:00
|
|
|
|
Ale_CreateAlert (Ale_WARNING,NULL,
|
|
|
|
|
Txt_You_must_specify_the_web_address_of_the_new_institution);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else // If there is not a institution name
|
2019-04-08 15:33:29 +02:00
|
|
|
|
Ale_CreateAlert (Ale_WARNING,NULL,
|
|
|
|
|
Txt_You_must_specify_the_short_name_and_the_full_name_of_the_new_institution);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Create a new institution *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-04-06 20:43:31 +02:00
|
|
|
|
static void Ins_CreateInstitution (unsigned Status)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Create a new institution *****/
|
2019-04-06 20:43:31 +02:00
|
|
|
|
Ins_EditingIns->InsCod =
|
2018-11-03 01:45:36 +01:00
|
|
|
|
DB_QueryINSERTandReturnCode ("can not create institution",
|
2021-03-07 21:52:56 +01:00
|
|
|
|
"INSERT INTO ins_instits"
|
2018-11-03 01:45:36 +01:00
|
|
|
|
" (CtyCod,Status,RequesterUsrCod,ShortName,FullName,WWW)"
|
|
|
|
|
" VALUES"
|
|
|
|
|
" (%ld,%u,%ld,'%s','%s','%s')",
|
2019-04-06 20:43:31 +02:00
|
|
|
|
Ins_EditingIns->CtyCod,
|
2018-11-03 01:45:36 +01:00
|
|
|
|
Status,
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
2019-04-06 20:43:31 +02:00
|
|
|
|
Ins_EditingIns->ShrtName,
|
|
|
|
|
Ins_EditingIns->FullName,
|
|
|
|
|
Ins_EditingIns->WWW);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Get total number of institutions **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-05-03 20:58:03 +02:00
|
|
|
|
unsigned Ins_GetCachedNumInssInSys (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-05-03 20:58:03 +02:00
|
|
|
|
unsigned NumInss;
|
|
|
|
|
|
|
|
|
|
/***** Get number of institutions from cache *****/
|
2021-02-11 22:57:09 +01:00
|
|
|
|
if (!FigCch_GetFigureFromCache (FigCch_NUM_INSS,Hie_Lvl_SYS,-1L,
|
2020-05-03 20:58:03 +02:00
|
|
|
|
FigCch_UNSIGNED,&NumInss))
|
|
|
|
|
{
|
|
|
|
|
/***** Get current number of institutions from database and update cache *****/
|
2021-03-07 21:52:56 +01:00
|
|
|
|
NumInss = (unsigned) DB_GetNumRowsTable ("ins_instits");
|
2021-02-11 22:57:09 +01:00
|
|
|
|
FigCch_UpdateFigureIntoCache (FigCch_NUM_INSS,Hie_Lvl_SYS,-1L,
|
2020-05-03 20:58:03 +02:00
|
|
|
|
FigCch_UNSIGNED,&NumInss);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NumInss;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************** Get number of institutions in a country ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-01-07 00:42:24 +01:00
|
|
|
|
void Ins_FlushCacheNumInssInCty (void)
|
|
|
|
|
{
|
|
|
|
|
Gbl.Cache.NumInssInCty.Valid = false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned Ins_GetNumInssInCty (long CtyCod)
|
|
|
|
|
{
|
2020-01-07 00:42:24 +01:00
|
|
|
|
/***** 1. Fast check: If cached... *****/
|
|
|
|
|
if (Gbl.Cache.NumInssInCty.Valid &&
|
|
|
|
|
CtyCod == Gbl.Cache.NumInssInCty.CtyCod)
|
|
|
|
|
return Gbl.Cache.NumInssInCty.NumInss;
|
|
|
|
|
|
|
|
|
|
/***** 2. Slow: number of institutions in a country from database *****/
|
|
|
|
|
Gbl.Cache.NumInssInCty.CtyCod = CtyCod;
|
|
|
|
|
Gbl.Cache.NumInssInCty.NumInss =
|
2018-11-03 20:52:00 +01:00
|
|
|
|
(unsigned) DB_QueryCOUNT ("can not get the number of institutions"
|
|
|
|
|
" in a country",
|
2021-03-07 21:52:56 +01:00
|
|
|
|
"SELECT COUNT(*) FROM ins_instits"
|
2018-11-03 20:52:00 +01:00
|
|
|
|
" WHERE CtyCod=%ld",
|
|
|
|
|
CtyCod);
|
2020-01-07 00:42:24 +01:00
|
|
|
|
Gbl.Cache.NumInssInCty.Valid = true;
|
2021-02-11 22:57:09 +01:00
|
|
|
|
FigCch_UpdateFigureIntoCache (FigCch_NUM_INSS,Hie_Lvl_CTY,Gbl.Cache.NumInssInCty.CtyCod,
|
2020-05-03 21:56:55 +02:00
|
|
|
|
FigCch_UNSIGNED,&Gbl.Cache.NumInssInCty.NumInss);
|
2020-01-07 00:42:24 +01:00
|
|
|
|
return Gbl.Cache.NumInssInCty.NumInss;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-03 20:58:03 +02:00
|
|
|
|
unsigned Ins_GetCachedNumInssInCty (long CtyCod)
|
|
|
|
|
{
|
|
|
|
|
unsigned NumInss;
|
|
|
|
|
|
|
|
|
|
/***** Get number of institutions from cache *****/
|
2021-02-11 22:57:09 +01:00
|
|
|
|
if (!FigCch_GetFigureFromCache (FigCch_NUM_INSS,Hie_Lvl_CTY,CtyCod,
|
2020-05-03 20:58:03 +02:00
|
|
|
|
FigCch_UNSIGNED,&NumInss))
|
|
|
|
|
/***** Get current number of institutions from database and update cache *****/
|
|
|
|
|
NumInss = Ins_GetNumInssInCty (CtyCod);
|
|
|
|
|
|
|
|
|
|
return NumInss;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***************** Get number of institutions with centers *******************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-05-03 20:58:03 +02:00
|
|
|
|
unsigned Ins_GetCachedNumInssWithCtrs (const char *SubQuery,
|
2021-02-11 22:57:09 +01:00
|
|
|
|
Hie_Lvl_Level_t Scope,long Cod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-05-03 20:58:03 +02:00
|
|
|
|
unsigned NumInssWithCtrs;
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get number of institutions with centers from cache *****/
|
2020-05-03 20:58:03 +02:00
|
|
|
|
if (!FigCch_GetFigureFromCache (FigCch_NUM_INSS_WITH_CTRS,Scope,Cod,
|
|
|
|
|
FigCch_UNSIGNED,&NumInssWithCtrs))
|
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get current number of institutions with centers from database and update cache *****/
|
2020-05-03 20:58:03 +02:00
|
|
|
|
NumInssWithCtrs = (unsigned)
|
2021-03-07 21:21:04 +01:00
|
|
|
|
DB_QueryCOUNT ("can not get number of institutions with centers",
|
2021-03-07 21:52:56 +01:00
|
|
|
|
"SELECT COUNT(DISTINCT ins_instits.InsCod)"
|
|
|
|
|
" FROM ins_instits,"
|
2021-03-07 21:21:04 +01:00
|
|
|
|
"ctr_centers"
|
|
|
|
|
" WHERE %sinstitutions.InsCod=ctr_centers.InsCod",
|
|
|
|
|
SubQuery);
|
2020-05-03 20:58:03 +02:00
|
|
|
|
FigCch_UpdateFigureIntoCache (FigCch_NUM_INSS_WITH_CTRS,Scope,Cod,
|
|
|
|
|
FigCch_UNSIGNED,&NumInssWithCtrs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NumInssWithCtrs;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Get number of institutions with degrees ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-05-03 20:58:03 +02:00
|
|
|
|
unsigned Ins_GetCachedNumInssWithDegs (const char *SubQuery,
|
2021-02-11 22:57:09 +01:00
|
|
|
|
Hie_Lvl_Level_t Scope,long Cod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-05-03 20:58:03 +02:00
|
|
|
|
unsigned NumInssWithDegs;
|
|
|
|
|
|
|
|
|
|
/***** Get number of institutions with degrees from cache *****/
|
|
|
|
|
if (!FigCch_GetFigureFromCache (FigCch_NUM_INSS_WITH_DEGS,Scope,Cod,
|
|
|
|
|
FigCch_UNSIGNED,&NumInssWithDegs))
|
|
|
|
|
{
|
|
|
|
|
/***** Get current number of institutions with degrees from database and update cache *****/
|
|
|
|
|
NumInssWithDegs = (unsigned)
|
2021-03-07 21:21:04 +01:00
|
|
|
|
DB_QueryCOUNT ("can not get number of institutions with degrees",
|
2021-03-07 21:52:56 +01:00
|
|
|
|
"SELECT COUNT(DISTINCT ins_instits.InsCod)"
|
|
|
|
|
" FROM ins_instits,"
|
2021-03-07 21:21:04 +01:00
|
|
|
|
"ctr_centers,"
|
|
|
|
|
"deg_degrees"
|
|
|
|
|
" WHERE %sinstitutions.InsCod=ctr_centers.InsCod"
|
|
|
|
|
" AND ctr_centers.CtrCod=deg_degrees.CtrCod",
|
|
|
|
|
SubQuery);
|
2020-05-03 20:58:03 +02:00
|
|
|
|
FigCch_UpdateFigureIntoCache (FigCch_NUM_INSS_WITH_DEGS,Scope,Cod,
|
|
|
|
|
FigCch_UNSIGNED,&NumInssWithDegs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NumInssWithDegs;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Get number of institutions with courses ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-05-03 20:58:03 +02:00
|
|
|
|
unsigned Ins_GetCachedNumInssWithCrss (const char *SubQuery,
|
2021-02-11 22:57:09 +01:00
|
|
|
|
Hie_Lvl_Level_t Scope,long Cod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-05-03 20:58:03 +02:00
|
|
|
|
unsigned NumInssWithCrss;
|
|
|
|
|
|
|
|
|
|
/***** Get number of institutions with courses from cache *****/
|
|
|
|
|
if (!FigCch_GetFigureFromCache (FigCch_NUM_INSS_WITH_CRSS,Scope,Cod,
|
|
|
|
|
FigCch_UNSIGNED,&NumInssWithCrss))
|
|
|
|
|
{
|
|
|
|
|
/***** Get current number of institutions with courses from database and update cache *****/
|
|
|
|
|
NumInssWithCrss = (unsigned)
|
2021-03-07 17:45:36 +01:00
|
|
|
|
DB_QueryCOUNT ("can not get number of institutions with courses",
|
2021-03-07 21:52:56 +01:00
|
|
|
|
"SELECT COUNT(DISTINCT ins_instits.InsCod)"
|
|
|
|
|
" FROM ins_instits,"
|
2021-03-07 21:21:04 +01:00
|
|
|
|
"ctr_centers,"
|
2021-03-07 17:45:36 +01:00
|
|
|
|
"deg_degrees,"
|
|
|
|
|
"crs_courses"
|
2021-03-07 21:21:04 +01:00
|
|
|
|
" WHERE %sinstitutions.InsCod=ctr_centers.InsCod"
|
|
|
|
|
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
2021-03-07 17:45:36 +01:00
|
|
|
|
" AND deg_degrees.DegCod=crs_courses.DegCod",
|
|
|
|
|
SubQuery);
|
2020-05-03 20:58:03 +02:00
|
|
|
|
FigCch_UpdateFigureIntoCache (FigCch_NUM_INSS_WITH_CRSS,Scope,Cod,
|
|
|
|
|
FigCch_UNSIGNED,&NumInssWithCrss);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NumInssWithCrss;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Get number of institutions with users ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-05-03 20:58:03 +02:00
|
|
|
|
unsigned Ins_GetCachedNumInssWithUsrs (Rol_Role_t Role,const char *SubQuery,
|
2021-02-11 22:57:09 +01:00
|
|
|
|
Hie_Lvl_Level_t Scope,long Cod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-05-03 20:58:03 +02:00
|
|
|
|
static const FigCch_FigureCached_t FigureInss[Rol_NUM_ROLES] =
|
|
|
|
|
{
|
|
|
|
|
[Rol_STD] = FigCch_NUM_INSS_WITH_STDS, // Students
|
|
|
|
|
[Rol_NET] = FigCch_NUM_INSS_WITH_NETS, // Non-editing teachers
|
|
|
|
|
[Rol_TCH] = FigCch_NUM_INSS_WITH_TCHS, // Teachers
|
|
|
|
|
};
|
|
|
|
|
unsigned NumInssWithUsrs;
|
|
|
|
|
|
|
|
|
|
/***** Get number of institutions with users from cache *****/
|
|
|
|
|
if (!FigCch_GetFigureFromCache (FigureInss[Role],Scope,Cod,
|
|
|
|
|
FigCch_UNSIGNED,&NumInssWithUsrs))
|
|
|
|
|
{
|
|
|
|
|
/***** Get current number of institutions with users from database and update cache *****/
|
|
|
|
|
NumInssWithUsrs = (unsigned)
|
2021-03-07 17:45:36 +01:00
|
|
|
|
DB_QueryCOUNT ("can not get number of institutions with users",
|
2021-03-07 21:52:56 +01:00
|
|
|
|
"SELECT COUNT(DISTINCT ins_instits.InsCod)"
|
|
|
|
|
" FROM ins_instits,"
|
2021-03-07 21:21:04 +01:00
|
|
|
|
"ctr_centers,"
|
2021-03-07 17:45:36 +01:00
|
|
|
|
"deg_degrees,"
|
|
|
|
|
"crs_courses,"
|
|
|
|
|
"crs_usr"
|
2021-03-07 21:21:04 +01:00
|
|
|
|
" WHERE %sinstitutions.InsCod=ctr_centers.InsCod"
|
|
|
|
|
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
2021-03-07 17:45:36 +01:00
|
|
|
|
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
|
|
|
|
" AND crs_courses.CrsCod=crs_usr.CrsCod"
|
|
|
|
|
" AND crs_usr.Role=%u",
|
|
|
|
|
SubQuery,(unsigned) Role);
|
2020-05-03 20:58:03 +02:00
|
|
|
|
FigCch_UpdateFigureIntoCache (FigureInss[Role],Scope,Cod,
|
|
|
|
|
FigCch_UNSIGNED,&NumInssWithUsrs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NumInssWithUsrs;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************************** List institutions found *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2018-10-31 16:16:57 +01:00
|
|
|
|
void Ins_ListInssFound (MYSQL_RES **mysql_res,unsigned NumInss)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_institution;
|
|
|
|
|
extern const char *Txt_institutions;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumIns;
|
2021-02-11 00:58:53 +01:00
|
|
|
|
struct Ins_Instit Ins;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2018-10-31 16:16:57 +01:00
|
|
|
|
/***** List the institutions (one row per institution) *****/
|
|
|
|
|
if (NumInss)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box and table *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/* Number of institutions found */
|
2019-12-30 21:47:07 +01:00
|
|
|
|
Box_BoxTableBegin (NULL,Str_BuildStringLongStr ((long) NumInss,
|
|
|
|
|
NumInss == 1 ? Txt_institution :
|
|
|
|
|
Txt_institutions),
|
2020-03-26 02:54:30 +01:00
|
|
|
|
NULL,NULL,
|
|
|
|
|
NULL,Box_NOT_CLOSABLE,2);
|
2019-12-30 21:47:07 +01:00
|
|
|
|
Str_FreeString ();
|
2017-06-12 14:16:33 +02:00
|
|
|
|
|
|
|
|
|
/***** Write heading *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Ins_PutHeadInstitutionsForSeeing (false); // Order not selectable
|
|
|
|
|
|
2017-02-28 00:59:01 +01:00
|
|
|
|
/***** List the institutions (one row per institution) *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
for (NumIns = 1;
|
|
|
|
|
NumIns <= NumInss;
|
|
|
|
|
NumIns++)
|
|
|
|
|
{
|
|
|
|
|
/* Get next institution */
|
2018-10-31 16:16:57 +01:00
|
|
|
|
row = mysql_fetch_row (*mysql_res);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get institution code (row[0]) */
|
|
|
|
|
Ins.InsCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
|
|
|
|
|
|
|
|
/* Get data of institution */
|
2020-01-07 00:09:30 +01:00
|
|
|
|
Ins_GetDataOfInstitutionByCod (&Ins);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-02-28 00:59:01 +01:00
|
|
|
|
/* Write data of this institution */
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Ins_ListOneInstitutionForSeeing (&Ins,NumIns);
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End table and box *****/
|
2019-11-25 23:18:08 +01:00
|
|
|
|
Box_BoxTableEnd ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
2018-10-31 16:16:57 +01:00
|
|
|
|
DB_FreeMySQLResult (mysql_res);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2019-04-04 14:48:05 +02:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Institution constructor/destructor *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-04-06 20:43:31 +02:00
|
|
|
|
static void Ins_EditingInstitutionConstructor (void)
|
2019-04-04 14:48:05 +02:00
|
|
|
|
{
|
2019-04-06 21:39:35 +02:00
|
|
|
|
/***** Pointer must be NULL *****/
|
2019-04-06 20:43:31 +02:00
|
|
|
|
if (Ins_EditingIns != NULL)
|
2019-04-06 21:39:35 +02:00
|
|
|
|
Lay_ShowErrorAndExit ("Error initializing institution.");
|
2019-04-04 14:48:05 +02:00
|
|
|
|
|
|
|
|
|
/***** Allocate memory for institution *****/
|
2021-02-15 16:25:55 +01:00
|
|
|
|
if ((Ins_EditingIns = malloc (sizeof (*Ins_EditingIns))) == NULL)
|
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
2019-04-04 14:48:05 +02:00
|
|
|
|
|
|
|
|
|
/***** Reset institution *****/
|
2019-06-13 10:14:05 +02:00
|
|
|
|
Ins_EditingIns->InsCod = -1L;
|
|
|
|
|
Ins_EditingIns->CtyCod = -1L;
|
|
|
|
|
Ins_EditingIns->ShrtName[0] = '\0';
|
|
|
|
|
Ins_EditingIns->FullName[0] = '\0';
|
|
|
|
|
Ins_EditingIns->WWW[0] = '\0';
|
2019-04-06 20:43:31 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void Ins_EditingInstitutionDestructor (void)
|
2019-04-04 14:48:05 +02:00
|
|
|
|
{
|
|
|
|
|
/***** Free memory used for institution *****/
|
2019-04-06 20:43:31 +02:00
|
|
|
|
if (Ins_EditingIns != NULL)
|
2019-04-04 14:48:05 +02:00
|
|
|
|
{
|
2019-11-06 19:45:20 +01:00
|
|
|
|
free (Ins_EditingIns);
|
2019-04-06 20:43:31 +02:00
|
|
|
|
Ins_EditingIns = NULL;
|
2019-04-04 14:48:05 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-01-09 15:36:12 +01:00
|
|
|
|
|
2020-01-14 09:18:06 +01:00
|
|
|
|
/*****************************************************************************/
|
2020-01-14 13:30:18 +01:00
|
|
|
|
/********************* Form to go to institution map *************************/
|
2020-01-14 09:18:06 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-02-11 00:58:53 +01:00
|
|
|
|
static void Ins_FormToGoToMap (struct Ins_Instit *Ins)
|
2020-01-14 09:18:06 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Map;
|
|
|
|
|
|
|
|
|
|
if (Ins_GetIfMapIsAvailable (Ins->InsCod))
|
|
|
|
|
{
|
|
|
|
|
Ins_EditingIns = Ins; // Used to pass parameter with the code of the institution
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Lay_PutContextualLinkOnlyIcon (ActSeeInsInf,NULL,
|
2020-04-08 18:18:46 +02:00
|
|
|
|
Ins_PutParamGoToIns,&Ins_EditingIns->InsCod,
|
2020-01-14 09:18:06 +01:00
|
|
|
|
"map-marker-alt.svg",
|
|
|
|
|
Txt_Map);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-09 15:36:12 +01:00
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/********** Check if any of the centers in an institution has map ************/
|
2020-01-09 15:36:12 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
bool Ins_GetIfMapIsAvailable (long InsCod)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
bool MapIsAvailable = false;
|
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get if any center in current institution has a coordinate set
|
2020-01-09 15:36:12 +01:00
|
|
|
|
(coordinates 0, 0 means not set ==> don't show map) *****/
|
|
|
|
|
if (DB_QuerySELECT (&mysql_res,"can not get if map is available",
|
|
|
|
|
"SELECT EXISTS"
|
2021-03-07 21:21:04 +01:00
|
|
|
|
"(SELECT * FROM ctr_centers"
|
2020-01-09 15:36:12 +01:00
|
|
|
|
" WHERE InsCod=%ld"
|
|
|
|
|
" AND (Latitude<>0 OR Longitude<>0))",
|
|
|
|
|
InsCod))
|
|
|
|
|
{
|
|
|
|
|
/* Get if map is available */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
MapIsAvailable = (row[0][0] == '1');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Free structure that stores the query result */
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
return MapIsAvailable;
|
|
|
|
|
}
|