diff --git a/sql/swad.sql b/sql/swad.sql index 7779da0ad..b4a0b88b4 100644 --- a/sql/swad.sql +++ b/sql/swad.sql @@ -1243,9 +1243,9 @@ CREATE TABLE IF NOT EXISTS prj_usr ( UsrCod INT NOT NULL, UNIQUE INDEX(PrjCod,RoleInProject,UsrCod)); -- --- Table rooms: stores the rooms associated to each center +-- Table roo_rooms: stores the rooms associated to each center -- -CREATE TABLE IF NOT EXISTS rooms ( +CREATE TABLE IF NOT EXISTS roo_rooms ( RooCod INT NOT NULL AUTO_INCREMENT, CtrCod INT NOT NULL, BldCod INT NOT NULL DEFAULT -1, diff --git a/swad_API.c b/swad_API.c index 0d7d0490a..3c69b42ea 100644 --- a/swad_API.c +++ b/swad_API.c @@ -6005,22 +6005,22 @@ int swad__getLocation (struct soap *soap, "bld_buildings.BldCod," // row[ 6] "bld_buildings.ShortName," // row[ 7] "bld_buildings.FullName," // row[ 8] - "rooms.Floor," // row[ 9] - "rooms.RooCod," // row[10] - "rooms.ShortName," // row[11] - "rooms.FullName" // row[12] + "roo_rooms.Floor," // row[ 9] + "roo_rooms.RooCod," // row[10] + "roo_rooms.ShortName," // row[11] + "roo_rooms.FullName" // row[12] " FROM room_MAC," - "rooms," + "roo_rooms," "bld_buildings," "ctr_centers," "ins_instits" " WHERE room_MAC.MAC=%llu" - " AND room_MAC.RooCod=rooms.RooCod" - " AND rooms.BldCod=bld_buildings.BldCod" + " AND room_MAC.RooCod=roo_rooms.RooCod" + " AND roo_rooms.BldCod=bld_buildings.BldCod" " AND bld_buildings.CtrCod=ctr_centers.CtrCod" " AND ctr_centers.InsCod=ins_instits.InsCod" - " ORDER BY rooms.Capacity DESC," // Get the biggest room - "rooms.ShortName" + " ORDER BY roo_rooms.Capacity DESC," // Get the biggest room + "roo_rooms.ShortName" " LIMIT 1", MACnum); @@ -6072,9 +6072,11 @@ int swad__sendMyLocation (struct soap *soap, DB_QueryINSERTandReturnCode ("can not save current location", "INSERT INTO room_check_in" " (UsrCod,RooCod,CheckInTime)" - " SELECT %ld,RooCod,NOW()" - " FROM rooms" - " WHERE RooCod=%d", // Check that room exists + " SELECT %ld," + "RooCod," + "NOW()" + " FROM roo_rooms" + " WHERE RooCod=%d", // Check that room exists Gbl.Usrs.Me.UsrDat.UsrCod,roomCode); /***** Return notification code *****/ @@ -6146,16 +6148,16 @@ int swad__getLastLocation (struct soap *soap, "bld_buildings.BldCod," // row[ 6] "bld_buildings.ShortName," // row[ 7] "bld_buildings.FullName," // row[ 8] - "rooms.Floor," // row[ 9] - "rooms.RooCod," // row[10] - "rooms.ShortName," // row[11] - "rooms.FullName," // row[12] + "roo_rooms.Floor," // row[ 9] + "roo_rooms.RooCod," // row[10] + "roo_rooms.ShortName," // row[11] + "roo_rooms.FullName," // row[12] "UNIX_TIMESTAMP(room_check_in.CheckInTime)" // row[13] - " FROM room_check_in," - "rooms," - "bld_buildings," - "ctr_centers," - "ins_instits" + " FROM room_check_in," + "roo_rooms," + "bld_buildings," + "ctr_centers," + "ins_instits" " WHERE room_check_in.UsrCod=%d" " AND room_check_in.ChkCod=" "(SELECT ChkCod" @@ -6163,8 +6165,8 @@ int swad__getLastLocation (struct soap *soap, " WHERE UsrCod=%d" " ORDER BY ChkCod DESC" " LIMIT 1)" // Faster than SELECT MAX - " AND room_check_in.RooCod=rooms.RooCod" - " AND rooms.BldCod=bld_buildings.BldCod" + " AND room_check_in.RooCod=roo_rooms.RooCod" + " AND roo_rooms.BldCod=bld_buildings.BldCod" " AND bld_buildings.CtrCod=ctr_centers.CtrCod" " AND ctr_centers.InsCod=ins_instits.InsCod", userCode,userCode); @@ -6211,10 +6213,10 @@ static void API_GetDataOfLocation (struct soap *soap, bld_buildings.BldCod // row[ 6] bld_buildings.ShortName // row[ 7] bld_buildings.FullName // row[ 8] - rooms.Floor // row[ 9] - rooms.RooCod // row[10] - rooms.ShortName // row[11] - rooms.FullName // row[12] + roo_rooms.Floor // row[ 9] + roo_rooms.RooCod // row[10] + roo_rooms.ShortName // row[11] + roo_rooms.FullName // row[12] UNIX_TIMESTAMP(room_check_in.CheckInTime) // row[13] (optional) */ diff --git a/swad_attendance.c b/swad_attendance.c index 1ebb7a305..e06024320 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -1534,14 +1534,17 @@ static void Att_GetAndWriteNamesOfGrpsAssociatedToAttEvent (struct Att_Event *Ev NumGrps = (unsigned) DB_QuerySELECT (&mysql_res,"can not get groups of an attendance event", "SELECT crs_grp_types.GrpTypName," "crs_grp.GrpName," - "rooms.ShortName" - " FROM (att_grp,crs_grp,crs_grp_types)" - " LEFT JOIN rooms" - " ON crs_grp.RooCod=rooms.RooCod" + "roo_rooms.ShortName" + " FROM (att_grp," + "crs_grp," + "crs_grp_types)" + " LEFT JOIN roo_rooms" + " ON crs_grp.RooCod=roo_rooms.RooCod" " WHERE att_grp.AttCod=%ld" - " AND att_grp.GrpCod=crs_grp.GrpCod" - " AND crs_grp.GrpTypCod=crs_grp_types.GrpTypCod" - " ORDER BY crs_grp_types.GrpTypName,crs_grp.GrpName", + " AND att_grp.GrpCod=crs_grp.GrpCod" + " AND crs_grp.GrpTypCod=crs_grp_types.GrpTypCod" + " ORDER BY crs_grp_types.GrpTypName," + "crs_grp.GrpName", Event->AttCod); /***** Write heading *****/ diff --git a/swad_building.c b/swad_building.c index 1c0e9914b..d1fcca294 100644 --- a/swad_building.c +++ b/swad_building.c @@ -565,12 +565,11 @@ void Bld_RemoveBuilding (void) Bld_GetDataOfBuildingByCod (Bld_EditingBuilding); /***** Update rooms assigned to this building *****/ - /* TODO: Uncomment when rooms be associated to building DB_QueryUPDATE ("can not update building in groups", - "UPDATE rooms SET BldCod=0" // 0 means another building + "UPDATE roo_rooms" + " SET BldCod=0" // 0 means another building " WHERE BldCod=%ld", Bld_EditingBuilding->BldCod); - */ /***** Remove building *****/ DB_QueryDELETE ("can not remove a building", diff --git a/swad_changelog.h b/swad_changelog.h index 07d0cd38b..9fe2e7662 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -607,6 +607,10 @@ TODO: FIX BUG, URGENT! En las fechas como par TODO: Rename CENTRE to CENTER in help wiki. TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams + Version 20.51.19: Mar 19, 2021 Rooms database table renamed. (308059 lines) + 1 change necessary in database: +RENAME TABLE rooms TO roo_rooms; + Version 20.51.19: Mar 19, 2021 Media database table renamed. (308033 lines) 1 change necessary in database: RENAME TABLE media TO med_media; diff --git a/swad_database.c b/swad_database.c index 1929d00a5..fac0e4681 100644 --- a/swad_database.c +++ b/swad_database.c @@ -2592,24 +2592,24 @@ mysql> DESCRIBE prj_usr; "UsrCod INT NOT NULL," "UNIQUE INDEX(PrjCod,RoleInProject,UsrCod))"); - /***** Table rooms *****/ + /***** Table roo_rooms *****/ /* -mysql> DESCRIBE rooms; +mysql> DESCRIBE roo_rooms; +-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------+-----+---------+----------------+ -| RooCod | int(11) | NO | PRI | NULL | auto_increment | -| CtrCod | int(11) | NO | MUL | NULL | | -| BldCod | int(11) | NO | | -1 | | -| Floor | int(11) | NO | | 0 | | +| RooCod | int | NO | PRI | NULL | auto_increment | +| CtrCod | int | NO | MUL | NULL | | +| BldCod | int | NO | | -1 | | +| Floor | int | NO | | 0 | | | Type | enum('no_type','administration','auditorium','cafeteria','canteen','classroom','concierge','corridor','gym','hall','kindergarten','laboratory','library','office','outdoors','parking','pavilion','room','secretariat','seminar','shop','store','toilets','virtual','yard') | NO | | no_type | | | ShortName | varchar(511) | NO | | NULL | | | FullName | varchar(2047) | NO | | NULL | | -| Capacity | int(11) | NO | | NULL | | +| Capacity | int | NO | | NULL | | +-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------+-----+---------+----------------+ 8 rows in set (0.00 sec) */ - DB_CreateTable ("CREATE TABLE IF NOT EXISTS rooms (" + DB_CreateTable ("CREATE TABLE IF NOT EXISTS roo_rooms (" "RooCod INT NOT NULL AUTO_INCREMENT," "CtrCod INT NOT NULL," "BldCod INT NOT NULL DEFAULT -1," diff --git a/swad_group.c b/swad_group.c index 687f41c3e..7465abbdb 100644 --- a/swad_group.c +++ b/swad_group.c @@ -982,7 +982,7 @@ static void Grp_LockTables (void) "crs_grp_usr WRITE," "crs_usr READ," "crs_usr_last READ," - "rooms READ"); + "roo_rooms READ"); Gbl.DB.LockedTables = true; } @@ -3068,13 +3068,13 @@ unsigned long Grp_GetGrpsOfType (long GrpTypCod,MYSQL_RES **mysql_res) "SELECT crs_grp.GrpCod," "crs_grp.GrpName," "crs_grp.RooCod," - "rooms.ShortName," + "roo_rooms.ShortName," "crs_grp.MaxStudents," "crs_grp.Open," "crs_grp.FileZones" - " FROM crs_grp" - " LEFT JOIN rooms" - " ON crs_grp.RooCod=rooms.RooCod" + " FROM crs_grp" + " LEFT JOIN roo_rooms" + " ON crs_grp.RooCod=roo_rooms.RooCod" " WHERE crs_grp.GrpTypCod=%ld" " ORDER BY crs_grp.GrpName", GrpTypCod); @@ -3175,13 +3175,14 @@ void Grp_GetDataOfGroupByCod (struct GroupData *GrpDat) "crs_grp_types.Multiple," // row[3] "crs_grp.GrpName," // row[4] "crs_grp.RooCod," // row[5] - "rooms.ShortName," // row[6] + "roo_rooms.ShortName," // row[6] "crs_grp.MaxStudents," // row[7] "crs_grp.Open," // row[8] "crs_grp.FileZones" // row[9] - " FROM (crs_grp,crs_grp_types)" - " LEFT JOIN rooms" - " ON crs_grp.RooCod=rooms.RooCod" + " FROM (crs_grp," + "crs_grp_types)" + " LEFT JOIN roo_rooms" + " ON crs_grp.RooCod=roo_rooms.RooCod" " WHERE crs_grp.GrpCod=%ld" " AND crs_grp.GrpTypCod=crs_grp_types.GrpTypCod", GrpDat->GrpCod); diff --git a/swad_room.c b/swad_room.c index f97f3772b..70f4c0fb8 100644 --- a/swad_room.c +++ b/swad_room.c @@ -533,23 +533,23 @@ void Roo_GetListRooms (struct Roo_Rooms *Rooms, static const char *OrderBySubQuery[Roo_NUM_ORDERS] = { [Roo_ORDER_BY_BUILDING ] = "bld_buildings.ShortName," - "rooms.Floor," - "rooms.ShortName", - [Roo_ORDER_BY_FLOOR ] = "rooms.Floor," + "roo_rooms.Floor," + "roo_rooms.ShortName", + [Roo_ORDER_BY_FLOOR ] = "roo_rooms.Floor," "bld_buildings.ShortName," - "rooms.ShortName", - [Roo_ORDER_BY_TYPE ] = "rooms.Type," + "roo_rooms.ShortName", + [Roo_ORDER_BY_TYPE ] = "roo_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," + "roo_rooms.Floor," + "roo_rooms.ShortName", + [Roo_ORDER_BY_SHRT_NAME] = "roo_rooms.ShortName," + "roo_rooms.FullName", + [Roo_ORDER_BY_FULL_NAME] = "roo_rooms.FullName," + "roo_rooms.ShortName", + [Roo_ORDER_BY_CAPACITY ] = "roo_rooms.Capacity DESC," "bld_buildings.ShortName," - "rooms.Floor," - "rooms.ShortName", + "roo_rooms.Floor," + "roo_rooms.ShortName", }; MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -562,17 +562,18 @@ void Roo_GetListRooms (struct Roo_Rooms *Rooms, { case Roo_ALL_DATA: NumRows = DB_QuerySELECT (&mysql_res,"can not get rooms", - "SELECT rooms.RooCod," // row[0] - "rooms.BldCod," // row[1] + "SELECT roo_rooms.RooCod," // row[0] + "roo_rooms.BldCod," // row[1] "bld_buildings.ShortName," // row[2] - "rooms.Floor," // row[3] - "rooms.Type," // row[4] - "rooms.ShortName," // row[5] - "rooms.FullName," // row[6] - "rooms.Capacity" // row[7] - " FROM rooms LEFT JOIN bld_buildings" - " ON rooms.BldCod=bld_buildings.BldCod" - " WHERE rooms.CtrCod=%ld" + "roo_rooms.Floor," // row[3] + "roo_rooms.Type," // row[4] + "roo_rooms.ShortName," // row[5] + "roo_rooms.FullName," // row[6] + "roo_rooms.Capacity" // row[7] + " FROM roo_rooms" + " LEFT JOIN bld_buildings" + " ON roo_rooms.BldCod=bld_buildings.BldCod" + " WHERE roo_rooms.CtrCod=%ld" " ORDER BY %s", Gbl.Hierarchy.Ctr.CtrCod, OrderBySubQuery[Rooms->SelectedOrder]); @@ -580,11 +581,11 @@ void Roo_GetListRooms (struct Roo_Rooms *Rooms, case Roo_ONLY_SHRT_NAME: default: NumRows = DB_QuerySELECT (&mysql_res,"can not get rooms", - "SELECT rooms.RooCod," // row[0] - "rooms.ShortName" // row[1] - " FROM rooms LEFT JOIN bld_buildings" - " ON rooms.BldCod=bld_buildings.BldCod" - " WHERE rooms.CtrCod=%ld" + "SELECT roo_rooms.RooCod," // row[0] + "roo_rooms.ShortName" // row[1] + " FROM roo_rooms LEFT JOIN bld_buildings" + " ON roo_rooms.BldCod=bld_buildings.BldCod" + " WHERE roo_rooms.CtrCod=%ld" " ORDER BY %s", Gbl.Hierarchy.Ctr.CtrCod, OrderBySubQuery[Roo_ORDER_DEFAULT]); @@ -668,16 +669,16 @@ static void Roo_GetDataOfRoomByCod (struct Roo_Room *Room) /***** Get data of a room from database *****/ NumRows = DB_QuerySELECT (&mysql_res,"can not get data of a room", - "SELECT rooms.BldCod," // row[0] + "SELECT roo_rooms.BldCod," // row[0] "bld_buildings.ShortName," // row[1] - "rooms.Floor," // row[2] - "rooms.Type," // row[3] - "rooms.ShortName," // row[4] - "rooms.FullName," // row[5] - "rooms.Capacity" // row[6] - " FROM rooms LEFT JOIN bld_buildings" - " ON rooms.BldCod=bld_buildings.BldCod" - " WHERE rooms.RooCod=%ld", + "roo_rooms.Floor," // row[2] + "roo_rooms.Type," // row[3] + "roo_rooms.ShortName," // row[4] + "roo_rooms.FullName," // row[5] + "roo_rooms.Capacity" // row[6] + " FROM roo_rooms LEFT JOIN bld_buildings" + " ON roo_rooms.BldCod=bld_buildings.BldCod" + " WHERE roo_rooms.RooCod=%ld", Room->RooCod); /***** Count number of rows in result *****/ @@ -1017,7 +1018,8 @@ void Roo_RemoveRoom (void) /***** Remove room *****/ DB_QueryDELETE ("can not remove a room", - "DELETE FROM rooms WHERE RooCod=%ld", + "DELETE FROM roo_rooms" + " WHERE RooCod=%ld", Roo_EditingRoom->RooCod); /***** Create message to show the change made *****/ @@ -1034,7 +1036,7 @@ void Roo_RemoveAllRoomsInCtr (long CtrCod) { /***** Remove all rooms in center *****/ DB_QueryDELETE ("can not remove rooms", - "DELETE FROM rooms" + "DELETE FROM roo_rooms" " WHERE CtrCod=%ld", CtrCod); } @@ -1076,7 +1078,9 @@ void Roo_ChangeBuilding (void) { /***** Update the table of rooms changing the old building for the new one *****/ DB_QueryUPDATE ("can not update the building of a room", - "UPDATE rooms SET BldCod=%ld WHERE RooCod=%ld", + "UPDATE roo_rooms" + " SET BldCod=%ld" + " WHERE RooCod=%ld", NewBldCod,Roo_EditingRoom->RooCod); /***** Get updated data of the room from database *****/ @@ -1124,7 +1128,9 @@ void Roo_ChangeFloor (void) { /***** Update the table of rooms changing the old floor for the new one *****/ DB_QueryUPDATE ("can not update the capacity of a room", - "UPDATE rooms SET Floor=%d WHERE RooCod=%ld", + "UPDATE roo_rooms" + " SET Floor=%d" + " WHERE RooCod=%ld", NewFloor,Roo_EditingRoom->RooCod); /***** Get updated data of the room from database *****/ @@ -1175,7 +1181,9 @@ void Roo_ChangeType (void) { /***** Update the table of rooms changing the old type for the new one *****/ DB_QueryUPDATE ("can not update the type of a room", - "UPDATE rooms SET Type='%s' WHERE RooCod=%ld", + "UPDATE roo_rooms" + " SET Type='%s'" + " WHERE RooCod=%ld", Roo_TypesDB[NewType], Roo_EditingRoom->RooCod); @@ -1301,11 +1309,14 @@ static bool Roo_CheckIfRoomNameExists (const char *FieldName,const char *Name,lo /***** Get number of rooms with a name from database *****/ return (DB_QueryCOUNT ("can not check if the name of a room" " already existed", - "SELECT COUNT(*) FROM rooms" + "SELECT COUNT(*)" + " FROM roo_rooms" " WHERE CtrCod=%ld" - " AND %s='%s' AND RooCod<>%ld", + " AND %s='%s'" + " AND RooCod<>%ld", Gbl.Hierarchy.Ctr.CtrCod, - FieldName,Name,RooCod) != 0); + FieldName,Name, + RooCod) != 0); } /*****************************************************************************/ @@ -1316,7 +1327,9 @@ static void Roo_UpdateRoomNameDB (long RooCod,const char *FieldName,const char * { /***** Update room changing old name by new name */ DB_QueryUPDATE ("can not update the name of a room", - "UPDATE rooms SET %s='%s' WHERE RooCod=%ld", + "UPDATE roo_rooms" + " SET %s='%s'" + " WHERE RooCod=%ld", FieldName,NewRoomName,RooCod); } @@ -1360,7 +1373,9 @@ void Roo_ChangeCapacity (void) { /***** Update the table of rooms changing the old capacity for the new one *****/ DB_QueryUPDATE ("can not update the capacity of a room", - "UPDATE rooms SET Capacity=%u WHERE RooCod=%ld", + "UPDATE roo_rooms" + " SET Capacity=%u" + " WHERE RooCod=%ld", NewCapacity,Roo_EditingRoom->RooCod); Roo_EditingRoom->Capacity = NewCapacity; @@ -1602,7 +1617,7 @@ static void Roo_CreateRoom (struct Roo_Room *Room) /***** Create a new room *****/ Room->RooCod = DB_QueryINSERTandReturnCode ("can not create room", - "INSERT INTO rooms" + "INSERT INTO roo_rooms" " (CtrCod,BldCod,Floor,Type,ShortName,FullName,Capacity)" " VALUES" " (%ld,%ld,%d,'%s','%s','%s',%u)",