diff --git a/Makefile b/Makefile index eb5557b5c..3e5465ff8 100644 --- a/Makefile +++ b/Makefile @@ -33,11 +33,12 @@ OBJS = swad_account.o swad_account_database.o swad_action.o swad_agenda.o \ swad_banner.o swad_banner_database.o swad_box.o swad_building.o \ swad_building_database.o swad_button.o \ swad_calendar.o swad_call_for_exam.o swad_call_for_exam_database.o \ - swad_center.o swad_center_config.o swad_chat.o swad_chat_database.o \ - swad_config.o swad_connected.o swad_connected_database.o swad_cookie.o \ - swad_cookie_database.o swad_country.o swad_country_config.o \ - swad_country_database.o swad_course.o swad_course_config.o \ - swad_course_database.o swad_cryptography.o \ + swad_center.o swad_center_config.o swad_center_database.o swad_chat.o \ + swad_chat_database.o swad_config.o swad_connected.o \ + swad_connected_database.o swad_cookie.o swad_cookie_database.o \ + swad_country.o swad_country_config.o swad_country_database.o \ + swad_course.o swad_course_config.o swad_course_database.o \ + swad_cryptography.o \ swad_database.o swad_date.o swad_degree.o swad_degree_config.o \ swad_degree_database.o swad_degree_type.o swad_department.o \ swad_duplicate.o \ diff --git a/swad_building_database.c b/swad_building_database.c index 9342446aa..3ec2401f6 100644 --- a/swad_building_database.c +++ b/swad_building_database.c @@ -25,17 +25,9 @@ /********************************** Headers **********************************/ /*****************************************************************************/ -// #include // For calloc, free -// #include // For NULL -// #include // For string functions - -// #include "swad_box.h" #include "swad_building.h" #include "swad_database.h" -// #include "swad_error.h" -// #include "swad_form.h" #include "swad_global.h" -// #include "swad_HTML.h" /*****************************************************************************/ /************** External global variables from others modules ****************/ diff --git a/swad_building_database.h b/swad_building_database.h index e6612613a..b8a62a10a 100644 --- a/swad_building_database.h +++ b/swad_building_database.h @@ -30,7 +30,6 @@ #include // To access MySQL databases #include "swad_building.h" -// #include "swad_string.h" /*****************************************************************************/ /************************** Public types and constants ***********************/ diff --git a/swad_center.c b/swad_center.c index 2af4d3222..66c5ca91a 100644 --- a/swad_center.c +++ b/swad_center.c @@ -90,7 +90,7 @@ static Ctr_Status_t Ctr_GetStatusBitsFromStatusTxt (Ctr_StatusTxt_t StatusTxt); static void Ctr_PutParamOtherCtrCod (void *CtrCod); -static void Ctr_UpdateInsNameDB (long CtrCod,const char *FieldName,const char *NewCtrName); +static void Ctr_DB_UpdateCtrName (long CtrCod,const char *FieldName,const char *NewCtrName); static void Ctr_ShowAlertAndButtonToGoToCtr (void); static void Ctr_PutParamGoToCtr (void *CtrCod); @@ -99,7 +99,7 @@ static void Ctr_PutFormToCreateCenter (const struct Plc_Places *Places); static void Ctr_PutHeadCentersForSeeing (bool OrderSelectable); static void Ctr_PutHeadCentersForEdition (void); static void Ctr_ReceiveFormRequestOrCreateCtr (unsigned Status); -static void Ctr_CreateCenter (unsigned Status); +static void Ctr_DB_CreateCenter (unsigned Status); static unsigned Ctr_GetNumCtrsInCty (long CtyCod); @@ -169,46 +169,45 @@ void Ctr_SeeCtrWithPendingDegs (void) NULL,NULL, Hlp_SYSTEM_Pending,Box_NOT_CLOSABLE,2); - /***** Wrtie heading *****/ - HTM_TR_Begin (NULL); + /***** Wrtie heading *****/ + HTM_TR_Begin (NULL); - HTM_TH (1,1,"LM",Txt_Center); - HTM_TH (1,1,"RM",Txt_Degrees_ABBREVIATION); + HTM_TH (1,1,"LM",Txt_Center); + HTM_TH (1,1,"RM",Txt_Degrees_ABBREVIATION); - HTM_TR_End (); + HTM_TR_End (); - /***** List the centers *****/ - for (NumCtr = 0; - NumCtr < NumCtrs; - NumCtr++) - { - /* Get next center */ - row = mysql_fetch_row (mysql_res); + /***** List the centers *****/ + for (NumCtr = 0; + NumCtr < NumCtrs; + NumCtr++, Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd) + { + /* Get next center */ + row = mysql_fetch_row (mysql_res); - /* Get center code (row[0]) */ - Ctr.CtrCod = Str_ConvertStrCodToLongCod (row[0]); - BgColor = (Ctr.CtrCod == Gbl.Hierarchy.Ctr.CtrCod) ? "LIGHT_BLUE" : - Gbl.ColorRows[Gbl.RowEvenOdd]; + /* Get center code (row[0]) */ + Ctr.CtrCod = Str_ConvertStrCodToLongCod (row[0]); + BgColor = (Ctr.CtrCod == Gbl.Hierarchy.Ctr.CtrCod) ? "LIGHT_BLUE" : + Gbl.ColorRows[Gbl.RowEvenOdd]; - /* Get data of center */ - Ctr_GetDataOfCenterByCod (&Ctr); + /* Get data of center */ + Ctr_GetDataOfCenterByCod (&Ctr); - /* Center logo and full name */ - HTM_TR_Begin (NULL); + /* Center logo and full name */ + HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"LM %s\"",BgColor); - Ctr_DrawCenterLogoAndNameWithLink (&Ctr,ActSeeDeg, - "BT_LINK DAT_NOBR","CM"); - HTM_TD_End (); + HTM_TD_Begin ("class=\"LM %s\"",BgColor); + Ctr_DrawCenterLogoAndNameWithLink (&Ctr,ActSeeDeg, + "BT_LINK DAT_NOBR","CM"); + HTM_TD_End (); - /* Number of pending degrees (row[1]) */ - HTM_TD_Begin ("class=\"DAT RM %s\"",BgColor); - HTM_Txt (row[1]); - HTM_TD_End (); + /* Number of pending degrees (row[1]) */ + HTM_TD_Begin ("class=\"DAT RM %s\"",BgColor); + HTM_Txt (row[1]); + HTM_TD_End (); - Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd; - HTM_TR_End (); - } + HTM_TR_End (); + } /***** End table and box *****/ Box_BoxTableEnd (); @@ -231,16 +230,16 @@ void Ctr_DrawCenterLogoAndNameWithLink (struct Ctr_Center *Ctr,Act_Action_t Acti Frm_BeginFormGoTo (Action); Ctr_PutParamCtrCod (Ctr->CtrCod); - /***** Link to action *****/ - HTM_BUTTON_SUBMIT_Begin (Hie_BuildGoToMsg (Ctr->FullName),ClassLink,NULL); - Hie_FreeGoToMsg (); + /***** Link to action *****/ + HTM_BUTTON_SUBMIT_Begin (Hie_BuildGoToMsg (Ctr->FullName),ClassLink,NULL); + Hie_FreeGoToMsg (); - /***** Center logo and name *****/ - Lgo_DrawLogo (HieLvl_CTR,Ctr->CtrCod,Ctr->ShrtName,16,ClassLogo,true); - HTM_TxtF (" %s",Ctr->FullName); + /***** Center logo and name *****/ + Lgo_DrawLogo (HieLvl_CTR,Ctr->CtrCod,Ctr->ShrtName,16,ClassLogo,true); + HTM_TxtF (" %s",Ctr->FullName); - /***** End link *****/ - HTM_BUTTON_End (); + /***** End link *****/ + HTM_BUTTON_End (); /***** End form *****/ Frm_EndForm (); @@ -295,32 +294,34 @@ static void Ctr_ListCenters (void) Hlp_INSTITUTION_Centers,Box_NOT_CLOSABLE); Str_FreeString (); - if (Gbl.Hierarchy.Ctrs.Num) // There are centers in the current institution - { - /***** Begin table *****/ - HTM_TABLE_BeginWideMarginPadding (2); - Ctr_PutHeadCentersForSeeing (true); // Order selectable + if (Gbl.Hierarchy.Ctrs.Num) // There are centers in the current institution + { + /***** Begin table *****/ + HTM_TABLE_BeginWideMarginPadding (2); - /***** Write all the centers and their nuber of teachers *****/ - for (NumCtr = 0; - NumCtr < Gbl.Hierarchy.Ctrs.Num; - NumCtr++) - Ctr_ListOneCenterForSeeing (&(Gbl.Hierarchy.Ctrs.Lst[NumCtr]),NumCtr + 1); + /***** Write heading *****/ + Ctr_PutHeadCentersForSeeing (true); // Order selectable - /***** End table *****/ - HTM_TABLE_End (); - } - else // No centers created in the current institution - Ale_ShowAlert (Ale_INFO,Txt_No_centers); + /***** Write all the centers and their nuber of teachers *****/ + for (NumCtr = 0; + NumCtr < Gbl.Hierarchy.Ctrs.Num; + NumCtr++) + Ctr_ListOneCenterForSeeing (&(Gbl.Hierarchy.Ctrs.Lst[NumCtr]),NumCtr + 1); - /***** Button to create center *****/ - if (Ctr_CheckIfICanCreateCenters ()) - { - Frm_BeginForm (ActEdiCtr); - Btn_PutConfirmButton (Gbl.Hierarchy.Ctrs.Num ? Txt_Create_another_center : - Txt_Create_center); - Frm_EndForm (); - } + /***** End table *****/ + HTM_TABLE_End (); + } + else // No centers created in the current institution + Ale_ShowAlert (Ale_INFO,Txt_No_centers); + + /***** Button to create center *****/ + if (Ctr_CheckIfICanCreateCenters ()) + { + Frm_BeginForm (ActEdiCtr); + Btn_PutConfirmButton (Gbl.Hierarchy.Ctrs.Num ? Txt_Create_another_center : + Txt_Create_center); + Frm_EndForm (); + } /***** End box *****/ Box_BoxEnd (); @@ -394,51 +395,51 @@ static void Ctr_ListOneCenterForSeeing (struct Ctr_Center *Ctr,unsigned NumCtr) HTM_TR_Begin (NULL); - /***** Number of center in this list *****/ - HTM_TD_Begin ("class=\"%s RM %s\"",TxtClassNormal,BgColor); - HTM_Unsigned (NumCtr); - HTM_TD_End (); + /***** Number of center in this list *****/ + HTM_TD_Begin ("class=\"%s RM %s\"",TxtClassNormal,BgColor); + HTM_Unsigned (NumCtr); + HTM_TD_End (); - /***** Center logo and name *****/ - HTM_TD_Begin ("class=\"LM %s\"",BgColor); - Ctr_DrawCenterLogoAndNameWithLink (Ctr,ActSeeDeg, - TxtClassStrong,"CM"); - HTM_TD_End (); + /***** Center logo and name *****/ + HTM_TD_Begin ("class=\"LM %s\"",BgColor); + Ctr_DrawCenterLogoAndNameWithLink (Ctr,ActSeeDeg, + TxtClassStrong,"CM"); + HTM_TD_End (); - /***** Number of users who claim to belong to this center *****/ - HTM_TD_Begin ("class=\"%s RM %s\"",TxtClassNormal,BgColor); - HTM_Unsigned (Usr_GetCachedNumUsrsWhoClaimToBelongToCtr (Ctr)); - HTM_TD_End (); + /***** Number of users who claim to belong to this center *****/ + HTM_TD_Begin ("class=\"%s RM %s\"",TxtClassNormal,BgColor); + HTM_Unsigned (Usr_GetCachedNumUsrsWhoClaimToBelongToCtr (Ctr)); + HTM_TD_End (); - /***** Place *****/ - HTM_TD_Begin ("class=\"%s LM %s\"",TxtClassNormal,BgColor); - HTM_Txt (Plc.ShrtName); - HTM_TD_End (); + /***** Place *****/ + HTM_TD_Begin ("class=\"%s LM %s\"",TxtClassNormal,BgColor); + HTM_Txt (Plc.ShrtName); + HTM_TD_End (); - /***** Number of degrees *****/ - HTM_TD_Begin ("class=\"%s RM %s\"",TxtClassNormal,BgColor); - HTM_Unsigned (Deg_GetCachedNumDegsInCtr (Ctr->CtrCod)); - HTM_TD_End (); + /***** Number of degrees *****/ + HTM_TD_Begin ("class=\"%s RM %s\"",TxtClassNormal,BgColor); + HTM_Unsigned (Deg_GetCachedNumDegsInCtr (Ctr->CtrCod)); + HTM_TD_End (); - /***** Number of courses *****/ - HTM_TD_Begin ("class=\"%s RM %s\"",TxtClassNormal,BgColor); - HTM_Unsigned (Crs_GetCachedNumCrssInCtr (Ctr->CtrCod)); - HTM_TD_End (); + /***** Number of courses *****/ + HTM_TD_Begin ("class=\"%s RM %s\"",TxtClassNormal,BgColor); + HTM_Unsigned (Crs_GetCachedNumCrssInCtr (Ctr->CtrCod)); + HTM_TD_End (); - /***** Number of users in courses of this center *****/ - HTM_TD_Begin ("class=\"%s RM %s\"",TxtClassNormal,BgColor); - HTM_Unsigned (Usr_GetCachedNumUsrsInCrss (HieLvl_CTR,Ctr->CtrCod, - 1 << Rol_STD | - 1 << Rol_NET | - 1 << Rol_TCH)); // Any user - HTM_TD_End (); + /***** Number of users in courses of this center *****/ + HTM_TD_Begin ("class=\"%s RM %s\"",TxtClassNormal,BgColor); + HTM_Unsigned (Usr_GetCachedNumUsrsInCrss (HieLvl_CTR,Ctr->CtrCod, + 1 << Rol_STD | + 1 << Rol_NET | + 1 << Rol_TCH)); // Any user + HTM_TD_End (); - /***** Center status *****/ - StatusTxt = Ctr_GetStatusTxtFromStatusBits (Ctr->Status); - HTM_TD_Begin ("class=\"%s LM %s\"",TxtClassNormal,BgColor); - if (StatusTxt != Ctr_STATUS_ACTIVE) // If active ==> do not show anything - HTM_Txt (Txt_CENTER_STATUS[StatusTxt]); - HTM_TD_End (); + /***** Center status *****/ + StatusTxt = Ctr_GetStatusTxtFromStatusBits (Ctr->Status); + HTM_TD_Begin ("class=\"%s LM %s\"",TxtClassNormal,BgColor); + if (StatusTxt != Ctr_STATUS_ACTIVE) // If active ==> do not show anything + HTM_Txt (Txt_CENTER_STATUS[StatusTxt]); + HTM_TD_End (); HTM_TR_End (); @@ -452,10 +453,10 @@ static void Ctr_ListOneCenterForSeeing (struct Ctr_Center *Ctr,unsigned NumCtr) static void Ctr_GetParamCtrOrder (void) { Gbl.Hierarchy.Ctrs.SelectedOrder = (Ctr_Order_t) - Par_GetParToUnsignedLong ("Order", - 0, - Ctr_NUM_ORDERS - 1, - (unsigned long) Ctr_ORDER_DEFAULT); + Par_GetParToUnsignedLong ("Order", + 0, + Ctr_NUM_ORDERS - 1, + (unsigned long) Ctr_ORDER_DEFAULT); } /*****************************************************************************/ @@ -501,12 +502,12 @@ static void Ctr_EditCentersInternal (void) Hlp_INSTITUTION_Centers,Box_NOT_CLOSABLE); Str_FreeString (); - /***** Put a form to create a new center *****/ - Ctr_PutFormToCreateCenter (&Places); + /***** Put a form to create a new center *****/ + Ctr_PutFormToCreateCenter (&Places); - /***** List current centers *****/ - if (Gbl.Hierarchy.Ctrs.Num) - Ctr_ListCentersForEdition (&Places); + /***** List current centers *****/ + if (Gbl.Hierarchy.Ctrs.Num) + Ctr_ListCentersForEdition (&Places); /***** End box *****/ Box_BoxEnd (); @@ -850,54 +851,57 @@ void Ctr_WriteSelectorOfCenter (void) /***** Begin form *****/ Frm_BeginFormGoTo (ActSeeDeg); - if (Gbl.Hierarchy.Ins.InsCod > 0) - HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE, - "id=\"ctr\" name=\"ctr\" class=\"HIE_SEL\""); - else - HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE, - "id=\"ctr\" name=\"ctr\" class=\"HIE_SEL\"" - " disabled=\"disabled\""); - HTM_OPTION (HTM_Type_STRING,"", - Gbl.Hierarchy.Ctr.CtrCod < 0,true, - "[%s]",Txt_Center); + /***** Begin selector *****/ + if (Gbl.Hierarchy.Ins.InsCod > 0) + HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE, + "id=\"ctr\" name=\"ctr\" class=\"HIE_SEL\""); + else + HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE, + "id=\"ctr\" name=\"ctr\" class=\"HIE_SEL\"" + " disabled=\"disabled\""); + HTM_OPTION (HTM_Type_STRING,"", + Gbl.Hierarchy.Ctr.CtrCod < 0,true, + "[%s]",Txt_Center); - if (Gbl.Hierarchy.Ins.InsCod > 0) - { - /***** Get centers from database *****/ - NumCtrs = (unsigned) - DB_QuerySELECT (&mysql_res,"can not get centers", - "SELECT DISTINCT CtrCod," // row[0] - "ShortName" // row[1] - " FROM ctr_centers" - " WHERE InsCod=%ld" - " ORDER BY ShortName", - Gbl.Hierarchy.Ins.InsCod); + if (Gbl.Hierarchy.Ins.InsCod > 0) + { + /***** Get centers from database *****/ + NumCtrs = (unsigned) + DB_QuerySELECT (&mysql_res,"can not get centers", + "SELECT DISTINCT CtrCod," // row[0] + "ShortName" // row[1] + " FROM ctr_centers" + " WHERE InsCod=%ld" + " ORDER BY ShortName", + Gbl.Hierarchy.Ins.InsCod); - /***** Get centers *****/ - for (NumCtr = 0; - NumCtr < NumCtrs; - NumCtr++) - { - /* Get next center */ - row = mysql_fetch_row (mysql_res); + /***** Get centers *****/ + for (NumCtr = 0; + NumCtr < NumCtrs; + NumCtr++) + { + /* Get next center */ + row = mysql_fetch_row (mysql_res); - /* Get center code (row[0]) */ - if ((CtrCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Err_WrongCenterExit (); + /* Get center code (row[0]) */ + if ((CtrCod = Str_ConvertStrCodToLongCod (row[0])) < 0) + Err_WrongCenterExit (); - /* Write option */ - HTM_OPTION (HTM_Type_LONG,&CtrCod, - Gbl.Hierarchy.Ctr.CtrCod > 0 && - CtrCod == Gbl.Hierarchy.Ctr.CtrCod,false, - "%s",row[1]); - } + /* Write option */ + HTM_OPTION (HTM_Type_LONG,&CtrCod, + Gbl.Hierarchy.Ctr.CtrCod > 0 && + CtrCod == Gbl.Hierarchy.Ctr.CtrCod,false, + "%s",row[1]); + } - /***** Free structure that stores the query result *****/ - DB_FreeMySQLResult (&mysql_res); - } + /***** Free structure that stores the query result *****/ + DB_FreeMySQLResult (&mysql_res); + } + + /***** End selector *****/ + HTM_SELECT_End (); /***** End form *****/ - HTM_SELECT_End (); Frm_EndForm (); } @@ -924,179 +928,183 @@ static void Ctr_ListCentersForEdition (const struct Plc_Places *Places) /***** Initialize structure with user's data *****/ Usr_UsrDataConstructor (&UsrDat); - /***** Write heading *****/ + /***** Begin table *****/ HTM_TABLE_BeginWidePadding (2); - Ctr_PutHeadCentersForEdition (); - /***** Write all the centers *****/ - for (NumCtr = 0; - NumCtr < Gbl.Hierarchy.Ctrs.Num; - NumCtr++) - { - Ctr = &Gbl.Hierarchy.Ctrs.Lst[NumCtr]; + /***** Write heading *****/ + Ctr_PutHeadCentersForEdition (); - ICanEdit = Ctr_CheckIfICanEditACenter (Ctr); - NumDegs = Deg_GetNumDegsInCtr (Ctr->CtrCod); - NumUsrsCtr = Usr_GetNumUsrsWhoClaimToBelongToCtr (Ctr); - NumUsrsInCrssOfCtr = Usr_GetNumUsrsInCrss (HieLvl_CTR,Ctr->CtrCod, - 1 << Rol_STD | - 1 << Rol_NET | - 1 << Rol_TCH); // Any user - - /* Put icon to remove center */ - HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"BM\""); - if (!ICanEdit || // I cannot edit - NumDegs || // Center has degrees - NumUsrsCtr || // Center has users who claim to belong to it - NumUsrsInCrssOfCtr) // Center has users - Ico_PutIconRemovalNotAllowed (); - else // I can remove center - Ico_PutContextualIconToRemove (ActRemCtr,NULL, - Ctr_PutParamOtherCtrCod,&Ctr->CtrCod); - HTM_TD_End (); - - /* Center code */ - HTM_TD_Begin ("class=\"DAT CODE\""); - HTM_Long (Ctr->CtrCod); - HTM_TD_End (); - - /* Center logo */ - HTM_TD_Begin ("title=\"%s\" class=\"HIE_LOGO\"",Ctr->FullName); - Lgo_DrawLogo (HieLvl_CTR,Ctr->CtrCod,Ctr->ShrtName,20,NULL,true); - HTM_TD_End (); - - /* Place */ - HTM_TD_Begin ("class=\"DAT LM\""); - if (ICanEdit) + /***** Write all the centers *****/ + for (NumCtr = 0; + NumCtr < Gbl.Hierarchy.Ctrs.Num; + NumCtr++) { - Frm_BeginForm (ActChgCtrPlc); - Ctr_PutParamOtherCtrCod (&Ctr->CtrCod); - HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE, - "name=\"PlcCod\" class=\"PLC_SEL\""); - HTM_OPTION (HTM_Type_STRING,"0", - Ctr->PlcCod == 0,false, - "%s",Txt_Another_place); - for (NumPlc = 0; - NumPlc < Places->Num; - NumPlc++) - HTM_OPTION (HTM_Type_LONG,&Places->Lst[NumPlc].PlcCod, - Places->Lst[NumPlc].PlcCod == Ctr->PlcCod,false, - "%s",Places->Lst[NumPlc].ShrtName); - HTM_SELECT_End (); - Frm_EndForm (); + Ctr = &Gbl.Hierarchy.Ctrs.Lst[NumCtr]; + + ICanEdit = Ctr_CheckIfICanEditACenter (Ctr); + NumDegs = Deg_GetNumDegsInCtr (Ctr->CtrCod); + NumUsrsCtr = Usr_GetNumUsrsWhoClaimToBelongToCtr (Ctr); + NumUsrsInCrssOfCtr = Usr_GetNumUsrsInCrss (HieLvl_CTR,Ctr->CtrCod, + 1 << Rol_STD | + 1 << Rol_NET | + 1 << Rol_TCH); // Any user + + HTM_TR_Begin (NULL); + + /* Put icon to remove center */ + HTM_TD_Begin ("class=\"BM\""); + if (!ICanEdit || // I cannot edit + NumDegs || // Center has degrees + NumUsrsCtr || // Center has users who claim to belong to it + NumUsrsInCrssOfCtr) // Center has users + Ico_PutIconRemovalNotAllowed (); + else // I can remove center + Ico_PutContextualIconToRemove (ActRemCtr,NULL, + Ctr_PutParamOtherCtrCod,&Ctr->CtrCod); + HTM_TD_End (); + + /* Center code */ + HTM_TD_Begin ("class=\"DAT CODE\""); + HTM_Long (Ctr->CtrCod); + HTM_TD_End (); + + /* Center logo */ + HTM_TD_Begin ("title=\"%s\" class=\"HIE_LOGO\"",Ctr->FullName); + Lgo_DrawLogo (HieLvl_CTR,Ctr->CtrCod,Ctr->ShrtName,20,NULL,true); + HTM_TD_End (); + + /* Place */ + HTM_TD_Begin ("class=\"DAT LM\""); + if (ICanEdit) + { + Frm_BeginForm (ActChgCtrPlc); + Ctr_PutParamOtherCtrCod (&Ctr->CtrCod); + HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE, + "name=\"PlcCod\" class=\"PLC_SEL\""); + HTM_OPTION (HTM_Type_STRING,"0", + Ctr->PlcCod == 0,false, + "%s",Txt_Another_place); + for (NumPlc = 0; + NumPlc < Places->Num; + NumPlc++) + HTM_OPTION (HTM_Type_LONG,&Places->Lst[NumPlc].PlcCod, + Places->Lst[NumPlc].PlcCod == Ctr->PlcCod,false, + "%s",Places->Lst[NumPlc].ShrtName); + HTM_SELECT_End (); + Frm_EndForm (); + } + else + for (NumPlc = 0; + NumPlc < Places->Num; + NumPlc++) + if (Places->Lst[NumPlc].PlcCod == Ctr->PlcCod) + HTM_Txt (Places->Lst[NumPlc].ShrtName); + HTM_TD_End (); + + /* Center short name */ + HTM_TD_Begin ("class=\"DAT LM\""); + if (ICanEdit) + { + Frm_BeginForm (ActRenCtrSho); + Ctr_PutParamOtherCtrCod (&Ctr->CtrCod); + HTM_INPUT_TEXT ("ShortName",Cns_HIERARCHY_MAX_CHARS_SHRT_NAME,Ctr->ShrtName, + HTM_SUBMIT_ON_CHANGE, + "class=\"INPUT_SHORT_NAME\""); + Frm_EndForm (); + } + else + HTM_Txt (Ctr->ShrtName); + HTM_TD_End (); + + /* Center full name */ + HTM_TD_Begin ("class=\"DAT LM\""); + if (ICanEdit) + { + Frm_BeginForm (ActRenCtrFul); + Ctr_PutParamOtherCtrCod (&Ctr->CtrCod); + HTM_INPUT_TEXT ("FullName",Cns_HIERARCHY_MAX_CHARS_FULL_NAME,Ctr->FullName, + HTM_SUBMIT_ON_CHANGE, + "class=\"INPUT_FULL_NAME\""); + Frm_EndForm (); + } + else + HTM_Txt (Ctr->FullName); + HTM_TD_End (); + + /* Center WWW */ + HTM_TD_Begin ("class=\"DAT LM\""); + if (ICanEdit) + { + Frm_BeginForm (ActChgCtrWWW); + Ctr_PutParamOtherCtrCod (&Ctr->CtrCod); + HTM_INPUT_URL ("WWW",Ctr->WWW,HTM_SUBMIT_ON_CHANGE, + "class=\"INPUT_WWW_NARROW\" required=\"required\""); + Frm_EndForm (); + } + else + { + Str_Copy (WWW,Ctr->WWW,sizeof (WWW) - 1); + HTM_DIV_Begin ("class=\"EXTERNAL_WWW_SHORT\""); + HTM_A_Begin ("href=\"%s\" target=\"_blank\"" + " class=\"DAT\" title=\"%s\"",Ctr->WWW,Ctr->WWW); + HTM_Txt (WWW); + HTM_A_End (); + HTM_DIV_End (); + } + HTM_TD_End (); + + /* Number of users who claim to belong to this center */ + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumUsrsCtr); + HTM_TD_End (); + + /* Number of degrees */ + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumDegs); + HTM_TD_End (); + + /* Number of users in courses of this center */ + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumUsrsInCrssOfCtr); + HTM_TD_End (); + + /* Center requester */ + UsrDat.UsrCod = Ctr->RequesterUsrCod; + Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat, + Usr_DONT_GET_PREFS, + Usr_DONT_GET_ROLE_IN_CURRENT_CRS); + HTM_TD_Begin ("class=\"DAT INPUT_REQUESTER LT\""); + Msg_WriteMsgAuthor (&UsrDat,true,NULL); + HTM_TD_End (); + + /* Center status */ + StatusTxt = Ctr_GetStatusTxtFromStatusBits (Ctr->Status); + HTM_TD_Begin ("class=\"DAT LM\""); + if (Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM && + StatusTxt == Ctr_STATUS_PENDING) + { + Frm_BeginForm (ActChgCtrSta); + Ctr_PutParamOtherCtrCod (&Ctr->CtrCod); + HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE, + "name=\"Status\" class=\"INPUT_STATUS\""); + + StatusUnsigned = (unsigned) Ctr_GetStatusBitsFromStatusTxt (Ctr_STATUS_PENDING); + HTM_OPTION (HTM_Type_UNSIGNED,&StatusUnsigned,true,false, + "%s",Txt_CENTER_STATUS[Ctr_STATUS_PENDING]); + + StatusUnsigned = (unsigned) Ctr_GetStatusBitsFromStatusTxt (Ctr_STATUS_ACTIVE); + HTM_OPTION (HTM_Type_UNSIGNED,&StatusUnsigned,false,false, + "%s",Txt_CENTER_STATUS[Ctr_STATUS_ACTIVE]); + + HTM_SELECT_End (); + Frm_EndForm (); + } + else if (StatusTxt != Ctr_STATUS_ACTIVE) // If active ==> do not show anything + HTM_Txt (Txt_CENTER_STATUS[StatusTxt]); + HTM_TD_End (); + + HTM_TR_End (); } - else - for (NumPlc = 0; - NumPlc < Places->Num; - NumPlc++) - if (Places->Lst[NumPlc].PlcCod == Ctr->PlcCod) - HTM_Txt (Places->Lst[NumPlc].ShrtName); - HTM_TD_End (); - - /* Center short name */ - HTM_TD_Begin ("class=\"DAT LM\""); - if (ICanEdit) - { - Frm_BeginForm (ActRenCtrSho); - Ctr_PutParamOtherCtrCod (&Ctr->CtrCod); - HTM_INPUT_TEXT ("ShortName",Cns_HIERARCHY_MAX_CHARS_SHRT_NAME,Ctr->ShrtName, - HTM_SUBMIT_ON_CHANGE, - "class=\"INPUT_SHORT_NAME\""); - Frm_EndForm (); - } - else - HTM_Txt (Ctr->ShrtName); - HTM_TD_End (); - - /* Center full name */ - HTM_TD_Begin ("class=\"DAT LM\""); - if (ICanEdit) - { - Frm_BeginForm (ActRenCtrFul); - Ctr_PutParamOtherCtrCod (&Ctr->CtrCod); - HTM_INPUT_TEXT ("FullName",Cns_HIERARCHY_MAX_CHARS_FULL_NAME,Ctr->FullName, - HTM_SUBMIT_ON_CHANGE, - "class=\"INPUT_FULL_NAME\""); - Frm_EndForm (); - } - else - HTM_Txt (Ctr->FullName); - HTM_TD_End (); - - /* Center WWW */ - HTM_TD_Begin ("class=\"DAT LM\""); - if (ICanEdit) - { - Frm_BeginForm (ActChgCtrWWW); - Ctr_PutParamOtherCtrCod (&Ctr->CtrCod); - HTM_INPUT_URL ("WWW",Ctr->WWW,HTM_SUBMIT_ON_CHANGE, - "class=\"INPUT_WWW_NARROW\" required=\"required\""); - Frm_EndForm (); - } - else - { - Str_Copy (WWW,Ctr->WWW,sizeof (WWW) - 1); - HTM_DIV_Begin ("class=\"EXTERNAL_WWW_SHORT\""); - HTM_A_Begin ("href=\"%s\" target=\"_blank\"" - " class=\"DAT\" title=\"%s\"",Ctr->WWW,Ctr->WWW); - HTM_Txt (WWW); - HTM_A_End (); - HTM_DIV_End (); - } - HTM_TD_End (); - - /* Number of users who claim to belong to this center */ - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumUsrsCtr); - HTM_TD_End (); - - /* Number of degrees */ - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumDegs); - HTM_TD_End (); - - /* Number of users in courses of this center */ - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumUsrsInCrssOfCtr); - HTM_TD_End (); - - /* Center requester */ - UsrDat.UsrCod = Ctr->RequesterUsrCod; - Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat, - Usr_DONT_GET_PREFS, - Usr_DONT_GET_ROLE_IN_CURRENT_CRS); - HTM_TD_Begin ("class=\"DAT INPUT_REQUESTER LT\""); - Msg_WriteMsgAuthor (&UsrDat,true,NULL); - HTM_TD_End (); - - /* Center status */ - StatusTxt = Ctr_GetStatusTxtFromStatusBits (Ctr->Status); - HTM_TD_Begin ("class=\"DAT LM\""); - if (Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM && - StatusTxt == Ctr_STATUS_PENDING) - { - Frm_BeginForm (ActChgCtrSta); - Ctr_PutParamOtherCtrCod (&Ctr->CtrCod); - HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE, - "name=\"Status\" class=\"INPUT_STATUS\""); - - StatusUnsigned = (unsigned) Ctr_GetStatusBitsFromStatusTxt (Ctr_STATUS_PENDING); - HTM_OPTION (HTM_Type_UNSIGNED,&StatusUnsigned,true,false, - "%s",Txt_CENTER_STATUS[Ctr_STATUS_PENDING]); - - StatusUnsigned = (unsigned) Ctr_GetStatusBitsFromStatusTxt (Ctr_STATUS_ACTIVE); - HTM_OPTION (HTM_Type_UNSIGNED,&StatusUnsigned,false,false, - "%s",Txt_CENTER_STATUS[Ctr_STATUS_ACTIVE]); - - HTM_SELECT_End (); - Frm_EndForm (); - } - else if (StatusTxt != Ctr_STATUS_ACTIVE) // If active ==> do not show anything - HTM_Txt (Txt_CENTER_STATUS[StatusTxt]); - HTM_TD_End (); - HTM_TR_End (); - } /***** End table *****/ HTM_TABLE_End (); @@ -1290,7 +1298,7 @@ void Ctr_ChangeCtrPlc (void) Ctr_GetDataOfCenterByCod (Ctr_EditingCtr); /***** Update place in table of centers *****/ - Ctr_UpdateCtrPlcDB (Ctr_EditingCtr->CtrCod,NewPlcCod); + Ctr_DB_UpdateCtrPlc (Ctr_EditingCtr->CtrCod,NewPlcCod); Ctr_EditingCtr->PlcCod = NewPlcCod; /***** Create alert to show the change made @@ -1303,7 +1311,7 @@ void Ctr_ChangeCtrPlc (void) /************** Update database changing old place by new place **************/ /*****************************************************************************/ -void Ctr_UpdateCtrPlcDB (long CtrCod,long NewPlcCod) +void Ctr_DB_UpdateCtrPlc (long CtrCod,long NewPlcCod) { DB_QueryUPDATE ("can not update the place of a center", "UPDATE ctr_centers" @@ -1385,14 +1393,14 @@ void Ctr_RenameCenter (struct Ctr_Center *Ctr,Cns_ShrtOrFullName_t ShrtOrFullNam if (strcmp (CurrentCtrName,NewCtrName)) // Different names { /***** If degree was in database... *****/ - if (Ctr_CheckIfCtrNameExistsInIns (ParamName,NewCtrName,Ctr->CtrCod,Gbl.Hierarchy.Ins.InsCod)) + if (Ctr_DB_CheckIfCtrNameExistsInIns (ParamName,NewCtrName,Ctr->CtrCod,Gbl.Hierarchy.Ins.InsCod)) Ale_CreateAlert (Ale_WARNING,NULL, Txt_The_center_X_already_exists, NewCtrName); else { /* Update the table changing old name by new name */ - Ctr_UpdateInsNameDB (Ctr->CtrCod,FieldName,NewCtrName); + Ctr_DB_UpdateCtrName (Ctr->CtrCod,FieldName,NewCtrName); /* Write message to show the change made */ Ale_CreateAlert (Ale_SUCCESS,NULL, @@ -1414,8 +1422,8 @@ void Ctr_RenameCenter (struct Ctr_Center *Ctr,Cns_ShrtOrFullName_t ShrtOrFullNam /********************* Check if the name of center exists ********************/ /*****************************************************************************/ -bool Ctr_CheckIfCtrNameExistsInIns (const char *FieldName,const char *Name, - long CtrCod,long InsCod) +bool Ctr_DB_CheckIfCtrNameExistsInIns (const char *FieldName,const char *Name, + long CtrCod,long InsCod) { /***** Get number of centers with a name from database *****/ return (DB_QueryCOUNT ("can not check if the name of a center" @@ -1435,7 +1443,7 @@ bool Ctr_CheckIfCtrNameExistsInIns (const char *FieldName,const char *Name, /****************** Update center name in table of centers *******************/ /*****************************************************************************/ -static void Ctr_UpdateInsNameDB (long CtrCod,const char *FieldName,const char *NewCtrName) +static void Ctr_DB_UpdateCtrName (long CtrCod,const char *FieldName,const char *NewCtrName) { /***** Update center changing old name by new name */ DB_QueryUPDATE ("can not update the name of a center", @@ -1472,7 +1480,7 @@ void Ctr_ChangeCtrWWW (void) if (NewWWW[0]) { /***** Update database changing old WWW by new WWW *****/ - Ctr_UpdateCtrWWWDB (Ctr_EditingCtr->CtrCod,NewWWW); + Ctr_DB_UpdateCtrWWW (Ctr_EditingCtr->CtrCod,NewWWW); Str_Copy (Ctr_EditingCtr->WWW,NewWWW,sizeof (Ctr_EditingCtr->WWW) - 1); /***** Write message to show the change made @@ -1489,7 +1497,7 @@ void Ctr_ChangeCtrWWW (void) /**************** Update database changing old WWW by new WWW ****************/ /*****************************************************************************/ -void Ctr_UpdateCtrWWWDB (long CtrCod,const char NewWWW[Cns_MAX_BYTES_WWW + 1]) +void Ctr_DB_UpdateCtrWWW (long CtrCod,const char NewWWW[Cns_MAX_BYTES_WWW + 1]) { /***** Update database changing old WWW by new WWW *****/ DB_QueryUPDATE ("can not update the web of a center", @@ -1620,78 +1628,78 @@ static void Ctr_PutFormToCreateCenter (const struct Plc_Places *Places) HTM_TR_Begin (NULL); - /***** Column to remove center, disabled here *****/ - HTM_TD_Begin ("class=\"BM\""); - HTM_TD_End (); + /***** Column to remove center, disabled here *****/ + HTM_TD_Begin ("class=\"BM\""); + HTM_TD_End (); - /***** Center code *****/ - HTM_TD_Begin ("class=\"CODE\""); - HTM_TD_End (); + /***** Center code *****/ + HTM_TD_Begin ("class=\"CODE\""); + HTM_TD_End (); - /***** Center logo *****/ - HTM_TD_Begin ("title=\"%s\" class=\"HIE_LOGO\"",Ctr_EditingCtr->FullName); - Lgo_DrawLogo (HieLvl_CTR,-1L,"",20,NULL,true); - HTM_TD_End (); + /***** Center logo *****/ + HTM_TD_Begin ("title=\"%s\" class=\"HIE_LOGO\"",Ctr_EditingCtr->FullName); + Lgo_DrawLogo (HieLvl_CTR,-1L,"",20,NULL,true); + HTM_TD_End (); - /***** Place *****/ - HTM_TD_Begin ("class=\"LM\""); - HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE, - "name=\"PlcCod\" class=\"PLC_SEL\""); - HTM_OPTION (HTM_Type_STRING,"0", - Ctr_EditingCtr->PlcCod == 0,false, - "%s",Txt_Another_place); - for (NumPlc = 0; - NumPlc < Places->Num; - NumPlc++) - HTM_OPTION (HTM_Type_LONG,&Places->Lst[NumPlc].PlcCod, - Places->Lst[NumPlc].PlcCod == Ctr_EditingCtr->PlcCod,false, - "%s",Places->Lst[NumPlc].ShrtName); - HTM_SELECT_End (); - HTM_TD_End (); + /***** Place *****/ + HTM_TD_Begin ("class=\"LM\""); + HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE, + "name=\"PlcCod\" class=\"PLC_SEL\""); + HTM_OPTION (HTM_Type_STRING,"0", + Ctr_EditingCtr->PlcCod == 0,false, + "%s",Txt_Another_place); + for (NumPlc = 0; + NumPlc < Places->Num; + NumPlc++) + HTM_OPTION (HTM_Type_LONG,&Places->Lst[NumPlc].PlcCod, + Places->Lst[NumPlc].PlcCod == Ctr_EditingCtr->PlcCod,false, + "%s",Places->Lst[NumPlc].ShrtName); + HTM_SELECT_End (); + HTM_TD_End (); - /***** Center short name *****/ - HTM_TD_Begin ("class=\"LM\""); - HTM_INPUT_TEXT ("ShortName",Cns_HIERARCHY_MAX_CHARS_SHRT_NAME,Ctr_EditingCtr->ShrtName, - HTM_DONT_SUBMIT_ON_CHANGE, - "class=\"INPUT_SHORT_NAME\" required=\"required\""); - HTM_TD_End (); + /***** Center short name *****/ + HTM_TD_Begin ("class=\"LM\""); + HTM_INPUT_TEXT ("ShortName",Cns_HIERARCHY_MAX_CHARS_SHRT_NAME,Ctr_EditingCtr->ShrtName, + HTM_DONT_SUBMIT_ON_CHANGE, + "class=\"INPUT_SHORT_NAME\" required=\"required\""); + HTM_TD_End (); - /***** Center full name *****/ - HTM_TD_Begin ("class=\"LM\""); - HTM_INPUT_TEXT ("FullName",Cns_HIERARCHY_MAX_CHARS_FULL_NAME,Ctr_EditingCtr->FullName, - HTM_DONT_SUBMIT_ON_CHANGE, - "class=\"INPUT_FULL_NAME\" required=\"required\""); - HTM_TD_End (); + /***** Center full name *****/ + HTM_TD_Begin ("class=\"LM\""); + HTM_INPUT_TEXT ("FullName",Cns_HIERARCHY_MAX_CHARS_FULL_NAME,Ctr_EditingCtr->FullName, + HTM_DONT_SUBMIT_ON_CHANGE, + "class=\"INPUT_FULL_NAME\" required=\"required\""); + HTM_TD_End (); - /***** Center WWW *****/ - HTM_TD_Begin ("class=\"LM\""); - HTM_INPUT_URL ("WWW",Ctr_EditingCtr->WWW,HTM_DONT_SUBMIT_ON_CHANGE, - "class=\"INPUT_WWW_NARROW\" required=\"required\""); - HTM_TD_End (); + /***** Center WWW *****/ + HTM_TD_Begin ("class=\"LM\""); + HTM_INPUT_URL ("WWW",Ctr_EditingCtr->WWW,HTM_DONT_SUBMIT_ON_CHANGE, + "class=\"INPUT_WWW_NARROW\" required=\"required\""); + HTM_TD_End (); - /***** Number of users who claim to belong to this center *****/ - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (0); - HTM_TD_End (); + /***** Number of users who claim to belong to this center *****/ + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (0); + HTM_TD_End (); - /***** Number of degrees *****/ - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (0); - HTM_TD_End (); + /***** Number of degrees *****/ + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (0); + HTM_TD_End (); - /***** Number of users in courses of this center *****/ - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (0); - HTM_TD_End (); + /***** Number of users in courses of this center *****/ + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (0); + HTM_TD_End (); - /***** Center requester *****/ - HTM_TD_Begin ("class=\"DAT INPUT_REQUESTER LT\""); - Msg_WriteMsgAuthor (&Gbl.Usrs.Me.UsrDat,true,NULL); - HTM_TD_End (); + /***** Center requester *****/ + HTM_TD_Begin ("class=\"DAT INPUT_REQUESTER LT\""); + Msg_WriteMsgAuthor (&Gbl.Usrs.Me.UsrDat,true,NULL); + HTM_TD_End (); - /***** Center status *****/ - HTM_TD_Begin ("class=\"DAT LM\""); - HTM_TD_End (); + /***** Center status *****/ + HTM_TD_Begin ("class=\"DAT LM\""); + HTM_TD_End (); HTM_TR_End (); @@ -1718,45 +1726,45 @@ static void Ctr_PutHeadCentersForSeeing (bool OrderSelectable) HTM_TR_Begin (NULL); - HTM_TH_Empty (1); + HTM_TH_Empty (1); - for (Order = (Ctr_Order_t) 0; - Order <= (Ctr_Order_t) (Ctr_NUM_ORDERS - 1); - Order++) - { - HTM_TH_Begin (1,1,Order == Ctr_ORDER_BY_CENTER ? "LM" : - "RM"); - if (OrderSelectable) + for (Order = (Ctr_Order_t) 0; + Order <= (Ctr_Order_t) (Ctr_NUM_ORDERS - 1); + Order++) { - Frm_BeginForm (ActSeeCtr); - Par_PutHiddenParamUnsigned (NULL,"Order",(unsigned) Order); - HTM_BUTTON_SUBMIT_Begin (Txt_CENTERS_HELP_ORDER[Order], - Order == Ctr_ORDER_BY_CENTER ? "BT_LINK LM TIT_TBL" : - "BT_LINK RM TIT_TBL", - NULL); - if (Order == Gbl.Hierarchy.Ctrs.SelectedOrder) - HTM_U_Begin (); - } - HTM_Txt (Txt_CENTERS_ORDER[Order]); - if (OrderSelectable) - { - if (Order == Gbl.Hierarchy.Ctrs.SelectedOrder) - HTM_U_End (); - HTM_BUTTON_End (); - Frm_EndForm (); + HTM_TH_Begin (1,1,Order == Ctr_ORDER_BY_CENTER ? "LM" : + "RM"); + if (OrderSelectable) + { + Frm_BeginForm (ActSeeCtr); + Par_PutHiddenParamUnsigned (NULL,"Order",(unsigned) Order); + HTM_BUTTON_SUBMIT_Begin (Txt_CENTERS_HELP_ORDER[Order], + Order == Ctr_ORDER_BY_CENTER ? "BT_LINK LM TIT_TBL" : + "BT_LINK RM TIT_TBL", + NULL); + if (Order == Gbl.Hierarchy.Ctrs.SelectedOrder) + HTM_U_Begin (); + } + HTM_Txt (Txt_CENTERS_ORDER[Order]); + if (OrderSelectable) + { + if (Order == Gbl.Hierarchy.Ctrs.SelectedOrder) + HTM_U_End (); + HTM_BUTTON_End (); + Frm_EndForm (); + } + HTM_TH_End (); } + + HTM_TH (1,1,"LM",Txt_Place); + HTM_TH (1,1,"RM",Txt_Degrees_ABBREVIATION); + HTM_TH (1,1,"RM",Txt_Courses_ABBREVIATION); + HTM_TH_Begin (1,1,"RM"); + HTM_TxtF ("%s+",Txt_ROLES_PLURAL_BRIEF_Abc[Rol_TCH]); + HTM_BR (); + HTM_Txt (Txt_ROLES_PLURAL_BRIEF_Abc[Rol_STD]); HTM_TH_End (); - } - - HTM_TH (1,1,"LM",Txt_Place); - HTM_TH (1,1,"RM",Txt_Degrees_ABBREVIATION); - HTM_TH (1,1,"RM",Txt_Courses_ABBREVIATION); - HTM_TH_Begin (1,1,"RM"); - HTM_TxtF ("%s+",Txt_ROLES_PLURAL_BRIEF_Abc[Rol_TCH]); - HTM_BR (); - HTM_Txt (Txt_ROLES_PLURAL_BRIEF_Abc[Rol_STD]); - HTM_TH_End (); - HTM_TH_Empty (1); + HTM_TH_Empty (1); HTM_TR_End (); } @@ -1779,22 +1787,22 @@ static void Ctr_PutHeadCentersForEdition (void) HTM_TR_Begin (NULL); - HTM_TH_Empty (1); - HTM_TH (1,1,"RM",Txt_Code); - HTM_TH_Empty (1); - HTM_TH (1,1,"LM",Txt_Place); - HTM_TH (1,1,"LM",Txt_Short_name_of_the_center); - HTM_TH (1,1,"LM",Txt_Full_name_of_the_center); - HTM_TH (1,1,"LM",Txt_WWW); - HTM_TH (1,1,"RM",Txt_Users); - HTM_TH (1,1,"RM",Txt_Degrees_ABBREVIATION); - HTM_TH_Begin (1,1,"RM"); - HTM_TxtF ("%s+",Txt_ROLES_PLURAL_BRIEF_Abc[Rol_TCH]); - HTM_BR (); - HTM_Txt (Txt_ROLES_PLURAL_BRIEF_Abc[Rol_STD]); - HTM_TH_End (); - HTM_TH (1,1,"LM",Txt_Requester); - HTM_TH_Empty (1); + HTM_TH_Empty (1); + HTM_TH (1,1,"RM",Txt_Code); + HTM_TH_Empty (1); + HTM_TH (1,1,"LM",Txt_Place); + HTM_TH (1,1,"LM",Txt_Short_name_of_the_center); + HTM_TH (1,1,"LM",Txt_Full_name_of_the_center); + HTM_TH (1,1,"LM",Txt_WWW); + HTM_TH (1,1,"RM",Txt_Users); + HTM_TH (1,1,"RM",Txt_Degrees_ABBREVIATION); + HTM_TH_Begin (1,1,"RM"); + HTM_TxtF ("%s+",Txt_ROLES_PLURAL_BRIEF_Abc[Rol_TCH]); + HTM_BR (); + HTM_Txt (Txt_ROLES_PLURAL_BRIEF_Abc[Rol_STD]); + HTM_TH_End (); + HTM_TH (1,1,"LM",Txt_Requester); + HTM_TH_Empty (1); HTM_TR_End (); } @@ -1859,17 +1867,17 @@ static void Ctr_ReceiveFormRequestOrCreateCtr (unsigned Status) if (Ctr_EditingCtr->WWW[0]) { /***** If name of center was in database... *****/ - if (Ctr_CheckIfCtrNameExistsInIns ("ShortName",Ctr_EditingCtr->ShrtName,-1L,Gbl.Hierarchy.Ins.InsCod)) + if (Ctr_DB_CheckIfCtrNameExistsInIns ("ShortName",Ctr_EditingCtr->ShrtName,-1L,Gbl.Hierarchy.Ins.InsCod)) Ale_CreateAlert (Ale_WARNING,NULL, Txt_The_center_X_already_exists, Ctr_EditingCtr->ShrtName); - else if (Ctr_CheckIfCtrNameExistsInIns ("FullName",Ctr_EditingCtr->FullName,-1L,Gbl.Hierarchy.Ins.InsCod)) + else if (Ctr_DB_CheckIfCtrNameExistsInIns ("FullName",Ctr_EditingCtr->FullName,-1L,Gbl.Hierarchy.Ins.InsCod)) Ale_CreateAlert (Ale_WARNING,NULL, Txt_The_center_X_already_exists, Ctr_EditingCtr->FullName); else // Add new center to database { - Ctr_CreateCenter (Status); + Ctr_DB_CreateCenter (Status); Ale_CreateAlert (Ale_SUCCESS,NULL, Txt_Created_new_center_X, Ctr_EditingCtr->FullName); @@ -1888,7 +1896,7 @@ static void Ctr_ReceiveFormRequestOrCreateCtr (unsigned Status) /***************************** Create a new center ***************************/ /*****************************************************************************/ -static void Ctr_CreateCenter (unsigned Status) +static void Ctr_DB_CreateCenter (unsigned Status) { /***** Create a new center *****/ Ctr_EditingCtr->CtrCod = @@ -2114,7 +2122,7 @@ unsigned Ctr_GetCachedNumCtrsWithMapInIns (long InsCod) /******* Get number of centers (of the current institution) in a place *******/ /*****************************************************************************/ -unsigned Ctr_GetNumCtrsInPlc (long PlcCod) +unsigned Ctr_DB_GetNumCtrsInPlc (long PlcCod) { /***** Get number of centers (of the current institution) in a place *****/ return (unsigned) @@ -2254,23 +2262,23 @@ void Ctr_ListCtrsFound (MYSQL_RES **mysql_res,unsigned NumCtrs) NULL,Box_NOT_CLOSABLE,2); Str_FreeString (); - /***** Write heading *****/ - Ctr_PutHeadCentersForSeeing (false); // Order not selectable + /***** Write heading *****/ + Ctr_PutHeadCentersForSeeing (false); // Order not selectable - /***** List the centers (one row per center) *****/ - for (NumCtr = 1; - NumCtr <= NumCtrs; - NumCtr++) - { - /* Get next center */ - Ctr.CtrCod = DB_GetNextCode (*mysql_res); + /***** List the centers (one row per center) *****/ + for (NumCtr = 1; + NumCtr <= NumCtrs; + NumCtr++) + { + /* Get next center */ + Ctr.CtrCod = DB_GetNextCode (*mysql_res); - /* Get data of center */ - Ctr_GetDataOfCenterByCod (&Ctr); + /* Get data of center */ + Ctr_GetDataOfCenterByCod (&Ctr); - /* Write data of this center */ - Ctr_ListOneCenterForSeeing (&Ctr,NumCtr); - } + /* Write data of this center */ + Ctr_ListOneCenterForSeeing (&Ctr,NumCtr); + } /***** End table and box *****/ Box_BoxTableEnd (); diff --git a/swad_center.h b/swad_center.h index bcfc7bef7..0bdb7aa8b 100644 --- a/swad_center.h +++ b/swad_center.h @@ -118,14 +118,14 @@ void Ctr_PutParamCtrCod (long CtrCod); long Ctr_GetAndCheckParamOtherCtrCod (long MinCodAllowed); void Ctr_RemoveCenter (void); void Ctr_ChangeCtrPlc (void); -void Ctr_UpdateCtrPlcDB (long CtrCod,long NewPlcCod); +void Ctr_DB_UpdateCtrPlc (long CtrCod,long NewPlcCod); void Ctr_RenameCenterShort (void); void Ctr_RenameCenterFull (void); void Ctr_RenameCenter (struct Ctr_Center *Ctr,Cns_ShrtOrFullName_t ShrtOrFullName); -bool Ctr_CheckIfCtrNameExistsInIns (const char *FieldName,const char *Name, - long CtrCod,long InsCod); +bool Ctr_DB_CheckIfCtrNameExistsInIns (const char *FieldName,const char *Name, + long CtrCod,long InsCod); void Ctr_ChangeCtrWWW (void); -void Ctr_UpdateCtrWWWDB (long CtrCod,const char NewWWW[Cns_MAX_BYTES_WWW + 1]); +void Ctr_DB_UpdateCtrWWW (long CtrCod,const char NewWWW[Cns_MAX_BYTES_WWW + 1]); void Ctr_ChangeCtrStatus (void); void Ctr_ContEditAfterChgCtr (void); @@ -145,7 +145,7 @@ unsigned Ctr_GetCachedNumCtrsWithMapInSys (void); unsigned Ctr_GetCachedNumCtrsWithMapInCty (long CtyCod); unsigned Ctr_GetCachedNumCtrsWithMapInIns (long InsCod); -unsigned Ctr_GetNumCtrsInPlc (long PlcCod); +unsigned Ctr_DB_GetNumCtrsInPlc (long PlcCod); unsigned Ctr_GetCachedNumCtrsWithDegs (const char *SubQuery, HieLvl_Level_t Scope,long Cod); diff --git a/swad_center_config.c b/swad_center_config.c index 03f2215a8..22caa6f43 100644 --- a/swad_center_config.c +++ b/swad_center_config.c @@ -101,7 +101,7 @@ static void CtrCfg_NumUsrs (void); static void CtrCfg_NumDegs (void); static void CtrCfg_NumCrss (void); -static void CtrCfg_UpdateCtrInsDB (long CtrCod,long InsCod); +static void Ctr_DB_UpdateCtrIns (long CtrCod,long InsCod); static void CtrCfg_UpdateCtrCoordinateDB (long CtrCod, const char *CoordField,double NewCoord); @@ -173,54 +173,54 @@ static void CtrCfg_Configuration (bool PrintView) /**************************** Left part ***********************************/ HTM_DIV_Begin ("class=\"HIE_CFG_LEFT HIE_CFG_WIDTH\""); - /***** Begin table *****/ - HTM_TABLE_BeginWidePadding (2); + /***** Begin table *****/ + HTM_TABLE_BeginWidePadding (2); - /***** Institution *****/ - CtrCfg_Institution (PrintView,PutFormIns); + /***** Institution *****/ + CtrCfg_Institution (PrintView,PutFormIns); - /***** Center name *****/ - CtrCfg_FullName (PutFormName); - CtrCfg_ShrtName (PutFormName); + /***** Center name *****/ + CtrCfg_FullName (PutFormName); + CtrCfg_ShrtName (PutFormName); - /***** Place *****/ - CtrCfg_Place (PutFormPlc); + /***** Place *****/ + CtrCfg_Place (PutFormPlc); - /***** Coordinates *****/ - if (PutFormCoor) - { - CtrCfg_Latitude (); - CtrCfg_Longitude (); - CtrCfg_Altitude (); - } + /***** Coordinates *****/ + if (PutFormCoor) + { + CtrCfg_Latitude (); + CtrCfg_Longitude (); + CtrCfg_Altitude (); + } - /***** Center WWW *****/ - CtrCfg_WWW (PrintView,PutFormWWW); + /***** Center WWW *****/ + CtrCfg_WWW (PrintView,PutFormWWW); - /***** Shortcut to the center *****/ - CtrCfg_Shortcut (PrintView); + /***** Shortcut to the center *****/ + CtrCfg_Shortcut (PrintView); - if (PrintView) - /***** QR code with link to the center *****/ - CtrCfg_QR (); - else - { - /***** Number of users who claim to belong to this center, - number of degrees, - number of courses *****/ - CtrCfg_NumUsrs (); - CtrCfg_NumDegs (); - CtrCfg_NumCrss (); + if (PrintView) + /***** QR code with link to the center *****/ + CtrCfg_QR (); + else + { + /***** Number of users who claim to belong to this center, + number of degrees, + number of courses *****/ + CtrCfg_NumUsrs (); + CtrCfg_NumDegs (); + CtrCfg_NumCrss (); - /***** Number of users in courses of this center *****/ - HieCfg_NumUsrsInCrss (HieLvl_CTR,Gbl.Hierarchy.Ctr.CtrCod,Rol_TCH); - HieCfg_NumUsrsInCrss (HieLvl_CTR,Gbl.Hierarchy.Ctr.CtrCod,Rol_NET); - HieCfg_NumUsrsInCrss (HieLvl_CTR,Gbl.Hierarchy.Ctr.CtrCod,Rol_STD); - HieCfg_NumUsrsInCrss (HieLvl_CTR,Gbl.Hierarchy.Ctr.CtrCod,Rol_UNK); - } + /***** Number of users in courses of this center *****/ + HieCfg_NumUsrsInCrss (HieLvl_CTR,Gbl.Hierarchy.Ctr.CtrCod,Rol_TCH); + HieCfg_NumUsrsInCrss (HieLvl_CTR,Gbl.Hierarchy.Ctr.CtrCod,Rol_NET); + HieCfg_NumUsrsInCrss (HieLvl_CTR,Gbl.Hierarchy.Ctr.CtrCod,Rol_STD); + HieCfg_NumUsrsInCrss (HieLvl_CTR,Gbl.Hierarchy.Ctr.CtrCod,Rol_UNK); + } - /***** End table *****/ - HTM_TABLE_End (); + /***** End table *****/ + HTM_TABLE_End (); /***** End of left part *****/ HTM_DIV_End (); @@ -241,13 +241,13 @@ static void CtrCfg_Configuration (bool PrintView) { HTM_DIV_Begin ("class=\"HIE_CFG_RIGHT HIE_CFG_WIDTH\""); - /***** Center map *****/ - if (MapIsAvailable) - CtrCfg_Map (); + /***** Center map *****/ + if (MapIsAvailable) + CtrCfg_Map (); - /***** Center photo *****/ - if (PhotoExists) - CtrCfg_Photo (PrintView,PutFormPhoto,PutLink,PathPhoto); + /***** Center photo *****/ + if (PhotoExists) + CtrCfg_Photo (PrintView,PutFormPhoto,PutLink,PathPhoto); HTM_DIV_End (); } @@ -342,18 +342,18 @@ static void CtrCfg_Map (void) /***** Script to draw the map *****/ HTM_SCRIPT_Begin (NULL,NULL); - /* Let's create a map with pretty Mapbox Streets tiles */ - Map_CreateMap (CtrCfg_MAP_CONTAINER_ID,&Gbl.Hierarchy.Ctr.Coord,16); + /* Let's create a map with pretty Mapbox Streets tiles */ + Map_CreateMap (CtrCfg_MAP_CONTAINER_ID,&Gbl.Hierarchy.Ctr.Coord,16); - /* Add Mapbox Streets tile layer to our map */ - Map_AddTileLayer (); + /* Add Mapbox Streets tile layer to our map */ + Map_AddTileLayer (); - /* Add marker */ - Map_AddMarker (&Gbl.Hierarchy.Ctr.Coord); + /* Add marker */ + Map_AddMarker (&Gbl.Hierarchy.Ctr.Coord); - /* Add popup */ - Map_AddPopup (Gbl.Hierarchy.Ctr.ShrtName,Gbl.Hierarchy.Ins.ShrtName, - true); // Open + /* Add popup */ + Map_AddPopup (Gbl.Hierarchy.Ctr.ShrtName,Gbl.Hierarchy.Ins.ShrtName, + true); // Open HTM_SCRIPT_End (); } @@ -369,20 +369,20 @@ static void CtrCfg_Latitude (void) /***** Latitude *****/ HTM_TR_Begin (NULL); - /* Label */ - Frm_LabelColumn ("RT","Latitude",Txt_Latitude); + /* Label */ + Frm_LabelColumn ("RT","Latitude",Txt_Latitude); - /* Data */ - HTM_TD_Begin ("class=\"LB\""); - Frm_BeginForm (ActChgCtrLatCfg); - HTM_INPUT_FLOAT ("Latitude", - -90.0, // South Pole - 90.0, // North Pole - 0.0, // step="any" - Gbl.Hierarchy.Ctr.Coord.Latitude,false, - "class=\"INPUT_COORD\" required=\"required\""); - Frm_EndForm (); - HTM_TD_End (); + /* Data */ + HTM_TD_Begin ("class=\"LB\""); + Frm_BeginForm (ActChgCtrLatCfg); + HTM_INPUT_FLOAT ("Latitude", + -90.0, // South Pole + 90.0, // North Pole + 0.0, // step="any" + Gbl.Hierarchy.Ctr.Coord.Latitude,false, + "class=\"INPUT_COORD\" required=\"required\""); + Frm_EndForm (); + HTM_TD_End (); HTM_TR_End (); } @@ -394,20 +394,20 @@ static void CtrCfg_Longitude (void) /***** Longitude *****/ HTM_TR_Begin (NULL); - /* Label */ - Frm_LabelColumn ("RT","Longitude",Txt_Longitude); + /* Label */ + Frm_LabelColumn ("RT","Longitude",Txt_Longitude); - /* Data */ - HTM_TD_Begin ("class=\"LB\""); - Frm_BeginForm (ActChgCtrLgtCfg); - HTM_INPUT_FLOAT ("Longitude", - -180.0, // West - 180.0, // East - 0.0, // step="any" - Gbl.Hierarchy.Ctr.Coord.Longitude,false, - "class=\"INPUT_COORD\" required=\"required\""); - Frm_EndForm (); - HTM_TD_End (); + /* Data */ + HTM_TD_Begin ("class=\"LB\""); + Frm_BeginForm (ActChgCtrLgtCfg); + HTM_INPUT_FLOAT ("Longitude", + -180.0, // West + 180.0, // East + 0.0, // step="any" + Gbl.Hierarchy.Ctr.Coord.Longitude,false, + "class=\"INPUT_COORD\" required=\"required\""); + Frm_EndForm (); + HTM_TD_End (); HTM_TR_End (); } @@ -419,20 +419,20 @@ static void CtrCfg_Altitude (void) /***** Altitude *****/ HTM_TR_Begin (NULL); - /* Label */ - Frm_LabelColumn ("RT","Altitude",Txt_Altitude); + /* Label */ + Frm_LabelColumn ("RT","Altitude",Txt_Altitude); - /* Data */ - HTM_TD_Begin ("class=\"LB\""); - Frm_BeginForm (ActChgCtrAltCfg); - HTM_INPUT_FLOAT ("Altitude", - -413.0, // Dead Sea shore - 8848.0, // Mount Everest - 0.0, // step="any" - Gbl.Hierarchy.Ctr.Coord.Altitude,false, - "class=\"INPUT_COORD\" required=\"required\""); - Frm_EndForm (); - HTM_TD_End (); + /* Data */ + HTM_TD_Begin ("class=\"LB\""); + Frm_BeginForm (ActChgCtrAltCfg); + HTM_INPUT_FLOAT ("Altitude", + -413.0, // Dead Sea shore + 8848.0, // Mount Everest + 0.0, // step="any" + Gbl.Hierarchy.Ctr.Coord.Altitude,false, + "class=\"INPUT_COORD\" required=\"required\""); + Frm_EndForm (); + HTM_TD_End (); HTM_TR_End (); } @@ -459,44 +459,44 @@ static void CtrCfg_Photo (bool PrintView,bool PutForm,bool PutLink, /***** Photo image *****/ HTM_DIV_Begin ("class=\"DAT_SMALL CM\""); - if (PutLink) - HTM_A_Begin ("href=\"%s\" target=\"_blank\" class=\"DAT_N\"", - Gbl.Hierarchy.Ctr.WWW); - if (asprintf (&URL,"%s/%02u/%u", - Cfg_URL_CTR_PUBLIC, - (unsigned) (Gbl.Hierarchy.Ctr.CtrCod % 100), - (unsigned) Gbl.Hierarchy.Ctr.CtrCod) < 0) - Err_NotEnoughMemoryExit (); - if (asprintf (&Icon,"%u.jpg", - (unsigned) Gbl.Hierarchy.Ctr.CtrCod) < 0) - Err_NotEnoughMemoryExit (); - HTM_IMG (URL,Icon,Gbl.Hierarchy.Ctr.FullName, - "class=\"%s\"",PrintView ? "CENTER_PHOTO_PRINT CENTER_PHOTO_WIDTH" : - "CENTER_PHOTO_SHOW CENTER_PHOTO_WIDTH"); - free (Icon); - free (URL); - if (PutLink) - HTM_A_End (); + if (PutLink) + HTM_A_Begin ("href=\"%s\" target=\"_blank\" class=\"DAT_N\"", + Gbl.Hierarchy.Ctr.WWW); + if (asprintf (&URL,"%s/%02u/%u", + Cfg_URL_CTR_PUBLIC, + (unsigned) (Gbl.Hierarchy.Ctr.CtrCod % 100), + (unsigned) Gbl.Hierarchy.Ctr.CtrCod) < 0) + Err_NotEnoughMemoryExit (); + if (asprintf (&Icon,"%u.jpg", + (unsigned) Gbl.Hierarchy.Ctr.CtrCod) < 0) + Err_NotEnoughMemoryExit (); + HTM_IMG (URL,Icon,Gbl.Hierarchy.Ctr.FullName, + "class=\"%s\"",PrintView ? "CENTER_PHOTO_PRINT CENTER_PHOTO_WIDTH" : + "CENTER_PHOTO_SHOW CENTER_PHOTO_WIDTH"); + free (Icon); + free (URL); + if (PutLink) + HTM_A_End (); HTM_DIV_End (); /****** Photo attribution ******/ if (PutForm) { HTM_DIV_Begin ("class=\"CM\""); - Frm_BeginForm (ActChgCtrPhoAtt); - HTM_TEXTAREA_Begin ("id=\"AttributionArea\" name=\"Attribution\" rows=\"3\"" - " onchange=\"document.getElementById('%s').submit();return false;\"", - Gbl.Form.Id); - if (PhotoAttribution) - HTM_Txt (PhotoAttribution); - HTM_TEXTAREA_End (); - Frm_EndForm (); + Frm_BeginForm (ActChgCtrPhoAtt); + HTM_TEXTAREA_Begin ("id=\"AttributionArea\" name=\"Attribution\" rows=\"3\"" + " onchange=\"document.getElementById('%s').submit();return false;\"", + Gbl.Form.Id); + if (PhotoAttribution) + HTM_Txt (PhotoAttribution); + HTM_TEXTAREA_End (); + Frm_EndForm (); HTM_DIV_End (); } else if (PhotoAttribution) { HTM_DIV_Begin ("class=\"ATTRIBUTION\""); - HTM_Txt (PhotoAttribution); + HTM_Txt (PhotoAttribution); HTM_DIV_End (); } @@ -567,56 +567,58 @@ static void CtrCfg_Institution (bool PrintView,bool PutForm) /***** Institution *****/ HTM_TR_Begin (NULL); - /* Label */ - Frm_LabelColumn ("RT",PutForm ? "OthInsCod" : - NULL, - Txt_Institution); + /* Label */ + Frm_LabelColumn ("RT",PutForm ? "OthInsCod" : + NULL, + Txt_Institution); - /* Data */ - HTM_TD_Begin ("class=\"DAT LB\""); - if (PutForm) - { - /* Get list of institutions of the current country */ - Ins_GetBasicListOfInstitutions (Gbl.Hierarchy.Cty.CtyCod); + /* Data */ + HTM_TD_Begin ("class=\"DAT LB\""); + if (PutForm) + { + /* Get list of institutions of the current country */ + Ins_GetBasicListOfInstitutions (Gbl.Hierarchy.Cty.CtyCod); - /* Put form to select institution */ - Frm_BeginForm (ActChgCtrInsCfg); - HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE, - "id=\"OthInsCod\" name=\"OthInsCod\"" - " class=\"INPUT_SHORT_NAME\""); - for (NumIns = 0; - NumIns < Gbl.Hierarchy.Inss.Num; - NumIns++) - HTM_OPTION (HTM_Type_LONG,&Gbl.Hierarchy.Inss.Lst[NumIns].InsCod, - Gbl.Hierarchy.Inss.Lst[NumIns].InsCod == Gbl.Hierarchy.Ins.InsCod,false, - "%s",Gbl.Hierarchy.Inss.Lst[NumIns].ShrtName); - HTM_SELECT_End (); - Frm_EndForm (); + /* Put form to select institution */ + Frm_BeginForm (ActChgCtrInsCfg); + HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE, + "id=\"OthInsCod\" name=\"OthInsCod\"" + " class=\"INPUT_SHORT_NAME\""); + for (NumIns = 0; + NumIns < Gbl.Hierarchy.Inss.Num; + NumIns++) + HTM_OPTION (HTM_Type_LONG,&Gbl.Hierarchy.Inss.Lst[NumIns].InsCod, + Gbl.Hierarchy.Inss.Lst[NumIns].InsCod == Gbl.Hierarchy.Ins.InsCod,false, + "%s",Gbl.Hierarchy.Inss.Lst[NumIns].ShrtName); + HTM_SELECT_End (); + Frm_EndForm (); - /* Free list of institutions */ - Ins_FreeListInstitutions (); - } - else // I can not move center to another institution - { - if (!PrintView) - { - Frm_BeginFormGoTo (ActSeeInsInf); - Ins_PutParamInsCod (Gbl.Hierarchy.Ins.InsCod); - HTM_BUTTON_SUBMIT_Begin (Hie_BuildGoToMsg (Gbl.Hierarchy.Ins.ShrtName), - "BT_LINK LT DAT",NULL); - Hie_FreeGoToMsg (); - } - Lgo_DrawLogo (HieLvl_INS,Gbl.Hierarchy.Ins.InsCod,Gbl.Hierarchy.Ins.ShrtName, - 20,"LM",true); - HTM_NBSP (); - HTM_Txt (Gbl.Hierarchy.Ins.FullName); - if (!PrintView) - { - HTM_BUTTON_End (); - Frm_EndForm (); - } - } - HTM_TD_End (); + /* Free list of institutions */ + Ins_FreeListInstitutions (); + } + else // I can not move center to another institution + { + if (!PrintView) + { + Frm_BeginFormGoTo (ActSeeInsInf); + Ins_PutParamInsCod (Gbl.Hierarchy.Ins.InsCod); + HTM_BUTTON_SUBMIT_Begin (Hie_BuildGoToMsg (Gbl.Hierarchy.Ins.ShrtName), + "BT_LINK LT DAT",NULL); + Hie_FreeGoToMsg (); + } + + Lgo_DrawLogo (HieLvl_INS,Gbl.Hierarchy.Ins.InsCod,Gbl.Hierarchy.Ins.ShrtName, + 20,"LM",true); + HTM_NBSP (); + HTM_Txt (Gbl.Hierarchy.Ins.FullName); + + if (!PrintView) + { + HTM_BUTTON_End (); + Frm_EndForm (); + } + } + HTM_TD_End (); HTM_TR_End (); } @@ -664,41 +666,41 @@ static void CtrCfg_Place (bool PutForm) /***** Place *****/ HTM_TR_Begin (NULL); - /* Label */ - Frm_LabelColumn ("RT",PutForm ? "PlcCod" : - NULL, - Txt_Place); + /* Label */ + Frm_LabelColumn ("RT",PutForm ? "PlcCod" : + NULL, + Txt_Place); - /* Data */ - HTM_TD_Begin ("class=\"DAT LB\""); - if (PutForm) - { - /* Get list of places of the current institution */ - Places.SelectedOrder = Plc_ORDER_BY_PLACE; - Plc_GetListPlaces (&Places); + /* Data */ + HTM_TD_Begin ("class=\"DAT LB\""); + if (PutForm) + { + /* Get list of places of the current institution */ + Places.SelectedOrder = Plc_ORDER_BY_PLACE; + Plc_GetListPlaces (&Places); - /* Put form to select place */ - Frm_BeginForm (ActChgCtrPlcCfg); - HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE, - "name=\"PlcCod\" class=\"INPUT_SHORT_NAME\""); - HTM_OPTION (HTM_Type_STRING,"0", - Gbl.Hierarchy.Ctr.PlcCod == 0,false, - "%s",Txt_Another_place); - for (NumPlc = 0; - NumPlc < Places.Num; - NumPlc++) - HTM_OPTION (HTM_Type_LONG,&Places.Lst[NumPlc].PlcCod, - Places.Lst[NumPlc].PlcCod == Gbl.Hierarchy.Ctr.PlcCod,false, - "%s",Places.Lst[NumPlc].ShrtName); - HTM_SELECT_End (); - Frm_EndForm (); + /* Put form to select place */ + Frm_BeginForm (ActChgCtrPlcCfg); + HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE, + "name=\"PlcCod\" class=\"INPUT_SHORT_NAME\""); + HTM_OPTION (HTM_Type_STRING,"0", + Gbl.Hierarchy.Ctr.PlcCod == 0,false, + "%s",Txt_Another_place); + for (NumPlc = 0; + NumPlc < Places.Num; + NumPlc++) + HTM_OPTION (HTM_Type_LONG,&Places.Lst[NumPlc].PlcCod, + Places.Lst[NumPlc].PlcCod == Gbl.Hierarchy.Ctr.PlcCod,false, + "%s",Places.Lst[NumPlc].ShrtName); + HTM_SELECT_End (); + Frm_EndForm (); - /* Free list of places */ - Plc_FreeListPlaces (&Places); - } - else // I can not change center place - HTM_Txt (Plc.FullName); - HTM_TD_End (); + /* Free list of places */ + Plc_FreeListPlaces (&Places); + } + else // I can not change center place + HTM_Txt (Plc.FullName); + HTM_TD_End (); HTM_TR_End (); } @@ -741,13 +743,13 @@ static void CtrCfg_NumUsrs (void) /***** Number of users *****/ HTM_TR_Begin (NULL); - /* Label */ - Frm_LabelColumn ("RT",NULL,Txt_Users_of_the_center); + /* Label */ + Frm_LabelColumn ("RT",NULL,Txt_Users_of_the_center); - /* Data */ - HTM_TD_Begin ("class=\"DAT LB\""); - HTM_Unsigned (Usr_GetCachedNumUsrsWhoClaimToBelongToCtr (&Gbl.Hierarchy.Ctr)); - HTM_TD_End (); + /* Data */ + HTM_TD_Begin ("class=\"DAT LB\""); + HTM_Unsigned (Usr_GetCachedNumUsrsWhoClaimToBelongToCtr (&Gbl.Hierarchy.Ctr)); + HTM_TD_End (); HTM_TR_End (); } @@ -764,21 +766,21 @@ static void CtrCfg_NumDegs (void) /***** Number of degrees *****/ HTM_TR_Begin (NULL); - /* Label */ - Frm_LabelColumn ("RT",NULL,Txt_Degrees); + /* Label */ + Frm_LabelColumn ("RT",NULL,Txt_Degrees); - /* Data */ - HTM_TD_Begin ("class=\"LB\""); - Frm_BeginFormGoTo (ActSeeDeg); - Ctr_PutParamCtrCod (Gbl.Hierarchy.Ctr.CtrCod); - HTM_BUTTON_SUBMIT_Begin (Str_BuildStringStr (Txt_Degrees_of_CENTER_X, - Gbl.Hierarchy.Ctr.ShrtName), - "BT_LINK DAT",NULL); - Str_FreeString (); - HTM_Unsigned (Deg_GetCachedNumDegsInCtr (Gbl.Hierarchy.Ctr.CtrCod)); - HTM_BUTTON_End (); - Frm_EndForm (); - HTM_TD_End (); + /* Data */ + HTM_TD_Begin ("class=\"LB\""); + Frm_BeginFormGoTo (ActSeeDeg); + Ctr_PutParamCtrCod (Gbl.Hierarchy.Ctr.CtrCod); + HTM_BUTTON_SUBMIT_Begin (Str_BuildStringStr (Txt_Degrees_of_CENTER_X, + Gbl.Hierarchy.Ctr.ShrtName), + "BT_LINK DAT",NULL); + Str_FreeString (); + HTM_Unsigned (Deg_GetCachedNumDegsInCtr (Gbl.Hierarchy.Ctr.CtrCod)); + HTM_BUTTON_End (); + Frm_EndForm (); + HTM_TD_End (); HTM_TR_End (); } @@ -794,13 +796,13 @@ static void CtrCfg_NumCrss (void) /***** Number of courses *****/ HTM_TR_Begin (NULL); - /* Label */ - Frm_LabelColumn ("RT",NULL,Txt_Courses); + /* Label */ + Frm_LabelColumn ("RT",NULL,Txt_Courses); - /* Data */ - HTM_TD_Begin ("class=\"DAT LB\""); - HTM_Unsigned (Crs_GetCachedNumCrssInCtr (Gbl.Hierarchy.Ctr.CtrCod)); - HTM_TD_End (); + /* Data */ + HTM_TD_Begin ("class=\"DAT LB\""); + HTM_Unsigned (Crs_GetCachedNumCrssInCtr (Gbl.Hierarchy.Ctr.CtrCod)); + HTM_TD_End (); HTM_TR_End (); } @@ -848,31 +850,31 @@ void CtrCfg_RequestPhoto (void) /***** Begin form to upload photo *****/ Frm_BeginForm (ActRecCtrPho); - /***** Begin box *****/ - Box_BoxBegin (NULL,Txt_Photo, - NULL,NULL, - NULL,Box_NOT_CLOSABLE); + /***** Begin box *****/ + Box_BoxBegin (NULL,Txt_Photo, + NULL,NULL, + NULL,Box_NOT_CLOSABLE); - /***** Write help message *****/ - Ale_ShowAlert (Ale_INFO,"%s: %s
" - "%s: %u×%u %s", - Txt_Recommended_aspect_ratio, - Ctr_RECOMMENDED_ASPECT_RATIO, - Txt_Recommended_resolution, - Ctr_PHOTO_SAVED_MAX_WIDTH, - Ctr_PHOTO_SAVED_MAX_HEIGHT, - Txt_XxY_pixels_or_higher); + /***** Write help message *****/ + Ale_ShowAlert (Ale_INFO,"%s: %s
" + "%s: %u×%u %s", + Txt_Recommended_aspect_ratio, + Ctr_RECOMMENDED_ASPECT_RATIO, + Txt_Recommended_resolution, + Ctr_PHOTO_SAVED_MAX_WIDTH, + Ctr_PHOTO_SAVED_MAX_HEIGHT, + Txt_XxY_pixels_or_higher); - /***** Upload photo *****/ - HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_TxtColonNBSP (Txt_File_with_the_photo); - HTM_INPUT_FILE (Fil_NAME_OF_PARAM_FILENAME_ORG,"image/*", - HTM_SUBMIT_ON_CHANGE, - NULL); - HTM_LABEL_End (); + /***** Upload photo *****/ + HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + HTM_TxtColonNBSP (Txt_File_with_the_photo); + HTM_INPUT_FILE (Fil_NAME_OF_PARAM_FILENAME_ORG,"image/*", + HTM_SUBMIT_ON_CHANGE, + NULL); + HTM_LABEL_End (); - /***** End box *****/ - Box_BoxEnd (); + /***** End box *****/ + Box_BoxEnd (); /***** End form *****/ Frm_EndForm (); @@ -1037,7 +1039,7 @@ void CtrCfg_ChangeCtrIns (void) Ins_GetDataOfInstitutionByCod (&NewIns); /***** Check if it already exists a center with the same name in the new institution *****/ - if (Ctr_CheckIfCtrNameExistsInIns ("ShortName", + if (Ctr_DB_CheckIfCtrNameExistsInIns ("ShortName", Gbl.Hierarchy.Ctr.ShrtName, Gbl.Hierarchy.Ctr.CtrCod, NewIns.InsCod)) @@ -1045,7 +1047,7 @@ void CtrCfg_ChangeCtrIns (void) Ale_CreateAlert (Ale_WARNING,NULL, Txt_The_center_X_already_exists, Gbl.Hierarchy.Ctr.ShrtName); - else if (Ctr_CheckIfCtrNameExistsInIns ("FullName", + else if (Ctr_DB_CheckIfCtrNameExistsInIns ("FullName", Gbl.Hierarchy.Ctr.FullName, Gbl.Hierarchy.Ctr.CtrCod, NewIns.InsCod)) @@ -1056,7 +1058,7 @@ void CtrCfg_ChangeCtrIns (void) else { /***** Update institution in table of centers *****/ - CtrCfg_UpdateCtrInsDB (Gbl.Hierarchy.Ctr.CtrCod,NewIns.InsCod); + Ctr_DB_UpdateCtrIns (Gbl.Hierarchy.Ctr.CtrCod,NewIns.InsCod); Gbl.Hierarchy.Ctr.InsCod = Gbl.Hierarchy.Ins.InsCod = NewIns.InsCod; @@ -1075,7 +1077,7 @@ void CtrCfg_ChangeCtrIns (void) /******************* Update institution in table of centers ******************/ /*****************************************************************************/ -static void CtrCfg_UpdateCtrInsDB (long CtrCod,long InsCod) +static void Ctr_DB_UpdateCtrIns (long CtrCod,long InsCod) { /***** Update institution in table of centers *****/ DB_QueryUPDATE ("can not update the institution of a center", @@ -1099,7 +1101,7 @@ void CtrCfg_ChangeCtrPlc (void) NewPlcCod = Plc_GetParamPlcCod (); /***** Update place in table of centers *****/ - Ctr_UpdateCtrPlcDB (Gbl.Hierarchy.Ctr.CtrCod,NewPlcCod); + Ctr_DB_UpdateCtrPlc (Gbl.Hierarchy.Ctr.CtrCod,NewPlcCod); Gbl.Hierarchy.Ctr.PlcCod = NewPlcCod; /***** Write message to show the change made *****/ @@ -1222,7 +1224,7 @@ void CtrCfg_ChangeCtrWWW (void) if (NewWWW[0]) { /***** Update database changing old WWW by new WWW *****/ - Ctr_UpdateCtrWWWDB (Gbl.Hierarchy.Ctr.CtrCod,NewWWW); + Ctr_DB_UpdateCtrWWW (Gbl.Hierarchy.Ctr.CtrCod,NewWWW); Str_Copy (Gbl.Hierarchy.Ctr.WWW,NewWWW,sizeof (Gbl.Hierarchy.Ctr.WWW) - 1); /***** Write message to show the change made *****/ diff --git a/swad_center_database.c b/swad_center_database.c new file mode 100644 index 000000000..a79ca3b79 --- /dev/null +++ b/swad_center_database.c @@ -0,0 +1,70 @@ +// swad_center_database.c: centers operations with database + +/* + SWAD (Shared Workspace At a Distance), + is a web platform developed at the University of Granada (Spain), + and used to support university teaching. + + This file is part of SWAD core. + Copyright (C) 1999-2021 Antonio Caņas Vargas + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ +/*****************************************************************************/ +/********************************* Headers ***********************************/ +/*****************************************************************************/ + +// #include // For boolean type +// #include // For NULL +// #include // For free +// #include // For string functions + +#include "swad_center.h" +#include "swad_center_config.h" +// #include "swad_database.h" +// #include "swad_error.h" +// #include "swad_figure.h" +// #include "swad_figure_cache.h" +// #include "swad_form.h" +// #include "swad_forum.h" +#include "swad_global.h" +// #include "swad_hierarchy.h" +// #include "swad_hierarchy_level.h" +// #include "swad_HTML.h" +// #include "swad_logo.h" +// #include "swad_message.h" +// #include "swad_place.h" +// #include "swad_survey.h" + +/*****************************************************************************/ +/************** External global variables from others modules ****************/ +/*****************************************************************************/ + +extern struct Globals Gbl; + +/*****************************************************************************/ +/***************************** Private constants *****************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/******************************* Private types *******************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/***************************** Private variables *****************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/***************************** Private prototypes ****************************/ +/*****************************************************************************/ diff --git a/swad_center_database.h b/swad_center_database.h new file mode 100644 index 000000000..094a6981a --- /dev/null +++ b/swad_center_database.h @@ -0,0 +1,46 @@ +// swad_center_database.h: centers operations with database + +#ifndef _SWAD_CTR_DB +#define _SWAD_CTR_DB +/* + SWAD (Shared Workspace At a Distance), + is a web platform developed at the University of Granada (Spain), + and used to support university teaching. + + This file is part of SWAD core. + Copyright (C) 1999-2021 Antonio Caņas Vargas + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ +/*****************************************************************************/ +/********************************* Headers ***********************************/ +/*****************************************************************************/ + +// #include // To access MySQL databases + +// #include "swad_action.h" +// #include "swad_constant.h" +// #include "swad_degree.h" +// #include "swad_map.h" +// #include "swad_role_type.h" + +/*****************************************************************************/ +/************************** Public types and constants ***********************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/****************************** Public prototypes ****************************/ +/*****************************************************************************/ + +#endif diff --git a/swad_changelog.h b/swad_changelog.h index 95863caf5..12775ba92 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -602,13 +602,14 @@ TODO: FIX BUG, URGENT! En las fechas como par TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo. */ -#define Log_PLATFORM_VERSION "SWAD 20.87.1 (2021-06-01)" +#define Log_PLATFORM_VERSION "SWAD 20.88 (2021-06-02)" #define CSS_FILE "swad20.45.css" #define JS_FILE "swad20.69.1.js" /* TODO: Rename CENTRE to CENTER in help wiki. TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams + Version 20.88: Jun 02, 2021 New module swad_center_database for database queries related to centers. (312638 lines) Version 20.87.1: Jun 01, 2021 Database function moved from swad_calendar to swad_setting. (312549 lines) Version 20.87: Jun 01, 2021 New module swad_building_database for database queries related to buildings. (312538 lines) Version 20.86.1: May 31, 2021 Queries moved to module swad_call_for_exam_database. (312420 lines) diff --git a/swad_place.c b/swad_place.c index 07e7da4a7..34c675060 100644 --- a/swad_place.c +++ b/swad_place.c @@ -181,7 +181,7 @@ void Plc_SeePlaces (void) HTM_TR_End (); /***** Write centers (of the current institution) with other place *****/ - NumCtrsInOtherPlcs = Ctr_GetNumCtrsInPlc (0); + NumCtrsInOtherPlcs = Ctr_DB_GetNumCtrsInPlc (0); HTM_TR_Begin (NULL); HTM_TD_Begin ("class=\"DAT LM\"");