2014-12-01 23:55:08 +01:00
|
|
|
|
// swad_place.c: places
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
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.
|
2024-02-07 00:40:28 +01:00
|
|
|
|
Copyright (C) 1999-2024 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 12:39:00 +01:00
|
|
|
|
#include <stddef.h> // For NULL
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include <stdlib.h> // For calloc
|
|
|
|
|
#include <string.h> // For string functions
|
|
|
|
|
|
2022-11-06 18:11:10 +01:00
|
|
|
|
#include "swad_action_list.h"
|
2022-10-19 18:07:49 +02:00
|
|
|
|
#include "swad_alert.h"
|
2017-06-10 21:38:10 +02:00
|
|
|
|
#include "swad_box.h"
|
2021-06-02 20:47:31 +02:00
|
|
|
|
#include "swad_center_database.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_constant.h"
|
|
|
|
|
#include "swad_database.h"
|
2021-04-26 15:27:27 +02:00
|
|
|
|
#include "swad_error.h"
|
2018-11-09 20:47:39 +01:00
|
|
|
|
#include "swad_form.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_global.h"
|
2019-10-23 19:05:05 +02:00
|
|
|
|
#include "swad_HTML.h"
|
2018-12-08 16:43:13 +01:00
|
|
|
|
#include "swad_language.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_parameter.h"
|
2023-03-10 17:21:04 +01:00
|
|
|
|
#include "swad_parameter_code.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_place.h"
|
2021-10-05 22:55:32 +02:00
|
|
|
|
#include "swad_place_database.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private variables *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-13 21:26:47 +02:00
|
|
|
|
static struct Plc_Place *Plc_EditingPlc = NULL; // Static variable to keep the place being edited
|
2019-04-09 00:24:50 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private prototypes ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2024-04-19 12:00:30 +02:00
|
|
|
|
static Usr_Can_t Plc_CheckIfICanEditPlaces (void);
|
2024-04-01 17:59:51 +02:00
|
|
|
|
|
2023-03-10 00:13:55 +01:00
|
|
|
|
static Plc_Order_t Plc_GetParPlcOrder (void);
|
2020-04-08 22:09:35 +02:00
|
|
|
|
static void Plc_PutIconsListingPlaces (__attribute__((unused)) void *Args);
|
2016-03-16 22:40:35 +01:00
|
|
|
|
static void Plc_PutIconToEditPlaces (void);
|
2019-04-09 00:24:50 +02:00
|
|
|
|
static void Plc_EditPlacesInternal (void);
|
2020-04-08 22:09:35 +02:00
|
|
|
|
static void Plc_PutIconsEditingPlaces (__attribute__((unused)) void *Args);
|
2018-11-15 10:13:53 +01:00
|
|
|
|
|
2023-03-23 18:28:56 +01:00
|
|
|
|
static void Plc_GetPlaceDataFromRow (MYSQL_RES *mysql_res,struct Plc_Place *Plc);
|
|
|
|
|
|
2020-04-13 21:26:47 +02:00
|
|
|
|
static void Plc_ListPlacesForEdition (const struct Plc_Places *Places);
|
2023-03-10 00:13:55 +01:00
|
|
|
|
static void Plc_PutParPlcCod (void *PlcCod);
|
2017-03-09 11:16:17 +01:00
|
|
|
|
|
2023-10-11 00:02:14 +02:00
|
|
|
|
static void Plc_RenamePlace (Nam_ShrtOrFullName_t ShrtOrFull);
|
2017-03-09 11:16:17 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static void Plc_PutFormToCreatePlace (void);
|
|
|
|
|
static void Plc_PutHeadPlaces (void);
|
|
|
|
|
|
2019-04-09 00:24:50 +02:00
|
|
|
|
static void Plc_EditingPlaceConstructor (void);
|
|
|
|
|
static void Plc_EditingPlaceDestructor (void);
|
|
|
|
|
|
2024-04-01 17:59:51 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Check if I can edit places ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2024-04-19 12:00:30 +02:00
|
|
|
|
static Usr_Can_t Plc_CheckIfICanEditPlaces (void)
|
2024-04-01 17:59:51 +02:00
|
|
|
|
{
|
2024-04-19 12:00:30 +02:00
|
|
|
|
static Usr_Can_t Plc_ICanEditPlaces[Rol_NUM_ROLES] =
|
2024-04-01 17:59:51 +02:00
|
|
|
|
{
|
|
|
|
|
/* Users who can edit */
|
2024-04-19 12:00:30 +02:00
|
|
|
|
[Rol_INS_ADM] = Usr_CAN,
|
|
|
|
|
[Rol_SYS_ADM] = Usr_CAN,
|
2024-04-01 17:59:51 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return Plc_ICanEditPlaces[Gbl.Usrs.Me.Role.Logged];
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-13 21:26:47 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************************** Reset places context ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Plc_ResetPlaces (struct Plc_Places *Places)
|
|
|
|
|
{
|
2020-04-13 22:04:46 +02:00
|
|
|
|
Places->Num = 0;
|
|
|
|
|
Places->Lst = NULL;
|
2020-04-13 21:26:47 +02:00
|
|
|
|
Places->SelectedOrder = Plc_ORDER_DEFAULT;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
2021-10-30 13:28:48 +02:00
|
|
|
|
/***************************** List all places *******************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-04-19 12:11:38 +02:00
|
|
|
|
void Plc_SeeAllPlaces (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2016-11-28 12:11:44 +01:00
|
|
|
|
extern const char *Hlp_INSTITUTION_Places;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Places;
|
|
|
|
|
extern const char *Txt_PLACES_HELP_ORDER[2];
|
|
|
|
|
extern const char *Txt_PLACES_ORDER[2];
|
|
|
|
|
extern const char *Txt_Other_places;
|
|
|
|
|
extern const char *Txt_Place_unspecified;
|
2020-04-13 21:26:47 +02:00
|
|
|
|
struct Plc_Places Places;
|
2017-01-29 12:42:19 +01:00
|
|
|
|
Plc_Order_t Order;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned NumPlc;
|
|
|
|
|
unsigned NumCtrsWithPlc = 0;
|
|
|
|
|
unsigned NumCtrsInOtherPlcs;
|
|
|
|
|
|
2023-09-22 14:47:56 +02:00
|
|
|
|
if (Gbl.Hierarchy.Node[Hie_INS].HieCod > 0)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-04-13 21:26:47 +02:00
|
|
|
|
/***** Reset places context *****/
|
|
|
|
|
Plc_ResetPlaces (&Places);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get parameter with the type of order in the list of places *****/
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Places.SelectedOrder = Plc_GetParPlcOrder ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get list of places *****/
|
2020-04-13 21:26:47 +02:00
|
|
|
|
Plc_GetListPlaces (&Places);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2024-01-29 09:45:28 +01:00
|
|
|
|
/***** Begin box *****/
|
|
|
|
|
Box_BoxBegin (Txt_Places,Plc_PutIconsListingPlaces,NULL,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
Hlp_INSTITUTION_Places,Box_NOT_CLOSABLE);
|
2024-01-29 09:45:28 +01:00
|
|
|
|
|
|
|
|
|
/***** Table head *****/
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_TABLE_BeginWideMarginPadding (2);
|
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
for (Order = (Plc_Order_t) 0;
|
|
|
|
|
Order <= (Plc_Order_t) (Plc_NUM_ORDERS - 1);
|
|
|
|
|
Order++)
|
|
|
|
|
{
|
2022-01-02 15:17:30 +01:00
|
|
|
|
HTM_TH_Begin (HTM_HEAD_LEFT);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
|
|
|
|
|
Frm_BeginForm (ActSeePlc);
|
2023-03-07 09:55:39 +01:00
|
|
|
|
Par_PutParUnsigned (NULL,"Order",(unsigned) Order);
|
2022-04-01 01:06:44 +02:00
|
|
|
|
HTM_BUTTON_Submit_Begin (Txt_PLACES_HELP_ORDER[Order],
|
|
|
|
|
"class=\"BT_LINK\"");
|
2021-07-08 15:00:17 +02:00
|
|
|
|
if (Order == Places.SelectedOrder)
|
|
|
|
|
HTM_U_Begin ();
|
|
|
|
|
HTM_Txt (Txt_PLACES_ORDER[Order]);
|
|
|
|
|
if (Order == Places.SelectedOrder)
|
|
|
|
|
HTM_U_End ();
|
|
|
|
|
HTM_BUTTON_End ();
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
|
|
|
|
|
HTM_TH_End ();
|
|
|
|
|
}
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
|
|
|
|
|
/***** Write all places and their nuber of centers *****/
|
|
|
|
|
for (NumPlc = 0;
|
|
|
|
|
NumPlc < Places.Num;
|
|
|
|
|
NumPlc++)
|
|
|
|
|
{
|
|
|
|
|
/* Write data of this place */
|
|
|
|
|
HTM_TR_Begin (NULL);
|
2023-10-14 21:36:39 +02:00
|
|
|
|
HTM_TD_Txt_Left (Places.Lst[NumPlc].FullName);
|
|
|
|
|
HTM_TD_Unsigned (Places.Lst[NumPlc].NumCtrs);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_TR_End ();
|
2023-10-14 21:36:39 +02:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
NumCtrsWithPlc += Places.Lst[NumPlc].NumCtrs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Separation row *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
2024-06-20 10:51:17 +02:00
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"DAT_%s\"",The_GetSuffix ());
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_NBSP ();
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
|
|
|
|
|
/***** Write centers (of the current institution) with other place *****/
|
|
|
|
|
NumCtrsInOtherPlcs = Ctr_DB_GetNumCtrsInPlc (0);
|
|
|
|
|
|
2023-10-14 21:36:39 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
HTM_TD_Txt_Left (Txt_Other_places);
|
|
|
|
|
HTM_TD_Unsigned (NumCtrsInOtherPlcs);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_TR_End ();
|
2023-10-14 21:36:39 +02:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
NumCtrsWithPlc += NumCtrsInOtherPlcs;
|
|
|
|
|
|
|
|
|
|
/***** Write centers (of the current institution) with no place *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
2023-10-14 21:36:39 +02:00
|
|
|
|
HTM_TD_Txt_Left (Txt_Place_unspecified);
|
2023-10-11 22:45:34 +02:00
|
|
|
|
HTM_TD_Unsigned (Hie_GetNumNodesInHieLvl (Hie_CTR, // Number of centers...
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Hie_INS, // ...in institution
|
|
|
|
|
Gbl.Hierarchy.Node[Hie_INS].HieCod) -
|
2021-07-08 15:00:17 +02:00
|
|
|
|
NumCtrsWithPlc);
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
|
|
|
|
|
/***** End table *****/
|
|
|
|
|
HTM_TABLE_End ();
|
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End box *****/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Box_BoxEnd ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free list of places *****/
|
2020-04-13 21:26:47 +02:00
|
|
|
|
Plc_FreeListPlaces (&Places);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********** Get parameter with the type or order in list of places ***********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-03-10 00:13:55 +01:00
|
|
|
|
static Plc_Order_t Plc_GetParPlcOrder (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2023-03-07 09:55:39 +01:00
|
|
|
|
return (Plc_Order_t) Par_GetParUnsignedLong ("Order",
|
2023-03-10 00:13:55 +01:00
|
|
|
|
0,
|
|
|
|
|
Plc_NUM_ORDERS - 1,
|
|
|
|
|
(unsigned long) Plc_ORDER_DEFAULT);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-11-15 10:33:45 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Put contextual icons in list of places *******************/
|
2018-11-15 10:13:53 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-08 22:09:35 +02:00
|
|
|
|
static void Plc_PutIconsListingPlaces (__attribute__((unused)) void *Args)
|
2018-11-15 10:13:53 +01:00
|
|
|
|
{
|
2020-04-08 22:09:35 +02:00
|
|
|
|
/***** Put icon to edit places *****/
|
2024-04-19 12:00:30 +02:00
|
|
|
|
if (Plc_CheckIfICanEditPlaces () == Usr_CAN)
|
2020-04-08 22:09:35 +02:00
|
|
|
|
Plc_PutIconToEditPlaces ();
|
2018-11-15 10:13:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Put a link (form) to edit places *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-03-16 22:40:35 +01:00
|
|
|
|
static void Plc_PutIconToEditPlaces (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2024-04-01 17:59:51 +02:00
|
|
|
|
Ico_PutContextualIconToEdit (ActEdiPlc,NULL,NULL,NULL);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************************** Put forms to edit places ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Plc_EditPlaces (void)
|
2019-04-09 00:24:50 +02:00
|
|
|
|
{
|
|
|
|
|
/***** Place constructor *****/
|
|
|
|
|
Plc_EditingPlaceConstructor ();
|
|
|
|
|
|
|
|
|
|
/***** Edit places *****/
|
|
|
|
|
Plc_EditPlacesInternal ();
|
|
|
|
|
|
|
|
|
|
/***** Place destructor *****/
|
|
|
|
|
Plc_EditingPlaceDestructor ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void Plc_EditPlacesInternal (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-04-30 21:00:56 +02:00
|
|
|
|
extern const char *Hlp_INSTITUTION_Places_edit;
|
|
|
|
|
extern const char *Txt_Places;
|
2020-04-13 21:26:47 +02:00
|
|
|
|
struct Plc_Places Places;
|
|
|
|
|
|
|
|
|
|
/***** Reset places context *****/
|
|
|
|
|
Plc_ResetPlaces (&Places);
|
2017-04-30 21:00:56 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get list of places *****/
|
2020-04-13 21:26:47 +02:00
|
|
|
|
Plc_GetListPlaces (&Places);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box *****/
|
2024-01-29 09:45:28 +01:00
|
|
|
|
Box_BoxBegin (Txt_Places,Plc_PutIconsEditingPlaces,NULL,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
Hlp_INSTITUTION_Places_edit,Box_NOT_CLOSABLE);
|
2017-04-30 21:00:56 +02:00
|
|
|
|
|
2024-01-29 09:45:28 +01:00
|
|
|
|
/***** Put a form to create a new place *****/
|
|
|
|
|
Plc_PutFormToCreatePlace ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2024-01-29 09:45:28 +01:00
|
|
|
|
/***** Forms to edit current places *****/
|
|
|
|
|
if (Places.Num)
|
|
|
|
|
Plc_ListPlacesForEdition (&Places);
|
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 21:00:56 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Free list of places *****/
|
2020-04-13 21:26:47 +02:00
|
|
|
|
Plc_FreeListPlaces (&Places);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-30 21:00:56 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************** Put contextual icons in edition of places *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-08 22:09:35 +02:00
|
|
|
|
static void Plc_PutIconsEditingPlaces (__attribute__((unused)) void *Args)
|
2017-04-30 21:00:56 +02:00
|
|
|
|
{
|
2020-04-08 22:09:35 +02:00
|
|
|
|
/***** Put icon to view places *****/
|
2024-04-01 17:59:51 +02:00
|
|
|
|
Ico_PutContextualIconToView (ActSeePlc,NULL,NULL,NULL);
|
2018-11-15 10:41:11 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Put icon to view places **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Plc_PutIconToViewPlaces (void)
|
|
|
|
|
{
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Lay_PutContextualLinkOnlyIcon (ActSeePlc,NULL,
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Ins_PutParInsCod,&Gbl.Hierarchy.Node[Hie_INS].HieCod,
|
2022-06-29 18:34:15 +02:00
|
|
|
|
"map-marker-alt.svg",Ico_BLACK);
|
2017-04-30 21:00:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
2021-10-30 13:28:48 +02:00
|
|
|
|
/******************************* List all places *****************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-13 21:26:47 +02:00
|
|
|
|
void Plc_GetListPlaces (struct Plc_Places *Places)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
unsigned NumPlc;
|
|
|
|
|
|
|
|
|
|
/***** Get places from database *****/
|
2021-10-05 22:55:32 +02:00
|
|
|
|
if ((Places->Num = Plc_DB_GetListPlaces (&mysql_res,Places->SelectedOrder))) // Places found...
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Create list with courses in center *****/
|
2021-04-17 01:08:48 +02:00
|
|
|
|
if ((Places->Lst = calloc ((size_t) Places->Num,
|
|
|
|
|
sizeof (*Places->Lst))) == NULL)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get the places *****/
|
|
|
|
|
for (NumPlc = 0;
|
2020-04-13 21:26:47 +02:00
|
|
|
|
NumPlc < Places->Num;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
NumPlc++)
|
2023-03-23 22:47:23 +01:00
|
|
|
|
Plc_GetPlaceDataFromRow (mysql_res,&Places->Lst[NumPlc]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2023-03-23 18:28:56 +01:00
|
|
|
|
/************************ Get place data using its code **********************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-03-23 09:35:20 +01:00
|
|
|
|
void Plc_GetPlaceDataByCod (struct Plc_Place *Plc)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2015-12-09 22:05:21 +01:00
|
|
|
|
extern const char *Txt_Place_unspecified;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Another_place;
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
|
|
|
|
|
/***** Clear data *****/
|
2016-10-28 10:03:37 +02:00
|
|
|
|
Plc->ShrtName[0] = '\0';
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Plc->FullName[0] = '\0';
|
|
|
|
|
Plc->NumCtrs = 0;
|
|
|
|
|
|
|
|
|
|
/***** Check if place code is correct *****/
|
2015-12-09 22:05:21 +01:00
|
|
|
|
if (Plc->PlcCod < 0)
|
|
|
|
|
{
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (Plc->ShrtName,Txt_Place_unspecified,sizeof (Plc->ShrtName) - 1);
|
|
|
|
|
Str_Copy (Plc->FullName,Txt_Place_unspecified,sizeof (Plc->FullName) - 1);
|
2015-12-09 22:05:21 +01:00
|
|
|
|
}
|
|
|
|
|
else if (Plc->PlcCod == 0)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-02-15 22:49:44 +01:00
|
|
|
|
Str_Copy (Plc->ShrtName,Txt_Another_place ,sizeof (Plc->ShrtName) - 1);
|
|
|
|
|
Str_Copy (Plc->FullName,Txt_Another_place ,sizeof (Plc->FullName) - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else if (Plc->PlcCod > 0)
|
|
|
|
|
{
|
|
|
|
|
/***** Get data of a place from database *****/
|
2023-03-23 09:35:20 +01:00
|
|
|
|
if (Plc_DB_GetPlaceDataByCod (&mysql_res,Plc->PlcCod)) // Place found...
|
2023-03-23 18:28:56 +01:00
|
|
|
|
Plc_GetPlaceDataFromRow (mysql_res,Plc);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-23 18:28:56 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Get place data from database row *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Plc_GetPlaceDataFromRow (MYSQL_RES *mysql_res,struct Plc_Place *Plc)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
|
2023-03-23 19:56:18 +01:00
|
|
|
|
/***** Get next row from result *****/
|
2023-03-23 18:28:56 +01:00
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/***** Get place code (row[0]) *****/
|
|
|
|
|
if ((Plc->PlcCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
|
|
|
|
|
Err_WrongPlaceExit ();
|
|
|
|
|
|
|
|
|
|
/***** Get the short (row[1]) and full (row[2]) names of the place *****/
|
|
|
|
|
Str_Copy (Plc->ShrtName,row[1],sizeof (Plc->ShrtName) - 1);
|
|
|
|
|
Str_Copy (Plc->FullName,row[2],sizeof (Plc->FullName) - 1);
|
|
|
|
|
|
|
|
|
|
/***** Get number of centers in this place (row[3]) *****/
|
|
|
|
|
if (sscanf (row[3],"%u",&Plc->NumCtrs) != 1)
|
|
|
|
|
Plc->NumCtrs = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************************** Free list of places ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-13 21:26:47 +02:00
|
|
|
|
void Plc_FreeListPlaces (struct Plc_Places *Places)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-04-13 21:26:47 +02:00
|
|
|
|
if (Places->Lst)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Free memory used by the list of places in institution *****/
|
2020-04-13 21:26:47 +02:00
|
|
|
|
free (Places->Lst);
|
|
|
|
|
Places->Lst = NULL;
|
|
|
|
|
Places->Num = 0;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-10-30 13:28:48 +02:00
|
|
|
|
/***************************** List all places *******************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-13 21:26:47 +02:00
|
|
|
|
static void Plc_ListPlacesForEdition (const struct Plc_Places *Places)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2024-03-20 09:39:04 +01:00
|
|
|
|
static Act_Action_t ActionRename[Nam_NUM_SHRT_FULL_NAMES] =
|
2023-10-09 17:07:19 +02:00
|
|
|
|
{
|
2023-10-10 10:51:21 +02:00
|
|
|
|
[Nam_SHRT_NAME] = ActRenPlcSho,
|
|
|
|
|
[Nam_FULL_NAME] = ActRenPlcFul,
|
2023-10-09 17:07:19 +02:00
|
|
|
|
};
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned NumPlc;
|
2020-04-13 21:26:47 +02:00
|
|
|
|
struct Plc_Place *Plc;
|
2023-10-10 10:51:21 +02:00
|
|
|
|
const char *Names[Nam_NUM_SHRT_FULL_NAMES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/***** Begin table *****/
|
2024-01-30 00:20:11 +01:00
|
|
|
|
HTM_TABLE_Begin ("TBL_SCROLL");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/***** Write heading *****/
|
|
|
|
|
Plc_PutHeadPlaces ();
|
|
|
|
|
|
2021-10-30 13:28:48 +02:00
|
|
|
|
/***** Write all places *****/
|
2021-07-08 15:00:17 +02:00
|
|
|
|
for (NumPlc = 0;
|
|
|
|
|
NumPlc < Places->Num;
|
|
|
|
|
NumPlc++)
|
|
|
|
|
{
|
|
|
|
|
Plc = &Places->Lst[NumPlc];
|
|
|
|
|
|
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
|
|
|
|
|
/* Put icon to remove place */
|
|
|
|
|
HTM_TD_Begin ("class=\"BM\"");
|
|
|
|
|
if (Plc->NumCtrs) // Place has centers ==> deletion forbidden
|
|
|
|
|
Ico_PutIconRemovalNotAllowed ();
|
|
|
|
|
else
|
|
|
|
|
Ico_PutContextualIconToRemove (ActRemPlc,NULL,
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Plc_PutParPlcCod,&Plc->PlcCod);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Place code */
|
2023-05-09 18:28:04 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"CODE DAT_%s\"",The_GetSuffix ());
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_Long (Plc->PlcCod);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
2023-10-09 17:07:19 +02:00
|
|
|
|
/* Place short name and full name */
|
2023-10-10 10:51:21 +02:00
|
|
|
|
Names[Nam_SHRT_NAME] = Plc->ShrtName;
|
|
|
|
|
Names[Nam_FULL_NAME] = Plc->FullName;
|
|
|
|
|
Nam_ExistingShortAndFullNames (ActionRename,
|
2023-10-10 09:35:17 +02:00
|
|
|
|
ParCod_Plc,Plc->PlcCod,
|
|
|
|
|
Names,
|
2024-04-01 17:59:51 +02:00
|
|
|
|
Frm_PUT_FORM);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
|
|
|
|
|
/* Number of centers */
|
2023-10-11 22:45:34 +02:00
|
|
|
|
HTM_TD_Unsigned (Plc->NumCtrs);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-05-01 10:22:16 +02:00
|
|
|
|
/***** End table *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Write parameter with code of place *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-03-10 00:13:55 +01:00
|
|
|
|
static void Plc_PutParPlcCod (void *PlcCod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-10-13 22:34:31 +02:00
|
|
|
|
if (PlcCod)
|
2023-03-10 17:21:04 +01:00
|
|
|
|
ParCod_PutPar (ParCod_Plc,*((long *) PlcCod));
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************************* Remove a place ******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Plc_RemovePlace (void)
|
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
extern const char *Txt_To_remove_a_place_you_must_first_remove_all_centers_of_that_place;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Place_X_removed;
|
2019-04-09 00:24:50 +02:00
|
|
|
|
|
|
|
|
|
/***** Place constructor *****/
|
|
|
|
|
Plc_EditingPlaceConstructor ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get place code *****/
|
2023-03-10 17:21:04 +01:00
|
|
|
|
Plc_EditingPlc->PlcCod = ParCod_GetAndCheckPar (ParCod_Plc);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2023-04-13 14:25:52 +02:00
|
|
|
|
/***** Get place data from database *****/
|
2023-03-23 09:35:20 +01:00
|
|
|
|
Plc_GetPlaceDataByCod (Plc_EditingPlc);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Check if this place has centers *****/
|
|
|
|
|
if (Plc_EditingPlc->NumCtrs) // Place has centers ==> don't remove
|
2019-04-09 00:24:50 +02:00
|
|
|
|
Ale_CreateAlert (Ale_WARNING,NULL,
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Txt_To_remove_a_place_you_must_first_remove_all_centers_of_that_place);
|
|
|
|
|
else // Place has no centers ==> remove it
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Remove place *****/
|
2021-10-05 22:55:32 +02:00
|
|
|
|
Plc_DB_RemovePlace (Plc_EditingPlc->PlcCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write message to show the change made *****/
|
2019-04-09 00:24:50 +02:00
|
|
|
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
|
|
|
|
Txt_Place_X_removed,
|
|
|
|
|
Plc_EditingPlc->FullName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Change the short name of a place **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2024-04-23 23:54:23 +02:00
|
|
|
|
void Plc_RenamePlaceShrt (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-04-09 00:24:50 +02:00
|
|
|
|
/***** Place constructor *****/
|
|
|
|
|
Plc_EditingPlaceConstructor ();
|
|
|
|
|
|
|
|
|
|
/***** Rename place *****/
|
2023-10-10 10:51:21 +02:00
|
|
|
|
Plc_RenamePlace (Nam_SHRT_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Change the full name of a place ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Plc_RenamePlaceFull (void)
|
|
|
|
|
{
|
2019-04-09 00:24:50 +02:00
|
|
|
|
/***** Place constructor *****/
|
|
|
|
|
Plc_EditingPlaceConstructor ();
|
|
|
|
|
|
|
|
|
|
/***** Rename place *****/
|
2023-10-10 10:51:21 +02:00
|
|
|
|
Plc_RenamePlace (Nam_FULL_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Change the name of a place *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-10-11 00:02:14 +02:00
|
|
|
|
static void Plc_RenamePlace (Nam_ShrtOrFullName_t ShrtOrFull)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2023-10-11 00:02:14 +02:00
|
|
|
|
extern const char *Nam_Fields[Nam_NUM_SHRT_FULL_NAMES];
|
|
|
|
|
extern unsigned Nam_MaxBytes[Nam_NUM_SHRT_FULL_NAMES];
|
2023-10-10 19:12:17 +02:00
|
|
|
|
extern const char *Txt_X_already_exists;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_The_place_X_has_been_renamed_as_Y;
|
2022-05-12 22:16:39 +02:00
|
|
|
|
extern const char *Txt_The_name_X_has_not_changed;
|
2023-10-10 10:51:21 +02:00
|
|
|
|
char *CurrentName[Nam_NUM_SHRT_FULL_NAMES] =
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2023-10-10 10:51:21 +02:00
|
|
|
|
[Nam_SHRT_NAME] = Plc_EditingPlc->ShrtName,
|
|
|
|
|
[Nam_FULL_NAME] = Plc_EditingPlc->FullName,
|
2023-10-06 10:55:13 +02:00
|
|
|
|
};
|
2023-10-10 10:51:21 +02:00
|
|
|
|
char NewName[Nam_MAX_BYTES_FULL_NAME + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get parameters from form *****/
|
|
|
|
|
/* Get the code of the place */
|
2023-03-10 17:21:04 +01:00
|
|
|
|
Plc_EditingPlc->PlcCod = ParCod_GetAndCheckPar (ParCod_Plc);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get the new name for the place */
|
2023-10-11 00:02:14 +02:00
|
|
|
|
Nam_GetParShrtOrFullName (ShrtOrFull,NewName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2023-04-13 14:25:52 +02:00
|
|
|
|
/***** Get place old names from database *****/
|
2023-03-23 09:35:20 +01:00
|
|
|
|
Plc_GetPlaceDataByCod (Plc_EditingPlc);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Check if new name is empty *****/
|
2023-10-06 10:55:13 +02:00
|
|
|
|
if (NewName[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) *****/
|
2023-10-11 00:02:14 +02:00
|
|
|
|
if (strcmp (CurrentName[ShrtOrFull],NewName)) // Different names
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** If place was in database... *****/
|
2023-10-11 09:55:06 +02:00
|
|
|
|
if (Plc_DB_CheckIfPlaceNameExists (Nam_Fields[ShrtOrFull],
|
2023-10-10 19:12:17 +02:00
|
|
|
|
NewName,Plc_EditingPlc->PlcCod,
|
|
|
|
|
Gbl.Hierarchy.Node[Hie_INS].HieCod,
|
|
|
|
|
0)) // Unused
|
|
|
|
|
Ale_CreateAlert (Ale_WARNING,NULL,Txt_X_already_exists,NewName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Update the table changing old name by new name */
|
2023-10-06 10:55:13 +02:00
|
|
|
|
Plc_DB_UpdatePlcName (Plc_EditingPlc->PlcCod,
|
2023-10-11 00:02:14 +02:00
|
|
|
|
Nam_Fields[ShrtOrFull],NewName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-03-09 11:16:17 +01:00
|
|
|
|
/* Write message to show the change made */
|
2019-04-09 00:24:50 +02:00
|
|
|
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
|
|
|
|
Txt_The_place_X_has_been_renamed_as_Y,
|
2023-10-11 00:02:14 +02:00
|
|
|
|
CurrentName[ShrtOrFull],NewName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // The same name
|
2019-04-09 00:24:50 +02:00
|
|
|
|
Ale_CreateAlert (Ale_INFO,NULL,
|
2023-10-06 10:55:13 +02:00
|
|
|
|
Txt_The_name_X_has_not_changed,
|
2023-10-11 00:02:14 +02:00
|
|
|
|
CurrentName[ShrtOrFull]);
|
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
|
|
|
|
|
2019-04-09 00:24:50 +02:00
|
|
|
|
/***** Update place name *****/
|
2023-10-11 22:45:34 +02:00
|
|
|
|
Str_Copy (CurrentName[ShrtOrFull],NewName,Nam_MaxBytes[ShrtOrFull]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-04-09 00:24:50 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********** Show alerts after changing a place and continue editing **********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Plc_ContEditAfterChgPlc (void)
|
|
|
|
|
{
|
|
|
|
|
/***** Write message to show the change made *****/
|
|
|
|
|
Ale_ShowAlerts (NULL);
|
|
|
|
|
|
|
|
|
|
/***** Show the form again *****/
|
|
|
|
|
Plc_EditPlacesInternal ();
|
|
|
|
|
|
|
|
|
|
/***** Place destructor *****/
|
|
|
|
|
Plc_EditingPlaceDestructor ();
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Put a form to create a new place **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Plc_PutFormToCreatePlace (void)
|
|
|
|
|
{
|
2023-10-11 00:02:14 +02:00
|
|
|
|
const char *Names[Nam_NUM_SHRT_FULL_NAMES];
|
2023-10-09 17:07:19 +02:00
|
|
|
|
|
2023-05-11 18:35:16 +02:00
|
|
|
|
/***** Begin form to create *****/
|
2024-01-30 00:20:11 +01:00
|
|
|
|
Frm_BeginFormTable (ActNewPlc,NULL,NULL,NULL,"TBL_SCROLL");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2023-05-11 18:35:16 +02:00
|
|
|
|
/***** Write heading *****/
|
|
|
|
|
Plc_PutHeadPlaces ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2023-05-11 18:35:16 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
|
|
|
|
|
/***** Column to remove place, disabled here *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"BM\"");
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Place code *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"CODE\"");
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
2023-10-09 17:07:19 +02:00
|
|
|
|
/***** Place short name and full name *****/
|
2023-10-11 00:02:14 +02:00
|
|
|
|
Names[Nam_SHRT_NAME] = Plc_EditingPlc->ShrtName;
|
|
|
|
|
Names[Nam_FULL_NAME] = Plc_EditingPlc->FullName;
|
2023-10-10 10:51:21 +02:00
|
|
|
|
Nam_NewShortAndFullNames (Names);
|
2023-05-11 18:35:16 +02:00
|
|
|
|
|
|
|
|
|
/***** Number of centers *****/
|
2023-10-11 22:45:34 +02:00
|
|
|
|
HTM_TD_Unsigned (0);
|
2023-05-11 18:35:16 +02:00
|
|
|
|
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
|
|
|
|
|
/***** End form to create *****/
|
|
|
|
|
Frm_EndFormTable (Btn_CREATE_BUTTON);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Write header with fields of a place ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Plc_PutHeadPlaces (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Code;
|
2015-02-04 20:03:23 +01:00
|
|
|
|
extern const char *Txt_Short_name;
|
|
|
|
|
extern const char *Txt_Full_name;
|
2023-11-06 15:20:34 +01:00
|
|
|
|
extern const char *Txt_HIERARCHY_PLURAL_Abc[Hie_NUM_LEVELS];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2023-11-06 15:20:34 +01:00
|
|
|
|
HTM_TH_Span (NULL ,HTM_HEAD_CENTER,1,1,"BT");
|
|
|
|
|
HTM_TH (Txt_Code ,HTM_HEAD_RIGHT );
|
|
|
|
|
HTM_TH (Txt_Short_name ,HTM_HEAD_LEFT );
|
|
|
|
|
HTM_TH (Txt_Full_name ,HTM_HEAD_LEFT );
|
|
|
|
|
HTM_TH (Txt_HIERARCHY_PLURAL_Abc[Hie_CTR],HTM_HEAD_RIGHT );
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Receive form to create a new place **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2024-03-20 09:39:04 +01:00
|
|
|
|
void Plc_ReceiveNewPlace (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-04-09 00:24:50 +02:00
|
|
|
|
extern const char *Txt_Created_new_place_X;
|
2023-10-11 00:02:14 +02:00
|
|
|
|
char *Names[Nam_NUM_SHRT_FULL_NAMES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 00:24:50 +02:00
|
|
|
|
/***** Place constructor *****/
|
|
|
|
|
Plc_EditingPlaceConstructor ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get parameters from form *****/
|
2023-10-09 17:07:19 +02:00
|
|
|
|
/* Get place short name and full name */
|
2023-10-11 00:02:14 +02:00
|
|
|
|
Names[Nam_SHRT_NAME] = Plc_EditingPlc->ShrtName;
|
|
|
|
|
Names[Nam_FULL_NAME] = Plc_EditingPlc->FullName;
|
2023-10-10 10:51:21 +02:00
|
|
|
|
Nam_GetParsShrtAndFullName (Names);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 00:24:50 +02:00
|
|
|
|
if (Plc_EditingPlc->ShrtName[0] &&
|
|
|
|
|
Plc_EditingPlc->FullName[0]) // If there's a place name
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2023-10-10 19:12:17 +02:00
|
|
|
|
/***** If name of place was not in database... *****/
|
2023-10-11 00:02:14 +02:00
|
|
|
|
if (!Nam_CheckIfNameExists (Plc_DB_CheckIfPlaceNameExists,
|
|
|
|
|
(const char **) Names,
|
|
|
|
|
-1L,
|
|
|
|
|
Gbl.Hierarchy.Node[Hie_INS].HieCod,
|
2023-10-10 19:12:17 +02:00
|
|
|
|
0)) // Unused
|
2019-04-09 00:24:50 +02:00
|
|
|
|
{
|
2021-07-08 15:00:17 +02:00
|
|
|
|
Plc_DB_CreatePlace (Plc_EditingPlc);
|
2019-04-09 00:24:50 +02:00
|
|
|
|
Ale_CreateAlert (Ale_SUCCESS,NULL,Txt_Created_new_place_X,
|
2023-10-10 10:51:21 +02:00
|
|
|
|
Names[Nam_FULL_NAME]);
|
2019-04-09 00:24:50 +02:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else // If there is not a place name
|
2023-10-09 17:07:19 +02:00
|
|
|
|
Ale_CreateAlertYouMustSpecifyShrtNameAndFullName ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-04-09 00:24:50 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Place constructor/destructor **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Plc_EditingPlaceConstructor (void)
|
|
|
|
|
{
|
|
|
|
|
/***** Pointer must be NULL *****/
|
|
|
|
|
if (Plc_EditingPlc != NULL)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongPlaceExit ();
|
2019-04-09 00:24:50 +02:00
|
|
|
|
|
|
|
|
|
/***** Allocate memory for place *****/
|
2021-02-15 16:25:55 +01:00
|
|
|
|
if ((Plc_EditingPlc = malloc (sizeof (*Plc_EditingPlc))) == NULL)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
2019-04-09 00:24:50 +02:00
|
|
|
|
|
|
|
|
|
/***** Reset place *****/
|
|
|
|
|
Plc_EditingPlc->PlcCod = -1L;
|
|
|
|
|
Plc_EditingPlc->InsCod = -1L;
|
|
|
|
|
Plc_EditingPlc->ShrtName[0] = '\0';
|
|
|
|
|
Plc_EditingPlc->FullName[0] = '\0';
|
|
|
|
|
Plc_EditingPlc->NumCtrs = 0;
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 00:24:50 +02:00
|
|
|
|
static void Plc_EditingPlaceDestructor (void)
|
|
|
|
|
{
|
|
|
|
|
/***** Free memory used for place *****/
|
|
|
|
|
if (Plc_EditingPlc != NULL)
|
|
|
|
|
{
|
2019-11-06 19:45:20 +01:00
|
|
|
|
free (Plc_EditingPlc);
|
2019-04-09 00:24:50 +02:00
|
|
|
|
Plc_EditingPlc = NULL;
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|