Version 20.88: Jun 02, 2021 New module swad_center_database for database queries related to centers.

This commit is contained in:
acanas 2021-06-02 00:08:30 +02:00
parent 9ea5a0eeec
commit 17c04cc470
10 changed files with 854 additions and 735 deletions

View File

@ -33,11 +33,12 @@ OBJS = swad_account.o swad_account_database.o swad_action.o swad_agenda.o \
swad_banner.o swad_banner_database.o swad_box.o swad_building.o \ swad_banner.o swad_banner_database.o swad_box.o swad_building.o \
swad_building_database.o swad_button.o \ swad_building_database.o swad_button.o \
swad_calendar.o swad_call_for_exam.o swad_call_for_exam_database.o \ swad_calendar.o swad_call_for_exam.o swad_call_for_exam_database.o \
swad_center.o swad_center_config.o swad_chat.o swad_chat_database.o \ swad_center.o swad_center_config.o swad_center_database.o swad_chat.o \
swad_config.o swad_connected.o swad_connected_database.o swad_cookie.o \ swad_chat_database.o swad_config.o swad_connected.o \
swad_cookie_database.o swad_country.o swad_country_config.o \ swad_connected_database.o swad_cookie.o swad_cookie_database.o \
swad_country_database.o swad_course.o swad_course_config.o \ swad_country.o swad_country_config.o swad_country_database.o \
swad_course_database.o swad_cryptography.o \ swad_course.o swad_course_config.o swad_course_database.o \
swad_cryptography.o \
swad_database.o swad_date.o swad_degree.o swad_degree_config.o \ swad_database.o swad_date.o swad_degree.o swad_degree_config.o \
swad_degree_database.o swad_degree_type.o swad_department.o \ swad_degree_database.o swad_degree_type.o swad_department.o \
swad_duplicate.o \ swad_duplicate.o \

View File

@ -25,17 +25,9 @@
/********************************** Headers **********************************/ /********************************** Headers **********************************/
/*****************************************************************************/ /*****************************************************************************/
// #include <malloc.h> // For calloc, free
// #include <stddef.h> // For NULL
// #include <string.h> // For string functions
// #include "swad_box.h"
#include "swad_building.h" #include "swad_building.h"
#include "swad_database.h" #include "swad_database.h"
// #include "swad_error.h"
// #include "swad_form.h"
#include "swad_global.h" #include "swad_global.h"
// #include "swad_HTML.h"
/*****************************************************************************/ /*****************************************************************************/
/************** External global variables from others modules ****************/ /************** External global variables from others modules ****************/

View File

@ -30,7 +30,6 @@
#include <mysql/mysql.h> // To access MySQL databases #include <mysql/mysql.h> // To access MySQL databases
#include "swad_building.h" #include "swad_building.h"
// #include "swad_string.h"
/*****************************************************************************/ /*****************************************************************************/
/************************** Public types and constants ***********************/ /************************** Public types and constants ***********************/

File diff suppressed because it is too large Load Diff

View File

@ -118,14 +118,14 @@ void Ctr_PutParamCtrCod (long CtrCod);
long Ctr_GetAndCheckParamOtherCtrCod (long MinCodAllowed); long Ctr_GetAndCheckParamOtherCtrCod (long MinCodAllowed);
void Ctr_RemoveCenter (void); void Ctr_RemoveCenter (void);
void Ctr_ChangeCtrPlc (void); void Ctr_ChangeCtrPlc (void);
void Ctr_UpdateCtrPlcDB (long CtrCod,long NewPlcCod); void Ctr_DB_UpdateCtrPlc (long CtrCod,long NewPlcCod);
void Ctr_RenameCenterShort (void); void Ctr_RenameCenterShort (void);
void Ctr_RenameCenterFull (void); void Ctr_RenameCenterFull (void);
void Ctr_RenameCenter (struct Ctr_Center *Ctr,Cns_ShrtOrFullName_t ShrtOrFullName); void Ctr_RenameCenter (struct Ctr_Center *Ctr,Cns_ShrtOrFullName_t ShrtOrFullName);
bool Ctr_CheckIfCtrNameExistsInIns (const char *FieldName,const char *Name, bool Ctr_DB_CheckIfCtrNameExistsInIns (const char *FieldName,const char *Name,
long CtrCod,long InsCod); long CtrCod,long InsCod);
void Ctr_ChangeCtrWWW (void); void Ctr_ChangeCtrWWW (void);
void Ctr_UpdateCtrWWWDB (long CtrCod,const char NewWWW[Cns_MAX_BYTES_WWW + 1]); void Ctr_DB_UpdateCtrWWW (long CtrCod,const char NewWWW[Cns_MAX_BYTES_WWW + 1]);
void Ctr_ChangeCtrStatus (void); void Ctr_ChangeCtrStatus (void);
void Ctr_ContEditAfterChgCtr (void); void Ctr_ContEditAfterChgCtr (void);
@ -145,7 +145,7 @@ unsigned Ctr_GetCachedNumCtrsWithMapInSys (void);
unsigned Ctr_GetCachedNumCtrsWithMapInCty (long CtyCod); unsigned Ctr_GetCachedNumCtrsWithMapInCty (long CtyCod);
unsigned Ctr_GetCachedNumCtrsWithMapInIns (long InsCod); unsigned Ctr_GetCachedNumCtrsWithMapInIns (long InsCod);
unsigned Ctr_GetNumCtrsInPlc (long PlcCod); unsigned Ctr_DB_GetNumCtrsInPlc (long PlcCod);
unsigned Ctr_GetCachedNumCtrsWithDegs (const char *SubQuery, unsigned Ctr_GetCachedNumCtrsWithDegs (const char *SubQuery,
HieLvl_Level_t Scope,long Cod); HieLvl_Level_t Scope,long Cod);

