Version 20.50.6: Mar 17, 2021 Buildings database table renamed.

This commit is contained in:
acanas 2021-03-17 10:27:58 +01:00
parent 1a6147d9b1
commit ce8a3aa9c9
6 changed files with 93 additions and 70 deletions

View File

@ -126,9 +126,9 @@ CREATE TABLE IF NOT EXISTS ban_banners (
UNIQUE INDEX(BanCod), UNIQUE INDEX(BanCod),
INDEX(Hidden)); INDEX(Hidden));
-- --
-- Table buildings: buildings in a center -- Table bld_buildings: buildings in a center
-- --
CREATE TABLE IF NOT EXISTS buildings ( CREATE TABLE IF NOT EXISTS bld_buildings (
BldCod INT NOT NULL AUTO_INCREMENT, BldCod INT NOT NULL AUTO_INCREMENT,
CtrCod INT NOT NULL, CtrCod INT NOT NULL,
ShortName VARCHAR(511) NOT NULL, ShortName VARCHAR(511) NOT NULL,

View File

@ -5995,26 +5995,26 @@ int swad__getLocation (struct soap *soap,
"ctr_centers.CtrCod," // row[ 3] "ctr_centers.CtrCod," // row[ 3]
"ctr_centers.ShortName," // row[ 4] "ctr_centers.ShortName," // row[ 4]
"ctr_centers.FullName," // row[ 5] "ctr_centers.FullName," // row[ 5]
"buildings.BldCod," // row[ 6] "bld_buildings.BldCod," // row[ 6]
"buildings.ShortName," // row[ 7] "bld_buildings.ShortName," // row[ 7]
"buildings.FullName," // row[ 8] "bld_buildings.FullName," // row[ 8]
"rooms.Floor," // row[ 9] "rooms.Floor," // row[ 9]
"rooms.RooCod," // row[10] "rooms.RooCod," // row[10]
"rooms.ShortName," // row[11] "rooms.ShortName," // row[11]
"rooms.FullName" // row[12] "rooms.FullName" // row[12]
" FROM room_MAC," " FROM room_MAC,"
"rooms," "rooms,"
"buildings," "bld_buildings,"
"ctr_centers," "ctr_centers,"
"ins_instits" "ins_instits"
" WHERE room_MAC.MAC=%llu" " WHERE room_MAC.MAC=%llu"
" AND room_MAC.RooCod=rooms.RooCod" " AND room_MAC.RooCod=rooms.RooCod"
" AND rooms.BldCod=buildings.BldCod" " AND rooms.BldCod=bld_buildings.BldCod"
" AND buildings.CtrCod=ctr_centers.CtrCod" " AND bld_buildings.CtrCod=ctr_centers.CtrCod"
" AND ctr_centers.InsCod=ins_instits.InsCod" " AND ctr_centers.InsCod=ins_instits.InsCod"
" ORDER BY rooms.Capacity," // Get the biggest room " ORDER BY rooms.Capacity DESC," // Get the biggest room
"rooms.ShortName" "rooms.ShortName"
" DESC LIMIT 1", " LIMIT 1",
MACnum); MACnum);
API_GetDataOfLocation (soap, API_GetDataOfLocation (soap,
@ -6131,33 +6131,35 @@ int swad__getLastLocation (struct soap *soap,
NumLocs = (unsigned) NumLocs = (unsigned)
DB_QuerySELECT (&mysql_res,"can not get matches", DB_QuerySELECT (&mysql_res,"can not get matches",
"SELECT ins_instits.InsCod," // row[ 0] "SELECT ins_instits.InsCod," // row[ 0]
"ins_instits.ShortName," // row[ 1] "ins_instits.ShortName," // row[ 1]
"ins_instits.FullName," // row[ 2] "ins_instits.FullName," // row[ 2]
"ctr_centers.CtrCod," // row[ 3] "ctr_centers.CtrCod," // row[ 3]
"ctr_centers.ShortName," // row[ 4] "ctr_centers.ShortName," // row[ 4]
"ctr_centers.FullName," // row[ 5] "ctr_centers.FullName," // row[ 5]
"buildings.BldCod," // row[ 6] "bld_buildings.BldCod," // row[ 6]
"buildings.ShortName," // row[ 7] "bld_buildings.ShortName," // row[ 7]
"buildings.FullName," // row[ 8] "bld_buildings.FullName," // row[ 8]
"rooms.Floor," // row[ 9] "rooms.Floor," // row[ 9]
"rooms.RooCod," // row[10] "rooms.RooCod," // row[10]
"rooms.ShortName," // row[11] "rooms.ShortName," // row[11]
"rooms.FullName," // row[12] "rooms.FullName," // row[12]
"UNIX_TIMESTAMP(room_check_in.CheckInTime)" // row[13] "UNIX_TIMESTAMP(room_check_in.CheckInTime)" // row[13]
" FROM room_check_in," " FROM room_check_in,"
"rooms," "rooms,"
"buildings," "bld_buildings,"
"ctr_centers," "ctr_centers,"
"ins_instits" "ins_instits"
" WHERE room_check_in.UsrCod=%d" " WHERE room_check_in.UsrCod=%d"
" AND room_check_in.ChkCod=" " AND room_check_in.ChkCod="
"(SELECT ChkCod FROM room_check_in" "(SELECT ChkCod"
" WHERE UsrCod=%d" " FROM room_check_in"
" ORDER BY ChkCod DESC LIMIT 1)" // Faster than SELECT MAX " WHERE UsrCod=%d"
" AND room_check_in.RooCod=rooms.RooCod" " ORDER BY ChkCod DESC"
" AND rooms.BldCod=buildings.BldCod" " LIMIT 1)" // Faster than SELECT MAX
" AND buildings.CtrCod=ctr_centers.CtrCod" " AND room_check_in.RooCod=rooms.RooCod"
" AND ctr_centers.InsCod=ins_instits.InsCod", " AND rooms.BldCod=bld_buildings.BldCod"
" AND bld_buildings.CtrCod=ctr_centers.CtrCod"
" AND ctr_centers.InsCod=ins_instits.InsCod",
userCode,userCode); userCode,userCode);
API_GetDataOfLocation (soap, API_GetDataOfLocation (soap,
&(getLastLocationOut->location), &(getLastLocationOut->location),
@ -6199,9 +6201,9 @@ static void API_GetDataOfLocation (struct soap *soap,
ctr_centers.CtrCod // row[ 3] ctr_centers.CtrCod // row[ 3]
ctr_centers.ShortName // row[ 4] ctr_centers.ShortName // row[ 4]
ctr_centers.FullName // row[ 5] ctr_centers.FullName // row[ 5]
buildings.BldCod // row[ 6] bld_buildings.BldCod // row[ 6]
buildings.ShortName // row[ 7] bld_buildings.ShortName // row[ 7]
buildings.FullName // row[ 8] bld_buildings.FullName // row[ 8]
rooms.Floor // row[ 9] rooms.Floor // row[ 9]
rooms.RooCod // row[10] rooms.RooCod // row[10]
rooms.ShortName // row[11] rooms.ShortName // row[11]

View File

@ -327,11 +327,11 @@ void Bld_GetListBuildings (struct Bld_Buildings *Buildings,
{ {
case Bld_ALL_DATA: case Bld_ALL_DATA:
NumRows = DB_QuerySELECT (&mysql_res,"can not get buildings", NumRows = DB_QuerySELECT (&mysql_res,"can not get buildings",
"SELECT BldCod," "SELECT BldCod," // row[0]
"ShortName," "ShortName," // row[1]
"FullName," "FullName," // row[2]
"Location" "Location" // row[3]
" FROM buildings" " FROM bld_buildings"
" WHERE CtrCod=%ld" " WHERE CtrCod=%ld"
" ORDER BY %s", " ORDER BY %s",
Gbl.Hierarchy.Ctr.CtrCod, Gbl.Hierarchy.Ctr.CtrCod,
@ -340,9 +340,9 @@ void Bld_GetListBuildings (struct Bld_Buildings *Buildings,
case Bld_ONLY_SHRT_NAME: case Bld_ONLY_SHRT_NAME:
default: default:
NumRows = DB_QuerySELECT (&mysql_res,"can not get buildings", NumRows = DB_QuerySELECT (&mysql_res,"can not get buildings",
"SELECT BldCod," "SELECT BldCod," // row[0]
"ShortName" "ShortName" // row[1]
" FROM buildings" " FROM bld_buildings"
" WHERE CtrCod=%ld" " WHERE CtrCod=%ld"
" ORDER BY ShortName", " ORDER BY ShortName",
Gbl.Hierarchy.Ctr.CtrCod); Gbl.Hierarchy.Ctr.CtrCod);
@ -413,7 +413,7 @@ void Bld_GetDataOfBuildingByCod (struct Bld_Building *Building)
"SELECT ShortName," // row[0] "SELECT ShortName," // row[0]
"FullName," // row[1] "FullName," // row[1]
"Location" // row[2] "Location" // row[2]
" FROM buildings" " FROM bld_buildings"
" WHERE BldCod=%ld", " WHERE BldCod=%ld",
Building->BldCod); Building->BldCod);
@ -574,7 +574,8 @@ void Bld_RemoveBuilding (void)
/***** Remove building *****/ /***** Remove building *****/
DB_QueryDELETE ("can not remove a building", DB_QueryDELETE ("can not remove a building",
"DELETE FROM buildings WHERE BldCod=%ld", "DELETE FROM bld_buildings"
" WHERE BldCod=%ld",
Bld_EditingBuilding->BldCod); Bld_EditingBuilding->BldCod);
/***** Create message to show the change made *****/ /***** Create message to show the change made *****/
@ -708,9 +709,11 @@ static bool Bld_CheckIfBuildingNameExists (const char *FieldName,const char *Nam
/***** Get number of buildings with a name from database *****/ /***** Get number of buildings with a name from database *****/
return (DB_QueryCOUNT ("can not check if the name of a building" return (DB_QueryCOUNT ("can not check if the name of a building"
" already existed", " already existed",
"SELECT COUNT(*) FROM buildings" "SELECT COUNT(*)"
" FROM bld_buildings"
" WHERE CtrCod=%ld" " WHERE CtrCod=%ld"
" AND %s='%s' AND BldCod<>%ld", " AND %s='%s'"
" AND BldCod<>%ld",
Gbl.Hierarchy.Ctr.CtrCod, Gbl.Hierarchy.Ctr.CtrCod,
FieldName,Name,BldCod) != 0); FieldName,Name,BldCod) != 0);
} }
@ -723,7 +726,9 @@ static void Bld_UpdateBuildingNameDB (long BldCod,const char *FieldName,const ch
{ {
/***** Update building changing old name by new name */ /***** Update building changing old name by new name */
DB_QueryUPDATE ("can not update the name of a building", DB_QueryUPDATE ("can not update the name of a building",
"UPDATE buildings SET %s='%s' WHERE BldCod=%ld", "UPDATE bld_buildings"
" SET %s='%s'"
" WHERE BldCod=%ld",
FieldName,NewBuildingName,BldCod); FieldName,NewBuildingName,BldCod);
} }

View File

@ -600,12 +600,16 @@ TODO: Salvador Romero Cort
TODO: FIX BUG, URGENT! En las fechas como parámetro Dat_WriteParamsIniEndDates(), por ejemplo al cambiar el color de la gráfica de accesos por día y hora, no se respeta la zona horaria. TODO: FIX BUG, URGENT! En las fechas como parámetro Dat_WriteParamsIniEndDates(), por ejemplo al cambiar el color de la gráfica de accesos por día y hora, no se respeta la zona horaria.
*/ */
#define Log_PLATFORM_VERSION "SWAD 20.50.5 (2021-03-17)" #define Log_PLATFORM_VERSION "SWAD 20.50.6 (2021-03-17)"
#define CSS_FILE "swad20.45.css" #define CSS_FILE "swad20.45.css"
#define JS_FILE "swad20.6.2.js" #define JS_FILE "swad20.6.2.js"
/* /*
TODO: Rename CENTRE to CENTER in help wiki. TODO: Rename CENTRE to CENTER in help wiki.
Version 20.50.6: Mar 17, 2021 Buildings database table renamed. (307310 lines)
1 change necessary in database:
RENAME TABLE buildings TO bld_buildings;
Version 20.50.5: Mar 17, 2021 Birthdays-today database table renamed. (307288 lines) Version 20.50.5: Mar 17, 2021 Birthdays-today database table renamed. (307288 lines)
1 change necessary in database: 1 change necessary in database:
RENAME TABLE birthdays_today TO usr_birthdays_today; RENAME TABLE birthdays_today TO usr_birthdays_today;

View File

@ -358,9 +358,9 @@ mysql> DESCRIBE ban_banners;
"UNIQUE INDEX(BanCod)," "UNIQUE INDEX(BanCod),"
"INDEX(Hidden))"); "INDEX(Hidden))");
/***** Table buildings *****/ /***** Table bld_buildings *****/
/* /*
mysql> DESCRIBE buildings; mysql> DESCRIBE bld_buildings;
+-----------+---------------+------+-----+---------+----------------+ +-----------+---------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra | | Field | Type | Null | Key | Default | Extra |
+-----------+---------------+------+-----+---------+----------------+ +-----------+---------------+------+-----+---------+----------------+
@ -372,7 +372,7 @@ mysql> DESCRIBE buildings;
+-----------+---------------+------+-----+---------+----------------+ +-----------+---------------+------+-----+---------+----------------+
5 rows in set (0.00 sec) 5 rows in set (0.00 sec)
*/ */
DB_CreateTable ("CREATE TABLE IF NOT EXISTS buildings (" DB_CreateTable ("CREATE TABLE IF NOT EXISTS bld_buildings ("
"BldCod INT NOT NULL AUTO_INCREMENT," "BldCod INT NOT NULL AUTO_INCREMENT,"
"CtrCod INT NOT NULL," "CtrCod INT NOT NULL,"
"ShortName VARCHAR(511) NOT NULL," // Bld_MAX_BYTES_SHRT_NAME "ShortName VARCHAR(511) NOT NULL," // Bld_MAX_BYTES_SHRT_NAME

View File

@ -532,12 +532,24 @@ void Roo_GetListRooms (struct Roo_Rooms *Rooms,
{ {
static const char *OrderBySubQuery[Roo_NUM_ORDERS] = static const char *OrderBySubQuery[Roo_NUM_ORDERS] =
{ {
[Roo_ORDER_BY_BUILDING ] = "buildings.ShortName,rooms.Floor,rooms.ShortName", [Roo_ORDER_BY_BUILDING ] = "bld_buildings.ShortName,"
[Roo_ORDER_BY_FLOOR ] = "rooms.Floor,buildings.ShortName,rooms.ShortName", "rooms.Floor,"
[Roo_ORDER_BY_TYPE ] = "rooms.Type,buildings.ShortName,rooms.Floor,rooms.ShortName", "rooms.ShortName",
[Roo_ORDER_BY_SHRT_NAME] = "rooms.ShortName,rooms.FullName", [Roo_ORDER_BY_FLOOR ] = "rooms.Floor,"
[Roo_ORDER_BY_FULL_NAME] = "rooms.FullName,rooms.ShortName", "bld_buildings.ShortName,"
[Roo_ORDER_BY_CAPACITY ] = "rooms.Capacity DESC,buildings.ShortName,rooms.Floor,rooms.ShortName", "rooms.ShortName",
[Roo_ORDER_BY_TYPE ] = "rooms.Type,"
"bld_buildings.ShortName,"
"rooms.Floor,"
"rooms.ShortName",
[Roo_ORDER_BY_SHRT_NAME] = "rooms.ShortName,"
"rooms.FullName",
[Roo_ORDER_BY_FULL_NAME] = "rooms.FullName,"
"rooms.ShortName",
[Roo_ORDER_BY_CAPACITY ] = "rooms.Capacity DESC,"
"bld_buildings.ShortName,"
"rooms.Floor,"
"rooms.ShortName",
}; };
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
@ -552,14 +564,14 @@ void Roo_GetListRooms (struct Roo_Rooms *Rooms,
NumRows = DB_QuerySELECT (&mysql_res,"can not get rooms", NumRows = DB_QuerySELECT (&mysql_res,"can not get rooms",
"SELECT rooms.RooCod," // row[0] "SELECT rooms.RooCod," // row[0]
"rooms.BldCod," // row[1] "rooms.BldCod," // row[1]
"buildings.ShortName," // row[2] "bld_buildings.ShortName," // row[2]
"rooms.Floor," // row[3] "rooms.Floor," // row[3]
"rooms.Type," // row[4] "rooms.Type," // row[4]
"rooms.ShortName," // row[5] "rooms.ShortName," // row[5]
"rooms.FullName," // row[6] "rooms.FullName," // row[6]
"rooms.Capacity" // row[7] "rooms.Capacity" // row[7]
" FROM rooms LEFT JOIN buildings" " FROM rooms LEFT JOIN bld_buildings"
" ON rooms.BldCod=buildings.BldCod" " ON rooms.BldCod=bld_buildings.BldCod"
" WHERE rooms.CtrCod=%ld" " WHERE rooms.CtrCod=%ld"
" ORDER BY %s", " ORDER BY %s",
Gbl.Hierarchy.Ctr.CtrCod, Gbl.Hierarchy.Ctr.CtrCod,
@ -570,8 +582,8 @@ void Roo_GetListRooms (struct Roo_Rooms *Rooms,
NumRows = DB_QuerySELECT (&mysql_res,"can not get rooms", NumRows = DB_QuerySELECT (&mysql_res,"can not get rooms",
"SELECT rooms.RooCod," // row[0] "SELECT rooms.RooCod," // row[0]
"rooms.ShortName" // row[1] "rooms.ShortName" // row[1]
" FROM rooms LEFT JOIN buildings" " FROM rooms LEFT JOIN bld_buildings"
" ON rooms.BldCod=buildings.BldCod" " ON rooms.BldCod=bld_buildings.BldCod"
" WHERE rooms.CtrCod=%ld" " WHERE rooms.CtrCod=%ld"
" ORDER BY %s", " ORDER BY %s",
Gbl.Hierarchy.Ctr.CtrCod, Gbl.Hierarchy.Ctr.CtrCod,
@ -657,14 +669,14 @@ static void Roo_GetDataOfRoomByCod (struct Roo_Room *Room)
/***** Get data of a room from database *****/ /***** Get data of a room from database *****/
NumRows = DB_QuerySELECT (&mysql_res,"can not get data of a room", NumRows = DB_QuerySELECT (&mysql_res,"can not get data of a room",
"SELECT rooms.BldCod," // row[0] "SELECT rooms.BldCod," // row[0]
"buildings.ShortName," // row[1] "bld_buildings.ShortName," // row[1]
"rooms.Floor," // row[2] "rooms.Floor," // row[2]
"rooms.Type," // row[3] "rooms.Type," // row[3]
"rooms.ShortName," // row[4] "rooms.ShortName," // row[4]
"rooms.FullName," // row[5] "rooms.FullName," // row[5]
"rooms.Capacity" // row[6] "rooms.Capacity" // row[6]
" FROM rooms LEFT JOIN buildings" " FROM rooms LEFT JOIN bld_buildings"
" ON rooms.BldCod=buildings.BldCod" " ON rooms.BldCod=bld_buildings.BldCod"
" WHERE rooms.RooCod=%ld", " WHERE rooms.RooCod=%ld",
Room->RooCod); Room->RooCod);