Version19.182

This commit is contained in:
acanas 2020-04-13 21:26:47 +02:00
parent c048d8c2a2
commit e1ff9a8e0b
10 changed files with 150 additions and 127 deletions

View File

@ -74,7 +74,7 @@ static void Ctr_PutIconsEditingCentres (__attribute__((unused)) void *Args);
static void Ctr_GetDataOfCentreFromRow (struct Centre *Ctr,MYSQL_ROW row); static void Ctr_GetDataOfCentreFromRow (struct Centre *Ctr,MYSQL_ROW row);
static void Ctr_ListCentresForEdition (void); static void Ctr_ListCentresForEdition (const struct Plc_Places *Places);
static bool Ctr_CheckIfICanEditACentre (struct Centre *Ctr); static bool Ctr_CheckIfICanEditACentre (struct Centre *Ctr);
static Ctr_StatusTxt_t Ctr_GetStatusTxtFromStatusBits (Ctr_Status_t Status); static Ctr_StatusTxt_t Ctr_GetStatusTxtFromStatusBits (Ctr_Status_t Status);
static Ctr_Status_t Ctr_GetStatusBitsFromStatusTxt (Ctr_StatusTxt_t StatusTxt); static Ctr_Status_t Ctr_GetStatusBitsFromStatusTxt (Ctr_StatusTxt_t StatusTxt);
@ -86,7 +86,7 @@ static void Ctr_UpdateInsNameDB (long CtrCod,const char *FieldName,const char *N
static void Ctr_ShowAlertAndButtonToGoToCtr (void); static void Ctr_ShowAlertAndButtonToGoToCtr (void);
static void Ctr_PutParamGoToCtr (void *CtrCod); static void Ctr_PutParamGoToCtr (void *CtrCod);
static void Ctr_PutFormToCreateCentre (void); static void Ctr_PutFormToCreateCentre (const struct Plc_Places *Places);
static void Ctr_PutHeadCentresForSeeing (bool OrderSelectable); static void Ctr_PutHeadCentresForSeeing (bool OrderSelectable);
static void Ctr_PutHeadCentresForEdition (void); static void Ctr_PutHeadCentresForEdition (void);
static void Ctr_RecFormRequestOrCreateCtr (unsigned Status); static void Ctr_RecFormRequestOrCreateCtr (unsigned Status);
@ -351,7 +351,7 @@ static void Ctr_PutIconToEditCentres (void)
static void Ctr_ListOneCentreForSeeing (struct Centre *Ctr,unsigned NumCtr) static void Ctr_ListOneCentreForSeeing (struct Centre *Ctr,unsigned NumCtr)
{ {
extern const char *Txt_CENTRE_STATUS[Ctr_NUM_STATUS_TXT]; extern const char *Txt_CENTRE_STATUS[Ctr_NUM_STATUS_TXT];
struct Place Plc; struct Plc_Place Plc;
const char *TxtClassNormal; const char *TxtClassNormal;
const char *TxtClassStrong; const char *TxtClassStrong;
const char *BgColor; const char *BgColor;
@ -460,10 +460,14 @@ static void Ctr_EditCentresInternal (void)
{ {
extern const char *Hlp_INSTITUTION_Centres; extern const char *Hlp_INSTITUTION_Centres;
extern const char *Txt_Centres_of_INSTITUTION_X; extern const char *Txt_Centres_of_INSTITUTION_X;
struct Plc_Places Places;
/***** Reset places context *****/
Plc_ResetPlaces (&Places);
/***** Get list of places *****/ /***** Get list of places *****/
Gbl.Plcs.SelectedOrder = Plc_ORDER_BY_PLACE; Places.SelectedOrder = Plc_ORDER_BY_PLACE;
Plc_GetListPlaces (); Plc_GetListPlaces (&Places);
/***** Get list of centres *****/ /***** Get list of centres *****/
Gbl.Hierarchy.Ctrs.SelectedOrder = Ctr_ORDER_BY_CENTRE; Gbl.Hierarchy.Ctrs.SelectedOrder = Ctr_ORDER_BY_CENTRE;
@ -480,11 +484,11 @@ static void Ctr_EditCentresInternal (void)
Str_FreeString (); Str_FreeString ();
/***** Put a form to create a new centre *****/ /***** Put a form to create a new centre *****/
Ctr_PutFormToCreateCentre (); Ctr_PutFormToCreateCentre (&Places);
/***** List current centres *****/ /***** List current centres *****/
if (Gbl.Hierarchy.Ctrs.Num) if (Gbl.Hierarchy.Ctrs.Num)
Ctr_ListCentresForEdition (); Ctr_ListCentresForEdition (&Places);
/***** End box *****/ /***** End box *****/
Box_BoxEnd (); Box_BoxEnd ();
@ -493,7 +497,7 @@ static void Ctr_EditCentresInternal (void)
Ctr_FreeListCentres (); Ctr_FreeListCentres ();
/***** Free list of places *****/ /***** Free list of places *****/
Plc_FreeListPlaces (); Plc_FreeListPlaces (&Places);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -920,7 +924,7 @@ void Ctr_WriteSelectorOfCentre (void)
/*************************** List all the centres ****************************/ /*************************** List all the centres ****************************/
/*****************************************************************************/ /*****************************************************************************/
static void Ctr_ListCentresForEdition (void) static void Ctr_ListCentresForEdition (const struct Plc_Places *Places)
{ {
extern const char *Txt_Another_place; extern const char *Txt_Another_place;
extern const char *Txt_CENTRE_STATUS[Ctr_NUM_STATUS_TXT]; extern const char *Txt_CENTRE_STATUS[Ctr_NUM_STATUS_TXT];
@ -995,20 +999,20 @@ static void Ctr_ListCentresForEdition (void)
Ctr->PlcCod == 0,false, Ctr->PlcCod == 0,false,
"%s",Txt_Another_place); "%s",Txt_Another_place);
for (NumPlc = 0; for (NumPlc = 0;
NumPlc < Gbl.Plcs.Num; NumPlc < Places->Num;
NumPlc++) NumPlc++)
HTM_OPTION (HTM_Type_LONG,&Gbl.Plcs.Lst[NumPlc].PlcCod, HTM_OPTION (HTM_Type_LONG,&Places->Lst[NumPlc].PlcCod,
Gbl.Plcs.Lst[NumPlc].PlcCod == Ctr->PlcCod,false, Places->Lst[NumPlc].PlcCod == Ctr->PlcCod,false,
"%s",Gbl.Plcs.Lst[NumPlc].ShrtName); "%s",Places->Lst[NumPlc].ShrtName);
HTM_SELECT_End (); HTM_SELECT_End ();
Frm_EndForm (); Frm_EndForm ();
} }
else else
for (NumPlc = 0; for (NumPlc = 0;
NumPlc < Gbl.Plcs.Num; NumPlc < Places->Num;
NumPlc++) NumPlc++)
if (Gbl.Plcs.Lst[NumPlc].PlcCod == Ctr->PlcCod) if (Places->Lst[NumPlc].PlcCod == Ctr->PlcCod)
HTM_Txt (Gbl.Plcs.Lst[NumPlc].ShrtName); HTM_Txt (Places->Lst[NumPlc].ShrtName);
HTM_TD_End (); HTM_TD_End ();
/* Centre short name */ /* Centre short name */
@ -1588,7 +1592,7 @@ static void Ctr_PutParamGoToCtr (void *CtrCod)
/********************* Put a form to create a new centre *********************/ /********************* Put a form to create a new centre *********************/
/*****************************************************************************/ /*****************************************************************************/
static void Ctr_PutFormToCreateCentre (void) static void Ctr_PutFormToCreateCentre (const struct Plc_Places *Places)
{ {
extern const char *Txt_New_centre; extern const char *Txt_New_centre;
extern const char *Txt_Another_place; extern const char *Txt_Another_place;
@ -1634,11 +1638,11 @@ static void Ctr_PutFormToCreateCentre (void)
Ctr_EditingCtr->PlcCod == 0,false, Ctr_EditingCtr->PlcCod == 0,false,
"%s",Txt_Another_place); "%s",Txt_Another_place);
for (NumPlc = 0; for (NumPlc = 0;
NumPlc < Gbl.Plcs.Num; NumPlc < Places->Num;
NumPlc++) NumPlc++)
HTM_OPTION (HTM_Type_LONG,&Gbl.Plcs.Lst[NumPlc].PlcCod, HTM_OPTION (HTM_Type_LONG,&Places->Lst[NumPlc].PlcCod,
Gbl.Plcs.Lst[NumPlc].PlcCod == Ctr_EditingCtr->PlcCod,false, Places->Lst[NumPlc].PlcCod == Ctr_EditingCtr->PlcCod,false,
"%s",Gbl.Plcs.Lst[NumPlc].ShrtName); "%s",Places->Lst[NumPlc].ShrtName);
HTM_SELECT_End (); HTM_SELECT_End ();
HTM_TD_End (); HTM_TD_End ();

View File

@ -648,9 +648,13 @@ static void CtrCfg_Place (bool PutForm)
{ {
extern const char *Txt_Place; extern const char *Txt_Place;
extern const char *Txt_Another_place; extern const char *Txt_Another_place;
struct Place Plc; struct Plc_Places Places;
struct Plc_Place Plc;
unsigned NumPlc; unsigned NumPlc;
/***** Reset places context *****/
Plc_ResetPlaces (&Places);
/***** Get data of place *****/ /***** Get data of place *****/
Plc.PlcCod = Gbl.Hierarchy.Ctr.PlcCod; Plc.PlcCod = Gbl.Hierarchy.Ctr.PlcCod;
Plc_GetDataOfPlaceByCod (&Plc); Plc_GetDataOfPlaceByCod (&Plc);
@ -668,8 +672,8 @@ static void CtrCfg_Place (bool PutForm)
if (PutForm) if (PutForm)
{ {
/* Get list of places of the current institution */ /* Get list of places of the current institution */
Gbl.Plcs.SelectedOrder = Plc_ORDER_BY_PLACE; Places.SelectedOrder = Plc_ORDER_BY_PLACE;
Plc_GetListPlaces (); Plc_GetListPlaces (&Places);
/* Put form to select place */ /* Put form to select place */
Frm_StartForm (ActChgCtrPlcCfg); Frm_StartForm (ActChgCtrPlcCfg);
@ -679,16 +683,16 @@ static void CtrCfg_Place (bool PutForm)
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 < Gbl.Plcs.Num; NumPlc < Places.Num;
NumPlc++) NumPlc++)
HTM_OPTION (HTM_Type_LONG,&Gbl.Plcs.Lst[NumPlc].PlcCod, HTM_OPTION (HTM_Type_LONG,&Places.Lst[NumPlc].PlcCod,
Gbl.Plcs.Lst[NumPlc].PlcCod == Gbl.Hierarchy.Ctr.PlcCod,false, Places.Lst[NumPlc].PlcCod == Gbl.Hierarchy.Ctr.PlcCod,false,
"%s",Gbl.Plcs.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 (); Plc_FreeListPlaces (&Places);
} }
else // I can not change centre place else // I can not change centre place
HTM_Txt (Plc.FullName); HTM_Txt (Plc.FullName);

View File

@ -497,7 +497,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
En OpenSWAD: En OpenSWAD:
ps2pdf source.ps destination.pdf ps2pdf source.ps destination.pdf
*/ */
#define Log_PLATFORM_VERSION "SWAD 19.181 (2020-04-13)" #define Log_PLATFORM_VERSION "SWAD 19.182 (2020-04-13)"
#define CSS_FILE "swad19.146.css" #define CSS_FILE "swad19.146.css"
#define JS_FILE "swad19.172.1.js" #define JS_FILE "swad19.172.1.js"
/* /*
@ -548,6 +548,7 @@ Funci
// TODO: Oresti Baños: cambiar ojos por candados en descriptores para prohibir/permitir y dejar los ojos para poder elegir descriptores // TODO: Oresti Baños: cambiar ojos por candados en descriptores para prohibir/permitir y dejar los ojos para poder elegir descriptores
// TODO: Integrar pull requests con traducciones del alemán del usuario eruedin en GitHub // TODO: Integrar pull requests con traducciones del alemán del usuario eruedin en GitHub
Version 19.182: Apr 13, 2020 Code refactoring in places. (285685 lines)
Version 19.181: Apr 13, 2020 Code refactoring in departments. (285667 lines) Version 19.181: Apr 13, 2020 Code refactoring in departments. (285667 lines)
Version 19.180.5: Apr 13, 2020 Fixed bug in statistics. (285637 lines) Version 19.180.5: Apr 13, 2020 Fixed bug in statistics. (285637 lines)
Version 19.180.4: Apr 13, 2020 Fixed bug in attendance. Version 19.180.4: Apr 13, 2020 Fixed bug in attendance.

View File

@ -66,9 +66,11 @@ static struct Dpt_Department *Dpt_EditingDpt = NULL; // Static variable to keep
/***************************** Private prototypes ****************************/ /***************************** Private prototypes ****************************/
/*****************************************************************************/ /*****************************************************************************/
static void Dpt_ResetDepartments (struct Dpt_Departments *Departments);
static Dpt_Order_t Dpt_GetParamDptOrder (void); static Dpt_Order_t Dpt_GetParamDptOrder (void);
static void Dpt_PutIconToEditDpts (__attribute__((unused)) void *Args); static void Dpt_PutIconToEditDpts (__attribute__((unused)) void *Args);
static void Dpt_EditDepartmentsInternal (struct Dpt_Departments *Departments); static void Dpt_EditDepartmentsInternal (void);
static void Dpt_GetListDepartments (struct Dpt_Departments *Departments,long InsCod); static void Dpt_GetListDepartments (struct Dpt_Departments *Departments,long InsCod);
@ -90,7 +92,7 @@ static void Dpt_EditingDepartmentDestructor (void);
/************************* Reset departments context *************************/ /************************* Reset departments context *************************/
/*****************************************************************************/ /*****************************************************************************/
void Dpt_ResetDepartments (struct Dpt_Departments *Departments) static void Dpt_ResetDepartments (struct Dpt_Departments *Departments)
{ {
Departments->Num = 0; Departments->Num = 0;
Departments->Lst = NULL; Departments->Lst = NULL;
@ -259,35 +261,34 @@ static void Dpt_PutIconToEditDpts (__attribute__((unused)) void *Args)
void Dpt_EditDepartments (void) void Dpt_EditDepartments (void)
{ {
struct Dpt_Departments Departments;
/***** Reset departments context *****/
Dpt_ResetDepartments (&Departments);
/***** Department constructor *****/ /***** Department constructor *****/
Dpt_EditingDepartmentConstructor (); Dpt_EditingDepartmentConstructor ();
/***** Edit departments *****/ /***** Edit departments *****/
Dpt_EditDepartmentsInternal (&Departments); Dpt_EditDepartmentsInternal ();
/***** Department destructor *****/ /***** Department destructor *****/
Dpt_EditingDepartmentDestructor (); Dpt_EditingDepartmentDestructor ();
} }
static void Dpt_EditDepartmentsInternal (struct Dpt_Departments *Departments) static void Dpt_EditDepartmentsInternal (void)
{ {
extern const char *Hlp_INSTITUTION_Departments_edit; extern const char *Hlp_INSTITUTION_Departments_edit;
extern const char *Txt_Departments_of_INSTITUTION_X; extern const char *Txt_Departments_of_INSTITUTION_X;
struct Dpt_Departments Departments;
/***** Trivial check *****/ /***** Trivial check *****/
if (Gbl.Hierarchy.Ins.InsCod <= 0) // An institution must be selected if (Gbl.Hierarchy.Ins.InsCod <= 0) // An institution must be selected
return; return;
/***** Reset departments context *****/
Dpt_ResetDepartments (&Departments);
/***** Get list of institutions *****/ /***** Get list of institutions *****/
Ins_GetBasicListOfInstitutions (Gbl.Hierarchy.Cty.CtyCod); Ins_GetBasicListOfInstitutions (Gbl.Hierarchy.Cty.CtyCod);
/***** Get list of departments *****/ /***** Get list of departments *****/
Dpt_GetListDepartments (Departments,Gbl.Hierarchy.Ins.InsCod); Dpt_GetListDepartments (&Departments,Gbl.Hierarchy.Ins.InsCod);
/***** Begin box *****/ /***** Begin box *****/
Box_BoxBegin (NULL,Str_BuildStringStr (Txt_Departments_of_INSTITUTION_X, Box_BoxBegin (NULL,Str_BuildStringStr (Txt_Departments_of_INSTITUTION_X,
@ -300,14 +301,14 @@ static void Dpt_EditDepartmentsInternal (struct Dpt_Departments *Departments)
Dpt_PutFormToCreateDepartment (); Dpt_PutFormToCreateDepartment ();
/***** Forms to edit current departments *****/ /***** Forms to edit current departments *****/
if (Departments->Num) if (Departments.Num)
Dpt_ListDepartmentsForEdition (Departments); Dpt_ListDepartmentsForEdition (&Departments);
/***** End box *****/ /***** End box *****/
Box_BoxEnd (); Box_BoxEnd ();
/***** Free list of departments *****/ /***** Free list of departments *****/
Dpt_FreeListDepartments (Departments); Dpt_FreeListDepartments (&Departments);
/***** Free list of institutions *****/ /***** Free list of institutions *****/
Ins_FreeListInstitutions (); Ins_FreeListInstitutions ();
@ -896,16 +897,11 @@ void Dpt_ChangeDptWWW (void)
void Dpt_ContEditAfterChgDpt (void) void Dpt_ContEditAfterChgDpt (void)
{ {
struct Dpt_Departments Departments;
/***** Reset departments context *****/
Dpt_ResetDepartments (&Departments);
/***** Write message to show the change made *****/ /***** Write message to show the change made *****/
Ale_ShowAlerts (NULL); Ale_ShowAlerts (NULL);
/***** Show the form again *****/ /***** Show the form again *****/
Dpt_EditDepartmentsInternal (&Departments); Dpt_EditDepartmentsInternal ();
/***** Department destructor *****/ /***** Department destructor *****/
Dpt_EditingDepartmentDestructor (); Dpt_EditingDepartmentDestructor ();

View File

@ -64,8 +64,6 @@ struct Dpt_Departments
/***************************** Public prototypes *****************************/ /***************************** Public prototypes *****************************/
/*****************************************************************************/ /*****************************************************************************/
void Dpt_ResetDepartments (struct Dpt_Departments *Departments);
void Dpt_SeeDepts (void); void Dpt_SeeDepts (void);
void Dpt_EditDepartments (void); void Dpt_EditDepartments (void);
void Dpt_FreeListDepartments (struct Dpt_Departments *Departments); void Dpt_FreeListDepartments (struct Dpt_Departments *Departments);

View File

@ -236,10 +236,6 @@ void Gbl_InitializeGlobals (void)
Gbl.Hierarchy.Crs.ShrtName[0] = Gbl.Hierarchy.Crs.ShrtName[0] =
Gbl.Hierarchy.Crs.FullName[0] = '\0'; Gbl.Hierarchy.Crs.FullName[0] = '\0';
Gbl.Plcs.Num = 0;
Gbl.Plcs.Lst = NULL;
Gbl.Plcs.SelectedOrder = Plc_ORDER_DEFAULT;
Gbl.Hlds.LstIsRead = false; // List is not read Gbl.Hlds.LstIsRead = false; // List is not read
Gbl.Hlds.Num = 0; Gbl.Hlds.Num = 0;
Gbl.Hlds.Lst = NULL; Gbl.Hlds.Lst = NULL;
@ -384,7 +380,6 @@ void Gbl_Cleanup (void)
Ins_FreeListInstitutions (); Ins_FreeListInstitutions ();
Ctr_FreeListCentres (); Ctr_FreeListCentres ();
Cty_FreeListCountries (); Cty_FreeListCountries ();
Plc_FreeListPlaces ();
Hld_FreeListHolidays (); Hld_FreeListHolidays ();
Lnk_FreeListLinks (); Lnk_FreeListLinks ();
Plg_FreeListPlugins (); Plg_FreeListPlugins ();

View File

@ -226,12 +226,6 @@ struct Globals
unsigned Num; // Number of degree types unsigned Num; // Number of degree types
struct DegreeType *Lst; // List of degree types struct DegreeType *Lst; // List of degree types
} DegTypes; } DegTypes;
struct
{
unsigned Num; // Number of places
struct Place *Lst; // List of places
Plc_Order_t SelectedOrder;
} Plcs;
struct struct
{ {
unsigned Num; // Number of classrooms unsigned Num; // Number of classrooms

View File

@ -72,10 +72,10 @@ static void Hld_GetDataOfHolidayByCod (struct Holiday *Hld);
static Hld_HolidayType_t Hld_GetParamHldType (void); static Hld_HolidayType_t Hld_GetParamHldType (void);
static Hld_HolidayType_t Hld_GetTypeOfHoliday (const char *UnsignedStr); static Hld_HolidayType_t Hld_GetTypeOfHoliday (const char *UnsignedStr);
static void Hld_ListHolidaysForEdition (void); static void Hld_ListHolidaysForEdition (const struct Plc_Places *Places);
static void Hld_PutParamHldCod (long HldCod); static void Hld_PutParamHldCod (long HldCod);
static void Hld_ChangeDate (Hld_StartOrEndDate_t StartOrEndDate); static void Hld_ChangeDate (Hld_StartOrEndDate_t StartOrEndDate);
static void Hld_PutFormToCreateHoliday (void); static void Hld_PutFormToCreateHoliday (const struct Plc_Places *Places);
static void Hld_PutHeadHolidays (void); static void Hld_PutHeadHolidays (void);
static void Hld_CreateHoliday (struct Holiday *Hld); static void Hld_CreateHoliday (struct Holiday *Hld);
@ -264,24 +264,29 @@ void Hld_EditHolidays (void)
static void Hld_EditHolidaysInternal (void) static void Hld_EditHolidaysInternal (void)
{ {
struct Plc_Places Places;
/***** Reset places context *****/
Plc_ResetPlaces (&Places);
/***** Get list of places *****/ /***** Get list of places *****/
Plc_GetListPlaces (); Plc_GetListPlaces (&Places);
/***** Get list of holidays *****/ /***** Get list of holidays *****/
Hld_GetListHolidays (); Hld_GetListHolidays ();
/***** Put a form to create a new holiday *****/ /***** Put a form to create a new holiday *****/
Hld_PutFormToCreateHoliday (); Hld_PutFormToCreateHoliday (&Places);
/***** Forms to edit current holidays *****/ /***** Forms to edit current holidays *****/
if (Gbl.Hlds.Num) if (Gbl.Hlds.Num)
Hld_ListHolidaysForEdition (); Hld_ListHolidaysForEdition (&Places);
/***** Free list of holidays *****/ /***** Free list of holidays *****/
Hld_FreeListHolidays (); Hld_FreeListHolidays ();
/***** Free list of places *****/ /***** Free list of places *****/
Plc_FreeListPlaces (); Plc_FreeListPlaces (&Places);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -543,7 +548,7 @@ void Hld_FreeListHolidays (void)
/********************* List all the holidays for edition *********************/ /********************* List all the holidays for edition *********************/
/*****************************************************************************/ /*****************************************************************************/
static void Hld_ListHolidaysForEdition (void) static void Hld_ListHolidaysForEdition (const struct Plc_Places *Places)
{ {
extern const char *Hlp_INSTITUTION_Holidays_edit; extern const char *Hlp_INSTITUTION_Holidays_edit;
extern const char *Txt_Holidays; extern const char *Txt_Holidays;
@ -594,11 +599,11 @@ static void Hld_ListHolidaysForEdition (void)
HTM_OPTION (HTM_Type_STRING,"-1",Hld->PlcCod <= 0,false, HTM_OPTION (HTM_Type_STRING,"-1",Hld->PlcCod <= 0,false,
"%s",Txt_All_places); "%s",Txt_All_places);
for (NumPlc = 0; for (NumPlc = 0;
NumPlc < Gbl.Plcs.Num; NumPlc < Places->Num;
NumPlc++) NumPlc++)
HTM_OPTION (HTM_Type_LONG,&Gbl.Plcs.Lst[NumPlc].PlcCod, HTM_OPTION (HTM_Type_LONG,&Places->Lst[NumPlc].PlcCod,
Gbl.Plcs.Lst[NumPlc].PlcCod == Hld->PlcCod,false, Places->Lst[NumPlc].PlcCod == Hld->PlcCod,false,
"%s",Gbl.Plcs.Lst[NumPlc].ShrtName); "%s",Places->Lst[NumPlc].ShrtName);
HTM_SELECT_End (); HTM_SELECT_End ();
Frm_EndForm (); Frm_EndForm ();
HTM_TD_End (); HTM_TD_End ();
@ -716,7 +721,7 @@ void Hld_RemoveHoliday (void)
void Hld_ChangeHolidayPlace (void) void Hld_ChangeHolidayPlace (void)
{ {
extern const char *Txt_The_place_of_the_holiday_X_has_changed_to_Y; extern const char *Txt_The_place_of_the_holiday_X_has_changed_to_Y;
struct Place NewPlace; struct Plc_Place NewPlace;
/***** Holiday constructor *****/ /***** Holiday constructor *****/
Hld_EditingHolidayConstructor (); Hld_EditingHolidayConstructor ();
@ -946,7 +951,7 @@ void Hld_ContEditAfterChgHld (void)
/********************* Put a form to create a new holiday ********************/ /********************* Put a form to create a new holiday ********************/
/*****************************************************************************/ /*****************************************************************************/
static void Hld_PutFormToCreateHoliday (void) static void Hld_PutFormToCreateHoliday (const struct Plc_Places *Places)
{ {
extern const char *Hlp_INSTITUTION_Holidays_edit; extern const char *Hlp_INSTITUTION_Holidays_edit;
extern const char *Txt_All_places; extern const char *Txt_All_places;
@ -989,11 +994,11 @@ static void Hld_PutFormToCreateHoliday (void)
HTM_OPTION (HTM_Type_STRING,"-1",Hld_EditingHld->PlcCod <= 0,false, HTM_OPTION (HTM_Type_STRING,"-1",Hld_EditingHld->PlcCod <= 0,false,
"%s",Txt_All_places); "%s",Txt_All_places);
for (NumPlc = 0; for (NumPlc = 0;
NumPlc < Gbl.Plcs.Num; NumPlc < Places->Num;
NumPlc++) NumPlc++)
HTM_OPTION (HTM_Type_LONG,&Gbl.Plcs.Lst[NumPlc].PlcCod, HTM_OPTION (HTM_Type_LONG,&Places->Lst[NumPlc].PlcCod,
Gbl.Plcs.Lst[NumPlc].PlcCod == Hld_EditingHld->PlcCod,false, Places->Lst[NumPlc].PlcCod == Hld_EditingHld->PlcCod,false,
"%s",Gbl.Plcs.Lst[NumPlc].ShrtName); "%s",Places->Lst[NumPlc].ShrtName);
HTM_SELECT_End (); HTM_SELECT_End ();
HTM_TD_End (); HTM_TD_End ();

View File

@ -57,20 +57,20 @@ extern struct Globals Gbl;
/***************************** Private variables *****************************/ /***************************** Private variables *****************************/
/*****************************************************************************/ /*****************************************************************************/
static struct Place *Plc_EditingPlc = NULL; // Static variable to keep the place being edited static struct Plc_Place *Plc_EditingPlc = NULL; // Static variable to keep the place being edited
/*****************************************************************************/ /*****************************************************************************/
/***************************** Private prototypes ****************************/ /***************************** Private prototypes ****************************/
/*****************************************************************************/ /*****************************************************************************/
static void Plc_GetParamPlcOrder (void); static Plc_Order_t Plc_GetParamPlcOrder (void);
static bool Plc_CheckIfICanCreatePlaces (void); static bool Plc_CheckIfICanCreatePlaces (void);
static void Plc_PutIconsListingPlaces (__attribute__((unused)) void *Args); static void Plc_PutIconsListingPlaces (__attribute__((unused)) void *Args);
static void Plc_PutIconToEditPlaces (void); static void Plc_PutIconToEditPlaces (void);
static void Plc_EditPlacesInternal (void); static void Plc_EditPlacesInternal (void);
static void Plc_PutIconsEditingPlaces (__attribute__((unused)) void *Args); static void Plc_PutIconsEditingPlaces (__attribute__((unused)) void *Args);
static void Plc_ListPlacesForEdition (void); static void Plc_ListPlacesForEdition (const struct Plc_Places *Places);
static void Plc_PutParamPlcCod (long PlcCod); static void Plc_PutParamPlcCod (long PlcCod);
static void Plc_RenamePlace (Cns_ShrtOrFullName_t ShrtOrFullName); static void Plc_RenamePlace (Cns_ShrtOrFullName_t ShrtOrFullName);
@ -79,11 +79,22 @@ static void Plc_UpdatePlcNameDB (long PlcCod,const char *FieldName,const char *N
static void Plc_PutFormToCreatePlace (void); static void Plc_PutFormToCreatePlace (void);
static void Plc_PutHeadPlaces (void); static void Plc_PutHeadPlaces (void);
static void Plc_CreatePlace (struct Place *Plc); static void Plc_CreatePlace (struct Plc_Place *Plc);
static void Plc_EditingPlaceConstructor (void); static void Plc_EditingPlaceConstructor (void);
static void Plc_EditingPlaceDestructor (void); static void Plc_EditingPlaceDestructor (void);
/*****************************************************************************/
/**************************** Reset places context ***************************/
/*****************************************************************************/
void Plc_ResetPlaces (struct Plc_Places *Places)
{
Places->Num = 0;
Places->Lst = NULL;
Places->SelectedOrder = Plc_ORDER_DEFAULT;
}
/*****************************************************************************/ /*****************************************************************************/
/*************************** List all the places *****************************/ /*************************** List all the places *****************************/
/*****************************************************************************/ /*****************************************************************************/
@ -97,6 +108,7 @@ void Plc_SeePlaces (void)
extern const char *Txt_Other_places; extern const char *Txt_Other_places;
extern const char *Txt_Place_unspecified; extern const char *Txt_Place_unspecified;
extern const char *Txt_New_place; extern const char *Txt_New_place;
struct Plc_Places Places;
Plc_Order_t Order; Plc_Order_t Order;
unsigned NumPlc; unsigned NumPlc;
unsigned NumCtrsWithPlc = 0; unsigned NumCtrsWithPlc = 0;
@ -104,11 +116,14 @@ void Plc_SeePlaces (void)
if (Gbl.Hierarchy.Ins.InsCod > 0) if (Gbl.Hierarchy.Ins.InsCod > 0)
{ {
/***** Reset places context *****/
Plc_ResetPlaces (&Places);
/***** Get parameter with the type of order in the list of places *****/ /***** Get parameter with the type of order in the list of places *****/
Plc_GetParamPlcOrder (); Places.SelectedOrder = Plc_GetParamPlcOrder ();
/***** Get list of places *****/ /***** Get list of places *****/
Plc_GetListPlaces (); Plc_GetListPlaces (&Places);
/***** Table head *****/ /***** Table head *****/
Box_BoxBegin (NULL,Txt_Places, Box_BoxBegin (NULL,Txt_Places,
@ -125,10 +140,10 @@ void Plc_SeePlaces (void)
Frm_StartForm (ActSeePlc); Frm_StartForm (ActSeePlc);
Par_PutHiddenParamUnsigned (NULL,"Order",(unsigned) Order); Par_PutHiddenParamUnsigned (NULL,"Order",(unsigned) Order);
HTM_BUTTON_SUBMIT_Begin (Txt_PLACES_HELP_ORDER[Order],"BT_LINK TIT_TBL",NULL); HTM_BUTTON_SUBMIT_Begin (Txt_PLACES_HELP_ORDER[Order],"BT_LINK TIT_TBL",NULL);
if (Order == Gbl.Plcs.SelectedOrder) if (Order == Places.SelectedOrder)
HTM_U_Begin (); HTM_U_Begin ();
HTM_Txt (Txt_PLACES_ORDER[Order]); HTM_Txt (Txt_PLACES_ORDER[Order]);
if (Order == Gbl.Plcs.SelectedOrder) if (Order == Places.SelectedOrder)
HTM_U_End (); HTM_U_End ();
HTM_BUTTON_End (); HTM_BUTTON_End ();
Frm_EndForm (); Frm_EndForm ();
@ -139,22 +154,22 @@ void Plc_SeePlaces (void)
/***** Write all places and their nuber of centres *****/ /***** Write all places and their nuber of centres *****/
for (NumPlc = 0; for (NumPlc = 0;
NumPlc < Gbl.Plcs.Num; NumPlc < Places.Num;
NumPlc++) NumPlc++)
{ {
/* Write data of this place */ /* Write data of this place */
HTM_TR_Begin (NULL); HTM_TR_Begin (NULL);
HTM_TD_Begin ("class=\"DAT LM\""); HTM_TD_Begin ("class=\"DAT LM\"");
HTM_Txt (Gbl.Plcs.Lst[NumPlc].FullName); HTM_Txt (Places.Lst[NumPlc].FullName);
HTM_TD_End (); HTM_TD_End ();
HTM_TD_Begin ("class=\"DAT RM\""); HTM_TD_Begin ("class=\"DAT RM\"");
HTM_Unsigned (Gbl.Plcs.Lst[NumPlc].NumCtrs); HTM_Unsigned (Places.Lst[NumPlc].NumCtrs);
HTM_TD_End (); HTM_TD_End ();
HTM_TR_End (); HTM_TR_End ();
NumCtrsWithPlc += Gbl.Plcs.Lst[NumPlc].NumCtrs; NumCtrsWithPlc += Places.Lst[NumPlc].NumCtrs;
} }
/***** Separation row *****/ /***** Separation row *****/
@ -208,7 +223,7 @@ void Plc_SeePlaces (void)
Box_BoxEnd (); Box_BoxEnd ();
/***** Free list of places *****/ /***** Free list of places *****/
Plc_FreeListPlaces (); Plc_FreeListPlaces (&Places);
} }
} }
@ -216,13 +231,12 @@ void Plc_SeePlaces (void)
/********** Get parameter with the type or order in list of places ***********/ /********** Get parameter with the type or order in list of places ***********/
/*****************************************************************************/ /*****************************************************************************/
static void Plc_GetParamPlcOrder (void) static Plc_Order_t Plc_GetParamPlcOrder (void)
{ {
Gbl.Plcs.SelectedOrder = (Plc_Order_t) return (Plc_Order_t) Par_GetParToUnsignedLong ("Order",
Par_GetParToUnsignedLong ("Order", 0,
0, Plc_NUM_ORDERS - 1,
Plc_NUM_ORDERS - 1, (unsigned long) Plc_ORDER_DEFAULT);
(unsigned long) Plc_ORDER_DEFAULT);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -278,9 +292,13 @@ static void Plc_EditPlacesInternal (void)
{ {
extern const char *Hlp_INSTITUTION_Places_edit; extern const char *Hlp_INSTITUTION_Places_edit;
extern const char *Txt_Places; extern const char *Txt_Places;
struct Plc_Places Places;
/***** Reset places context *****/
Plc_ResetPlaces (&Places);
/***** Get list of places *****/ /***** Get list of places *****/
Plc_GetListPlaces (); Plc_GetListPlaces (&Places);
/***** Begin box *****/ /***** Begin box *****/
Box_BoxBegin (NULL,Txt_Places, Box_BoxBegin (NULL,Txt_Places,
@ -291,17 +309,16 @@ static void Plc_EditPlacesInternal (void)
Plc_PutFormToCreatePlace (); Plc_PutFormToCreatePlace ();
/***** Forms to edit current places *****/ /***** Forms to edit current places *****/
if (Gbl.Plcs.Num) if (Places.Num)
Plc_ListPlacesForEdition (); Plc_ListPlacesForEdition (&Places);
/***** End box *****/ /***** End box *****/
Box_BoxEnd (); Box_BoxEnd ();
/***** Free list of places *****/ /***** Free list of places *****/
Plc_FreeListPlaces (); Plc_FreeListPlaces (&Places);
} }
/*****************************************************************************/ /*****************************************************************************/
/**************** Put contextual icons in edition of places *****************/ /**************** Put contextual icons in edition of places *****************/
/*****************************************************************************/ /*****************************************************************************/
@ -333,7 +350,7 @@ void Plc_PutIconToViewPlaces (void)
/**************************** List all the places ****************************/ /**************************** List all the places ****************************/
/*****************************************************************************/ /*****************************************************************************/
void Plc_GetListPlaces (void) void Plc_GetListPlaces (struct Plc_Places *Places)
{ {
static const char *OrderBySubQuery[Plc_NUM_ORDERS] = static const char *OrderBySubQuery[Plc_NUM_ORDERS] =
{ {
@ -344,7 +361,7 @@ void Plc_GetListPlaces (void)
MYSQL_ROW row; MYSQL_ROW row;
unsigned long NumRows; unsigned long NumRows;
unsigned NumPlc; unsigned NumPlc;
struct Place *Plc; struct Plc_Place *Plc;
/***** Get places from database *****/ /***** Get places from database *****/
NumRows = DB_QuerySELECT (&mysql_res,"can not get places", NumRows = DB_QuerySELECT (&mysql_res,"can not get places",
@ -372,23 +389,23 @@ void Plc_GetListPlaces (void)
Gbl.Hierarchy.Ins.InsCod, Gbl.Hierarchy.Ins.InsCod,
Gbl.Hierarchy.Ins.InsCod, Gbl.Hierarchy.Ins.InsCod,
Gbl.Hierarchy.Ins.InsCod, Gbl.Hierarchy.Ins.InsCod,
OrderBySubQuery[Gbl.Plcs.SelectedOrder]); OrderBySubQuery[Places->SelectedOrder]);
/***** Count number of rows in result *****/ /***** Count number of rows in result *****/
if (NumRows) // Places found... if (NumRows) // Places found...
{ {
Gbl.Plcs.Num = (unsigned) NumRows; Places->Num = (unsigned) NumRows;
/***** Create list with courses in centre *****/ /***** Create list with courses in centre *****/
if ((Gbl.Plcs.Lst = (struct Place *) calloc (NumRows,sizeof (struct Place))) == NULL) if ((Places->Lst = (struct Plc_Place *) calloc (NumRows,sizeof (struct Plc_Place))) == NULL)
Lay_NotEnoughMemoryExit (); Lay_NotEnoughMemoryExit ();
/***** Get the places *****/ /***** Get the places *****/
for (NumPlc = 0; for (NumPlc = 0;
NumPlc < Gbl.Plcs.Num; NumPlc < Places->Num;
NumPlc++) NumPlc++)
{ {
Plc = &(Gbl.Plcs.Lst[NumPlc]); Plc = &(Places->Lst[NumPlc]);
/* Get next place */ /* Get next place */
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
@ -411,7 +428,7 @@ void Plc_GetListPlaces (void)
} }
} }
else else
Gbl.Plcs.Num = 0; Places->Num = 0;
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res); DB_FreeMySQLResult (&mysql_res);
@ -421,7 +438,7 @@ void Plc_GetListPlaces (void)
/**************************** Get place full name ****************************/ /**************************** Get place full name ****************************/
/*****************************************************************************/ /*****************************************************************************/
void Plc_GetDataOfPlaceByCod (struct Place *Plc) void Plc_GetDataOfPlaceByCod (struct Plc_Place *Plc)
{ {
extern const char *Txt_Place_unspecified; extern const char *Txt_Place_unspecified;
extern const char *Txt_Another_place; extern const char *Txt_Another_place;
@ -501,14 +518,14 @@ void Plc_GetDataOfPlaceByCod (struct Place *Plc)
/**************************** Free list of places ****************************/ /**************************** Free list of places ****************************/
/*****************************************************************************/ /*****************************************************************************/
void Plc_FreeListPlaces (void) void Plc_FreeListPlaces (struct Plc_Places *Places)
{ {
if (Gbl.Plcs.Lst) if (Places->Lst)
{ {
/***** Free memory used by the list of places in institution *****/ /***** Free memory used by the list of places in institution *****/
free (Gbl.Plcs.Lst); free (Places->Lst);
Gbl.Plcs.Lst = NULL; Places->Lst = NULL;
Gbl.Plcs.Num = 0; Places->Num = 0;
} }
} }
@ -516,10 +533,10 @@ void Plc_FreeListPlaces (void)
/*************************** List all the places *****************************/ /*************************** List all the places *****************************/
/*****************************************************************************/ /*****************************************************************************/
static void Plc_ListPlacesForEdition (void) static void Plc_ListPlacesForEdition (const struct Plc_Places *Places)
{ {
unsigned NumPlc; unsigned NumPlc;
struct Place *Plc; struct Plc_Place *Plc;
/***** Write heading *****/ /***** Write heading *****/
HTM_TABLE_BeginWidePadding (2); HTM_TABLE_BeginWidePadding (2);
@ -527,10 +544,10 @@ static void Plc_ListPlacesForEdition (void)
/***** Write all the places *****/ /***** Write all the places *****/
for (NumPlc = 0; for (NumPlc = 0;
NumPlc < Gbl.Plcs.Num; NumPlc < Places->Num;
NumPlc++) NumPlc++)
{ {
Plc = &Gbl.Plcs.Lst[NumPlc]; Plc = &Places->Lst[NumPlc];
HTM_TR_Begin (NULL); HTM_TR_Begin (NULL);
@ -912,7 +929,7 @@ void Plc_RecFormNewPlace (void)
/**************************** Create a new place *****************************/ /**************************** Create a new place *****************************/
/*****************************************************************************/ /*****************************************************************************/
static void Plc_CreatePlace (struct Place *Plc) static void Plc_CreatePlace (struct Plc_Place *Plc)
{ {
/***** Create a new place *****/ /***** Create a new place *****/
DB_QueryINSERT ("can not create place", DB_QueryINSERT ("can not create place",
@ -934,7 +951,7 @@ static void Plc_EditingPlaceConstructor (void)
Lay_ShowErrorAndExit ("Error initializing place."); Lay_ShowErrorAndExit ("Error initializing place.");
/***** Allocate memory for place *****/ /***** Allocate memory for place *****/
if ((Plc_EditingPlc = (struct Place *) malloc (sizeof (struct Place))) == NULL) if ((Plc_EditingPlc = (struct Plc_Place *) malloc (sizeof (struct Plc_Place))) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for place."); Lay_ShowErrorAndExit ("Error allocating memory for place.");
/***** Reset place *****/ /***** Reset place *****/

View File

@ -39,7 +39,7 @@
#define Plc_MAX_CHARS_PLACE_FULL_NAME (128 - 1) // 127 #define Plc_MAX_CHARS_PLACE_FULL_NAME (128 - 1) // 127
#define Plc_MAX_BYTES_PLACE_FULL_NAME ((Plc_MAX_CHARS_PLACE_FULL_NAME + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 #define Plc_MAX_BYTES_PLACE_FULL_NAME ((Plc_MAX_CHARS_PLACE_FULL_NAME + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047
struct Place struct Plc_Place
{ {
long PlcCod; long PlcCod;
long InsCod; long InsCod;
@ -56,16 +56,25 @@ typedef enum
} Plc_Order_t; } Plc_Order_t;
#define Plc_ORDER_DEFAULT Plc_ORDER_BY_NUM_CTRS #define Plc_ORDER_DEFAULT Plc_ORDER_BY_NUM_CTRS
struct Plc_Places
{
unsigned Num; // Number of places
struct Plc_Place *Lst; // List of places
Plc_Order_t SelectedOrder;
};
/*****************************************************************************/ /*****************************************************************************/
/***************************** Public prototypes *****************************/ /***************************** Public prototypes *****************************/
/*****************************************************************************/ /*****************************************************************************/
void Plc_ResetPlaces (struct Plc_Places *Places);
void Plc_SeePlaces (void); void Plc_SeePlaces (void);
void Plc_EditPlaces (void); void Plc_EditPlaces (void);
void Plc_PutIconToViewPlaces (void); void Plc_PutIconToViewPlaces (void);
void Plc_GetListPlaces (void); void Plc_GetListPlaces (struct Plc_Places *Places);
void Plc_FreeListPlaces (void); void Plc_FreeListPlaces (struct Plc_Places *Places);
void Plc_GetDataOfPlaceByCod (struct Place *Plc); void Plc_GetDataOfPlaceByCod (struct Plc_Place *Plc);
long Plc_GetParamPlcCod (void); long Plc_GetParamPlcCod (void);
void Plc_RemovePlace (void); void Plc_RemovePlace (void);
void Plc_RenamePlaceShort (void); void Plc_RenamePlaceShort (void);