View File

@ -101,7 +101,7 @@ static void CtrCfg_NumUsrs (void);
static void CtrCfg_NumDegs (void); static void CtrCfg_NumDegs (void);
static void CtrCfg_NumCrss (void); static void CtrCfg_NumCrss (void);
static void CtrCfg_UpdateCtrInsDB (long CtrCod,long InsCod); static void Ctr_DB_UpdateCtrIns (long CtrCod,long InsCod);
static void CtrCfg_UpdateCtrCoordinateDB (long CtrCod, static void CtrCfg_UpdateCtrCoordinateDB (long CtrCod,
const char *CoordField,double NewCoord); const char *CoordField,double NewCoord);
@ -173,54 +173,54 @@ static void CtrCfg_Configuration (bool PrintView)
/**************************** Left part ***********************************/ /**************************** Left part ***********************************/
HTM_DIV_Begin ("class=\"HIE_CFG_LEFT HIE_CFG_WIDTH\""); HTM_DIV_Begin ("class=\"HIE_CFG_LEFT HIE_CFG_WIDTH\"");
/***** Begin table *****/ /***** Begin table *****/
HTM_TABLE_BeginWidePadding (2); HTM_TABLE_BeginWidePadding (2);
/***** Institution *****/ /***** Institution *****/
CtrCfg_Institution (PrintView,PutFormIns); CtrCfg_Institution (PrintView,PutFormIns);
/***** Center name *****/ /***** Center name *****/
CtrCfg_FullName (PutFormName); CtrCfg_FullName (PutFormName);
CtrCfg_ShrtName (PutFormName); CtrCfg_ShrtName (PutFormName);
/***** Place *****/ /***** Place *****/
CtrCfg_Place (PutFormPlc); CtrCfg_Place (PutFormPlc);
/***** Coordinates *****/ /***** Coordinates *****/
if (PutFormCoor) if (PutFormCoor)
{ {
CtrCfg_Latitude (); CtrCfg_Latitude ();
CtrCfg_Longitude (); CtrCfg_Longitude ();
CtrCfg_Altitude (); CtrCfg_Altitude ();
} }
/***** Center WWW *****/ /***** Center WWW *****/
CtrCfg_WWW (PrintView,PutFormWWW); CtrCfg_WWW (PrintView,PutFormWWW);
/***** Shortcut to the center *****/ /***** Shortcut to the center *****/
CtrCfg_Shortcut (PrintView); CtrCfg_Shortcut (PrintView);
if (PrintView) if (PrintView)
/***** QR code with link to the center *****/ /***** QR code with link to the center *****/
CtrCfg_QR (); CtrCfg_QR ();
else else
{ {
/***** Number of users who claim to belong to this center, /***** Number of users who claim to belong to this center,
number of degrees, number of degrees,
number of courses *****/ number of courses *****/
CtrCfg_NumUsrs (); CtrCfg_NumUsrs ();
CtrCfg_NumDegs (); CtrCfg_NumDegs ();
CtrCfg_NumCrss (); CtrCfg_NumCrss ();
/***** Number of users in courses of this center *****/ /***** Number of users in courses of this center *****/
HieCfg_NumUsrsInCrss (HieLvl_CTR,Gbl.Hierarchy.Ctr.CtrCod,Rol_TCH); HieCfg_NumUsrsInCrss (HieLvl_CTR,Gbl.Hierarchy.Ctr.CtrCod,Rol_TCH);
HieCfg_NumUsrsInCrss (HieLvl_CTR,Gbl.Hierarchy.Ctr.CtrCod,Rol_NET); HieCfg_NumUsrsInCrss (HieLvl_CTR,Gbl.Hierarchy.Ctr.CtrCod,Rol_NET);
HieCfg_NumUsrsInCrss (HieLvl_CTR,Gbl.Hierarchy.Ctr.CtrCod,Rol_STD); HieCfg_NumUsrsInCrss (HieLvl_CTR,Gbl.Hierarchy.Ctr.CtrCod,Rol_STD);
HieCfg_NumUsrsInCrss (HieLvl_CTR,Gbl.Hierarchy.Ctr.CtrCod,Rol_UNK); HieCfg_NumUsrsInCrss (HieLvl_CTR,Gbl.Hierarchy.Ctr.CtrCod,Rol_UNK);
} }
/***** End table *****/ /***** End table *****/
HTM_TABLE_End (); HTM_TABLE_End ();
/***** End of left part *****/ /***** End of left part *****/
HTM_DIV_End (); HTM_DIV_End ();
@ -241,13 +241,13 @@ static void CtrCfg_Configuration (bool PrintView)
{ {
HTM_DIV_Begin ("class=\"HIE_CFG_RIGHT HIE_CFG_WIDTH\""); HTM_DIV_Begin ("class=\"HIE_CFG_RIGHT HIE_CFG_WIDTH\"");
/***** Center map *****/ /***** Center map *****/
if (MapIsAvailable) if (MapIsAvailable)
CtrCfg_Map (); CtrCfg_Map ();
/***** Center photo *****/ /***** Center photo *****/
if (PhotoExists) if (PhotoExists)
CtrCfg_Photo (PrintView,PutFormPhoto,PutLink,PathPhoto); CtrCfg_Photo (PrintView,PutFormPhoto,PutLink,PathPhoto);
HTM_DIV_End (); HTM_DIV_End ();
} }
@ -342,18 +342,18 @@ static void CtrCfg_Map (void)
/***** Script to draw the map *****/ /***** Script to draw the map *****/
HTM_SCRIPT_Begin (NULL,NULL); HTM_SCRIPT_Begin (NULL,NULL);
/* Let's create a map with pretty Mapbox Streets tiles */ /* Let's create a map with pretty Mapbox Streets tiles */
Map_CreateMap (CtrCfg_MAP_CONTAINER_ID,&Gbl.Hierarchy.Ctr.Coord,16); Map_CreateMap (CtrCfg_MAP_CONTAINER_ID,&Gbl.Hierarchy.Ctr.Coord,16);
/* Add Mapbox Streets tile layer to our map */ /* Add Mapbox Streets tile layer to our map */
Map_AddTileLayer (); Map_AddTileLayer ();
/* Add marker */ /* Add marker */
Map_AddMarker (&Gbl.Hierarchy.Ctr.Coord); Map_AddMarker (&Gbl.Hierarchy.Ctr.Coord);
/* Add popup */ /* Add popup */
Map_AddPopup (Gbl.Hierarchy.Ctr.ShrtName,Gbl.Hierarchy.Ins.ShrtName, Map_AddPopup (Gbl.Hierarchy.Ctr.ShrtName,Gbl.Hierarchy.Ins.ShrtName,
true); // Open true); // Open
HTM_SCRIPT_End (); HTM_SCRIPT_End ();
} }
@ -369,20 +369,20 @@ static void CtrCfg_Latitude (void)
/***** Latitude *****/ /***** Latitude *****/
HTM_TR_Begin (NULL); HTM_TR_Begin (NULL);
/* Label */ /* Label */
Frm_LabelColumn ("RT","Latitude",Txt_Latitude); Frm_LabelColumn ("RT","Latitude",Txt_Latitude);
/* Data */ /* Data */
HTM_TD_Begin ("class=\"LB\""); HTM_TD_Begin ("class=\"LB\"");
Frm_BeginForm (ActChgCtrLatCfg); Frm_BeginForm (ActChgCtrLatCfg);
HTM_INPUT_FLOAT ("Latitude", HTM_INPUT_FLOAT ("Latitude",
-90.0, // South Pole -90.0, // South Pole
90.0, // North Pole 90.0, // North Pole
0.0, // step="any" 0.0, // step="any"
Gbl.Hierarchy.Ctr.Coord.Latitude,false, Gbl.Hierarchy.Ctr.Coord.Latitude,false,
"class=\"INPUT_COORD\" required=\"required\""); "class=\"INPUT_COORD\" required=\"required\"");
Frm_EndForm (); Frm_EndForm ();
HTM_TD_End (); HTM_TD_End ();
HTM_TR_End (); HTM_TR_End ();
} }
@ -394,20 +394,20 @@ static void CtrCfg_Longitude (void)
/***** Longitude *****/ /***** Longitude *****/
HTM_TR_Begin (NULL); HTM_TR_Begin (NULL);
/* Label */ /* Label */
Frm_LabelColumn ("RT","Longitude",Txt_Longitude); Frm_LabelColumn ("RT","Longitude",Txt_Longitude);
/* Data */ /* Data */
HTM_TD_Begin ("class=\"LB\""); HTM_TD_Begin ("class=\"LB\"");
Frm_BeginForm (ActChgCtrLgtCfg); Frm_BeginForm (ActChgCtrLgtCfg);
HTM_INPUT_FLOAT ("Longitude", HTM_INPUT_FLOAT ("Longitude",
-180.0, // West -180.0, // West
180.0, // East 180.0, // East
0.0, // step="any" 0.0, // step="any"
Gbl.Hierarchy.Ctr.Coord.Longitude,false, Gbl.Hierarchy.Ctr.Coord.Longitude,false,
"class=\"INPUT_COORD\" required=\"required\""); "class=\"INPUT_COORD\" required=\"required\"");
Frm_EndForm (); Frm_EndForm ();
HTM_TD_End (); HTM_TD_End ();
HTM_TR_End (); HTM_TR_End ();
} }
@ -419,20 +419,20 @@ static void CtrCfg_Altitude (void)
/***** Altitude *****/ /***** Altitude *****/
HTM_TR_Begin (NULL); HTM_TR_Begin (NULL);
/* Label */ /* Label */
Frm_LabelColumn ("RT","Altitude",Txt_Altitude); Frm_LabelColumn ("RT","Altitude",Txt_Altitude);
/* Data */ /* Data */
HTM_TD_Begin ("class=\"LB\""); HTM_TD_Begin ("class=\"LB\"");
Frm_BeginForm (ActChgCtrAltCfg); Frm_BeginForm (ActChgCtrAltCfg);
HTM_INPUT_FLOAT ("Altitude", HTM_INPUT_FLOAT ("Altitude",
-413.0, // Dead Sea shore -413.0, // Dead Sea shore
8848.0, // Mount Everest 8848.0, // Mount Everest
0.0, // step="any" 0.0, // step="any"
Gbl.Hierarchy.Ctr.Coord.Altitude,false, Gbl.Hierarchy.Ctr.Coord.Altitude,false,
"class=\"INPUT_COORD\" required=\"required\""); "class=\"INPUT_COORD\" required=\"required\"");
Frm_EndForm (); Frm_EndForm ();
HTM_TD_End (); HTM_TD_End ();
HTM_TR_End (); HTM_TR_End ();
} }
@ -459,44 +459,44 @@ static void CtrCfg_Photo (bool PrintView,bool PutForm,bool PutLink,
/***** Photo image *****/ /***** Photo image *****/
HTM_DIV_Begin ("class=\"DAT_SMALL CM\""); HTM_DIV_Begin ("class=\"DAT_SMALL CM\"");
if (PutLink) if (PutLink)
HTM_A_Begin ("href=\"%s\" target=\"_blank\" class=\"DAT_N\"", HTM_A_Begin ("href=\"%s\" target=\"_blank\" class=\"DAT_N\"",
Gbl.Hierarchy.Ctr.WWW); Gbl.Hierarchy.Ctr.WWW);
if (asprintf (&URL,"%s/%02u/%u", if (asprintf (&URL,"%s/%02u/%u",
Cfg_URL_CTR_PUBLIC, Cfg_URL_CTR_PUBLIC,
(unsigned) (Gbl.Hierarchy.Ctr.CtrCod % 100), (unsigned) (Gbl.Hierarchy.Ctr.CtrCod % 100),
(unsigned) Gbl.Hierarchy.Ctr.CtrCod) < 0) (unsigned) Gbl.Hierarchy.Ctr.CtrCod) < 0)
Err_NotEnoughMemoryExit (); Err_NotEnoughMemoryExit ();
if (asprintf (&Icon,"%u.jpg", if (asprintf (&Icon,"%u.jpg",
(unsigned) Gbl.Hierarchy.Ctr.CtrCod) < 0) (unsigned) Gbl.Hierarchy.Ctr.CtrCod) < 0)
Err_NotEnoughMemoryExit (); Err_NotEnoughMemoryExit ();
HTM_IMG (URL,Icon,Gbl.Hierarchy.Ctr.FullName, HTM_IMG (URL,Icon,Gbl.Hierarchy.Ctr.FullName,
"class=\"%s\"",PrintView ? "CENTER_PHOTO_PRINT CENTER_PHOTO_WIDTH" : "class=\"%s\"",PrintView ? "CENTER_PHOTO_PRINT CENTER_PHOTO_WIDTH" :
"CENTER_PHOTO_SHOW CENTER_PHOTO_WIDTH"); "CENTER_PHOTO_SHOW CENTER_PHOTO_WIDTH");
free (Icon); free (Icon);
free (URL); free (URL);
if (PutLink) if (PutLink)
HTM_A_End (); HTM_A_End ();
HTM_DIV_End (); HTM_DIV_End ();
/****** Photo attribution ******/ /****** Photo attribution ******/
if (PutForm) if (PutForm)
{ {
HTM_DIV_Begin ("class=\"CM\""); HTM_DIV_Begin ("class=\"CM\"");
Frm_BeginForm (ActChgCtrPhoAtt); Frm_BeginForm (ActChgCtrPhoAtt);
HTM_TEXTAREA_Begin ("id=\"AttributionArea\" name=\"Attribution\" rows=\"3\"" HTM_TEXTAREA_Begin ("id=\"AttributionArea\" name=\"Attribution\" rows=\"3\""
" onchange=\"document.getElementById('%s').submit();return false;\"", " onchange=\"document.getElementById('%s').submit();return false;\"",
Gbl.Form.Id); Gbl.Form.Id);
if (PhotoAttribution) if (PhotoAttribution)
HTM_Txt (PhotoAttribution); HTM_Txt (PhotoAttribution);
HTM_TEXTAREA_End (); HTM_TEXTAREA_End ();
Frm_EndForm (); Frm_EndForm ();
HTM_DIV_End (); HTM_DIV_End ();
} }
else if (PhotoAttribution) else if (PhotoAttribution)
{ {
HTM_DIV_Begin ("class=\"ATTRIBUTION\""); HTM_DIV_Begin ("class=\"ATTRIBUTION\"");
HTM_Txt (PhotoAttribution); HTM_Txt (PhotoAttribution);
HTM_DIV_End (); HTM_DIV_End ();
} }
@ -567,56 +567,58 @@ static void CtrCfg_Institution (bool PrintView,bool PutForm)
/***** Institution *****/ /***** Institution *****/
HTM_TR_Begin (NULL); HTM_TR_Begin (NULL);
/* Label */ /* Label */
Frm_LabelColumn ("RT",PutForm ? "OthInsCod" : Frm_LabelColumn ("RT",PutForm ? "OthInsCod" :
NULL, NULL,
Txt_Institution); Txt_Institution);
/* Data */ /* Data */
HTM_TD_Begin ("class=\"DAT LB\""); HTM_TD_Begin ("class=\"DAT LB\"");
if (PutForm) if (PutForm)
{ {
/* Get list of institutions of the current country */ /* Get list of institutions of the current country */
Ins_GetBasicListOfInstitutions (Gbl.Hierarchy.Cty.CtyCod); Ins_GetBasicListOfInstitutions (Gbl.Hierarchy.Cty.CtyCod);
/* Put form to select institution */ /* Put form to select institution */
Frm_BeginForm (ActChgCtrInsCfg); Frm_BeginForm (ActChgCtrInsCfg);
HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE, HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,
"id=\"OthInsCod\" name=\"OthInsCod\"" "id=\"OthInsCod\" name=\"OthInsCod\""
" class=\"INPUT_SHORT_NAME\""); " class=\"INPUT_SHORT_NAME\"");
for (NumIns = 0; for (NumIns = 0;
NumIns < Gbl.Hierarchy.Inss.Num; NumIns < Gbl.Hierarchy.Inss.Num;
NumIns++) NumIns++)
HTM_OPTION (HTM_Type_LONG,&Gbl.Hierarchy.Inss.Lst[NumIns].InsCod, HTM_OPTION (HTM_Type_LONG,&Gbl.Hierarchy.Inss.Lst[NumIns].InsCod,
Gbl.Hierarchy.Inss.Lst[NumIns].InsCod == Gbl.Hierarchy.Ins.InsCod,false, Gbl.Hierarchy.Inss.Lst[NumIns].InsCod == Gbl.Hierarchy.Ins.InsCod,false,
"%s",Gbl.Hierarchy.Inss.Lst[NumIns].ShrtName); "%s",Gbl.Hierarchy.Inss.Lst[NumIns].ShrtName);
HTM_SELECT_End (); HTM_SELECT_End ();
Frm_EndForm (); Frm_EndForm ();
/* Free list of institutions */ /* Free list of institutions */
Ins_FreeListInstitutions (); Ins_FreeListInstitutions ();
} }
else // I can not move center to another institution else // I can not move center to another institution
{ {
if (!PrintView) if (!PrintView)
{ {
Frm_BeginFormGoTo (ActSeeInsInf); Frm_BeginFormGoTo (ActSeeInsInf);
Ins_PutParamInsCod (Gbl.Hierarchy.Ins.InsCod); Ins_PutParamInsCod (Gbl.Hierarchy.Ins.InsCod);
HTM_BUTTON_SUBMIT_Begin (Hie_BuildGoToMsg (Gbl.Hierarchy.Ins.ShrtName), HTM_BUTTON_SUBMIT_Begin (Hie_BuildGoToMsg (Gbl.Hierarchy.Ins.ShrtName),
"BT_LINK LT DAT",NULL); "BT_LINK LT DAT",NULL);
Hie_FreeGoToMsg (); Hie_FreeGoToMsg ();
} }
Lgo_DrawLogo (HieLvl_INS,Gbl.Hierarchy.Ins.InsCod,Gbl.Hierarchy.Ins.ShrtName,
20,"LM",true); Lgo_DrawLogo (HieLvl_INS,Gbl.Hierarchy.Ins.InsCod,Gbl.Hierarchy.Ins.ShrtName,
HTM_NBSP (); 20,"LM",true);
HTM_Txt (Gbl.Hierarchy.Ins.FullName); HTM_NBSP ();
if (!PrintView) HTM_Txt (Gbl.Hierarchy.Ins.FullName);
{
HTM_BUTTON_End (); if (!PrintView)
Frm_EndForm (); {
} HTM_BUTTON_End ();
} Frm_EndForm ();
HTM_TD_End (); }
}
HTM_TD_End ();
HTM_TR_End (); HTM_TR_End ();
} }
@ -664,41 +666,41 @@ static void CtrCfg_Place (bool PutForm)
/***** Place *****/ /***** Place *****/
HTM_TR_Begin (NULL); HTM_TR_Begin (NULL);
/* Label */ /* Label */
Frm_LabelColumn ("RT",PutForm ? "PlcCod" : Frm_LabelColumn ("RT",PutForm ? "PlcCod" :
NULL, NULL,
Txt_Place); Txt_Place);
/* Data */ /* Data */
HTM_TD_Begin ("class=\"DAT LB\""); HTM_TD_Begin ("class=\"DAT LB\"");
if (PutForm) if (PutForm)
{ {
/* Get list of places of the current institution */ /* Get list of places of the current institution */
Places.SelectedOrder = Plc_ORDER_BY_PLACE; Places.SelectedOrder = Plc_ORDER_BY_PLACE;
Plc_GetListPlaces (&Places); Plc_GetListPlaces (&Places);
/* Put form to select place */ /* Put form to select place */
Frm_BeginForm (ActChgCtrPlcCfg); Frm_BeginForm (ActChgCtrPlcCfg);
HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE, HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,
"name=\"PlcCod\" class=\"INPUT_SHORT_NAME\""); "name=\"PlcCod\" class=\"INPUT_SHORT_NAME\"");
HTM_OPTION (HTM_Type_STRING,"0", HTM_OPTION (HTM_Type_STRING,"0",
Gbl.Hierarchy.Ctr.PlcCod == 0,false, Gbl.Hierarchy.Ctr.PlcCod == 0,false,
"%s",Txt_Another_place); "%s",Txt_Another_place);
for (NumPlc = 0; for (NumPlc = 0;
NumPlc < Places.Num; NumPlc < Places.Num;
NumPlc++) NumPlc++)
HTM_OPTION (HTM_Type_LONG,&Places.Lst[NumPlc].PlcCod, HTM_OPTION (HTM_Type_LONG,&Places.Lst[NumPlc].PlcCod,
Places.Lst[NumPlc].PlcCod == Gbl.Hierarchy.Ctr.PlcCod,false, Places.Lst[NumPlc].PlcCod == Gbl.Hierarchy.Ctr.PlcCod,false,
"%s",Places.Lst[NumPlc].ShrtName); "%s",Places.Lst[NumPlc].ShrtName);
HTM_SELECT_End (); HTM_SELECT_End ();
Frm_EndForm (); Frm_EndForm ();
/* Free list of places */ /* Free list of places */
Plc_FreeListPlaces (&Places); Plc_FreeListPlaces (&Places);
} }
else // I can not change center place else // I can not change center place
HTM_Txt (Plc.FullName); HTM_Txt (Plc.FullName);
HTM_TD_End (); HTM_TD_End ();
HTM_TR_End (); HTM_TR_End ();
} }
@ -741,13 +743,13 @@ static void CtrCfg_NumUsrs (void)
/***** Number of users *****/ /***** Number of users *****/
HTM_TR_Begin (NULL); HTM_TR_Begin (NULL);
/* Label */ /* Label */
Frm_LabelColumn ("RT",NULL,Txt_Users_of_the_center); Frm_LabelColumn ("RT",NULL,Txt_Users_of_the_center);
/* Data */ /* Data */
HTM_TD_Begin ("class=\"DAT LB\""); HTM_TD_Begin ("class=\"DAT LB\"");
HTM_Unsigned (Usr_GetCachedNumUsrsWhoClaimToBelongToCtr (&Gbl.Hierarchy.Ctr)); HTM_Unsigned (Usr_GetCachedNumUsrsWhoClaimToBelongToCtr (&Gbl.Hierarchy.Ctr));
HTM_TD_End (); HTM_TD_End ();
HTM_TR_End (); HTM_TR_End ();
} }
@ -764,21 +766,21 @@ static void CtrCfg_NumDegs (void)
/***** Number of degrees *****/ /***** Number of degrees *****/
HTM_TR_Begin (NULL); HTM_TR_Begin (NULL);
/* Label */ /* Label */
Frm_LabelColumn ("RT",NULL,Txt_Degrees); Frm_LabelColumn ("RT",NULL,Txt_Degrees);
/* Data */ /* Data */
HTM_TD_Begin ("class=\"LB\""); HTM_TD_Begin ("class=\"LB\"");
Frm_BeginFormGoTo (ActSeeDeg); Frm_BeginFormGoTo (ActSeeDeg);
Ctr_PutParamCtrCod (Gbl.Hierarchy.Ctr.CtrCod); Ctr_PutParamCtrCod (Gbl.Hierarchy.Ctr.CtrCod);
HTM_BUTTON_SUBMIT_Begin (Str_BuildStringStr (Txt_Degrees_of_CENTER_X, HTM_BUTTON_SUBMIT_Begin (Str_BuildStringStr (Txt_Degrees_of_CENTER_X,
Gbl.Hierarchy.Ctr.ShrtName), Gbl.Hierarchy.Ctr.ShrtName),
"BT_LINK DAT",NULL); "BT_LINK DAT",NULL);
Str_FreeString (); Str_FreeString ();
HTM_Unsigned (Deg_GetCachedNumDegsInCtr (Gbl.Hierarchy.Ctr.CtrCod)); HTM_Unsigned (Deg_GetCachedNumDegsInCtr (Gbl.Hierarchy.Ctr.CtrCod));
HTM_BUTTON_End (); HTM_BUTTON_End ();
Frm_EndForm (); Frm_EndForm ();
HTM_TD_End (); HTM_TD_End ();
HTM_TR_End (); HTM_TR_End ();
} }
@ -794,13 +796,13 @@ static void CtrCfg_NumCrss (void)
/***** Number of courses *****/ /***** Number of courses *****/
HTM_TR_Begin (NULL); HTM_TR_Begin (NULL);
/* Label */ /* Label */
Frm_LabelColumn ("RT",NULL,Txt_Courses); Frm_LabelColumn ("RT",NULL,Txt_Courses);
/* Data */ /* Data */
HTM_TD_Begin ("class=\"DAT LB\""); HTM_TD_Begin ("class=\"DAT LB\"");
HTM_Unsigned (Crs_GetCachedNumCrssInCtr (Gbl.Hierarchy.Ctr.CtrCod)); HTM_Unsigned (Crs_GetCachedNumCrssInCtr (Gbl.Hierarchy.Ctr.CtrCod));
HTM_TD_End (); HTM_TD_End ();
HTM_TR_End (); HTM_TR_End ();
} }
@ -848,31 +850,31 @@ void CtrCfg_RequestPhoto (void)
/***** Begin form to upload photo *****/ /***** Begin form to upload photo *****/
Frm_BeginForm (ActRecCtrPho); Frm_BeginForm (ActRecCtrPho);
/***** Begin box *****/ /***** Begin box *****/
Box_BoxBegin (NULL,Txt_Photo, Box_BoxBegin (NULL,Txt_Photo,
NULL,NULL, NULL,NULL,
NULL,Box_NOT_CLOSABLE); NULL,Box_NOT_CLOSABLE);
/***** Write help message *****/ /***** Write help message *****/
Ale_ShowAlert (Ale_INFO,"%s: %s<br />" Ale_ShowAlert (Ale_INFO,"%s: %s<br />"
"%s: %u&times;%u %s", "%s: %u&times;%u %s",
Txt_Recommended_aspect_ratio, Txt_Recommended_aspect_ratio,
Ctr_RECOMMENDED_ASPECT_RATIO, Ctr_RECOMMENDED_ASPECT_RATIO,
Txt_Recommended_resolution, Txt_Recommended_resolution,
Ctr_PHOTO_SAVED_MAX_WIDTH, Ctr_PHOTO_SAVED_MAX_WIDTH,
Ctr_PHOTO_SAVED_MAX_HEIGHT, Ctr_PHOTO_SAVED_MAX_HEIGHT,
Txt_XxY_pixels_or_higher); Txt_XxY_pixels_or_higher);
/***** Upload photo *****/ /***** Upload photo *****/
HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]);
HTM_TxtColonNBSP (Txt_File_with_the_photo); HTM_TxtColonNBSP (Txt_File_with_the_photo);
HTM_INPUT_FILE (Fil_NAME_OF_PARAM_FILENAME_ORG,"image/*", HTM_INPUT_FILE (Fil_NAME_OF_PARAM_FILENAME_ORG,"image/*",
HTM_SUBMIT_ON_CHANGE, HTM_SUBMIT_ON_CHANGE,
NULL); NULL);
HTM_LABEL_End (); HTM_LABEL_End ();
/***** End box *****/ /***** End box *****/
Box_BoxEnd (); Box_BoxEnd ();
/***** End form *****/ /***** End form *****/
Frm_EndForm (); Frm_EndForm ();
@ -1037,7 +1039,7 @@ void CtrCfg_ChangeCtrIns (void)
Ins_GetDataOfInstitutionByCod (&NewIns); Ins_GetDataOfInstitutionByCod (&NewIns);
/***** Check if it already exists a center with the same name in the new institution *****/ /***** Check if it already exists a center with the same name in the new institution *****/
if (Ctr_CheckIfCtrNameExistsInIns ("ShortName", if (Ctr_DB_CheckIfCtrNameExistsInIns ("ShortName",
Gbl.Hierarchy.Ctr.ShrtName, Gbl.Hierarchy.Ctr.ShrtName,
Gbl.Hierarchy.Ctr.CtrCod, Gbl.Hierarchy.Ctr.CtrCod,
NewIns.InsCod)) NewIns.InsCod))
@ -1045,7 +1047,7 @@ void CtrCfg_ChangeCtrIns (void)
Ale_CreateAlert (Ale_WARNING,NULL, Ale_CreateAlert (Ale_WARNING,NULL,
Txt_The_center_X_already_exists, Txt_The_center_X_already_exists,
Gbl.Hierarchy.Ctr.ShrtName); Gbl.Hierarchy.Ctr.ShrtName);
else if (Ctr_CheckIfCtrNameExistsInIns ("FullName", else if (Ctr_DB_CheckIfCtrNameExistsInIns ("FullName",
Gbl.Hierarchy.Ctr.FullName, Gbl.Hierarchy.Ctr.FullName,
Gbl.Hierarchy.Ctr.CtrCod, Gbl.Hierarchy.Ctr.CtrCod,
NewIns.InsCod)) NewIns.InsCod))
@ -1056,7 +1058,7 @@ void CtrCfg_ChangeCtrIns (void)
else else
{ {
/***** Update institution in table of centers *****/ /***** Update institution in table of centers *****/
CtrCfg_UpdateCtrInsDB (Gbl.Hierarchy.Ctr.CtrCod,NewIns.InsCod); Ctr_DB_UpdateCtrIns (Gbl.Hierarchy.Ctr.CtrCod,NewIns.InsCod);
Gbl.Hierarchy.Ctr.InsCod = Gbl.Hierarchy.Ctr.InsCod =
Gbl.Hierarchy.Ins.InsCod = NewIns.InsCod; Gbl.Hierarchy.Ins.InsCod = NewIns.InsCod;
@ -1075,7 +1077,7 @@ void CtrCfg_ChangeCtrIns (void)
/******************* Update institution in table of centers ******************/ /******************* Update institution in table of centers ******************/
/*****************************************************************************/ /*****************************************************************************/
static void CtrCfg_UpdateCtrInsDB (long CtrCod,long InsCod) static void Ctr_DB_UpdateCtrIns (long CtrCod,long InsCod)
{ {
/***** Update institution in table of centers *****/ /***** Update institution in table of centers *****/
DB_QueryUPDATE ("can not update the institution of a center", DB_QueryUPDATE ("can not update the institution of a center",
@ -1099,7 +1101,7 @@ void CtrCfg_ChangeCtrPlc (void)
NewPlcCod = Plc_GetParamPlcCod (); NewPlcCod = Plc_GetParamPlcCod ();
/***** Update place in table of centers *****/ /***** Update place in table of centers *****/
Ctr_UpdateCtrPlcDB (Gbl.Hierarchy.Ctr.CtrCod,NewPlcCod); Ctr_DB_UpdateCtrPlc (Gbl.Hierarchy.Ctr.CtrCod,NewPlcCod);
Gbl.Hierarchy.Ctr.PlcCod = NewPlcCod; Gbl.Hierarchy.Ctr.PlcCod = NewPlcCod;
/***** Write message to show the change made *****/ /***** Write message to show the change made *****/
@ -1222,7 +1224,7 @@ void CtrCfg_ChangeCtrWWW (void)
if (NewWWW[0]) if (NewWWW[0])
{ {
/***** Update database changing old WWW by new WWW *****/ /***** Update database changing old WWW by new WWW *****/
Ctr_UpdateCtrWWWDB (Gbl.Hierarchy.Ctr.CtrCod,NewWWW); Ctr_DB_UpdateCtrWWW (Gbl.Hierarchy.Ctr.CtrCod,NewWWW);
Str_Copy (Gbl.Hierarchy.Ctr.WWW,NewWWW,sizeof (Gbl.Hierarchy.Ctr.WWW) - 1); Str_Copy (Gbl.Hierarchy.Ctr.WWW,NewWWW,sizeof (Gbl.Hierarchy.Ctr.WWW) - 1);
/***** Write message to show the change made *****/ /***** Write message to show the change made *****/

70
swad_center_database.c Normal file
View File

@ -0,0 +1,70 @@
// swad_center_database.c: centers operations with database
/*
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.
Copyright (C) 1999-2021 Antonio Cañas Vargas
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 ***********************************/
/*****************************************************************************/
// #include <stdbool.h> // For boolean type
// #include <stddef.h> // For NULL
// #include <stdlib.h> // For free
// #include <string.h> // For string functions
#include "swad_center.h"
#include "swad_center_config.h"
// #include "swad_database.h"
// #include "swad_error.h"
// #include "swad_figure.h"
// #include "swad_figure_cache.h"
// #include "swad_form.h"
// #include "swad_forum.h"
#include "swad_global.h"
// #include "swad_hierarchy.h"
// #include "swad_hierarchy_level.h"
// #include "swad_HTML.h"
// #include "swad_logo.h"
// #include "swad_message.h"
// #include "swad_place.h"
// #include "swad_survey.h"
/*****************************************************************************/
/************** External global variables from others modules ****************/
/*****************************************************************************/
extern struct Globals Gbl;
/*****************************************************************************/
/***************************** Private constants *****************************/
/*****************************************************************************/
/*****************************************************************************/
/******************************* Private types *******************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Private variables *****************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Private prototypes ****************************/
/*****************************************************************************/

46
swad_center_database.h Normal file
View File

@ -0,0 +1,46 @@
// swad_center_database.h: centers operations with database
#ifndef _SWAD_CTR_DB
#define _SWAD_CTR_DB
/*
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.
Copyright (C) 1999-2021 Antonio Cañas Vargas
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 ***********************************/
/*****************************************************************************/
// #include <mysql/mysql.h> // To access MySQL databases
// #include "swad_action.h"
// #include "swad_constant.h"
// #include "swad_degree.h"
// #include "swad_map.h"
// #include "swad_role_type.h"
/*****************************************************************************/
/************************** Public types and constants ***********************/
/*****************************************************************************/
/*****************************************************************************/
/****************************** Public prototypes ****************************/
/*****************************************************************************/
#endif

View File

@ -602,13 +602,14 @@ TODO: FIX BUG, URGENT! En las fechas como par
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo. TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
*/ */
#define Log_PLATFORM_VERSION "SWAD 20.87.1 (2021-06-01)" #define Log_PLATFORM_VERSION "SWAD 20.88 (2021-06-02)"
#define CSS_FILE "swad20.45.css" #define CSS_FILE "swad20.45.css"
#define JS_FILE "swad20.69.1.js" #define JS_FILE "swad20.69.1.js"
/* /*
TODO: Rename CENTRE to CENTER in help wiki. TODO: Rename CENTRE to CENTER in help wiki.
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
Version 20.88: Jun 02, 2021 New module swad_center_database for database queries related to centers. (312638 lines)
Version 20.87.1: Jun 01, 2021 Database function moved from swad_calendar to swad_setting. (312549 lines) Version 20.87.1: Jun 01, 2021 Database function moved from swad_calendar to swad_setting. (312549 lines)
Version 20.87: Jun 01, 2021 New module swad_building_database for database queries related to buildings. (312538 lines) Version 20.87: Jun 01, 2021 New module swad_building_database for database queries related to buildings. (312538 lines)
Version 20.86.1: May 31, 2021 Queries moved to module swad_call_for_exam_database. (312420 lines) Version 20.86.1: May 31, 2021 Queries moved to module swad_call_for_exam_database. (312420 lines)

View File

@ -181,7 +181,7 @@ void Plc_SeePlaces (void)
HTM_TR_End (); HTM_TR_End ();
/***** Write centers (of the current institution) with other place *****/ /***** Write centers (of the current institution) with other place *****/
NumCtrsInOtherPlcs = Ctr_GetNumCtrsInPlc (0); NumCtrsInOtherPlcs = Ctr_DB_GetNumCtrsInPlc (0);
HTM_TR_Begin (NULL); HTM_TR_Begin (NULL);
HTM_TD_Begin ("class=\"DAT LM\""); HTM_TD_Begin ("class=\"DAT LM\"");